20
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2008 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: CSConBackupRestore implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <pathinfo.h>
|
|
21 |
|
|
22 |
#include "sconbackuprestore.h"
|
|
23 |
#include "sconsbeclient.h"
|
|
24 |
#include "sconbrqueue.h"
|
|
25 |
#include "sconpcdconsts.h"
|
|
26 |
|
|
27 |
#include "debug.h"
|
|
28 |
|
|
29 |
// ============================= MEMBER FUNCTIONS ===============================
|
|
30 |
|
|
31 |
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
// CSConBackupRestore* CSConBackupRestore::NewL( CSConBackupRestoreQueue* aQueue,
|
|
34 |
// cost TInt& aMaxObjectSize )
|
|
35 |
// Two-phase constructor
|
|
36 |
// -----------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
CSConBackupRestore* CSConBackupRestore::NewL( CSConBackupRestoreQueue* aQueue,
|
|
39 |
const TInt aMaxObjectSize, RFs& aFs )
|
|
40 |
{
|
|
41 |
CSConBackupRestore* self = new (ELeave) CSConBackupRestore( aQueue, aFs );
|
|
42 |
CleanupStack::PushL( self );
|
|
43 |
self->ConstructL( aMaxObjectSize );
|
|
44 |
CleanupStack::Pop( self );
|
|
45 |
return self;
|
|
46 |
}
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// CSConBackupRestore::CSConBackupRestore( CSConBackupRestoreQueue* aQueue )
|
|
50 |
// Constructor
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CSConBackupRestore::CSConBackupRestore( CSConBackupRestoreQueue* aQueue, RFs& aFs ) :
|
|
54 |
CActive( EPriorityStandard ), iQueue( aQueue ), iFs( aFs )
|
|
55 |
{
|
|
56 |
}
|
|
57 |
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
// CSConBackupRestore::ConstructL( const TInt aMaxObjectSize )
|
|
60 |
// Initializes member data
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
void CSConBackupRestore::ConstructL( const TInt aMaxObjectSize )
|
|
64 |
{
|
|
65 |
iMaxObjectSize = aMaxObjectSize;
|
|
66 |
iSBEClient = CSConSBEClient::NewL( aMaxObjectSize, iFs );
|
|
67 |
CActiveScheduler::Add( iSBEClient );
|
|
68 |
}
|
|
69 |
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
// CSConBackupRestore::~CSConBackupRestore()
|
|
72 |
// Destructor
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
CSConBackupRestore::~CSConBackupRestore()
|
|
76 |
{
|
|
77 |
if( iSBEClient )
|
|
78 |
{
|
|
79 |
iSBEClient->Cancel();
|
|
80 |
delete iSBEClient;
|
|
81 |
iSBEClient = NULL;
|
|
82 |
}
|
|
83 |
}
|
|
84 |
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
// CSConBackupRestore::StartBackupRestore( TInt aTaskId )
|
|
87 |
// Starts backup-restore task
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void CSConBackupRestore::StartBackupRestore( TInt aTaskId )
|
|
91 |
{
|
|
92 |
iBackupRestoreActive = ETrue;
|
|
93 |
CSConTask* task = NULL;
|
|
94 |
|
|
95 |
TInt ret = iQueue->GetTask( aTaskId, task );
|
|
96 |
|
|
97 |
if( aTaskId > 0 && ret != KErrNotFound )
|
|
98 |
{
|
|
99 |
iCurrentTask = aTaskId;
|
|
100 |
iQueue->SetTaskProgress( aTaskId, KSConCodeProcessingStarted );
|
|
101 |
}
|
|
102 |
|
|
103 |
switch( task->GetServiceId() )
|
|
104 |
{
|
|
105 |
case ESetBURMode :
|
|
106 |
iQueue->ChangeQueueProcessStatus();
|
|
107 |
iSBEClient->SetBURMode( iStatus, task );
|
|
108 |
break;
|
|
109 |
case EListPublicFiles :
|
|
110 |
iSBEClient->ListPublicFiles( iStatus, task );
|
|
111 |
break;
|
|
112 |
case EListDataOwners :
|
|
113 |
iSBEClient->ListDataOwners( iStatus, task );
|
|
114 |
break;
|
|
115 |
case EGetDataSize :
|
|
116 |
iSBEClient->GetDataSize( iStatus, task );
|
|
117 |
break;
|
|
118 |
case ERequestData :
|
|
119 |
iSBEClient->RequestData( iStatus, task );
|
|
120 |
break;
|
|
121 |
case EGetDataOwnerStatus :
|
|
122 |
iSBEClient->GetDataOwnerStatus( iStatus, task );
|
|
123 |
break;
|
|
124 |
case ESupplyData :
|
|
125 |
iSBEClient->SupplyData( iStatus, task );
|
|
126 |
break;
|
|
127 |
default :
|
|
128 |
break;
|
|
129 |
}
|
|
130 |
|
|
131 |
SetActive();
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CSConBackupRestore::StopBackupRestore( TInt aTaskId )
|
|
136 |
// Stops executing backup-restore task
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
void CSConBackupRestore::StopBackupRestore( TInt aTaskId )
|
|
140 |
{
|
|
141 |
TRACE_FUNC_ENTRY;
|
|
142 |
//if the task is active, do cancel
|
|
143 |
if( iCurrentTask == aTaskId )
|
|
144 |
{
|
|
145 |
iBackupRestoreActive = EFalse;
|
|
146 |
iSBEClient->Cancel();
|
|
147 |
}
|
|
148 |
TRACE_FUNC_EXIT;
|
|
149 |
}
|
|
150 |
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
// CSConBackupRestore::Reset()
|
|
153 |
// Resets backup
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CSConBackupRestore::Reset()
|
|
157 |
{
|
|
158 |
TRACE_FUNC_ENTRY;
|
|
159 |
if( iSBEClient )
|
|
160 |
{
|
|
161 |
iSBEClient->Cancel();
|
|
162 |
delete iSBEClient;
|
|
163 |
iSBEClient = NULL;
|
|
164 |
}
|
|
165 |
|
|
166 |
TRAPD( err, iSBEClient = CSConSBEClient::NewL( iMaxObjectSize, iFs ) );
|
|
167 |
|
|
168 |
if( err == KErrNone )
|
|
169 |
{
|
|
170 |
CActiveScheduler::Add( iSBEClient );
|
|
171 |
}
|
|
172 |
|
|
173 |
iBackupRestoreActive = EFalse;
|
|
174 |
TRACE_FUNC_EXIT;
|
|
175 |
}
|
|
176 |
|
|
177 |
// -----------------------------------------------------------------------------
|
|
178 |
// CSConBackupRestore::BackupRestoreActive()
|
|
179 |
// returns backup-restore activity status
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
TBool CSConBackupRestore::BackupRestoreActive() const
|
|
183 |
{
|
|
184 |
return iBackupRestoreActive;
|
|
185 |
}
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
// CSConBackupRestore::DoCancel()
|
|
188 |
// Implementation of CActive::DoCancel()
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CSConBackupRestore::DoCancel()
|
|
192 |
{
|
|
193 |
TRACE_FUNC;
|
|
194 |
}
|
|
195 |
|
|
196 |
// -----------------------------------------------------------------------------
|
|
197 |
// CSConBackupRestore::RunL()
|
|
198 |
// Implementation of CActive::RunL()
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
//
|
|
201 |
void CSConBackupRestore::RunL()
|
|
202 |
{
|
|
203 |
TRACE_FUNC;
|
|
204 |
iQueue->CompleteTask( iCurrentTask, iStatus.Int() );
|
|
205 |
iBackupRestoreActive = EFalse;
|
|
206 |
}
|
|
207 |
|
|
208 |
// End of file
|