|
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 |
|
59 QString service("com.nokia.services.phonebookservices"); |
|
60 QString interface("Fetch"); |
|
61 QString operation("editCreateNew(QString)"); |
|
62 XQApplicationManager appManager; |
|
63 XQAiwRequest* request = appManager.create(service, interface, operation, true); //embedded |
|
64 if(request) |
|
65 { |
|
66 QList<QVariant> args; |
|
67 args << newfilepath; |
|
68 request->setArguments(args); |
|
69 QVariant retValue; |
|
70 bool res = request->send(retValue); |
|
71 delete request; |
|
72 } |
|
73 else |
|
74 { |
|
75 return false; |
|
76 } |
|
77 //TODO: remove deleteVcsFile after capabilities fix from Contacts |
|
78 deleteVCardFromTemp(newfilepath); |
|
79 return true; |
|
80 } |
|
81 |
|
82 |
|
83 // EOF |
|
84 |