24
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Implements CBackupAndRestore
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include <e32std.h>
|
|
23 |
#include "SmsuBackup.h"
|
|
24 |
#include <babackup.h>
|
|
25 |
#include "smsstacklog.h"
|
|
26 |
|
|
27 |
|
|
28 |
const TInt KBURPartMask = 0x000000FF;
|
|
29 |
|
|
30 |
#include <connect/sbdefs.h>
|
|
31 |
|
|
32 |
using namespace conn;
|
|
33 |
|
|
34 |
|
|
35 |
EXPORT_C CBackupAndRestore* CBackupAndRestore::NewL(MNBBackupAndRestoreObserver& aBackupAndRestoreObserver)
|
|
36 |
{
|
|
37 |
LOGSMSU1("CBackupAndRestore::NewL()");
|
|
38 |
|
|
39 |
CBackupAndRestore* me = new(ELeave) CBackupAndRestore(aBackupAndRestoreObserver);
|
|
40 |
CleanupStack::PushL(me);
|
|
41 |
me->ConstructL();
|
|
42 |
CleanupStack::Pop(me);
|
|
43 |
return me;
|
|
44 |
} // CBackupAndRestore::NewL
|
|
45 |
|
|
46 |
|
|
47 |
CBackupAndRestore::CBackupAndRestore(MNBBackupAndRestoreObserver& aBackupAndRestoreObserver)
|
|
48 |
:CActive(EPriorityStandard)
|
|
49 |
{
|
|
50 |
iBackupAndRestoreObserver=&aBackupAndRestoreObserver;
|
|
51 |
}
|
|
52 |
|
|
53 |
|
|
54 |
void CBackupAndRestore::ConstructL()
|
|
55 |
{
|
|
56 |
LOGSMSU1("CBackupAndRestore::ConstructL()");
|
|
57 |
|
|
58 |
iBackupOrRestoreInProgress = EFalse;
|
|
59 |
User::LeaveIfError(iBackupProperty.Attach(KUidSystemCategory,KUidBackupRestoreKey));
|
|
60 |
CActiveScheduler::Add(this);
|
|
61 |
iBackupProperty.Subscribe(iStatus);
|
|
62 |
SetActive();
|
|
63 |
}
|
|
64 |
|
|
65 |
|
|
66 |
EXPORT_C CBackupAndRestore::~CBackupAndRestore()
|
|
67 |
{
|
|
68 |
Cancel();
|
|
69 |
iBackupProperty.Close();
|
|
70 |
} // CBackupAndRestore::~CBackupAndRestore
|
|
71 |
|
|
72 |
|
|
73 |
void CBackupAndRestore::DoCancel()
|
|
74 |
{
|
|
75 |
LOGSMSU1("CBackupAndRestore::DoCancel()");
|
|
76 |
|
|
77 |
iBackupProperty.Cancel();
|
|
78 |
} // CBackupAndRestore::DoCancel
|
|
79 |
|
|
80 |
|
|
81 |
EXPORT_C TBool CBackupAndRestore::IsBackupOrRestoreInProgress()
|
|
82 |
{
|
|
83 |
LOGSMSU1("CBackupAndRestore::IsBackupOrRestoreInProgress()");
|
|
84 |
|
|
85 |
return iBackupOrRestoreInProgress;
|
|
86 |
} // CBackupAndRestore::IsBackupOrRestoreInProgress
|
|
87 |
|
|
88 |
|
|
89 |
/**
|
|
90 |
* @leave KErrNotSupported if unknown backup flag is found
|
|
91 |
*/
|
|
92 |
void CBackupAndRestore::RunL()
|
|
93 |
{
|
|
94 |
LOGSMSU1("CBackupAndRestore::RunL()");
|
|
95 |
|
|
96 |
iBackupProperty.Subscribe(iStatus);
|
|
97 |
SetActive();
|
|
98 |
|
|
99 |
|
|
100 |
TInt backupRestoreFlag;
|
|
101 |
iBackupProperty.Get(backupRestoreFlag);
|
|
102 |
switch(backupRestoreFlag & KBURPartMask)
|
|
103 |
{
|
|
104 |
case EBURUnset:
|
|
105 |
case EBURNormal:
|
|
106 |
if(iBackupOrRestoreInProgress) //only report complete if already reported starting
|
|
107 |
{
|
|
108 |
iBackupAndRestoreObserver->HandleBackupOrRestoreCompleteL();
|
|
109 |
iBackupOrRestoreInProgress=EFalse;
|
|
110 |
}
|
|
111 |
break;
|
|
112 |
case EBURBackupFull:
|
|
113 |
case EBURBackupPartial:
|
|
114 |
case EBURRestoreFull:
|
|
115 |
case EBURRestorePartial:
|
|
116 |
iBackupOrRestoreInProgress=ETrue;
|
|
117 |
iBackupAndRestoreObserver->HandleBackupOrRestoreStartingL();
|
|
118 |
break;
|
|
119 |
default:
|
|
120 |
User::Leave(KErrNotSupported); //unexpected value
|
|
121 |
};
|
|
122 |
} // CBackupAndRestore::RunL
|
|
123 |
|