messagingappbase/mce/src/MceListItemArrayGetSmsNumberCDMA.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 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:  
       
    15 *     Defines methods for CMceListItemArray
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <txtetext.h>
       
    23 #include <smuthdr.h>                // CSmsHeader
       
    24 #include <SmsMessageWrappers.h>     // Transport Wrappers
       
    25 #include "MceMessageListItemArray.h"
       
    26 
       
    27 // ----------------------------------------------------
       
    28 // CMceListItemArray::GetSmsNumberL
       
    29 // This is invoked when the call key is pressed to get
       
    30 // the callback number from SMS entry if it exists,
       
    31 // otherwise this method gets the phone number from SMS
       
    32 // entry.
       
    33 // ----------------------------------------------------
       
    34 void CMceMessageListItemArray::GetSmsNumberL( const TMsvEntry& aEntry, TPhCltTelephoneNumber& aNumber ) const
       
    35     {
       
    36     TMsvId entryId = aEntry.Id();
       
    37     CMsvEntry* parentEntry = iSession->GetEntryL( entryId );
       
    38     CleanupStack::PushL( parentEntry );
       
    39     CPlainText* nullString = CPlainText::NewL();
       
    40     CleanupStack::PushL( nullString );
       
    41     CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *nullString );
       
    42     CleanupStack::PushL( header );
       
    43     CMsvStore* store = parentEntry->ReadStoreL();
       
    44     CleanupStack::PushL( store );
       
    45     header->RestoreL( *store );
       
    46 
       
    47     //
       
    48     // Get the callback number from the SMS entry if it exists
       
    49     //
       
    50     HBufC* callbackNumber = header->CdmaMessage().GetCallbackNumberL();
       
    51     if ( callbackNumber )
       
    52         {
       
    53         CleanupStack::PushL( callbackNumber );
       
    54         aNumber.Copy(callbackNumber->Des());
       
    55         CleanupStack::PopAndDestroy( callbackNumber );
       
    56         }
       
    57 
       
    58     //
       
    59     // SMS entry doesn't contain a callback number, get the number from
       
    60     // the FromAddress instead
       
    61     //
       
    62     if ( aNumber.Length() <= 0 )
       
    63         {
       
    64         aNumber = header->FromAddress();
       
    65         }
       
    66 
       
    67     CleanupStack::PopAndDestroy( 4 ); // store, header, parentEntry, nullString
       
    68     }
       
    69 
       
    70 //  End of File