phonebookengines/cntactions/src/cntmessageaction.cpp
changeset 40 b46a585f6909
child 47 7cbcb2896f0e
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cntmessageaction.h"
       
    19 
       
    20 #include <xqservicerequest.h>
       
    21 #include <qcontactphonenumber.h>
       
    22 #include <qcontactfilters.h>
       
    23 
       
    24 //Action class
       
    25 CntMessageAction::CntMessageAction() : 
       
    26     CntAction("message")
       
    27 {
       
    28 }
       
    29 
       
    30 CntMessageAction::~CntMessageAction()
       
    31 {
       
    32 }
       
    33 
       
    34 CntMessageAction* CntMessageAction::clone() const
       
    35 {
       
    36 	 return new CntMessageAction();
       
    37 }
       
    38 
       
    39 bool CntMessageAction::isDetailSupported(const QContactDetail &detail, const QContact &/*contact*/) const
       
    40 {
       
    41     if (detail.definitionName() == QContactPhoneNumber::DefinitionName 
       
    42         && !static_cast<QContactPhoneNumber>(detail).subTypes().isEmpty())
       
    43     {
       
    44         return (static_cast<QContactPhoneNumber>(detail).subTypes().first() == QContactPhoneNumber::SubTypeMobile);
       
    45     }
       
    46     else
       
    47     {
       
    48         return false;
       
    49     }
       
    50 }
       
    51 
       
    52 QList<QContactDetail> CntMessageAction::supportedDetails(const QContact& contact) const
       
    53 {
       
    54     QList<QContactDetail> details = contact.details(QContactPhoneNumber::DefinitionName);
       
    55     QList<QContactDetail> supportedDetails;
       
    56     for (int i = 0; i < details.count(); i++)
       
    57     {
       
    58         if (!static_cast<QContactPhoneNumber>(details[i]).subTypes().isEmpty() 
       
    59             && static_cast<QContactPhoneNumber>(details[i]).subTypes().first() == QContactPhoneNumber::SubTypeMobile)
       
    60         {
       
    61             supportedDetails.append(details[i]);
       
    62         }
       
    63     } 
       
    64     return supportedDetails;
       
    65 }
       
    66 
       
    67 void CntMessageAction::performAction()
       
    68 {
       
    69     QString service("com.nokia.services.hbserviceprovider.conversationview");
       
    70     QString type("send(QString,qint32,QString)");
       
    71     
       
    72     performNumberAction(service, type);
       
    73 }
       
    74 
       
    75 
       
    76