emailuis/nmailui/src/nmattachmentpicker.cpp
changeset 30 759dc5235cdb
parent 23 2dc6caa42ec3
child 47 f83bd4ae1fe3
--- a/emailuis/nmailui/src/nmattachmentpicker.cpp	Thu May 27 12:43:55 2010 +0300
+++ b/emailuis/nmailui/src/nmattachmentpicker.cpp	Fri Jun 11 13:27:14 2010 +0300
@@ -15,8 +15,11 @@
 *
 */
 
+#include <fmfiledialog.h>
+#include <xqaiwdecl.h>
 #include "nmuiheaders.h"
-
+const int NmAttachmentPickerStillMode = 0;
+const int NmAttachmentPickerVideoMode = 1;
 
 /*!
     \class NmAttachmentPicker
@@ -30,6 +33,7 @@
     QObject(parent),
     mRequest(NULL)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -37,6 +41,8 @@
 */
 NmAttachmentPicker::~NmAttachmentPicker()
 {
+    NM_FUNCTION;
+    
     delete mRequest;
 }
 
@@ -45,7 +51,9 @@
 */
 void NmAttachmentPicker::fetchImage()
 {
-    fetch(IMAGE_FETCHER_INTERFACE, IMAGE_FETCHER_OPERATION);
+    NM_FUNCTION;
+    
+    fetch(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH);
 }
 
 /*!
@@ -53,7 +61,9 @@
 */
 void NmAttachmentPicker::fetchAudio()
 {
-    fetch(AUDIO_FETCHER_INTERFACE, AUDIO_FETCHER_OPERATION);    
+    NM_FUNCTION;
+    
+    fetch(XQI_MUSIC_FETCH, XQOP_MUSIC_FETCH);    
 }
 
 /*!
@@ -61,7 +71,8 @@
 */
 void NmAttachmentPicker::fetchVideo()
 {
-
+    NM_FUNCTION;
+    fetch(XQI_VIDEO_FETCH, XQOP_VIDEO_FETCH);
 }
 
 /*!
@@ -69,22 +80,82 @@
 */
 void NmAttachmentPicker::fetchOther()
 {
+    NM_FUNCTION;
+    
+    QString path;
+    path = FmFileDialog::getSaveFileName(0, hbTrId("txt_mail_dialog_select_file"));
+    
+    if(!path.isEmpty()) {
+        QString temp = QDir::toNativeSeparators(path);
+        emit attachmentsFetchOk(QVariant(temp));    
+    }
+}
 
+/*!
+    Send request to retrieve image from camera
+*/
+void NmAttachmentPicker::fetchCameraStill()
+{
+    NM_FUNCTION;
+    fetchFromCamera(NmAttachmentPickerStillMode);
+}
+
+/*!
+    Send request to retrieve video from camera
+*/
+void NmAttachmentPicker::fetchCameraVideo()
+{
+    NM_FUNCTION;
+    fetchFromCamera(NmAttachmentPickerVideoMode);
 }
 
 /*!
+    Send request to retrieve image/video from camera
+*/
+void NmAttachmentPicker::fetchFromCamera(int mode)
+{
+    NM_FUNCTION;
+
+    int cameraIndex = 0;            //primary camera
+    int quality = 0;                //default
+    bool allowModeSwitch = false;   //not allowed to change
+    bool allowCameraSwitch = true;  //allow changes
+    bool allowQualityChange = true; //allow changes
+    
+    QVariantMap parameters;
+    parameters.insert(XQCAMERA_INDEX, cameraIndex);
+    parameters.insert(XQCAMERA_QUALITY, quality);
+    parameters.insert(XQCAMERA_MODE_SWITCH, allowModeSwitch);
+    parameters.insert(XQCAMERA_INDEX_SWITCH, allowCameraSwitch);
+    parameters.insert(XQCAMERA_QUALITY_CHANGE, allowQualityChange); 
+ 
+    QList<QVariant> args;
+    args << mode;
+    args << parameters;
+    
+    fetch(XQI_CAMERA_CAPTURE, "capture(int,QVariantMap)", &args);
+}
+/*!
     Construct & send appmgr request to start appropriate picker   
+    param <interface> the interface to be connected to
+    param <operation> the operation of the interface
+    param <args> the arguments that needed by the operation
 */
 void NmAttachmentPicker::fetch(const QString& interface, 
-    const QString& operation)
+    const QString& operation, const QList<QVariant>* args)
 {
+    NM_FUNCTION;
+    
     delete mRequest;
     mRequest = NULL;
     XQApplicationManager appMgr;
     mRequest = appMgr.create(interface, operation, true);
-
+   
     if (mRequest) {
         mRequest->setSynchronous(false);
+        if (args) {
+            mRequest->setArguments(*args);
+        }
         connect(mRequest, SIGNAL(requestOk(const QVariant&)),
                 this, SIGNAL(attachmentsFetchOk(const QVariant&)));