13 * |
13 * |
14 * Description: Device updates data for control panel |
14 * Description: Device updates data for control panel |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 #include <QtCore/QProcess> |
|
19 #include <QtCore/QDir> |
|
20 #include <QtCore/QLibraryInfo> |
19 #include <cpsettingformitemdata.h> |
21 #include <cpsettingformitemdata.h> |
20 #include <centralrepository.h> |
22 #include <apgtask.h> |
21 #include "deviceupdatesdata.h" |
23 #include "deviceupdatesdata.h" |
22 |
24 |
23 |
25 |
24 DeviceUpdateData::DeviceUpdateData(CpItemDataHelper &itemDataHelper, |
26 DeviceUpdateData::DeviceUpdateData(CpItemDataHelper &itemDataHelper, |
25 const QString &text /*= QString()*/, |
27 const QString &text /*= QString()*/, |
30 text, |
32 text, |
31 description, |
33 description, |
32 icon, |
34 icon, |
33 parent) |
35 parent) |
34 { |
36 { |
|
37 mproc = NULL; |
35 } |
38 } |
36 |
39 |
37 DeviceUpdateData::~DeviceUpdateData() |
40 DeviceUpdateData::~DeviceUpdateData() |
38 { |
41 { |
39 CloseDmUi(); |
42 CloseDeviceUpdatesUi(); |
|
43 if (mproc) |
|
44 { |
|
45 delete mproc; |
|
46 mproc = NULL; |
|
47 } |
40 } |
48 } |
41 |
49 |
42 // ----------------------------------------------------------------------------- |
50 // ----------------------------------------------------------------------------- |
43 // DeviceUpdateData::OpenDmAppL() |
51 // DeviceUpdateData::OpenDmAppL() |
44 // ----------------------------------------------------------------------------- |
52 // ----------------------------------------------------------------------------- |
45 // |
53 // |
46 void DeviceUpdateData::OpenDmAppL() |
54 void DeviceUpdateData::LaunchDeviceUpdatesUi() |
47 { |
55 { |
48 |
56 |
49 // Create DM UI Process |
57 RWsSession ws; |
50 RProcess rp; |
58 User::LeaveIfError( ws.Connect() ); |
51 TInt cpLaunch(1); |
59 CleanupClosePushL( ws ); |
52 CRepository *cenrep = CRepository::NewL(KUidSmlSyncApp); |
60 // Find the task with uid |
53 if(cenrep) |
61 TApaTaskList taskList(ws); |
54 { |
62 TApaTask task = taskList.FindApp( KUidSmlSyncApp ); |
55 cenrep->Set( KNsmlDmUILaunch, cpLaunch); |
63 if ( task.Exists() ) |
56 delete cenrep; |
64 { |
57 cenrep = NULL; |
65 task.BringToForeground(); |
58 } |
66 } |
59 TInt err = rp.Create(KDMUIProcess,KNullDesC); |
67 else |
60 |
68 { |
61 User::LeaveIfError(err); |
69 // Create DM UI Process |
62 |
70 if(!mproc) |
63 |
71 mproc = new QProcess(); |
64 rp.Resume(); // logon OK - start the server |
72 if(mproc->state() != QProcess::Running) |
65 |
73 { |
66 |
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 |
67 } |
82 } |
68 |
83 |
69 // --------------------------------------------------------------------------------------------- |
84 // --------------------------------------------------------------------------------------------- |
70 // DeviceUpdateData::CloseDmUi |
85 // DeviceUpdateData::CloseDmUi |
71 // closes DM Ui |
86 // closes DM Ui |
72 // --------------------------------------------------------------------------------------------- |
87 // --------------------------------------------------------------------------------------------- |
73 void DeviceUpdateData:: CloseDmUi() |
88 void DeviceUpdateData:: CloseDeviceUpdatesUi() |
74 { |
89 { |
75 // Create DM UI Process |
90 if(( mproc )&&(mproc->state() == QProcess::Running)) |
76 |
91 { |
77 TFullName processName; |
92 mproc->close(); |
78 TFindProcess process; |
93 } |
79 while ( process.Next( processName ) != KErrNotFound ) |
94 |
80 { |
|
81 if ( ( processName.Find( KDMUIName ) != KErrNotFound ) ) |
|
82 { |
|
83 RProcess rprocess; |
|
84 if (rprocess.Open(process, EOwnerProcess) == KErrNone) |
|
85 { |
|
86 rprocess.Terminate(KErrNone); |
|
87 rprocess.Close(); |
|
88 } |
|
89 } |
|
90 } |
|
91 } |
95 } |
92 |
96 |
93 void DeviceUpdateData::onLaunchView() |
97 void DeviceUpdateData::onLaunchView() |
94 { |
98 { |
95 TRAP_IGNORE( OpenDmAppL() ); |
99 LaunchDeviceUpdatesUi(); |
96 } |
100 } |
97 |
101 |
98 CpBaseSettingView *DeviceUpdateData::createSettingView() const |
102 CpBaseSettingView *DeviceUpdateData::createSettingView() const |
99 { |
103 { |
100 return 0; |
104 return 0; |
101 } |
105 } |
102 |
|
103 |
|