controlpanelui/src/cpplugins/personalizationplugin/src/cppersonalizationentryitemdata.cpp
changeset 19 36aa4756ee82
parent 12 624337f114fe
child 20 22d3abee08da
equal deleted inserted replaced
12:624337f114fe 19:36aa4756ee82
     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 #include "cppersonalizationentryitemdata.h"
       
    18 #include <xqaiwrequest.h>
       
    19 #include <cpitemdatahelper.h>
       
    20 
       
    21 CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(CpItemDataHelper &itemDataHelper,
       
    22                 const QString &text,
       
    23                 const QString &description,
       
    24                 const HbIcon &icon,
       
    25                 const HbDataFormModelItem *parent)
       
    26                 :CpSettingFormEntryItemData(itemDataHelper,text,description,
       
    27                                             icon,parent),mReq(0)
       
    28 {
       
    29 }
       
    30 CpPersonalizationEntryItemData::~CpPersonalizationEntryItemData()
       
    31 {
       
    32 }
       
    33 void CpPersonalizationEntryItemData::onLaunchView()
       
    34 {
       
    35     //launch media fetcher
       
    36     if (!mReq)
       
    37     {
       
    38         mReq = mAppMgr.create("com.nokia.services.media.Music", "fetch(QString)", true);
       
    39 
       
    40         if (!mReq)
       
    41         {
       
    42             return;
       
    43         }
       
    44         else
       
    45         {
       
    46             connect(mReq, SIGNAL(requestOk(const QVariant&)), SLOT(handleOk(const QVariant&)));
       
    47             connect(mReq, SIGNAL(requestError(int,const QString&)), SLOT(handleError(int,const QString&)));
       
    48         }
       
    49     }
       
    50 
       
    51     // Set arguments for request (music fetcher application title)
       
    52     QList<QVariant> args;
       
    53     args << QVariant( text() );
       
    54     mReq->setArguments(args);
       
    55 
       
    56     // Make the request
       
    57     if (!mReq->send())
       
    58     {
       
    59         //report error
       
    60         return;
       
    61     }
       
    62 }
       
    63 void CpPersonalizationEntryItemData::handleOk(const QVariant &result)
       
    64 {
       
    65     if (!result.canConvert<QString>())
       
    66     {
       
    67         setDescription( "Corrupt result" );
       
    68     }
       
    69     else
       
    70     {
       
    71         setDescription( result.value<QString>() );
       
    72     }
       
    73 }
       
    74 void CpPersonalizationEntryItemData::handleError(int errorCode, const QString& errorMessage)
       
    75 {
       
    76     //
       
    77     Q_UNUSED(errorCode);
       
    78     Q_UNUSED(errorMessage);
       
    79     setDescription("Error");
       
    80 }
       
    81 
       
    82 CpBaseSettingView *CpPersonalizationEntryItemData::createSettingView() const
       
    83 {
       
    84         return 0;
       
    85 }