sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#ifndef SYSIF_H
|
sl@0
|
20 |
#define SYSIF_H
|
sl@0
|
21 |
#include <e32std.h>
|
sl@0
|
22 |
#include <e32base.h>
|
sl@0
|
23 |
#include <f32file.h>
|
sl@0
|
24 |
#include <es_sock.h>
|
sl@0
|
25 |
#include <c32comm.h>
|
sl@0
|
26 |
#include <sys/select.h>
|
sl@0
|
27 |
#include <spawn.h>
|
sl@0
|
28 |
#include <sys/types.h>
|
sl@0
|
29 |
#include <wchar.h>
|
sl@0
|
30 |
#include "ipcclient.h"
|
sl@0
|
31 |
#include <dirent.h>
|
sl@0
|
32 |
#include <sys/socket.h>
|
sl@0
|
33 |
#include <stdapis/net/if.h>
|
sl@0
|
34 |
#include <commdb.h>
|
sl@0
|
35 |
#include <commdbconnpref.h>
|
sl@0
|
36 |
#include <rpipe.h>
|
sl@0
|
37 |
|
sl@0
|
38 |
#include<tz.h>
|
sl@0
|
39 |
#include <e32atomics.h>
|
sl@0
|
40 |
|
sl@0
|
41 |
#ifdef SYMBIAN_OE_POSIX_SIGNALS
|
sl@0
|
42 |
#include "signalclient.h"
|
sl@0
|
43 |
#include "tsignalmessage.h"
|
sl@0
|
44 |
|
sl@0
|
45 |
typedef void (*TSignalHandler)(int);
|
sl@0
|
46 |
typedef void (*TSignalAction)(int, siginfo_t *, void *);
|
sl@0
|
47 |
#endif
|
sl@0
|
48 |
|
sl@0
|
49 |
/*
|
sl@0
|
50 |
@internalComponent
|
sl@0
|
51 |
*/
|
sl@0
|
52 |
_LIT(KEstlibInit, "STDLIBS-INIT");
|
sl@0
|
53 |
|
sl@0
|
54 |
_LIT(KFDTransferSvr,"FDTrnsfrSvr");
|
sl@0
|
55 |
//Forward declaration for references below
|
sl@0
|
56 |
class RPipe;
|
sl@0
|
57 |
class CFileDesTransferServer;
|
sl@0
|
58 |
class RFileDesTransferSession;
|
sl@0
|
59 |
class CFileDescBase;
|
sl@0
|
60 |
/* TODO: We don't have to do this in CFileTable. Move to methods */
|
sl@0
|
61 |
class CFileSocketDesc;
|
sl@0
|
62 |
class CSocketDesc;
|
sl@0
|
63 |
struct TChild
|
sl@0
|
64 |
/*
|
sl@0
|
65 |
@internalComponent
|
sl@0
|
66 |
*/
|
sl@0
|
67 |
{
|
sl@0
|
68 |
TInt iFid;
|
sl@0
|
69 |
TProcessId iPid;
|
sl@0
|
70 |
RProcess iProc;
|
sl@0
|
71 |
|
sl@0
|
72 |
#ifdef __X86GCC__
|
sl@0
|
73 |
// The underlying data for a TProcessId is a TUint64. GCC raises an error if this is intialised to a negative value. Consider changing for all platforms.
|
sl@0
|
74 |
TChild(TInt aFid = -1, TProcessId aPid = 0) : iFid(aFid), iPid(aPid)
|
sl@0
|
75 |
#else
|
sl@0
|
76 |
TChild(TInt aFid = -1, TProcessId aPid = -1) : iFid(aFid), iPid(aPid)
|
sl@0
|
77 |
#endif //__X86GCC__
|
sl@0
|
78 |
{
|
sl@0
|
79 |
// nada
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
#ifdef __X86GCC__
|
sl@0
|
83 |
// The underlying data for a TProcessId is a TUint64. GCC raises an error if this is intialised to a negative value. Consider changing for all platforms.
|
sl@0
|
84 |
TChild(RProcess &aProc, TProcessId aFid = 0) : iProc(aProc), iFid(aFid)
|
sl@0
|
85 |
#else
|
sl@0
|
86 |
TChild(RProcess &aProc, TProcessId aFid = -1) : iProc(aProc), iFid(aFid)
|
sl@0
|
87 |
#endif //__X86GCC__
|
sl@0
|
88 |
{
|
sl@0
|
89 |
iPid = aProc.Id();
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
|
sl@0
|
93 |
static TBool MatchByFid(const TChild& aChild1, const TChild& aChild2)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
if (aChild1.iFid == aChild2.iFid)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
return ETrue;
|
sl@0
|
98 |
}
|
sl@0
|
99 |
return EFalse;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
static TBool MatchByPid(const TChild& aChild1, const TChild& aChild2)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
if (aChild1.iPid == aChild2.iPid)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
return ETrue;
|
sl@0
|
107 |
}
|
sl@0
|
108 |
return EFalse;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
};
|
sl@0
|
111 |
|
sl@0
|
112 |
class TCLSICleanup
|
sl@0
|
113 |
/*
|
sl@0
|
114 |
@internalComponent
|
sl@0
|
115 |
*/
|
sl@0
|
116 |
{
|
sl@0
|
117 |
public:
|
sl@0
|
118 |
void StorePtrs(RHeap* aHeap, RFs* aFs, RSocketServ* aSs, RCommServ* aCs, RFastLock* aSsLock, RFastLock* aCsLock,RFastLock* aDefConnLock,RFastLock* aAESelectLock,RFastLock* aTzServerLock)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
iHeap = aHeap;
|
sl@0
|
121 |
iFs = aFs;
|
sl@0
|
122 |
iSs = aSs;
|
sl@0
|
123 |
iCs = aCs;
|
sl@0
|
124 |
iSsLock = aSsLock;
|
sl@0
|
125 |
iCsLock = aCsLock;
|
sl@0
|
126 |
iDefConnLock = aDefConnLock;
|
sl@0
|
127 |
iAESelectLock = aAESelectLock;
|
sl@0
|
128 |
iTzServerLock = aTzServerLock;
|
sl@0
|
129 |
}
|
sl@0
|
130 |
|
sl@0
|
131 |
~TCLSICleanup()
|
sl@0
|
132 |
{
|
sl@0
|
133 |
iFs->Close();
|
sl@0
|
134 |
iSs->Close();
|
sl@0
|
135 |
iSsLock->Close();
|
sl@0
|
136 |
iCs->Close();
|
sl@0
|
137 |
iCsLock->Close();
|
sl@0
|
138 |
iHeap->Close();
|
sl@0
|
139 |
iDefConnLock->Close();
|
sl@0
|
140 |
iAESelectLock->Close();
|
sl@0
|
141 |
iTzServerLock->Close();
|
sl@0
|
142 |
}
|
sl@0
|
143 |
private:
|
sl@0
|
144 |
RHeap* iHeap;
|
sl@0
|
145 |
RFs* iFs;
|
sl@0
|
146 |
RSocketServ* iSs;
|
sl@0
|
147 |
RCommServ* iCs;
|
sl@0
|
148 |
RFastLock* iSsLock;
|
sl@0
|
149 |
RFastLock* iCsLock;
|
sl@0
|
150 |
RFastLock* iDefConnLock;
|
sl@0
|
151 |
RFastLock* iAESelectLock;
|
sl@0
|
152 |
RFastLock* iTzServerLock;
|
sl@0
|
153 |
};
|
sl@0
|
154 |
|
sl@0
|
155 |
|
sl@0
|
156 |
class TFileTableCleanup
|
sl@0
|
157 |
{
|
sl@0
|
158 |
public:
|
sl@0
|
159 |
void SaveUserHeap(RHeap* aHeap)
|
sl@0
|
160 |
{
|
sl@0
|
161 |
iUserHeap = aHeap;
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
~TFileTableCleanup()
|
sl@0
|
165 |
{
|
sl@0
|
166 |
User::SwitchHeap(iUserHeap);
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|
sl@0
|
169 |
private:
|
sl@0
|
170 |
RHeap* iUserHeap;
|
sl@0
|
171 |
};
|
sl@0
|
172 |
|
sl@0
|
173 |
|
sl@0
|
174 |
class CFileTable // codescanner::missingcclass
|
sl@0
|
175 |
/*
|
sl@0
|
176 |
@internalComponent
|
sl@0
|
177 |
*/
|
sl@0
|
178 |
{
|
sl@0
|
179 |
public:
|
sl@0
|
180 |
CFileTable();
|
sl@0
|
181 |
~CFileTable();
|
sl@0
|
182 |
|
sl@0
|
183 |
TInt Init(RHeap* aHeap = NULL);
|
sl@0
|
184 |
void Close();
|
sl@0
|
185 |
void Default(CFileDescBase* aRedirMedia, CFileDescBase* aStdErrMedia);
|
sl@0
|
186 |
TInt Reserve();
|
sl@0
|
187 |
TInt Attach(TInt aFid, CFileDescBase* aFile);
|
sl@0
|
188 |
TInt Detach(TInt aFid, CFileDescBase*& aDetached);
|
sl@0
|
189 |
TInt At(TInt aFid, CFileDescBase*& aFound) const;
|
sl@0
|
190 |
TInt Reserve(TInt aFids[3]);
|
sl@0
|
191 |
TInt Detach(TInt aFids[3]);
|
sl@0
|
192 |
|
sl@0
|
193 |
int dup (int fid, int& anErrno);
|
sl@0
|
194 |
int dup2 (int fid1, int fid2, int& anErrno);
|
sl@0
|
195 |
int open (const wchar_t* name, int mode, int perms, int& anErrno);
|
sl@0
|
196 |
int close (int fid, int& anErrno);
|
sl@0
|
197 |
|
sl@0
|
198 |
int UserClose (int fid, int& anErrno);
|
sl@0
|
199 |
|
sl@0
|
200 |
off_t lseek (int fid, off_t offset, int whence, int& anErrno);
|
sl@0
|
201 |
int fstat (int fid, struct stat* st, int& anErrno);
|
sl@0
|
202 |
int socket (int family, int style, int protocol, int& anErrno, RSocketServ& aSs);
|
sl@0
|
203 |
int listen (int fd, int n, int& anErrno);
|
sl@0
|
204 |
int bind (int fd, const struct sockaddr* addr, unsigned long size, int& anErrno);
|
sl@0
|
205 |
int sockname (int fd, struct sockaddr* address, unsigned long* aAddrLen,int anEnd, int& anErrno);
|
sl@0
|
206 |
int getsockopt (int fd, int level, int opt, void* buf, unsigned long* len, int& anErrno);
|
sl@0
|
207 |
int setsockopt (int fd, int level, int opt, void* buf, unsigned long len, int& anErrno);
|
sl@0
|
208 |
int ioctlcomplete (int fid, int cmd, void* param, TRequestStatus& aStatus, int& anErrno);
|
sl@0
|
209 |
int ioctlcancel (int fid, int& anErrno);
|
sl@0
|
210 |
int fcntl (int aFid, int aCmd, long anArg, int& anErrno);
|
sl@0
|
211 |
|
sl@0
|
212 |
TInt Asynch (int fid, CFileDescBase*& aFile);
|
sl@0
|
213 |
|
sl@0
|
214 |
int popen (const wchar_t* file, const wchar_t* cmd,const char* mode, int& anErrno);
|
sl@0
|
215 |
int pclose (int aFid, int& anErrno);
|
sl@0
|
216 |
int popen3 (const wchar_t *file, const wchar_t *cmd, wchar_t** envp, int fids[3], int& anErrno);
|
sl@0
|
217 |
int system (const wchar_t* aCmd, const wchar_t* aCmdArg, int& anErrno);
|
sl@0
|
218 |
int waitpid (int pid, int* status, int options, int& anErrno);
|
sl@0
|
219 |
|
sl@0
|
220 |
int posix_spawn (int* pid, const wchar_t* wpath,
|
sl@0
|
221 |
const posix_spawn_file_actions_t* file_actions,
|
sl@0
|
222 |
const posix_spawnattr_t* attrp,
|
sl@0
|
223 |
const wchar_t* wargs, wchar_t** wenvp);
|
sl@0
|
224 |
|
sl@0
|
225 |
void TransferToChild (RProcess& child, TInt aFds[], TInt aWhich, TInt aSlot);
|
sl@0
|
226 |
void PassEnvToChild (RProcess& child, wchar_t** aEnvp);
|
sl@0
|
227 |
void PassFileActionsToChild (RProcess& child,
|
sl@0
|
228 |
const posix_spawn_file_actions_t* aFileActions);
|
sl@0
|
229 |
|
sl@0
|
230 |
#ifdef SYMBIAN_OE_POSIX_SIGNALS
|
sl@0
|
231 |
void TransferSigMaskToChild(RProcess& childproc,TDes& sigmask);
|
sl@0
|
232 |
void CheckOrigins (wchar_t**& wenvp, int& aCount, TUint64 & aSigMask);
|
sl@0
|
233 |
#else
|
sl@0
|
234 |
void CheckOrigins (wchar_t**& wenvp, int& aCount);
|
sl@0
|
235 |
#endif
|
sl@0
|
236 |
TInt InheritFiles(CFileDesTransferServer* server);
|
sl@0
|
237 |
int pipe (int fildes[2], int& anErrno);
|
sl@0
|
238 |
int mkfifo (const wchar_t *pathname, mode_t mode, int& anErrno, RFs& aFs);
|
sl@0
|
239 |
int CreatePipeDesc (int fildes, RPipe& aHandle, TUint16 aMode = 0);
|
sl@0
|
240 |
void ClosePipe (int fds[2], int& err);
|
sl@0
|
241 |
|
sl@0
|
242 |
static CFileDescBase* FifoOpen (const wchar_t* pathName, mode_t mode, int perms, int& anErrno);
|
sl@0
|
243 |
int link (const wchar_t *oldpathName, const wchar_t *newpathName, int& anErrno, RFs& aFs);
|
sl@0
|
244 |
static CFileDescBase* LinkOpen (const wchar_t* pathName, mode_t mode, int perms, int& anErrno, RFs& aFs);
|
sl@0
|
245 |
int unlink (RFs& aFs, const wchar_t *pathName, int& anErrno);
|
sl@0
|
246 |
int AcceptFileSocket(CFileSocketDesc* pfs, const struct sockaddr_un* addr, int& anErrno, RFs& aFs);
|
sl@0
|
247 |
TInt RConnectionCount();
|
sl@0
|
248 |
TInt RConnectionAt (TInt aRcIndex, RConnection *&aRc);
|
sl@0
|
249 |
TInt AddRConnectionPtr (RConnection *aRc, TInt &aRcIndex);
|
sl@0
|
250 |
void RemoveRConnectionPtrAt (TInt aRcIndex);
|
sl@0
|
251 |
void DeleteRConnectionList();
|
sl@0
|
252 |
|
sl@0
|
253 |
CFileDesTransferServer* NewFDTransferServerL(RSemaphore &sem);
|
sl@0
|
254 |
void StartFDTransferServer(CFileDesTransferServer* pServer);
|
sl@0
|
255 |
void CloseFDTransferServer(CFileDesTransferServer* pServer);
|
sl@0
|
256 |
|
sl@0
|
257 |
int SetEcho(int aFd, TUint8 aEcho, int& aErrno);
|
sl@0
|
258 |
|
sl@0
|
259 |
void DoTransferAll(RSemaphore &sem,TDesC& name);
|
sl@0
|
260 |
TInt GetFileCount() const
|
sl@0
|
261 |
{
|
sl@0
|
262 |
return iFids.Count();
|
sl@0
|
263 |
}
|
sl@0
|
264 |
|
sl@0
|
265 |
void Lock()
|
sl@0
|
266 |
{
|
sl@0
|
267 |
iFidLock.Wait();
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
void Unlock()
|
sl@0
|
271 |
{
|
sl@0
|
272 |
iFidLock.Signal();
|
sl@0
|
273 |
}
|
sl@0
|
274 |
|
sl@0
|
275 |
private:
|
sl@0
|
276 |
TFileTableCleanup iCleanup;
|
sl@0
|
277 |
CArrayPtrSeg<CFileDescBase> iFids;
|
sl@0
|
278 |
// invoked by dup
|
sl@0
|
279 |
TInt Dup(TInt aFid);
|
sl@0
|
280 |
// invoked by both dup2 and fcntl with F_DUPFD
|
sl@0
|
281 |
TInt Dup2(TInt aFid, TInt aFid2, TBool aCloseFid2);
|
sl@0
|
282 |
// the real dup-er.
|
sl@0
|
283 |
TInt DupFd(TInt aFid1, TInt aFid2);
|
sl@0
|
284 |
void Release(TInt aFid);
|
sl@0
|
285 |
|
sl@0
|
286 |
//Lock for protecting FIDs across threads
|
sl@0
|
287 |
RFastLock iFidLock;
|
sl@0
|
288 |
|
sl@0
|
289 |
//stores pids of all children of this process
|
sl@0
|
290 |
RArray<TChild> iChildren;
|
sl@0
|
291 |
|
sl@0
|
292 |
//Methods to manipulate iChildren
|
sl@0
|
293 |
void AddChild(const TChild& aChild);
|
sl@0
|
294 |
void RemoveChild(TInt aIdx);
|
sl@0
|
295 |
|
sl@0
|
296 |
void ExpandFTableL(TInt count);
|
sl@0
|
297 |
|
sl@0
|
298 |
const RArray<TChild>& GetChildren() const
|
sl@0
|
299 |
{
|
sl@0
|
300 |
return iChildren;
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
TInt FindChild(const TInt aFid) const
|
sl@0
|
304 |
{
|
sl@0
|
305 |
return iChildren.Find(TChild(aFid),
|
sl@0
|
306 |
TIdentityRelation<TChild>(TChild::MatchByFid));
|
sl@0
|
307 |
}
|
sl@0
|
308 |
|
sl@0
|
309 |
TInt FindChild(const TProcessId aPid) const
|
sl@0
|
310 |
{
|
sl@0
|
311 |
return iChildren.Find(TChild(-1, aPid),
|
sl@0
|
312 |
TIdentityRelation<TChild>(TChild::MatchByPid));
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
CArrayPtrSeg<RConnection> iRConnectionList;
|
sl@0
|
316 |
//Lock for protecting iRConnectionList across threads
|
sl@0
|
317 |
RFastLock iRcLock;
|
sl@0
|
318 |
|
sl@0
|
319 |
// A pointer to the private heap
|
sl@0
|
320 |
RHeap* iPrivateHeap;
|
sl@0
|
321 |
friend class CFileDesTransferSession;
|
sl@0
|
322 |
};
|
sl@0
|
323 |
|
sl@0
|
324 |
|
sl@0
|
325 |
class PosixFilesystem
|
sl@0
|
326 |
/*
|
sl@0
|
327 |
@internalComponent
|
sl@0
|
328 |
*/
|
sl@0
|
329 |
{
|
sl@0
|
330 |
public:
|
sl@0
|
331 |
static wchar_t* getcwd(RFs& aFs, wchar_t* buf, unsigned long len, int& anErrno);
|
sl@0
|
332 |
static int chdir(RFs& aFs, const wchar_t* path, int& anErrno);
|
sl@0
|
333 |
static int mkdir(RFs& aFs, const wchar_t* path, int perms, int& anErrno);
|
sl@0
|
334 |
static int rmdir(RFs& aFs, const wchar_t* path, int& anErrno);
|
sl@0
|
335 |
static int chmod(RFs& aFs, const wchar_t* path, int perms, int& anErrno);
|
sl@0
|
336 |
static int reg_unlink(RFs& aFs, const wchar_t* path, int& anErrno);
|
sl@0
|
337 |
static int statbackend(RFs& aFs, const wchar_t* name, struct stat* st, int& anErrno);
|
sl@0
|
338 |
static int rename(RFs& aFs, const wchar_t* oldname, const wchar_t* newname, int& anErrno);
|
sl@0
|
339 |
static TInt ResolvePath(TParse& aResult, const wchar_t* path, TDes* aFilename);
|
sl@0
|
340 |
static TInt SetDefaultDir(RFs& aFs);
|
sl@0
|
341 |
static TInt CreateDefaultPrivatePath(RFs& aFs);
|
sl@0
|
342 |
static int utime(RFs& aFs, const wchar_t* name, const struct utimbuf* filetimes, int& anErrno);
|
sl@0
|
343 |
};
|
sl@0
|
344 |
|
sl@0
|
345 |
|
sl@0
|
346 |
class TAccessPointRecord
|
sl@0
|
347 |
{
|
sl@0
|
348 |
public:
|
sl@0
|
349 |
TUint32 iId;
|
sl@0
|
350 |
TBuf<KCommsDbSvrMaxColumnNameLength> iName;
|
sl@0
|
351 |
TUint32 iDialogPref;
|
sl@0
|
352 |
TUint32 iDirection;
|
sl@0
|
353 |
TUint32 iService;
|
sl@0
|
354 |
TBuf<KCommsDbSvrMaxColumnNameLength> iServiceType;
|
sl@0
|
355 |
TUint32 iBearer;
|
sl@0
|
356 |
TBuf<KCommsDbSvrMaxColumnNameLength> iBearerType;
|
sl@0
|
357 |
TUint32 iNetwork;
|
sl@0
|
358 |
TUint32 iNetworkWeighting;
|
sl@0
|
359 |
TUint32 iLocation;
|
sl@0
|
360 |
public:
|
sl@0
|
361 |
TAccessPointRecord();
|
sl@0
|
362 |
|
sl@0
|
363 |
};
|
sl@0
|
364 |
|
sl@0
|
365 |
// This structure encapsulates an aselect request
|
sl@0
|
366 |
NONSHARABLE_STRUCT ( TaselectRequestInfo )
|
sl@0
|
367 |
{
|
sl@0
|
368 |
TThreadId iId;
|
sl@0
|
369 |
int iMaxFd;
|
sl@0
|
370 |
fd_set* iReadFds;
|
sl@0
|
371 |
fd_set* iWriteFds;
|
sl@0
|
372 |
fd_set* iExceptFds;
|
sl@0
|
373 |
struct timeval *itvptr;
|
sl@0
|
374 |
TRequestStatus* iRequestStatus;
|
sl@0
|
375 |
};
|
sl@0
|
376 |
|
sl@0
|
377 |
// Holds the information about aselect requests, this used required
|
sl@0
|
378 |
// for cancellation of the aselect requests
|
sl@0
|
379 |
NONSHARABLE_CLASS ( TASelectRequest )
|
sl@0
|
380 |
{
|
sl@0
|
381 |
public:
|
sl@0
|
382 |
// Thread id of the thread processing the aselect
|
sl@0
|
383 |
TThreadId iThreadId;
|
sl@0
|
384 |
// Request object used for the request
|
sl@0
|
385 |
TRequestStatus* iRequestStatus;
|
sl@0
|
386 |
};
|
sl@0
|
387 |
|
sl@0
|
388 |
NONSHARABLE_CLASS(CLocalSystemInterface) : public CBase
|
sl@0
|
389 |
/*
|
sl@0
|
390 |
@internalComponent
|
sl@0
|
391 |
*/
|
sl@0
|
392 |
{
|
sl@0
|
393 |
public:
|
sl@0
|
394 |
|
sl@0
|
395 |
|
sl@0
|
396 |
IMPORT_C CLocalSystemInterface();
|
sl@0
|
397 |
IMPORT_C ~CLocalSystemInterface();
|
sl@0
|
398 |
|
sl@0
|
399 |
#ifdef __SYMBIAN_COMPILE_UNUSED__
|
sl@0
|
400 |
CLocalSystemInterface& Clone();
|
sl@0
|
401 |
void Release();
|
sl@0
|
402 |
void TerminateProcess(int status);
|
sl@0
|
403 |
#endif //__SYMBIAN_COMPILE_UNUSED__
|
sl@0
|
404 |
|
sl@0
|
405 |
int AddToDirList(DIR *aDir);
|
sl@0
|
406 |
int RemoveDirFromList(DIR* aDir);
|
sl@0
|
407 |
int FindInDirList(DIR* aDir);
|
sl@0
|
408 |
|
sl@0
|
409 |
void Exit(int code);
|
sl@0
|
410 |
|
sl@0
|
411 |
int dup (int fid, int& anErrno);
|
sl@0
|
412 |
int dup2 (int fid, int fid2, int& anErrno);
|
sl@0
|
413 |
int open (const wchar_t* name, int mode, int perms, int& anErrno);
|
sl@0
|
414 |
int read (int fid, char* buf, unsigned long len, int& anErrno);
|
sl@0
|
415 |
int write (int fid, const char* buf, unsigned long len, int& anErrno);
|
sl@0
|
416 |
int fsync (int fid, int& anErrno);
|
sl@0
|
417 |
int close (int fid, int& anErrno);
|
sl@0
|
418 |
off_t lseek (int fid, off_t offset, int whence, int& anErrno);
|
sl@0
|
419 |
int fstat (int fid, struct stat* st, int& anErrno);
|
sl@0
|
420 |
int ioctl (int fid, int cmd, void* param, int& anErrno);
|
sl@0
|
421 |
int ioctl (int fid, int cmd, void* param, TRequestStatus& aStatus, int& anErrno);
|
sl@0
|
422 |
int ioctl_complete (int fid, int cmd, void* param, TRequestStatus& aStatus, int& anErrno);
|
sl@0
|
423 |
|
sl@0
|
424 |
#ifdef __SYMBIAN_COMPILE_UNUSED__
|
sl@0
|
425 |
int ioctl_cancel (int fid, int& anErrno);
|
sl@0
|
426 |
#endif //__SYMBIAN_COMPILE_UNUSED__
|
sl@0
|
427 |
|
sl@0
|
428 |
wchar_t* getcwd (wchar_t* buf, unsigned long len, int& anErrno);
|
sl@0
|
429 |
|
sl@0
|
430 |
int chdir (const wchar_t* path, int& anErrno);
|
sl@0
|
431 |
int mkdir (const wchar_t* path, int perms, int& anErrno);
|
sl@0
|
432 |
int rmdir (const wchar_t* path, int& anErrno);
|
sl@0
|
433 |
int chmod (const wchar_t* path, int perms, int& anErrno);
|
sl@0
|
434 |
int stat (const wchar_t* name, struct stat* st, int& anErrno);
|
sl@0
|
435 |
int lstat (const wchar_t* name, struct stat *st, int& anErrno);
|
sl@0
|
436 |
int rename (const wchar_t* oldname, const wchar_t* newname, int& anErrno);
|
sl@0
|
437 |
|
sl@0
|
438 |
IMPORT_C TInt ResolvePath (TParse& aResult, const wchar_t* path, TDes* aFilename);
|
sl@0
|
439 |
int socket (int family, int style, int protocol, int& anErrno);
|
sl@0
|
440 |
int recvfrom (int fd, char* buf, unsigned long cnt, int flags, struct sockaddr* from, unsigned long* fromsize, int& anErrno);
|
sl@0
|
441 |
int sendto (int fd, const char* buf, unsigned long cnt, int flags, struct sockaddr* to, unsigned long tosize, int& anErrno);
|
sl@0
|
442 |
int shutdown (int fd, int how, int& anErrno);
|
sl@0
|
443 |
int listen (int fd, int n, int& anErrno);
|
sl@0
|
444 |
int accept (int fd, struct sockaddr *addr, size_t *size, int& anErrno);
|
sl@0
|
445 |
int bind (int fd, const struct sockaddr* addr, unsigned long size, int& anErrno);
|
sl@0
|
446 |
int connect (int fd, const struct sockaddr* addr, unsigned long size, int& anErrno);
|
sl@0
|
447 |
int sockname (int fd, struct sockaddr* addr, unsigned long* size, int anEnd, int& anErrno);
|
sl@0
|
448 |
int getsockopt (int fd, int level, int opt, void* buf, unsigned long* len, int& anErrno);
|
sl@0
|
449 |
int setsockopt (int fd, int level, int opt, void* buf, unsigned long len, int& anErrno);
|
sl@0
|
450 |
|
sl@0
|
451 |
int popen3 (const wchar_t *file, const wchar_t *cmd, wchar_t** envp, int fids[3], int& anErrno);
|
sl@0
|
452 |
int waitpid (int pid, int* status, int options, int& anErrno);
|
sl@0
|
453 |
|
sl@0
|
454 |
int fcntl (int aFid, int aCmd, long anArg, int& anErrno);
|
sl@0
|
455 |
int utime (const wchar_t* name, const struct utimbuf* filetimes, int& anErrno);
|
sl@0
|
456 |
|
sl@0
|
457 |
int popen (const wchar_t* file, const wchar_t* cmd, const char* mode, int& anErrno);
|
sl@0
|
458 |
int pclose (int aFid, int& anErrno);
|
sl@0
|
459 |
IMPORT_C void CheckOrigins (wchar_t**& wenvp, int& aCount);
|
sl@0
|
460 |
#ifdef SYMBIAN_OE_POSIX_SIGNALS
|
sl@0
|
461 |
TInt SignalHandler();
|
sl@0
|
462 |
IMPORT_C void InitSignalHandler();
|
sl@0
|
463 |
void RegisterExitNotification(TProcessId aPid);
|
sl@0
|
464 |
|
sl@0
|
465 |
inline TUint64 GetSigMask()const
|
sl@0
|
466 |
{
|
sl@0
|
467 |
return iSigMask;
|
sl@0
|
468 |
}
|
sl@0
|
469 |
|
sl@0
|
470 |
int kill(pid_t pid, int sig, int& anErrno);
|
sl@0
|
471 |
int raise(int sig, int& anErrno);
|
sl@0
|
472 |
int sigqueue(pid_t pid, int sig, const union sigval val, int& anErrno);
|
sl@0
|
473 |
|
sl@0
|
474 |
int sigfillset(sigset_t *set, int& anErrno);
|
sl@0
|
475 |
int sigaddset(sigset_t *set, int signo, int& anErrno);
|
sl@0
|
476 |
int sigdelset(sigset_t *set, int signo, int& anErrno);
|
sl@0
|
477 |
int sigismember(const sigset_t *set, int signo, int& anErrno);
|
sl@0
|
478 |
int sigandset(sigset_t * set, const sigset_t * left, const sigset_t * right, int& anErrno);
|
sl@0
|
479 |
int sigorset(sigset_t * set, const sigset_t * left, const sigset_t * right, int& anErrno);
|
sl@0
|
480 |
int sigisemptyset(const sigset_t * set, int& anErrno);
|
sl@0
|
481 |
int sigemptyset(sigset_t * set, int& anErrno);
|
sl@0
|
482 |
|
sl@0
|
483 |
int sigprocmask(int how, const sigset_t *set, sigset_t *oset, int& anErrno);
|
sl@0
|
484 |
int sighold(int signo, int& anErrno);
|
sl@0
|
485 |
int sigrelse(int signo, int& anErrno);
|
sl@0
|
486 |
int sigpause(int signo, int& anErrno);
|
sl@0
|
487 |
|
sl@0
|
488 |
int sigwait(const sigset_t *set, int *sig, int& anErrno);
|
sl@0
|
489 |
int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout, int& anErrno);
|
sl@0
|
490 |
int sigwaitinfo(const sigset_t *set, siginfo_t *info, int& anErrno);
|
sl@0
|
491 |
int sigaction(int sig, const struct sigaction *act, struct sigaction *oact, int& anErrno);
|
sl@0
|
492 |
TSignalHandler sigset(int aSigNum, TSignalHandler disp, int& anErrno);
|
sl@0
|
493 |
TSignalHandler bsd_signal(int aSigNum, TSignalHandler aFunc,int& anErrno);
|
sl@0
|
494 |
TSignalHandler signal(int aSigNum, TSignalHandler aFunc,int& anErrno);
|
sl@0
|
495 |
int sigignore(int aSigNum, int& anErrno);
|
sl@0
|
496 |
unsigned int alarm(unsigned int seconds);
|
sl@0
|
497 |
int sigpending(sigset_t *set,int& anErrno);
|
sl@0
|
498 |
|
sl@0
|
499 |
#ifdef SYMBIAN_OE_LIBRT
|
sl@0
|
500 |
//start timers...
|
sl@0
|
501 |
IMPORT_C TInt AddTimer(const TInt& aTimerId);
|
sl@0
|
502 |
IMPORT_C TInt DeleteTimer(const TInt& aTimerId);
|
sl@0
|
503 |
IMPORT_C TInt IncrementOverrun(const TInt& aTimerId);
|
sl@0
|
504 |
IMPORT_C TInt ResetOverrun(const TInt& aTimerId);
|
sl@0
|
505 |
IMPORT_C TInt Overrun(const TInt& aTimerId);
|
sl@0
|
506 |
IMPORT_C TInt RaiseTimerSignal(int sig, int timerid);
|
sl@0
|
507 |
//end timers
|
sl@0
|
508 |
#endif //SYMBIAN_OE_LIBRT
|
sl@0
|
509 |
#endif // SYMBIAN_OE_POSIX_SIGNALS
|
sl@0
|
510 |
int pipe (int fildes[2], int& anErrno );
|
sl@0
|
511 |
int mkfifo (const wchar_t *pathname, mode_t mode, int& anErrno);
|
sl@0
|
512 |
int link (const wchar_t *oldpathName, const wchar_t *newpathName, int& anErrno );
|
sl@0
|
513 |
int unlink (const wchar_t *pathName, int& anErrno );
|
sl@0
|
514 |
|
sl@0
|
515 |
int select (int maxfd, fd_set* readfds,fd_set* writefds,fd_set* exceptfds, struct timeval* tvptr, int& anErrno);
|
sl@0
|
516 |
|
sl@0
|
517 |
int aselect(int maxfd, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval *tvptr, TRequestStatus* requeststatus,int& anErrno);
|
sl@0
|
518 |
|
sl@0
|
519 |
int cancelaselect(TRequestStatus* requeststatus, int& anErrno, TBool perform_cleanup = EFalse);
|
sl@0
|
520 |
|
sl@0
|
521 |
int eselect(int maxfd, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval *tvptr, int arraycount,TRequestStatus* waitarray,int& anErrno);
|
sl@0
|
522 |
|
sl@0
|
523 |
static TInt handleaselect(TAny* aPtr);
|
sl@0
|
524 |
|
sl@0
|
525 |
RArray<TASelectRequest>& ASelectRequest();
|
sl@0
|
526 |
|
sl@0
|
527 |
RFastLock& ASelectLock();
|
sl@0
|
528 |
|
sl@0
|
529 |
inline RFastLock& DefConnLock() { return iDefConnLock; }
|
sl@0
|
530 |
|
sl@0
|
531 |
inline TInt AddSocket(CSocketDesc* aPtr)
|
sl@0
|
532 |
{
|
sl@0
|
533 |
RHeap* oheap = User::SwitchHeap(iPrivateHeap);
|
sl@0
|
534 |
TInt ret = iSocketArray.InsertInAddressOrder(aPtr);
|
sl@0
|
535 |
User::SwitchHeap(oheap);
|
sl@0
|
536 |
return ret;
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
inline void RemoveSocket(CSocketDesc* aPtr)
|
sl@0
|
540 |
{
|
sl@0
|
541 |
TInt index = iSocketArray.FindInAddressOrder(aPtr);
|
sl@0
|
542 |
if (index != -1)
|
sl@0
|
543 |
{
|
sl@0
|
544 |
RHeap* oheap = User::SwitchHeap(iPrivateHeap);
|
sl@0
|
545 |
iSocketArray.Remove(index);
|
sl@0
|
546 |
iSocketArray.Compress();
|
sl@0
|
547 |
User::SwitchHeap(oheap);
|
sl@0
|
548 |
}
|
sl@0
|
549 |
}
|
sl@0
|
550 |
|
sl@0
|
551 |
int system (const wchar_t* aCmd, const wchar_t* aCmdArg, int& anErrno );
|
sl@0
|
552 |
const wchar_t* GetDirName (int aFid);
|
sl@0
|
553 |
IMPORT_C int Truncate (int aFid, off_t anOffset, int& anErrno);
|
sl@0
|
554 |
int fchmod (int fd , mode_t perms, int& anErrno);
|
sl@0
|
555 |
|
sl@0
|
556 |
int posix_spawn (int* pid, const wchar_t* wpath,
|
sl@0
|
557 |
const posix_spawn_file_actions_t* file_actions,
|
sl@0
|
558 |
const posix_spawnattr_t* attrp,
|
sl@0
|
559 |
const wchar_t* wargs, wchar_t** wenvp);
|
sl@0
|
560 |
|
sl@0
|
561 |
int SetEcho(int aFd, TUint8 aEcho, int& aErrno);
|
sl@0
|
562 |
|
sl@0
|
563 |
//Set the default interface for network operations
|
sl@0
|
564 |
int setdefaultif(const struct ifreq* aIfReq);
|
sl@0
|
565 |
int unsetdefaultif(TBool allow_bringup = ETrue);
|
sl@0
|
566 |
|
sl@0
|
567 |
IMPORT_C CFileDescBase* GetDesc(int aFid);
|
sl@0
|
568 |
|
sl@0
|
569 |
// functions returning session to File Server
|
sl@0
|
570 |
IMPORT_C RFs& FileSession();
|
sl@0
|
571 |
RCommServ& CommServSession();
|
sl@0
|
572 |
RSocketServ& SockServSession();
|
sl@0
|
573 |
|
sl@0
|
574 |
//Dynamic Memory related APIs
|
sl@0
|
575 |
IMPORT_C void* Alloc(size_t aNBytes);
|
sl@0
|
576 |
IMPORT_C void* ReAlloc(void* aPtr, size_t aNBytes);
|
sl@0
|
577 |
IMPORT_C void Free(void* aPtr);
|
sl@0
|
578 |
IMPORT_C void* AllocTLD(TInt aSize);
|
sl@0
|
579 |
|
sl@0
|
580 |
//Return the private Heap memory
|
sl@0
|
581 |
IMPORT_C RHeap* Heap();
|
sl@0
|
582 |
|
sl@0
|
583 |
//Return the Comms Server Lock
|
sl@0
|
584 |
RFastLock& CommsSessionLock();
|
sl@0
|
585 |
|
sl@0
|
586 |
//Return reference to file table
|
sl@0
|
587 |
const CFileTable& FileTable() const;
|
sl@0
|
588 |
|
sl@0
|
589 |
//Get the default connection (RConnection) instance
|
sl@0
|
590 |
RConnection& GetDefaultConnection();
|
sl@0
|
591 |
|
sl@0
|
592 |
//Get the saved session path of the file server session
|
sl@0
|
593 |
TInt GetSessionPath(TDes& aPath);
|
sl@0
|
594 |
|
sl@0
|
595 |
//Save the file server session path
|
sl@0
|
596 |
TInt SaveSessionPath(const TDesC& aPath);
|
sl@0
|
597 |
|
sl@0
|
598 |
static void WaitForNRequest(TRequestStatus aStatusArray[], TInt aNum);
|
sl@0
|
599 |
|
sl@0
|
600 |
private:
|
sl@0
|
601 |
//Helper function to read a record from the IAP table
|
sl@0
|
602 |
void ReadRecordFromIapTableL(CCommsDbTableView* aView, TAccessPointRecord &aRecord);
|
sl@0
|
603 |
//Get the connection preferences from an IAP name
|
sl@0
|
604 |
TInt GetConnectionPreferencesL(TBuf<KCommsDbSvrMaxColumnNameLength> aIapName,
|
sl@0
|
605 |
TCommDbConnPref &aConnPref);
|
sl@0
|
606 |
|
sl@0
|
607 |
// Helper function used by "select" api.
|
sl@0
|
608 |
// The function returns "True", if an ioctl call has been made and it is to be waited upon.
|
sl@0
|
609 |
// The function returns "False", (if an ioctl call is not made)/(an ioctl call was made but is not to be waited upon, and will get cancelled).
|
sl@0
|
610 |
TBool SelectPollIssueIoctl(fd_set** aInputFds, fd_set** aOutputFds,
|
sl@0
|
611 |
TRequestStatus* aReqArray, TInt *aReqFds, TInt aNumReqs, TInt& nDescriptorsSet) ;
|
sl@0
|
612 |
TInt CreateaselectThread(int maxfd, fd_set* readfds, fd_set* writefds,
|
sl@0
|
613 |
fd_set* exceptfds, struct timeval* tvptr,
|
sl@0
|
614 |
TRequestStatus* requeststatus, int& anErrno);
|
sl@0
|
615 |
|
sl@0
|
616 |
// Helper function for the setdefaultif() API to restart the
|
sl@0
|
617 |
// default RConnection with the new settings.
|
sl@0
|
618 |
TInt StartDefConnection();
|
sl@0
|
619 |
|
sl@0
|
620 |
// Helper function for doing an on-demand connection to RTz server
|
sl@0
|
621 |
TInt OnDemandTZServerConnection();
|
sl@0
|
622 |
private:
|
sl@0
|
623 |
// NOTE: iCleanup should be the first member of CLSI, since iPrivateHeap
|
sl@0
|
624 |
// will be destroyed from within iCleanup destructor.
|
sl@0
|
625 |
TCLSICleanup iCleanup;
|
sl@0
|
626 |
|
sl@0
|
627 |
CFileTable iFids;
|
sl@0
|
628 |
|
sl@0
|
629 |
//The backend file session for the application
|
sl@0
|
630 |
RFs iFs;
|
sl@0
|
631 |
//The current session path of the application.
|
sl@0
|
632 |
TFileName iSessionPath;
|
sl@0
|
633 |
//Lock to guard the session path
|
sl@0
|
634 |
RFastLock iSessionPathLock;
|
sl@0
|
635 |
|
sl@0
|
636 |
RSocketServ iSs;
|
sl@0
|
637 |
RCommServ iCs;
|
sl@0
|
638 |
|
sl@0
|
639 |
//Lock for protecting Socket Session across threads
|
sl@0
|
640 |
RFastLock iSSLock;
|
sl@0
|
641 |
//Lock for protecting Comms Session across threads
|
sl@0
|
642 |
RFastLock iCSLock;
|
sl@0
|
643 |
|
sl@0
|
644 |
//Private Heap which will be used by the library for all memory allocation
|
sl@0
|
645 |
RHeap* iPrivateHeap;
|
sl@0
|
646 |
|
sl@0
|
647 |
//used for Opendir
|
sl@0
|
648 |
const static TInt KDirGran = 2;
|
sl@0
|
649 |
RPointerArray<TAny> iOpenDirList;
|
sl@0
|
650 |
|
sl@0
|
651 |
//in class consts
|
sl@0
|
652 |
const static TInt KTLDInfoListGran = 4;
|
sl@0
|
653 |
const static TInt KPtrsGran = 2;
|
sl@0
|
654 |
|
sl@0
|
655 |
//Thread-TLS pointers mapping
|
sl@0
|
656 |
class TTLDInfo
|
sl@0
|
657 |
{
|
sl@0
|
658 |
public:
|
sl@0
|
659 |
TTLDInfo(TThreadId id, TAny* ptr) : iTid(id), iPtrs(CLocalSystemInterface::KPtrsGran)
|
sl@0
|
660 |
{
|
sl@0
|
661 |
iPtrs.Append(ptr);
|
sl@0
|
662 |
}
|
sl@0
|
663 |
void Close(RHeap* pHeap)
|
sl@0
|
664 |
{
|
sl@0
|
665 |
TInt nptrs = iPtrs.Count();
|
sl@0
|
666 |
for (TInt j = 0; j < nptrs; ++j)
|
sl@0
|
667 |
{
|
sl@0
|
668 |
pHeap->Free(iPtrs[j]);
|
sl@0
|
669 |
}
|
sl@0
|
670 |
iPtrs.Close();
|
sl@0
|
671 |
}
|
sl@0
|
672 |
TThreadId iTid;
|
sl@0
|
673 |
RPointerArray<TAny> iPtrs;
|
sl@0
|
674 |
};
|
sl@0
|
675 |
|
sl@0
|
676 |
//Array of Thread-TLS pointers mappings
|
sl@0
|
677 |
RArray<TTLDInfo> iTLDInfoList;
|
sl@0
|
678 |
|
sl@0
|
679 |
//Protect the array from concurrent access
|
sl@0
|
680 |
RFastLock iTLDListLock;
|
sl@0
|
681 |
//The default connection to be used for all network apis.
|
sl@0
|
682 |
RConnection iDefConnection;
|
sl@0
|
683 |
//Protect the iDefConnection from concurrent GetDefaultConnection calls
|
sl@0
|
684 |
RFastLock iDefConnLock;
|
sl@0
|
685 |
//Calling unsetdefaultif(), instead of setdefaultif(NULL) ensures that the torn down
|
sl@0
|
686 |
//connection is not brought back up again, by subsequent socket/network calls.
|
sl@0
|
687 |
//This variable enables this facility. It is reset to default (ETrue) by setdefaultif(<pref>)
|
sl@0
|
688 |
TBool iDefConnResurrect;
|
sl@0
|
689 |
//Lock for protecting iASelectRequest across threads
|
sl@0
|
690 |
RFastLock iASelectLock;
|
sl@0
|
691 |
|
sl@0
|
692 |
// iASelectRequest holds the TASelectRequest objects of the aselect requests
|
sl@0
|
693 |
RArray<TASelectRequest> iASelectRequest;
|
sl@0
|
694 |
|
sl@0
|
695 |
// Default connection settings, set/cleared using setdefaultif
|
sl@0
|
696 |
TConnPref* iDefConnPref;
|
sl@0
|
697 |
RTz iTzServer;
|
sl@0
|
698 |
RFastLock iTzServerLock;
|
sl@0
|
699 |
TBool iIsRTzConnected;
|
sl@0
|
700 |
RPointerArray<CSocketDesc> iSocketArray;
|
sl@0
|
701 |
#ifdef SYMBIAN_OE_POSIX_SIGNALS
|
sl@0
|
702 |
// Signal handler thread
|
sl@0
|
703 |
RThread iSignalHandlerThread;
|
sl@0
|
704 |
RPipe iSignalReadPipe;
|
sl@0
|
705 |
RPipe iSignalWritePipe;
|
sl@0
|
706 |
TBool iSignalLoopRunning;
|
sl@0
|
707 |
RSignalSession iSignalSession;
|
sl@0
|
708 |
TUint64 iSigMask;
|
sl@0
|
709 |
RArray<TSignalMessage> iBlockedSigArray;
|
sl@0
|
710 |
RMutex iBlockedSAMutex;
|
sl@0
|
711 |
TRequestStatus iPipeReadStatus;
|
sl@0
|
712 |
|
sl@0
|
713 |
// For thread(s) to wait till signals initialization happens
|
sl@0
|
714 |
TInt iSigInitWaitCount;
|
sl@0
|
715 |
RSemaphore iSigInitWaitSemaphore;
|
sl@0
|
716 |
RMutex iSigInitWaitMutex;
|
sl@0
|
717 |
TBool iSignalsInitialized;
|
sl@0
|
718 |
|
sl@0
|
719 |
RSemaphore iSignalInitSemaphore;
|
sl@0
|
720 |
|
sl@0
|
721 |
class TChildWaiter
|
sl@0
|
722 |
{
|
sl@0
|
723 |
public:
|
sl@0
|
724 |
TChildWaiter()
|
sl@0
|
725 |
{
|
sl@0
|
726 |
iWaiterStatus = KRequestPending;
|
sl@0
|
727 |
iWaiterPid = 0;
|
sl@0
|
728 |
}
|
sl@0
|
729 |
|
sl@0
|
730 |
virtual ~TChildWaiter() {}
|
sl@0
|
731 |
|
sl@0
|
732 |
TRequestStatus iWaiterStatus;
|
sl@0
|
733 |
TProcessId iWaiterPid;
|
sl@0
|
734 |
|
sl@0
|
735 |
static TBool MatchByPid(const TChildWaiter& aWaiter1, const TChildWaiter& aWaiter2)
|
sl@0
|
736 |
{
|
sl@0
|
737 |
if((aWaiter1.iWaiterPid == aWaiter2.iWaiterPid) != 0)
|
sl@0
|
738 |
return ETrue;
|
sl@0
|
739 |
else
|
sl@0
|
740 |
return EFalse;
|
sl@0
|
741 |
}
|
sl@0
|
742 |
|
sl@0
|
743 |
static TBool MatchNotPending(const TChildWaiter& aWaiter1, const TChildWaiter& aWaiter2)
|
sl@0
|
744 |
{
|
sl@0
|
745 |
if(aWaiter1.iWaiterStatus == KRequestPending || aWaiter2.iWaiterStatus == KRequestPending)
|
sl@0
|
746 |
return EFalse;
|
sl@0
|
747 |
else
|
sl@0
|
748 |
return ETrue;
|
sl@0
|
749 |
}
|
sl@0
|
750 |
};
|
sl@0
|
751 |
|
sl@0
|
752 |
class TSignalActionInfo
|
sl@0
|
753 |
{
|
sl@0
|
754 |
public:
|
sl@0
|
755 |
TSignalActionInfo()
|
sl@0
|
756 |
{
|
sl@0
|
757 |
iSigHandler = SIG_DFL;
|
sl@0
|
758 |
iSigAction = 0;
|
sl@0
|
759 |
iSigFlags = 0;
|
sl@0
|
760 |
}
|
sl@0
|
761 |
|
sl@0
|
762 |
virtual ~TSignalActionInfo() {}
|
sl@0
|
763 |
|
sl@0
|
764 |
TSignalHandler iSigHandler;
|
sl@0
|
765 |
TSignalAction iSigAction;
|
sl@0
|
766 |
TUint32 iSigFlags;
|
sl@0
|
767 |
};
|
sl@0
|
768 |
|
sl@0
|
769 |
TFixedArray<TSignalActionInfo,SIGRTMAX> iSigActions;
|
sl@0
|
770 |
RMutex iSigHandlerMutex;
|
sl@0
|
771 |
RTimer iAlarmTimer;
|
sl@0
|
772 |
TTime iAlarmStartTime;
|
sl@0
|
773 |
TRequestStatus iAlarmStatus;
|
sl@0
|
774 |
TBool iIsTimerActive;
|
sl@0
|
775 |
TUint iCurrentTimeout;
|
sl@0
|
776 |
|
sl@0
|
777 |
void HandleSignal(TSignalMessage& aMsg, TBool aIsDequeued = EFalse);
|
sl@0
|
778 |
void InitializeSignalHandlers();
|
sl@0
|
779 |
void CallDefaultHandler(int aSigNum);
|
sl@0
|
780 |
void WaitOrHandleSignal(TSignalMessage aMsg);
|
sl@0
|
781 |
TInt SuspendOtherThreads();
|
sl@0
|
782 |
TInt ResumeOtherThreads();
|
sl@0
|
783 |
TInt EnsureSignalsInitialized();
|
sl@0
|
784 |
TInt SigWaitInternal(TUint64 aWaitSet,TSignalMessage* aMsg,TInt aTimeout,TBool aTimeCheckFailed=EFalse);
|
sl@0
|
785 |
|
sl@0
|
786 |
class TSignalWaiter
|
sl@0
|
787 |
{
|
sl@0
|
788 |
public:
|
sl@0
|
789 |
TSignalWaiter(TUint64 aWaitMask, TSignalMessage* aMsgPtr)
|
sl@0
|
790 |
{
|
sl@0
|
791 |
iSigWaitSemaphore.CreateLocal(0);
|
sl@0
|
792 |
iSigWaitMessagePtr = aMsgPtr;
|
sl@0
|
793 |
iSigWaitMask = aWaitMask;
|
sl@0
|
794 |
|
sl@0
|
795 |
RThread lThread;
|
sl@0
|
796 |
iSigWaitThreadId = lThread.Id();
|
sl@0
|
797 |
lThread.Close();
|
sl@0
|
798 |
}
|
sl@0
|
799 |
|
sl@0
|
800 |
virtual ~TSignalWaiter()
|
sl@0
|
801 |
{
|
sl@0
|
802 |
iSigWaitSemaphore.Close();
|
sl@0
|
803 |
}
|
sl@0
|
804 |
|
sl@0
|
805 |
TUint64 iSigWaitMask;
|
sl@0
|
806 |
RSemaphore iSigWaitSemaphore;
|
sl@0
|
807 |
TSignalMessage* iSigWaitMessagePtr;
|
sl@0
|
808 |
TThreadId iSigWaitThreadId;
|
sl@0
|
809 |
|
sl@0
|
810 |
static TBool MatchByMask(const TSignalWaiter& aWaiter1, const TSignalWaiter& aWaiter2)
|
sl@0
|
811 |
{
|
sl@0
|
812 |
if((aWaiter1.iSigWaitMask & aWaiter2.iSigWaitMask) != 0)
|
sl@0
|
813 |
return ETrue;
|
sl@0
|
814 |
else
|
sl@0
|
815 |
return EFalse;
|
sl@0
|
816 |
}
|
sl@0
|
817 |
|
sl@0
|
818 |
static TBool MatchByThreadId(const TSignalWaiter& aWaiter1, const TSignalWaiter& aWaiter2)
|
sl@0
|
819 |
{
|
sl@0
|
820 |
if(aWaiter1.iSigWaitThreadId == aWaiter2.iSigWaitThreadId)
|
sl@0
|
821 |
return ETrue;
|
sl@0
|
822 |
else
|
sl@0
|
823 |
return EFalse;
|
sl@0
|
824 |
}
|
sl@0
|
825 |
};
|
sl@0
|
826 |
|
sl@0
|
827 |
RArray<TSignalWaiter> iSignalWaiterArray;
|
sl@0
|
828 |
RArray<TChildWaiter> iChildWaiterArray;
|
sl@0
|
829 |
RMutex iSignalWaiterMutex;
|
sl@0
|
830 |
|
sl@0
|
831 |
#ifdef SYMBIAN_OE_LIBRT
|
sl@0
|
832 |
//timers..
|
sl@0
|
833 |
TInt FindTimer(const TInt& aTimerId);
|
sl@0
|
834 |
class TOverrun
|
sl@0
|
835 |
{
|
sl@0
|
836 |
public:
|
sl@0
|
837 |
TOverrun(const TInt& aTimerId):iTimerId(aTimerId), Overruns(0)
|
sl@0
|
838 |
{
|
sl@0
|
839 |
}
|
sl@0
|
840 |
|
sl@0
|
841 |
TInt iTimerId;
|
sl@0
|
842 |
TInt Overruns;
|
sl@0
|
843 |
};
|
sl@0
|
844 |
|
sl@0
|
845 |
RArray<TOverrun> iTimerOverruns;
|
sl@0
|
846 |
RMutex iTimerOverrunsMutex;
|
sl@0
|
847 |
//timers..
|
sl@0
|
848 |
#endif // SYMBIAN_OE_LIBRT
|
sl@0
|
849 |
|
sl@0
|
850 |
#endif // SYMBIAN_OE_POSIX_SIGNALS
|
sl@0
|
851 |
public:
|
sl@0
|
852 |
|
sl@0
|
853 |
IMPORT_C RTz & TZServer(TInt& aStatus);
|
sl@0
|
854 |
|
sl@0
|
855 |
//ipc server session
|
sl@0
|
856 |
RIpcSession iIpcS;
|
sl@0
|
857 |
friend class RFileDesTransferSession;
|
sl@0
|
858 |
};
|
sl@0
|
859 |
|
sl@0
|
860 |
|
sl@0
|
861 |
/*
|
sl@0
|
862 |
* Return global backend object to libraries
|
sl@0
|
863 |
*/
|
sl@0
|
864 |
IMPORT_C CLocalSystemInterface* Backend();
|
sl@0
|
865 |
|
sl@0
|
866 |
|
sl@0
|
867 |
|
sl@0
|
868 |
|
sl@0
|
869 |
// LIBC-BACKEND specific Symbian Error Codes
|
sl@0
|
870 |
const TInt KErrMaxFdOpened = -1025;
|
sl@0
|
871 |
const TInt KErrDirectoryOpen = -1026;
|
sl@0
|
872 |
|
sl@0
|
873 |
|
sl@0
|
874 |
|
sl@0
|
875 |
// Directory enumeration
|
sl@0
|
876 |
|
sl@0
|
877 |
NONSHARABLE_STRUCT(__EPOC32_WDIR) : public CBase // aka "class __EPOC32_WDIR with everything public"
|
sl@0
|
878 |
{
|
sl@0
|
879 |
public:
|
sl@0
|
880 |
__EPOC32_WDIR() {}
|
sl@0
|
881 |
~__EPOC32_WDIR();
|
sl@0
|
882 |
|
sl@0
|
883 |
TInt Open();
|
sl@0
|
884 |
TInt Open(const TDesC& aPath);
|
sl@0
|
885 |
TInt Open(const wchar_t *_path,int*);
|
sl@0
|
886 |
virtual TInt UpdateNarrow();
|
sl@0
|
887 |
HBufC* iPath;
|
sl@0
|
888 |
CDir* iEntries;
|
sl@0
|
889 |
TInt iIndex; // counting down, 0 means "finished"
|
sl@0
|
890 |
struct wdirent iCurrent;
|
sl@0
|
891 |
TInt iCount ;
|
sl@0
|
892 |
TBuf16<KMaxFileName> iCurrentName;
|
sl@0
|
893 |
/* *****************************************************************
|
sl@0
|
894 |
Overloading new and delete operators so that they will
|
sl@0
|
895 |
allocate and deallocare memory from/to the private heap of backend
|
sl@0
|
896 |
********************************************************************/
|
sl@0
|
897 |
inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW
|
sl@0
|
898 |
{
|
sl@0
|
899 |
Mem::FillZ(aBase, aSize); return aBase;
|
sl@0
|
900 |
}
|
sl@0
|
901 |
|
sl@0
|
902 |
inline TAny* operator new(TUint aSize) __NO_THROW
|
sl@0
|
903 |
{
|
sl@0
|
904 |
return Backend()->Alloc(aSize);
|
sl@0
|
905 |
}
|
sl@0
|
906 |
|
sl@0
|
907 |
inline TAny* operator new(TUint aSize, TLeave)
|
sl@0
|
908 |
{
|
sl@0
|
909 |
TAny* ptr = Backend()->Alloc(aSize);
|
sl@0
|
910 |
if (ptr == NULL)
|
sl@0
|
911 |
{
|
sl@0
|
912 |
User::Leave(KErrNoMemory);
|
sl@0
|
913 |
}
|
sl@0
|
914 |
return ptr;
|
sl@0
|
915 |
}
|
sl@0
|
916 |
|
sl@0
|
917 |
inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW
|
sl@0
|
918 |
{
|
sl@0
|
919 |
return Backend()->Alloc(aSize + aExtraSize);
|
sl@0
|
920 |
}
|
sl@0
|
921 |
|
sl@0
|
922 |
inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize)
|
sl@0
|
923 |
{
|
sl@0
|
924 |
TAny* ptr = Backend()->Alloc(aSize + aExtraSize);
|
sl@0
|
925 |
if (ptr == NULL)
|
sl@0
|
926 |
{
|
sl@0
|
927 |
User::Leave(KErrNoMemory);
|
sl@0
|
928 |
}
|
sl@0
|
929 |
return ptr;
|
sl@0
|
930 |
}
|
sl@0
|
931 |
|
sl@0
|
932 |
inline void operator delete(TAny *aPtr) __NO_THROW
|
sl@0
|
933 |
{
|
sl@0
|
934 |
Backend()->Free( aPtr );
|
sl@0
|
935 |
}
|
sl@0
|
936 |
};
|
sl@0
|
937 |
|
sl@0
|
938 |
NONSHARABLE_STRUCT(__EPOC32_DIR) : public __EPOC32_WDIR
|
sl@0
|
939 |
{
|
sl@0
|
940 |
public:
|
sl@0
|
941 |
__EPOC32_DIR(){}
|
sl@0
|
942 |
~__EPOC32_DIR(){}
|
sl@0
|
943 |
|
sl@0
|
944 |
virtual TInt UpdateNarrow();
|
sl@0
|
945 |
struct dirent iCurrentNarrow;
|
sl@0
|
946 |
TBuf8<KMaxFileName> iCurrentNarrowName;
|
sl@0
|
947 |
};
|
sl@0
|
948 |
|
sl@0
|
949 |
NONSHARABLE_STRUCT (_iconv_t)
|
sl@0
|
950 |
{
|
sl@0
|
951 |
TUint toCode;
|
sl@0
|
952 |
TUint fromCode;
|
sl@0
|
953 |
};
|
sl@0
|
954 |
|
sl@0
|
955 |
class TUSockAddr : public TSockAddr
|
sl@0
|
956 |
/*
|
sl@0
|
957 |
Utility class for converting struct sockaddr to and from EPOC32 TSockAddr
|
sl@0
|
958 |
@internalComponent
|
sl@0
|
959 |
*/
|
sl@0
|
960 |
{
|
sl@0
|
961 |
public:
|
sl@0
|
962 |
TUSockAddr() : TSockAddr(), iError(0) {}
|
sl@0
|
963 |
|
sl@0
|
964 |
TUSockAddr(TAny* addr); // constructor form of Prepare
|
sl@0
|
965 |
IMPORT_C TUSockAddr(const TAny* addr, TUint len); // constructor form of Set
|
sl@0
|
966 |
private:
|
sl@0
|
967 |
void Prepare(TAny* addr);
|
sl@0
|
968 |
void Set(const TAny* addr, TUint len);
|
sl@0
|
969 |
public:
|
sl@0
|
970 |
IMPORT_C void Get(TAny* addr, unsigned long* len);
|
sl@0
|
971 |
public:
|
sl@0
|
972 |
TInt iError; // To store error status of TUSockAddr functions, refers errno.h. Notebly not Symbian error codes.
|
sl@0
|
973 |
};
|
sl@0
|
974 |
|
sl@0
|
975 |
|
sl@0
|
976 |
|
sl@0
|
977 |
|
sl@0
|
978 |
|
sl@0
|
979 |
#endif //SYSIF_H
|
sl@0
|
980 |
|