phonebookui/phonebookservices/src/cntserviceproviderold.cpp
author hgs
Mon, 23 Aug 2010 16:06:28 +0300
changeset 61 d30183af6ca6
parent 53 e6aff7b69165
child 72 6abfb1094884
permissions -rw-r--r--
201033
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 "cntserviceproviderold.h"
hgs
parents:
diff changeset
    19
#include "cntservices.h"
hgs
parents:
diff changeset
    20
#include "cntdebug.h"
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
#include <qapplication.h>
hgs
parents:
diff changeset
    23
#include <QPixmap>
hgs
parents:
diff changeset
    24
#include <QFile>
hgs
parents:
diff changeset
    25
#include <QUrl>
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
CntServiceProviderOld::CntServiceProviderOld(CntServices& aServices, QObject *parent):
hgs
parents:
diff changeset
    28
    XQServiceProvider(QLatin1String("com.nokia.services.phonebookservices.Fetch"), parent),
hgs
parents:
diff changeset
    29
    mServices(aServices),
hgs
parents:
diff changeset
    30
    mCurrentRequestIndex(0)
hgs
parents:
diff changeset
    31
{
hgs
parents:
diff changeset
    32
    CNT_ENTRY
hgs
parents:
diff changeset
    33
    publishAll();
hgs
parents:
diff changeset
    34
    connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp()));
hgs
parents:
diff changeset
    35
    CNT_EXIT
hgs
parents:
diff changeset
    36
}
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
CntServiceProviderOld::~CntServiceProviderOld()
hgs
parents:
diff changeset
    39
{
hgs
parents:
diff changeset
    40
    CNT_ENTRY
hgs
parents:
diff changeset
    41
    CNT_EXIT
hgs
parents:
diff changeset
    42
}
hgs
parents:
diff changeset
    43
hgs
parents:
diff changeset
    44
/*!
hgs
parents:
diff changeset
    45
Launch fetch service with given parameters. OLD INTERFACE.
hgs
parents:
diff changeset
    46
*/
hgs
parents:
diff changeset
    47
void CntServiceProviderOld::fetch(const QString &title, const QString &action, const QString& /*filter*/)
hgs
parents:
diff changeset
    48
{
hgs
parents:
diff changeset
    49
    CNT_ENTRY
hgs
parents:
diff changeset
    50
    // Ignore the filter parameter
hgs
parents:
diff changeset
    51
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
    52
    mServices.setQuittable(requestInfo().isEmbedded());
50
hgs
parents:
diff changeset
    53
    mServices.multiFetch( title, action, *this );
hgs
parents:
diff changeset
    54
    CNT_EXIT
hgs
parents:
diff changeset
    55
}
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
hgs
parents:
diff changeset
    58
/*
hgs
parents:
diff changeset
    59
Launch fetch service with given parameters. Fetching mode is No-select by default. OLD INTERFACE.
hgs
parents:
diff changeset
    60
*/
hgs
parents:
diff changeset
    61
void CntServiceProviderOld::Dofetch(const QString &title, const QString &action, const QString& /*filter*/, const QString& /*mode*/)
hgs
parents:
diff changeset
    62
{
hgs
parents:
diff changeset
    63
    CNT_ENTRY
hgs
parents:
diff changeset
    64
    // Ignore the filter parameter
hgs
parents:
diff changeset
    65
    // Ignoring fourth argument, because it's not needed. DoFetch() by old contract is only for single-fetching.
hgs
parents:
diff changeset
    66
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
    67
    mServices.setQuittable(requestInfo().isEmbedded());
50
hgs
parents:
diff changeset
    68
    mServices.singleFetch( title, action, *this );
hgs
parents:
diff changeset
    69
    CNT_EXIT
hgs
parents:
diff changeset
    70
}
hgs
parents:
diff changeset
    71
hgs
parents:
diff changeset
    72
hgs
parents:
diff changeset
    73
/*
hgs
parents:
diff changeset
    74
Launch new contact editor with a given detail
hgs
parents:
diff changeset
    75
*/
hgs
parents:
diff changeset
    76
void CntServiceProviderOld::editCreateNew(const QString& definitionName, const QString& value)
hgs
parents:
diff changeset
    77
{
hgs
parents:
diff changeset
    78
    CNT_ENTRY
hgs
parents:
diff changeset
    79
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
    80
    mServices.setQuittable(requestInfo().isEmbedded());
hgs
parents: 50
diff changeset
    81
    mServices.editCreateNew( definitionName, value, *this, false ); // defaultForOnlineAccountIsImpp = false
50
hgs
parents:
diff changeset
    82
    CNT_EXIT
hgs
parents:
diff changeset
    83
}
hgs
parents:
diff changeset
    84
hgs
parents:
diff changeset
    85
void CntServiceProviderOld::editCreateNew(const QString &vCardFile)
hgs
parents:
diff changeset
    86
{
hgs
parents:
diff changeset
    87
    CNT_ENTRY
hgs
parents:
diff changeset
    88
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
    89
    mServices.setQuittable(requestInfo().isEmbedded());
50
hgs
parents:
diff changeset
    90
    mServices.editCreateNewFromVCard( vCardFile, *this );
hgs
parents:
diff changeset
    91
    CNT_EXIT
hgs
parents:
diff changeset
    92
}
hgs
parents:
diff changeset
    93
hgs
parents:
diff changeset
    94
hgs
parents:
diff changeset
    95
/*!
hgs
parents:
diff changeset
    96
Launch contact selection view with a given detail (selecting detail there opens the editor and adds the new detail)
hgs
parents:
diff changeset
    97
*/
hgs
parents:
diff changeset
    98
void CntServiceProviderOld::editUpdateExisting(const QString &definitionName, const QString &value)
hgs
parents:
diff changeset
    99
{
hgs
parents:
diff changeset
   100
    CNT_ENTRY
hgs
parents:
diff changeset
   101
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
   102
    mServices.setQuittable(requestInfo().isEmbedded());
hgs
parents: 50
diff changeset
   103
    mServices.editUpdateExisting( definitionName, value, *this, false ); // defaultForOnlineAccountIsImpp = false
50
hgs
parents:
diff changeset
   104
    CNT_EXIT
hgs
parents:
diff changeset
   105
}
hgs
parents:
diff changeset
   106
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
/*!
hgs
parents:
diff changeset
   109
Launch communication launcher view for the contact with the given ID (QContactLocalId -> int)
hgs
parents:
diff changeset
   110
*/
hgs
parents:
diff changeset
   111
void CntServiceProviderOld::open(int contactId)
hgs
parents:
diff changeset
   112
{
hgs
parents:
diff changeset
   113
    CNT_ENTRY
hgs
parents:
diff changeset
   114
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
   115
    mServices.setQuittable(requestInfo().isEmbedded());
50
hgs
parents:
diff changeset
   116
    mServices.launchContactCard( contactId, *this );
hgs
parents:
diff changeset
   117
    CNT_EXIT
hgs
parents:
diff changeset
   118
}
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
/*!
hgs
parents:
diff changeset
   121
  Launch temporary communication launcher view with the given detail.
hgs
parents:
diff changeset
   122
*/
hgs
parents:
diff changeset
   123
void CntServiceProviderOld::open(const QString &definitionName, const QString &value)
hgs
parents:
diff changeset
   124
{
hgs
parents:
diff changeset
   125
    CNT_ENTRY
hgs
parents:
diff changeset
   126
    mCurrentRequestIndex = setCurrentRequestAsync();
53
hgs
parents: 50
diff changeset
   127
    mServices.setQuittable(requestInfo().isEmbedded());
50
hgs
parents:
diff changeset
   128
    mServices.launchTemporaryContactCard( definitionName, value, *this ); // definitionName = field type      value = actual field value for prefilling editor
hgs
parents:
diff changeset
   129
    CNT_EXIT
hgs
parents:
diff changeset
   130
}
hgs
parents:
diff changeset
   131
hgs
parents:
diff changeset
   132
hgs
parents:
diff changeset
   133
void CntServiceProviderOld::CompleteServiceAndCloseApp(const QVariant& retValue)
hgs
parents:
diff changeset
   134
{
hgs
parents:
diff changeset
   135
    CNT_ENTRY
hgs
parents:
diff changeset
   136
    connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
hgs
parents:
diff changeset
   137
    if ( mCurrentRequestIndex != 0 )
hgs
parents:
diff changeset
   138
    {
61
hgs
parents: 53
diff changeset
   139
        bool success = false;
hgs
parents: 53
diff changeset
   140
        
hgs
parents: 53
diff changeset
   141
        if (!mOverriddenReturnValue.isNull() && retValue.value<int>() != KCntServicesReturnValueContactDeleted)
hgs
parents: 53
diff changeset
   142
        {
hgs
parents: 53
diff changeset
   143
            CNT_LOG_ARGS(mOverriddenReturnValue.value<int>());
hgs
parents: 53
diff changeset
   144
            success = completeRequest(mCurrentRequestIndex, mOverriddenReturnValue);
hgs
parents: 53
diff changeset
   145
        }
hgs
parents: 53
diff changeset
   146
        else
hgs
parents: 53
diff changeset
   147
        {
hgs
parents: 53
diff changeset
   148
            CNT_LOG_ARGS(retValue.value<int>());
hgs
parents: 53
diff changeset
   149
            success = completeRequest(mCurrentRequestIndex, retValue);
hgs
parents: 53
diff changeset
   150
        }
hgs
parents: 53
diff changeset
   151
        
50
hgs
parents:
diff changeset
   152
        if ( !success )
hgs
parents:
diff changeset
   153
        {
hgs
parents:
diff changeset
   154
            CNT_LOG_ARGS("Failed to complete highway request.");
hgs
parents:
diff changeset
   155
        }
hgs
parents:
diff changeset
   156
        mCurrentRequestIndex = 0;
hgs
parents:
diff changeset
   157
    }
hgs
parents:
diff changeset
   158
    CNT_EXIT
hgs
parents:
diff changeset
   159
}
hgs
parents:
diff changeset
   160
61
hgs
parents: 53
diff changeset
   161
void CntServiceProviderOld::overrideReturnValue(const QVariant& retValue)
hgs
parents: 53
diff changeset
   162
{
hgs
parents: 53
diff changeset
   163
    CNT_ENTRY
hgs
parents: 53
diff changeset
   164
    
hgs
parents: 53
diff changeset
   165
    if (mOverriddenReturnValue.isNull() || mOverriddenReturnValue.value<int>() != KCntServicesReturnValueContactSaved)
hgs
parents: 53
diff changeset
   166
    {
hgs
parents: 53
diff changeset
   167
        mOverriddenReturnValue = retValue;
hgs
parents: 53
diff changeset
   168
    }
hgs
parents: 53
diff changeset
   169
    
hgs
parents: 53
diff changeset
   170
    CNT_EXIT
hgs
parents: 53
diff changeset
   171
}
hgs
parents: 53
diff changeset
   172
50
hgs
parents:
diff changeset
   173
// end of file