|
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 |
|
28 #ifdef MAIN |
|
29 #define sendmessage_test6 main |
|
30 #endif |
|
31 |
|
32 class CTestAsync6: public CActive, public CMsgCallbackBase |
|
33 { |
|
34 public: |
|
35 static CTestAsync6* NewL(); |
|
36 ~CTestAsync6(); |
|
37 void Start(); |
|
38 TInt Result(); |
|
39 |
|
40 private: |
|
41 void ConstructL(); |
|
42 CTestAsync6(); |
|
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 CTestAsync6* CTestAsync6::NewL() |
|
60 { |
|
61 CTestAsync6* self = new(ELeave)CTestAsync6(); |
|
62 self->ConstructL(); |
|
63 return self; |
|
64 } |
|
65 |
|
66 CTestAsync6::~CTestAsync6() |
|
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 CTestAsync6::ConstructL() |
|
81 { |
|
82 CActiveScheduler::Add(this); |
|
83 iMessagingService = CMessagingService::NewL(); |
|
84 iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
85 } |
|
86 |
|
87 CTestAsync6::CTestAsync6() : |
|
88 CActive(EPriorityStandard) |
|
89 { |
|
90 } |
|
91 |
|
92 void CTestAsync6::DoCancel() |
|
93 { |
|
94 |
|
95 } |
|
96 |
|
97 void CTestAsync6::RunL() |
|
98 { |
|
99 TestFunc(); |
|
100 } |
|
101 |
|
102 void CTestAsync6::Start() |
|
103 { |
|
104 SetActive(); |
|
105 TRequestStatus* temp = &iStatus; |
|
106 User::RequestComplete(temp, KErrNone); |
|
107 iWaitSchedular->Start(); |
|
108 } |
|
109 |
|
110 void CTestAsync6::NotifyResultL(TInt aErrCode, TAny* aResult) |
|
111 { |
|
112 //******************* set iResult **************************** |
|
113 iResult = aErrCode; |
|
114 //******************* set iResult **************************** |
|
115 |
|
116 iWaitSchedular->AsyncStop(); |
|
117 } |
|
118 TInt CTestAsync6::Result() |
|
119 { |
|
120 return iResult; |
|
121 } |
|
122 |
|
123 void CTestAsync6::TestFunc() |
|
124 { |
|
125 |
|
126 CSendMessageParams* messageParam = CSendMessageParams::NewL(); |
|
127 CleanupStack::PushL(messageParam); |
|
128 |
|
129 messageParam->AddRecipientL(_L("9008032761")); |
|
130 messageParam->SetMessageTypeL(_L("SMS")); |
|
131 messageParam->SetBodyTextL(_L("Hi How are you!!! Its the first Sms from imessaging")); |
|
132 |
|
133 TRAPD (errcode, iMessagingService->SendMessageL(messageParam, this)); |
|
134 iMessagingService->Cancel(0); |
|
135 CleanupStack::PopAndDestroy(messageParam); |
|
136 |
|
137 } |
|
138 |
|
139 |
|
140 int sendmessage_test6(int, char**) |
|
141 { |
|
142 __UHEAP_MARK; |
|
143 |
|
144 CTestAsync6* test = CTestAsync6::NewL(); |
|
145 test->Start(); |
|
146 |
|
147 __UHEAP_MARKEND; |
|
148 return KErrNone; |
|
149 } |