47
|
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 |
*
|
|
15 |
* Description:
|
|
16 |
* The source file of service utils handler
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include "fmserviceutilshandler.h"
|
|
23 |
#include <coreapplicationuisdomainpskeys.h>
|
|
24 |
#include <coemain.h>
|
|
25 |
#include <apgwgnam.h>
|
|
26 |
#include <apgtask.h>
|
|
27 |
#include <bautils.h>
|
|
28 |
#include <tz.h>
|
|
29 |
#include <babackup.h>
|
|
30 |
#include <pathinfo.h>
|
|
31 |
#include <sysutil.h>
|
|
32 |
#include <driveinfo.h>
|
|
33 |
#include <e32property.h>
|
|
34 |
#include <centralrepository.h>
|
|
35 |
|
|
36 |
#include "fmutils.h"
|
|
37 |
#include <QSettings>
|
|
38 |
#include <XQConversions>
|
|
39 |
|
|
40 |
// CONSTANTS
|
|
41 |
const TInt KAppCloseTimeout = 1000000;
|
|
42 |
|
|
43 |
/*!
|
|
44 |
constructor.
|
|
45 |
*/
|
|
46 |
CFmServiceUtilsHandler::CFmServiceUtilsHandler() :
|
|
47 |
CActive( CActive::EPriorityStandard )
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
/*!
|
|
52 |
Two-phased constructor.
|
|
53 |
*/
|
|
54 |
void CFmServiceUtilsHandler::ConstructL()
|
|
55 |
{
|
|
56 |
CActiveScheduler::Add( this );
|
|
57 |
}
|
|
58 |
|
|
59 |
/*!
|
|
60 |
Two-phased constructor.
|
|
61 |
*/
|
|
62 |
CFmServiceUtilsHandler* CFmServiceUtilsHandler::NewL()
|
|
63 |
{
|
|
64 |
RFs& fs( CCoeEnv::Static()->FsSession() );
|
|
65 |
CFmServiceUtilsHandler* self =
|
|
66 |
new( ELeave ) CFmServiceUtilsHandler();
|
|
67 |
|
|
68 |
CleanupStack::PushL( self );
|
|
69 |
self->ConstructL();
|
|
70 |
CleanupStack::Pop( self );
|
|
71 |
|
|
72 |
return self;
|
|
73 |
}
|
|
74 |
|
|
75 |
/*!
|
|
76 |
destructor.
|
|
77 |
*/
|
|
78 |
CFmServiceUtilsHandler::~CFmServiceUtilsHandler()
|
|
79 |
{
|
|
80 |
Cancel();
|
|
81 |
if( iBSWrapper ) {
|
|
82 |
delete iBSWrapper;
|
|
83 |
iBSWrapper = 0;
|
|
84 |
}
|
|
85 |
}
|
|
86 |
|
|
87 |
/*
|
|
88 |
\sa CActive
|
|
89 |
*/
|
|
90 |
void CFmServiceUtilsHandler::DoCancel()
|
|
91 |
{
|
|
92 |
}
|
|
93 |
|
|
94 |
/*
|
|
95 |
\sa CActive
|
|
96 |
*/
|
|
97 |
void CFmServiceUtilsHandler::RunL()
|
|
98 |
{
|
|
99 |
iWait.AsyncStop();
|
|
100 |
TInt err( iStatus.Int() );
|
|
101 |
}
|
|
102 |
|
|
103 |
/*
|
|
104 |
\sa CActive
|
|
105 |
*/
|
|
106 |
TInt CFmServiceUtilsHandler::RunError( TInt /*aError*/ )
|
|
107 |
{
|
|
108 |
iWait.AsyncStop();
|
|
109 |
return KErrNone;
|
|
110 |
}
|
|
111 |
|
|
112 |
/*
|
|
113 |
Call CBaBackupSessionWrapper to close apps
|
|
114 |
this is synchronous which will take a while, please call this function in thread
|
|
115 |
*/
|
|
116 |
void CFmServiceUtilsHandler::CloseAppsL()
|
|
117 |
{
|
|
118 |
if( iBSWrapper ) {
|
|
119 |
delete iBSWrapper;
|
|
120 |
iBSWrapper = 0;
|
|
121 |
}
|
|
122 |
|
|
123 |
iBSWrapper = CBaBackupSessionWrapper::NewL();
|
|
124 |
|
|
125 |
TBackupOperationAttributes atts(
|
|
126 |
MBackupObserver::EReleaseLockNoAccess,
|
|
127 |
MBackupOperationObserver::EStart );
|
|
128 |
iBSWrapper->NotifyBackupOperationL( atts );
|
|
129 |
iBSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, iStatus );
|
|
130 |
SetActive();
|
|
131 |
|
|
132 |
// Memory card formatting cannot be executed if there are open files on it.
|
|
133 |
// It has been detected, that in some cases memory card using applications
|
|
134 |
// have no time to close file handles before formatting is tried to be executed.
|
|
135 |
// To address this issue, we need to add a delay here after client-notification
|
|
136 |
// about pending format and real formatting procedure.
|
|
137 |
User::After( KAppCloseTimeout );
|
|
138 |
StartWait();
|
|
139 |
}
|
|
140 |
|
|
141 |
/*
|
|
142 |
Call CBaBackupSessionWrapper to restart closed apps
|
|
143 |
this is synchronous which will return quickly.
|
|
144 |
*/
|
|
145 |
void CFmServiceUtilsHandler::RestartAppsL()
|
|
146 |
{
|
|
147 |
if ( !iBSWrapper )
|
|
148 |
{
|
|
149 |
return;
|
|
150 |
}
|
|
151 |
|
|
152 |
TBackupOperationAttributes atts(
|
|
153 |
MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd );
|
|
154 |
iBSWrapper->NotifyBackupOperationL( atts );
|
|
155 |
iBSWrapper->RestartAll();
|
|
156 |
|
|
157 |
// Get rid of the wrapper instance
|
|
158 |
delete iBSWrapper;
|
|
159 |
iBSWrapper = 0;
|
|
160 |
}
|
|
161 |
|
|
162 |
/*
|
|
163 |
wait till request returned in RunL
|
|
164 |
*/
|
|
165 |
void CFmServiceUtilsHandler::StartWait()
|
|
166 |
{
|
|
167 |
if ( iWait.IsStarted() != (TInt)ETrue )
|
|
168 |
{
|
|
169 |
iWait.Start();
|
|
170 |
}
|
|
171 |
}
|
|
172 |
|
|
173 |
// End of File
|