|
1 // Copyright (c) 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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef PTPSESSION_H |
|
23 #define PTPSESSION_H |
|
24 |
|
25 #include <e32svr.h> |
|
26 #include "ptpdef.h" |
|
27 #include "rptp.h" |
|
28 |
|
29 class CPtpServer; |
|
30 class CPtpTimer; |
|
31 |
|
32 /** |
|
33 * MServiceHandlerObserver M Class for callbacks |
|
34 * @since S60 3.2 |
|
35 */ |
|
36 class MServiceHandlerObserver |
|
37 { |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Called to notify send Object complete with status |
|
42 * @since S60 3.2 |
|
43 * @param aState, Object send status |
|
44 */ |
|
45 virtual void SendObjectCompleted(TInt aStatus) = 0; |
|
46 |
|
47 /** |
|
48 * Called to notify object received with name and path |
|
49 * @since S60 3.2 |
|
50 * @param aNameAndPath |
|
51 */ |
|
52 virtual void ReceivedObjectCompleted(TDes& aNameAndPath) = 0; |
|
53 |
|
54 /** |
|
55 * Called to notify DPS Discovery status |
|
56 * @param aState, Printer state |
|
57 */ |
|
58 virtual void IsDpsPrinterCompleted(TDpsPrinterState aState) = 0; |
|
59 /** |
|
60 * Cancel Outstanding request |
|
61 * @since S60 3.2 |
|
62 */ |
|
63 |
|
64 virtual void CancelOutstandingRequest() = 0; |
|
65 }; |
|
66 |
|
67 /** |
|
68 * A session class which creates an instance of PTP Stack when starting, |
|
69 * and releases used memory when closing. |
|
70 * |
|
71 * @since S60 3.2 |
|
72 */ |
|
73 NONSHARABLE_CLASS(CPtpSession) : public CSession2, MServiceHandlerObserver |
|
74 { |
|
75 public: |
|
76 /** |
|
77 * 2-phased constructor. |
|
78 * @since S60 3.2 |
|
79 */ |
|
80 static CPtpSession* NewL(CPtpServer* aServer); |
|
81 |
|
82 /** |
|
83 * C++ destructor. |
|
84 * @since S60 3.2 |
|
85 */ |
|
86 ~CPtpSession(); |
|
87 |
|
88 /** |
|
89 * From CSession2, passes the request forward to DispatchMessageL. |
|
90 * @since S60 3.2 |
|
91 */ |
|
92 void ServiceL( const RMessage2& aMessage ); |
|
93 |
|
94 /** |
|
95 * Handles the request from client. |
|
96 * @since S60 3.2 |
|
97 */ |
|
98 void DispatchMessageL( const RMessage2& aMessage ); |
|
99 |
|
100 CPtpServer* ServerP() const; |
|
101 |
|
102 |
|
103 public: // from MServiceHandlerObserver |
|
104 |
|
105 /** |
|
106 * @since S60 3.2 |
|
107 */ |
|
108 void SendObjectCompleted(TInt aStatus); |
|
109 |
|
110 /** |
|
111 * @since S60 3.2 |
|
112 */ |
|
113 void ReceivedObjectCompleted(TDes& aNameAndPath); |
|
114 |
|
115 /** |
|
116 @since S60 3.2 |
|
117 */ |
|
118 void IsDpsPrinterCompleted(TDpsPrinterState aState); |
|
119 |
|
120 void MTPSessionOpened(); |
|
121 private: |
|
122 |
|
123 /** |
|
124 * C++ constructor. |
|
125 * @since S60 3.2 |
|
126 */ |
|
127 CPtpSession(CPtpServer* aServer); |
|
128 void ConstructL(); |
|
129 |
|
130 /** |
|
131 * To create PTP stack and load Transport Plugin |
|
132 * @since S60 3.2 |
|
133 */ |
|
134 void CreateStackL(const RMessage2& aMessage); |
|
135 |
|
136 /** |
|
137 * Destroys PTP stack and Unloads Transport Plugin |
|
138 * @since S60 3.2 |
|
139 */ |
|
140 void DestroyStackL(); |
|
141 |
|
142 /** |
|
143 * Asynch. request if DPS (PictBridge) Printer connected |
|
144 * @since S60 3.2 |
|
145 */ |
|
146 TInt IsDpsPrinter(const RMessage2& aMessage, TBool& aComplete); |
|
147 |
|
148 /** |
|
149 * To get object handle By Name |
|
150 * @since S60 3.2 |
|
151 */ |
|
152 void GetObjectHandleByNameL(const RMessage2& aMessage); |
|
153 |
|
154 /** |
|
155 * To Get Object name by handle |
|
156 * @since S60 3.2 |
|
157 */ |
|
158 void GetNameByObjectHandleL(const RMessage2& aMessage); |
|
159 |
|
160 /** |
|
161 * Request to send Object |
|
162 * @since S60 3.2 |
|
163 */ |
|
164 TInt SendObject(const RMessage2& aMessage, TBool& aComplete); |
|
165 |
|
166 /** |
|
167 * Register for Object received notifications |
|
168 * @since S60 3.2 |
|
169 */ |
|
170 TInt ObjectReceivedNotify(const RMessage2& aMessage, TBool& aComplete); |
|
171 |
|
172 /** |
|
173 * Cancel previously issued Asynch. request IsDpsPrinter() |
|
174 * @since S60 3.2 |
|
175 */ |
|
176 void CancelIsDpsPrinter(); |
|
177 |
|
178 /** |
|
179 * Cancel previously issued asynch. request send Object |
|
180 * @since S60 3.2 |
|
181 */ |
|
182 void CancelSendObject(); |
|
183 |
|
184 /** |
|
185 * DeRegister for Object received notification |
|
186 * @since S60 3.2 |
|
187 */ |
|
188 void CancelObjectReceivedNotify(); |
|
189 |
|
190 /** |
|
191 * Get PTP Folder name and path |
|
192 * @since S60 3.2 |
|
193 */ |
|
194 TInt PtpFolder(const RMessage2& aMessage); |
|
195 |
|
196 /** |
|
197 * Request Cancel current PTP Transaction |
|
198 * @since S60 3.2 |
|
199 */ |
|
200 void CancelOutstandingRequest(); |
|
201 |
|
202 void CleanupL(); |
|
203 |
|
204 private: // Data |
|
205 CPtpServer* iServerP; // not owned |
|
206 RMessage2 iSendObjectMsg; |
|
207 RMessage2 iObjectReceivedNotifyMsg; |
|
208 RMessage2 iDpsPrinterMsg; |
|
209 RMessage2 iCancelMsg; |
|
210 TFileName iReceivedFile; |
|
211 CPtpTimer* iTimerP; // owned |
|
212 /** |
|
213 FLOGGER debug trace member variable. |
|
214 */ |
|
215 __FLOG_DECLARATION_MEMBER_MUTABLE; |
|
216 }; |
|
217 |
|
218 #endif // PTPSESSION_H |
|
219 |
|
220 |