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