sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Abstraction representing a UNIX file descriptor
|
sl@0
|
15 |
// CFileDescBase maintains the simple semantics of
|
sl@0
|
16 |
// Dup() and Close(), so the final Close() will
|
sl@0
|
17 |
// delete the object and hence call the destructor.
|
sl@0
|
18 |
//
|
sl@0
|
19 |
//
|
sl@0
|
20 |
|
sl@0
|
21 |
#ifndef _FDESC_H
|
sl@0
|
22 |
#define _FDESC_H
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <e32std.h>
|
sl@0
|
25 |
#include <e32atomics.h>
|
sl@0
|
26 |
#include <e32cons.h>
|
sl@0
|
27 |
#include <f32file.h>
|
sl@0
|
28 |
#include <es_sock.h>
|
sl@0
|
29 |
#include <c32comm.h>
|
sl@0
|
30 |
#include <stddef.h>
|
sl@0
|
31 |
#include <cdblen.h>
|
sl@0
|
32 |
#include <commdb.h>
|
sl@0
|
33 |
#include <commdbconnpref.h>
|
sl@0
|
34 |
#include <sys/stat.h>
|
sl@0
|
35 |
#include <fcntl.h>
|
sl@0
|
36 |
#include <rpipe.h>
|
sl@0
|
37 |
#include <in_sock.h>
|
sl@0
|
38 |
|
sl@0
|
39 |
#include "base.h"
|
sl@0
|
40 |
#include "StdioClient.h"
|
sl@0
|
41 |
|
sl@0
|
42 |
//FD attributes used internally by the backend
|
sl@0
|
43 |
const TUint KInvalidFd = 0x00000001;
|
sl@0
|
44 |
const TUint KMMapedFd = 0x00000002;
|
sl@0
|
45 |
const TUint KCloseonExec = 0x00000004;
|
sl@0
|
46 |
const TUint KPipeFd = 0x00000008;
|
sl@0
|
47 |
const TUint KIoctlOutstanding = 0x00000010;
|
sl@0
|
48 |
const TUint KConsoleFd = 0x00000020;
|
sl@0
|
49 |
const TUint KFifoFd = 0x00000030;
|
sl@0
|
50 |
const TUint KSpawnCloseInChild = 0x00000040;
|
sl@0
|
51 |
|
sl@0
|
52 |
#define SET_CLOSE_ON_EXEC_FLG (1 << 2)
|
sl@0
|
53 |
|
sl@0
|
54 |
#if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
|
sl@0
|
55 |
|
sl@0
|
56 |
//Large File Support - Use RFile64 and 64 bit file sizes
|
sl@0
|
57 |
#define RFILE RFile64
|
sl@0
|
58 |
#define FSIZE TInt64
|
sl@0
|
59 |
|
sl@0
|
60 |
#else
|
sl@0
|
61 |
|
sl@0
|
62 |
//No large file support - Use RFile and 32 bit file sizes
|
sl@0
|
63 |
#define RFILE RFile
|
sl@0
|
64 |
#define FSIZE TInt
|
sl@0
|
65 |
|
sl@0
|
66 |
#endif //SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS
|
sl@0
|
67 |
|
sl@0
|
68 |
// Atomic socket operations support
|
sl@0
|
69 |
|
sl@0
|
70 |
#define ATOMICSOCKETOP(realcall,on_error) \
|
sl@0
|
71 |
{ \
|
sl@0
|
72 |
if (__e32_atomic_tau_ord32((void *)&iCount, 0x8000, 0, 1) >= 0x8000) \
|
sl@0
|
73 |
{ \
|
sl@0
|
74 |
on_error; \
|
sl@0
|
75 |
} \
|
sl@0
|
76 |
else \
|
sl@0
|
77 |
{ \
|
sl@0
|
78 |
realcall; \
|
sl@0
|
79 |
__e32_atomic_tas_ord32((void *)&iCount, 0, -1, 0); \
|
sl@0
|
80 |
} \
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
#define NOP
|
sl@0
|
84 |
|
sl@0
|
85 |
//Enumarations for Polling
|
sl@0
|
86 |
enum TPollMode
|
sl@0
|
87 |
{
|
sl@0
|
88 |
EReadyForReading = 1,
|
sl@0
|
89 |
EReadyForWriting = 2,
|
sl@0
|
90 |
EAnyException = 4
|
sl@0
|
91 |
};
|
sl@0
|
92 |
|
sl@0
|
93 |
//Enumarations for Redirection Server
|
sl@0
|
94 |
enum TRedirConnState
|
sl@0
|
95 |
{
|
sl@0
|
96 |
ENotConnected,
|
sl@0
|
97 |
EConnected,
|
sl@0
|
98 |
ENoServer
|
sl@0
|
99 |
};
|
sl@0
|
100 |
|
sl@0
|
101 |
//Enumerations for the console echo
|
sl@0
|
102 |
enum TConsoleEcho
|
sl@0
|
103 |
{
|
sl@0
|
104 |
EOff = 0, //Turn Off the echo
|
sl@0
|
105 |
EOn = 1, //Turn On the echo
|
sl@0
|
106 |
EPrintValid = 33, //Printable ascii character set <33-126>
|
sl@0
|
107 |
EPrintInvalid=127
|
sl@0
|
108 |
};
|
sl@0
|
109 |
|
sl@0
|
110 |
// The base class for all flavours of FileDescriptor
|
sl@0
|
111 |
//
|
sl@0
|
112 |
class CSocketDesc;
|
sl@0
|
113 |
|
sl@0
|
114 |
NONSHARABLE_CLASS(CFileDescBase) : public CBase
|
sl@0
|
115 |
/*
|
sl@0
|
116 |
@internalComponent
|
sl@0
|
117 |
*/
|
sl@0
|
118 |
{
|
sl@0
|
119 |
public:
|
sl@0
|
120 |
|
sl@0
|
121 |
static CFileDescBase* Open(const wchar_t* name, int mode, int perms, TInt& err);
|
sl@0
|
122 |
static CFileDescBase* Socket(RSocketServ& aSs, int family, int style, int protocol, TInt& err);
|
sl@0
|
123 |
|
sl@0
|
124 |
virtual void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
125 |
virtual TInt ReadCompletion(TDes8& aDesc, TInt aStatus);
|
sl@0
|
126 |
virtual void ReadCancel();
|
sl@0
|
127 |
|
sl@0
|
128 |
virtual void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
129 |
virtual TInt WriteCompletion(TDes8& aDesc, TInt aStatus);
|
sl@0
|
130 |
virtual void WriteCancel();
|
sl@0
|
131 |
virtual TInt SetAtt(TUint aSetAttMask, TUint aClearAttMask);
|
sl@0
|
132 |
|
sl@0
|
133 |
virtual void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
|
sl@0
|
134 |
virtual TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
|
sl@0
|
135 |
virtual void IoctlCancel();
|
sl@0
|
136 |
|
sl@0
|
137 |
virtual void RecvFrom(TDes8& aDesc, TSockAddr& from, int flags, TRequestStatus& aStatus);
|
sl@0
|
138 |
virtual void RecvFromCancel();
|
sl@0
|
139 |
|
sl@0
|
140 |
virtual void SendTo(TDes8& aDesc, const struct sockaddr* anAddr, unsigned long aAddrLen,int flags, TRequestStatus& aStatus);
|
sl@0
|
141 |
|
sl@0
|
142 |
virtual void SendToCancel();
|
sl@0
|
143 |
|
sl@0
|
144 |
virtual TInt CompletionStatus(TInt& aLength, TInt aStatus);
|
sl@0
|
145 |
|
sl@0
|
146 |
virtual void Sync(TRequestStatus& aStatus);
|
sl@0
|
147 |
virtual void SyncCancel();
|
sl@0
|
148 |
|
sl@0
|
149 |
virtual void Accept(CFileDescBase*& aNewSocket, TRequestStatus& aStatus, RSocketServ& aSs,TSockAddr *aAddr);
|
sl@0
|
150 |
virtual void AcceptCancel();
|
sl@0
|
151 |
|
sl@0
|
152 |
virtual void Connect(const struct sockaddr* aAddr,unsigned long size,TRequestStatus& aStatus);
|
sl@0
|
153 |
virtual void ConnectCancel();
|
sl@0
|
154 |
virtual TBool GetConnectionProgress();
|
sl@0
|
155 |
virtual void SetConnectionProgress( TBool aInProgress );
|
sl@0
|
156 |
|
sl@0
|
157 |
virtual void Shutdown(TUint aHow,TRequestStatus& aStatus);
|
sl@0
|
158 |
virtual void ShutdownCancel();
|
sl@0
|
159 |
|
sl@0
|
160 |
virtual TBool TimedRead() {return EFalse;} //default implementation
|
sl@0
|
161 |
TInt TimeoutValue() const {return iReadTimeout;}
|
sl@0
|
162 |
|
sl@0
|
163 |
virtual TInt LSeek(off_t& offset, int whence);
|
sl@0
|
164 |
virtual TInt FStat(struct stat* st);
|
sl@0
|
165 |
virtual TInt Bind(const struct sockaddr* addr, unsigned long size);
|
sl@0
|
166 |
virtual TInt Listen(TUint qSize);
|
sl@0
|
167 |
virtual TInt SockName(int anEnd, struct sockaddr* anAddr,unsigned long* aSize);
|
sl@0
|
168 |
virtual TInt GetSockOpt(TInt anOptionName,TInt anOptionLevel,TDes8& anOption);
|
sl@0
|
169 |
virtual TInt SetSockOpt(TInt anOptionName,TInt anOptionLevel,TDesC8& anOption);
|
sl@0
|
170 |
virtual TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
171 |
|
sl@0
|
172 |
virtual TInt Poll(TPollMode aMode,TBool& aReadyStatus,TInt& aErrno);
|
sl@0
|
173 |
virtual TInt Poll(TUint aEvents);
|
sl@0
|
174 |
virtual TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 timeout);
|
sl@0
|
175 |
virtual void TweakWatchedEvents(TUint& events);
|
sl@0
|
176 |
virtual TInt TweakReadyEvents(TInt errval);
|
sl@0
|
177 |
virtual void CancelNotify();
|
sl@0
|
178 |
|
sl@0
|
179 |
//Truncate the File
|
sl@0
|
180 |
virtual TInt Truncate(off_t /*anOffset*/)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
return KErrNotSupported;
|
sl@0
|
183 |
}
|
sl@0
|
184 |
//Type of the Descriptor
|
sl@0
|
185 |
virtual TInt Type()
|
sl@0
|
186 |
{
|
sl@0
|
187 |
return EBaseDesc;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
//Set/reset the Attributes of the FD
|
sl@0
|
191 |
inline void SetAttributes( TUint32 aBit, TBool aFlag )
|
sl@0
|
192 |
{
|
sl@0
|
193 |
if( aFlag )
|
sl@0
|
194 |
{
|
sl@0
|
195 |
//Set the bit to 1
|
sl@0
|
196 |
iFdAttrib |= aBit;
|
sl@0
|
197 |
}
|
sl@0
|
198 |
else
|
sl@0
|
199 |
{
|
sl@0
|
200 |
//Reset the bit to 0
|
sl@0
|
201 |
iFdAttrib &= ~aBit;
|
sl@0
|
202 |
}
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
//Get the Attributes of the FD
|
sl@0
|
206 |
inline const TUint32 Attributes() const
|
sl@0
|
207 |
{
|
sl@0
|
208 |
return iFdAttrib;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
inline const TUint32 FcntlFlag() const
|
sl@0
|
212 |
{
|
sl@0
|
213 |
return iFcntlFlag;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
static inline void Cleanup(TAny *aPtr)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
((CFileDescBase*)aPtr)->Close();
|
sl@0
|
219 |
}
|
sl@0
|
220 |
|
sl@0
|
221 |
inline void PushLC()
|
sl@0
|
222 |
{
|
sl@0
|
223 |
CleanupStack::PushL(TCleanupItem(Cleanup,this));
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
IMPORT_C TInt Close();
|
sl@0
|
227 |
virtual void UserClose() {return;}
|
sl@0
|
228 |
inline CFileDescBase* Dup();
|
sl@0
|
229 |
inline void SetFid(TInt aFid) { iFid = aFid; }
|
sl@0
|
230 |
virtual void SetFids(void *aFids);
|
sl@0
|
231 |
|
sl@0
|
232 |
inline void operator delete(TAny *aPtr) __NO_THROW
|
sl@0
|
233 |
{
|
sl@0
|
234 |
Backend()->Free(aPtr);
|
sl@0
|
235 |
}
|
sl@0
|
236 |
|
sl@0
|
237 |
inline void operator delete(TAny *aPtr, TLeave) __NO_THROW
|
sl@0
|
238 |
{
|
sl@0
|
239 |
Backend()->Free(aPtr);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
inline void operator delete(TAny *aPtr, TAny*) __NO_THROW
|
sl@0
|
243 |
{
|
sl@0
|
244 |
Backend()->Free(aPtr);
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
TBool ReadIsTimed;
|
sl@0
|
248 |
TBool ReadWasCancelled;
|
sl@0
|
249 |
|
sl@0
|
250 |
protected:
|
sl@0
|
251 |
CFileDescBase( TUint aFcntl = 0, TUint32 aFdAttrib = 0 );
|
sl@0
|
252 |
virtual TInt FinalClose();
|
sl@0
|
253 |
static void Complete(TRequestStatus& aStatus, TInt aResult);
|
sl@0
|
254 |
TInt iReadTimeout;
|
sl@0
|
255 |
//Used in case of CRedirDesc
|
sl@0
|
256 |
TInt iFid;
|
sl@0
|
257 |
//For FD's fcntl
|
sl@0
|
258 |
TUint iFcntlFlag;
|
sl@0
|
259 |
//For FD's other attributes
|
sl@0
|
260 |
TUint32 iFdAttrib;
|
sl@0
|
261 |
|
sl@0
|
262 |
private:
|
sl@0
|
263 |
//Check if the path corresponds to a directory
|
sl@0
|
264 |
static TBool CheckIfDirectory(const TDesC& aPath, RFs& aFs);
|
sl@0
|
265 |
|
sl@0
|
266 |
public:
|
sl@0
|
267 |
enum TDescType
|
sl@0
|
268 |
{
|
sl@0
|
269 |
EBaseDesc,
|
sl@0
|
270 |
EFileDesc,
|
sl@0
|
271 |
EFileTempDesc,
|
sl@0
|
272 |
ESocketDesc,
|
sl@0
|
273 |
ESerialDesc,
|
sl@0
|
274 |
EDirDesc,
|
sl@0
|
275 |
ETtyDesc,
|
sl@0
|
276 |
EPopenPipeDesc,
|
sl@0
|
277 |
EPipeDesc,
|
sl@0
|
278 |
ERedirDesc,
|
sl@0
|
279 |
EStdErrDesc,
|
sl@0
|
280 |
EFileSocketDesc
|
sl@0
|
281 |
};
|
sl@0
|
282 |
private:
|
sl@0
|
283 |
TInt iDupCount;
|
sl@0
|
284 |
public:
|
sl@0
|
285 |
// Poll is required to return any of the requested events.
|
sl@0
|
286 |
// In case of any error, "iPollErr" should be checked by the socket-descriptor
|
sl@0
|
287 |
// to take any corrective action.
|
sl@0
|
288 |
TInt iPollErr;
|
sl@0
|
289 |
};
|
sl@0
|
290 |
|
sl@0
|
291 |
|
sl@0
|
292 |
inline CFileDescBase* CFileDescBase::Dup ()
|
sl@0
|
293 |
{ iDupCount += 1; return this; }
|
sl@0
|
294 |
|
sl@0
|
295 |
|
sl@0
|
296 |
NONSHARABLE_CLASS(CTtyDesc) : public CFileDescBase
|
sl@0
|
297 |
/*
|
sl@0
|
298 |
Abstraction of a teletype device, which will be used for
|
sl@0
|
299 |
the console.
|
sl@0
|
300 |
@internalComponent
|
sl@0
|
301 |
*/
|
sl@0
|
302 |
{
|
sl@0
|
303 |
public:
|
sl@0
|
304 |
inline CTtyDesc(CConsoleBase *c);
|
sl@0
|
305 |
inline CTtyDesc();
|
sl@0
|
306 |
~CTtyDesc();
|
sl@0
|
307 |
virtual TInt Type()
|
sl@0
|
308 |
{
|
sl@0
|
309 |
return ETtyDesc;
|
sl@0
|
310 |
}
|
sl@0
|
311 |
void Read(TDes8& aDesc, TRequestStatus &aStatus);
|
sl@0
|
312 |
void ReadCancel();
|
sl@0
|
313 |
TInt ReadCompletion(TDes8& aDesc, TInt aStatus);
|
sl@0
|
314 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
315 |
void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
|
sl@0
|
316 |
TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
|
sl@0
|
317 |
TInt SetEcho(TUint8 aEcho);
|
sl@0
|
318 |
protected:
|
sl@0
|
319 |
virtual TInt FinalClose();
|
sl@0
|
320 |
private:
|
sl@0
|
321 |
void MapCodeAndEcho(TDes8& aDesc, TKeyCode aCode);
|
sl@0
|
322 |
void CheckConsoleCreated();
|
sl@0
|
323 |
void Write(TDes8& aDesc);
|
sl@0
|
324 |
CConsoleBase *iConsole;
|
sl@0
|
325 |
//To store last non-modifiable data position and flag for reading data
|
sl@0
|
326 |
TInt iCurPosX;
|
sl@0
|
327 |
TInt iCurPosY;
|
sl@0
|
328 |
TBool iReadingData;
|
sl@0
|
329 |
TUint8 iEchoVal;
|
sl@0
|
330 |
};
|
sl@0
|
331 |
|
sl@0
|
332 |
inline CTtyDesc::CTtyDesc(CConsoleBase *c) : CFileDescBase(), iConsole(c), iEchoVal(EOn){}
|
sl@0
|
333 |
inline CTtyDesc::CTtyDesc() : CFileDescBase(), iEchoVal(EOn) {}
|
sl@0
|
334 |
|
sl@0
|
335 |
|
sl@0
|
336 |
NONSHARABLE_CLASS(CRedirDesc) : public CFileDescBase
|
sl@0
|
337 |
/*
|
sl@0
|
338 |
client-side CRedirDesc desc class which will be used to connecting to the Redirection Server
|
sl@0
|
339 |
@internalComponent
|
sl@0
|
340 |
*/
|
sl@0
|
341 |
{
|
sl@0
|
342 |
public:
|
sl@0
|
343 |
CRedirDesc();
|
sl@0
|
344 |
virtual TInt Type()
|
sl@0
|
345 |
{
|
sl@0
|
346 |
return ERedirDesc;
|
sl@0
|
347 |
}
|
sl@0
|
348 |
virtual void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
349 |
virtual void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
350 |
TInt WriteCompletion(TDes8& aDesc, TInt /*aStatus*/);
|
sl@0
|
351 |
TInt ReadCompletion(TDes8& aDesc, TInt /*aStatus*/);
|
sl@0
|
352 |
virtual TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
353 |
TInt FinalClose();
|
sl@0
|
354 |
TInt Configure();
|
sl@0
|
355 |
TInt Poll(TUint aEvents);
|
sl@0
|
356 |
TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 timeout);
|
sl@0
|
357 |
TInt TweakReadyEvents(TInt errval);
|
sl@0
|
358 |
void CancelNotify();
|
sl@0
|
359 |
TInt SetEcho(TUint8 aEcho);
|
sl@0
|
360 |
TBool iReadNone;
|
sl@0
|
361 |
TBool iWriteNone;
|
sl@0
|
362 |
private:
|
sl@0
|
363 |
//Handle to StdioSession
|
sl@0
|
364 |
RStdioSession iSession;
|
sl@0
|
365 |
TRedirConnState iStatus;
|
sl@0
|
366 |
RFastLock iLock;
|
sl@0
|
367 |
};
|
sl@0
|
368 |
|
sl@0
|
369 |
|
sl@0
|
370 |
NONSHARABLE_CLASS(CStdErrDesc) : public CFileDescBase
|
sl@0
|
371 |
|
sl@0
|
372 |
/*
|
sl@0
|
373 |
client-side Standard Error desc class which will be used to put all stderr to RDebug::Printf
|
sl@0
|
374 |
@internalComponent
|
sl@0
|
375 |
*/
|
sl@0
|
376 |
{
|
sl@0
|
377 |
public:
|
sl@0
|
378 |
CStdErrDesc();
|
sl@0
|
379 |
virtual void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
380 |
TInt WriteCompletion(TDes8& aDesc, TInt /*aStatus*/);
|
sl@0
|
381 |
virtual TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
382 |
virtual TInt Type()
|
sl@0
|
383 |
{
|
sl@0
|
384 |
return EStdErrDesc;
|
sl@0
|
385 |
}
|
sl@0
|
386 |
};
|
sl@0
|
387 |
|
sl@0
|
388 |
NONSHARABLE_CLASS(CFileDesc) : public CFileDescBase
|
sl@0
|
389 |
/*
|
sl@0
|
390 |
Abstractions for a plain file and a temporary file
|
sl@0
|
391 |
@internalComponent
|
sl@0
|
392 |
*/
|
sl@0
|
393 |
{
|
sl@0
|
394 |
public:
|
sl@0
|
395 |
CFileDesc();
|
sl@0
|
396 |
~CFileDesc();
|
sl@0
|
397 |
|
sl@0
|
398 |
void SetState(const TDes& params);
|
sl@0
|
399 |
|
sl@0
|
400 |
TInt Open(RFs& aSession, const TDesC& aName, int mode, int perms);
|
sl@0
|
401 |
TInt LSeek(off_t& offset, int whence);
|
sl@0
|
402 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
403 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
404 |
TInt FStat(struct stat *st);
|
sl@0
|
405 |
void Sync(TRequestStatus &aStatus);
|
sl@0
|
406 |
TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
|
sl@0
|
407 |
TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
408 |
static void MapStat(struct stat& st, const TTime& aModTime, TUint& aAttr, const mode_t aMode = S_IFREG);
|
sl@0
|
409 |
TInt Truncate(off_t anOffset);
|
sl@0
|
410 |
TInt SetAtt(TUint aSetAttMask, TUint aClearAttMask);
|
sl@0
|
411 |
TInt ProcessLockParams(FSIZE& pos, FSIZE &lock_len, TInt& lock_type, struct flock* anArg);
|
sl@0
|
412 |
inline int CreateLock()
|
sl@0
|
413 |
{
|
sl@0
|
414 |
return iLock.CreateLocal();
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
inline RFILE& FileHandle()
|
sl@0
|
418 |
{
|
sl@0
|
419 |
return iFile;
|
sl@0
|
420 |
}
|
sl@0
|
421 |
|
sl@0
|
422 |
inline const FSIZE Offset() const
|
sl@0
|
423 |
{
|
sl@0
|
424 |
return iPos;
|
sl@0
|
425 |
}
|
sl@0
|
426 |
|
sl@0
|
427 |
inline const FSIZE Size() const
|
sl@0
|
428 |
{
|
sl@0
|
429 |
return iSize;
|
sl@0
|
430 |
}
|
sl@0
|
431 |
inline void setSize(TUint32 param)
|
sl@0
|
432 |
{
|
sl@0
|
433 |
iSize = param;
|
sl@0
|
434 |
}
|
sl@0
|
435 |
inline const FSIZE Extent() const
|
sl@0
|
436 |
{
|
sl@0
|
437 |
return iExt;
|
sl@0
|
438 |
}
|
sl@0
|
439 |
virtual TInt Type()
|
sl@0
|
440 |
{
|
sl@0
|
441 |
return EFileDesc;
|
sl@0
|
442 |
}
|
sl@0
|
443 |
protected:
|
sl@0
|
444 |
virtual TInt FinalClose();
|
sl@0
|
445 |
TInt Alloc();
|
sl@0
|
446 |
private:
|
sl@0
|
447 |
TInt FileRead(TUint8* aPtr,TInt aLength);
|
sl@0
|
448 |
TInt FileWrite(TUint8* aPtr,TInt aLength);
|
sl@0
|
449 |
TInt Flush();
|
sl@0
|
450 |
TInt DoSync();
|
sl@0
|
451 |
TInt DoRead(TDes8& aDesc);
|
sl@0
|
452 |
TInt DoWrite(TDes8& aDesc);
|
sl@0
|
453 |
FSIZE Pos();
|
sl@0
|
454 |
FSIZE Ext();
|
sl@0
|
455 |
|
sl@0
|
456 |
private:
|
sl@0
|
457 |
enum {EAlloc,EReading,EWriting};
|
sl@0
|
458 |
enum {EBufferSize = 0x600,EReadAhead = 0x200};
|
sl@0
|
459 |
protected:
|
sl@0
|
460 |
RFILE iFile;
|
sl@0
|
461 |
TInt16 iDrive; // for use with stat()
|
sl@0
|
462 |
private:
|
sl@0
|
463 |
TUint8 iState;
|
sl@0
|
464 |
TUint8* iBuffer;
|
sl@0
|
465 |
TUint8* iPtr;
|
sl@0
|
466 |
TUint8* iEnd;
|
sl@0
|
467 |
|
sl@0
|
468 |
FSIZE iSize;
|
sl@0
|
469 |
FSIZE iPos;
|
sl@0
|
470 |
FSIZE iExt;
|
sl@0
|
471 |
|
sl@0
|
472 |
//For locking the descriptor before any operation.
|
sl@0
|
473 |
//To make it thread safe.
|
sl@0
|
474 |
RFastLock iLock;
|
sl@0
|
475 |
friend class RFileDesTransferSession;
|
sl@0
|
476 |
friend class CFileDesTransferSession;
|
sl@0
|
477 |
};
|
sl@0
|
478 |
|
sl@0
|
479 |
NONSHARABLE_CLASS(CTempFileDesc) : public CFileDesc
|
sl@0
|
480 |
/*
|
sl@0
|
481 |
@internalComponent
|
sl@0
|
482 |
*/
|
sl@0
|
483 |
{
|
sl@0
|
484 |
public:
|
sl@0
|
485 |
TInt Open(const wchar_t* aName, TInt mode);
|
sl@0
|
486 |
virtual TInt Type()
|
sl@0
|
487 |
{
|
sl@0
|
488 |
return EFileTempDesc;
|
sl@0
|
489 |
}
|
sl@0
|
490 |
protected:
|
sl@0
|
491 |
virtual TInt FinalClose();
|
sl@0
|
492 |
private:
|
sl@0
|
493 |
RFs iSession;
|
sl@0
|
494 |
TFileName iName;
|
sl@0
|
495 |
};
|
sl@0
|
496 |
|
sl@0
|
497 |
/*
|
sl@0
|
498 |
Implements common functionality between CSocketDesc and CFileSocketDesc.
|
sl@0
|
499 |
Not meant to be instantaible.
|
sl@0
|
500 |
*/
|
sl@0
|
501 |
NONSHARABLE_CLASS(CSockDescBase) : public CFileDescBase
|
sl@0
|
502 |
{
|
sl@0
|
503 |
public:
|
sl@0
|
504 |
virtual TInt Socket(RSocketServ& aSs, int family, int style, int protocol);
|
sl@0
|
505 |
TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
506 |
TInt FStat(struct stat *st);
|
sl@0
|
507 |
TInt FinalClose();
|
sl@0
|
508 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
509 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
510 |
void RecvFrom(TDes8& aDesc, TSockAddr& from, int flags, TRequestStatus& aStatus);
|
sl@0
|
511 |
void SendTo(TDes8& aDesc, TSockAddr& to, int flags, TRequestStatus& aStatus);
|
sl@0
|
512 |
TInt Poll(TUint aEvents);
|
sl@0
|
513 |
TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 aTimeout);
|
sl@0
|
514 |
void TweakWatchedEvents(TUint& events);
|
sl@0
|
515 |
TInt TweakReadyEvents(TInt errval);
|
sl@0
|
516 |
void CancelNotify();
|
sl@0
|
517 |
TInt Listen(TUint qSize);
|
sl@0
|
518 |
void ReadCancel();
|
sl@0
|
519 |
TInt ReadCompletion(TDes8& aBuf, TInt aStatus);
|
sl@0
|
520 |
void RecvFromCancel();
|
sl@0
|
521 |
void SendToCancel();
|
sl@0
|
522 |
void WriteCancel();
|
sl@0
|
523 |
TInt SockName(int anEnd, TSockAddr& anAddr);
|
sl@0
|
524 |
void Shutdown(TUint aHow,TRequestStatus& aStatus);
|
sl@0
|
525 |
TInt CompletionStatus(TInt& aLength, TInt aStatus);
|
sl@0
|
526 |
const TUint& GetSelectEvents()
|
sl@0
|
527 |
{
|
sl@0
|
528 |
iIoctlLock.Signal();
|
sl@0
|
529 |
return iSelectEvents();
|
sl@0
|
530 |
}
|
sl@0
|
531 |
|
sl@0
|
532 |
inline TInt CreateLock()
|
sl@0
|
533 |
{
|
sl@0
|
534 |
TInt err = iIoctlLock.CreateLocal(1) || iReadLock.CreateLocal() || iWriteLock.CreateLocal();
|
sl@0
|
535 |
if (err != KErrNone)
|
sl@0
|
536 |
{
|
sl@0
|
537 |
// closes on unopened handles are safe
|
sl@0
|
538 |
iIoctlLock.Close();
|
sl@0
|
539 |
iReadLock.Close();
|
sl@0
|
540 |
iWriteLock.Close();
|
sl@0
|
541 |
}
|
sl@0
|
542 |
return err;
|
sl@0
|
543 |
}
|
sl@0
|
544 |
|
sl@0
|
545 |
inline RSemaphore& GetIoctlLock()
|
sl@0
|
546 |
{
|
sl@0
|
547 |
return iIoctlLock;
|
sl@0
|
548 |
}
|
sl@0
|
549 |
inline TBool GetConnectionProgress()
|
sl@0
|
550 |
{
|
sl@0
|
551 |
return iConnectInProgress;
|
sl@0
|
552 |
}
|
sl@0
|
553 |
|
sl@0
|
554 |
inline void SetConnectionProgress( TBool aInProgress )
|
sl@0
|
555 |
{
|
sl@0
|
556 |
iConnectInProgress = aInProgress;
|
sl@0
|
557 |
}
|
sl@0
|
558 |
|
sl@0
|
559 |
protected:
|
sl@0
|
560 |
//rearrange these
|
sl@0
|
561 |
CSockDescBase():iAddrFamily(-1),iProtocol(KUndefinedProtocol),iIoctlFlag(EFalse),iCount(0)
|
sl@0
|
562 |
{
|
sl@0
|
563 |
|
sl@0
|
564 |
}
|
sl@0
|
565 |
RSocket iSocket;
|
sl@0
|
566 |
TSockXfrLength iLength;
|
sl@0
|
567 |
TFileName iPath;
|
sl@0
|
568 |
TPckgBuf<TUint> iSelectEvents;
|
sl@0
|
569 |
TInt iAddrFamily;
|
sl@0
|
570 |
TInt iProtocol;
|
sl@0
|
571 |
TInt iStyle;
|
sl@0
|
572 |
// For preventing simultaneous ioctl calls.
|
sl@0
|
573 |
// No native support.
|
sl@0
|
574 |
RSemaphore iIoctlLock;
|
sl@0
|
575 |
// Is this required?
|
sl@0
|
576 |
TBool iIoctlFlag;
|
sl@0
|
577 |
// Safeguard against issue of a second Read/Write request while the first is pending.
|
sl@0
|
578 |
// The iReadLock also guards OpenUsingPreference
|
sl@0
|
579 |
//For locking the descriptor before any operation.
|
sl@0
|
580 |
//To make it thread safe.
|
sl@0
|
581 |
RFastLock iReadLock;
|
sl@0
|
582 |
RFastLock iWriteLock;
|
sl@0
|
583 |
|
sl@0
|
584 |
//Flag to mark the connect status of a non-blocking socket as "in progress"
|
sl@0
|
585 |
//to prevent duplicate connection request
|
sl@0
|
586 |
TBool iConnectInProgress;
|
sl@0
|
587 |
volatile TInt iCount;
|
sl@0
|
588 |
protected:
|
sl@0
|
589 |
|
sl@0
|
590 |
inline TInt isStream() const // inline, but private
|
sl@0
|
591 |
{
|
sl@0
|
592 |
return iStyle==SOCK_STREAM;
|
sl@0
|
593 |
}
|
sl@0
|
594 |
};
|
sl@0
|
595 |
|
sl@0
|
596 |
NONSHARABLE_CLASS(CSocketDesc) : public CSockDescBase
|
sl@0
|
597 |
/*
|
sl@0
|
598 |
Abstraction for a socket
|
sl@0
|
599 |
@internalComponent
|
sl@0
|
600 |
*/
|
sl@0
|
601 |
{
|
sl@0
|
602 |
public:
|
sl@0
|
603 |
CSocketDesc();
|
sl@0
|
604 |
TInt Socket(RSocketServ& aSs, int family, int style, int protocol);
|
sl@0
|
605 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
606 |
TInt ReadCompletion (TDes8& /*aBuf*/, TInt aStatus);
|
sl@0
|
607 |
void ReadCancel();
|
sl@0
|
608 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
609 |
void WriteCancel();
|
sl@0
|
610 |
void Sync(TRequestStatus& aStatus);
|
sl@0
|
611 |
void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
|
sl@0
|
612 |
TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
|
sl@0
|
613 |
void IoctlCancel();
|
sl@0
|
614 |
|
sl@0
|
615 |
void RecvFrom(TDes8& aDesc, TSockAddr& from, int flags, TRequestStatus& aStatus);
|
sl@0
|
616 |
void RecvFromCancel();
|
sl@0
|
617 |
void SendTo(TDes8& aDesc, const struct sockaddr* anAddr, unsigned long aAddrLen, int flags, TRequestStatus& aStatus);
|
sl@0
|
618 |
|
sl@0
|
619 |
void SendToCancel();
|
sl@0
|
620 |
|
sl@0
|
621 |
void Shutdown(TUint aHow,TRequestStatus& aStatus);
|
sl@0
|
622 |
void Accept(CFileDescBase*& aNewSocket, TRequestStatus& aStatus, RSocketServ& aSs,TSockAddr *aAddr);
|
sl@0
|
623 |
void AcceptCancel();
|
sl@0
|
624 |
void Connect(const struct sockaddr* aAddr,unsigned long size,TRequestStatus& aStatus);
|
sl@0
|
625 |
void ConnectCancel();
|
sl@0
|
626 |
|
sl@0
|
627 |
TInt Bind(const struct sockaddr* addr, unsigned long size);
|
sl@0
|
628 |
TInt Listen(TUint qSize);
|
sl@0
|
629 |
TInt SockName(int anEnd, struct sockaddr* anAddr,unsigned long* aSize);
|
sl@0
|
630 |
TInt GetSockOpt(TInt anOptionName,TInt anOptionLevel,TDes8& anOption);
|
sl@0
|
631 |
TInt SetSockOpt(TInt anOptionName,TInt anOptionLevel,TDesC8& anOption);
|
sl@0
|
632 |
TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
633 |
|
sl@0
|
634 |
TInt Poll(TPollMode aMode,TBool& aReadyStatus,TInt& aErrno);
|
sl@0
|
635 |
TInt Poll(TUint aEvents);
|
sl@0
|
636 |
void CancelNotify();
|
sl@0
|
637 |
void TempClose();
|
sl@0
|
638 |
|
sl@0
|
639 |
void SetFids(void *aFids);
|
sl@0
|
640 |
virtual TInt Type()
|
sl@0
|
641 |
{
|
sl@0
|
642 |
return ESocketDesc;
|
sl@0
|
643 |
}
|
sl@0
|
644 |
|
sl@0
|
645 |
protected:
|
sl@0
|
646 |
TInt FinalClose();
|
sl@0
|
647 |
private:
|
sl@0
|
648 |
|
sl@0
|
649 |
TInt GetInterfaceIndex(TUint32 aAddr);
|
sl@0
|
650 |
TInt GetInterfaceList(void *aParam);
|
sl@0
|
651 |
TInt GetActiveInterface( void *aParam);
|
sl@0
|
652 |
TInt GetInterfaceIndexByName(void *aParam);
|
sl@0
|
653 |
TInt GetActiveInterfaceList(void *aParam);
|
sl@0
|
654 |
TInt SetInterfaceByName(void *aParam);
|
sl@0
|
655 |
TInt StartInterface(void *aParam);
|
sl@0
|
656 |
TInt StartActiveInterface(void *aParam);
|
sl@0
|
657 |
TInt StopInterface(void *aParam);
|
sl@0
|
658 |
TInt OpenUsingPreference();
|
sl@0
|
659 |
void AccessPointListL(CArrayFixFlat<TAccessPointRecord> *&aRecordPtr, TInt &aLength);
|
sl@0
|
660 |
void AccessPointCountL(TInt &aCount);
|
sl@0
|
661 |
void ReadRecordFromIapTableL(CCommsDbTableView* aView, TAccessPointRecord &aRecord);
|
sl@0
|
662 |
void OpenIapTableLC(CCommsDatabase **aIapDatabase, CCommsDbTableView **aView);
|
sl@0
|
663 |
TInt ActiveConnectionCount(TInt &aCount);
|
sl@0
|
664 |
TInt ActiveConnectionListL(CArrayFixFlat<TAccessPointRecord> *aRecordPtr, TInt &aLength);
|
sl@0
|
665 |
TInt GetRConnectionDetails(RConnection *aRc, TAccessPointRecord &aApr);
|
sl@0
|
666 |
TInt StartConnection(void *aParam);
|
sl@0
|
667 |
TInt GetConnectionPreference(TCommDbConnPref &aApr);
|
sl@0
|
668 |
void GetIapDetailsByNameL(TBuf<KCommsDbSvrMaxColumnNameLength> aIapName, TAccessPointRecord &aRecord);
|
sl@0
|
669 |
void StopSubConnection();
|
sl@0
|
670 |
void StopConnection();
|
sl@0
|
671 |
TInt StartSubConnection(void *aParam);
|
sl@0
|
672 |
TInt GetInterface(void *Param, TInt aType);
|
sl@0
|
673 |
TInt GetInterafceNumber(void *aParam);
|
sl@0
|
674 |
TInt GetIpAddress( void *aParam );
|
sl@0
|
675 |
|
sl@0
|
676 |
TInt RouteRequest(TInt aReq, void *aParam);
|
sl@0
|
677 |
TInt GetInterfaceHWAddress(void *aParam);
|
sl@0
|
678 |
|
sl@0
|
679 |
TInt ConvertRtEntry(TSoInetRouteInfo& aRouteInfo, struct rtentry *aRouteEntry);
|
sl@0
|
680 |
TInt ConvertSockAddr(TInetAddr& aInetAddr, struct sockaddr_in *aSockAddr);
|
sl@0
|
681 |
|
sl@0
|
682 |
TInt GetInterfaceByName(const TDesC& aIfName, TPckgBuf<TSoInetInterfaceInfo>& aIface);
|
sl@0
|
683 |
TInt Copy(TInetAddr& aDest, TInetAddr& aSrc);
|
sl@0
|
684 |
|
sl@0
|
685 |
TInt GetRemoteIpAddress( void *aParam );
|
sl@0
|
686 |
TInt GetInterafceParamInfo( void *aParam,TInt aType);
|
sl@0
|
687 |
void FindConnectionDetailsL(CArrayFixFlat<TAccessPointRecord>*& aRecordPtr, TInt& aCount);
|
sl@0
|
688 |
void FindConnectionInfoL(TAccessPointRecord &aRecord,char *ptr);
|
sl@0
|
689 |
TInt GetInterfaceDetails( void *aParam ,TInt aFlag, TInt aType );
|
sl@0
|
690 |
TInt SetInterafceParamInfo( void *aParam,TInt aType);
|
sl@0
|
691 |
TInt SetInterfaceDetails( void *aParam ,TInt aFlag, TInt aType );
|
sl@0
|
692 |
|
sl@0
|
693 |
TInt maybe_reopen_socket()
|
sl@0
|
694 |
{
|
sl@0
|
695 |
TInt err = KErrNone;
|
sl@0
|
696 |
if (!__e32_atomic_load_acq32(&iSocketPtr))
|
sl@0
|
697 |
{
|
sl@0
|
698 |
iReadLock.Wait();
|
sl@0
|
699 |
if (!iSocketPtr)
|
sl@0
|
700 |
{
|
sl@0
|
701 |
err = OpenUsingPreference();
|
sl@0
|
702 |
}
|
sl@0
|
703 |
iReadLock.Signal();
|
sl@0
|
704 |
}
|
sl@0
|
705 |
return err;
|
sl@0
|
706 |
}
|
sl@0
|
707 |
|
sl@0
|
708 |
enum InterfaceType
|
sl@0
|
709 |
{
|
sl@0
|
710 |
EACCESS_POINT,
|
sl@0
|
711 |
EACTIVE_CONNECTION,
|
sl@0
|
712 |
EACTIVE_GETIP,
|
sl@0
|
713 |
EACCESS_GETMETRIC,
|
sl@0
|
714 |
EACCESS_GETMTU,
|
sl@0
|
715 |
EACCESS_GETNETMASK,
|
sl@0
|
716 |
EACCESS_GETBROADCAST,
|
sl@0
|
717 |
EACCESS_GETPHYSADDR,
|
sl@0
|
718 |
EACCESS_GETFLAGS,
|
sl@0
|
719 |
EACCESS_SETMETRIC,
|
sl@0
|
720 |
EACCESS_SETMTU,
|
sl@0
|
721 |
EACCESS_SETFLAGS,
|
sl@0
|
722 |
EACCESS_SETPHYSADDR,
|
sl@0
|
723 |
EACTIVE_SETIP,
|
sl@0
|
724 |
EACCESS_SETNETMASK,
|
sl@0
|
725 |
EACCESS_SETBROADCAST
|
sl@0
|
726 |
};
|
sl@0
|
727 |
|
sl@0
|
728 |
TPtr8 iIoctlBuf;
|
sl@0
|
729 |
RSocket *iSocketPtr;
|
sl@0
|
730 |
TAccessPointRecord iConnPref;
|
sl@0
|
731 |
RConnection iConnection;
|
sl@0
|
732 |
RConnection *iConnectionPtr;
|
sl@0
|
733 |
RSubConnection iSubConnection;
|
sl@0
|
734 |
RSubConnection *iSubConnectionPtr;
|
sl@0
|
735 |
TInt iRConnectionIndex;
|
sl@0
|
736 |
RSocketServ *iSockServPtr;
|
sl@0
|
737 |
void *iFids;
|
sl@0
|
738 |
|
sl@0
|
739 |
};
|
sl@0
|
740 |
|
sl@0
|
741 |
|
sl@0
|
742 |
class CNotifier;
|
sl@0
|
743 |
|
sl@0
|
744 |
NONSHARABLE_CLASS(CSerialDesc) : public CFileDescBase
|
sl@0
|
745 |
/*
|
sl@0
|
746 |
@internalComponent
|
sl@0
|
747 |
*/
|
sl@0
|
748 |
{
|
sl@0
|
749 |
|
sl@0
|
750 |
friend class CNotifier;
|
sl@0
|
751 |
|
sl@0
|
752 |
public:
|
sl@0
|
753 |
CSerialDesc() : CFileDescBase(), iReadThreshold(-1), iRequestedSignals(0),
|
sl@0
|
754 |
iNotifyStatus(NULL), iNotifyParamPtr(NULL) {}
|
sl@0
|
755 |
|
sl@0
|
756 |
TInt Open(const wchar_t* name, int mode, int perms);
|
sl@0
|
757 |
TInt FinalClose();
|
sl@0
|
758 |
|
sl@0
|
759 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
760 |
void ReadCancel();
|
sl@0
|
761 |
|
sl@0
|
762 |
TInt& TimeoutValue() const;
|
sl@0
|
763 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
764 |
TInt WriteCompletion(TDes8& aDesc, TInt aStatus);
|
sl@0
|
765 |
|
sl@0
|
766 |
|
sl@0
|
767 |
void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
|
sl@0
|
768 |
TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
|
sl@0
|
769 |
void IoctlCancel();
|
sl@0
|
770 |
|
sl@0
|
771 |
TBool TimedRead();
|
sl@0
|
772 |
void UserClose();
|
sl@0
|
773 |
virtual TInt Type()
|
sl@0
|
774 |
{
|
sl@0
|
775 |
return ESerialDesc;
|
sl@0
|
776 |
}
|
sl@0
|
777 |
|
sl@0
|
778 |
protected:
|
sl@0
|
779 |
|
sl@0
|
780 |
private:
|
sl@0
|
781 |
|
sl@0
|
782 |
void NotifyDataAvailable(TRequestStatus& aStatus);
|
sl@0
|
783 |
void NotifyOutputEmpty(TRequestStatus& aStatus);
|
sl@0
|
784 |
void NotifyBreak(TRequestStatus& aStatus);
|
sl@0
|
785 |
void NotifyWriteErrors(TRequestStatus& aStatus, TUint* aRequestParams, TUint aSignalsMask);
|
sl@0
|
786 |
void NotifySignalChange(TRequestStatus& iStatus, TUint& aRequestParam, TUint aSignalsMask);
|
sl@0
|
787 |
void NotifyDataAvailableCancel();
|
sl@0
|
788 |
void NotifyOutputEmptyCancel();
|
sl@0
|
789 |
void NotifyBreakCancel();
|
sl@0
|
790 |
void NotifyWriteErrorsCancel();
|
sl@0
|
791 |
void NotifySignalChangeCancel();
|
sl@0
|
792 |
void Notify(TInt aVal); //complete the notify request
|
sl@0
|
793 |
TInt NotifiesSupported(); //return the notifies supported at the moment
|
sl@0
|
794 |
TBool RequestedNotifiesSupported(TInt aRequested); //see if the notifies requested are supported
|
sl@0
|
795 |
void CancelNotifiers(const CNotifier* aCompletedNotifier); //cancel them all apart from the passed one
|
sl@0
|
796 |
TUint Signals();
|
sl@0
|
797 |
|
sl@0
|
798 |
TInt ReadCompletion (TDes8& aBuf, TInt aStatus);
|
sl@0
|
799 |
|
sl@0
|
800 |
TInt iReadThreshold;
|
sl@0
|
801 |
RComm iCommPort;
|
sl@0
|
802 |
|
sl@0
|
803 |
TInt iRequestedSignals;
|
sl@0
|
804 |
TRequestStatus* iNotifyStatus;
|
sl@0
|
805 |
TUint* iNotifyParamPtr;
|
sl@0
|
806 |
TUint* iRequestDataPtr;
|
sl@0
|
807 |
|
sl@0
|
808 |
CNotifier* iDataAvailableNotifier;
|
sl@0
|
809 |
CNotifier* iOutputEmptyNotifier;
|
sl@0
|
810 |
CNotifier* iBreakNotifier;
|
sl@0
|
811 |
CNotifier* iErrorsNotifier;
|
sl@0
|
812 |
CNotifier* iSignalsNotifier;
|
sl@0
|
813 |
|
sl@0
|
814 |
};
|
sl@0
|
815 |
|
sl@0
|
816 |
|
sl@0
|
817 |
NONSHARABLE_CLASS(CPipeDescBase) : public CFileDescBase
|
sl@0
|
818 |
/*
|
sl@0
|
819 |
Base class with the RPipe handle and common methods
|
sl@0
|
820 |
@internalComponent
|
sl@0
|
821 |
*/
|
sl@0
|
822 |
{
|
sl@0
|
823 |
public:
|
sl@0
|
824 |
CPipeDescBase(const TUint16 aMode = 0) : CFileDescBase()
|
sl@0
|
825 |
{
|
sl@0
|
826 |
iFdAttrib |= KPipeFd;
|
sl@0
|
827 |
if (aMode & O_NONBLOCK)
|
sl@0
|
828 |
{
|
sl@0
|
829 |
iFcntlFlag |= O_NONBLOCK;
|
sl@0
|
830 |
}
|
sl@0
|
831 |
}
|
sl@0
|
832 |
|
sl@0
|
833 |
TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
834 |
TInt FStat(struct stat *st);
|
sl@0
|
835 |
void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
|
sl@0
|
836 |
TInt FinalClose();
|
sl@0
|
837 |
|
sl@0
|
838 |
RPipe& Handle()
|
sl@0
|
839 |
{
|
sl@0
|
840 |
return iHandle;
|
sl@0
|
841 |
}
|
sl@0
|
842 |
|
sl@0
|
843 |
TUint& FcntlFlag()
|
sl@0
|
844 |
{
|
sl@0
|
845 |
return iFcntlFlag;
|
sl@0
|
846 |
}
|
sl@0
|
847 |
|
sl@0
|
848 |
TUint32& FDAttrib()
|
sl@0
|
849 |
{
|
sl@0
|
850 |
return iFdAttrib;
|
sl@0
|
851 |
}
|
sl@0
|
852 |
virtual TInt Type()
|
sl@0
|
853 |
{
|
sl@0
|
854 |
return EPipeDesc;
|
sl@0
|
855 |
}
|
sl@0
|
856 |
|
sl@0
|
857 |
protected:
|
sl@0
|
858 |
RPipe iHandle;
|
sl@0
|
859 |
};
|
sl@0
|
860 |
|
sl@0
|
861 |
NONSHARABLE_CLASS(CPipeReadDesc) : public CPipeDescBase
|
sl@0
|
862 |
/*
|
sl@0
|
863 |
Handle to the read-end of an RPipe object.
|
sl@0
|
864 |
@internalComponent
|
sl@0
|
865 |
*/
|
sl@0
|
866 |
{
|
sl@0
|
867 |
public:
|
sl@0
|
868 |
CPipeReadDesc(const TUint16 aMode = 0) : CPipeDescBase(aMode)
|
sl@0
|
869 |
{
|
sl@0
|
870 |
iFcntlFlag |= O_RDONLY;
|
sl@0
|
871 |
}
|
sl@0
|
872 |
|
sl@0
|
873 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
874 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
875 |
TInt Poll(TUint aEvents);
|
sl@0
|
876 |
TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 /*timeout*/);
|
sl@0
|
877 |
TInt TweakReadyEvents(TInt errval);
|
sl@0
|
878 |
void CancelNotify();
|
sl@0
|
879 |
|
sl@0
|
880 |
protected:
|
sl@0
|
881 |
TInt DoRead(TDes8& aDesc);
|
sl@0
|
882 |
};
|
sl@0
|
883 |
|
sl@0
|
884 |
NONSHARABLE_CLASS(CPipeWriteDesc) : public CPipeDescBase
|
sl@0
|
885 |
/*
|
sl@0
|
886 |
Handle to the write-end of an RPipe object.
|
sl@0
|
887 |
@internalComponent
|
sl@0
|
888 |
*/
|
sl@0
|
889 |
{
|
sl@0
|
890 |
public:
|
sl@0
|
891 |
CPipeWriteDesc(const TUint16 aMode = 0) : CPipeDescBase(aMode)
|
sl@0
|
892 |
{
|
sl@0
|
893 |
iFcntlFlag |= O_WRONLY;
|
sl@0
|
894 |
}
|
sl@0
|
895 |
|
sl@0
|
896 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
897 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
898 |
TInt Poll(TUint aEvents);
|
sl@0
|
899 |
TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 timeout);
|
sl@0
|
900 |
TInt TweakReadyEvents(TInt errval);
|
sl@0
|
901 |
void CancelNotify();
|
sl@0
|
902 |
|
sl@0
|
903 |
protected:
|
sl@0
|
904 |
TInt DoWrite(TDes8& aDesc);
|
sl@0
|
905 |
};
|
sl@0
|
906 |
NONSHARABLE_CLASS(CFileSocketDesc) : public CSockDescBase
|
sl@0
|
907 |
/*
|
sl@0
|
908 |
Class representing AF_UNIX socket descriptors
|
sl@0
|
909 |
Implemented using 2 FIFOs
|
sl@0
|
910 |
@internalComponent
|
sl@0
|
911 |
*/
|
sl@0
|
912 |
{
|
sl@0
|
913 |
public:
|
sl@0
|
914 |
CFileSocketDesc(const TUint16 aMode = 0)
|
sl@0
|
915 |
{
|
sl@0
|
916 |
if (aMode & O_NONBLOCK)
|
sl@0
|
917 |
{
|
sl@0
|
918 |
iFcntlFlag |= O_NONBLOCK;
|
sl@0
|
919 |
}
|
sl@0
|
920 |
iFcntlFlag |= O_RDWR;
|
sl@0
|
921 |
iPath.Zero();
|
sl@0
|
922 |
}
|
sl@0
|
923 |
|
sl@0
|
924 |
void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
|
sl@0
|
925 |
TInt FinalClose();
|
sl@0
|
926 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
927 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
928 |
void RecvFrom(TDes8& aDesc, TSockAddr& from, int flags, TRequestStatus& aStatus);
|
sl@0
|
929 |
void SendTo(TDes8& aDesc, const struct sockaddr* anAddr, unsigned long aAddrLen, int flags, TRequestStatus& aStatus);
|
sl@0
|
930 |
TInt Listen(TUint qSize);
|
sl@0
|
931 |
TInt GetSockOpt(TInt anOptionName,TInt anOptionLevel,TDes8& anOption);
|
sl@0
|
932 |
TInt SetSockOpt(TInt anOptionName,TInt anOptionLevel,TDesC8& anOption);
|
sl@0
|
933 |
TInt Bind(const struct sockaddr* addr, unsigned long size);
|
sl@0
|
934 |
void Connect(const struct sockaddr* aAddr,unsigned long size, TRequestStatus& aStatus);
|
sl@0
|
935 |
void Accept(CFileDescBase*& aNewSocket, TRequestStatus& aStatus, RSocketServ& aSs, TSockAddr *);
|
sl@0
|
936 |
TInt Socket(RSocketServ& aSs, int family, int style, int protocol);
|
sl@0
|
937 |
TInt SockName(int anEnd, struct sockaddr* anAddr,unsigned long* aSize);
|
sl@0
|
938 |
void AcceptCancel();
|
sl@0
|
939 |
void ConnectCancel();
|
sl@0
|
940 |
|
sl@0
|
941 |
TUint& FcntlFlag()
|
sl@0
|
942 |
{
|
sl@0
|
943 |
return iFcntlFlag;
|
sl@0
|
944 |
}
|
sl@0
|
945 |
|
sl@0
|
946 |
TUint32& FDAttrib()
|
sl@0
|
947 |
{
|
sl@0
|
948 |
return iFdAttrib;
|
sl@0
|
949 |
}
|
sl@0
|
950 |
virtual TInt Type()
|
sl@0
|
951 |
{
|
sl@0
|
952 |
return EFileSocketDesc;
|
sl@0
|
953 |
}
|
sl@0
|
954 |
|
sl@0
|
955 |
TInt GetLocalSockAddrByPort(struct sockaddr_un* aAddr,unsigned long* aAddrLen,TUint aPortNum);
|
sl@0
|
956 |
TInt GetLocalSockPortByPath(const struct sockaddr_un* aAddr,unsigned long aAddrLen,TUint& aPortNum);
|
sl@0
|
957 |
|
sl@0
|
958 |
private:
|
sl@0
|
959 |
TInt ValidateAddress(const struct sockaddr_un* aAddr,unsigned long* aAddrLen);
|
sl@0
|
960 |
TInt RemoveLocalSockAddr();
|
sl@0
|
961 |
private:
|
sl@0
|
962 |
TBuf8<KMaxFileName> iPath;
|
sl@0
|
963 |
RFastLock iReadLock;
|
sl@0
|
964 |
RFastLock iWriteLock;
|
sl@0
|
965 |
class TAutoFastLock
|
sl@0
|
966 |
{
|
sl@0
|
967 |
public:
|
sl@0
|
968 |
TAutoFastLock(RFastLock &aLock):iAutoLock(aLock)
|
sl@0
|
969 |
{
|
sl@0
|
970 |
iAutoLock.Wait() ;
|
sl@0
|
971 |
}
|
sl@0
|
972 |
~TAutoFastLock()
|
sl@0
|
973 |
{
|
sl@0
|
974 |
iAutoLock.Signal() ;
|
sl@0
|
975 |
}
|
sl@0
|
976 |
private:
|
sl@0
|
977 |
RFastLock &iAutoLock;
|
sl@0
|
978 |
};
|
sl@0
|
979 |
};
|
sl@0
|
980 |
|
sl@0
|
981 |
NONSHARABLE_CLASS(CDirectoryDesc) : public CFileDescBase
|
sl@0
|
982 |
/*
|
sl@0
|
983 |
Abstractions for a directory
|
sl@0
|
984 |
@internalComponent
|
sl@0
|
985 |
*/
|
sl@0
|
986 |
{
|
sl@0
|
987 |
public:
|
sl@0
|
988 |
CDirectoryDesc();
|
sl@0
|
989 |
~CDirectoryDesc();
|
sl@0
|
990 |
|
sl@0
|
991 |
TInt Open(RFs& aSession, const TDesC& aName, int mode, int perms);
|
sl@0
|
992 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
993 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
994 |
TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
995 |
TInt LSeek(off_t& offset, int whence);
|
sl@0
|
996 |
TInt FStat(struct stat *st);
|
sl@0
|
997 |
//Get the Name of the directory
|
sl@0
|
998 |
inline const wchar_t* GetDirName()
|
sl@0
|
999 |
{
|
sl@0
|
1000 |
return (const wchar_t*)iDirName.Ptr();
|
sl@0
|
1001 |
}
|
sl@0
|
1002 |
virtual TInt Type()
|
sl@0
|
1003 |
{
|
sl@0
|
1004 |
return EDirDesc;
|
sl@0
|
1005 |
}
|
sl@0
|
1006 |
|
sl@0
|
1007 |
private:
|
sl@0
|
1008 |
RDir iDir;
|
sl@0
|
1009 |
//Name of the directory
|
sl@0
|
1010 |
TFileName iDirName;
|
sl@0
|
1011 |
};
|
sl@0
|
1012 |
|
sl@0
|
1013 |
#ifdef SYMBIAN_OE_LIBRT
|
sl@0
|
1014 |
NONSHARABLE_CLASS(CSharedMemDesc) : public CFileDescBase
|
sl@0
|
1015 |
/*
|
sl@0
|
1016 |
Abstractions for shared memory
|
sl@0
|
1017 |
@internalComponent
|
sl@0
|
1018 |
*/
|
sl@0
|
1019 |
{
|
sl@0
|
1020 |
public:
|
sl@0
|
1021 |
CSharedMemDesc();
|
sl@0
|
1022 |
~CSharedMemDesc();
|
sl@0
|
1023 |
|
sl@0
|
1024 |
TInt Open(const wchar_t* aName, int mode, int perms);
|
sl@0
|
1025 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
1026 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
1027 |
TInt Fcntl(TUint anArg, TUint aCmd);
|
sl@0
|
1028 |
TInt FStat(struct stat *st);
|
sl@0
|
1029 |
TInt LSeek(off_t& offset, int whence);
|
sl@0
|
1030 |
private:
|
sl@0
|
1031 |
TInt ShmRead(TUint8* aPtr,TInt aLength);
|
sl@0
|
1032 |
TInt ShmWrite(TUint8* aPtr,TInt aLength);
|
sl@0
|
1033 |
TInt DoShmRead(TDes8& aDesc);
|
sl@0
|
1034 |
TInt DoShmWrite(TDes8& aDesc);
|
sl@0
|
1035 |
TInt Pos();
|
sl@0
|
1036 |
TInt Ext();
|
sl@0
|
1037 |
protected:
|
sl@0
|
1038 |
TInt FinalClose();
|
sl@0
|
1039 |
private:
|
sl@0
|
1040 |
RFastLock iLock;
|
sl@0
|
1041 |
void* iPtr;
|
sl@0
|
1042 |
TInt iSize;
|
sl@0
|
1043 |
TInt iPos;
|
sl@0
|
1044 |
TInt iExt;
|
sl@0
|
1045 |
TInt iPerms;
|
sl@0
|
1046 |
TInt iKey;
|
sl@0
|
1047 |
};
|
sl@0
|
1048 |
#endif //SYMBIAN_OE_LIBRT
|
sl@0
|
1049 |
#endif // !_FDESC_H
|