deviceupdatesui/deviceupdatesplugin/src/deviceupdatesdata.cpp
branchRCL_3
changeset 57 6757f1e2efd2
equal deleted inserted replaced
55:c4687ff85147 57:6757f1e2efd2
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Device updates data for control panel
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtCore/QProcess>
       
    19 #include <QtCore/QDir>
       
    20 #include <QtCore/QLibraryInfo>
       
    21 #include <cpsettingformitemdata.h>
       
    22 #include <apgtask.h>
       
    23 #include "deviceupdatesdata.h"
       
    24 
       
    25 
       
    26 DeviceUpdateData::DeviceUpdateData(CpItemDataHelper &itemDataHelper,
       
    27 													   const QString &text /*= QString()*/,
       
    28 													   const QString &description /*= QString()*/,
       
    29 													   const HbIcon &icon /*= HbIcon()*/,
       
    30 													   const HbDataFormModelItem *parent /*= 0*/)
       
    31 													   : CpSettingFormEntryItemData(itemDataHelper,
       
    32 													   text,
       
    33 													   description,
       
    34 													   icon,
       
    35 													   parent)
       
    36 {
       
    37 	mproc = NULL;
       
    38 }
       
    39 
       
    40 DeviceUpdateData::~DeviceUpdateData()
       
    41 {
       
    42 	CloseDeviceUpdatesUi();
       
    43 	if (mproc)
       
    44 	{
       
    45 		delete mproc;
       
    46 		mproc = NULL;
       
    47 	}
       
    48 }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // DeviceUpdateData::OpenDmAppL()
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void DeviceUpdateData::LaunchDeviceUpdatesUi()
       
    55 	{	
       
    56 		
       
    57 		RWsSession ws;
       
    58     User::LeaveIfError( ws.Connect() );
       
    59     CleanupClosePushL( ws );
       
    60     // Find the task with uid
       
    61     TApaTaskList taskList(ws);
       
    62     TApaTask task = taskList.FindApp( KUidSmlSyncApp );    
       
    63     if ( task.Exists() )
       
    64     {    	    
       
    65         task.BringToForeground();        
       
    66     }
       
    67     else
       
    68     {
       
    69  				// Create DM UI Process
       
    70     		if(!mproc)
       
    71     			mproc = new QProcess();
       
    72     		if(mproc->state() != QProcess::Running)
       
    73     		{
       
    74     			QString app = QLatin1String("deviceupdates");
       
    75     			QStringList args;
       
    76     			args<< QLatin1String("-cp");
       
    77     			mproc->start(app, args);
       
    78     			mproc->waitForStarted();
       
    79     		}     
       
    80     }
       
    81     CleanupStack::PopAndDestroy();  // ws    		
       
    82 	}
       
    83 
       
    84 // ---------------------------------------------------------------------------------------------
       
    85 // DeviceUpdateData::CloseDmUi
       
    86 // closes DM Ui
       
    87 // ---------------------------------------------------------------------------------------------	
       
    88 void DeviceUpdateData:: CloseDeviceUpdatesUi()
       
    89 {
       
    90 	if(( mproc )&&(mproc->state() == QProcess::Running))
       
    91   	{
       
    92     			mproc->close();
       
    93     }
       
    94 
       
    95 }	
       
    96 
       
    97 void DeviceUpdateData::onLaunchView()
       
    98 {
       
    99 	LaunchDeviceUpdatesUi();
       
   100 }
       
   101 
       
   102 CpBaseSettingView *DeviceUpdateData::createSettingView() const
       
   103 {
       
   104 		return 0;
       
   105 }