emailuis/nmailui/src/nmattachmentpicker.cpp
changeset 59 16ed8d08d0b1
parent 54 997a02608b3a
child 62 a8c646b56683
equal deleted inserted replaced
54:997a02608b3a 59:16ed8d08d0b1
    39     Destructor
    39     Destructor
    40 */
    40 */
    41 NmAttachmentPicker::~NmAttachmentPicker()
    41 NmAttachmentPicker::~NmAttachmentPicker()
    42 {
    42 {
    43     NM_FUNCTION;
    43     NM_FUNCTION;
    44     
    44 
    45     delete mRequest;
    45     delete mRequest;
    46 }
    46 }
    47 
    47 
    48 /*!
    48 /*!
    49     Send request to start Photo picker 
    49     Send request to start Photo picker
    50 */
    50 */
    51 void NmAttachmentPicker::fetchImage()
    51 void NmAttachmentPicker::fetchImage()
    52 {
    52 {
    53     NM_FUNCTION;
    53     NM_FUNCTION;
    54     
    54 
    55     fetch(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH);
    55     fetch(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH);
    56 }
    56 }
    57 
    57 
    58 /*!
    58 /*!
    59     Send request to start Music picker 
    59     Send request to start Music picker
    60 */
    60 */
    61 void NmAttachmentPicker::fetchAudio()
    61 void NmAttachmentPicker::fetchAudio()
    62 {
    62 {
    63     NM_FUNCTION;
    63     NM_FUNCTION;
    64     
    64 
    65     fetch(XQI_MUSIC_FETCH, XQOP_MUSIC_FETCH);    
    65     fetch(XQI_MUSIC_FETCH, XQOP_MUSIC_FETCH);
    66 }
    66 }
    67 
    67 
    68 /*!
    68 /*!
    69     Send request to start Video picker 
    69     Send request to start Video picker
    70 */
    70 */
    71 void NmAttachmentPicker::fetchVideo()
    71 void NmAttachmentPicker::fetchVideo()
    72 {
    72 {
    73     NM_FUNCTION;
    73     NM_FUNCTION;
    74     fetch(XQI_VIDEO_FETCH, XQOP_VIDEO_FETCH);
    74     fetch(XQI_VIDEO_FETCH, XQOP_VIDEO_FETCH);
    75 }
    75 }
    76 
    76 
    77 /*!
    77 /*!
    78     Send request to start general file picker 
    78     Send request to start general file picker
    79 */
    79 */
    80 void NmAttachmentPicker::fetchOther()
    80 void NmAttachmentPicker::fetchOther()
    81 {
    81 {
    82     NM_FUNCTION;
    82     NM_FUNCTION;
    83     
    83 
    84     QString path;
    84     QString path;
    85     path = FmFileDialog::getSaveFileName(0, hbTrId("txt_mail_dialog_select_file"));
    85     path = FmFileDialog::getOpenFileName(0, hbTrId("txt_mail_dialog_select_file"));
    86     
    86 
    87     if (!path.isEmpty()) {
    87     QString temp = QDir::toNativeSeparators(path);
    88         QString temp = QDir::toNativeSeparators(path);
    88     emit attachmentsFetchOk(QVariant(temp));
    89         emit attachmentsFetchOk(QVariant(temp));    
       
    90     }
       
    91 }
    89 }
    92 
    90 
    93 /*!
    91 /*!
    94     Send request to retrieve image from camera
    92     Send request to retrieve image from camera
    95 */
    93 */
   118     int cameraIndex(0);            //primary camera
   116     int cameraIndex(0);            //primary camera
   119     int quality(0);                //default
   117     int quality(0);                //default
   120     bool allowModeSwitch(false);   //not allowed to change
   118     bool allowModeSwitch(false);   //not allowed to change
   121     bool allowCameraSwitch(true);  //allow changes
   119     bool allowCameraSwitch(true);  //allow changes
   122     bool allowQualityChange(true); //allow changes
   120     bool allowQualityChange(true); //allow changes
   123     
   121 
   124     QVariantMap parameters;
   122     QVariantMap parameters;
   125     parameters.insert(XQCAMERA_INDEX, cameraIndex);
   123     parameters.insert(XQCAMERA_INDEX, cameraIndex);
   126     parameters.insert(XQCAMERA_QUALITY, quality);
   124     parameters.insert(XQCAMERA_QUALITY, quality);
   127     parameters.insert(XQCAMERA_MODE_SWITCH, allowModeSwitch);
   125     parameters.insert(XQCAMERA_MODE_SWITCH, allowModeSwitch);
   128     parameters.insert(XQCAMERA_INDEX_SWITCH, allowCameraSwitch);
   126     parameters.insert(XQCAMERA_INDEX_SWITCH, allowCameraSwitch);
   129     parameters.insert(XQCAMERA_QUALITY_CHANGE, allowQualityChange); 
   127     parameters.insert(XQCAMERA_QUALITY_CHANGE, allowQualityChange);
   130  
   128 
   131     QList<QVariant> args;
   129     QList<QVariant> args;
   132     args << mode;
   130     args << mode;
   133     args << parameters;
   131     args << parameters;
   134     
   132 
   135     fetch(XQI_CAMERA_CAPTURE, "capture(int,QVariantMap)", &args);
   133     fetch(XQI_CAMERA_CAPTURE, "capture(int,QVariantMap)", &args);
   136 }
   134 }
   137 /*!
   135 /*!
   138     Construct & send appmgr request to start appropriate picker   
   136     Construct & send appmgr request to start appropriate picker
   139     param <interface> the interface to be connected to
   137     param <interface> the interface to be connected to
   140     param <operation> the operation of the interface
   138     param <operation> the operation of the interface
   141     param <args> the arguments that needed by the operation
   139     param <args> the arguments that needed by the operation
   142 */
   140 */
   143 void NmAttachmentPicker::fetch(const QString &interface, 
   141 void NmAttachmentPicker::fetch(const QString &interface,
   144     const QString &operation, const QList<QVariant> *args)
   142     const QString &operation, const QList<QVariant> *args)
   145 {
   143 {
   146     NM_FUNCTION;
   144     NM_FUNCTION;
   147     
   145 
   148     delete mRequest;
   146     delete mRequest;
   149     mRequest = NULL;
   147     mRequest = NULL;
   150     XQApplicationManager appMgr;
   148     XQApplicationManager appMgr;
   151     mRequest = appMgr.create(interface, operation, true);
   149     mRequest = appMgr.create(interface, operation, true);
   152    
   150 
   153     if (mRequest) {
   151     if (mRequest) {
   154         mRequest->setSynchronous(false);
   152         mRequest->setSynchronous(false);
   155         if (args) {
   153         if (args) {
   156             mRequest->setArguments(*args);
   154             mRequest->setArguments(*args);
   157         }
   155         }
   158         connect(mRequest, SIGNAL(requestOk(const QVariant&)),
   156         connect(mRequest, SIGNAL(requestOk(const QVariant&)),
   159                 this, SIGNAL(attachmentsFetchOk(const QVariant&)));
   157                 this, SIGNAL(attachmentsFetchOk(const QVariant&)));
   160 
   158 
   161         connect(mRequest, SIGNAL(requestError(int, const QString&)),
   159         connect(mRequest, SIGNAL(requestError(int, const QString&)),
   162                 this, SIGNAL(attachmentsFetchError(int, const QString&)));
   160                 this, SIGNAL(attachmentsFetchError(int, const QString&)));
   163         
   161 
   164         mRequest->send();
   162         mRequest->send();
   165     } 
   163     }
   166 }
   164 }
       
   165 
       
   166 /*!
       
   167 	Launch the correct fetcher based on the clicked list item.
       
   168 */
       
   169 void NmAttachmentPicker::selectFetcher(HbListWidgetItem *listItem)
       
   170 {
       
   171 	QString itemText = listItem->text();
       
   172     if (itemText == hbTrId("txt_mail_list_photo")) {
       
   173         fetchImage();
       
   174     }
       
   175     else if (itemText == hbTrId("txt_mail_list_music")) {
       
   176         fetchAudio();
       
   177 	}
       
   178     else if (itemText == hbTrId("txt_mail_list_video")) {
       
   179         fetchVideo();
       
   180 	}
       
   181     else if (itemText == hbTrId("txt_mail_list_other")) {
       
   182         QMetaObject::invokeMethod(this, "fetchOther", Qt::QueuedConnection);
       
   183 	}
       
   184     else if (itemText == hbTrId("txt_mail_list_new_photo")) {
       
   185         fetchCameraStill();
       
   186 	}
       
   187 }