messagingappbase/sendui/mmsdirectupload/src/MDUSyncCreateAndSend.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:   Wrapper to make message creation and sending synchronous.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <e32def.h>     // for basic types
       
    23 #include <E32BASE.H>    // for CActiveScheduler
       
    24 #include <eikenv.h>     // for CBase
       
    25 
       
    26 #include "MDUSyncCreateAndSend.h"
       
    27 
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CMDUSyncCreateAndSend::CMDUSyncCreateAndSend
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CMDUSyncCreateAndSend::CMDUSyncCreateAndSend()
       
    38     {
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------
       
    42 // CMDUSyncCreateAndSend::ConstructL
       
    43 // Symbian 2nd phase constructor can leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CMDUSyncCreateAndSend::ConstructL( CCoeEnv& aCoeEnv, CSendUiSingleton& aSingleton )
       
    47     {
       
    48     iCreateAndSend = CMDUCreateAndSend::NewL( aCoeEnv, aSingleton, this );
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // CMDUSyncCreateAndSend::NewLC()
       
    53 // Two-phased constructor.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CMDUSyncCreateAndSend* CMDUSyncCreateAndSend::NewLC( CCoeEnv& aCoeEnv, CSendUiSingleton& aSingleton )
       
    57     {
       
    58     CMDUSyncCreateAndSend* self = new(ELeave) CMDUSyncCreateAndSend();
       
    59 
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL( aCoeEnv, aSingleton );
       
    62     
       
    63     return self;
       
    64     }
       
    65 
       
    66 // Destructor
       
    67 CMDUSyncCreateAndSend::~CMDUSyncCreateAndSend()
       
    68     {
       
    69     if ( iWait.IsStarted() )
       
    70         {
       
    71         iWait.AsyncStop();
       
    72         }
       
    73 
       
    74     delete iCreateAndSend;
       
    75     }
       
    76 
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CMDUSyncCreateAndSend::CreateAndSendL
       
    80 // Creates and sends as many MMS messages as there are files
       
    81 // to be send.Synchronous operation.
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CMDUSyncCreateAndSend::CreateAndSendL(
       
    86     CArrayPtrFlat<CSendUiAttachment>* aAttachments,
       
    87     const TDesC& aToAddress,
       
    88     const TDesC& aToAlias,
       
    89     TInt aMaxMsgSize )
       
    90     {
       
    91     iCreateAndSend->CreateAndSendL(
       
    92         aAttachments,
       
    93         aToAddress,
       
    94         aToAlias,
       
    95         aMaxMsgSize );
       
    96 
       
    97     BeginActiveWait();
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // CMDUSyncCreateAndSend::MessagesReady
       
   102 // Callback function called when message creation is completed.
       
   103 // (other items were commented in a header).
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CMDUSyncCreateAndSend::MessagesReady()
       
   107     {
       
   108     if( !iWait.IsStarted() )
       
   109         {
       
   110         return;
       
   111         }
       
   112     iWait.AsyncStop();
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------
       
   116 // CMDUSyncCreateAndSend::BeginActiveWait
       
   117 // Starts active scheduler waiter.
       
   118 // (other items were commented in a header).
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CMDUSyncCreateAndSend::BeginActiveWait()
       
   122     {
       
   123     if( iWait.IsStarted() )
       
   124         {
       
   125         return;
       
   126         }
       
   127     iWait.Start();
       
   128     }
       
   129 
       
   130 // End of file