phonebookui/phonebookservices/src/cntserviceproviderfetch.cpp
changeset 59 a642906a277a
child 75 4ecbe3571b5a
equal deleted inserted replaced
47:7cbcb2896f0e 59:a642906a277a
       
     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 "cntserviceproviderfetch.h"
       
    19 #include "cntservices.h"
       
    20 #include "cntservicestrings.h"
       
    21 #include "cntdebug.h"
       
    22 
       
    23 #include <qapplication.h>
       
    24 #include <QPixmap>
       
    25 #include <QFile>
       
    26 #include <QUrl>
       
    27 
       
    28 CntServiceProviderFetch::CntServiceProviderFetch(CntServices& aServices, QObject *parent):
       
    29     XQServiceProvider(QLatin1String(KCntServiceInterfaceFetch), parent),
       
    30     mServices(aServices),
       
    31     mCurrentRequestIndex(0)
       
    32 {
       
    33     CNT_ENTRY
       
    34     publishAll();
       
    35     connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp()));
       
    36     CNT_EXIT
       
    37 }
       
    38 
       
    39 CntServiceProviderFetch::~CntServiceProviderFetch()
       
    40 {
       
    41     CNT_ENTRY
       
    42     CNT_EXIT
       
    43 }
       
    44 
       
    45 void CntServiceProviderFetch::multiFetch(const QString &title, const QString &action )
       
    46 {
       
    47     CNT_ENTRY
       
    48     mCurrentRequestIndex = setCurrentRequestAsync();
       
    49     mServices.setQuittable(requestInfo().isEmbedded());
       
    50     mServices.multiFetch( title, action, *this );
       
    51     CNT_EXIT
       
    52 }
       
    53 
       
    54 void CntServiceProviderFetch::singleFetch(const QString &title, const QString &action )
       
    55 {
       
    56     CNT_ENTRY
       
    57     mCurrentRequestIndex = setCurrentRequestAsync();
       
    58     mServices.setQuittable(requestInfo().isEmbedded());
       
    59     mServices.singleFetch( title, action, *this );
       
    60     CNT_EXIT
       
    61 }
       
    62 
       
    63 void CntServiceProviderFetch::CompleteServiceAndCloseApp(const QVariant& retValue)
       
    64 {
       
    65     CNT_ENTRY
       
    66     if ( mCurrentRequestIndex != 0 )
       
    67     {
       
    68         connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
    69         const bool success = completeRequest(mCurrentRequestIndex, retValue);
       
    70         if ( !success )
       
    71         {
       
    72             CNT_LOG_ARGS("Failed to complete highway request.");
       
    73         }
       
    74         mCurrentRequestIndex = 0;
       
    75     }
       
    76     CNT_EXIT
       
    77 }
       
    78