mobilemessaging/audiomsg/src/audiomessagesendoperation.cpp
branchRCL_3
changeset 60 7fdbb852d323
parent 0 72b543305e3a
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Provides message sending methods. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <mmsclient.h>
       
    21 #include <MsgEditorAppUi.h>   
       
    22 #include <MsgAddressControl.h>  
       
    23 #include <uniaddresshandler.h>
       
    24 
       
    25 #include <audiomessage.rsg>
       
    26 #include "audiomessagesendoperation.h"
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 // ---------------------------------------------------------
       
    31 // CAudioMessageSendOperation::NewL
       
    32 // ---------------------------------------------------------
       
    33 //
       
    34 CAudioMessageSendOperation* CAudioMessageSendOperation::NewL(
       
    35 		CMsgAddressControl& aAddressCtrl,
       
    36         CUniAddressHandler& aAddressHandler,
       
    37         MAmsOperationObserver& aObserver,
       
    38         CAudioMessageDocument& aDocument,
       
    39         CMsgEditorView& aView )
       
    40     {
       
    41     CAudioMessageSendOperation* self = new ( ELeave ) CAudioMessageSendOperation(
       
    42         aAddressCtrl,
       
    43         aAddressHandler,
       
    44         aObserver,
       
    45         aDocument, 
       
    46         aView );
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL();
       
    49     CleanupStack::Pop( self );
       
    50     return self;
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CAudioMessageSendOperation::Constructor
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CAudioMessageSendOperation::CAudioMessageSendOperation(
       
    58 		CMsgAddressControl& aAddressCtrl,
       
    59         CUniAddressHandler& aAddressHandler,
       
    60         MAmsOperationObserver& aObserver,
       
    61         CAudioMessageDocument& aDocument,
       
    62         CMsgEditorView& aView ) :
       
    63     CAudioMessageOperation( aObserver, aDocument ),
       
    64     iAddressCtrl( aAddressCtrl ),
       
    65     iAddressHandler( aAddressHandler ),
       
    66     iView( aView )
       
    67     {
       
    68     }
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CAudioMessageSendOperation::Destructor
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 CAudioMessageSendOperation::~CAudioMessageSendOperation()
       
    76     {
       
    77     Cancel();
       
    78     delete iSaveOperation;
       
    79     delete iMtmSendOperation;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CAudioMessageSendOperation::Send
       
    84 // ---------------------------------------------------------
       
    85 //
       
    86 void CAudioMessageSendOperation::Send()
       
    87     {
       
    88     ResetError();
       
    89     iSendState = EAmsSendRemoveDuplicateAddresses;
       
    90     CompleteSelf( KErrNone );
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CAudioMessageSendOperation::DoSendStepL
       
    95 // ---------------------------------------------------------
       
    96 //
       
    97 void CAudioMessageSendOperation::DoSendStepL()
       
    98     {
       
    99     switch ( iSendState )
       
   100         {
       
   101         case EAmsSendRemoveDuplicateAddresses:
       
   102             DoRemoveDuplicateAddressesL();
       
   103             break;
       
   104         case EAmsSendSave:
       
   105             DoSave();
       
   106             break;
       
   107         case EAmsSendMtmSend:
       
   108             DoSendL();
       
   109             break;
       
   110         case EAmsSendEnd:
       
   111             iObserver.EditorOperationEvent(
       
   112                 EAmsOperationSend,
       
   113                 EAmsOperationComplete );
       
   114             break;
       
   115         default:
       
   116             iObserver.EditorOperationEvent(
       
   117                 EAmsOperationSend,
       
   118                 EAmsOperationError );
       
   119             break;
       
   120         }
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // CAudioMessageSendOperation::DoRemoveDuplicateAddressesL
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 void CAudioMessageSendOperation::DoRemoveDuplicateAddressesL()
       
   128     {
       
   129     CArrayPtrFlat<CMsgAddressControl>* addressControls 
       
   130         = new ( ELeave ) CArrayPtrFlat<CMsgAddressControl>( 1 );
       
   131     CleanupStack::PushL( addressControls );
       
   132     addressControls->AppendL( &iAddressCtrl );
       
   133     if ( iAddressHandler.RemoveDuplicateAddressesL( *addressControls ) )
       
   134         {
       
   135         iDocument.SetHeaderModified( ETrue );
       
   136         }
       
   137     CleanupStack::PopAndDestroy( addressControls );
       
   138     iSendState = EAmsSendSave;
       
   139     CompleteSelf( KErrNone );
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------
       
   143 // CAudioMessageSendOperation::DoSave
       
   144 // ---------------------------------------------------------
       
   145 //
       
   146 void CAudioMessageSendOperation::DoSave()
       
   147     {
       
   148     iSendState = EAmsSendMtmSend;
       
   149     iSaveOperation->Save();
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------
       
   153 // CAudioMessageSendOperation::DoSendL
       
   154 // ---------------------------------------------------------
       
   155 //
       
   156 void CAudioMessageSendOperation::DoSendL()
       
   157     {
       
   158     iSendState = EAmsSendEnd;
       
   159     iStatus = KRequestPending;
       
   160     iMtmSendOperation = iDocument.Mtm().SendL( iStatus );
       
   161     SetActive();
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // CAudioMessageSendOperation::ConstructL
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 void CAudioMessageSendOperation::ConstructL()
       
   169     {
       
   170     iSaveOperation = CAudioMessageSaveOperation::NewL( iAddressCtrl, *this, iDocument, 
       
   171     	iView );
       
   172     }
       
   173 
       
   174 // ---------------------------------------------------------
       
   175 // CAudioMessageSendOperation::DoCancel
       
   176 // ---------------------------------------------------------
       
   177 //
       
   178 void CAudioMessageSendOperation::DoCancel()
       
   179     {
       
   180     if ( iSaveOperation )
       
   181         {
       
   182         iSaveOperation->Cancel();
       
   183         }
       
   184     if ( iMtmSendOperation )
       
   185         {
       
   186         iMtmSendOperation->Cancel();
       
   187         }
       
   188     }
       
   189 
       
   190 // ---------------------------------------------------------
       
   191 // CAudioMessageSendOperation::RunL
       
   192 // ---------------------------------------------------------
       
   193 //
       
   194 void CAudioMessageSendOperation::RunL()
       
   195     {
       
   196     if ( iStatus.Int() != KErrNone )
       
   197         {
       
   198         SetError( iStatus.Int() );
       
   199         iObserver.EditorOperationEvent(
       
   200             EAmsOperationSend,
       
   201             EAmsOperationError );
       
   202         }
       
   203     else
       
   204         {
       
   205         DoSendStepL();
       
   206         }
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------
       
   210 // CAudioMessageSendOperation::EditorOperationEvent
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 void CAudioMessageSendOperation::EditorOperationEvent(
       
   214     TAmsOperationType /*aOperation*/,
       
   215     TAmsOperationEvent /*aEvent*/ )
       
   216     {
       
   217     CompleteSelf( KErrNone );
       
   218     }
       
   219