phoneapp/phoneuiqtviewadapter/src/phonecommandextensionwrapper.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     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:  Wraps phone command extensions.
       
    15 */
       
    16 
       
    17 #include "phonecommandextensionwrapper.h"
       
    18 #include "qtphonelog.h"
       
    19 #include <xqplugin.h>
       
    20 #include <xqpluginloader.h>
       
    21 #include <pevirtualengine.h>
       
    22 
       
    23 
       
    24 PhoneCommandExtensionWrapper::PhoneCommandExtensionWrapper(int pluginUid) :
       
    25     m_plugin(0),m_pluginUid(pluginUid)
       
    26 {
       
    27     PHONE_DEBUG("PhoneCommandExtensionWrapper::PhoneMenuExtensionWrapper");
       
    28     XQPluginLoader pluginLoader;
       
    29     pluginLoader.setUid(m_pluginUid);
       
    30 
       
    31     QObject *plugin = pluginLoader.instance();
       
    32 
       
    33     if (plugin) {
       
    34         m_plugin = qobject_cast<XQTelUiCommandExtension*>(plugin);
       
    35     }
       
    36 }
       
    37 
       
    38 PhoneCommandExtensionWrapper::~PhoneCommandExtensionWrapper()
       
    39 {
       
    40     PHONE_DEBUG("PhoneCommandExtensionWrapper::~PhoneCommandExtensionWrapper");
       
    41     release();
       
    42 }
       
    43 
       
    44 int PhoneCommandExtensionWrapper::pluginUid()
       
    45 {
       
    46     return m_pluginUid;
       
    47 }
       
    48 
       
    49 void PhoneCommandExtensionWrapper::modifyMenuCommandList(
       
    50         const QList<XQTelUiCommandExtension::CallInfo> &callInfo,
       
    51         QList<int> &menuCmdList)
       
    52 {
       
    53     if (m_plugin) {
       
    54         m_plugin->modifyMenuCommandList(callInfo, menuCmdList);
       
    55     }
       
    56 }
       
    57 
       
    58 void PhoneCommandExtensionWrapper::modifyPushButtonCommandList(
       
    59         const QList<XQTelUiCommandExtension::CallInfo> &callInfo,
       
    60         QList<int> &buttonCmdList)
       
    61 {
       
    62     if (m_plugin) {
       
    63         m_plugin->modifyPushButtonCommandList(callInfo, buttonCmdList);
       
    64     }
       
    65 }
       
    66 
       
    67 void PhoneCommandExtensionWrapper::addMenuActions(
       
    68         const QList<XQTelUiCommandExtension::CallInfo> &callInfo,
       
    69         QList<HbAction*> &menuActions)
       
    70 {
       
    71     if (m_plugin) {
       
    72         m_plugin->addMenuActions(callInfo,menuActions);
       
    73     }
       
    74 }
       
    75 
       
    76 void PhoneCommandExtensionWrapper::releaseMenu()
       
    77 {
       
    78     if (m_plugin) {
       
    79         m_plugin->releaseMenu();
       
    80     }
       
    81 }
       
    82 
       
    83 void PhoneCommandExtensionWrapper::release()
       
    84 {
       
    85     if (m_plugin) {
       
    86         m_plugin->release();
       
    87         m_plugin = 0;
       
    88     }
       
    89 }
       
    90 
       
    91 void PhoneCommandExtensionWrapper::getCallInfoList(
       
    92         QList<XQTelUiCommandExtension::CallInfo> &callInfo,
       
    93         QMap<int,int> callStates,
       
    94         QMap<int,int> serviceIds,
       
    95         int expandedCall )
       
    96 {
       
    97     for (int i=0;i<callStates.keys().count();++i) {
       
    98         XQTelUiCommandExtension::CallInfo info;
       
    99         info.mCallState = mapCallState(callStates.values().at(i));
       
   100         info.mServiceId = serviceIds.value(callStates.keys().at(i));
       
   101         info.mIsExpanded = (expandedCall == callStates.keys().at(i));
       
   102         callInfo.append(info);
       
   103     }
       
   104 }
       
   105 
       
   106 XQTelUiCommandExtension::CallState PhoneCommandExtensionWrapper::mapCallState(
       
   107         int callState )
       
   108 {
       
   109     XQTelUiCommandExtension::CallState state(XQTelUiCommandExtension::None);
       
   110 
       
   111     switch( callState ) {
       
   112     case EPEStateDisconnecting: {
       
   113         state = XQTelUiCommandExtension::Disconnecting;
       
   114     }
       
   115     break;
       
   116 
       
   117     case EPEStateRinging: {
       
   118         state = XQTelUiCommandExtension::Incoming;
       
   119     }
       
   120     break;
       
   121 
       
   122     case EPEStateDialing:
       
   123     case EPEStateConnecting: {
       
   124         state = XQTelUiCommandExtension::Outgoing;
       
   125     }
       
   126     break;
       
   127 
       
   128     case EPEStateConnected:
       
   129     case EPEStateConnectedConference: {
       
   130         state = XQTelUiCommandExtension::Active;
       
   131     }
       
   132     break;
       
   133 
       
   134     case EPEStateHeld:
       
   135     case EPEStateHeldConference: {
       
   136         state = XQTelUiCommandExtension::OnHold;
       
   137     }
       
   138     break;
       
   139 
       
   140     case EPEStateUnknown:
       
   141     case EPEStateIdle:
       
   142     case EPEStateConferenceIdle:
       
   143     break;
       
   144 
       
   145     default:
       
   146     break;
       
   147     }
       
   148 
       
   149     return state;
       
   150 }
       
   151 
       
   152