author | hgs |
Tue, 19 Oct 2010 12:30:59 +0300 | |
changeset 79 | 2508e95245f2 |
parent 66 | 084b5b1f02a7 |
permissions | -rw-r--r-- |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: Utility class for launching different file pickers |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include "nmuiheaders.h" |
47 | 19 |
|
20 |
static const int NmAttachmentPickerStillMode = 0; |
|
21 |
static const int NmAttachmentPickerVideoMode = 1; |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
/*! |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
\class NmAttachmentPicker |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
\brief Attachment picker for mail editor |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
/*! |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
Constructor |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
*/ |
47 | 31 |
NmAttachmentPicker::NmAttachmentPicker(QObject *parent): |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
QObject(parent), |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
mRequest(NULL) |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
{ |
43 | 35 |
NM_FUNCTION; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
/*! |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
Destructor |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
NmAttachmentPicker::~NmAttachmentPicker() |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
{ |
43 | 43 |
NM_FUNCTION; |
56 | 44 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
delete mRequest; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
/*! |
56 | 49 |
Send request to start Photo picker |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
void NmAttachmentPicker::fetchImage() |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
{ |
43 | 53 |
NM_FUNCTION; |
56 | 54 |
|
43 | 55 |
fetch(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
/*! |
56 | 59 |
Send request to start Music picker |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
void NmAttachmentPicker::fetchAudio() |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
{ |
43 | 63 |
NM_FUNCTION; |
56 | 64 |
|
65 |
fetch(XQI_MUSIC_FETCH, XQOP_MUSIC_FETCH); |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
/*! |
56 | 69 |
Send request to start Video picker |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
void NmAttachmentPicker::fetchVideo() |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
{ |
43 | 73 |
NM_FUNCTION; |
62 | 74 |
|
43 | 75 |
fetch(XQI_VIDEO_FETCH, XQOP_VIDEO_FETCH); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
/*! |
56 | 79 |
Send request to start general file picker |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
void NmAttachmentPicker::fetchOther() |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
{ |
43 | 83 |
NM_FUNCTION; |
56 | 84 |
|
43 | 85 |
QString path; |
56 | 86 |
path = FmFileDialog::getOpenFileName(0, hbTrId("txt_mail_dialog_select_file")); |
87 |
||
88 |
QString temp = QDir::toNativeSeparators(path); |
|
89 |
emit attachmentsFetchOk(QVariant(temp)); |
|
43 | 90 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
|
43 | 92 |
/*! |
93 |
Send request to retrieve image from camera |
|
94 |
*/ |
|
95 |
void NmAttachmentPicker::fetchCameraStill() |
|
96 |
{ |
|
97 |
NM_FUNCTION; |
|
62 | 98 |
|
43 | 99 |
fetchFromCamera(NmAttachmentPickerStillMode); |
100 |
} |
|
101 |
||
102 |
/*! |
|
103 |
Send request to retrieve video from camera |
|
104 |
*/ |
|
105 |
void NmAttachmentPicker::fetchCameraVideo() |
|
106 |
{ |
|
107 |
NM_FUNCTION; |
|
62 | 108 |
|
43 | 109 |
fetchFromCamera(NmAttachmentPickerVideoMode); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
110 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
/*! |
43 | 113 |
Send request to retrieve image/video from camera |
114 |
*/ |
|
115 |
void NmAttachmentPicker::fetchFromCamera(int mode) |
|
116 |
{ |
|
117 |
NM_FUNCTION; |
|
118 |
||
47 | 119 |
int cameraIndex(0); //primary camera |
120 |
int quality(0); //default |
|
121 |
bool allowModeSwitch(false); //not allowed to change |
|
122 |
bool allowCameraSwitch(true); //allow changes |
|
123 |
bool allowQualityChange(true); //allow changes |
|
56 | 124 |
|
43 | 125 |
QVariantMap parameters; |
126 |
parameters.insert(XQCAMERA_INDEX, cameraIndex); |
|
127 |
parameters.insert(XQCAMERA_QUALITY, quality); |
|
128 |
parameters.insert(XQCAMERA_MODE_SWITCH, allowModeSwitch); |
|
129 |
parameters.insert(XQCAMERA_INDEX_SWITCH, allowCameraSwitch); |
|
56 | 130 |
parameters.insert(XQCAMERA_QUALITY_CHANGE, allowQualityChange); |
131 |
||
43 | 132 |
QList<QVariant> args; |
133 |
args << mode; |
|
134 |
args << parameters; |
|
56 | 135 |
|
43 | 136 |
fetch(XQI_CAMERA_CAPTURE, "capture(int,QVariantMap)", &args); |
137 |
} |
|
138 |
/*! |
|
56 | 139 |
Construct & send appmgr request to start appropriate picker |
43 | 140 |
param <interface> the interface to be connected to |
141 |
param <operation> the operation of the interface |
|
142 |
param <args> the arguments that needed by the operation |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
*/ |
56 | 144 |
void NmAttachmentPicker::fetch(const QString &interface, |
47 | 145 |
const QString &operation, const QList<QVariant> *args) |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
146 |
{ |
43 | 147 |
NM_FUNCTION; |
56 | 148 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
149 |
delete mRequest; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
150 |
mRequest = NULL; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
151 |
XQApplicationManager appMgr; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
152 |
mRequest = appMgr.create(interface, operation, true); |
56 | 153 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
154 |
if (mRequest) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
mRequest->setSynchronous(false); |
43 | 156 |
if (args) { |
157 |
mRequest->setArguments(*args); |
|
158 |
} |
|
66 | 159 |
// Set the title pane text for the picker window |
160 |
// sub-title comes from the pickers |
|
161 |
QVariant title(mTitle); |
|
162 |
XQRequestInfo info; |
|
163 |
info.setInfo(XQINFO_KEY_WINDOW_TITLE, title); |
|
164 |
mRequest->setInfo(info); |
|
62 | 165 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
connect(mRequest, SIGNAL(requestOk(const QVariant&)), |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
this, SIGNAL(attachmentsFetchOk(const QVariant&))); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
168 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
connect(mRequest, SIGNAL(requestError(int, const QString&)), |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
this, SIGNAL(attachmentsFetchError(int, const QString&))); |
56 | 171 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
172 |
mRequest->send(); |
56 | 173 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
174 |
} |
56 | 175 |
|
176 |
/*! |
|
177 |
Launch the correct fetcher based on the clicked list item. |
|
178 |
*/ |
|
179 |
void NmAttachmentPicker::selectFetcher(HbListWidgetItem *listItem) |
|
180 |
{ |
|
62 | 181 |
NM_FUNCTION; |
182 |
||
183 |
QString itemText = listItem->text(); |
|
56 | 184 |
if (itemText == hbTrId("txt_mail_list_photo")) { |
185 |
fetchImage(); |
|
186 |
} |
|
66 | 187 |
else if (itemText == hbTrId("txt_mail_list_sound")) { |
56 | 188 |
fetchAudio(); |
189 |
} |
|
190 |
else if (itemText == hbTrId("txt_mail_list_video")) { |
|
191 |
fetchVideo(); |
|
192 |
} |
|
193 |
else if (itemText == hbTrId("txt_mail_list_other")) { |
|
194 |
QMetaObject::invokeMethod(this, "fetchOther", Qt::QueuedConnection); |
|
195 |
} |
|
196 |
else if (itemText == hbTrId("txt_mail_list_new_photo")) { |
|
197 |
fetchCameraStill(); |
|
198 |
} |
|
62 | 199 |
else if (itemText == hbTrId("txt_mail_list_new_video")) { |
200 |
fetchCameraVideo(); |
|
201 |
} |
|
56 | 202 |
} |
62 | 203 |
|
204 |
/*! |
|
205 |
Sets the title used in the picker views |
|
206 |
*/ |
|
207 |
void NmAttachmentPicker::setTitle(const QString &title) |
|
208 |
{ |
|
209 |
NM_FUNCTION; |
|
210 |
||
211 |
mTitle = title; |
|
212 |
} |