|
1 // Copyright (c) 2003-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 "TestObexErrorCodes.h" |
|
17 |
|
18 /** |
|
19 * Static NewL |
|
20 * |
|
21 * @return Base class* |
|
22 */ |
|
23 CTestObexErrorCodesServer* CTestObexErrorCodesServer::NewL(CControllerConsoleTest* aOwner) |
|
24 { |
|
25 CTestObexErrorCodesServer* self = new(ELeave) CTestObexErrorCodesServer; |
|
26 CleanupStack::PushL(self); |
|
27 self->ConstructL(aOwner); |
|
28 self->StartIrdaServerL(); |
|
29 CleanupStack::Pop( self ); |
|
30 |
|
31 return self; |
|
32 } |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 /** |
|
38 * |
|
39 * CTestObexErrorCodesServer |
|
40 * |
|
41 */ |
|
42 |
|
43 CTestObexErrorCodesServer::CTestObexErrorCodesServer() |
|
44 { |
|
45 } |
|
46 |
|
47 /** |
|
48 * |
|
49 * ~CTestObexErrorCodesServer |
|
50 * |
|
51 */ |
|
52 |
|
53 CTestObexErrorCodesServer::~CTestObexErrorCodesServer() |
|
54 { |
|
55 delete iServer; |
|
56 } |
|
57 |
|
58 void CTestObexErrorCodesServer::Stop() |
|
59 { |
|
60 iOwner->iConsole->Printf(_L("About to Stop the iServer ..\n")); |
|
61 |
|
62 if(iServer) |
|
63 iServer->Stop(); |
|
64 iOwner->iConsole->Printf(_L("iServer Stopped ..\n")); |
|
65 |
|
66 } |
|
67 |
|
68 |
|
69 void CTestObexErrorCodesServer::Start() |
|
70 { |
|
71 |
|
72 iOwner->iConsole->Printf(_L("About to Start the iServer ..\n")); |
|
73 |
|
74 TInt err = iServer->Start (this); |
|
75 iOwner->iConsole->Printf(_L("Server started with err=%d ..\n"), err); |
|
76 |
|
77 iErrorCode = ERespSuccess; //first returned code not Continue as this really breaks everything |
|
78 } |
|
79 |
|
80 |
|
81 /** |
|
82 Virtual functions from OBEX |
|
83 */ |
|
84 |
|
85 void CTestObexErrorCodesServer::ErrorIndication(TInt /*aError*/) |
|
86 { |
|
87 } |
|
88 |
|
89 void CTestObexErrorCodesServer::TransportUpIndication() |
|
90 { |
|
91 iOwner->iConsole->Printf(_L("Transport layer now connected\n")); |
|
92 } |
|
93 |
|
94 void CTestObexErrorCodesServer::TransportDownIndication() |
|
95 { |
|
96 iOwner->iConsole->Printf(_L("Transport layer has gone down\n")); |
|
97 } |
|
98 |
|
99 TInt CTestObexErrorCodesServer::ObexConnectIndication(const TObexConnectInfo& /*aRemoteInfo*/, const TDesC8& /*aInfo*/) |
|
100 { |
|
101 return KErrNone; |
|
102 } |
|
103 |
|
104 void CTestObexErrorCodesServer::ObexDisconnectIndication(const TDesC8& /*aInfo*/) |
|
105 { |
|
106 iOwner->iConsole->Printf(_L("\r\nObex Disconnected\n")); |
|
107 } |
|
108 |
|
109 CObexBufObject* CTestObexErrorCodesServer::PutRequestIndication() |
|
110 { |
|
111 return (iObject); |
|
112 } |
|
113 |
|
114 TInt CTestObexErrorCodesServer::PutPacketIndication() |
|
115 { |
|
116 return (KErrNone); |
|
117 |
|
118 } |
|
119 |
|
120 TInt CTestObexErrorCodesServer::PutCompleteIndication() |
|
121 { |
|
122 |
|
123 iOwner->iConsole->Printf(_L("PutComplete returning error code %d ..\n"), iErrorCode); |
|
124 //return the changing error code here |
|
125 TInt retValue = (iErrorCode * -1 ) + KErrIrObexRespBase; |
|
126 |
|
127 iErrorCode++; |
|
128 |
|
129 return (retValue); |
|
130 // return (KErrNone); |
|
131 |
|
132 } |
|
133 |
|
134 CObexBufObject* CTestObexErrorCodesServer::GetRequestIndication(CObexBaseObject* /*aRequiredObject*/) |
|
135 { |
|
136 return (NULL); |
|
137 } |
|
138 |
|
139 TInt CTestObexErrorCodesServer::GetPacketIndication() |
|
140 { |
|
141 //return the changing error code here |
|
142 TInt retValue = iErrorCode; |
|
143 if ( iErrorCode < ERespDatabaseLocked ) |
|
144 iErrorCode++; |
|
145 else |
|
146 iErrorCode = ERespContinue; |
|
147 |
|
148 return (retValue); |
|
149 } |
|
150 |
|
151 TInt CTestObexErrorCodesServer::GetCompleteIndication() |
|
152 { |
|
153 //return the changing error code here |
|
154 TInt retValue = iErrorCode; |
|
155 if ( iErrorCode < ERespDatabaseLocked ) |
|
156 iErrorCode++; |
|
157 else |
|
158 iErrorCode = ERespContinue; |
|
159 |
|
160 return (retValue); |
|
161 } |
|
162 |
|
163 TInt CTestObexErrorCodesServer::SetPathIndication(const CObex::TSetPathInfo& /*aPathInfo*/, const TDesC8& /*aInfo*/) |
|
164 { |
|
165 //return the changing error code here |
|
166 TInt retValue = iErrorCode; |
|
167 if ( iErrorCode < ERespDatabaseLocked ) |
|
168 iErrorCode++; |
|
169 else |
|
170 iErrorCode = ERespContinue; |
|
171 |
|
172 return (retValue); |
|
173 } |
|
174 |
|
175 void CTestObexErrorCodesServer::AbortIndication() |
|
176 { |
|
177 } |
|
178 |
|
179 |
|
180 void CTestObexErrorCodesServer::StartIrdaServerL() |
|
181 { |
|
182 |
|
183 iOwner->iConsole->Printf(_L("About to load the CObexServer...\n")); |
|
184 |
|
185 TObexIrProtocolInfo aInfo; |
|
186 aInfo.iAddr.SetPort(9);//default obex server for now |
|
187 aInfo.iTransport = _L("IrTinyTP"); |
|
188 aInfo.iClassName = _L8("OBEX"); |
|
189 aInfo.iAttributeName = _L8("IrDA:TinyTP:LsapSel"); |
|
190 |
|
191 |
|
192 iServer = CObexServer::NewL (aInfo); |
|
193 |
|
194 |
|
195 iBuf = CBufFlat::NewL(5000);//5000 - what should I put?? |
|
196 iObject = CObexBufObject::NewL (iBuf); |
|
197 iOwner->iConsole->Printf(_L("Irda Server loaded Success \n")); |
|
198 |
|
199 |
|
200 } |