filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilsprivate.cpp
changeset 48 1bebd60c0f00
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilsprivate.cpp	Mon Oct 04 00:06:46 2010 +0300
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+* 
+* Contributors:
+*
+* 
+* Description:
+*     The source file of service utils private
+*/
+
+#include "fmserviceutilsprivate.h"
+#include "fmserviceutilshandler.h"
+#include "fmcommon.h"
+#include <shareui.h>
+
+FmServiceUtilsPrivate::FmServiceUtilsPrivate()
+    :mShareUi( 0 ), mServiceUtilsHandler( 0 )
+{
+    
+}
+
+FmServiceUtilsPrivate::~FmServiceUtilsPrivate()
+{
+    if( mShareUi ) {
+        delete mShareUi;
+        mShareUi = 0;
+    }
+    
+    if( mServiceUtilsHandler ) {
+        delete mServiceUtilsHandler;
+        mServiceUtilsHandler = 0;
+    }
+    
+}
+
+/*
+   return \a shareUi which is used to send files. 
+*/
+ShareUi *FmServiceUtilsPrivate::shareUi()
+{
+    if( !mShareUi ) {
+        mShareUi = new ShareUi;
+    }
+    return mShareUi;
+}
+
+/*
+   return \a CFmServiceUtilsHandler which is used to closeApps and restartApps
+*/
+CFmServiceUtilsHandler *FmServiceUtilsPrivate::serviceUtilsHandler()
+{
+    if( !mServiceUtilsHandler ) {
+        TRAPD(err, mServiceUtilsHandler = CFmServiceUtilsHandler::NewL());
+        if( err != KErrNone ) {
+            mServiceUtilsHandler = 0;
+        }
+    }
+    return mServiceUtilsHandler;
+}
+
+/*!
+    send files that included in \a filePathList via ShareUi
+*/
+void FmServiceUtilsPrivate::sendFile( const QStringList &filePathList )
+{
+    // send do not accept const QStringList, so use QStringList()<<filePathList
+    shareUi()->send( QStringList()<<filePathList, true );
+}
+
+/*!
+    call CBaBackupSessionWrapper to close apps, for example, before formant, apps need be closed
+    this is synchronous which will take a while, please call this function in thread
+*/
+void FmServiceUtilsPrivate::closeApps()
+{
+    CFmServiceUtilsHandler *utilsHandler = serviceUtilsHandler();
+    if( utilsHandler ) {
+        TRAP_IGNORE( utilsHandler->CloseAppsL() );
+    }
+}
+
+/*!
+    call CBaBackupSessionWrapper to restart apps
+    for example, after formant, closed apps need be restarted
+    this is synchronous which will return quickly.
+*/
+void FmServiceUtilsPrivate::restartApps()
+{
+    CFmServiceUtilsHandler *utilsHandler = serviceUtilsHandler();
+    if( utilsHandler ) {
+        TRAP_IGNORE( serviceUtilsHandler()->RestartAppsL() );
+    }
+}
+