|
1 /* |
|
2 * Copyright (c) 2002-2007 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: A command to delete a contact from the sim store |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CDeleteCommand.h" |
|
22 |
|
23 #include "CVPbkStoreSession.h" |
|
24 #include "SimServerInternal.h" |
|
25 #include <MVPbkSimCntStore.h> |
|
26 #include <MVPbkSimCommandObserver.h> |
|
27 #include <MVPbkSimStoreOperation.h> |
|
28 |
|
29 #include <VPbkDebug.h> |
|
30 |
|
31 namespace VPbkSimServer { |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CDeleteCommand::CDeleteCommand |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CDeleteCommand::CDeleteCommand( CVPbkStoreSession& aParentSession, |
|
42 RVPbkStreamedIntArray& aSimIndexes, const RMessage2& aMessage ) |
|
43 : iParentSession( aParentSession ), |
|
44 iSimIndexes( aSimIndexes ), |
|
45 iMessage( aMessage ) |
|
46 { |
|
47 } |
|
48 |
|
49 // Destructor |
|
50 CDeleteCommand::~CDeleteCommand() |
|
51 { |
|
52 delete iDeleteOperation; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CDeleteCommand::PanicClient |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void CDeleteCommand::PanicClient( TClientPanicCode aPanicCode ) |
|
60 { |
|
61 delete iDeleteOperation; |
|
62 iDeleteOperation = NULL; |
|
63 iParentSession.ResetLatestDeleteCommand(); |
|
64 iObserver->CommandDone( *this ); |
|
65 VPbkSimServer::PanicClient( iMessage, aPanicCode ); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CDeleteCommand::Execute |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CDeleteCommand::Execute() |
|
73 { |
|
74 TRAPD( result, |
|
75 iDeleteOperation = |
|
76 iParentSession.Store().DeleteL( iSimIndexes, *this ) ); |
|
77 if ( result != KErrNone ) |
|
78 { |
|
79 CompleteDeleteRequest( result ); |
|
80 iObserver->CommandDone( *this ); |
|
81 } |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CDeleteCommand::AddObserverL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CDeleteCommand::AddObserverL( MVPbkSimCommandObserver& aObserver ) |
|
89 { |
|
90 __ASSERT_DEBUG( !iObserver, |
|
91 VPbkSimServer::Panic( ECommandObserverAlreadySetInDeleteCmd ) ); |
|
92 iObserver = &aObserver; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CDeleteCommand::CancelCmd |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CDeleteCommand::CancelCmd() |
|
100 { |
|
101 delete iDeleteOperation; |
|
102 iDeleteOperation = NULL; |
|
103 CompleteDeleteRequest( KErrCancel ); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CDeleteCommand::ContactEventComplete |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CDeleteCommand::ContactEventComplete( TEvent VPBK_DEBUG_ONLY( aEvent ), |
|
111 CVPbkSimContact* /*aContact*/ ) |
|
112 { |
|
113 __ASSERT_DEBUG( aEvent == MVPbkSimContactObserver::EDelete, |
|
114 VPbkSimServer::Panic( EIncorrectContactEventInDeleteCmd ) ); |
|
115 __ASSERT_DEBUG( iMessage.Handle(), |
|
116 VPbkSimServer::Panic( EInvalidHandleInDeleteCmd ) ); |
|
117 |
|
118 CompleteDeleteRequest( KErrNone ); |
|
119 iObserver->CommandDone( *this ); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CDeleteCommand::ContactEventError |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CDeleteCommand::ContactEventError( TEvent /*aEvent*/, |
|
127 CVPbkSimContact* /*aContact*/, TInt aError ) |
|
128 { |
|
129 CompleteDeleteRequest( aError ); |
|
130 iObserver->CommandDone( *this ); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CDeleteCommand::CompleteDeleteRequest |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CDeleteCommand::CompleteDeleteRequest( TInt aResult ) |
|
138 { |
|
139 __ASSERT_DEBUG( iMessage.Handle(), |
|
140 VPbkSimServer::Panic( VPbkSimServer::EInvalidHandleInDeleteCmd ) ); |
|
141 VPbkSimSrvUtility::CompleteRequest( iMessage, aResult ); |
|
142 iParentSession.ResetLatestDeleteCommand(); |
|
143 } |
|
144 } // namespace VPbkSimServer |
|
145 // End of File |