deviceupdatesui/deviceupdatesplugin/src/deviceupdatesdata.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 15:05:55 +0300
branchRCL_3
changeset 57 6757f1e2efd2
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* Copyright (c) 2010 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:  Device updates data for control panel
*
*/

#include <QtCore/QProcess>
#include <QtCore/QDir>
#include <QtCore/QLibraryInfo>
#include <cpsettingformitemdata.h>
#include <apgtask.h>
#include "deviceupdatesdata.h"


DeviceUpdateData::DeviceUpdateData(CpItemDataHelper &itemDataHelper,
													   const QString &text /*= QString()*/,
													   const QString &description /*= QString()*/,
													   const HbIcon &icon /*= HbIcon()*/,
													   const HbDataFormModelItem *parent /*= 0*/)
													   : CpSettingFormEntryItemData(itemDataHelper,
													   text,
													   description,
													   icon,
													   parent)
{
	mproc = NULL;
}

DeviceUpdateData::~DeviceUpdateData()
{
	CloseDeviceUpdatesUi();
	if (mproc)
	{
		delete mproc;
		mproc = NULL;
	}
}

// -----------------------------------------------------------------------------
// DeviceUpdateData::OpenDmAppL()
// -----------------------------------------------------------------------------
//
void DeviceUpdateData::LaunchDeviceUpdatesUi()
	{	
		
		RWsSession ws;
    User::LeaveIfError( ws.Connect() );
    CleanupClosePushL( ws );
    // Find the task with uid
    TApaTaskList taskList(ws);
    TApaTask task = taskList.FindApp( KUidSmlSyncApp );    
    if ( task.Exists() )
    {    	    
        task.BringToForeground();        
    }
    else
    {
 				// Create DM UI Process
    		if(!mproc)
    			mproc = new QProcess();
    		if(mproc->state() != QProcess::Running)
    		{
    			QString app = QLatin1String("deviceupdates");
    			QStringList args;
    			args<< QLatin1String("-cp");
    			mproc->start(app, args);
    			mproc->waitForStarted();
    		}     
    }
    CleanupStack::PopAndDestroy();  // ws    		
	}

// ---------------------------------------------------------------------------------------------
// DeviceUpdateData::CloseDmUi
// closes DM Ui
// ---------------------------------------------------------------------------------------------	
void DeviceUpdateData:: CloseDeviceUpdatesUi()
{
	if(( mproc )&&(mproc->state() == QProcess::Running))
  	{
    			mproc->close();
    }

}	

void DeviceUpdateData::onLaunchView()
{
	LaunchDeviceUpdatesUi();
}

CpBaseSettingView *DeviceUpdateData::createSettingView() const
{
		return 0;
}