phonebookui/phonebookservices/src/cntserviceproviderfetch.cpp
author hgs
Fri, 23 Jul 2010 12:43:48 +0300
changeset 53 e6aff7b69165
parent 50 77bc263e1626
child 72 6abfb1094884
permissions -rw-r--r--
201029
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
 * All rights reserved.
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
 *
hgs
parents:
diff changeset
     9
 * Initial Contributors:
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
 *
hgs
parents:
diff changeset
    12
 * Contributors:
hgs
parents:
diff changeset
    13
 *
hgs
parents:
diff changeset
    14
 * Description:
hgs
parents:
diff changeset
    15
 *
hgs
parents:
diff changeset
    16
 */
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "cntserviceproviderfetch.h"
hgs
parents:
diff changeset
    19
#include "cntservices.h"
hgs
parents:
diff changeset
    20
#include "cntservicestrings.h"
hgs
parents:
diff changeset
    21
#include "cntdebug.h"
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
#include <qapplication.h>
hgs
parents:
diff changeset
    24
#include <QPixmap>
hgs
parents:
diff changeset
    25
#include <QFile>
hgs
parents:
diff changeset
    26
#include <QUrl>
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
CntServiceProviderFetch::CntServiceProviderFetch(CntServices& aServices, QObject *parent):
hgs
parents:
diff changeset
    29
    XQServiceProvider(QLatin1String(KCntServiceInterfaceFetch), parent),
hgs
parents:
diff changeset
    30
    mServices(aServices),
hgs
parents:
diff changeset
    31
    mCurrentRequestIndex(0)
hgs
parents:
diff changeset
    32
{
hgs
parents:
diff changeset
    33
    CNT_ENTRY
hgs
parents:
diff changeset
    34
    publishAll();
hgs
parents:
diff changeset
    35
    connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp()));
hgs
parents:
diff changeset
    36
    CNT_EXIT
hgs
parents:
diff changeset
    37
}
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
CntServiceProviderFetch::~CntServiceProviderFetch()
hgs
parents:
diff changeset
    40
{
hgs
parents:
diff changeset
    41
    CNT_ENTRY
hgs
parents:
diff changeset
    42
    CNT_EXIT
hgs
parents:
diff changeset
    43
}
hgs
parents:
diff changeset
    44
hgs
parents:
diff changeset
    45
void CntServiceProviderFetch::multiFetch(const QString &title, const QString &action )
hgs
parents:
diff changeset
    46
{
hgs
parents:
diff changeset
    47
    CNT_ENTRY
hgs
parents:
diff changeset
    48
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
    49
    mServices.setQuittable(requestInfo().isEmbedded());
50
hgs
parents:
diff changeset
    50
    mServices.multiFetch( title, action, *this );
hgs
parents:
diff changeset
    51
    CNT_EXIT
hgs
parents:
diff changeset
    52
}
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
void CntServiceProviderFetch::singleFetch(const QString &title, const QString &action )
hgs
parents:
diff changeset
    55
{
hgs
parents:
diff changeset
    56
    CNT_ENTRY
hgs
parents:
diff changeset
    57
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
    58
    mServices.setQuittable(requestInfo().isEmbedded());
50
hgs
parents:
diff changeset
    59
    mServices.singleFetch( title, action, *this );
hgs
parents:
diff changeset
    60
    CNT_EXIT
hgs
parents:
diff changeset
    61
}
hgs
parents:
diff changeset
    62
hgs
parents:
diff changeset
    63
void CntServiceProviderFetch::CompleteServiceAndCloseApp(const QVariant& retValue)
hgs
parents:
diff changeset
    64
{
hgs
parents:
diff changeset
    65
    CNT_ENTRY
hgs
parents:
diff changeset
    66
    if ( mCurrentRequestIndex != 0 )
hgs
parents:
diff changeset
    67
    {
53
hgs
parents: 50
diff changeset
    68
        connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
50
hgs
parents:
diff changeset
    69
        const bool success = completeRequest(mCurrentRequestIndex, retValue);
hgs
parents:
diff changeset
    70
        if ( !success )
hgs
parents:
diff changeset
    71
        {
hgs
parents:
diff changeset
    72
            CNT_LOG_ARGS("Failed to complete highway request.");
hgs
parents:
diff changeset
    73
        }
hgs
parents:
diff changeset
    74
        mCurrentRequestIndex = 0;
hgs
parents:
diff changeset
    75
    }
hgs
parents:
diff changeset
    76
    CNT_EXIT
hgs
parents:
diff changeset
    77
}
hgs
parents:
diff changeset
    78