|
1 /* |
|
2 * Copyright (c) 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 |
|
19 |
|
20 #ifndef __RIPC_SESSION__ |
|
21 #define __RIPC_SESSION__ |
|
22 |
|
23 #include<e32std.h> //RSessionBase |
|
24 #include<e32def.h> //Varargs |
|
25 #include<sys/types.h> |
|
26 #include<sys/sem.h> |
|
27 |
|
28 struct msqid_ds; |
|
29 struct shmid_ds; |
|
30 |
|
31 class TChunk |
|
32 { |
|
33 public: |
|
34 TChunk(): iRef(0){} |
|
35 TChunk(TInt aShmID): iShmID(aShmID), iRef(0){} |
|
36 TInt iShmID; |
|
37 RChunk iChunk; |
|
38 TInt iRef; |
|
39 }; |
|
40 |
|
41 |
|
42 //----------------------------------------------------------------------- |
|
43 //Class name: RIpcSession |
|
44 //Description: It represents the session to Ipc Server. |
|
45 //----------------------------------------------------------------------- |
|
46 |
|
47 class RIpcSession : public RSessionBase |
|
48 { |
|
49 public: |
|
50 RIpcSession():iIsConnected(EFalse) |
|
51 {iLock.CreateLocal();} |
|
52 |
|
53 //msgqueue functions |
|
54 int msgctl(int msqid, int cmd, struct msqid_ds *buf, int &aerrno); |
|
55 int msgget(key_t key, int msgflg, int& aerrno); |
|
56 ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg, int& aerrno); |
|
57 int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg, int& aerrno); |
|
58 |
|
59 //msgqueue functions |
|
60 int shmctl(int shmid, int cmd, struct shmid_ds *buf, int &aerrno); |
|
61 int shmget(key_t key, size_t size, int shmflg, int& aerrno); |
|
62 void *shmat(int shmid, const void *shmaddr, int shmflg, int& aerrno); |
|
63 int shmdt(const void *shmaddr, int& aerrno); |
|
64 |
|
65 //semqueue functions |
|
66 int semget(key_t key, int nsems, int semflags, int& aerrno); |
|
67 int semctl(int semid, int semnum, int cmd, union semun *arg, int& aerrno); |
|
68 int semop(int semid, struct sembuf *sops, size_t nsops, int& aerrno); |
|
69 |
|
70 RFastLock iLock; |
|
71 private: |
|
72 TInt AddToList(const TInt& aKey, const TInt& aErr, TAny*& aRetPtr); |
|
73 TInt OnDemandConnection(); |
|
74 void Lock() |
|
75 { |
|
76 iLock.Wait(); |
|
77 } |
|
78 void UnLock() |
|
79 { |
|
80 iLock.Signal(); |
|
81 } |
|
82 private: |
|
83 |
|
84 TInt Connect(); |
|
85 TInt iIsConnected; |
|
86 //todo put a lock around this list |
|
87 RArray<TChunk> iChunkList; |
|
88 }; |
|
89 |
|
90 #endif //__RIPC_SESSION__ |
|
91 |
|
92 |