168 |
167 |
169 return displayName.mid(firstPos, lastPos - firstPos + 1); |
168 return displayName.mid(firstPos, lastPos - firstPos + 1); |
170 } |
169 } |
171 |
170 |
172 /*! |
171 /*! |
173 Opens file specified by QFile handle. Usually used by editor |
172 Opens file specified by RFile handle. Usually used by viewer |
174 for opening added attachments |
173 for opening attachments from message store as RFiles |
175 */ |
174 */ |
176 int NmUtilities::openFile(QFile &file) |
175 int NmUtilities::openFile(XQSharableFile &file) |
177 { |
176 { |
178 NM_FUNCTION; |
177 NM_FUNCTION; |
179 |
178 |
180 int ret(NmNotFoundError); |
179 int ret(NmNotFoundError); |
181 XQApplicationManager aiwMgr; |
180 XQApplicationManager aiwMgr; |
182 XQAiwRequest *request(NULL); |
181 XQAiwRequest *request(NULL); |
183 request = aiwMgr.create(file); |
182 request = aiwMgr.create(file); |
184 // If request is created then there is a handler for that file |
|
185 if (request) { |
|
186 // Set request arguments |
|
187 QList<QVariant> args; |
|
188 args << file.fileName(); |
|
189 request->setArguments(args); |
|
190 // Send the request, ownership of request is transferred |
|
191 bool res = request->send(); |
|
192 if (res) { |
|
193 // Request ok, set error status. |
|
194 ret = NmNoError; |
|
195 } |
|
196 } |
|
197 delete request; |
|
198 return ret; |
|
199 } |
|
200 |
|
201 |
|
202 /*! |
|
203 Opens file specified by RFile handle. Usually used by viewer |
|
204 for opening attachments from message store as RFiles |
|
205 */ |
|
206 int NmUtilities::openFile(XQSharableFile &file) |
|
207 { |
|
208 NM_FUNCTION; |
|
209 |
|
210 int ret(NmNotFoundError); |
|
211 XQApplicationManager aiwMgr; |
|
212 XQAiwRequest *request(NULL); |
|
213 request = aiwMgr.create(file); |
|
214 // Create request for the sharable file |
183 // Create request for the sharable file |
215 if (request) |
184 if (request) |
216 { |
185 { |
217 // Set request arguments |
186 // Set request arguments |
218 QList<QVariant> args; |
187 QList<QVariant> args; |
219 args << qVariantFromValue(file); |
188 args << qVariantFromValue(file); |
220 request->setArguments(args); |
189 request->setArguments(args); |
221 // Send the request, ownership of request is transferred |
190 // Send the request, ownership of request is transferred |
222 bool res = request->send(); |
191 bool res = request->send(); |
223 if (res) { |
192 if (res) { |
224 // Request ok, set error status. |
193 // Request ok, set error status. |
270 on attachment size in bytes |
239 on attachment size in bytes |
271 */ |
240 */ |
272 QString NmUtilities::attachmentSizeString(const int sizeInBytes) |
241 QString NmUtilities::attachmentSizeString(const int sizeInBytes) |
273 { |
242 { |
274 NM_FUNCTION; |
243 NM_FUNCTION; |
275 |
244 |
276 qreal sizeMb = (qreal)sizeInBytes / (qreal)NmMegabyte; |
245 qreal sizeMb = (qreal)sizeInBytes / (qreal)NmMegabyte; |
277 if (sizeMb < 0.1) { |
246 if (sizeMb < 0.1) { |
278 // 0.1 Mb is the minimum size shown for attachment |
247 // 0.1 Mb is the minimum size shown for attachment |
279 sizeMb = 0.1; |
248 sizeMb = 0.1; |
280 } |
249 } |
281 return QString().sprintf("(%.1f Mb)", sizeMb); // Use loc string when available |
250 return QString().sprintf("(%.1f Mb)", sizeMb); // Use loc string when available |
282 } |
251 } |
283 |
252 |
284 /*! |
253 /*! |
285 Displays a note with Yes/No buttons. Note has no timeout, i.e. it has to be dismissed manually. |
254 Displays a note with Yes/No buttons. Note has no timeout, i.e. it has to be dismissed manually. |
286 Returns pointer to dialog so that caller can take ownership and handle deletion. |
255 Returns pointer to dialog so that caller can take ownership and handle deletion. |
287 Parameter 'receiver' is the object and 'member' is the slot where user selection is passed. |
256 Parameter 'receiver' is the object and 'member' is the slot where user selection is passed. |
288 */ |
257 */ |
289 HbMessageBox* NmUtilities::displayQuestionNote( |
258 HbMessageBox* NmUtilities::displayQuestionNote( |
290 QString noteText, QObject* receiver, const char* member) |
259 QString noteText, QObject* receiver, const char* member) |
291 { |
260 { |
292 NM_FUNCTION; |
261 NM_FUNCTION; |
293 |
262 |
294 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
263 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
295 messageBox->setText(noteText); |
264 messageBox->setText(noteText); |
296 messageBox->setTimeout(HbMessageBox::NoTimeout); // Note has to be dismissed manually |
265 messageBox->setTimeout(HbMessageBox::NoTimeout); // Note has to be dismissed manually |
297 messageBox->open(receiver, member); |
266 messageBox->open(receiver, member); |
298 return messageBox; |
267 return messageBox; |
299 } |
268 } |
300 |
269 |
301 /*! |
270 /*! |
302 * displays an error note with no buttons. Note dismisses itself after NmShortInterval. |
271 * displays an warning note. |
303 */ |
272 */ |
304 void NmUtilities::displayWarningNote(QString noteText) |
273 HbMessageBox* NmUtilities::displayWarningNote(QString noteText, QObject* receiver, const char* member) |
305 { |
274 { |
306 NM_FUNCTION; |
275 NM_FUNCTION; |
307 |
276 |
308 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning); |
277 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning); |
309 messageBox->setText(noteText); |
278 messageBox->setText(noteText); |
310 messageBox->setTimeout(NmShortInterval); |
279 messageBox->setTimeout(HbMessageBox::NoTimeout); // Note has to be dismissed manually |
311 messageBox->clearActions(); // gets rid of buttons from the note |
280 messageBox->open(receiver, member); |
312 messageBox->setModal(false); |
281 return messageBox; |
313 messageBox->setBackgroundFaded(false); |
|
314 messageBox->show(); |
|
315 |
|
316 delete messageBox; |
|
317 } |
282 } |
318 |
283 |
319 /*! |
284 /*! |
320 Function returns localized "Original message" header |
285 Function returns localized "Original message" header |
321 in html format based on envelope |
286 in html format based on envelope |
322 */ |
287 */ |
323 QString NmUtilities::createReplyHeader(const NmMessageEnvelope &env) |
288 QString NmUtilities::createReplyHeader(const NmMessageEnvelope &env) |
324 { |
289 { |
325 NM_FUNCTION; |
290 NM_FUNCTION; |
326 |
291 |
327 QString ret = "<html><body><br><br>"; |
292 QString ret = "<html><body><br><br>"; |
328 // Append "----- Original message ----" text |
293 // Append "----- Original message ----" text |
329 ret+=hbTrId("txt_mail_editor_reply_original_msg"); |
294 ret+=hbTrId("txt_mail_editor_reply_original_msg"); |
330 // Append sender |
295 // Append sender |
331 ret+="<br>"; |
296 ret+="<br>"; |
332 ret+=hbTrId("txt_mail_editor_reply_from"); |
297 ret+=hbTrId("txt_mail_editor_reply_from"); |
333 ret+=" "; |
298 ret+=" "; |
334 if (env.sender().displayName().length()){ |
299 if (env.sender().displayName().length()){ |
335 ret+=env.sender().displayName(); |
300 ret+=env.sender().displayName(); |
336 } |
301 } |
337 else{ |
302 else{ |
338 ret+=env.sender().address(); |
303 ret+=env.sender().address(); |
339 } |
304 } |
340 // Append sent time |
305 // Append sent time |
341 ret+="<br>"; |
306 ret+="<br>"; |
342 ret+=hbTrId("txt_mail_editor_reply_sent"); |
307 ret+=hbTrId("txt_mail_editor_reply_sent"); |
343 ret+=" "; |
308 ret+=" "; |
344 HbExtendedLocale locale = HbExtendedLocale::system(); |
309 HbExtendedLocale locale = HbExtendedLocale::system(); |
345 QDate sentLocalDate = env.sentTime().toLocalTime().date(); |
310 QDateTime localTime = env.sentTime().addSecs(locale.universalTimeOffset()); |
346 ret+=locale.format(sentLocalDate, r_qtn_date_usual); |
311 QDate sentLocalDate = localTime.date(); |
|
312 ret+=locale.format(sentLocalDate, r_qtn_date_usual); |
347 // Append to recipients |
313 // Append to recipients |
348 const QList<NmAddress> &toList = env.toRecipients(); |
314 const QList<NmAddress> &toList = env.toRecipients(); |
349 if (toList.count()){ |
315 if (toList.count()){ |
350 ret+="<br>"; |
316 ret+="<br>"; |
351 ret+=hbTrId("txt_mail_editor_reply_to"); |
317 ret+=hbTrId("txt_mail_editor_reply_to"); |
352 ret+=" "; |
318 ret+=" "; |
353 for (int i=0;i<toList.count();i++){ |
319 for (int i=0;i<toList.count();i++){ |
354 if (toList[i].displayName().length()){ |
320 if (toList[i].displayName().length()){ |
355 ret+=toList[i].displayName(); |
321 ret+=toList[i].displayName(); |
356 } |
322 } |
357 else{ |
323 else{ |
358 ret+=toList[i].address(); |
324 ret+=toList[i].address(); |
359 } |
325 } |
360 if (i!=toList.count()-1){ |
326 if (i!=toList.count()-1){ |
361 ret+=";"; |
327 ret+=";"; |
362 } |
328 } |
363 } |
329 } |
364 } |
330 } |
365 // Append cc recipients |
331 // Append cc recipients |
366 const QList<NmAddress> &ccList = env.ccRecipients(); |
332 const QList<NmAddress> &ccList = env.ccRecipients(); |
367 if (ccList.count()){ |
333 if (ccList.count()){ |
368 ret+="<br>"; |
334 ret+="<br>"; |
369 ret+=hbTrId("txt_mail_editor_reply_cc"); |
335 ret+=hbTrId("txt_mail_editor_reply_cc"); |
370 ret+=" "; |
336 ret+=" "; |
371 for (int i=0;i<ccList.count();i++){ |
337 for (int i=0;i<ccList.count();i++){ |
372 if (ccList[i].displayName().length()){ |
338 if (ccList[i].displayName().length()){ |
373 ret+=ccList[i].displayName(); |
339 ret+=ccList[i].displayName(); |
374 } |
340 } |
375 else{ |
341 else{ |
376 ret+=ccList[i].address(); |
342 ret+=ccList[i].address(); |
377 } |
343 } |
378 if (i!=toList.count()-1){ |
344 if (i!=toList.count()-1){ |
379 ret+=";"; |
345 ret+=";"; |
380 } |
346 } |
381 } |
347 } |
382 } |
348 } |
383 // Append subject if there is subject to display |
349 // Append subject if there is subject to display |
384 if (env.subject().length()){ |
350 if (env.subject().length()){ |
385 ret+="<br>"; |
351 ret+="<br>"; |
386 ret+=hbTrId("txt_mail_editor_reply_subject"); |
352 ret+=hbTrId("txt_mail_editor_reply_subject"); |
387 ret+=" "; |
353 ret+=" "; |
388 ret+=env.subject(); |
354 ret+=env.subject(); |
389 } |
355 } |
390 // Append priority if it is other than normal |
356 // Append priority if it is other than normal |
391 if (env.priority()!=NmMessagePriorityNormal){ |
357 if (env.priority()!=NmMessagePriorityNormal){ |
392 ret+="<br>"; |
358 ret+="<br>"; |
393 ret+=hbTrId("txt_mail_editor_reply_importance"); |
359 ret+=hbTrId("txt_mail_editor_reply_importance"); |
394 ret+=" "; |
360 ret+=" "; |
395 if (env.priority()==NmMessagePriorityLow){ |
361 if (env.priority()==NmMessagePriorityLow){ |
396 ret+=hbTrId("txt_mail_editor_reply_importance_low"); |
362 ret+=hbTrId("txt_mail_editor_reply_importance_low"); |
397 } |
363 } |
398 else { |
364 else { |
399 ret+=hbTrId("txt_mail_editor_reply_importance_high"); |
365 ret+=hbTrId("txt_mail_editor_reply_importance_high"); |
400 } |
366 } |
401 } |
367 } |
402 ret+="<br></body></html>"; |
368 ret+="<br></body></html>"; |
403 return ret; |
369 return ret; |
404 } |
370 } |