author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
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" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include<cmsvattachment.h> |
19 | 27 |
|
28 |
#ifdef MAIN |
|
29 |
#define sendmessage_test9 main |
|
30 |
#endif |
|
31 |
||
32 |
class CTestAsync9: public CActive, public CMsgCallbackBase |
|
33 |
{ |
|
34 |
public: |
|
35 |
static CTestAsync9* NewL(); |
|
36 |
~CTestAsync9(); |
|
37 |
void Start(); |
|
38 |
TInt Result(); |
|
39 |
||
40 |
private: |
|
41 |
void ConstructL(); |
|
42 |
CTestAsync9(); |
|
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 |
CTestAsync9* CTestAsync9::NewL() |
|
60 |
{ |
|
61 |
CTestAsync9* self = new(ELeave)CTestAsync9(); |
|
62 |
self->ConstructL(); |
|
63 |
return self; |
|
64 |
} |
|
65 |
||
66 |
CTestAsync9::~CTestAsync9() |
|
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 CTestAsync9::ConstructL() |
|
81 |
{ |
|
82 |
CActiveScheduler::Add(this); |
|
83 |
iMessagingService = CMessagingService::NewL(); |
|
84 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
85 |
} |
|
86 |
||
87 |
CTestAsync9::CTestAsync9() : |
|
88 |
CActive(EPriorityStandard) |
|
89 |
{ |
|
90 |
} |
|
91 |
||
92 |
void CTestAsync9::DoCancel() |
|
93 |
{ |
|
94 |
||
95 |
} |
|
96 |
||
97 |
void CTestAsync9::RunL() |
|
98 |
{ |
|
99 |
TestFunc(); |
|
100 |
} |
|
101 |
||
102 |
void CTestAsync9::Start() |
|
103 |
{ |
|
104 |
SetActive(); |
|
105 |
TRequestStatus* temp = &iStatus; |
|
106 |
User::RequestComplete(temp, KErrNone); |
|
107 |
iWaitSchedular->Start(); |
|
108 |
} |
|
109 |
||
110 |
void CTestAsync9::NotifyResultL(TInt aErrCode, TAny* aResult) |
|
111 |
{ |
|
112 |
//******************* set iResult **************************** |
|
113 |
iResult = aErrCode; |
|
114 |
//******************* set iResult **************************** |
|
115 |
||
116 |
iWaitSchedular->AsyncStop(); |
|
117 |
} |
|
118 |
TInt CTestAsync9::Result() |
|
119 |
{ |
|
120 |
return iResult; |
|
121 |
} |
|
122 |
||
123 |
void CTestAsync9::TestFunc() |
|
124 |
{ |
|
125 |
||
126 |
CSendMessageParams* messageParam = CSendMessageParams::NewL(); |
|
127 |
CleanupStack::PushL(messageParam); |
|
128 |
messageParam->AddRecipientL(_L("9008032761")); |
|
129 |
messageParam->SetMessageTypeL(_L("MMS")); |
|
130 |
messageParam->SetBodyTextL(_L("Hi How are you!!! Its the first mms from imessaging")); |
|
131 |
messageParam->SetSubjectL(_L("MMS")); |
|
132 |
||
133 |
CMsvAttachment* element = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); |
|
134 |
element->SetMimeTypeL(_L8("image/jpeg")); |
|
135 |
element->SetAttachmentNameL(_L("c:\\data\\images\\test1.jpg")); |
|
136 |
messageParam->AddAttachmentL(element); |
|
137 |
||
138 |
element = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); |
|
139 |
element->SetMimeTypeL(_L8("image/jpeg")); |
|
140 |
element->SetAttachmentNameL(_L("c:\\data\\images\\test2.jpg")); |
|
141 |
messageParam->AddAttachmentL(element); |
|
142 |
||
143 |
||
144 |
TRAPD(errcode, iMessagingService->SendMessageL(messageParam, this)); |
|
145 |
||
146 |
CleanupStack::PopAndDestroy(messageParam); |
|
147 |
||
148 |
} |
|
149 |
||
150 |
||
151 |
int sendmessage_test9(int, char**) |
|
152 |
{ |
|
153 |
__UHEAP_MARK; |
|
154 |
CTestAsync9* test = CTestAsync9::NewL(); |
|
155 |
test->Start(); |
|
156 |
__UHEAP_MARKEND;; |
|
157 |
||
158 |
return 0; |
|
159 |
} |
|
160 |
||
161 |
||
162 |
||
163 |
||
164 |
||
165 |