emailuis/nmframeworkadapter/src/nmfwaaddattachmentsoperation.cpp
changeset 43 99bcbff212ad
parent 40 2c62ef3caffd
child 76 38bf5461e270
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    37     const NmMessage &message,
    37     const NmMessage &message,
    38     const QList<QString> &fileList,
    38     const QList<QString> &fileList,
    39     CFSMailClient &mailClient) :
    39     CFSMailClient &mailClient) :
    40         mMailClient(mailClient)
    40         mMailClient(mailClient)
    41 {
    41 {
       
    42     NM_FUNCTION;
       
    43     
    42     // Take own copy of the file list.
    44     // Take own copy of the file list.
    43     mFileList.clear();
    45     mFileList.clear();
    44     for (int i=0; i<fileList.count(); ++i) {
    46     for (int i=0; i<fileList.count(); ++i) {
    45         mFileList.append(fileList.at(i));
    47         mFileList.append(fileList.at(i));
    46     }
    48     }
    51 /*!
    53 /*!
    52     Destructor
    54     Destructor
    53  */
    55  */
    54 NmFwaAddAttachmentsOperation::~NmFwaAddAttachmentsOperation()
    56 NmFwaAddAttachmentsOperation::~NmFwaAddAttachmentsOperation()
    55 {
    57 {
       
    58     NM_FUNCTION;
       
    59     
    56     // Cancel all running operations.
    60     // Cancel all running operations.
    57     doCancelOperation();
    61     doCancelOperation();
    58     mFileList.clear(); 
    62     mFileList.clear(); 
    59     delete mFSMessage;
    63     delete mFSMessage;
    60 }
    64 }
    65     
    69     
    66     \sa NmOperation
    70     \sa NmOperation
    67  */
    71  */
    68 void NmFwaAddAttachmentsOperation::doRunAsyncOperation()
    72 void NmFwaAddAttachmentsOperation::doRunAsyncOperation()
    69 {
    73 {
       
    74     NM_FUNCTION;
       
    75     
    70     TRAPD(err, doRunAsyncOperationL());
    76     TRAPD(err, doRunAsyncOperationL());
    71     // Trap harness catches an error.
    77     // Trap harness catches an error.
    72     if (err != KErrNone) {
    78     if (err != KErrNone) {
    73         // File not found, inform UI.
    79         // File not found, inform UI.
    74         if (err == KErrNotFound) {
    80         if (err == KErrNotFound) {
   102 /*!
   108 /*!
   103     Leaving version of doRunAsyncOperationL
   109     Leaving version of doRunAsyncOperationL
   104  */
   110  */
   105 void NmFwaAddAttachmentsOperation::doRunAsyncOperationL()
   111 void NmFwaAddAttachmentsOperation::doRunAsyncOperationL()
   106 {
   112 {
       
   113     NM_FUNCTION;
       
   114     
   107     if (mFileList.count() > 0) {
   115     if (mFileList.count() > 0) {
   108         // Add new attachment from first file in the list.
   116         // Add new attachment from first file in the list.
   109         HBufC *fileName = NmConverter::qstringToHBufCLC(mFileList.first());
   117         HBufC *fileName = NmConverter::qstringToHBufCLC(mFileList.first());
   110         mRequestId = mFSMessage->AddNewAttachmentL(*fileName, *this);
   118         mRequestId = mFSMessage->AddNewAttachmentL(*fileName, *this);
   111         CleanupStack::PopAndDestroy(fileName);   
   119         CleanupStack::PopAndDestroy(fileName);   
   122     \param aRequestId Request id of asyncronous operation.
   130     \param aRequestId Request id of asyncronous operation.
   123  */
   131  */
   124 void NmFwaAddAttachmentsOperation::RequestResponseL(TFSProgress aEvent,
   132 void NmFwaAddAttachmentsOperation::RequestResponseL(TFSProgress aEvent,
   125                                                     TInt aRequestId)
   133                                                     TInt aRequestId)
   126 {
   134 {
       
   135     NM_FUNCTION;
       
   136     
   127     int err = NmNoError;
   137     int err = NmNoError;
   128 
   138 
   129     // Request id should always be valid. If not,
   139     // Request id should always be valid. If not,
   130     // then report general error and complete operation.
   140     // then report general error and complete operation.
   131     if (aRequestId == mRequestId) {
   141     if (aRequestId == mRequestId) {
   194 /*!
   204 /*!
   195  * Complete the operation
   205  * Complete the operation
   196  */
   206  */
   197 void NmFwaAddAttachmentsOperation::doCompleteOperation()
   207 void NmFwaAddAttachmentsOperation::doCompleteOperation()
   198 {
   208 {
       
   209     NM_FUNCTION;
       
   210     
   199     mRequestId = NmNotFoundError;
   211     mRequestId = NmNotFoundError;
   200 }
   212 }
   201 
   213 
   202 /*!
   214 /*!
   203     Cancels the async operation. \sa NmOperation
   215     Cancels the async operation. \sa NmOperation
   204  */
   216  */
   205 void NmFwaAddAttachmentsOperation::doCancelOperation()
   217 void NmFwaAddAttachmentsOperation::doCancelOperation()
   206 {
   218 {
       
   219     NM_FUNCTION;
       
   220     
   207     if (mRequestId >= 0) {
   221     if (mRequestId >= 0) {
   208         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
   222         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
   209         mRequestId = NmNotFoundError;
   223         mRequestId = NmNotFoundError;
   210     }
   224     }
   211 }
   225 }