37
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: This static utility class handles all contacts & phbk services related
|
|
15 |
* common functions for UI modules.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <QFileInfo>
|
|
20 |
#include <QDir>
|
|
21 |
#include <QFile>
|
|
22 |
#include <xqapplicationmanager.h>
|
|
23 |
#include "msgcontactsutil.h"
|
|
24 |
|
|
25 |
|
|
26 |
//---------------------------------------------------------------
|
|
27 |
// MsgContactsUtil::copyVCardToTemp
|
|
28 |
// @see header file
|
|
29 |
//---------------------------------------------------------------
|
|
30 |
QString MsgContactsUtil::copyVCardToTemp(const QString& filepath)
|
|
31 |
{
|
|
32 |
QDir tempDir;
|
|
33 |
QString tempFilePath(QDir::toNativeSeparators(tempDir.tempPath()));
|
|
34 |
tempFilePath.append(QDir::separator());
|
|
35 |
QFileInfo fInfo(filepath);
|
|
36 |
tempFilePath.append(fInfo.fileName());
|
|
37 |
QFile::copy(filepath, tempFilePath);
|
|
38 |
return tempFilePath;
|
|
39 |
}
|
|
40 |
|
|
41 |
//---------------------------------------------------------------
|
|
42 |
// MsgContactsUtil::deleteVCardFromTemp
|
|
43 |
// @see header file
|
|
44 |
//---------------------------------------------------------------
|
|
45 |
void MsgContactsUtil::deleteVCardFromTemp(const QString& filepath)
|
|
46 |
{
|
|
47 |
QFile::remove(filepath);
|
|
48 |
}
|
|
49 |
|
|
50 |
//---------------------------------------------------------------
|
|
51 |
// MsgContactsUtil::launchVCardViewer
|
|
52 |
// @see header file
|
|
53 |
//---------------------------------------------------------------
|
|
54 |
bool MsgContactsUtil::launchVCardViewer(const QString& filepath)
|
|
55 |
{
|
|
56 |
//TODO: remove copyVcsFile after capabilities fix from Contacts
|
|
57 |
QString newfilepath = copyVCardToTemp(filepath);
|
|
58 |
|
62
|
59 |
QString service("phonebookservices");
|
|
60 |
QString interface("com.nokia.symbian.IContactsEdit");
|
|
61 |
QString operation("editCreateNewFromVCard(QString)");
|
37
|
62 |
XQApplicationManager appManager;
|
|
63 |
XQAiwRequest* request = appManager.create(service, interface, operation, true); //embedded
|
|
64 |
if(request)
|
|
65 |
{
|
|
66 |
QList<QVariant> args;
|
|
67 |
args << newfilepath;
|
73
|
68 |
request->setArguments(args);
|
|
69 |
request->setEmbedded(true);
|
|
70 |
request->setSynchronous(true);
|
37
|
71 |
QVariant retValue;
|
|
72 |
bool res = request->send(retValue);
|
|
73 |
delete request;
|
|
74 |
}
|
|
75 |
else
|
|
76 |
{
|
|
77 |
return false;
|
|
78 |
}
|
|
79 |
//TODO: remove deleteVcsFile after capabilities fix from Contacts
|
|
80 |
deleteVCardFromTemp(newfilepath);
|
|
81 |
return true;
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
// EOF
|
|
86 |
|