emailuis/nmailui/src/nmattachmentpicker.cpp
changeset 43 99bcbff212ad
parent 23 2dc6caa42ec3
child 47 f83bd4ae1fe3
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    13 *
    13 *
    14 * Description: Utility class for launching different file pickers
    14 * Description: Utility class for launching different file pickers
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 #include <fmfiledialog.h>
       
    19 #include <xqaiwdecl.h>
    18 #include "nmuiheaders.h"
    20 #include "nmuiheaders.h"
    19 
    21 const int NmAttachmentPickerStillMode = 0;
       
    22 const int NmAttachmentPickerVideoMode = 1;
    20 
    23 
    21 /*!
    24 /*!
    22     \class NmAttachmentPicker
    25     \class NmAttachmentPicker
    23     \brief Attachment picker for mail editor
    26     \brief Attachment picker for mail editor
    24 */
    27 */
    28 */
    31 */
    29 NmAttachmentPicker::NmAttachmentPicker(QObject* parent):
    32 NmAttachmentPicker::NmAttachmentPicker(QObject* parent):
    30     QObject(parent),
    33     QObject(parent),
    31     mRequest(NULL)
    34     mRequest(NULL)
    32 {
    35 {
       
    36     NM_FUNCTION;
    33 }
    37 }
    34 
    38 
    35 /*!
    39 /*!
    36     Destructor
    40     Destructor
    37 */
    41 */
    38 NmAttachmentPicker::~NmAttachmentPicker()
    42 NmAttachmentPicker::~NmAttachmentPicker()
    39 {
    43 {
       
    44     NM_FUNCTION;
       
    45     
    40     delete mRequest;
    46     delete mRequest;
    41 }
    47 }
    42 
    48 
    43 /*!
    49 /*!
    44     Send request to start Photo picker 
    50     Send request to start Photo picker 
    45 */
    51 */
    46 void NmAttachmentPicker::fetchImage()
    52 void NmAttachmentPicker::fetchImage()
    47 {
    53 {
    48     fetch(IMAGE_FETCHER_INTERFACE, IMAGE_FETCHER_OPERATION);
    54     NM_FUNCTION;
       
    55     
       
    56     fetch(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH);
    49 }
    57 }
    50 
    58 
    51 /*!
    59 /*!
    52     Send request to start Music picker 
    60     Send request to start Music picker 
    53 */
    61 */
    54 void NmAttachmentPicker::fetchAudio()
    62 void NmAttachmentPicker::fetchAudio()
    55 {
    63 {
    56     fetch(AUDIO_FETCHER_INTERFACE, AUDIO_FETCHER_OPERATION);    
    64     NM_FUNCTION;
       
    65     
       
    66     fetch(XQI_MUSIC_FETCH, XQOP_MUSIC_FETCH);    
    57 }
    67 }
    58 
    68 
    59 /*!
    69 /*!
    60     Send request to start Video picker 
    70     Send request to start Video picker 
    61 */
    71 */
    62 void NmAttachmentPicker::fetchVideo()
    72 void NmAttachmentPicker::fetchVideo()
    63 {
    73 {
    64 
    74     NM_FUNCTION;
       
    75     fetch(XQI_VIDEO_FETCH, XQOP_VIDEO_FETCH);
    65 }
    76 }
    66 
    77 
    67 /*!
    78 /*!
    68     Send request to start general file picker 
    79     Send request to start general file picker 
    69 */
    80 */
    70 void NmAttachmentPicker::fetchOther()
    81 void NmAttachmentPicker::fetchOther()
    71 {
    82 {
    72 
    83     NM_FUNCTION;
       
    84     
       
    85     QString path;
       
    86     path = FmFileDialog::getSaveFileName(0, hbTrId("txt_mail_dialog_select_file"));
       
    87     
       
    88     if(!path.isEmpty()) {
       
    89         QString temp = QDir::toNativeSeparators(path);
       
    90         emit attachmentsFetchOk(QVariant(temp));    
       
    91     }
    73 }
    92 }
    74 
    93 
    75 /*!
    94 /*!
       
    95     Send request to retrieve image from camera
       
    96 */
       
    97 void NmAttachmentPicker::fetchCameraStill()
       
    98 {
       
    99     NM_FUNCTION;
       
   100     fetchFromCamera(NmAttachmentPickerStillMode);
       
   101 }
       
   102 
       
   103 /*!
       
   104     Send request to retrieve video from camera
       
   105 */
       
   106 void NmAttachmentPicker::fetchCameraVideo()
       
   107 {
       
   108     NM_FUNCTION;
       
   109     fetchFromCamera(NmAttachmentPickerVideoMode);
       
   110 }
       
   111 
       
   112 /*!
       
   113     Send request to retrieve image/video from camera
       
   114 */
       
   115 void NmAttachmentPicker::fetchFromCamera(int mode)
       
   116 {
       
   117     NM_FUNCTION;
       
   118 
       
   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
       
   124     
       
   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);
       
   130     parameters.insert(XQCAMERA_QUALITY_CHANGE, allowQualityChange); 
       
   131  
       
   132     QList<QVariant> args;
       
   133     args << mode;
       
   134     args << parameters;
       
   135     
       
   136     fetch(XQI_CAMERA_CAPTURE, "capture(int,QVariantMap)", &args);
       
   137 }
       
   138 /*!
    76     Construct & send appmgr request to start appropriate picker   
   139     Construct & send appmgr request to start appropriate picker   
       
   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
    77 */
   143 */
    78 void NmAttachmentPicker::fetch(const QString& interface, 
   144 void NmAttachmentPicker::fetch(const QString& interface, 
    79     const QString& operation)
   145     const QString& operation, const QList<QVariant>* args)
    80 {
   146 {
       
   147     NM_FUNCTION;
       
   148     
    81     delete mRequest;
   149     delete mRequest;
    82     mRequest = NULL;
   150     mRequest = NULL;
    83     XQApplicationManager appMgr;
   151     XQApplicationManager appMgr;
    84     mRequest = appMgr.create(interface, operation, true);
   152     mRequest = appMgr.create(interface, operation, true);
    85 
   153    
    86     if (mRequest) {
   154     if (mRequest) {
    87         mRequest->setSynchronous(false);
   155         mRequest->setSynchronous(false);
       
   156         if (args) {
       
   157             mRequest->setArguments(*args);
       
   158         }
    88         connect(mRequest, SIGNAL(requestOk(const QVariant&)),
   159         connect(mRequest, SIGNAL(requestOk(const QVariant&)),
    89                 this, SIGNAL(attachmentsFetchOk(const QVariant&)));
   160                 this, SIGNAL(attachmentsFetchOk(const QVariant&)));
    90 
   161 
    91         connect(mRequest, SIGNAL(requestError(int, const QString&)),
   162         connect(mRequest, SIGNAL(requestError(int, const QString&)),
    92                 this, SIGNAL(attachmentsFetchError(int, const QString&)));
   163                 this, SIGNAL(attachmentsFetchError(int, const QString&)));