messagingapp/msgnotifications/msgnotifier/src/msgnotifier.cpp
changeset 23 238255e8b033
child 25 84d9eb65b26f
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
       
     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 
       
    23 
       
    24 //USER INCLUDES
       
    25 #include "msgnotifier.h"
       
    26 #include "msgnotifier_p.h"
       
    27 #include "msgsimnumberdetector.h"
       
    28 #include "msgnotificationdialogpluginkeys.h"
       
    29 #include "debugtraces.h"
       
    30 
       
    31 // plugin ids 
       
    32 const QString InidcationsPluginId
       
    33                           ("com.nokia.messaging.indicatorplugin/1.0");
       
    34 const QString NotificationPluginId
       
    35                           ("com.nokia.messaging.newmsgnotificationdialog/1.0");
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // MsgNotifier::MsgNotifier
       
    39 // @see MsgNotifier.h
       
    40 // ----------------------------------------------------------------------------
       
    41 MsgNotifier::MsgNotifier(QObject* parent):QObject(parent)
       
    42     {
       
    43     QDEBUG_WRITE("MsgNotifier::MsgNotifier : Enter")
       
    44     
       
    45      d_ptr = new MsgNotifierPrivate(this); 
       
    46      
       
    47      mSimHandler = new MsgSimNumDetector();
       
    48      
       
    49     QDEBUG_WRITE("MsgNotifier::MsgNotifier : Exit") 
       
    50     }
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // MsgNotifier::~MsgNotifier
       
    54 // @see MsgNotifier.h
       
    55 // ----------------------------------------------------------------------------
       
    56 MsgNotifier::~MsgNotifier()
       
    57     {
       
    58     QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter")
       
    59     
       
    60     delete d_ptr;
       
    61     delete mSimHandler;
       
    62     
       
    63     QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter")
       
    64     }
       
    65 
       
    66 
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // MsgNotifier::displayNewMessageNotification
       
    70 // @see MsgNotifier.h
       
    71 // ----------------------------------------------------------------------------
       
    72 void MsgNotifier::displayNewMessageNotification(NotificationData& data)
       
    73     {  
       
    74     QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Enter")
       
    75     QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification :"
       
    76     																				" Printing notification data")
       
    77     
       
    78     QDEBUG_WRITE_FORMAT("First Name : ", data.mFirstName);
       
    79     QDEBUG_WRITE_FORMAT("Last Name : ", data.mLastName);
       
    80     QDEBUG_WRITE_FORMAT("Number : ", data.mContactNum);
       
    81     QDEBUG_WRITE_FORMAT("Description : ", data.mDescription);
       
    82     QDEBUG_WRITE_FORMAT("Type : ", data.mMsgType);
       
    83     QDEBUG_WRITE_FORMAT("Conv Id : ", data.mConversationId);
       
    84     
       
    85     // Fill data to variant map
       
    86     QVariantMap notificationData;
       
    87     notificationData[QString(KFirstNameKey)] = data.mFirstName ;
       
    88     notificationData[QString(KLastNameKey)] = data.mLastName;
       
    89     notificationData[QString(KNickNameKey)] = QString();
       
    90     notificationData[QString(KConversationIdKey)] = data.mConversationId;
       
    91     notificationData[QString(KMessageTypeKey)] = data.mMsgType;
       
    92     notificationData[QString(KMessageBodyKey)] =  data.mDescription;
       
    93     notificationData[QString(KMessageSubjectKey)] = QString();
       
    94     notificationData[QString(KContactAddressKey)] = data.mContactNum;
       
    95 
       
    96     // call device dialog to show notification
       
    97     HbDeviceDialog deviceDialog ;
       
    98     deviceDialog.show(NotificationPluginId,notificationData);
       
    99     
       
   100     QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Exit")
       
   101     }
       
   102 
       
   103     
       
   104 // ----------------------------------------------------------------------------
       
   105 // MsgNotifier::updateIndications
       
   106 // @see MsgNotifier.h
       
   107 // ----------------------------------------------------------------------------
       
   108 void MsgNotifier::updateIndications(int unreadCount)
       
   109     {
       
   110     QDEBUG_WRITE("MsgNotifier::updateIndications  Enter")
       
   111     
       
   112     HbIndicator indicator; 
       
   113     if(unreadCount)
       
   114         {
       
   115         indicator.activate(InidcationsPluginId);      
       
   116         QDEBUG_WRITE("MsgNotifier::updateIndications Indications Activated")
       
   117         }
       
   118     else
       
   119         {
       
   120         indicator.deactivate(InidcationsPluginId);
       
   121         QDEBUG_WRITE("MsgNotifier::updateIndications Indications Deactivated")
       
   122         }
       
   123     
       
   124     QDEBUG_WRITE("MsgNotifier::updateIndications  Exit")
       
   125     }
       
   126 
       
   127 
       
   128 //EOF