19
|
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 |
#include<CMsvAttachment.h>
|
|
27 |
|
|
28 |
#ifdef MAIN
|
|
29 |
#define sendmessage_test10 main
|
|
30 |
#endif
|
|
31 |
|
|
32 |
class CTestAsync10: public CActive, public CMsgCallbackBase
|
|
33 |
{
|
|
34 |
public:
|
|
35 |
static CTestAsync10* NewL();
|
|
36 |
~CTestAsync10();
|
|
37 |
void Start();
|
|
38 |
TInt Result();
|
|
39 |
|
|
40 |
private:
|
|
41 |
void ConstructL();
|
|
42 |
CTestAsync10();
|
|
43 |
|
|
44 |
virtual void DoCancel();
|
|
45 |
virtual void RunL();
|
|
46 |
|
|
47 |
|
|
48 |
void TestFunc();
|
|
49 |
void NotifyResultL(TInt aErrCode, TAny* aResult);
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
private:
|
|
54 |
CActiveSchedulerWait* iWaitSchedular;
|
|
55 |
CMessagingService* iMessagingService;
|
|
56 |
TInt iResult;
|
|
57 |
};
|
|
58 |
|
|
59 |
CTestAsync10* CTestAsync10::NewL()
|
|
60 |
{
|
|
61 |
CTestAsync10* self = new(ELeave)CTestAsync10();
|
|
62 |
self->ConstructL();
|
|
63 |
return self;
|
|
64 |
}
|
|
65 |
|
|
66 |
CTestAsync10::~CTestAsync10()
|
|
67 |
{
|
|
68 |
Cancel();
|
|
69 |
|
|
70 |
if(iWaitSchedular->IsStarted())
|
|
71 |
iWaitSchedular->AsyncStop();
|
|
72 |
|
|
73 |
if(iMessagingService)
|
|
74 |
delete iMessagingService;
|
|
75 |
|
|
76 |
if(iWaitSchedular)
|
|
77 |
delete iWaitSchedular;
|
|
78 |
}
|
|
79 |
|
|
80 |
void CTestAsync10::ConstructL()
|
|
81 |
{
|
|
82 |
CActiveScheduler::Add(this);
|
|
83 |
iMessagingService = CMessagingService::NewL();
|
|
84 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait();
|
|
85 |
}
|
|
86 |
|
|
87 |
CTestAsync10::CTestAsync10() :
|
|
88 |
CActive(EPriorityStandard)
|
|
89 |
{
|
|
90 |
}
|
|
91 |
|
|
92 |
void CTestAsync10::DoCancel()
|
|
93 |
{
|
|
94 |
|
|
95 |
}
|
|
96 |
|
|
97 |
void CTestAsync10::RunL()
|
|
98 |
{
|
|
99 |
TestFunc();
|
|
100 |
}
|
|
101 |
|
|
102 |
void CTestAsync10::Start()
|
|
103 |
{
|
|
104 |
SetActive();
|
|
105 |
TRequestStatus* temp = &iStatus;
|
|
106 |
User::RequestComplete(temp, KErrNone);
|
|
107 |
iWaitSchedular->Start();
|
|
108 |
}
|
|
109 |
|
|
110 |
void CTestAsync10::NotifyResultL(TInt aErrCode, TAny* aResult)
|
|
111 |
{
|
|
112 |
//******************* set iResult ****************************
|
|
113 |
iResult = aErrCode;
|
|
114 |
//******************* set iResult ****************************
|
|
115 |
|
|
116 |
iWaitSchedular->AsyncStop();
|
|
117 |
}
|
|
118 |
TInt CTestAsync10::Result()
|
|
119 |
{
|
|
120 |
return iResult;
|
|
121 |
}
|
|
122 |
|
|
123 |
void CTestAsync10::TestFunc()
|
|
124 |
{
|
|
125 |
|
|
126 |
CSendMessageParams* messageParam = CSendMessageParams::NewL();
|
|
127 |
CleanupStack::PushL( messageParam );
|
|
128 |
messageParam->SetLaunchEditor(ETrue);
|
|
129 |
messageParam->AddRecipientL(_L("9008032761"));
|
|
130 |
messageParam->SetMessageTypeL(_L("MMS"));
|
|
131 |
messageParam->SetBodyTextL(_L("Hi How are you!!! Its the first mms from imessaging"));
|
|
132 |
messageParam->SetSubjectL(_L("MMS"));
|
|
133 |
|
|
134 |
CMsvAttachment* element = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
|
|
135 |
element->SetMimeTypeL(_L8("image/jpeg"));
|
|
136 |
element->SetAttachmentNameL(_L("c:\\data\\images\\test1.jpg"));
|
|
137 |
messageParam->AddAttachmentL(element);
|
|
138 |
|
|
139 |
element = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
|
|
140 |
element->SetMimeTypeL(_L8("image/jpeg"));
|
|
141 |
element->SetAttachmentNameL(_L("c:\\data\\images\\test2.jpg"));
|
|
142 |
messageParam->AddAttachmentL(element);
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
TRAPD(errcode, iMessagingService->SendMessageL(messageParam, this));
|
|
147 |
|
|
148 |
CleanupStack::PopAndDestroy( messageParam );
|
|
149 |
|
|
150 |
|
|
151 |
}
|
|
152 |
|
|
153 |
|
|
154 |
int sendmessage_test10(int, char**)
|
|
155 |
{
|
|
156 |
__UHEAP_MARK;
|
|
157 |
CTestAsync10* test = CTestAsync10::NewL();
|
|
158 |
test->Start();
|
|
159 |
__UHEAP_MARKEND;
|
|
160 |
|
|
161 |
return 0;
|
|
162 |
}
|
|
163 |
|
|
164 |
|