114
|
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 |
// INCLUDE FILES
|
|
19 |
|
|
20 |
#include "menuclientoperation.h"
|
|
21 |
#include "menumsg.h"
|
|
22 |
#include "mcsmenu.h"
|
|
23 |
#include "menubuf.h"
|
|
24 |
|
|
25 |
// ================= MEMBER FUNCTIONS =======================
|
|
26 |
|
|
27 |
// ---------------------------------------------------------
|
|
28 |
// RMenuOperation::Close
|
|
29 |
// ---------------------------------------------------------
|
|
30 |
//
|
|
31 |
void RMenuOperation::Close()
|
|
32 |
{
|
|
33 |
if ( SubSessionHandle() )
|
|
34 |
{
|
|
35 |
CloseSubSession( EMenuOperationClose );
|
|
36 |
}
|
|
37 |
}
|
|
38 |
|
|
39 |
// ---------------------------------------------------------
|
|
40 |
// RMenuOperation::CreateRemove
|
|
41 |
// ---------------------------------------------------------
|
|
42 |
//
|
|
43 |
TInt RMenuOperation::CreateRemove( RMenu& aMenu, TInt aId )
|
|
44 |
{
|
|
45 |
__ASSERT_DEBUG( !SubSessionHandle(), User::Invariant() );
|
|
46 |
return CreateSubSession(
|
|
47 |
aMenu,
|
|
48 |
EMenuOperationCreateRemove,
|
|
49 |
TIpcArgs( aId ) );
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------
|
|
53 |
// RMenuOperation::CreateMoveToFolder
|
|
54 |
// ---------------------------------------------------------
|
|
55 |
//
|
|
56 |
TInt RMenuOperation::CreateMoveToFolder
|
|
57 |
( RMenu& aMenu, const RMenuBuf& aItems, TInt aFolder, TInt aMoveBefore )
|
|
58 |
{
|
|
59 |
__ASSERT_DEBUG( !SubSessionHandle(), User::Invariant() );
|
|
60 |
return CreateSubSession(
|
|
61 |
aMenu,
|
|
62 |
EMenuOperationCreateMoveToFolder,
|
|
63 |
TIpcArgs( aItems.SubSessionHandle(), aFolder, aMoveBefore ) );
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------
|
|
67 |
// RMenuOperation::CreateReorder
|
|
68 |
// ---------------------------------------------------------
|
|
69 |
//
|
|
70 |
TInt RMenuOperation::CreateReorder
|
|
71 |
( RMenu& aMenu, TInt aId, TInt aMoveBefore )
|
|
72 |
{
|
|
73 |
__ASSERT_DEBUG( !SubSessionHandle(), User::Invariant() );
|
|
74 |
return CreateSubSession(
|
|
75 |
aMenu,
|
|
76 |
EMenuOperationCreateReorder,
|
|
77 |
TIpcArgs( aId, aMoveBefore ) );
|
|
78 |
}
|
|
79 |
|
|
80 |
// ---------------------------------------------------------
|
|
81 |
// RMenuOperation::CreateAdd
|
|
82 |
// ---------------------------------------------------------
|
|
83 |
//
|
|
84 |
TInt RMenuOperation::CreateAdd
|
|
85 |
( RMenu& aMenu, const TDesC& aType, const RMenuBuf& aChanges, TInt& aId )
|
|
86 |
{
|
|
87 |
__ASSERT_DEBUG( !SubSessionHandle(), User::Invariant() );
|
|
88 |
TPckg<TInt> id( aId );
|
|
89 |
id() = 0;
|
|
90 |
return CreateSubSession(
|
|
91 |
aMenu,
|
|
92 |
EMenuOperationCreateAdd,
|
|
93 |
TIpcArgs( &aType, aChanges.SubSessionHandle(), &id ) );
|
|
94 |
}
|
|
95 |
|
|
96 |
// ---------------------------------------------------------
|
|
97 |
// RMenuOperation::CreateUpdate
|
|
98 |
// ---------------------------------------------------------
|
|
99 |
//
|
|
100 |
TInt RMenuOperation::CreateUpdate
|
|
101 |
( RMenu& aMenu, TInt aId, const RMenuBuf& aChanges )
|
|
102 |
{
|
|
103 |
__ASSERT_DEBUG( !SubSessionHandle(), User::Invariant() );
|
|
104 |
return CreateSubSession(
|
|
105 |
aMenu,
|
|
106 |
EMenuOperationCreateUpdate,
|
|
107 |
TIpcArgs( aId, aChanges.SubSessionHandle() ) );
|
|
108 |
}
|
|
109 |
|
|
110 |
// ---------------------------------------------------------
|
|
111 |
// RMenuOperation::Cancel
|
|
112 |
// ---------------------------------------------------------
|
|
113 |
//
|
|
114 |
void RMenuOperation::Cancel()
|
|
115 |
{
|
|
116 |
SendReceive( EMenuOperationCancel );
|
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------
|
|
120 |
// RMenuOperation::Start
|
|
121 |
// ---------------------------------------------------------
|
|
122 |
//
|
|
123 |
void RMenuOperation::Start( TRequestStatus &aStatus )
|
|
124 |
{
|
|
125 |
aStatus = KRequestPending;
|
|
126 |
SendReceive( EMenuOperationStart, aStatus );
|
|
127 |
}
|
|
128 |
|
|
129 |
// ================= MEMBER FUNCTIONS =======================
|
|
130 |
|
|
131 |
// ---------------------------------------------------------
|
|
132 |
// CMenuClientOperation::~CMenuClientOperation
|
|
133 |
// ---------------------------------------------------------
|
|
134 |
//
|
|
135 |
CMenuClientOperation::~CMenuClientOperation()
|
|
136 |
{
|
|
137 |
Cancel();
|
|
138 |
iOperation.Close();
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------
|
|
142 |
// CMenuClientOperation::CMenuClientOperation
|
|
143 |
// ---------------------------------------------------------
|
|
144 |
//
|
|
145 |
CMenuClientOperation::CMenuClientOperation
|
|
146 |
( RMenu &aMenu, TInt aPriority, TRequestStatus &aObserverStatus )
|
|
147 |
: CMenuOperation( aMenu, aPriority, aObserverStatus )
|
|
148 |
{
|
|
149 |
CActiveScheduler::Add( this );
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
// CMenuClientOperation::RemoveL
|
|
154 |
// ---------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CMenuClientOperation::RemoveL( TInt aId )
|
|
157 |
{
|
|
158 |
User::LeaveIfError( iOperation.CreateRemove( iMenu, aId ) );
|
|
159 |
Start();
|
|
160 |
}
|
|
161 |
|
|
162 |
// ---------------------------------------------------------
|
|
163 |
// CMenuClientOperation::MoveToFolderL
|
|
164 |
// ---------------------------------------------------------
|
|
165 |
//
|
|
166 |
void CMenuClientOperation::MoveToFolderL
|
|
167 |
( const RMenuBuf& aItems, TInt aFolder, TInt aMoveBefore )
|
|
168 |
{
|
|
169 |
User::LeaveIfError( iOperation.CreateMoveToFolder
|
|
170 |
( iMenu, aItems, aFolder, aMoveBefore ) );
|
|
171 |
Start();
|
|
172 |
}
|
|
173 |
|
|
174 |
// ---------------------------------------------------------
|
|
175 |
// CMenuClientOperation::ReorderL
|
|
176 |
// ---------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CMenuClientOperation::ReorderL( TInt aId, TInt aMoveBefore )
|
|
179 |
{
|
|
180 |
User::LeaveIfError( iOperation.CreateReorder( iMenu, aId, aMoveBefore ) );
|
|
181 |
Start();
|
|
182 |
}
|
|
183 |
|
|
184 |
// ---------------------------------------------------------
|
|
185 |
// CMenuClientOperation::AddL
|
|
186 |
// ---------------------------------------------------------
|
|
187 |
//
|
|
188 |
TInt CMenuClientOperation::AddL
|
|
189 |
( const TDesC& aType, const RMenuBuf& aChanges )
|
|
190 |
{
|
|
191 |
TInt id = 0;
|
|
192 |
User::LeaveIfError( iOperation.CreateAdd( iMenu, aType, aChanges, id ) );
|
|
193 |
Start();
|
|
194 |
return id;
|
|
195 |
}
|
|
196 |
|
|
197 |
// ---------------------------------------------------------
|
|
198 |
// CMenuClientOperation::UpdateL
|
|
199 |
// ---------------------------------------------------------
|
|
200 |
//
|
|
201 |
void CMenuClientOperation::UpdateL
|
|
202 |
( TInt aId, const RMenuBuf& aChanges )
|
|
203 |
{
|
|
204 |
User::LeaveIfError( iOperation.CreateUpdate( iMenu, aId, aChanges ) );
|
|
205 |
Start();
|
|
206 |
}
|
|
207 |
|
|
208 |
// ---------------------------------------------------------
|
|
209 |
// CMenuClientOperation::Start
|
|
210 |
// ---------------------------------------------------------
|
|
211 |
//
|
|
212 |
void CMenuClientOperation::Start()
|
|
213 |
{
|
|
214 |
iObserverStatus = KRequestPending;
|
|
215 |
iOperation.Start( iStatus );
|
|
216 |
SetActive();
|
|
217 |
}
|
|
218 |
|
|
219 |
// ---------------------------------------------------------
|
|
220 |
// CMenuClientOperation::RunL
|
|
221 |
// ---------------------------------------------------------
|
|
222 |
//
|
|
223 |
void CMenuClientOperation::RunL()
|
|
224 |
{
|
|
225 |
// Propagate completion to observer.
|
|
226 |
TRequestStatus* status = &iObserverStatus;
|
|
227 |
User::RequestComplete( status, iStatus.Int() );
|
|
228 |
}
|
|
229 |
|
|
230 |
// ---------------------------------------------------------
|
|
231 |
// CMenuClientOperation::DoCancel
|
|
232 |
// ---------------------------------------------------------
|
|
233 |
//
|
|
234 |
void CMenuClientOperation::DoCancel()
|
|
235 |
{
|
|
236 |
iOperation.Cancel();
|
|
237 |
// Propagate completion to observer.
|
|
238 |
TRequestStatus* status = &iObserverStatus;
|
|
239 |
User::RequestComplete( status, KErrCancel );
|
|
240 |
}
|