/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include "cntserviceproviderold2.h"
#include "cntservices.h"
#include "cntdebug.h"
#include <qapplication.h>
#include <QPixmap>
#include <QFile>
#include <QUrl>
CntServiceProviderOld2::CntServiceProviderOld2(CntServices& aServices, QObject *parent):
XQServiceProvider(QLatin1String("phonebookservices.Fetch"), parent),
mServices(aServices),
mCurrentRequestIndex(0)
{
CNT_ENTRY
publishAll();
connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp()));
CNT_EXIT
}
CntServiceProviderOld2::~CntServiceProviderOld2()
{
CNT_ENTRY
CNT_EXIT
}
/*!
Launch fetch service with given parameters. OLD INTERFACE.
*/
void CntServiceProviderOld2::fetch(const QString &title, const QString &action, const QString& /*filter*/)
{
CNT_ENTRY
// Ignore the filter parameter
mCurrentRequestIndex = setCurrentRequestAsync();
mServices.setQuitable(requestInfo().isEmbedded());
mServices.multiFetch( title, action, *this );
CNT_EXIT
}
/*
Launch fetch service with given parameters. Fetching mode is No-select by default. OLD INTERFACE.
*/
void CntServiceProviderOld2::Dofetch(const QString &title, const QString &action, const QString& /*filter*/, const QString& /*mode*/)
{
CNT_ENTRY
// Ignore the filter parameter
// Ignoring fourth argument, because it's not needed. DoFetch() by old contract is only for single-fetching.
mCurrentRequestIndex = setCurrentRequestAsync();
mServices.setQuitable(requestInfo().isEmbedded());
mServices.singleFetch( title, action, *this );
CNT_EXIT
}
/*
Launch new contact editor with a given detail
*/
void CntServiceProviderOld2::editCreateNew(const QString& definitionName, const QString& value)
{
CNT_ENTRY
mCurrentRequestIndex = setCurrentRequestAsync();
mServices.setQuitable(requestInfo().isEmbedded());
mServices.editCreateNew( definitionName, value, *this );
}
void CntServiceProviderOld2::editCreateNew(const QString &vCardFile)
{
CNT_ENTRY
mCurrentRequestIndex = setCurrentRequestAsync();
mServices.setQuitable(requestInfo().isEmbedded());
mServices.editCreateNewFromVCard( vCardFile, *this );
CNT_EXIT
}
/*!
Launch contact selection view with a given detail (selecting detail there opens the editor and adds the new detail)
*/
void CntServiceProviderOld2::editUpdateExisting(const QString &definitionName, const QString &value)
{
CNT_ENTRY
mCurrentRequestIndex = setCurrentRequestAsync();
mServices.setQuitable(requestInfo().isEmbedded());
mServices.editUpdateExisting( definitionName, value, *this );
CNT_EXIT
}
/*!
Launch communication launcher view for the contact with the given ID (QContactLocalId -> int)
*/
void CntServiceProviderOld2::open(int contactId)
{
CNT_ENTRY
mCurrentRequestIndex = setCurrentRequestAsync();
mServices.setQuitable(requestInfo().isEmbedded());
mServices.launchContactCard( contactId, *this );
CNT_EXIT
}
/*!
Launch temporary communication launcher view with the given detail.
*/
void CntServiceProviderOld2::open(const QString &definitionName, const QString &value)
{
CNT_ENTRY
mCurrentRequestIndex = setCurrentRequestAsync();
mServices.setQuitable(requestInfo().isEmbedded());
mServices.launchTemporaryContactCard( definitionName, value, *this ); // definitionName = field type value = actual field value for prefilling editor
CNT_EXIT
}
void CntServiceProviderOld2::CompleteServiceAndCloseApp(const QVariant& retValue)
{
CNT_ENTRY
connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
if ( mCurrentRequestIndex != 0 )
{
CNT_LOG_ARGS("next, completing request.")
const bool success = completeRequest(mCurrentRequestIndex, retValue);
if ( !success )
{
CNT_LOG_ARGS("Failed to complete highway request.");
}
mCurrentRequestIndex = 0;
}
CNT_EXIT
}
// end of file