serviceproviders/sapi_messaging/tsrc/dev/tmessagingtest/tmsg_sendmessageiter1/src/sendmessage11.cpp
changeset 22 fc9cf246af83
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "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 *
       
    16 */
       
    17 
       
    18  
       
    19 // STLport regression testsuite component.
       
    20 // To compile as a separate example, please #define MAIN.
       
    21 
       
    22 #include<e32base.h>
       
    23 
       
    24 #include "messagingservice.h"
       
    25 #include "sendmessage.h"
       
    26 
       
    27 #ifdef MAIN
       
    28 #define sendmessage_test11 main
       
    29 #endif
       
    30 
       
    31 
       
    32 
       
    33 int sendmessage_test11(int, char**)
       
    34     {
       
    35     __UHEAP_MARK;
       
    36     TInt result = KErrNone;
       
    37     TMsvId messageid = 0;
       
    38     CFilterParamInfo* filterParams = CFilterParamInfo::NewL();
       
    39     CleanupStack::PushL(filterParams);
       
    40     filterParams->AddMtmL(_L("MMS"));
       
    41     CMsvEntrySelection* entryselection = NULL ;  
       
    42     CMessagingService* test = (CMessagingService*) CMessagingService::NewL() ; 
       
    43     CleanupStack::PushL( test );
       
    44     TRAPD(err, test->GetIdListL(filterParams,0,NULL,entryselection));
       
    45     if(err==KErrNone)
       
    46         {
       
    47         CMessageHeader* header = NULL;
       
    48         TInt index=0;
       
    49         test->GetNextHeaderL(filterParams, entryselection, index, NULL, header);
       
    50         if(header)
       
    51             {
       
    52             messageid = header->MessageId();
       
    53             }
       
    54         delete header;
       
    55         }
       
    56     delete entryselection;
       
    57     
       
    58     CSendMessageParams* messageParam = CSendMessageParams::NewL();
       
    59     CleanupStack::PushL(messageParam);
       
    60     messageParam->AddRecipientL(_L("9008032761"));
       
    61     messageParam->AddRecipientL(_L("9008032762"));
       
    62     messageParam->SetMessageTypeL(_L("SMS"));
       
    63     messageParam->SetBodyTextL(_L("Hi How are you!!! Its the first sms from imessaging"));
       
    64     if(messageid > 0)
       
    65     messageParam->SetTemplateId(messageid);
       
    66     
       
    67     TRAP(result, test->SendMessageL(messageParam, NULL));
       
    68     
       
    69     CleanupStack::PopAndDestroy(2, test) ;
       
    70     CleanupStack::PopAndDestroy(filterParams) ;
       
    71 
       
    72     __UHEAP_MARKEND;
       
    73     if(messageid)
       
    74         {
       
    75         if(result==KErrNotSupported)
       
    76             return KErrNone;
       
    77         else
       
    78             return KErrGeneral;
       
    79         }
       
    80     else
       
    81     return result;
       
    82     }