|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "CWspPrimitiveSender.h" |
|
17 |
|
18 #include <wsp/WspTypes.h> |
|
19 |
|
20 #include <http/framework/cprotocolhandler.h> |
|
21 |
|
22 #include "MWspPrimitiveSenderCallback.h" |
|
23 |
|
24 const TInt KWspPrimitiveSenderActivePriority = KTransactionActivePriority; |
|
25 |
|
26 CWspPrimitiveSender* CWspPrimitiveSender::NewL(MWspPrimitiveSenderCallback& aCallback) |
|
27 { |
|
28 return new (ELeave) CWspPrimitiveSender(aCallback); |
|
29 } |
|
30 |
|
31 CWspPrimitiveSender::~CWspPrimitiveSender() |
|
32 { |
|
33 Cancel(); |
|
34 } |
|
35 |
|
36 CWspPrimitiveSender::CWspPrimitiveSender(MWspPrimitiveSenderCallback& aCallback) |
|
37 : CActive(KWspPrimitiveSenderActivePriority), iCallback(aCallback) |
|
38 { |
|
39 CActiveScheduler::Add(this); |
|
40 } |
|
41 |
|
42 void CWspPrimitiveSender::InitiateSend(TWspPrimitive aPrimitive) |
|
43 { |
|
44 // Cancel ourselves as this could be superceeding a previous request |
|
45 Cancel(); |
|
46 |
|
47 // Need to set this object active and complete the request |
|
48 if (!IsActive()) |
|
49 { |
|
50 iPrimitive = aPrimitive; |
|
51 TRequestStatus* pStat = &iStatus; |
|
52 User::RequestComplete(pStat, KErrNone); |
|
53 SetActive(); |
|
54 } |
|
55 } |
|
56 |
|
57 void CWspPrimitiveSender::RunL() |
|
58 { |
|
59 // Get the callback object to send the WSP primitive |
|
60 iCallback.SendPrimitiveL(iPrimitive); |
|
61 } |
|
62 |
|
63 TInt CWspPrimitiveSender::RunError(TInt aError) |
|
64 { |
|
65 // RunL() left - get callback object to handle this |
|
66 return iCallback.WspPrimitiveSenderCallbackError(aError); |
|
67 } |
|
68 |
|
69 void CWspPrimitiveSender::DoCancel() |
|
70 { |
|
71 } |