phoneplugins/phoneindicatorplugin/src/phoneindicatorinterface.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2  * Copyright (c) 2010 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:  
       
    15  *
       
    16  */
       
    17 
       
    18 #include "Phoneindicatorinterface.h"
       
    19 #include "phoneindicators.h"
       
    20 
       
    21 #include <QTime>
       
    22 #include <QStringList> 
       
    23 #ifdef Q_OS_SYMBIAN
       
    24 #include <logsservices.h>
       
    25 #include <xqservicerequest.h>
       
    26 #include <eikenv.h>
       
    27 #include <apgtask.h>
       
    28 
       
    29 #endif
       
    30 
       
    31 PhoneIndicatorInterface::PhoneIndicatorInterface(
       
    32                 const QString &indicatorType,
       
    33                 int typeIndex,
       
    34                 Interaction interaction) :
       
    35         HbIndicatorInterface( indicatorType, HbIndicatorInterface::NotificationCategory,
       
    36         (interaction == InteractionNone) ? NoInteraction : InteractionActivated),
       
    37         m_typeIndex(typeIndex),
       
    38         m_interaction(interaction),
       
    39         m_primaryText(IndicatorInfos[typeIndex].primaryText),
       
    40         m_secondaryText(IndicatorInfos[typeIndex].secondaryText),
       
    41         m_icon(IndicatorInfos[typeIndex].icon)
       
    42 
       
    43 {
       
    44 }
       
    45 
       
    46 PhoneIndicatorInterface::~PhoneIndicatorInterface()
       
    47 {
       
    48 
       
    49 }
       
    50 
       
    51 bool PhoneIndicatorInterface::handleInteraction(InteractionType type)
       
    52 {
       
    53     if (type == InteractionActivated) {
       
    54         switch (m_interaction) {
       
    55             
       
    56         case OpenMissedCallView: {
       
    57 #ifdef Q_OS_SYMBIAN
       
    58             XQServiceRequest snd("com.nokia.services.logsservices.starter",
       
    59                                  "start(int,bool)", false);
       
    60             snd << (int)LogsServices::ViewMissed;
       
    61             snd << false;
       
    62             int retValue;
       
    63             snd.send(retValue);
       
    64 
       
    65 //            LogsServices::start( LogsServices::ViewMissed, false );
       
    66 #endif
       
    67             }
       
    68             break;
       
    69         case SwitchBackToCall: {
       
    70 #ifdef Q_OS_SYMBIAN
       
    71             RWsSession& wsSession = CEikonEnv::Static()->WsSession();
       
    72             TApaTaskList taskList( wsSession );
       
    73             const TUid KUidPhoneApp = { 0x100058B3 };   // Phone application
       
    74             TApaTask task = taskList.FindApp(KUidPhoneApp);
       
    75             task.BringToForeground();
       
    76 #endif
       
    77             }
       
    78             break;
       
    79         case Deactivate:
       
    80             emit deactivate();
       
    81             break;
       
    82         default:
       
    83             return false;
       
    84         }
       
    85         emit dataChanged();
       
    86     }
       
    87     return false;
       
    88 }
       
    89 
       
    90 QVariant PhoneIndicatorInterface::indicatorData(int role) const
       
    91 {
       
    92     QVariantMap map = m_parameter.value<QVariantMap>();
       
    93     
       
    94     if (role == PrimaryTextRole) {
       
    95         return map.value( (QVariant(PrimaryTextRole)).toString()).toString();
       
    96     } else if (role == SecondaryTextRole ) {
       
    97         return map.value( (QVariant(SecondaryTextRole)).toString()).toString();
       
    98     } else if (role == MonoDecorationNameRole) {
       
    99         return m_icon;
       
   100     } else if (role == DecorationNameRole) {
       
   101         return map.value( (QVariant(DecorationNameRole)).toString()).toString();
       
   102     }
       
   103     return QVariant();
       
   104 }
       
   105 
       
   106 bool PhoneIndicatorInterface::handleClientRequest(RequestType type, const QVariant &parameter)
       
   107 {
       
   108     bool handled(false);
       
   109     switch (type) {
       
   110         
       
   111     case RequestActivate:
       
   112         if (m_parameter != parameter) {
       
   113             m_parameter = parameter;
       
   114             emit dataChanged();
       
   115         }
       
   116         handled =  true;
       
   117         break;
       
   118     default:
       
   119         m_parameter.clear();
       
   120     }
       
   121 
       
   122     return handled;
       
   123 }