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 GET Operation Receive Specification State |
|
24 This state receives the specification object from the client and transfers to GetOpWaitForUser once the object is received |
|
25 A GET, DISCONNECT or ABORT will be processed |
|
26 Any other OBEX operation will be answered with an OBEX error code |
|
27 */ |
|
28 |
|
29 TObexServerStateGetOpReceiveSpecification::TObexServerStateGetOpReceiveSpecification() |
|
30 { |
|
31 #ifdef __FLOG_ACTIVE |
|
32 _LIT8(KName, "GetOpReceiveSpecification"); |
|
33 iName = KName; |
|
34 #endif |
|
35 } |
|
36 |
|
37 void TObexServerStateGetOpReceiveSpecification::Entry(CObexServerStateMachine& aContext) |
|
38 { |
|
39 // Reset specification object |
|
40 if(aContext.SpecObject()->InitReceive() != KErrNone) |
|
41 { |
|
42 aContext.Transport().Send(ERespInternalError); |
|
43 return; |
|
44 } |
|
45 aContext.Owner().SetCurrentOperation(CObex::EOpGet); |
|
46 // Chain on to Get to start receiving specification |
|
47 Get(aContext, aContext.LastReceivedPacket()); |
|
48 } |
|
49 |
|
50 void TObexServerStateGetOpReceiveSpecification::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/) |
|
51 { |
|
52 // Send ERespConflict and return to Ready |
|
53 RespondAndEndOperation(aContext, ERespConflict); |
|
54 } |
|
55 |
|
56 void TObexServerStateGetOpReceiveSpecification::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket) |
|
57 { |
|
58 // Process disconnect |
|
59 PerformDisconnect(aContext, aPacket); |
|
60 } |
|
61 |
|
62 void TObexServerStateGetOpReceiveSpecification::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/) |
|
63 { |
|
64 // Send ERespBadRequest and return to Ready |
|
65 RespondAndEndOperation(aContext, ERespBadRequest); |
|
66 } |
|
67 |
|
68 void TObexServerStateGetOpReceiveSpecification::Get(CObexServerStateMachine& aContext, CObexPacket& aPacket) |
|
69 { |
|
70 // Process packet and see if specification is complete |
|
71 // Packet contains more headers describing the object to be 'got' |
|
72 if(aContext.SpecObject()->ParseNextReceivePacket(aPacket) == CObexBaseObject::EError) |
|
73 { |
|
74 aContext.Transport().Send(aContext.SpecObject()->GetLastError()); |
|
75 aContext.ChangeState(CObexServerStateMachine::EReady); |
|
76 return; |
|
77 } |
|
78 |
|
79 if(aPacket.IsFinal()) |
|
80 {// Time to turn around and start sending our reply |
|
81 aContext.ChangeState(CObexServerStateMachine::EGetOpWaitForUser); |
|
82 } |
|
83 else |
|
84 { |
|
85 aContext.Transport().Send(ERespContinue); |
|
86 } |
|
87 } |
|
88 |
|
89 void TObexServerStateGetOpReceiveSpecification::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/) |
|
90 { |
|
91 // Send ERespConflict and return to Ready |
|
92 RespondAndEndOperation(aContext, ERespConflict); |
|
93 } |
|
94 |
|
95 void TObexServerStateGetOpReceiveSpecification::Abort(CObexServerStateMachine& aContext) |
|
96 { |
|
97 // Send ERespSuccess and return to Ready |
|
98 aContext.Notification().AbortIndication(); |
|
99 RespondAndEndOperation(aContext, ERespSuccess); |
|
100 } |
|
101 |
|
102 void TObexServerStateGetOpReceiveSpecification::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse) |
|
103 { |
|
104 // Send server app response and return to Ready |
|
105 RespondAndEndOperation(aContext, aResponse); |
|
106 } |
|
107 |
|