wvuing/wvuieng/EngSrc/CCAMessageCreator.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004-2005 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:  Creator class for messages.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CCAMessageCreator.h"
       
    20 #include "CCAContentMessage.h"
       
    21 #include "CCATextMessage.h"
       
    22 
       
    23 #include "ChatDebugPrint.h"
       
    24 
       
    25 const TInt KSystemOperationCode = -1;
       
    26 
       
    27 //-----------------------------------------------------------------------------
       
    28 // CCAMessageCreator::CCAMessageCreator
       
    29 // ( Other items commented in header )
       
    30 //-----------------------------------------------------------------------------
       
    31 CCAMessageCreator::CCAMessageCreator()
       
    32     {
       
    33     }
       
    34 
       
    35 //-----------------------------------------------------------------------------
       
    36 // CCAMessageCreator::~CCAMessageCreator
       
    37 // ( Other items commented in header )
       
    38 //-----------------------------------------------------------------------------
       
    39 CCAMessageCreator::~CCAMessageCreator()
       
    40     {
       
    41     }
       
    42 
       
    43 //-----------------------------------------------------------------------------
       
    44 // CCAMessageCreator::NewL
       
    45 // ( Other items commented in header )
       
    46 //-----------------------------------------------------------------------------
       
    47 CCAMessageCreator* CCAMessageCreator::NewL()
       
    48     {
       
    49     CCAMessageCreator* self = new ( ELeave ) CCAMessageCreator();
       
    50     return self;
       
    51     }
       
    52 
       
    53 //-----------------------------------------------------------------------------
       
    54 // CCAMessageCreator::NewLC
       
    55 // ( Other items commented in header )
       
    56 //-----------------------------------------------------------------------------
       
    57 CCAMessageCreator* CCAMessageCreator::NewLC()
       
    58     {
       
    59     CCAMessageCreator* self = new ( ELeave ) CCAMessageCreator();
       
    60     CleanupStack::PushL( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 //-----------------------------------------------------------------------------
       
    65 // CCAMessageCreator::CreateMessageL
       
    66 // ( Other items commented in header )
       
    67 //-----------------------------------------------------------------------------
       
    68 MCAMessage* CCAMessageCreator::CreateMessageL( const SMessageData& aData ) const
       
    69     {
       
    70     CHAT_DP( D_CHAT_LIT( "CCAMessageCreator::CreateMessageL" ) );
       
    71     if ( aData.iContentType == KNullDesC8 ) // Text message
       
    72         {
       
    73         CHAT_DP( D_CHAT_LIT( "Text message" ) );
       
    74         return CreateTextMessageL( aData );
       
    75         }
       
    76     else
       
    77         {
       
    78         return CreateContentMessageL( aData );
       
    79         }
       
    80     }
       
    81 
       
    82 //-----------------------------------------------------------------------------
       
    83 // CCAMessageCreator::CreateFailedMessageL
       
    84 // ( Other items commented in header )
       
    85 //-----------------------------------------------------------------------------
       
    86 MCAMessage* CCAMessageCreator::CreateFailedMessageL(
       
    87     const MCAMessage* pSource ) const
       
    88     {
       
    89     return CreateFailedTextMessageL( pSource );
       
    90     }
       
    91 
       
    92 //-----------------------------------------------------------------------------
       
    93 // CCAMessageCreator::CreateSystemMessageL
       
    94 // ( Other items commented in header )
       
    95 //-----------------------------------------------------------------------------
       
    96 MCAMessage* CCAMessageCreator::CreateSystemMessageL( MCAMessage::TSystemMessage aType,
       
    97                                                      const TDesC& aText ) const
       
    98     {
       
    99     CCATextMessage* message = CCATextMessage::NewLC( KSystemOperationCode,
       
   100                                                      KNullDesC, KNullDesC, NULL,
       
   101                                                      NULL, aText );
       
   102     message->SetSystem( aType );
       
   103     CleanupStack::Pop( message );
       
   104     return message;
       
   105     }
       
   106 
       
   107 //-----------------------------------------------------------------------------
       
   108 // CCAMessageCreator::CreateTextMessageL
       
   109 // ( Other items commented in header )
       
   110 //-----------------------------------------------------------------------------
       
   111 MCAMessage* CCAMessageCreator::CreateTextMessageL(
       
   112     const SMessageData& aData ) const
       
   113     {
       
   114     CCATextMessage* message = CCATextMessage::NewL( aData.iOpId,
       
   115                                                     aData.iSender,
       
   116                                                     aData.iTargetId,
       
   117                                                     aData.iRecipients,
       
   118                                                     aData.iScreenNames,
       
   119                                                     aData.iText );
       
   120     message->SetMessagerType( aData.iMessager );
       
   121     return message;
       
   122     }
       
   123 
       
   124 //-----------------------------------------------------------------------------
       
   125 // CCAMessageCreator::CreatePictureMessageL
       
   126 // ( Other items commented in header )
       
   127 //-----------------------------------------------------------------------------
       
   128 MCAMessage* CCAMessageCreator::CreateContentMessageL(
       
   129     const SMessageData& aData ) const
       
   130     {
       
   131     CCAContentMessage* message = CCAContentMessage::NewL( 	aData.iOpId,
       
   132                                                            aData.iSender,
       
   133                                                            aData.iTargetId,
       
   134                                                            aData.iRecipients,
       
   135                                                            aData.iScreenNames,
       
   136                                                            aData.iContentType,
       
   137                                                            aData.iContentData,
       
   138                                                            aData.iText );
       
   139     message->SetMessagerType( aData.iMessager );
       
   140     return message;
       
   141     }
       
   142 
       
   143 //-----------------------------------------------------------------------------
       
   144 // CCAMessageCreator::CreateFailedTextMessageL
       
   145 // ( Other items commented in header )
       
   146 //-----------------------------------------------------------------------------
       
   147 MCAMessage* CCAMessageCreator::CreateFailedTextMessageL(
       
   148     const MCAMessage* pSource ) const
       
   149     {
       
   150     CCATextMessage* message = CCATextMessage::NewLC( pSource->OperationCode(),
       
   151                                                      pSource->Sender(),
       
   152                                                      pSource->Recipient(),
       
   153                                                      pSource->Recipients(),
       
   154                                                      pSource->ScreenNames(),
       
   155                                                      pSource->Text() );
       
   156     message->SetFailedL();
       
   157     CleanupStack::Pop( message );
       
   158     message->SetMessagerType( pSource->MessagerType() );
       
   159     return message;
       
   160     }
       
   161 
       
   162 //-----------------------------------------------------------------------------
       
   163 // CCAMessageCreator::CloneMessageL
       
   164 // ( Other items commented in header )
       
   165 //-----------------------------------------------------------------------------
       
   166 MCAMessage* CCAMessageCreator::CloneMessageL( const MCAMessage* aSource ) const
       
   167     {
       
   168     MCAMessage* message = NULL;
       
   169     if ( aSource->ContentType() == MCAMessage::EContentText )
       
   170         {
       
   171         // Text message
       
   172         message = CCATextMessage::NewLC( aSource->OperationCode(),
       
   173                                          aSource->Sender(),
       
   174                                          aSource->Recipient(),
       
   175                                          aSource->Recipients(),
       
   176                                          aSource->ScreenNames(),
       
   177                                          aSource->Text() );
       
   178         message->SetForwardPartL( aSource->ForwardPart() );
       
   179         }
       
   180     else
       
   181         {
       
   182         // Content message
       
   183         message = CCAContentMessage::NewLC( aSource->OperationCode(),
       
   184                                             aSource->Sender(),
       
   185                                             aSource->Recipient(),
       
   186                                             aSource->Recipients(),
       
   187                                             aSource->ScreenNames(),
       
   188                                             aSource->MimeType(),
       
   189                                             aSource->ContentData(),
       
   190                                             aSource->Text() );
       
   191         }
       
   192     static_cast< CCAMessageBase* >( message )->
       
   193     SetMessagerType( aSource->MessagerType() );
       
   194 
       
   195     CleanupStack::Pop(); // message
       
   196     return message;
       
   197     }
       
   198 
       
   199 // end of file