|
1 /* |
|
2 * Copyright (c) 2002 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 * Implementation for the RDosEventRcv class. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "DosSvrServices.h" |
|
21 #include "dosclientserver.h" |
|
22 |
|
23 // --------------------------------------------------------- |
|
24 // RDosEventRcv Constructor |
|
25 // --------------------------------------------------------- |
|
26 // |
|
27 |
|
28 RDosEventRcv::RDosEventRcv() |
|
29 { |
|
30 iParamContent = NULL; |
|
31 iContentPtr = NULL; |
|
32 iRegistered = EFalse; |
|
33 iQueue = EQueue; |
|
34 } |
|
35 |
|
36 |
|
37 // --------------------------------------------------------- |
|
38 // RDosEventRcv Destructor |
|
39 // --------------------------------------------------------- |
|
40 // |
|
41 |
|
42 RDosEventRcv::~RDosEventRcv() |
|
43 { |
|
44 if(iParamContent) delete iParamContent; |
|
45 if(iContentPtr) delete iContentPtr; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // RDosEventRcv::Open |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 |
|
53 TInt RDosEventRcv::Open(RDosServer& aServer) |
|
54 { |
|
55 return CreateSubSession(aServer,EDosCreateEventRcvSubSession, TIpcArgs(TIpcArgs::ENothing, TIpcArgs::ENothing, KAutoComplete)); |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // RDosEventRcv::Register |
|
61 // --------------------------------------------------------- |
|
62 // |
|
63 |
|
64 TInt RDosEventRcv::Register(TInt aEvent,TInt aParamSize,TQueueType aQueue) |
|
65 { |
|
66 if(iRegistered) |
|
67 return KErrAlreadyExists; |
|
68 |
|
69 if(iParamContent) |
|
70 { |
|
71 delete iParamContent; |
|
72 } |
|
73 |
|
74 iParamContent = HBufC8::New(aParamSize); |
|
75 if(iParamContent) |
|
76 { |
|
77 if(iContentPtr) |
|
78 { |
|
79 delete iContentPtr; |
|
80 } |
|
81 |
|
82 iContentPtr = new TPtr8(iParamContent->Des()); |
|
83 |
|
84 if(iContentPtr) |
|
85 { |
|
86 TInt err = SendReceive(ERegisterEvent, TIpcArgs(aEvent, TIpcArgs::ENothing, KAutoComplete)); |
|
87 |
|
88 if(!err) |
|
89 { |
|
90 iRegistered = ETrue; |
|
91 iQueue = aQueue; |
|
92 iDosEvent = aEvent; |
|
93 } |
|
94 |
|
95 return err; |
|
96 } |
|
97 } |
|
98 return KErrNoMemory; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // RDosEventRcv::UnRegister |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 |
|
106 void RDosEventRcv::UnRegister() |
|
107 { |
|
108 if(iRegistered) |
|
109 { |
|
110 TInt err = SendReceive(EUnRegisterEvent, TIpcArgs(TIpcArgs::ENothing, TIpcArgs::ENothing, KAutoComplete)); |
|
111 |
|
112 if(!err) |
|
113 { |
|
114 |
|
115 delete iContentPtr; |
|
116 iContentPtr=NULL; |
|
117 delete iParamContent; |
|
118 iParamContent = NULL; |
|
119 |
|
120 iRegistered = EFalse; |
|
121 } |
|
122 } |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------- |
|
126 // RDosEventRcv::WaitEvent |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 |
|
130 TInt RDosEventRcv::WaitEvent(TRequestStatus& aStatus) const |
|
131 { |
|
132 if(iRegistered) |
|
133 { |
|
134 SendReceive(EWaitEvent, TIpcArgs(iQueue, iContentPtr, 0), aStatus); |
|
135 |
|
136 return KErrNone; |
|
137 } |
|
138 return KErrAbort; //It can't wait when it's not registered. |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // RDosEventRcv::CancelWaitEvent |
|
143 // --------------------------------------------------------- |
|
144 // |
|
145 |
|
146 TInt RDosEventRcv::CancelWaitEvent() const |
|
147 { |
|
148 if(iRegistered) |
|
149 { |
|
150 SendReceive(ECancelWaitEvent, TIpcArgs(TIpcArgs::ENothing, TIpcArgs::ENothing, KAutoComplete)); |
|
151 |
|
152 return KErrNone; |
|
153 } |
|
154 return KErrAbort; //It can't cancel wait when it's not registered. |
|
155 } |