|
1 // Copyright (c) 2005-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 <obex.h> |
|
17 #include "obexserverstatemachine.h" |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 |
|
23 Final Get Operation Receive State |
|
24 Waiting for reply from server app to an async notification GetCompleteIndication |
|
25 |
|
26 Any OBEX operation will cause a Protocol Error |
|
27 Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic |
|
28 A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected |
|
29 The NotificationComplete event send the response back to the client and move the state machine to Ready |
|
30 */ |
|
31 |
|
32 TObexServerStateGetOpFinal::TObexServerStateGetOpFinal() |
|
33 { |
|
34 #ifdef __FLOG_ACTIVE |
|
35 _LIT8(KName, "GetOpFinal"); |
|
36 iName = KName; |
|
37 #endif |
|
38 } |
|
39 |
|
40 void TObexServerStateGetOpFinal::Entry(CObexServerStateMachine& aContext) |
|
41 { |
|
42 aContext.Notification().GetCompleteIndication(); |
|
43 } |
|
44 |
|
45 void TObexServerStateGetOpFinal::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/) |
|
46 { |
|
47 aContext.Owner().Error(KErrIrObexPacketDuringWait); |
|
48 } |
|
49 |
|
50 void TObexServerStateGetOpFinal::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/) |
|
51 { |
|
52 aContext.Owner().Error(KErrIrObexPacketDuringWait); |
|
53 } |
|
54 |
|
55 void TObexServerStateGetOpFinal::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/) |
|
56 { |
|
57 aContext.Owner().Error(KErrIrObexPacketDuringWait); |
|
58 } |
|
59 |
|
60 void TObexServerStateGetOpFinal::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/) |
|
61 { |
|
62 aContext.Owner().Error(KErrIrObexPacketDuringWait); |
|
63 } |
|
64 |
|
65 void TObexServerStateGetOpFinal::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/) |
|
66 { |
|
67 aContext.Owner().Error(KErrIrObexPacketDuringWait); |
|
68 } |
|
69 |
|
70 void TObexServerStateGetOpFinal::Abort(CObexServerStateMachine& aContext) |
|
71 { |
|
72 aContext.Owner().Error(KErrIrObexPacketDuringWait); |
|
73 } |
|
74 |
|
75 void TObexServerStateGetOpFinal::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/) |
|
76 { |
|
77 aContext.Owner().Error(KErrIrObexPacketDuringWait); |
|
78 } |
|
79 |
|
80 void TObexServerStateGetOpFinal::Reset(CObexServerStateMachine& aContext) |
|
81 { |
|
82 // Cancel notification - if it has not already been activated |
|
83 if (!aContext.IsCallBackActive()) |
|
84 { |
|
85 aContext.Notification().CancelIndicationCallback(); |
|
86 } |
|
87 aContext.CancelCallBack(); |
|
88 aContext.ChangeState(CObexServerStateMachine::EDisconnected); |
|
89 } |
|
90 |
|
91 void TObexServerStateGetOpFinal::Start(CObexServerStateMachine& /*aContext*/) |
|
92 { |
|
93 // Panic - trying to change interface during wait |
|
94 IrOBEXUtil::Panic(EChangeInterfaceDuringWait); |
|
95 } |
|
96 |
|
97 void TObexServerStateGetOpFinal::RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse) |
|
98 { |
|
99 aContext.SetAppResponse(aAppResponse); |
|
100 aContext.CallBack(TObexServerStateGetOpFinal::ProcessNotification); |
|
101 } |
|
102 |
|
103 TInt TObexServerStateGetOpFinal::ProcessNotification(TAny* aPtr) |
|
104 { |
|
105 CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr); |
|
106 |
|
107 context.Transport().SendPacket().SetOpcode(context.AppResponse()); |
|
108 context.Transport().SendPacket().SetFinal(); |
|
109 context.Transport().Send(); |
|
110 |
|
111 context.ChangeState(CObexServerStateMachine::EReady); |
|
112 return KErrNone; |
|
113 } |
|
114 |
|
115 TBool TObexServerStateGetOpFinal::ValidResponse(TObexResponse aResponseCode) |
|
116 { |
|
117 return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue); |
|
118 } |
|
119 |
|
120 |