emailuis/nmframeworkadapter/src/nmfwaremoveattachmentoperation.cpp
changeset 76 38bf5461e270
parent 43 99bcbff212ad
equal deleted inserted replaced
74:6c59112cfd31 76:38bf5461e270
    23            attachment from the message.
    23            attachment from the message.
    24            
    24            
    25     NmFwaRemoveAttachmentOperation is an async operation which removes attachment from the message.
    25     NmFwaRemoveAttachmentOperation is an async operation which removes attachment from the message.
    26     \sa NmOperation
    26     \sa NmOperation
    27  */
    27  */
       
    28 
       
    29 void ResetAndDestroyArray( TAny* aAny )
       
    30     {
       
    31     RPointerArray<CFSMailMessagePart>* ptrArray =
       
    32             reinterpret_cast<RPointerArray<CFSMailMessagePart>*> (aAny);
       
    33     ptrArray->ResetAndDestroy();
       
    34     }
       
    35 
       
    36 void CleanupResetAndDestroyPushL( RPointerArray<CFSMailMessagePart>& aArray )
       
    37     {
       
    38     TCleanupItem item( &ResetAndDestroyArray, &aArray );
       
    39     CleanupStack::PushL( item );
       
    40     }
    28 
    41 
    29 /*!
    42 /*!
    30     Constructor
    43     Constructor
    31     
    44     
    32     \param message Message where attachment to be removed.
    45     \param message Message where attachment to be removed.
    79 void NmFwaRemoveAttachmentOperation::doRunAsyncOperationL()
    92 void NmFwaRemoveAttachmentOperation::doRunAsyncOperationL()
    80 {
    93 {
    81     NM_FUNCTION;
    94     NM_FUNCTION;
    82     
    95     
    83     CFSMailMessage *msg = NULL;
    96     CFSMailMessage *msg = NULL;
    84 
       
    85     msg = CFSMailMessage::NewL(mMessage);
    97     msg = CFSMailMessage::NewL(mMessage);
       
    98     CleanupStack::PushL( msg );
    86     
    99     
    87     // Get attachment list from the message
   100     // Get attachment list from the message
    88     RPointerArray<CFSMailMessagePart> attachments;
   101     RPointerArray<CFSMailMessagePart> attachments;
    89     attachments.Reset();
   102     CleanupResetAndDestroyPushL( attachments );
    90     msg->AttachmentListL(attachments);
   103     msg->AttachmentListL(attachments);
    91         
   104         
    92     // Search through all attachments from message and remove attachment
   105     // Search through all attachments from message and remove attachment
    93     // if message part match.
   106     // if message part match.
    94     bool found(false);
   107     bool found(false);
    97             mRequestId = msg->RemoveChildPartL(attachments[i]->GetPartId(),*this);
   110             mRequestId = msg->RemoveChildPartL(attachments[i]->GetPartId(),*this);
    98             found = true;
   111             found = true;
    99             break;
   112             break;
   100         }
   113         }
   101     }
   114     }
   102     attachments.ResetAndDestroy();   
   115     
   103     delete msg;
   116     CleanupStack::PopAndDestroy( 2, msg ); // attachments, msg
   104     msg = NULL;
       
   105     // if attachment is not found, request to plugin is not made
   117     // if attachment is not found, request to plugin is not made
   106     // and the operation should be completed here
   118     // and the operation should be completed here
   107     if (!found) {
   119     if (!found) {
   108         completeOperation(NmNotFoundError);
   120         completeOperation(NmNotFoundError);
   109     }
   121     }