wvuing/wvuieng/EngSrc/CCAContentMessage.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 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:  Message containing picture.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CCAContentMessage.h"
       
    20 #include "PublicEngineDefinitions.h"
       
    21 
       
    22 #include <fbs.h>
       
    23 
       
    24 /// Constants
       
    25 _LIT8( KMimeJpeg, "image/jpeg" );
       
    26 _LIT8( KMimeGif, "Image/gif" );
       
    27 
       
    28 //-----------------------------------------------------------------------------
       
    29 // CCAContentMessage::CCAContentMessage
       
    30 // ( Other items commented in header )
       
    31 //-----------------------------------------------------------------------------
       
    32 CCAContentMessage::CCAContentMessage()
       
    33     {
       
    34     iThumbnailSize.SetSize( 10, 10 );
       
    35     }
       
    36 
       
    37 //-----------------------------------------------------------------------------
       
    38 // CCAContentMessage::~CCAContentMessage
       
    39 // ( Other items commented in header )
       
    40 //-----------------------------------------------------------------------------
       
    41 CCAContentMessage::~CCAContentMessage()
       
    42     {
       
    43     __ASSERT_DEBUG( iOwnerCount == 0, User::Panic( KCAEnginePanicCategory ,
       
    44                                                    KErrInUse ) );
       
    45     delete iThumbnail;
       
    46     }
       
    47 
       
    48 //-----------------------------------------------------------------------------
       
    49 // CCAContentMessage::NewL
       
    50 // ( Other items commented in header )
       
    51 //-----------------------------------------------------------------------------
       
    52 CCAContentMessage* CCAContentMessage::NewL( TInt aOpCode,
       
    53                                             const TDesC& aSender,
       
    54                                             const TDesC& aRecipient,
       
    55                                             const MDesCArray* aRecipients,
       
    56                                             const MDesCArray* aScreenNames,
       
    57                                             const TDesC8& aContentType,
       
    58                                             const TDesC8& aContentData,
       
    59                                             const TDesC& aContentAddress )
       
    60     {
       
    61     CCAContentMessage* self = CCAContentMessage::NewLC( aOpCode,
       
    62                                                         aSender,
       
    63                                                         aRecipient,
       
    64                                                         aRecipients,
       
    65                                                         aScreenNames,
       
    66                                                         aContentType,
       
    67                                                         aContentData,
       
    68                                                         aContentAddress );
       
    69     CleanupStack::Pop( self );
       
    70     return self;
       
    71     }
       
    72 
       
    73 //-----------------------------------------------------------------------------
       
    74 // CCAContentMessage::NewL
       
    75 // ( Other items commented in header )
       
    76 //-----------------------------------------------------------------------------
       
    77 CCAContentMessage* CCAContentMessage::NewL()
       
    78     {
       
    79     return CCAContentMessage::NewL( 0, KNullDesC, KNullDesC, NULL, NULL,
       
    80                                     KNullDesC8, KNullDesC8, KNullDesC );
       
    81     }
       
    82 
       
    83 //-----------------------------------------------------------------------------
       
    84 // CCAContentMessage::NewLC
       
    85 // ( Other items commented in header )
       
    86 //-----------------------------------------------------------------------------
       
    87 CCAContentMessage* CCAContentMessage::NewLC( TInt aOpCode,
       
    88                                              const TDesC& aSender,
       
    89                                              const TDesC& aRecipient,
       
    90                                              const MDesCArray* aRecipients,
       
    91                                              const MDesCArray* aScreenNames,
       
    92                                              const TDesC8& aContentType,
       
    93                                              const TDesC8& aContentData,
       
    94                                              const TDesC& aContentAddress )
       
    95     {
       
    96     CCAContentMessage* self = new ( ELeave ) CCAContentMessage();
       
    97     CleanupStack::PushL( self );
       
    98     self->ConstructL( aContentType, aContentData, aContentAddress );
       
    99     self->CCAMessageBase::ConstructL( aOpCode, aSender, aRecipient, aRecipients,
       
   100                                       aScreenNames );
       
   101     return self;
       
   102     }
       
   103 
       
   104 //-----------------------------------------------------------------------------
       
   105 // CCAContentMessage::ConstructL
       
   106 // ( Other items commented in header )
       
   107 //-----------------------------------------------------------------------------
       
   108 void CCAContentMessage::ConstructL( const TDesC8& aContentType,
       
   109                                     const TDesC8& aContentData,
       
   110                                     const TDesC& aContentAddress )
       
   111     {
       
   112     iMimeType = aContentType.AllocL();
       
   113     iContentData = aContentData.AllocL();
       
   114     iText = aContentAddress.AllocL();
       
   115 
       
   116     if ( !( aContentType.CompareF( KMimeGif ) == 0 ||
       
   117             aContentType.CompareF( KMimeJpeg ) == 0 ) )
       
   118         {
       
   119         iContentType = EContentOther;
       
   120         }
       
   121     else
       
   122         {
       
   123         iContentType = EContentPicture;
       
   124         }
       
   125 
       
   126     if ( iContentType == EContentOther )
       
   127         {
       
   128         SetProcessState( EContentNotSupported );
       
   129         }
       
   130     }
       
   131 
       
   132 //-----------------------------------------------------------------------------
       
   133 // CCAContentMessage::SizeInBytes
       
   134 // ( Other items commented in header )
       
   135 //-----------------------------------------------------------------------------
       
   136 TInt CCAContentMessage::SizeInBytes() const
       
   137     {
       
   138     return  CCAMessageBase::SizeInBytes() +
       
   139             iMimeType->Size() +
       
   140             iContentData->Size() +
       
   141             sizeof( *this );
       
   142     }
       
   143 
       
   144 //-----------------------------------------------------------------------------
       
   145 // CCAContentMessage::ContentType
       
   146 // ( Other items commented in header )
       
   147 //-----------------------------------------------------------------------------
       
   148 MCAMessage::TContentType CCAContentMessage::ContentType() const
       
   149     {
       
   150     return iContentType;
       
   151     }
       
   152 
       
   153 //-----------------------------------------------------------------------------
       
   154 // CCAContentMessage::ContentType
       
   155 // ( Other items commented in header )
       
   156 //-----------------------------------------------------------------------------
       
   157 void CCAContentMessage::ReleaseTemporaryContentData()
       
   158     {
       
   159     SetProcessState( EContentReady );
       
   160     delete iThumbnail;
       
   161     iThumbnail = NULL;
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // CCAContentMessage::InternalizeL()
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 void CCAContentMessage::InternalizeL( RReadStream& aStream )
       
   169     {
       
   170     CCAMessageBase::InternalizeL( aStream );
       
   171 
       
   172     if ( !( iMimeType->CompareF( KMimeGif ) == 0 ||
       
   173             iMimeType->CompareF( KMimeJpeg ) == 0 ) )
       
   174         {
       
   175         iContentType = EContentOther;
       
   176         }
       
   177     else
       
   178         {
       
   179         iContentType = EContentPicture;
       
   180         }
       
   181 
       
   182     if ( iContentType == EContentOther )
       
   183         {
       
   184         SetProcessState( EContentNotSupported );
       
   185         }
       
   186     else
       
   187         {
       
   188         SetProcessState( EContentReady );
       
   189         }
       
   190     }
       
   191 
       
   192 //-----------------------------------------------------------------------------
       
   193 // CCAContentMessage::ThumbnailSize
       
   194 // ( Other items commented in header )
       
   195 //-----------------------------------------------------------------------------
       
   196 TSize CCAContentMessage::ThumbnailSize() const
       
   197     {
       
   198     return iThumbnailSize;
       
   199     }
       
   200 
       
   201 //-----------------------------------------------------------------------------
       
   202 // CCAContentMessage::SetThumbnailSize
       
   203 // ( Other items commented in header )
       
   204 //-----------------------------------------------------------------------------
       
   205 EXPORT_C void CCAContentMessage::SetThumbnailSize( TSize aSize )
       
   206     {
       
   207     iThumbnailSize = aSize;
       
   208     }
       
   209 
       
   210 //-----------------------------------------------------------------------------
       
   211 // CCAContentMessage::SetThumbnail
       
   212 // ( Other items commented in header )
       
   213 //-----------------------------------------------------------------------------
       
   214 void CCAContentMessage::SetThumbnail( CFbsBitmap* aThumbnail )
       
   215     {
       
   216     delete iThumbnail;
       
   217     iThumbnail = aThumbnail;
       
   218     }
       
   219 
       
   220 //-----------------------------------------------------------------------------
       
   221 // CCAContentMessage::Thumbnail
       
   222 // ( Other items commented in header )
       
   223 //-----------------------------------------------------------------------------
       
   224 EXPORT_C CFbsBitmap* CCAContentMessage::Thumbnail() const
       
   225     {
       
   226     return iThumbnail;
       
   227     }
       
   228 
       
   229 // end of file