|
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:Message service launch utility |
|
15 * |
|
16 */ |
|
17 |
|
18 // SYSTEM INCLUDES |
|
19 #include <xqaiwrequest.h> |
|
20 #include <xqrequestinfo.h> |
|
21 #include <xqappmgr.h> |
|
22 #include <hbglobal.h> |
|
23 #include <xqconversions.h> |
|
24 |
|
25 #include "msgservicelaunchutil.h" |
|
26 #include "msgcontactsutil.h" |
|
27 #include "msgservicelaunchutilprivate.h" |
|
28 #include "debugtraces.h" |
|
29 |
|
30 // LOCAL CONSTANTS |
|
31 #define LOC_TITLE hbTrId("txt_messaging_title_messaging") |
|
32 const QString VCARD_MIMETYPE("text/X-vCard"); |
|
33 |
|
34 //-------------------------------------------------------------- |
|
35 // MsgServiceLaunchUtil::MsgServiceLaunchUtil |
|
36 // Constructor |
|
37 //-------------------------------------------------------------- |
|
38 MsgServiceLaunchUtil::MsgServiceLaunchUtil(QObject* parent): |
|
39 QObject(parent) |
|
40 { |
|
41 //nothing required |
|
42 } |
|
43 |
|
44 //-------------------------------------------------------------- |
|
45 // MsgServiceLaunchUtil::~MsgServiceLaunchUtil |
|
46 // Destructor |
|
47 //-------------------------------------------------------------- |
|
48 MsgServiceLaunchUtil::~MsgServiceLaunchUtil() |
|
49 { |
|
50 //nothing required |
|
51 } |
|
52 |
|
53 //--------------------------------------------------------------- |
|
54 // MsgServiceLaunchUtil::launchContentViewer |
|
55 // @see header file |
|
56 //--------------------------------------------------------------- |
|
57 void MsgServiceLaunchUtil::launchContentViewer( |
|
58 const QString &mimeType, |
|
59 const QString &filePath) |
|
60 { |
|
61 if (mimeType.contains(VCARD_MIMETYPE, Qt::CaseInsensitive)) { |
|
62 MsgContactsUtil::launchVCardViewer(filePath); |
|
63 } |
|
64 else { |
|
65 MsgServiceLaunchUtil::launchViaSharableFile(filePath); |
|
66 } |
|
67 } |
|
68 |
|
69 //--------------------------------------------------------------- |
|
70 // MsgServiceLaunchUtil::launchContentViewer |
|
71 // @see header file |
|
72 //--------------------------------------------------------------- |
|
73 void MsgServiceLaunchUtil::launchContentViewer( |
|
74 int messageId) |
|
75 { |
|
76 // get the mimeType and filepath from messageId |
|
77 CMsgServiceLaunchUtilPrivate* util_p = 0; |
|
78 |
|
79 TRAPD(error, util_p = CMsgServiceLaunchUtilPrivate::NewL()); |
|
80 |
|
81 if(error == KErrNone) |
|
82 { |
|
83 HBufC* fileName = 0; |
|
84 fileName = util_p->GetMessagePath(messageId, error); |
|
85 |
|
86 if(error == KErrNone) |
|
87 { |
|
88 QString attachmentFName = XQConversions::s60DescToQString( |
|
89 fileName->Des()); |
|
90 QString mimeType = XQConversions::s60Desc8ToQString( |
|
91 util_p->GetMimeType()->Des()); |
|
92 |
|
93 launchContentViewer(mimeType, attachmentFName); |
|
94 |
|
95 } |
|
96 if (fileName){ |
|
97 delete fileName; |
|
98 } |
|
99 } |
|
100 if(util_p){ |
|
101 delete util_p; |
|
102 } |
|
103 } |
|
104 |
|
105 //--------------------------------------------------------------- |
|
106 // MsgServiceLaunchUtil::launchViaSharableFile |
|
107 // @see header file |
|
108 //--------------------------------------------------------------- |
|
109 void MsgServiceLaunchUtil::launchViaSharableFile( |
|
110 const QString &filePath) |
|
111 { |
|
112 XQSharableFile sf; |
|
113 XQAiwRequest* request = 0; |
|
114 |
|
115 if (!sf.open(filePath)) { |
|
116 return; |
|
117 } |
|
118 |
|
119 // Get handlers |
|
120 XQApplicationManager appManager; |
|
121 QList<XQAiwInterfaceDescriptor> fileHandlers = appManager.list(sf); |
|
122 if (fileHandlers.count() > 0) { |
|
123 XQAiwInterfaceDescriptor d = fileHandlers.first(); |
|
124 request = appManager.create(sf, d); |
|
125 |
|
126 if (!request) { |
|
127 sf.close(); |
|
128 return; |
|
129 } |
|
130 } |
|
131 else { |
|
132 sf.close(); |
|
133 return; |
|
134 } |
|
135 |
|
136 // Result handlers |
|
137 connect(request, |
|
138 SIGNAL(requestOk(const QVariant&)), |
|
139 this, |
|
140 SLOT(handleOk(const QVariant&)), |
|
141 Qt::UniqueConnection); |
|
142 connect(request, |
|
143 SIGNAL(requestError(int,const QString&)), |
|
144 this, |
|
145 SLOT(handleError(int,const QString&)), |
|
146 Qt::UniqueConnection); |
|
147 |
|
148 request->setEmbedded(true); |
|
149 request->setSynchronous(false); |
|
150 |
|
151 // Fill args |
|
152 QList<QVariant> args; |
|
153 args << qVariantFromValue(sf); |
|
154 request->setArguments(args); |
|
155 |
|
156 // Fill headers |
|
157 QString key("WindowTitle"); |
|
158 QVariant value(QString(LOC_TITLE)); |
|
159 XQRequestInfo info; |
|
160 info.setInfo(key, value); |
|
161 request->setInfo(info); |
|
162 |
|
163 request->send(); |
|
164 |
|
165 // Cleanup |
|
166 sf.close(); |
|
167 delete request; |
|
168 } |
|
169 |
|
170 //--------------------------------------------------------------- |
|
171 // MsgServiceLaunchUtil::handleOk |
|
172 // @see header file |
|
173 //--------------------------------------------------------------- |
|
174 void MsgServiceLaunchUtil::handleOk( |
|
175 const QVariant& result) |
|
176 { |
|
177 //do nothing |
|
178 Q_UNUSED(result) |
|
179 } |
|
180 |
|
181 //--------------------------------------------------------------- |
|
182 // MsgServiceLaunchUtil::handleError |
|
183 // @see header file |
|
184 //--------------------------------------------------------------- |
|
185 void MsgServiceLaunchUtil::handleError( |
|
186 int errorCode, |
|
187 const QString& errorMessage) |
|
188 { |
|
189 //do nothing |
|
190 Q_UNUSED(errorCode) |
|
191 Q_UNUSED(errorMessage) |
|
192 } |
|
193 |
|
194 //eof |