|
1 /* |
|
2 * Copyright (c) 2005-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 "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 #include <e32cons.h> |
|
19 #include <obex.h> |
|
20 #include <obexserver.h> |
|
21 |
|
22 #include "obexInitiator.h" |
|
23 |
|
24 /** |
|
25 * Creates a new object of type CObexInitiator |
|
26 */ |
|
27 CObexInitiator* CObexInitiator::NewL() |
|
28 { |
|
29 CObexInitiator* obexInit = new(ELeave) CObexInitiator(); |
|
30 CleanupStack::PushL(obexInit); |
|
31 obexInit->ConstructL(); |
|
32 CleanupStack::Pop(obexInit); |
|
33 return obexInit; |
|
34 } |
|
35 /** |
|
36 * Desctructor |
|
37 */ |
|
38 CObexInitiator::~CObexInitiator() |
|
39 { |
|
40 delete iObexServer; |
|
41 iObexServer = NULL; |
|
42 __DEBUG_ONLY(delete iConsole); |
|
43 } |
|
44 |
|
45 /** |
|
46 * Constructor |
|
47 */ |
|
48 CObexInitiator::CObexInitiator() |
|
49 { |
|
50 } |
|
51 |
|
52 /** |
|
53 * 2nd phase constructor, this creates a new CObexServer |
|
54 * with protocol information for USB Obex. |
|
55 */ |
|
56 void CObexInitiator::ConstructL() |
|
57 { |
|
58 TObexUsbProtocolInfo info; |
|
59 info.iTransport = KObexUsbProtocol; |
|
60 info.iInterfaceStringDescriptor = KObexDescription; |
|
61 iObexServer = CObexServer::NewL(info); |
|
62 __DEBUG_ONLY(iConsole = Console::NewL(KConsoleName, TSize(KConsFullScreen,KConsFullScreen)); |
|
63 iConsole->Printf(_L("A New Obex Server has been Created!\n"));); |
|
64 } |
|
65 |
|
66 |
|
67 /** |
|
68 * Start the Obex Server by calling CObexServer::Start |
|
69 * Current instance that implements MObexServerNotify |
|
70 * is passed to the CObexServer. |
|
71 */ |
|
72 void CObexInitiator::StartObexServerL() |
|
73 { |
|
74 TInt err = iObexServer->Start(this); |
|
75 User::LeaveIfError(err); |
|
76 __DEBUG_ONLY(iConsole->Printf(_L("Obex Server Started!\n\n"));); |
|
77 } |
|
78 |
|
79 |
|
80 /** |
|
81 * Stop the Obex Server and delete the CObexServer member. |
|
82 * Set to NULL to avoid de referencing freed memory |
|
83 */ |
|
84 void CObexInitiator::StopObexServer() |
|
85 { |
|
86 iObexServer->Stop(); |
|
87 } |
|
88 |
|
89 |
|
90 //Start of the MServerNotify virtual functions |
|
91 |
|
92 void CObexInitiator::ErrorIndication (TInt /*aError*/) |
|
93 { |
|
94 __DEBUG_ONLY(iConsole->Printf(_L("An OBEX Protocol error has occured!\n"));); |
|
95 } |
|
96 |
|
97 void CObexInitiator::TransportUpIndication () |
|
98 { |
|
99 __DEBUG_ONLY(iConsole->Printf(_L("Transport Up\n"));); |
|
100 } |
|
101 |
|
102 void CObexInitiator::TransportDownIndication () |
|
103 { |
|
104 __DEBUG_ONLY(iConsole->Printf(_L("Transport Down\n"));); |
|
105 } |
|
106 |
|
107 TInt CObexInitiator::ObexConnectIndication(const TObexConnectInfo& /*aRemoteInfo*/, const TDesC8& /*aInfo*/) |
|
108 { |
|
109 __DEBUG_ONLY(iConsole->Printf(_L("OBEX connection has been made with client\n"));); |
|
110 return KErrNone; |
|
111 } |
|
112 |
|
113 void CObexInitiator::ObexDisconnectIndication (const TDesC8& /*aInfo*/) |
|
114 { |
|
115 __DEBUG_ONLY(iConsole->Printf(_L("OBEX has been disconnected with client\n"));); |
|
116 } |
|
117 |
|
118 CObexBufObject* CObexInitiator::PutRequestIndication () |
|
119 { |
|
120 __DEBUG_ONLY(iConsole->Printf(_L("A Put is being made\n"));); |
|
121 return NULL; |
|
122 } |
|
123 |
|
124 TInt CObexInitiator::PutPacketIndication () |
|
125 { |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 TInt CObexInitiator::PutCompleteIndication () |
|
130 { |
|
131 __DEBUG_ONLY(iConsole->Printf(_L("Put has completed\n"));); |
|
132 return KErrNone; |
|
133 } |
|
134 |
|
135 |
|
136 CObexBufObject* CObexInitiator::GetRequestIndication (CObexBaseObject* /*aRequiredObject*/) |
|
137 { |
|
138 __DEBUG_ONLY(iConsole->Printf(_L("Client has made a Get request\n"));); |
|
139 return NULL; |
|
140 } |
|
141 |
|
142 TInt CObexInitiator::GetPacketIndication () |
|
143 { |
|
144 return KErrNone; |
|
145 } |
|
146 |
|
147 TInt CObexInitiator::GetCompleteIndication () |
|
148 { |
|
149 __DEBUG_ONLY(iConsole->Printf(_L("Get has completed\n"));); |
|
150 return KErrNone; |
|
151 } |
|
152 |
|
153 TInt CObexInitiator::SetPathIndication (const CObex::TSetPathInfo& /*aPathInfo*/, const TDesC8& /*aInfo*/) |
|
154 { |
|
155 return KErrNone; |
|
156 } |
|
157 |
|
158 void CObexInitiator::AbortIndication () |
|
159 { |
|
160 __DEBUG_ONLY(iConsole->Printf(_L("Operation aborted\n"));); |
|
161 } |
|
162 |