Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage into lp:qtcreator-plugin-ubuntu

Proposed by Benjamin Zeller
Status: Merged
Merged at revision: 134
Proposed branch: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 3275 lines (+2562/-68)
34 files modified
manifest.json (+15/-0)
share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml (+92/-0)
share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml (+42/-0)
share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml (+12/-0)
share/qtcreator/ubuntu/devicespage/DevicePage.qml (+105/-0)
share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml (+108/-0)
share/qtcreator/ubuntu/devicespage/EmulatorPage.qml (+150/-0)
share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml (+46/-0)
share/qtcreator/ubuntu/devicespage/LogPage.qml (+24/-0)
share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml (+46/-0)
share/qtcreator/ubuntu/devicespage/devicespage.qmlproject (+20/-0)
share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml (+52/-0)
share/qtcreator/ubuntu/devicespage/main.qml (+25/-0)
share/qtcreator/ubuntu/devicespage/test.qml# (+18/-0)
share/qtcreator/ubuntu/scripts/local_start_emulator (+0/-1)
src/ubuntu/resources.qrc (+2/-0)
src/ubuntu/ubuntu.pro (+27/-5)
src/ubuntu/ubuntuconstants.h (+4/-2)
src/ubuntu/ubuntudevice.cpp (+125/-20)
src/ubuntu/ubuntudevice.h (+9/-4)
src/ubuntu/ubuntudevicemode.cpp (+91/-9)
src/ubuntu/ubuntudevicemode.h (+42/-2)
src/ubuntu/ubuntudevicesmodel.cpp (+734/-0)
src/ubuntu/ubuntudevicesmodel.h (+169/-0)
src/ubuntu/ubuntuemulatormodel.cpp (+408/-0)
src/ubuntu/ubuntuemulatormodel.h (+102/-0)
src/ubuntu/ubuntukitmanager.cpp (+50/-1)
src/ubuntu/ubuntukitmanager.h (+3/-0)
src/ubuntu/ubuntumenu.cpp (+9/-4)
src/ubuntu/ubuntuplugin.cpp (+4/-1)
src/ubuntu/ubuntuprocess.cpp (+5/-6)
src/ubuntu/ubuntuprocess.h (+3/-2)
src/ubuntu/ubunturemoterunconfiguration.cpp (+20/-10)
src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp (+0/-1)
To merge this branch: bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage
Reviewer Review Type Date Requested Status
Zoltan Balogh Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+217232@code.launchpad.net

Commit message

- Added new QML based devices mode
- Reworked backend that handles devices and emulators and put
  it into QAbstractListModel derived classes to control them from QML
- Fixed a bug with starting applications on the device that don't use
   a launcher
- Switched to the RemoteLinux configuration widget , it provides better
  informations about the device state in the options dialog
- Easy creation of Kits for devices that are not assigned (Autocreate Kit)

Description of the change

New devices page

To post a comment you must log in.
149. By Benjamin Zeller

Removed user file (how did they get in there?)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

Is the welcome.qmlproject.user intentional?

Revision history for this message
Benjamin Zeller (zeller-benjamin) wrote :

> Is the welcome.qmlproject.user intentional?
Meh, of course not, also not the manifest and apparmor files

150. By Benjamin Zeller

Removed other not required files

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

what about the share/qtcreator/ubuntu/devicespage/test.qml file ?

151. By Benjamin Zeller

deleted more files

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.excludes'
=== added file 'manifest.json'
--- manifest.json 1970-01-01 00:00:00 +0000
+++ manifest.json 2014-04-27 13:29:17 +0000
@@ -0,0 +1,15 @@
1{
2 "architecture": "all",
3 "description": "description of qtcreator-plugin-ubuntu",
4 "framework": "ubuntu-sdk-13.10",
5 "hooks": {
6 "qtcreator-plugin-ubuntu": {
7 "apparmor": "qtcreator-plugin-ubuntu.json",
8 "desktop": "qtcreator-plugin-ubuntu.desktop"
9 }
10 },
11 "maintainer": "Benjamin Zeller <benjamin.zeller@canonical.com>",
12 "name": "com.ubuntu.developer.zeller-benjamin.qtcreator-plugin-ubuntu",
13 "title": "qtcreator-plugin-ubuntu",
14 "version": "0.1"
15}
0\ No newline at end of file16\ No newline at end of file
117
=== added directory 'share/qtcreator/ubuntu/devicespage'
=== added file 'share/qtcreator/ubuntu/devicespage/.excludes'
=== added file 'share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml'
--- share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,92 @@
1import QtQuick 2.0
2import QtQuick.Controls 1.0 as Controls
3import QtQuick.Layouts 1.0
4import Ubuntu.Components 0.1
5import Ubuntu.Components.ListItems 0.1 as ListItem
6
7
8RowLayout {
9 Controls.ScrollView {
10 Layout.fillHeight: true
11 Layout.minimumWidth: units.gu(78)
12 UbuntuListView {
13 model: VisualItemModel{
14 Label {
15 text: "Device Control"
16 fontSize: "large"
17 anchors.left: parent.left
18 }
19 ListItem.Standard {
20 text:"Clone time config from Host to Device"
21 control: Button{
22 text: "Execute"
23 enabled: !deviceItemView.deviceBusy
24 onClicked: devicesModel.triggerCloneTimeConfig(deviceId)
25 }
26 }
27 ListItem.Standard {
28 text:"Enable port forwarding"
29 control: Button{
30 text: "Execute"
31 enabled: !deviceItemView.deviceBusy
32 onClicked: devicesModel.triggerPortForwarding(deviceId)
33 }
34 }
35 ListItem.Standard {
36 text:"Setup public key authentication"
37 control: Button{
38 text: "Execute"
39 enabled: !deviceItemView.deviceBusy
40 onClicked: devicesModel.triggerSSHSetup(deviceId)
41 }
42 }
43 ListItem.Standard {
44 text:"Open SSH connection to the device"
45 control: Button{
46 text: "Execute"
47 enabled: !deviceItemView.deviceBusy
48 onClicked: devicesModel.triggerSSHConnection(deviceId)
49 }
50 }
51 ListItem.Divider{}
52 Label {
53 text: "Device Mode"
54 fontSize: "large"
55 }
56 ListItem.Standard {
57 text:"Reboot"
58 control: Button{
59 text: "Execute"
60 enabled: !deviceItemView.deviceBusy
61 onClicked: devicesModel.triggerReboot(deviceId)
62 }
63 }
64 ListItem.Standard {
65 text:"Reboot to bootloader"
66 control: Button{
67 text: "Execute"
68 enabled: !deviceItemView.deviceBusy
69 onClicked: devicesModel.triggerRebootBootloader(deviceId)
70 }
71 }
72 ListItem.Standard {
73 text:"Reboot to recovery"
74 control: Button{
75 text: "Execute"
76 enabled: !deviceItemView.deviceBusy
77 onClicked: devicesModel.triggerRebootRecovery(deviceId)
78 }
79 }
80 ListItem.Standard {
81 text:"Shutdown"
82 control: Button{
83 text: "Execute"
84 enabled: !deviceItemView.deviceBusy
85 onClicked: devicesModel.triggerShutdown(deviceId)
86 }
87 }
88 }
89 }
90 }
91}
92
093
=== added file 'share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml'
--- share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,42 @@
1import QtQuick 2.0
2import QtQuick.Controls 1.0 as Controls
3import QtQuick.Layouts 1.0
4import Ubuntu.Components 0.1
5import Ubuntu.Components.ListItems 0.1 as ListItem
6
7RowLayout {
8 spacing: units.gu(1)
9 Controls.ScrollView {
10 Layout.fillHeight: true
11 Layout.minimumWidth: units.gu(78)
12
13 ColumnLayout {
14 Layout.fillWidth: true
15 Label {
16 text: "Platform development"
17 fontSize: "large"
18 anchors.left: parent.left
19 Layout.fillWidth: true
20 }
21 Label {
22 text: "The connected device can be turned to be a native development environment.\n Use this feature with care and only if you know what are you doing."
23 }
24 FeatureStateItem {
25 text: "Has writeable image"
26 input: hasWriteableImage
27 inputRole: "hasWriteableImage"
28 height: 24
29 width: 300
30 checkable: !deviceItemView.deviceBusy
31 }
32 FeatureStateItem {
33 text: "Has device developer tools"
34 input: hasDeveloperTools
35 inputRole: "hasDeveloperTools"
36 height: 24
37 width: 300
38 checkable: !deviceItemView.deviceBusy
39 }
40 }
41 }
42}
043
=== added file 'share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml'
--- share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,12 @@
1import QtQuick 2.0
2import QtQuick.Controls 1.0 as Controls
3import QtQuick.Layouts 1.0
4import Ubuntu.Components 0.1
5import Ubuntu.Components.ListItems 0.1 as ListItem
6
7
8Controls.TextArea {
9 readOnly: true
10 text: deviceLog
11 textFormat: TextEdit.AutoText
12}
013
=== added file 'share/qtcreator/ubuntu/devicespage/DevicePage.qml'
--- share/qtcreator/ubuntu/devicespage/DevicePage.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/DevicePage.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,105 @@
1import QtQuick 2.0
2import QtQuick.Layouts 1.0
3import QtQuick.Controls 1.0 as Controls
4
5import Ubuntu.Components 0.1
6import Ubuntu.Components.ListItems 0.1 as ListItem
7import Ubuntu.DevicesModel 0.1
8
9Page {
10 flickable: null
11
12 Controls.SplitView {
13 orientation: Qt.Horizontal
14 anchors.fill: parent
15 Controls.SplitView {
16 orientation: Qt.Vertical
17 width: 200
18 Layout.minimumWidth: 200
19 Layout.maximumWidth: 400
20
21 Controls.ScrollView {
22 Layout.fillHeight: true
23 UbuntuListView {
24 id: devicesList
25 objectName: "devicesList"
26 model: devicesModel
27 currentIndex: 0
28 delegate: ListItem.Standard {
29 id: delegate
30 text: display
31 selected: devicesList.currentIndex == index
32 onClicked: devicesList.currentIndex = index
33 }
34 onCurrentIndexChanged: deviceMode.deviceSelected(currentIndex)
35 }
36 }
37 Controls.ToolBar {
38 Layout.fillWidth: true
39 Layout.minimumHeight: units.gu(5)
40 Layout.maximumHeight: units.gu(5)
41 Row{
42 anchors.fill: parent
43 spacing: units.gu(2)
44 Controls.ToolButton {
45 text: i18n.tr("Refresh devices")
46 tooltip: text
47 iconSource: "qrc:/ubuntu/images/view-refresh.png"
48 onClicked: devicesModel.refresh()
49 }
50 }
51 }
52 }
53 Item {
54 id: centerItem
55 Layout.minimumWidth: 400
56 Layout.fillWidth: true
57 property int currentIndex: devicesList.currentIndex
58 Repeater {
59 model: devicesModel
60 anchors.fill: parent
61 Rectangle{
62 id: deviceItemView
63 property bool deviceBusy: (detectionState != States.Done && detectionState != States.NotStarted)
64 anchors.fill: parent
65 anchors.margins: 12
66
67 color: Qt.rgba(0.0, 0.0, 0.0, 0.01)
68 visible: index == devicesList.currentIndex
69
70 Controls.TabView {
71 id: pagesTabView
72 anchors.fill: parent
73 visible: connectionState === States.DeviceReadyToUse || connectionState === States.DeviceConnected
74 Controls.Tab {
75 title: "Device"
76 DeviceStatusTab{
77 }
78 }
79 Controls.Tab {
80 title: "Advanced"
81 DeviceAdvancedTab{
82 }
83 }
84 Controls.Tab {
85 title: "Builder"
86 DeviceBuilderTab{
87 }
88 }
89 Controls.Tab {
90 title: "Log"
91 DeviceLogTab{}
92 }
93 }
94 Label {
95 visible: !pagesTabView.visible
96 anchors.centerIn: parent
97 text: "The device is currently not connected"
98 fontSize: "large"
99 }
100 }
101 }
102 }
103 }
104}
105
0106
=== added file 'share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml'
--- share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,108 @@
1import QtQuick 2.0
2import QtQuick.Controls 1.0 as Controls
3import QtQuick.Layouts 1.0
4import Ubuntu.Components 0.1
5import Ubuntu.Components.ListItems 0.1 as ListItem
6import Ubuntu.DevicesModel 0.1
7
8RowLayout {
9 Controls.ScrollView {
10 id: scrollView
11 Layout.fillHeight: true
12 Layout.minimumWidth: units.gu(78)
13 ColumnLayout {
14 width: scrollView.width
15 Row {
16 Label {
17 text:"Device Status: "+detectionStateString
18 fontSize: "large"
19 }
20 Item {
21 width: units.gu(2)
22 height: parent.height
23 }
24 ActivityIndicator{
25 visible: deviceItemView.deviceBusy
26 running: true
27 }
28 }
29 ListItem.SingleValue {
30 text:i18n.tr("Serial ID")
31 Layout.fillWidth: true
32 value: serial
33 }
34 ListItem.SingleValue {
35 text:i18n.tr("Device")
36 Layout.fillWidth: true
37 value: deviceInfo
38 }
39 ListItem.SingleValue {
40 text:i18n.tr("Model")
41 Layout.fillWidth: true
42 value: modelInfo
43 }
44 ListItem.SingleValue {
45 text:i18n.tr("Product")
46 Layout.fillWidth: true
47 value: productInfo
48 }
49 FeatureStateItem {
50 text: "Has network connection"
51 input: hasNetworkConnection
52 inputRole: "hasNetworkConnection"
53 Layout.fillWidth: true
54 checkable: hasNetworkConnection == States.NotAvailable && !deviceItemView.deviceBusy
55 }
56 FeatureStateItem {
57 text: "Has devloper mode enabled"
58 input: developerModeEnabled
59 inputRole: "developerModeEnabled"
60 Layout.fillWidth: true
61 checkable: !deviceItemView.deviceBusy
62 }
63 ListItem.Divider{}
64
65 Label {
66 text: "Device Kits"
67 fontSize: "large"
68 anchors.left: parent.left
69 }
70 Repeater {
71 model: kits
72 delegate: ListItem.Standard {
73 text: modelData.displayName
74 Layout.fillWidth: true
75 control: Button{
76 text: "Remove"
77 enabled: !deviceItemView.deviceBusy
78 onClicked: devicesModel.triggerKitRemove(deviceId,modelData.id)
79 }
80 }
81 }
82 Item {
83 clip: true
84 visible: kits.length === 0
85 Layout.minimumHeight: units.gu(25)
86 Layout.fillWidth: true
87 Label {
88 id:label
89 anchors.centerIn: parent
90 anchors.bottom: button.top
91 fontSize: "large"
92 text: "There is currently no Kit defined for your device.\n In order to use the device in your Projects,\n you can either add a existing Kit "
93 +"\nor let Qt Creator autocreate one for you."
94 }
95 Button {
96 id: button
97 anchors.left: label.left
98 anchors.right: label.right
99 anchors.top: label.bottom
100 anchors.topMargin: units.gu(2)
101 text: "Autocreate"
102 enabled: !deviceItemView.deviceBusy
103 onClicked: devicesModel.triggerKitAutocreate(deviceId)
104 }
105 }
106 }
107 }
108}
0109
=== added file 'share/qtcreator/ubuntu/devicespage/EmulatorPage.qml'
--- share/qtcreator/ubuntu/devicespage/EmulatorPage.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/EmulatorPage.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,150 @@
1import QtQuick 2.0
2import QtQuick.Layouts 1.0
3import QtQuick.Controls 1.0 as Controls
4
5import Ubuntu.Components 0.1
6import Ubuntu.Components.ListItems 0.1 as ListItem
7import Ubuntu.Components.Popups 0.1
8
9Page {
10 flickable: null
11 id: myPage
12
13 Item {
14 anchors.fill: parent
15 visible: emulatorModel.busy
16
17 Column {
18 anchors.centerIn: parent
19 spacing: units.gu(1)
20
21 ActivityIndicator{
22 anchors.horizontalCenter: parent.horizontalCenter
23 running: emulatorModel.busy
24 }
25 Label {
26 text: i18n.tr("There is currently a process running in the background, please check the logs for details")
27 fontSize: "large"
28 anchors.left: parent.left
29 }
30 Button {
31 visible: emulatorModel.cancellable
32 anchors.horizontalCenter: parent.horizontalCenter
33 text: "cancel"
34 onClicked: emulatorModel.cancel()
35 }
36 }
37 }
38
39 Controls.SplitView {
40 orientation: Qt.Horizontal
41 anchors.fill: parent
42 visible: !emulatorModel.busy
43
44 Controls.SplitView {
45 orientation: Qt.Vertical
46 width: 200
47 Layout.minimumWidth: 200
48 Layout.maximumWidth: 400
49
50 Controls.ScrollView {
51 Layout.fillHeight: true
52 Layout.fillWidth: true
53
54 UbuntuListView {
55 id: emulatorList
56 objectName: "emulatorList"
57 model: emulatorModel
58 currentIndex: 0
59 delegate: ListItem.Standard {
60 id: delegate
61 text: display
62 selected: emulatorList.currentIndex == index
63 onClicked: emulatorList.currentIndex = index
64 }
65 }
66 }
67
68 Controls.ToolBar {
69 Layout.fillWidth: true
70 Layout.minimumHeight: units.gu(5)
71 Layout.maximumHeight: units.gu(5)
72 Row{
73 anchors.fill: parent
74 spacing: units.gu(2)
75 Controls.ToolButton {
76 text: i18n.tr("Add Emulator")
77 tooltip: text
78 iconSource: "qrc:/ubuntu/images/list-add.png"
79 onClicked: PopupUtils.open(resourceRoot+"/NewEmulatorDialog.qml",myPage);
80 }
81 Controls.ToolButton {
82 text: i18n.tr("Refresh emulators")
83 tooltip: text
84 iconSource: "qrc:/ubuntu/images/view-refresh.png"
85 onClicked: emulatorModel.findEmulatorImages()
86 }
87 }
88 }
89 }
90 Item {
91 id: centerItem
92 Layout.minimumWidth: units.gu(78)
93 Layout.fillWidth: true
94 property int currentIndex: emulatorList.currentIndex
95 Repeater {
96 model: emulatorModel
97 anchors.fill: parent
98 Rectangle{
99 id: deviceItemView
100 anchors.fill: parent
101 anchors.margins: 12
102
103 color: Qt.rgba(0.0, 0.0, 0.0, 0.01)
104 visible: index == emulatorList.currentIndex && !emulatorModel.busy
105
106 UbuntuListView {
107 anchors.left: parent.left
108 anchors.top: parent.top
109 height: units.gu(50)
110 width: units.gu(50)
111 model: VisualItemModel {
112 ListItem.SingleValue {
113 text: i18n.tr("Ubuntu version")
114 value: ubuntuVersion
115 }
116 ListItem.SingleValue {
117 text: i18n.tr("Device version")
118 value: deviceVersion
119 }
120 ListItem.SingleValue {
121 text: i18n.tr("Image version")
122 value: imageVersion
123 }
124 ListItem.SingleControl {
125 control: Button {
126 text: "Start emulator"
127 onClicked: emulatorModel.startEmulator(display)
128 }
129 }
130 /*
131 ListItem.SingleControl {
132 control: Button {
133 text: "Delete emulator"
134 }
135 }
136 */
137 }
138 }
139
140 Label {
141 visible: emulatorModel.busy
142 anchors.centerIn: parent
143 text: emulatorModel.state
144 fontSize: "large"
145 }
146 }
147 }
148 }
149 }
150}
0151
=== added file 'share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml'
--- share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,46 @@
1import QtQuick 2.0
2import QtQuick.Layouts 1.0
3import Ubuntu.Components 0.1
4import Ubuntu.Components.ListItems 0.1 as ListItem
5import Ubuntu.DevicesModel 0.1
6
7ListItem.Standard {
8 id: item
9 property var input: null
10 property string inputRole
11 property alias checkable: switchbox.enabled
12
13 onInputChanged: {
14 console.log("INPUT CHANGED !!!!!"+input);
15 if(input == States.Available)
16 switchbox.checked = true;
17 else
18 switchbox.checked = false;
19 }
20
21 selected: false
22 control: Row {
23 ActivityIndicator {
24 visible: input === States.Detecting
25 running: true
26 }
27 Switch {
28 id: switchbox
29 visible: input !== States.Detecting
30 checked: input === States.Available
31 enabled: checkable
32 onCheckedChanged: {
33 console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!Checked changed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
34
35 if (checked && input == States.NotAvailable) {
36 devicesModel.set(index,inputRole,true);
37 checked = true;
38 }
39 else if ((!checked) && input == States.Available) {
40 devicesModel.set(index,inputRole,false);
41 checked = false;
42 }
43 }
44 }
45 }
46}
047
=== added file 'share/qtcreator/ubuntu/devicespage/LogPage.qml'
--- share/qtcreator/ubuntu/devicespage/LogPage.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/LogPage.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,24 @@
1import QtQuick 2.0
2import QtQuick.Layouts 1.0
3import QtQuick.Controls 1.0 as Controls
4
5import Ubuntu.Components 0.1
6import Ubuntu.Components.ListItems 0.1 as ListItem
7import Ubuntu.Components.Popups 0.1
8
9Page {
10 flickable: null
11
12 Controls.TextArea {
13 id: logTextArea
14 anchors.fill: parent
15 readOnly: true
16 textFormat: TextEdit.AutoText
17 Component.onCompleted: {
18 deviceMode.appendText.connect(appendToLog);
19 }
20 function appendToLog (txt) {
21 logTextArea.append(txt);
22 }
23 }
24}
025
=== added file 'share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml'
--- share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,46 @@
1import QtQuick 2.0
2import Ubuntu.Components 0.1
3import Ubuntu.Components.Popups 0.1
4
5Dialog {
6 id: dialogue
7 title: i18n.tr("Create emulator")
8 text: i18n.tr("Please select a name for the emulator")
9 modal: true
10 TextField {
11 id: inputName
12 placeholderText: i18n.tr("Emulator name")
13 property string lastError
14 property bool hasError
15 onTextChanged: validate()
16 Component.onCompleted: validate()
17 function validate() {
18 var result = emulatorModel.validateEmulatorName(text);
19 hasError = !result.valid;
20 lastError = result.error;
21 }
22 }
23 Label {
24 horizontalAlignment: Text.AlignHCenter
25 text: inputName.lastError
26 color: "red"
27 visible: inputName.hasError
28 }
29
30 Button {
31 text: "cancel"
32 onClicked: PopupUtils.close(dialogue)
33 }
34 Button {
35 text: "create"
36 color: UbuntuColors.orange
37 enabled: !inputName.hasError
38 onClicked: {
39 if(inputName.hasError)
40 return;
41 emulatorModel.createEmulatorImage(inputName.text);
42 PopupUtils.close(dialogue);
43 }
44 }
45}
46
047
=== added file 'share/qtcreator/ubuntu/devicespage/devicespage.qmlproject'
--- share/qtcreator/ubuntu/devicespage/devicespage.qmlproject 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/devicespage.qmlproject 2014-04-27 13:29:17 +0000
@@ -0,0 +1,20 @@
1/* File generated by Qt Creator, version 2.7.0 */
2
3import QmlProject 1.1
4
5Project {
6 mainFile: "devicespage.qml"
7
8 /* Include .qml, .js, and image files from current directory and subdirectories */
9 QmlFiles {
10 directory: "."
11 }
12 JavaScriptFiles {
13 directory: "."
14 }
15 ImageFiles {
16 directory: "."
17 }
18 /* List of plugin directories passed to QML runtime */
19 // importPaths: [ "../exampleplugin" ]
20}
021
=== added directory 'share/qtcreator/ubuntu/devicespage/dummydata'
=== added file 'share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml'
--- share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,52 @@
1import QtQuick 2.0
2
3ListModel {
4 id: devicesModel
5 ListElement {
6 display: "Ubuntu Device Nexus S"
7 isEmulator: false
8 connectionState: 1
9 connectionStateString: "Connected"
10 developerModeEnabled: 0
11 hasNetworkConnection: 0
12 hasWriteableImage: 1
13 hasDeveloperTools: 2
14 kits: [
15 ListElement{
16 kitId: "1"
17 displayName: "Nexus S UbuntuSDK for armhf (GCC ubuntu-sdk-14.04-trusty)"
18 }
19 ]
20 deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>"
21 }
22 ListElement {
23 display: "Ubuntu Emulator"
24 isEmulator: true
25 connectionState: 1
26 connectionStateString: "Connected"
27 developerModeEnabled: 1
28 hasNetworkConnection: 1
29 hasWriteableImage: 1
30 hasDeveloperTools: 1
31 kits: [
32 ]
33 deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>"
34 }
35 ListElement {
36 display: "Ubuntu Device Tablet"
37 isEmulator: false
38 connectionState: 0
39 connectionStateString: "Disconnected"
40 developerModeEnabled: 0
41 hasNetworkConnection: 0
42 hasWriteableImage: 0
43 hasDeveloperTools: 0
44 kits: [
45 ListElement{
46 kitId: "1"
47 displayName: "Tablet UbuntuSDK for armhf (GCC ubuntu-sdk-14.04-trusty)"
48 }
49 ]
50 deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>"
51 }
52}
053
=== added file 'share/qtcreator/ubuntu/devicespage/main.qml'
--- share/qtcreator/ubuntu/devicespage/main.qml 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/main.qml 2014-04-27 13:29:17 +0000
@@ -0,0 +1,25 @@
1import QtQuick 2.0
2import Ubuntu.Components 0.1
3
4
5MainView {
6 id: modeRoot
7 width: 860
8 height: 548
9
10 Tabs {
11 Tab {
12 title: "Ubuntu Devices"
13 page: DevicePage{}
14 }
15 Tab {
16 title: "Emulators"
17 page: EmulatorPage{}
18 }
19 Tab {
20 title: "Log"
21 page: LogPage{}
22 }
23 }
24}
25
026
=== added file 'share/qtcreator/ubuntu/devicespage/test.qml#'
--- share/qtcreator/ubuntu/devicespage/test.qml# 1970-01-01 00:00:00 +0000
+++ share/qtcreator/ubuntu/devicespage/test.qml# 2014-04-27 13:29:17 +0000
@@ -0,0 +1,18 @@
1import QtQuick 2.0
2import QtQuick.Layouts 1.0
3import Ubuntu.Components 0.1
4
5MainView {
6 height: 640
7 width: 480
8
9 Page {
10 title: "Hello World"
11 ActivityIndicator {
12 anchors.fill: parent
13 visible: true
14 running: true
15 }
16 }
17
18}
019
=== modified file 'share/qtcreator/ubuntu/scripts/local_start_emulator'
--- share/qtcreator/ubuntu/scripts/local_start_emulator 2014-02-05 12:13:31 +0000
+++ share/qtcreator/ubuntu/scripts/local_start_emulator 2014-04-27 13:29:17 +0000
@@ -19,5 +19,4 @@
19ubuntu-emulator run ${EMULATOR} &19ubuntu-emulator run ${EMULATOR} &
20set +e20set +e
21adb wait-for-device21adb wait-for-device
22adb forward tcp:9999 tcp:22
23set -e22set -e
2423
=== added file 'share/qtcreator/ubuntu/welcome/.excludes'
=== added file 'src/ubuntu/images/list-add.png'
25Binary files src/ubuntu/images/list-add.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-add.png 2014-04-27 13:29:17 +0000 differ24Binary files src/ubuntu/images/list-add.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-add.png 2014-04-27 13:29:17 +0000 differ
=== added file 'src/ubuntu/images/list-remove.png'
26Binary files src/ubuntu/images/list-remove.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-remove.png 2014-04-27 13:29:17 +0000 differ25Binary files src/ubuntu/images/list-remove.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-remove.png 2014-04-27 13:29:17 +0000 differ
=== added file 'src/ubuntu/images/view-refresh.png'
27Binary files src/ubuntu/images/view-refresh.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/view-refresh.png 2014-04-27 13:29:17 +0000 differ26Binary files src/ubuntu/images/view-refresh.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/view-refresh.png 2014-04-27 13:29:17 +0000 differ
=== modified file 'src/ubuntu/resources.qrc'
--- src/ubuntu/resources.qrc 2013-09-04 15:30:00 +0000
+++ src/ubuntu/resources.qrc 2014-04-27 13:29:17 +0000
@@ -14,5 +14,7 @@
14 <file>manifest.json.template</file>14 <file>manifest.json.template</file>
15 <file>myapp.json.template</file>15 <file>myapp.json.template</file>
16 <file>manifestlib.js</file>16 <file>manifestlib.js</file>
17 <file>images/view-refresh.png</file>
18 <file>images/list-add.png</file>
17 </qresource>19 </qresource>
18</RCC>20</RCC>
1921
=== modified file 'src/ubuntu/ubuntu.pro'
--- src/ubuntu/ubuntu.pro 2014-04-03 12:28:13 +0000
+++ src/ubuntu/ubuntu.pro 2014-04-27 13:29:17 +0000
@@ -26,11 +26,29 @@
26RESOURCES += \26RESOURCES += \
27 resources.qrc27 resources.qrc
2828
29#QML files
30QML_ROOT="$${PWD}/../../share/qtcreator/ubuntu"
31QML_FILES += \
32 $$QML_ROOT/welcome/welcome.qml \
33 $$QML_ROOT/welcome/Link.qml \
34 $$QML_ROOT/welcome/NewsBox.qml\
35 $$QML_ROOT/devicespage/main.qml \
36 $$QML_ROOT/devicespage/DeviceAdvancedTab.qml \
37 $$QML_ROOT/devicespage/DeviceBuilderTab.qml \
38 $$QML_ROOT/devicespage/DeviceLogTab.qml \
39 $$QML_ROOT/devicespage/DevicePage.qml \
40 $$QML_ROOT/devicespage/DeviceStatusTab.qml \
41 $$QML_ROOT/devicespage/EmulatorPage.qml \
42 $$QML_ROOT/devicespage/FeatureStateItem.qml \
43 $$QML_ROOT/devicespage/NewEmulatorDialog.qml \
44 $$QML_ROOT/devicespage/LogPage.qml
45
29OTHER_FILES += \46OTHER_FILES += \
30 UbuntuProject.mimetypes.xml \47 UbuntuProject.mimetypes.xml \
31 manifest.json.template \48 manifest.json.template \
32 myapp.json.template \49 myapp.json.template \
33 manifestlib.js50 manifestlib.js \
51 $$QML_FILES
3452
35SOURCES += \53SOURCES += \
36 ubuntuplugin.cpp \54 ubuntuplugin.cpp \
@@ -55,7 +73,7 @@
55 ubuntuclickmanifest.cpp \73 ubuntuclickmanifest.cpp \
56 ubuntuwebmode.cpp \74 ubuntuwebmode.cpp \
57 ubuntupastebinmode.cpp \75 ubuntupastebinmode.cpp \
58 ubuntudeviceswidget.cpp \76 #ubuntudeviceswidget.cpp \
59 ubuntudevicemode.cpp \77 ubuntudevicemode.cpp \
60 ubuntuprocess.cpp \78 ubuntuprocess.cpp \
61 ubuntudevicenotifier.cpp \79 ubuntudevicenotifier.cpp \
@@ -88,7 +106,9 @@
88 ubunturemotedeployconfiguration.cpp \106 ubunturemotedeployconfiguration.cpp \
89 ubuntulocalrunconfigurationfactory.cpp \107 ubuntulocalrunconfigurationfactory.cpp \
90 ubunturemoteruncontrolfactory.cpp \108 ubunturemoteruncontrolfactory.cpp \
91 ubuntulocalrunconfiguration.cpp109 ubuntulocalrunconfiguration.cpp \
110 ubuntudevicesmodel.cpp \
111 ubuntuemulatormodel.cpp
92112
93HEADERS += \113HEADERS += \
94 ubuntuplugin.h \114 ubuntuplugin.h \
@@ -117,7 +137,7 @@
117 ubuntuwebmode.h \137 ubuntuwebmode.h \
118 ubuntupastebinmode.h \138 ubuntupastebinmode.h \
119 ubuntudevicemode.h \139 ubuntudevicemode.h \
120 ubuntudeviceswidget.h \140 #ubuntudeviceswidget.h \
121 ubuntuprocess.h \141 ubuntuprocess.h \
122 ubuntudevicenotifier.h \142 ubuntudevicenotifier.h \
123 ubuntusettingspage.h \143 ubuntusettingspage.h \
@@ -149,5 +169,7 @@
149 ubunturemotedeployconfiguration.h \169 ubunturemotedeployconfiguration.h \
150 ubuntulocalrunconfigurationfactory.h \170 ubuntulocalrunconfigurationfactory.h \
151 ubunturemoteruncontrolfactory.h \171 ubunturemoteruncontrolfactory.h \
152 ubuntulocalrunconfiguration.h172 ubuntulocalrunconfiguration.h \
173 ubuntudevicesmodel.h \
174 ubuntuemulatormodel.h
153175
154176
=== modified file 'src/ubuntu/ubuntuconstants.h'
--- src/ubuntu/ubuntuconstants.h 2014-04-10 15:59:28 +0000
+++ src/ubuntu/ubuntuconstants.h 2014-04-27 13:29:17 +0000
@@ -120,7 +120,7 @@
120const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR[] = "Creating new emulator instance.";120const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR[] = "Creating new emulator instance.";
121const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT[] = "%0/local_create_emulator %1 %2";121const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT[] = "%0/local_create_emulator %1 %2";
122const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR[] = "Starting the selected emulator.";122const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR[] = "Starting the selected emulator.";
123const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT[] = "%0/local_start_emulator %1";123const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT[] = "%0/local_start_emulator";
124124
125125
126const char UBUNTUDEVICESWIDGET_STARTSSHSERVICE[] = "Start ssh service on device..";126const char UBUNTUDEVICESWIDGET_STARTSSHSERVICE[] = "Start ssh service on device..";
@@ -213,7 +213,7 @@
213const char UBUNTUDEVICESWIDGET_DETECTOPENSSH[] = "Detecting if openssh-server is installed..";213const char UBUNTUDEVICESWIDGET_DETECTOPENSSH[] = "Detecting if openssh-server is installed..";
214const char UBUNTUDEVICESWIDGET_DETECTOPENSSH_SCRIPT[] = "%0/openssh_version %1";214const char UBUNTUDEVICESWIDGET_DETECTOPENSSH_SCRIPT[] = "%0/openssh_version %1";
215const char UBUNTUDEVICESWIDGET_DETECTDEVICES[] = "Detecting device..";215const char UBUNTUDEVICESWIDGET_DETECTDEVICES[] = "Detecting device..";
216const char UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT[] = "%0/device_search %1";216const char UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT[] = "%0/device_search";
217const char UBUNTUDEVICESWIDGET_SSHCONNECT_SCRIPT[] = "%0/openssh_connect";217const char UBUNTUDEVICESWIDGET_SSHCONNECT_SCRIPT[] = "%0/openssh_connect";
218const char UBUNTUDEVICESWIDGET_SSHCONNECT[] = "Opening ssh connection to device";218const char UBUNTUDEVICESWIDGET_SSHCONNECT[] = "Opening ssh connection to device";
219219
@@ -241,6 +241,8 @@
241#endif241#endif
242242
243const QString UBUNTU_WELCOMESCREEN_QML = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/welcome/welcome.qml");243const QString UBUNTU_WELCOMESCREEN_QML = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/welcome/welcome.qml");
244const QString UBUNTU_DEVICESCREEN_QML = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/devicespage/main.qml");
245const QString UBUNTU_DEVICESCREEN_ROOT = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/devicespage");
244const QString UBUNTU_TEMPLATESPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/templates/wizards/ubuntu/");246const QString UBUNTU_TEMPLATESPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/templates/wizards/ubuntu/");
245const QString UBUNTU_MENUPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/");247const QString UBUNTU_MENUPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/");
246const QString UBUNTU_SHAREPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/");248const QString UBUNTU_SHAREPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/");
247249
=== modified file 'src/ubuntu/ubuntudevice.cpp'
--- src/ubuntu/ubuntudevice.cpp 2014-04-10 19:03:23 +0000
+++ src/ubuntu/ubuntudevice.cpp 2014-04-27 13:29:17 +0000
@@ -24,6 +24,7 @@
24#include "localportsmanager.h"24#include "localportsmanager.h"
2525
26#include <projectexplorer/devicesupport/devicemanager.h>26#include <projectexplorer/devicesupport/devicemanager.h>
27#include <remotelinux/genericlinuxdeviceconfigurationwidget.h>
27#include <coreplugin/messagemanager.h>28#include <coreplugin/messagemanager.h>
28#include <ssh/sshconnection.h>29#include <ssh/sshconnection.h>
29#include <utils/portlist.h>30#include <utils/portlist.h>
@@ -32,11 +33,15 @@
32#include <QCoreApplication>33#include <QCoreApplication>
33#include <QDir>34#include <QDir>
34#include <QDebug>35#include <QDebug>
36#include <QRegularExpression>
3537
36namespace Ubuntu {38namespace Ubuntu {
37namespace Internal {39namespace Internal {
3840
39const QLatin1String DEVICE_INFO_KEY("UbuntuDevice.InfoString");41const QLatin1String DEVICE_INFO_KEY("UbuntuDevice.InfoString");
42const QLatin1String DEVICE_PRODUCT_INFO_KEY("UbuntuDevice.Product.InfoString");
43const QLatin1String DEVICE_MODEL_INFO_KEY("UbuntuDevice.Model.InfoString");
44const QLatin1String DEVICE_DEVICE_INFO_KEY("UbuntuDevice.Device.InfoString");
4045
41/*!46/*!
42 * \class UbuntuDeviceHelper47 * \class UbuntuDeviceHelper
@@ -125,8 +130,8 @@
125 m_clonedNwCount = 0;130 m_clonedNwCount = 0;
126 if(m_dev->m_hasNetworkConnection != UbuntuDevice::Available) {131 if(m_dev->m_hasNetworkConnection != UbuntuDevice::Available) {
127 m_dev->m_hasNetworkConnection = UbuntuDevice::Available;132 m_dev->m_hasNetworkConnection = UbuntuDevice::Available;
128 emit featureDetected();
129 }133 }
134 emit featureDetected();
130 detectOpenSsh();135 detectOpenSsh();
131136
132 } else {137 } else {
@@ -137,9 +142,9 @@
137 //we tried to enable network and failed142 //we tried to enable network and failed
138 if(m_dev->m_hasNetworkConnection != UbuntuDevice::NotAvailable) {143 if(m_dev->m_hasNetworkConnection != UbuntuDevice::NotAvailable) {
139 m_dev->m_hasNetworkConnection = UbuntuDevice::NotAvailable;144 m_dev->m_hasNetworkConnection = UbuntuDevice::NotAvailable;
140 emit featureDetected();
141 emit deviceNeedsSetup();
142 }145 }
146 emit featureDetected();
147 emit deviceNeedsSetup();
143 //detect other features148 //detect other features
144 detectOpenSsh();149 detectOpenSsh();
145 }150 }
@@ -157,8 +162,8 @@
157162
158 if(m_dev->m_hasOpenSSHServer != UbuntuDevice::Available) {163 if(m_dev->m_hasOpenSSHServer != UbuntuDevice::Available) {
159 m_dev->m_hasOpenSSHServer = UbuntuDevice::Available;164 m_dev->m_hasOpenSSHServer = UbuntuDevice::Available;
160 emit featureDetected();
161 }165 }
166 emit featureDetected();
162167
163 ProjectExplorer::DeviceManager::instance()->setDeviceState(m_dev->id(),ProjectExplorer::IDevice::DeviceConnected);168 ProjectExplorer::DeviceManager::instance()->setDeviceState(m_dev->id(),ProjectExplorer::IDevice::DeviceConnected);
164 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_IS_INSTALLED).arg(m_reply.trimmed()));169 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_IS_INSTALLED).arg(m_reply.trimmed()));
@@ -170,9 +175,9 @@
170175
171 if(m_dev->m_hasOpenSSHServer != UbuntuDevice::NotAvailable) {176 if(m_dev->m_hasOpenSSHServer != UbuntuDevice::NotAvailable) {
172 m_dev->m_hasOpenSSHServer = UbuntuDevice::NotAvailable;177 m_dev->m_hasOpenSSHServer = UbuntuDevice::NotAvailable;
173 emit featureDetected();
174 emit deviceNeedsSetup();
175 }178 }
179 emit featureDetected();
180 emit deviceNeedsSetup();
176181
177 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_NOT_INSTALLED));182 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_NOT_INSTALLED));
178183
@@ -242,7 +247,6 @@
242 m_dev->m_hasDeveloperTools = UbuntuDevice::Available;247 m_dev->m_hasDeveloperTools = UbuntuDevice::Available;
243 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_DEVELOPERTOOLS_INSTALLED));248 endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_DEVELOPERTOOLS_INSTALLED));
244 }249 }
245
246 emit featureDetected();250 emit featureDetected();
247 break;251 break;
248 }252 }
@@ -297,6 +301,10 @@
297void UbuntuDeviceHelper::detectOpenSsh()301void UbuntuDeviceHelper::detectOpenSsh()
298{302{
299 setProcessState(UbuntuDevice::DetectOpenSSH);303 setProcessState(UbuntuDevice::DetectOpenSSH);
304
305 m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown;
306 emit featureDetected();
307
300 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTOPENSSH));308 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTOPENSSH));
301309
302 stopProcess();310 stopProcess();
@@ -323,6 +331,9 @@
323 setProcessState(UbuntuDevice::InstallOpenSSH);331 setProcessState(UbuntuDevice::InstallOpenSSH);
324 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL));332 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL));
325333
334 m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown;
335 emit featureDetected();
336
326 stopProcess();337 stopProcess();
327338
328 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL_SCRIPT)339 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL_SCRIPT)
@@ -335,6 +346,9 @@
335 setProcessState(UbuntuDevice::RemoveOpenSSH);346 setProcessState(UbuntuDevice::RemoveOpenSSH);
336 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE));347 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE));
337348
349 m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown;
350 emit featureDetected();
351
338 stopProcess();352 stopProcess();
339353
340 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE_SCRIPT)354 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE_SCRIPT)
@@ -348,6 +362,10 @@
348 // adb shell nmcli dev list iface <intfc> | grep IP4.ADDRESS362 // adb shell nmcli dev list iface <intfc> | grep IP4.ADDRESS
349 // to find out the devices ip address363 // to find out the devices ip address
350 setProcessState(UbuntuDevice::DetectNetworkConnection);364 setProcessState(UbuntuDevice::DetectNetworkConnection);
365
366 m_dev->m_hasNetworkConnection = UbuntuDevice::Unknown;
367 emit featureDetected();
368
351 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_HASNETWORK));369 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_HASNETWORK));
352370
353 stopProcess();371 stopProcess();
@@ -372,6 +390,10 @@
372void UbuntuDeviceHelper::detectDeviceWritableImage()390void UbuntuDeviceHelper::detectDeviceWritableImage()
373{391{
374 setProcessState(UbuntuDevice::DetectDeviceWriteableImage);392 setProcessState(UbuntuDevice::DetectDeviceWriteableImage);
393
394 m_dev->m_hasWriteableImage = UbuntuDevice::Unknown;
395 emit featureDetected();
396
375 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTWRITABLEIMAGE));397 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTWRITABLEIMAGE));
376398
377 stopProcess();399 stopProcess();
@@ -384,6 +406,10 @@
384void UbuntuDeviceHelper::detectDeveloperTools()406void UbuntuDeviceHelper::detectDeveloperTools()
385{407{
386 setProcessState(UbuntuDevice::DetectDeveloperTools);408 setProcessState(UbuntuDevice::DetectDeveloperTools);
409
410 m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown;
411 emit featureDetected();
412
387 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTDEVELOPERTOOLS));413 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTDEVELOPERTOOLS));
388414
389 stopProcess();415 stopProcess();
@@ -503,6 +529,9 @@
503 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE));529 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE));
504 stopProcess();530 stopProcess();
505531
532 m_dev->m_hasWriteableImage = UbuntuDevice::Unknown;
533 emit featureDetected();
534
506 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE_SCRIPT)535 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE_SCRIPT)
507 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)536 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
508 .arg(m_dev->id().toSetting().toString()));537 .arg(m_dev->id().toSetting().toString()));
@@ -517,6 +546,9 @@
517 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY));546 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY));
518 stopProcess();547 stopProcess();
519548
549 m_dev->m_hasWriteableImage = UbuntuDevice::Unknown;
550 emit featureDetected();
551
520 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY_SCRIPT)552 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY_SCRIPT)
521 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)553 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
522 .arg(m_dev->id().toSetting().toString()));554 .arg(m_dev->id().toSetting().toString()));
@@ -589,6 +621,9 @@
589 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT));621 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT));
590 stopProcess();622 stopProcess();
591623
624 m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown;
625 emit featureDetected();
626
592 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT_SCRIPT)627 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT_SCRIPT)
593 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)628 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
594 .arg(m_dev->id().toSetting().toString()));629 .arg(m_dev->id().toSetting().toString()));
@@ -604,6 +639,9 @@
604 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT));639 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT));
605 stopProcess();640 stopProcess();
606641
642 m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown;
643 emit featureDetected();
644
607 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT_SCRIPT)645 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT_SCRIPT)
608 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)646 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
609 .arg(m_dev->id().toSetting().toString()));647 .arg(m_dev->id().toSetting().toString()));
@@ -630,9 +668,13 @@
630void UbuntuDeviceHelper::cloneNetwork()668void UbuntuDeviceHelper::cloneNetwork()
631{669{
632 m_clonedNwCount++;670 m_clonedNwCount++;
671
633 setProcessState(UbuntuDevice::CloneNetwork);672 setProcessState(UbuntuDevice::CloneNetwork);
634 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK));673 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK));
635674
675 m_dev->m_hasNetworkConnection = UbuntuDevice::Unknown;
676 emit featureDetected();
677
636 stopProcess();678 stopProcess();
637 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK_SCRIPT)679 startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK_SCRIPT)
638 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)680 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
@@ -709,7 +751,9 @@
709 : LinuxDevice(other)751 : LinuxDevice(other)
710 , m_helper(new UbuntuDeviceHelper(this))752 , m_helper(new UbuntuDeviceHelper(this))
711 , m_processState(NotStarted)753 , m_processState(NotStarted)
712 , m_deviceInfoString(other.deviceInfoString())754 , m_deviceInfo(other.m_deviceInfo)
755 , m_modelInfo(other.m_modelInfo)
756 , m_productInfo(other.m_productInfo)
713{757{
714 setDeviceState(ProjectExplorer::IDevice::DeviceDisconnected);758 setDeviceState(ProjectExplorer::IDevice::DeviceDisconnected);
715 setupPrivateKey();759 setupPrivateKey();
@@ -772,6 +816,11 @@
772 return m_helper;816 return m_helper;
773}817}
774818
819void UbuntuDevice::cloneNetwork()
820{
821 m_helper->cloneNetwork();
822}
823
775/*!824/*!
776 * \brief UbuntuDevice::openTerminal825 * \brief UbuntuDevice::openTerminal
777 * Opens a detached terminal, logged into the device826 * Opens a detached terminal, logged into the device
@@ -898,14 +947,48 @@
898 m_helper->removeDevTools();947 m_helper->removeDevTools();
899}948}
900949
901void UbuntuDevice::setDeviceInfoString(const QString &info)950void UbuntuDevice::setDeviceInfoString(const QString &deviceInfo)
902{951{
903 m_deviceInfoString = info;952 m_productInfo = tr("unknown");
904}953 m_modelInfo = m_productInfo;
905954 m_deviceInfo = m_productInfo;
906QString UbuntuDevice::deviceInfoString() const955
907{956 QRegularExpression expr(QStringLiteral("product:\\s?(\\w+)"));
908 return m_deviceInfoString;957 QRegularExpressionMatch m = expr.match(deviceInfo);
958 if(m.hasMatch())
959 m_productInfo = m.captured(1);
960
961 expr.setPattern(QStringLiteral("model:\\s?(\\w+)"));
962 m = expr.match(deviceInfo);
963 if(m.hasMatch())
964 m_modelInfo = m.captured(1);
965
966 expr.setPattern(QStringLiteral("device:\\s?(\\w+)"));
967 m = expr.match(deviceInfo);
968 if(m.hasMatch())
969 m_deviceInfo = m.captured(1);
970}
971
972void UbuntuDevice::setDeviceInfo(const QString &productInfo, const QString &modelInfo, const QString &deviceInfo)
973{
974 m_productInfo = productInfo;
975 m_modelInfo = modelInfo;
976 m_deviceInfo = deviceInfo;
977}
978
979QString UbuntuDevice::modelInfo() const
980{
981 return m_modelInfo;
982}
983
984QString UbuntuDevice::deviceInfo() const
985{
986 return m_deviceInfo;
987}
988
989QString UbuntuDevice::productInfo() const
990{
991 return m_productInfo;
909}992}
910993
911UbuntuDevice::FeatureState UbuntuDevice::hasNetworkConnection() const994UbuntuDevice::FeatureState UbuntuDevice::hasNetworkConnection() const
@@ -968,14 +1051,15 @@
968 case RemoveDevTools:1051 case RemoveDevTools:
969 return tr("Removing development tools");1052 return tr("Removing development tools");
970 case Done:1053 case Done:
971 return tr("Finished");1054 return tr("Ready");
972 }1055 }
973 return QString();1056 return QString();
974}1057}
9751058
976ProjectExplorer::IDeviceWidget *UbuntuDevice::createWidget()1059ProjectExplorer::IDeviceWidget *UbuntuDevice::createWidget()
977{1060{
978 return new UbuntuDeviceConfigurationWidget(sharedFromThis());1061 return new RemoteLinux::GenericLinuxDeviceConfigurationWidget(sharedFromThis());
1062 //return new UbuntuDeviceConfigurationWidget(sharedFromThis());
979}1063}
9801064
981QList<Core::Id> UbuntuDevice::actionIds() const1065QList<Core::Id> UbuntuDevice::actionIds() const
@@ -996,8 +1080,27 @@
996void UbuntuDevice::fromMap(const QVariantMap &map)1080void UbuntuDevice::fromMap(const QVariantMap &map)
997{1081{
998 LinuxDevice::fromMap(map);1082 LinuxDevice::fromMap(map);
1083
1084 //legacy setting, will be converted to the new settings on the next save
999 if(map.contains(DEVICE_INFO_KEY))1085 if(map.contains(DEVICE_INFO_KEY))
1000 m_deviceInfoString = map[DEVICE_INFO_KEY].toString();1086 setDeviceInfoString(map[DEVICE_INFO_KEY].toString());
1087 else {
1088 QString unknown = tr("unknown");
1089 if(map.contains(DEVICE_DEVICE_INFO_KEY))
1090 m_deviceInfo = map[DEVICE_DEVICE_INFO_KEY].toString();
1091 else
1092 m_deviceInfo = unknown;
1093
1094 if(map.contains(DEVICE_MODEL_INFO_KEY))
1095 m_modelInfo = map[DEVICE_MODEL_INFO_KEY].toString();
1096 else
1097 m_modelInfo = unknown;
1098
1099 if(map.contains(DEVICE_PRODUCT_INFO_KEY))
1100 m_productInfo = map[DEVICE_PRODUCT_INFO_KEY].toString();
1101 else
1102 m_productInfo = unknown;
1103 }
10011104
1002 setupPrivateKey();1105 setupPrivateKey();
1003 m_helper->init();1106 m_helper->init();
@@ -1006,7 +1109,9 @@
1006QVariantMap UbuntuDevice::toMap() const1109QVariantMap UbuntuDevice::toMap() const
1007{1110{
1008 QVariantMap map = LinuxDevice::toMap();1111 QVariantMap map = LinuxDevice::toMap();
1009 map.insert(DEVICE_INFO_KEY,m_deviceInfoString);1112 map.insert(DEVICE_PRODUCT_INFO_KEY,m_productInfo);
1113 map.insert(DEVICE_MODEL_INFO_KEY,m_modelInfo);
1114 map.insert(DEVICE_DEVICE_INFO_KEY,m_deviceInfo);
1010 return map;1115 return map;
1011}1116}
10121117
10131118
=== modified file 'src/ubuntu/ubuntudevice.h'
--- src/ubuntu/ubuntudevice.h 2014-04-10 15:59:28 +0000
+++ src/ubuntu/ubuntudevice.h 2014-04-27 13:29:17 +0000
@@ -36,7 +36,6 @@
36{36{
37 Q_OBJECT37 Q_OBJECT
38 friend class UbuntuDevice;38 friend class UbuntuDevice;
39
40public:39public:
41 explicit UbuntuDeviceHelper(UbuntuDevice* dev);40 explicit UbuntuDeviceHelper(UbuntuDevice* dev);
42 ~UbuntuDeviceHelper();41 ~UbuntuDeviceHelper();
@@ -150,6 +149,7 @@
150 QString serialNumber () const;149 QString serialNumber () const;
151 UbuntuDeviceHelper *helper () const;150 UbuntuDeviceHelper *helper () const;
152151
152 void cloneNetwork ();
153 void openTerminal ();153 void openTerminal ();
154 void cloneTimeConfig ();154 void cloneTimeConfig ();
155 void enablePortForward ();155 void enablePortForward ();
@@ -162,8 +162,11 @@
162 void setWriteableImageEnabled ( const bool enabled = true );162 void setWriteableImageEnabled ( const bool enabled = true );
163 void setDeveloperToolsInstalled ( const bool installed = true );163 void setDeveloperToolsInstalled ( const bool installed = true );
164164
165 void setDeviceInfoString (const QString &info);165 void setDeviceInfoString (const QString &deviceInfo);
166 QString deviceInfoString () const;166 void setDeviceInfo (const QString &productInfo, const QString &modelInfo, const QString &deviceInfo);
167 QString modelInfo() const;
168 QString deviceInfo() const;
169 QString productInfo() const;
167170
168 FeatureState developerModeEnabled () const;171 FeatureState developerModeEnabled () const;
169 FeatureState hasNetworkConnection () const;172 FeatureState hasNetworkConnection () const;
@@ -198,7 +201,9 @@
198 FeatureState m_hasWriteableImage;201 FeatureState m_hasWriteableImage;
199 FeatureState m_hasDeveloperTools;202 FeatureState m_hasDeveloperTools;
200 ProcessState m_processState;203 ProcessState m_processState;
201 QString m_deviceInfoString;204 QString m_modelInfo;
205 QString m_deviceInfo;
206 QString m_productInfo;
202 Utils::PortList m_localForwardedPorts;207 Utils::PortList m_localForwardedPorts;
203208
204private:209private:
205210
=== modified file 'src/ubuntu/ubuntudevicemode.cpp'
--- src/ubuntu/ubuntudevicemode.cpp 2013-09-04 15:30:00 +0000
+++ src/ubuntu/ubuntudevicemode.cpp 2014-04-27 13:29:17 +0000
@@ -18,6 +18,8 @@
1818
19#include "ubuntudevicemode.h"19#include "ubuntudevicemode.h"
20#include "ubuntuconstants.h"20#include "ubuntuconstants.h"
21#include "ubuntudevicesmodel.h"
22#include "ubuntuemulatormodel.h"
2123
22#include <coreplugin/modemanager.h>24#include <coreplugin/modemanager.h>
23#include <coreplugin/editormanager/editormanager.h>25#include <coreplugin/editormanager/editormanager.h>
@@ -29,18 +31,30 @@
29#include <utils/styledbar.h>31#include <utils/styledbar.h>
30#include <QVBoxLayout>32#include <QVBoxLayout>
31#include <QScrollArea>33#include <QScrollArea>
34#include <QQuickView>
35#include <QQmlContext>
36#include <QQmlEngine>
37#include <QDebug>
3238
33using namespace Ubuntu::Internal;39using namespace Ubuntu::Internal;
3440
41UbuntuDeviceMode *UbuntuDeviceMode::m_instance = 0;
42
35UbuntuDeviceMode::UbuntuDeviceMode(QObject *parent) :43UbuntuDeviceMode::UbuntuDeviceMode(QObject *parent) :
36 Core::IMode(parent)44 Core::IMode(parent)
37{45{
46 Q_ASSERT_X(m_instance == 0, Q_FUNC_INFO,"There can be only one instance of UbuntuDeviceMode");
47 m_instance = this;
48
49 m_qmlControl = new UbuntuQMLDeviceMode(this);
50
38 setDisplayName(tr(Ubuntu::Constants::UBUNTU_MODE_DEVICES_DISPLAYNAME));51 setDisplayName(tr(Ubuntu::Constants::UBUNTU_MODE_DEVICES_DISPLAYNAME));
39 setIcon(QIcon(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES_ICON)));52 setIcon(QIcon(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES_ICON)));
40 setPriority(Ubuntu::Constants::UBUNTU_MODE_DEVICES_PRIORITY);53 setPriority(Ubuntu::Constants::UBUNTU_MODE_DEVICES_PRIORITY);
41 setId(Ubuntu::Constants::UBUNTU_MODE_DEVICES);54 setId(Ubuntu::Constants::UBUNTU_MODE_DEVICES);
42 setObjectName(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES));55 setObjectName(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES));
4356
57
44 m_modeWidget = new QWidget;58 m_modeWidget = new QWidget;
45 QVBoxLayout *layout = new QVBoxLayout;59 QVBoxLayout *layout = new QVBoxLayout;
46 layout->setMargin(0);60 layout->setMargin(0);
@@ -49,22 +63,90 @@
4963
50 Utils::StyledBar* styledBar = new Utils::StyledBar(m_modeWidget);64 Utils::StyledBar* styledBar = new Utils::StyledBar(m_modeWidget);
51 layout->addWidget(styledBar);65 layout->addWidget(styledBar);
52 QScrollArea *scrollArea = new QScrollArea(m_modeWidget);66
53 scrollArea->setFrameShape(QFrame::NoFrame);67 m_modeView = new QQuickView;
54 layout->addWidget(scrollArea);68 m_modeView->setResizeMode(QQuickView::SizeRootObjectToView);
55 scrollArea->setWidget(&m_ubuntuDevicesWidget);69 m_devicesModel = new UbuntuDevicesModel(m_modeView);
56 scrollArea->setWidgetResizable(true);70 m_emulatorModel = new UbuntuEmulatorModel(m_modeView);
71
72 connect(m_devicesModel,SIGNAL(stdOutMessage(QString)),m_qmlControl,SLOT(addText(QString)));
73 connect(m_devicesModel,SIGNAL(stdErrMessage(QString)),m_qmlControl,SLOT(addErrorText(QString)));
74 connect(m_emulatorModel,SIGNAL(logMessage(QString)),m_qmlControl,SLOT(addText(QString)));
75 connect(m_emulatorModel,SIGNAL(stdOutMessage(QString)),m_qmlControl,SLOT(addText(QString)));
76 connect(m_emulatorModel,SIGNAL(stdErrMessage(QString)),m_qmlControl,SLOT(addErrorText(QString)));
77
78 QWidget* container = QWidget::createWindowContainer(m_modeView);
79 container->setMinimumWidth(860);
80 container->setMinimumHeight(548);
81 container->setFocusPolicy(Qt::TabFocus);
82 layout->addWidget(container);
83
84 m_modeView->rootContext()->setContextProperty(QLatin1String("devicesModel") ,m_devicesModel);
85 m_modeView->rootContext()->setContextProperty(QLatin1String("emulatorModel"),m_emulatorModel);
86 m_modeView->rootContext()->setContextProperty(QLatin1String("deviceMode") ,m_qmlControl);
87 m_modeView->rootContext()->setContextProperty(QLatin1String("resourceRoot") ,Constants::UBUNTU_DEVICESCREEN_ROOT);
88 m_modeView->setSource(QUrl::fromLocalFile(Constants::UBUNTU_DEVICESCREEN_QML));
5789
58 connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*)));90 connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*)));
59
60 setWidget(m_modeWidget);91 setWidget(m_modeWidget);
61}92}
6293
63void UbuntuDeviceMode::modeChanged(Core::IMode *mode) {94UbuntuDevice::ConstPtr UbuntuDeviceMode::device()
6495{
96 if(m_devicesModel->rowCount() <= 0)
97 return UbuntuDevice::ConstPtr();
98
99 if(!m_deviceIndex.isValid()) {
100 m_deviceIndex = 0; //device 0 is always the first selected
101 }
102 return m_devicesModel->device(m_deviceIndex.toInt());
103}
104
105void UbuntuDeviceMode::deviceSelected(const QVariant index)
106{
107 m_deviceIndex = index;
108 emit updateDeviceActions ();
109}
110
111void UbuntuDeviceMode::modeChanged(Core::IMode *mode)
112{
113 Q_UNUSED(mode);
65}114}
66115
67void UbuntuDeviceMode::initialize() {116void UbuntuDeviceMode::initialize() {
68117
69118}
119
120UbuntuDeviceMode *UbuntuDeviceMode::instance()
121{
122 return m_instance;
123}
124
125
126UbuntuQMLDeviceMode::UbuntuQMLDeviceMode(UbuntuDeviceMode *parent)
127 : QObject(parent),
128 m_mode(parent)
129{
130
131}
132
133void UbuntuQMLDeviceMode::deviceSelected(const QVariant index)
134{
135 m_mode->deviceSelected(index);
136}
137
138void UbuntuQMLDeviceMode::addText(const QString &arg)
139{
140 QString in = arg;
141 in.replace(QStringLiteral("\n"),QStringLiteral("<br>"));
142 emit appendText(in);
143}
144
145void UbuntuQMLDeviceMode::addErrorText(const QString &error)
146{
147 QString in = error;
148 in.replace(QStringLiteral("\n"),QStringLiteral("<br>"));
149 in.prepend(QStringLiteral("<font color=\"#FF0000\">"));
150 in.append(QStringLiteral("</font>"));
151 emit appendText(in);
70}152}
71153
=== modified file 'src/ubuntu/ubuntudevicemode.h'
--- src/ubuntu/ubuntudevicemode.h 2013-09-04 15:30:00 +0000
+++ src/ubuntu/ubuntudevicemode.h 2014-04-27 13:29:17 +0000
@@ -19,12 +19,38 @@
19#ifndef UBUNTUDEVICEMODE_H19#ifndef UBUNTUDEVICEMODE_H
20#define UBUNTUDEVICEMODE_H20#define UBUNTUDEVICEMODE_H
2121
22#include "ubuntudevice.h"
22#include <coreplugin/imode.h>23#include <coreplugin/imode.h>
23#include "ubuntudeviceswidget.h"24
25class QQuickView;
2426
25namespace Ubuntu {27namespace Ubuntu {
26namespace Internal {28namespace Internal {
2729
30class UbuntuDevicesModel;
31class UbuntuEmulatorModel;
32class UbuntuDeviceMode;
33
34class UbuntuQMLDeviceMode : public QObject {
35 Q_OBJECT
36
37public:
38 UbuntuQMLDeviceMode( UbuntuDeviceMode *parent );
39
40public slots:
41 void deviceSelected ( const QVariant index );
42 void addText (const QString &arg);
43 void addErrorText (const QString &error);
44
45signals:
46 void logChanged(const QString &arg);
47 void appendText(const QString &newText);
48
49private:
50 UbuntuDeviceMode* m_mode;
51};
52
53
28class UbuntuDeviceMode : public Core::IMode54class UbuntuDeviceMode : public Core::IMode
29{55{
30 Q_OBJECT56 Q_OBJECT
@@ -33,12 +59,26 @@
33 UbuntuDeviceMode(QObject *parent = 0);59 UbuntuDeviceMode(QObject *parent = 0);
34 void initialize();60 void initialize();
3561
62 static UbuntuDeviceMode *instance();
63 UbuntuDevice::ConstPtr device();
64
65 void deviceSelected ( const QVariant index );
66
67signals:
68 void updateDeviceActions ();
69
36protected slots:70protected slots:
37 void modeChanged(Core::IMode*);71 void modeChanged(Core::IMode*);
3872
39protected:73protected:
74 static UbuntuDeviceMode *m_instance;
75 UbuntuDevicesModel *m_devicesModel;
76 UbuntuEmulatorModel *m_emulatorModel;
77 UbuntuQMLDeviceMode *m_qmlControl;
78 QQuickView *m_modeView;
40 QWidget* m_modeWidget;79 QWidget* m_modeWidget;
41 UbuntuDevicesWidget m_ubuntuDevicesWidget;80 QVariant m_deviceIndex;
81 QString m_log;
42};82};
4383
4484
4585
=== added file 'src/ubuntu/ubuntudevicesmodel.cpp'
--- src/ubuntu/ubuntudevicesmodel.cpp 1970-01-01 00:00:00 +0000
+++ src/ubuntu/ubuntudevicesmodel.cpp 2014-04-27 13:29:17 +0000
@@ -0,0 +1,734 @@
1#include "ubuntudevicesmodel.h"
2#include "ubuntuconstants.h"
3#include "ubuntukitmanager.h"
4
5#include <projectexplorer/devicesupport/devicemanager.h>
6#include <projectexplorer/kitmanager.h>
7#include <projectexplorer/kit.h>
8#include <projectexplorer/kitinformation.h>
9
10#include <QCoreApplication>
11#include <QRegularExpression>
12#include <QRegularExpressionMatch>
13#include <QVariant>
14
15namespace Ubuntu {
16namespace Internal {
17
18UbuntuDevicesModel::UbuntuDevicesModel(QObject *parent) :
19 QAbstractListModel(parent)
20{
21 m_deviceNotifier = new UbuntuDeviceNotifier(this);
22 connect(m_deviceNotifier,SIGNAL(deviceConnected(QString)),this,SLOT(deviceConnected(QString)));
23
24 m_adbProcess = new QProcess(this);
25 connect(m_adbProcess,SIGNAL(finished(int)),this,SLOT(refreshFinished(int)));
26 connect(m_adbProcess,SIGNAL(readyRead()),this,SLOT(adbReadyRead()));
27
28
29 ProjectExplorer::KitManager* devMgr = static_cast<ProjectExplorer::KitManager*>(ProjectExplorer::KitManager::instance());
30 connect(devMgr,SIGNAL(kitsLoaded()),this,SLOT(refresh()));
31 connect(ProjectExplorer::DeviceManager::instance(),SIGNAL(deviceListReplaced()),this,SLOT(readDevicesFromSettings()));
32}
33
34bool UbuntuDevicesModel::set(int index, const QString &role, const QVariant &value)
35{
36 if(index < 0 || index >= rowCount())
37 return false;
38
39 QModelIndex idx = createIndex(index,0);
40 if(!roleNames().values().contains(role.toUtf8()))
41 return false;
42
43 return setData(idx,value,roleNames().key(role.toUtf8()));
44}
45
46int UbuntuDevicesModel::rowCount(const QModelIndex &parent) const
47{
48 if(parent.isValid())
49 return 0;
50 return m_knownDevices.size();
51}
52
53bool UbuntuDevicesModel::setData(const QModelIndex &index, const QVariant &value, int role)
54{
55 qDebug()<<"Setting index "<<index<<" with data "<<value<<" to role "<<role;
56 if(!index.isValid()
57 || index.parent().isValid()
58 || index.row() < 0
59 || index.row() > rowCount())
60 return false;
61
62 UbuntuDevice::Ptr dev = m_knownDevices[index.row()]->device();
63
64 switch (role) {
65 case Qt::DisplayRole:
66 case Qt::EditRole:
67 return false;
68 case KitListRole:
69 return false;
70 case DeveloperModeRole: {
71 if(!value.type() == QVariant::Bool)
72 return false;
73
74 bool set = value.toBool();
75 UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable;
76 UbuntuDevice::FeatureState oldState = dev->developerModeEnabled();
77
78 if(oldState == UbuntuDevice::Unknown)
79 return false;
80
81 if( oldState != newState )
82 dev->setDeveloperModeEnabled(set);
83 return true;
84 break;
85 }
86 case NetworkConnectionRole: {
87 if(!value.type() == QVariant::Bool)
88 return false;
89
90 bool set = value.toBool();
91 UbuntuDevice::FeatureState oldState = dev->hasNetworkConnection();
92
93 if( oldState == UbuntuDevice::Unknown || oldState == UbuntuDevice::Available )
94 return false;
95
96 if(set)
97 dev->cloneNetwork();
98 return true;
99
100 break;
101 }
102 case WriteableImageRole: {
103 if(!value.type() == QVariant::Bool)
104 return false;
105
106 bool set = value.toBool();
107 UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable;
108 UbuntuDevice::FeatureState oldState = dev->hasWriteableImage();
109
110 if(oldState == UbuntuDevice::Unknown)
111 return false;
112
113 if( oldState != newState )
114 dev->setWriteableImageEnabled(set);
115 return true;
116 break;
117 }
118 case DeveloperToolsRole: {
119 if(!value.type() == QVariant::Bool)
120 return false;
121
122 bool set = value.toBool();
123 UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable;
124 UbuntuDevice::FeatureState oldState = dev->hasDeveloperTools();
125
126 if(oldState == UbuntuDevice::Unknown)
127 return false;
128
129 if( oldState != newState )
130 dev->setDeveloperToolsInstalled(set);
131 return true;
132 break;
133 }
134 default:
135 break;
136 }
137
138 return false;
139}
140
141QVariant UbuntuDevicesModel::data(const QModelIndex &index, int role) const
142{
143 if(!index.isValid()
144 || index.parent().isValid()
145 || index.row() < 0
146 || index.row() > rowCount())
147 return QVariant();
148
149 switch (role) {
150 case Qt::DisplayRole:
151 case Qt::EditRole:
152 return m_knownDevices[index.row()]->device()->displayName();
153 case UniqueIdRole:
154 return m_knownDevices[index.row()]->id().uniqueIdentifier();
155 case DetectionStateRole:
156 return m_knownDevices[index.row()]->device()->detectionState();
157 case DetectionStateStringRole:
158 return m_knownDevices[index.row()]->device()->detectionStateString();
159 case ConnectionStateRole:
160 return m_knownDevices[index.row()]->device()->deviceState();
161 case ConnectionStateStringRole:
162 return m_knownDevices[index.row()]->device()->deviceStateToString();
163 case KitListRole:
164 return QVariant::fromValue(m_knownDevices[index.row()]->kits());
165 case DeveloperModeRole:
166 return m_knownDevices[index.row()]->device()->developerModeEnabled();
167 case NetworkConnectionRole:
168 return m_knownDevices[index.row()]->device()->hasNetworkConnection();
169 case WriteableImageRole:
170 return m_knownDevices[index.row()]->device()->hasWriteableImage();
171 case DeveloperToolsRole:
172 return m_knownDevices[index.row()]->device()->hasDeveloperTools();
173 case EmulatorRole:
174 return false;
175 case LogRole:
176 return m_knownDevices[index.row()]->device()->helper()->log();
177 case SerialIdRole:
178 return m_knownDevices[index.row()]->device()->id().toSetting();
179 case ModelInfoRole:
180 return m_knownDevices[index.row()]->device()->modelInfo();
181 case DeviceInfoRole:
182 return m_knownDevices[index.row()]->device()->deviceInfo();
183 case ProductInfoRole:
184 return m_knownDevices[index.row()]->device()->productInfo();
185 default:
186 break;
187 }
188
189 return QVariant();
190}
191
192QHash<int, QByteArray> UbuntuDevicesModel::roleNames() const
193{
194 QHash<int,QByteArray> roles = QAbstractListModel::roleNames();
195 roles.insert(UniqueIdRole,"deviceId");
196 roles.insert(DetectionStateRole,"detectionState");
197 roles.insert(DetectionStateStringRole,"detectionStateString");
198 roles.insert(ConnectionStateRole,"connectionState");
199 roles.insert(ConnectionStateStringRole,"connectionStateString");
200 roles.insert(KitListRole,"kits");
201 roles.insert(DeveloperModeRole,"developerModeEnabled");
202 roles.insert(NetworkConnectionRole,"hasNetworkConnection");
203 roles.insert(WriteableImageRole,"hasWriteableImage");
204 roles.insert(DeveloperToolsRole,"hasDeveloperTools");
205 roles.insert(EmulatorRole,"isEmulator");
206 roles.insert(LogRole,"deviceLog");
207 roles.insert(SerialIdRole,"serial");
208 roles.insert(ModelInfoRole,"modelInfo");
209 roles.insert(DeviceInfoRole,"deviceInfo");
210 roles.insert(ProductInfoRole,"productInfo");
211 return roles;
212}
213
214Qt::ItemFlags UbuntuDevicesModel::flags(const QModelIndex &index) const
215{
216 return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
217}
218
219void UbuntuDevicesModel::triggerCloneTimeConfig(const int devId)
220{
221 int row = findDevice(devId);
222 if(row < 0)
223 return;
224 m_knownDevices[row]->device()->cloneTimeConfig();
225}
226
227void UbuntuDevicesModel::triggerPortForwarding(const int devId)
228{
229 int row = findDevice(devId);
230 if(row < 0)
231 return;
232 m_knownDevices[row]->device()->enablePortForward();
233}
234
235void UbuntuDevicesModel::triggerSSHSetup(const int devId)
236{
237 int row = findDevice(devId);
238 if(row < 0)
239 return;
240 m_knownDevices[row]->device()->deployPublicKey();
241}
242
243void UbuntuDevicesModel::triggerSSHConnection(const int devId)
244{
245 int row = findDevice(devId);
246 if(row < 0)
247 return;
248 m_knownDevices[row]->device()->openTerminal();
249}
250
251void UbuntuDevicesModel::triggerReboot(const int devId)
252{
253 int row = findDevice(devId);
254 if(row < 0)
255 return;
256 m_knownDevices[row]->device()->reboot();
257}
258
259void UbuntuDevicesModel::triggerRebootBootloader(const int devId)
260{
261 int row = findDevice(devId);
262 if(row < 0)
263 return;
264 m_knownDevices[row]->device()->rebootToBootloader();
265}
266
267void UbuntuDevicesModel::triggerRebootRecovery(const int devId)
268{
269 int row = findDevice(devId);
270 if(row < 0)
271 return;
272 m_knownDevices[row]->device()->rebootToRecovery();
273}
274
275void UbuntuDevicesModel::triggerShutdown(const int devId)
276{
277 int row = findDevice(devId);
278 if(row < 0)
279 return;
280 m_knownDevices[row]->device()->shutdown();
281}
282
283void UbuntuDevicesModel::triggerKitAutocreate(const int devId)
284{
285 int row = findDevice(devId);
286 if(row < 0)
287 return;
288 UbuntuKitManager::autoCreateKit(m_knownDevices[row]->device());
289}
290
291void UbuntuDevicesModel::triggerKitRemove(const int devId, const QVariant &kitid)
292{
293 int row = findDevice(devId);
294 if(row < 0)
295 return;
296
297 ProjectExplorer::Kit* k = ProjectExplorer::KitManager::find(Core::Id::fromSetting(kitid));
298 if(ProjectExplorer::DeviceKitInformation::deviceId(k) == Core::Id(devId)) {
299 //completely delete the kit
300 ProjectExplorer::KitManager::deregisterKit(k);
301 }
302}
303
304void UbuntuDevicesModel::refresh()
305{
306 if( m_adbProcess->state() != QProcess::NotRunning ) {
307 //make sure we use a clean QProcess
308 m_adbProcess->disconnect(this);
309 m_adbProcess->kill();
310 m_adbProcess->deleteLater();
311
312 m_adbProcess = new QProcess(this);
313 connect(m_adbProcess,SIGNAL(finished(int)),this,SLOT(refreshFinished(int)));
314 connect(m_adbProcess,SIGNAL(readyRead()),this,SLOT(adbReadyRead()));
315 }
316 bool restartAdb = true;
317 m_adbProcess->setWorkingDirectory(QCoreApplication::applicationDirPath());
318 QStringList args = QStringList() << (restartAdb ? QString::number(1) : QString::number(0));
319 m_adbProcess->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT)
320 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH),args);
321
322 clear();
323}
324
325void UbuntuDevicesModel::clear()
326{
327 if(rowCount()) {
328 beginRemoveRows(QModelIndex(),0,rowCount()-1);
329 qDeleteAll(m_knownDevices.begin(),m_knownDevices.end());
330 m_knownDevices.clear();
331 endRemoveRows();
332 }
333}
334
335int UbuntuDevicesModel::findDevice(int uniqueIdentifier) const
336{
337 for ( int i = 0; i < m_knownDevices.size(); i++ ) {
338 if(m_knownDevices[i]->id().uniqueIdentifier() == uniqueIdentifier)
339 return i;
340 }
341 return -1;
342}
343
344bool UbuntuDevicesModel::hasDevice(int uniqueIdentifier) const
345{
346 return findDevice(uniqueIdentifier) >= 0;
347}
348
349UbuntuDevice::ConstPtr UbuntuDevicesModel::device(const int index)
350{
351 if(index < 0 || index >= rowCount())
352 return UbuntuDevice::ConstPtr();
353 return m_knownDevices[index]->device();
354}
355
356UbuntuDevicesItem *UbuntuDevicesModel::createItem(UbuntuDevice::Ptr dev)
357{
358 UbuntuDevicesItem *devItem = new UbuntuDevicesItem(dev,this);
359 connect(devItem,SIGNAL(kitsChanged()),this,SLOT(kitsChanged()));
360 connect(devItem,SIGNAL(detectionStateChanged()),this,SLOT(detectionStateChanged()));
361 connect(devItem,SIGNAL(featureDetected()),this,SLOT(featureDetected()));
362 connect(devItem,SIGNAL(logUpdated()),this,SLOT(logUpdated()));
363 return devItem;
364}
365
366/*!
367 * \brief UbuntuDevicesModel::indexFromHelper
368 * Checks if the passed QObject is a DeviceHelper and returns the
369 * row index of the related device
370 */
371int UbuntuDevicesModel::indexFromHelper(QObject *possibleHelper)
372{
373 UbuntuDevicesItem* hlpr = qobject_cast<UbuntuDevicesItem*>(possibleHelper);
374 if(!hlpr) return -1;
375 return findDevice(hlpr->id().uniqueIdentifier());
376}
377
378void UbuntuDevicesModel::deviceChanged(QObject *possibleHelper, const QVector<int> &relatedRoles)
379{
380 int idx = indexFromHelper(possibleHelper);
381 if(idx < 0)
382 return;
383 QModelIndex changed = createIndex(idx,0);
384 emit dataChanged(changed,changed,relatedRoles);
385}
386
387/*!
388 * \brief UbuntuDevicesModel::readDevicesFromSettings
389 * read all known devices from the DeviceManager, this is triggered
390 * automatically on startup
391 */
392void UbuntuDevicesModel::readDevicesFromSettings()
393{
394 clear();
395
396 QList<UbuntuDevicesItem*> devs;
397 ProjectExplorer::DeviceManager* devMgr = ProjectExplorer::DeviceManager::instance();
398 for(int i = 0; i < devMgr->deviceCount(); i++) {
399 ProjectExplorer::IDevice::ConstPtr dev = devMgr->deviceAt(i);
400 if(dev && dev->type() == Core::Id(Constants::UBUNTU_DEVICE_TYPE_ID)) {
401
402 //ugly hack to get a mutable version of the device
403 //no idea why its necessary to lock it up
404 Ubuntu::Internal::UbuntuDevice* cPtr = qSharedPointerCast<const Ubuntu::Internal::UbuntuDevice>(dev)->helper()->device();
405 if(cPtr)
406 devs.append(createItem(cPtr->sharedFromThis()));
407
408 }
409 }
410
411 beginInsertRows(QModelIndex(),0,devs.count()-1);
412 m_knownDevices = devs;
413 endInsertRows();
414
415 connect(devMgr,SIGNAL(deviceAdded(Core::Id)),this,SLOT(deviceAdded(Core::Id)));
416 connect(devMgr,SIGNAL(deviceRemoved(Core::Id)),this,SLOT(deviceRemoved(Core::Id)));
417 connect(devMgr,SIGNAL(deviceUpdated(Core::Id)),this,SLOT(deviceUpdated(Core::Id)));
418}
419
420void UbuntuDevicesModel::detectionStateChanged()
421{
422 //contains the possible changed roles when this slot is called
423 static QVector<int> relatedRoles = QVector<int>()
424 << DetectionStateRole << DetectionStateStringRole;
425
426 deviceChanged(sender(),relatedRoles);
427}
428
429void UbuntuDevicesModel::featureDetected()
430{
431 //contains the possible changed roles when this slot is called
432 static QVector<int> relatedRoles = QVector<int>()
433 << DeveloperModeRole << NetworkConnectionRole
434 << WriteableImageRole << DeveloperToolsRole;
435
436 deviceChanged(sender(),relatedRoles);
437}
438
439void UbuntuDevicesModel::logUpdated()
440{
441 //contains the possible changed roles when this slot is called
442 static QVector<int> relatedRoles = QVector<int>()
443 << LogRole;
444
445 deviceChanged(sender(),relatedRoles);
446}
447
448void UbuntuDevicesModel::kitsChanged()
449{
450 //contains the possible changed roles when this slot is called
451 static QVector<int> relatedRoles = QVector<int>()
452 << KitListRole;
453
454 deviceChanged(sender(),relatedRoles);
455}
456
457/*!
458 * \brief UbuntuDevicesModel::deviceAdded
459 * A device was added in the DeviceManager, check if know it and
460 * if we should know it. If its a new Ubuntu device its added to
461 * the known devices
462 */
463void UbuntuDevicesModel::deviceAdded(const Core::Id &id)
464{
465 ProjectExplorer::IDevice::ConstPtr ptr = ProjectExplorer::DeviceManager::instance()->find(id);
466 if(!ptr)
467 return;
468
469 if(ptr->type() != Core::Id(Constants::UBUNTU_DEVICE_TYPE_ID))
470 return;
471
472 qDebug()<<"Device Manager reports device added: "<<id.toString();
473 if (hasDevice(id.uniqueIdentifier()))
474 return;
475
476 Ubuntu::Internal::UbuntuDevice::ConstPtr ubuntuDev
477 = qSharedPointerCast<const Ubuntu::Internal::UbuntuDevice>(ptr);
478
479 Ubuntu::Internal::UbuntuDeviceHelper* hlp = ubuntuDev->helper();
480 Ubuntu::Internal::UbuntuDevice* dev = hlp->device();
481
482 beginInsertRows(QModelIndex(),rowCount(),rowCount());
483 m_knownDevices.append(createItem(dev->sharedFromThis()));
484 endInsertRows();
485}
486
487/*!
488 * \brief UbuntuDevicesWidget::deviceRemoved
489 * A device was removed from the device manager, if its one of ours
490 * we will also remove it
491 */
492void UbuntuDevicesModel::deviceRemoved(const Core::Id &id)
493{
494 int index = findDevice(id.uniqueIdentifier());
495 if(index < 0)
496 return;
497
498 qDebug()<<"Device Manager reports device removed: "<<id.toString();
499 beginRemoveRows(QModelIndex(),index,index);
500 delete m_knownDevices.takeAt(index);
501 endRemoveRows();
502}
503
504/*!
505 * \brief UbuntuDevicesModel::deviceUpdated
506 * called when a device state is changed between connected
507 * and disconnected or device data was changed
508 */
509void UbuntuDevicesModel::deviceUpdated(const Core::Id &id)
510{
511 //contains the possible changed roles when this slot is called
512 static QVector<int> relatedRoles = QVector<int>()
513 << Qt::DisplayRole << Qt::EditRole
514 << ConnectionStateRole << ConnectionStateStringRole;
515
516 int index = findDevice(id.uniqueIdentifier());
517 if(index >= 0) {
518 QModelIndex changed = createIndex(index,0);
519 emit dataChanged(changed, changed,relatedRoles);
520 }
521}
522
523void UbuntuDevicesModel::deviceConnected(const QString &id)
524{
525 int idx = findDevice(Core::Id::fromSetting(id).uniqueIdentifier());
526 if(idx >= 0)
527 return;
528
529 refresh();
530}
531
532void UbuntuDevicesModel::refreshFinished(int exitCode)
533{
534 readDevicesFromSettings();
535 foreach(UbuntuDevicesItem* item, m_knownDevices)
536 item->device()->helper()->refresh();
537
538 if(exitCode != 0) {
539 return;
540 }
541
542 //read all data from the process
543 adbReadyRead();
544
545 QStringList lines = m_adbReply.trimmed().split(QLatin1String(Constants::LINEFEED));
546 foreach(QString line, lines) {
547 line = line.trimmed();
548
549 if (line.isEmpty()) {
550 continue;
551 }
552
553 QRegularExpression exp(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_ADB_REGEX));
554 QRegularExpressionMatch match = exp.match(line);
555
556 if(match.hasMatch()) {
557 QStringList lineData = match.capturedTexts();
558
559 //The first entry is always the full match
560 //which means in our case its the complete string
561 lineData.takeFirst();
562
563 if (lineData.count() == 2) {
564 QString sSerialNumber = lineData.takeFirst();
565 QString sDeviceInfo = lineData.takeFirst();
566
567 //sometimes the adb server is not started when adb devices is
568 //executed, we just skip those lines
569 if(sSerialNumber == QLatin1String("*"))
570 continue;
571
572 if(sSerialNumber.isEmpty() || sSerialNumber.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_ADB_NOACCESS))) {
573 continue;
574 }
575
576 registerNewDevice(sSerialNumber,sDeviceInfo);
577 }
578 }
579 }
580}
581
582void UbuntuDevicesModel::adbReadyRead()
583{
584 QString stderr = QString::fromLocal8Bit(m_adbProcess->readAllStandardError());
585 QString stdout = QString::fromLocal8Bit(m_adbProcess->readAllStandardOutput());
586
587 if(!stderr.trimmed().isEmpty()) {
588 emit stdErrMessage(stderr);
589 m_adbReply.append(stderr);
590 }
591
592 if(!stdout.trimmed().isEmpty()) {
593 emit stdOutMessage(stdout);
594 m_adbReply.append(stdout);
595 }
596 qDebug()<<m_adbReply;
597}
598
599/*!
600 * \brief UbuntuDevicesModel::registerNewDevice
601 * Registers a new device in the device manager if its not
602 * already in the known devices map.
603 * \note will not add it into model list, this
604 * will happen automatically when the device is
605 * registered in the device manager
606 */
607void UbuntuDevicesModel::registerNewDevice(const QString &serial, const QString &deviceInfo)
608{
609 if(findDevice(Core::Id::fromSetting(serial).uniqueIdentifier()) >= 0)
610 return;
611
612 bool isEmu = serial.startsWith(QLatin1String("emulator"));
613
614 Ubuntu::Internal::UbuntuDevice::Ptr dev = Ubuntu::Internal::UbuntuDevice::create(
615 tr("Ubuntu Device")
616 , serial
617 , isEmu ? ProjectExplorer::IDevice::Emulator : ProjectExplorer::IDevice::Hardware
618 , ProjectExplorer::IDevice::AutoDetected);
619
620 dev->setDeviceInfoString(deviceInfo);
621 ProjectExplorer::DeviceManager::instance()->addDevice(dev);
622}
623
624/*!
625 * \class UbuntuDevicesItem
626 * Represents a Device inside the UbuntuDevicesModel,
627 * the item tracks changes in the device and notifies the model
628 * accordingly
629 */
630UbuntuDevicesItem::UbuntuDevicesItem(UbuntuDevice::Ptr device, QObject* parent) :
631 QObject(parent),
632 m_device(device)
633{
634 QList<ProjectExplorer::Kit*> allkits = ProjectExplorer::KitManager::kits();
635 foreach (ProjectExplorer::Kit* k, allkits) {
636 if( ProjectExplorer::DeviceKitInformation::deviceId(k) == device->id() )
637 m_myKits.insert(k->id());
638 }
639
640 connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitAdded(ProjectExplorer::Kit*)),
641 this,SLOT(onKitAdded(ProjectExplorer::Kit*)));
642 connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitRemoved(ProjectExplorer::Kit*)),
643 this,SLOT(onKitRemoved(ProjectExplorer::Kit*)));
644 connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
645 this,SLOT(onKitUpdated(ProjectExplorer::Kit*)));
646
647 connect(device->helper(),SIGNAL(detectionStateChanged()),this,SLOT(deviceStateChanged()));
648 connect(device->helper(),SIGNAL(featureDetected()),this,SIGNAL(featureDetected()));
649 connect(device->helper(),SIGNAL(message(QString)),this,SIGNAL(logUpdated()));
650}
651
652/*!
653 * \brief UbuntuDevicesItem::id
654 * Returns the internal device ID
655 */
656Core::Id UbuntuDevicesItem::id() const
657{
658 return m_device->id();
659}
660
661UbuntuDevice::Ptr UbuntuDevicesItem::device() const
662{
663 return m_device;
664}
665
666QVariantList UbuntuDevicesItem::kits() const
667{
668 QVariantList kits;
669 foreach (const Core::Id &id, m_myKits) {
670 ProjectExplorer::Kit* k = ProjectExplorer::KitManager::find(id);
671 if(!k)
672 continue;
673
674 qDebug()<<"Adding "<<k->displayName();
675
676 QVariantMap m;
677 m.insert(QStringLiteral("displayName"),k->displayName());
678 m.insert(QStringLiteral("id"),k->id().toSetting());
679 kits.append(QVariant::fromValue(m));
680 }
681
682 return kits;
683}
684
685/*!
686 * \brief UbuntuDevicesItem::onKitAdded
687 * Checks if the new Kit that just got added to the KitManager contains
688 * the device, if it does the Kit is added to the internal Kit list
689 */
690void UbuntuDevicesItem::onKitAdded(ProjectExplorer::Kit *k)
691{
692 if( ProjectExplorer::DeviceKitInformation::deviceId(k) == m_device->id() ) {
693 if(!m_myKits.contains(k->id())){
694 m_myKits.insert(k->id());
695 emit kitsChanged();
696 }
697 }
698}
699
700/*!
701 * \brief UbuntuDevicesItem::onKitRemoved
702 * Checks if the removed Kit \a k is in the internal Kit list
703 * and removes it
704 */
705void UbuntuDevicesItem::onKitRemoved(ProjectExplorer::Kit *k)
706{
707 if(m_myKits.contains(k->id())) {
708 m_myKits.remove(k->id());
709 emit kitsChanged();
710 }
711}
712
713/*!
714 * \brief UbuntuDevicesItem::onKitUpdated
715 * Checks if the updated Kit now contains the internal device
716 * or if it does NOT contain the device anymore
717 */
718void UbuntuDevicesItem::onKitUpdated(ProjectExplorer::Kit *k)
719{
720 if( ProjectExplorer::DeviceKitInformation::deviceId(k) == m_device->id() ) {
721 onKitAdded(k);
722 } else {
723 onKitRemoved(k);
724 }
725}
726
727void UbuntuDevicesItem::deviceStateChanged()
728{
729 emit detectionStateChanged();
730}
731
732}
733}
734
0735
=== added file 'src/ubuntu/ubuntudevicesmodel.h'
--- src/ubuntu/ubuntudevicesmodel.h 1970-01-01 00:00:00 +0000
+++ src/ubuntu/ubuntudevicesmodel.h 2014-04-27 13:29:17 +0000
@@ -0,0 +1,169 @@
1#ifndef UBUNTUDEVICESMODEL_H
2#define UBUNTUDEVICESMODEL_H
3
4#include "ubuntudevice.h"
5#include "ubuntudevicenotifier.h"
6
7#include <coreplugin/id.h>
8
9#include <QAbstractListModel>
10#include <QList>
11
12namespace ProjectExplorer {
13class Kit;
14}
15
16namespace Ubuntu {
17namespace Internal {
18
19class UbuntuDevicesItem;
20
21class UbuntuDevicesModel : public QAbstractListModel
22{
23 Q_OBJECT
24public:
25
26 enum Roles {
27 ConnectionStateRole = Qt::UserRole,
28 UniqueIdRole,
29 ConnectionStateStringRole,
30 DetectionStateRole,
31 DetectionStateStringRole,
32 KitListRole,
33 DeveloperModeRole,
34 NetworkConnectionRole,
35 WriteableImageRole,
36 DeveloperToolsRole,
37 EmulatorRole,
38 LogRole,
39 SerialIdRole,
40 ModelInfoRole,
41 DeviceInfoRole,
42 ProductInfoRole
43 };
44
45 explicit UbuntuDevicesModel(QObject *parent = 0);
46
47 Q_INVOKABLE bool set(int index, const QString &role, const QVariant &value);
48
49 int findDevice(int uniqueIdentifier) const;
50 bool hasDevice (int uniqueIdentifier) const;
51 UbuntuDevice::ConstPtr device ( const int index );
52
53 // QAbstractItemModel interface
54 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
55 virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
56 virtual QVariant data(const QModelIndex &index, int role) const;
57 virtual QHash<int, QByteArray> roleNames() const;
58 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
59signals:
60 void logMessage (const QString &str);
61 void stdOutMessage (const QString &str);
62 void stdErrMessage (const QString &str);
63
64public slots:
65 void triggerCloneTimeConfig ( const int devId );
66 void triggerPortForwarding ( const int devId );
67 void triggerSSHSetup ( const int devId );
68 void triggerSSHConnection ( const int devId );
69 void triggerReboot ( const int devId );
70 void triggerRebootBootloader( const int devId );
71 void triggerRebootRecovery ( const int devId );
72 void triggerShutdown ( const int devId );
73 void triggerKitAutocreate ( const int devId );
74 void triggerKitRemove (const int devId, const QVariant &kitid );
75 void refresh ();
76
77protected:
78 void clear ();
79 UbuntuDevicesItem *createItem (UbuntuDevice::Ptr dev);
80 int indexFromHelper (QObject* possibleHelper);
81 void deviceChanged(QObject* possibleHelper, const QVector<int> &relatedRoles);
82 void registerNewDevice(const QString &serial, const QString &deviceInfo);
83
84protected slots:
85 void readDevicesFromSettings();
86 void detectionStateChanged ();
87 void featureDetected ();
88 void logUpdated ();
89 void kitsChanged ();
90 void deviceAdded(const Core::Id &id);
91 void deviceRemoved(const Core::Id &id);
92 void deviceUpdated(const Core::Id &id);
93 void deviceConnected(const QString&id);
94 void refreshFinished(int exitCode);
95 void adbReadyRead();
96
97private:
98 QList<UbuntuDevicesItem*> m_knownDevices;
99 UbuntuDeviceNotifier *m_deviceNotifier;
100 QProcess *m_adbProcess;
101 QString m_adbReply;
102};
103
104/*!
105 * \brief The UbuntuDeviceStates class
106 * Provides enums for QML
107 */
108class UbuntuDeviceStates : public QObject
109{
110 Q_OBJECT
111public:
112 enum FeatureState {
113 NotAvailable = UbuntuDevice::NotAvailable,
114 Unknown = UbuntuDevice::Unknown,
115 Available = UbuntuDevice::Available
116 };
117 Q_ENUMS(FeatureState)
118
119 enum DeviceDetectionState {
120 NotStarted = UbuntuDevice::NotStarted,
121 Detecting,
122 Done = UbuntuDevice::Done
123 };
124 Q_ENUMS(DeviceDetectionState)
125
126 enum DeviceConnectionState {
127 DeviceReadyToUse = ProjectExplorer::IDevice::DeviceReadyToUse,
128 DeviceConnected = ProjectExplorer::IDevice::DeviceConnected,
129 DeviceDisconnected = ProjectExplorer::IDevice::DeviceDisconnected,
130 DeviceStateUnknown = ProjectExplorer::IDevice::DeviceStateUnknown
131 };
132 Q_ENUMS(DeviceConnectionState)
133};
134
135class UbuntuDevicesItem : public QObject
136{
137 Q_OBJECT
138public:
139 UbuntuDevicesItem(Ubuntu::Internal::UbuntuDevice::Ptr device, QObject* parent = 0);
140
141 Core::Id id() const;
142 UbuntuDevice::Ptr device() const;
143 QVariantList kits() const;
144
145signals:
146 void kitsChanged ();
147 void connectionChanged ();
148 void detectionStateChanged ();
149 void featureDetected ();
150 void logUpdated();
151
152private slots:
153 void onKitAdded(ProjectExplorer::Kit *k);
154 void onKitRemoved(ProjectExplorer::Kit *k);
155 void onKitUpdated(ProjectExplorer::Kit *k);
156 void deviceStateChanged ();
157
158
159private:
160 Ubuntu::Internal::UbuntuDevice::Ptr m_device;
161 QSet<Core::Id> m_myKits;
162};
163
164}
165}
166
167
168
169#endif // UBUNTUDEVICESMODEL_H
0170
=== added file 'src/ubuntu/ubuntuemulatormodel.cpp'
--- src/ubuntu/ubuntuemulatormodel.cpp 1970-01-01 00:00:00 +0000
+++ src/ubuntu/ubuntuemulatormodel.cpp 2014-04-27 13:29:17 +0000
@@ -0,0 +1,408 @@
1#include "ubuntuemulatormodel.h"
2#include "ubuntuconstants.h"
3
4#include <utils/projectnamevalidatinglineedit.h>
5
6#include <QMutableStringListIterator>
7#include <QCoreApplication>
8#include <QStandardPaths>
9#include <QDir>
10#include <QRegularExpression>
11#include <QRegularExpressionMatch>
12
13namespace Ubuntu {
14namespace Internal {
15
16/*!
17 \brief UbuntuEmulatorModel
18 Provides informations about all existing emulators
19 \note This will be merged with the devices model when the
20 emulator tool can query the serial number of not running
21 emulators
22 */
23
24UbuntuEmulatorModel::UbuntuEmulatorModel(QObject *parent) :
25 QAbstractListModel(parent) ,
26 m_process(0),
27 m_emulatorInstalled(false) ,
28 m_state(UbuntuEmulatorModel::Initial),
29 m_cancellable(false)
30{
31 m_process = new UbuntuProcess(this);
32 connect(m_process,SIGNAL(message(QString)),this,SLOT(onMessage(QString)));
33 connect(m_process,SIGNAL(finished(QString,int)),this,SLOT(processFinished(QString,int)));
34 connect(m_process,SIGNAL(stdOut(QString)),this,SIGNAL(stdOutMessage(QString)));
35 connect(m_process,SIGNAL(error(QString)),this,SIGNAL(stdErrMessage(QString)));
36
37 checkEmulatorInstalled();
38}
39
40bool UbuntuEmulatorModel::emulatorInstalled() const
41{
42 return m_emulatorInstalled;
43}
44
45void UbuntuEmulatorModel::setEmulatorInstalled(bool arg)
46{
47 if (m_emulatorInstalled != arg) {
48 m_emulatorInstalled = arg;
49 emit emulatorInstalledChanged(arg);
50 }
51}
52
53bool UbuntuEmulatorModel::busy() const
54{
55 return m_busy;
56}
57
58void UbuntuEmulatorModel::setBusy(bool arg)
59{
60 if (m_busy != arg) {
61 m_busy = arg;
62 emit busyChanged(arg);
63 }
64}
65
66QString UbuntuEmulatorModel::state() const
67{
68 switch(m_state) {
69 case CheckEmulator: {
70 return tr("Checking if emulator tool is installed");
71 break;
72 }
73 case InstallEmulator: {
74 return tr("Installing emulator tool");
75 break;
76 }
77 case CreateEmulatorImage: {
78 return tr("Creating emulator image");
79 break;
80 }
81 case FindImages: {
82 return tr("Searching for emulator images");
83 break;
84 }
85 default:
86 return QString();
87 break;
88 }
89}
90
91void UbuntuEmulatorModel::setState(UbuntuEmulatorModel::State newState)
92{
93 if(m_state != newState) {
94 m_state = newState;
95 if(m_state == UbuntuEmulatorModel::Initial || m_state == UbuntuEmulatorModel::Idle)
96 setBusy(false);
97 else
98 setBusy(true);
99
100 emit stateChanged(state());
101 }
102}
103
104bool UbuntuEmulatorModel::cancellable() const
105{
106 return m_cancellable;
107}
108
109void UbuntuEmulatorModel::setCancellable(bool arg)
110{
111 if (m_cancellable != arg) {
112 m_cancellable = arg;
113 emit cancellableChanged(arg);
114 }
115}
116
117void UbuntuEmulatorModel::beginAction(const QString &msg)
118{
119 emit logMessage(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ACTION_BEGIN).arg(msg));
120}
121
122void UbuntuEmulatorModel::endAction(const QString &msg)
123{
124 emit logMessage(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ACTION_END).arg(msg));
125}
126
127int UbuntuEmulatorModel::rowCount(const QModelIndex &parent) const
128{
129 if(parent.isValid())
130 return 0;
131 return m_data.size();
132}
133
134QVariant UbuntuEmulatorModel::data(const QModelIndex &index, int role) const
135{
136 if(!index.isValid()
137 || index.parent().isValid()
138 || index.row() < 0
139 || index.row() > rowCount())
140 return QVariant();
141
142 switch (role) {
143 case Qt::DisplayRole:
144 case Qt::EditRole:
145 return m_data[index.row()].name;
146 case UbuntuVersionRole:
147 return m_data[index.row()].ubuntuVersion;
148 case DeviceVersionRole:
149 return m_data[index.row()].deviceVersion;
150 case ImageVersionRole:
151 return m_data[index.row()].imageVersion;
152 default:
153 break;
154 }
155 return QVariant();
156}
157
158QHash<int, QByteArray> UbuntuEmulatorModel::roleNames() const
159{
160 QHash<int, QByteArray> rNames = QAbstractListModel::roleNames();
161 rNames.insert(UbuntuVersionRole,"ubuntuVersion");
162 rNames.insert(DeviceVersionRole,"deviceVersion");
163 rNames.insert(ImageVersionRole,"imageVersion");
164 return rNames;
165}
166
167Qt::ItemFlags UbuntuEmulatorModel::flags(const QModelIndex &index) const
168{
169 return QAbstractListModel::flags(index);
170}
171
172void UbuntuEmulatorModel::clear()
173{
174 if(rowCount()) {
175 beginResetModel();
176 m_data.clear();
177 endResetModel();
178 }
179}
180
181void UbuntuEmulatorModel::checkEmulatorInstalled()
182{
183 setState(CheckEmulator);
184 setCancellable(false);
185
186 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_EMULATOR_INSTALLED));
187 m_process->stop();
188 QString sEmulatorPackageName = QLatin1String(Ubuntu::Constants::EMULATOR_PACKAGE_NAME);
189 m_process->append(QStringList()
190 << QString::fromLatin1(Constants::UBUNTUWIDGETS_LOCAL_PACKAGE_INSTALLED_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(sEmulatorPackageName)
191 << QCoreApplication::applicationDirPath());
192 m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_EMULATOR_INSTALLED));
193
194}
195
196void UbuntuEmulatorModel::findEmulatorImages()
197{
198 setState(FindImages);
199 setCancellable(false);
200
201 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES));
202 m_process->stop();
203 m_process->append(QStringList()
204 << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
205 << QCoreApplication::applicationDirPath());
206 m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES));
207}
208
209void UbuntuEmulatorModel::installEmulator()
210{
211 if(m_emulatorInstalled)
212 return;
213
214 setState(InstallEmulator);
215 setCancellable(false);
216
217 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE));
218 QString sEmulatorPackageName = QLatin1String(Ubuntu::Constants::EMULATOR_PACKAGE_NAME);
219 m_process->stop();
220 m_process->append(QStringList()
221 << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(sEmulatorPackageName)
222 << QCoreApplication::applicationDirPath());
223 m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE));
224}
225
226void UbuntuEmulatorModel::createEmulatorImage(const QString &name)
227{
228 setState(CreateEmulatorImage);
229 setCancellable(true);
230
231 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR));
232 m_process->stop();
233 QString strEmulatorName = name;
234 QString strEmulatorPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
235 strEmulatorPath += QDir::separator();
236 strEmulatorPath += QLatin1String(Constants::DEFAULT_EMULATOR_PATH);
237 strEmulatorPath += QDir::separator();
238 m_process->append(QStringList()
239 << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT)
240 .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(strEmulatorPath).arg(strEmulatorName)
241 << QCoreApplication::applicationDirPath());
242 m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR));
243}
244
245void UbuntuEmulatorModel::startEmulator(const QString &name)
246{
247 QStringList args = QStringList() << name;
248 QProcess::startDetached(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
249 ,args
250 ,QCoreApplication::applicationDirPath());
251}
252
253QVariant UbuntuEmulatorModel::validateEmulatorName(const QString &name)
254{
255
256 QString error;
257 bool result = Utils::ProjectNameValidatingLineEdit::validateProjectName(name,&error);
258
259 if(result) {
260 foreach(const EmulatorItem &item, m_data){
261 if(item.name == name) {
262 result = false;
263 error = tr("Emulator name already exists");
264 }
265 }
266 }
267
268 QVariantMap m;
269 m.insert(QStringLiteral("valid"),result);
270 m.insert(QStringLiteral("error"),error);
271 return QVariant::fromValue(m);
272}
273
274void UbuntuEmulatorModel::cancel()
275{
276 if (m_cancellable && m_state == CreateEmulatorImage) {
277 m_process->stop();
278 }
279}
280
281void UbuntuEmulatorModel::onMessage(const QString &msg)
282{
283 if (msg.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_UNABLE_TO_FETCH))) {
284 setEmulatorInstalled(false);
285 }
286 m_reply.append(msg);
287}
288
289void UbuntuEmulatorModel::processFinished(const QString &, int)
290{
291 State lastState = m_state;
292 setCancellable(false);
293
294 setState(UbuntuEmulatorModel::Idle);
295 switch(lastState) {
296 case CheckEmulator: {
297 QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED));
298 foreach(QString line, lines) {
299 line = line.trimmed();
300 if (line.isEmpty()) {
301 continue;
302 }
303 if (line.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_LOCAL_NO_EMULATOR_INSTALLED))) {
304 setEmulatorInstalled(false);
305 } else {
306 QStringList lineData = line.split(QLatin1String(Constants::SPACE));
307 QString sEmulatorPackageStatus = lineData.takeFirst();
308 //QString sEmulatorPackageName = lineData.takeFirst();
309 //QString sEmulatorPackageVersion = lineData.takeFirst();
310 if (sEmulatorPackageStatus.startsWith(QLatin1String(Constants::INSTALLED))) {
311 setEmulatorInstalled(true);
312 findEmulatorImages();
313 }
314 }
315 }
316 break;
317 }
318 case InstallEmulator: {
319 QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED));
320 foreach(QString line, lines) {
321 line = line.trimmed();
322 if (line.isEmpty()) {
323 continue;
324 }
325 if (line.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_LOCAL_NO_EMULATOR_INSTALLED))) {
326 setEmulatorInstalled(false);
327 break;
328 } else {
329 QStringList lineData = line.split(QLatin1String(Constants::SPACE));
330 QString sEmulatorPackageStatus = lineData.takeFirst();
331 //QString sEmulatorPackageName = lineData.takeFirst();
332 //QString sEmulatorPackageVersion = lineData.takeFirst();
333 if (sEmulatorPackageStatus.startsWith(QLatin1String(Constants::INSTALLED))) {
334 setEmulatorInstalled(true);
335 findEmulatorImages();
336 break;
337 }
338 }
339 }
340 break;
341 }
342 case CreateEmulatorImage: {
343 findEmulatorImages();
344 break;
345 }
346 case FindImages: {
347 QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED));
348 clear();
349
350 QList<EmulatorItem> items;
351
352 QMutableStringListIterator iter(lines);
353 QRegularExpression regexName (QStringLiteral("^(\\w+)"));
354 QRegularExpression regexUbuntu (QStringLiteral("ubuntu=([0-9]+)"));
355 QRegularExpression regexDevice (QStringLiteral("device=([0-9]+)"));
356 QRegularExpression regexVersion(QStringLiteral("version=([0-9]+)"));
357 while (iter.hasNext()) {
358 QString line = iter.next();
359 if(line.isEmpty()) {
360 iter.remove();
361 continue;
362 }
363
364 qDebug()<<"Handling emulator: "<<line;
365 QRegularExpressionMatch mName = regexName.match(line);
366 QRegularExpressionMatch mUbu = regexUbuntu.match(line);
367 QRegularExpressionMatch mDev = regexDevice.match(line);
368 QRegularExpressionMatch mVer = regexVersion.match(line);
369
370 if(!mName.hasMatch())
371 continue;
372
373 EmulatorItem item;
374 item.name = mName.captured(1);
375
376 if(mUbu.hasMatch())
377 item.ubuntuVersion = mUbu.captured(1);
378 else
379 item.ubuntuVersion = tr("unknown");
380
381 if(mDev.hasMatch())
382 item.deviceVersion = mDev.captured(1);
383 else
384 item.deviceVersion = tr("unknown");
385
386 if(mVer.hasMatch())
387 item.imageVersion = mVer.captured(1);
388 else
389 item.imageVersion = tr("unknown");
390
391 items.append(item);
392 }
393
394 if(items.count()) {
395 beginResetModel();
396 m_data = items;
397 endResetModel();
398 }
399 break;
400 }
401 default:
402 break;
403 }
404 m_reply.clear();
405}
406
407} // namespace Internal
408} // namespace Ubuntu
0409
=== added file 'src/ubuntu/ubuntuemulatormodel.h'
--- src/ubuntu/ubuntuemulatormodel.h 1970-01-01 00:00:00 +0000
+++ src/ubuntu/ubuntuemulatormodel.h 2014-04-27 13:29:17 +0000
@@ -0,0 +1,102 @@
1#ifndef UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H
2#define UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H
3
4#include "ubuntuprocess.h"
5#include <QAbstractListModel>
6
7namespace Ubuntu {
8namespace Internal {
9
10class UbuntuEmulatorModel : public QAbstractListModel
11{
12 Q_OBJECT
13public:
14
15 enum State {
16 Initial,
17 CheckEmulator,
18 InstallEmulator,
19 CreateEmulatorImage,
20 FindImages,
21 Idle
22 };
23
24 enum Roles {
25 UbuntuVersionRole = Qt::UserRole,
26 DeviceVersionRole,
27 ImageVersionRole
28 };
29
30 struct EmulatorItem {
31 QString name;
32 QString ubuntuVersion;
33 QString deviceVersion;
34 QString imageVersion;
35 };
36
37 Q_PROPERTY(bool emulatorInstalled READ emulatorInstalled WRITE setEmulatorInstalled NOTIFY emulatorInstalledChanged)
38 Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
39 Q_PROPERTY(bool cancellable READ cancellable NOTIFY cancellableChanged)
40 Q_PROPERTY(QString state READ state NOTIFY stateChanged)
41
42 explicit UbuntuEmulatorModel(QObject *parent = 0);
43
44 void setEmulatorInstalled(bool arg);
45 bool emulatorInstalled() const;
46
47 bool busy() const;
48 QString state() const;
49 bool cancellable() const;
50
51 // QAbstractItemModel interface
52 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
53 virtual QVariant data(const QModelIndex &index, int role) const;
54 virtual QHash<int, QByteArray> roleNames() const;
55 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
56
57protected:
58 void clear();
59 void setBusy(bool arg);
60 void setState(State newState);
61 void beginAction (const QString &msg);
62 void endAction (const QString &msg);
63 void setCancellable(bool arg);
64
65public slots:
66 void checkEmulatorInstalled ();
67 void findEmulatorImages ();
68 void installEmulator ();
69 void createEmulatorImage (const QString &name);
70 void startEmulator (const QString &name);
71 QVariant validateEmulatorName ( const QString &name);
72 void cancel ();
73
74protected slots:
75 void onMessage (const QString &msg);
76 void processFinished (const QString &, int);
77
78signals:
79 void emulatorInstalledChanged(bool arg);
80 void busyChanged(bool arg);
81 void stateChanged(const QString &arg);
82 void logMessage (const QString &str);
83 void stdOutMessage (const QString &str);
84 void stdErrMessage (const QString &str);
85
86 void cancellableChanged(bool arg);
87
88private:
89 QString m_reply;
90 UbuntuProcess *m_process;
91 bool m_emulatorInstalled;
92 State m_state;
93 bool m_busy;
94
95 QList<EmulatorItem> m_data;
96 bool m_cancellable;
97};
98
99} // namespace Internal
100} // namespace Ubuntu
101
102#endif // UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H
0103
=== modified file 'src/ubuntu/ubuntukitmanager.cpp'
--- src/ubuntu/ubuntukitmanager.cpp 2014-04-09 15:00:21 +0000
+++ src/ubuntu/ubuntukitmanager.cpp 2014-04-27 13:29:17 +0000
@@ -23,11 +23,24 @@
23 return ProjectExplorer::ToolChainKitInformation::toolChain(a) == ProjectExplorer::ToolChainKitInformation::ToolChainKitInformation::toolChain(b);23 return ProjectExplorer::ToolChainKitInformation::toolChain(a) == ProjectExplorer::ToolChainKitInformation::ToolChainKitInformation::toolChain(b);
24}24}
2525
26static bool lessThanToolchain (const ClickToolChain* left, const ClickToolChain* right)
27{
28 const UbuntuClickTool::Target &leftTarget = left->clickTarget();
29 const UbuntuClickTool::Target &rightTarget = right->clickTarget();
30
31 if(leftTarget.majorVersion < rightTarget.majorVersion)
32 return true;
33 if(leftTarget.minorVersion < rightTarget.minorVersion)
34 return true;
35
36 return false;
37}
38
26UbuntuKitManager::UbuntuKitManager()39UbuntuKitManager::UbuntuKitManager()
27{40{
28}41}
2942
30void UbuntuKitManager::autoDetectKits()43QList<ClickToolChain *> UbuntuKitManager::clickToolChains()
31{44{
32 QList<ClickToolChain *> toolchains;45 QList<ClickToolChain *> toolchains;
33 // having a empty toolchains list will remove all autodetected kits for android46 // having a empty toolchains list will remove all autodetected kits for android
@@ -41,6 +54,42 @@
41 toolchains << static_cast<ClickToolChain *>(tc);54 toolchains << static_cast<ClickToolChain *>(tc);
42 }55 }
43 }56 }
57 return toolchains;
58}
59
60void UbuntuKitManager::autoCreateKit(UbuntuDevice::Ptr device)
61{
62 QList<ClickToolChain*> toolchains = clickToolChains();
63 if(toolchains.size() == 0) {
64 //create target
65 return;
66 }
67
68 qSort(toolchains.begin(),toolchains.end(),lessThanToolchain);
69
70 //right now we are going to use the last toolchain, because its the one
71 //with the highest framework, this needs to be changed once we have x86 targets
72 ClickToolChain* tc = toolchains.last();
73 ProjectExplorer::Kit* newKit = createKit(tc);
74 if(newKit) {
75 fixKit(newKit);
76
77 newKit->setDisplayName(tr("%1 (GCC %2-%3-%4)")
78 .arg(device->displayName())
79 .arg(tc->clickTarget().architecture)
80 .arg(tc->clickTarget().framework)
81 .arg(tc->clickTarget().series));
82
83 ProjectExplorer::DeviceKitInformation::setDevice(newKit,device);
84 ProjectExplorer::KitManager::registerKit(newKit);
85 }
86}
87
88void UbuntuKitManager::autoDetectKits()
89{
90 // having a empty toolchains list will remove all autodetected kits for android
91 // exactly what we want in that case
92 QList<ClickToolChain *> toolchains = clickToolChains();
4493
45 QList<ProjectExplorer::Kit *> existingKits;94 QList<ProjectExplorer::Kit *> existingKits;
46 foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) {95 foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) {
4796
=== modified file 'src/ubuntu/ubuntukitmanager.h'
--- src/ubuntu/ubuntukitmanager.h 2014-04-10 10:56:24 +0000
+++ src/ubuntu/ubuntukitmanager.h 2014-04-27 13:29:17 +0000
@@ -19,6 +19,7 @@
19#define UBUNTU_INTERNAL_UBUNTUKITMANAGER_H19#define UBUNTU_INTERNAL_UBUNTUKITMANAGER_H
2020
21#include "clicktoolchain.h"21#include "clicktoolchain.h"
22#include "ubuntudevice.h"
22#include <projectexplorer/kit.h>23#include <projectexplorer/kit.h>
2324
24namespace Debugger{25namespace Debugger{
@@ -34,10 +35,12 @@
34public:35public:
35 UbuntuKitManager();36 UbuntuKitManager();
3637
38 static void autoCreateKit ( UbuntuDevice::Ptr device );
37 static void autoDetectKits ();39 static void autoDetectKits ();
38 static ProjectExplorer::Kit *createKit (ClickToolChain* tc);40 static ProjectExplorer::Kit *createKit (ClickToolChain* tc);
39 static QVariant createOrFindDebugger(const Utils::FileName &path);41 static QVariant createOrFindDebugger(const Utils::FileName &path);
40 static void fixKit (ProjectExplorer::Kit* k);42 static void fixKit (ProjectExplorer::Kit* k);
43 static QList<ClickToolChain *> clickToolChains();
41};44};
4245
43} // namespace Internal46} // namespace Internal
4447
=== modified file 'src/ubuntu/ubuntumenu.cpp'
--- src/ubuntu/ubuntumenu.cpp 2014-04-15 07:51:40 +0000
+++ src/ubuntu/ubuntumenu.cpp 2014-04-27 13:29:17 +0000
@@ -19,7 +19,7 @@
19#include "ubuntumenu.h"19#include "ubuntumenu.h"
20#include "ubuntushared.h"20#include "ubuntushared.h"
21#include "ubuntuconstants.h"21#include "ubuntuconstants.h"
22#include "ubuntudeviceswidget.h"22#include "ubuntudevicemode.h"
23#include "ubuntuproject.h"23#include "ubuntuproject.h"
24#include "ubuntuclicktool.h"24#include "ubuntuclicktool.h"
25#include "ubuntudevice.h"25#include "ubuntudevice.h"
@@ -82,7 +82,7 @@
82 connect(&m_ubuntuProcess,SIGNAL(error(QString)),this,SLOT(onError(QString)));82 connect(&m_ubuntuProcess,SIGNAL(error(QString)),this,SLOT(onError(QString)));
8383
84 connect(ProjectExplorer::ProjectExplorerPlugin::instance(),SIGNAL(updateRunActions()),this,SLOT(slotUpdateActions()));84 connect(ProjectExplorer::ProjectExplorerPlugin::instance(),SIGNAL(updateRunActions()),this,SLOT(slotUpdateActions()));
85 connect(UbuntuDevicesWidget::instance(),SIGNAL(updateDeviceActions()),this,SLOT(slotUpdateActions()));85 connect(UbuntuDeviceMode::instance(),SIGNAL(updateDeviceActions()),this,SLOT(slotUpdateActions()));
86}86}
8787
8888
@@ -103,7 +103,7 @@
103103
104 //bool canRun = projectExplorerInstance->canRun(startupProject,ProjectExplorer::NormalRunMode);104 //bool canRun = projectExplorerInstance->canRun(startupProject,ProjectExplorer::NormalRunMode);
105 bool projectOpen = (startupProject!=NULL);105 bool projectOpen = (startupProject!=NULL);
106 bool deviceDetected = UbuntuDevicesWidget::instance()->deviceDetected();106 bool deviceDetected = !UbuntuDeviceMode::instance()->device().isNull();
107107
108 foreach(QAction* act, m_actions) {108 foreach(QAction* act, m_actions) {
109 bool requiresDevice = act->property(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED).toBool();109 bool requiresDevice = act->property(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED).toBool();
@@ -475,8 +475,13 @@
475 }475 }
476 }476 }
477477
478 UbuntuDevice::ConstPtr device = UbuntuDevicesWidget::instance()->device();478 UbuntuDevice::ConstPtr device = UbuntuDeviceMode::instance()->device();
479 if (device) {479 if (device) {
480 if( device->deviceState() != ProjectExplorer::IDevice::DeviceReadyToUse ) {
481 QMessageBox::warning(0,tr("Device not ready"),tr("The currently selected device is not ready, please select another one on the devices mode"));
482 return;
483 }
484
480 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_IP),device->sshParameters().host);485 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_IP),device->sshParameters().host);
481 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_USERNAME),device->sshParameters().userName);486 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_USERNAME),device->sshParameters().userName);
482 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_PORT),QString::number(device->sshParameters().port));487 command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_PORT),QString::number(device->sshParameters().port));
483488
=== modified file 'src/ubuntu/ubuntuplugin.cpp'
--- src/ubuntu/ubuntuplugin.cpp 2014-04-10 18:50:24 +0000
+++ src/ubuntu/ubuntuplugin.cpp 2014-04-27 13:29:17 +0000
@@ -31,6 +31,7 @@
31#include "ubuntucmakebuildconfiguration.h"31#include "ubuntucmakebuildconfiguration.h"
32#include "ubunturemotedeployconfiguration.h"32#include "ubunturemotedeployconfiguration.h"
33#include "ubuntulocaldeployconfiguration.h"33#include "ubuntulocaldeployconfiguration.h"
34#include "ubuntudevicesmodel.h"
34#include "localportsmanager.h"35#include "localportsmanager.h"
3536
36#include <coreplugin/modemanager.h>37#include <coreplugin/modemanager.h>
@@ -42,6 +43,7 @@
42#include <QDebug>43#include <QDebug>
43#include <QFileInfo>44#include <QFileInfo>
44#include <QGuiApplication>45#include <QGuiApplication>
46#include <QtQml>
4547
46using namespace Ubuntu;48using namespace Ubuntu;
47using namespace Ubuntu::Internal;49using namespace Ubuntu::Internal;
@@ -61,8 +63,9 @@
61 Q_UNUSED(arguments)63 Q_UNUSED(arguments)
62 Q_UNUSED(errorString)64 Q_UNUSED(errorString)
6365
66 qmlRegisterUncreatableType<UbuntuDeviceStates>("Ubuntu.DevicesModel",0,1,"States",QStringLiteral("Not instantiable"));
67
64 const QLatin1String mimetypesXml(Constants::UBUNTU_MIMETYPE_XML);68 const QLatin1String mimetypesXml(Constants::UBUNTU_MIMETYPE_XML);
65
66 if (!Core::MimeDatabase::addMimeTypes(mimetypesXml, errorString))69 if (!Core::MimeDatabase::addMimeTypes(mimetypesXml, errorString))
67 return false;70 return false;
6871
6972
=== modified file 'src/ubuntu/ubuntuprocess.cpp'
--- src/ubuntu/ubuntuprocess.cpp 2014-03-06 09:43:48 +0000
+++ src/ubuntu/ubuntuprocess.cpp 2014-04-27 13:29:17 +0000
@@ -122,11 +122,8 @@
122 emit finished(m_currentProcess->program(), code);122 emit finished(m_currentProcess->program(), code);
123 return;123 return;
124 }124 }
125 QString errorMsg = QString::fromLocal8Bit(m_currentProcess->readAllStandardError());
126 if (errorMsg.trimmed().length()>0) emit error(errorMsg);
127 QString msg = QString::fromLocal8Bit(m_currentProcess->readAllStandardOutput());
128 if (msg.trimmed().length()>0) emit message(msg);
129125
126 processReadyRead();
130 emit finished(m_currentProcess->program(), code);127 emit finished(m_currentProcess->program(), code);
131 emit finished(m_currentProcess,m_currentProcess->program(),code);128 emit finished(m_currentProcess,m_currentProcess->program(),code);
132 processCmdQueue();129 processCmdQueue();
@@ -135,10 +132,12 @@
135void UbuntuProcess::processReadyRead() {132void UbuntuProcess::processReadyRead() {
136 QString stderr = QString::fromLocal8Bit(m_currentProcess->readAllStandardError());133 QString stderr = QString::fromLocal8Bit(m_currentProcess->readAllStandardError());
137 QString stdout = QString::fromLocal8Bit(m_currentProcess->readAllStandardOutput());134 QString stdout = QString::fromLocal8Bit(m_currentProcess->readAllStandardOutput());
138 if (!stderr.isEmpty()) {135 if (!stderr.trimmed().isEmpty()) {
136 emit error(stderr);
139 emit message(stderr);137 emit message(stderr);
140 }138 }
141 if (!stdout.isEmpty()) {139 if (!stdout.trimmed().isEmpty()) {
140 emit stdOut(stdout);
142 emit message(stdout);141 emit message(stdout);
143 }142 }
144}143}
145144
=== modified file 'src/ubuntu/ubuntuprocess.h'
--- src/ubuntu/ubuntuprocess.h 2014-03-06 09:43:48 +0000
+++ src/ubuntu/ubuntuprocess.h 2014-04-27 13:29:17 +0000
@@ -45,8 +45,9 @@
45 void start(QString taskTitle);45 void start(QString taskTitle);
4646
47signals:47signals:
48 void message(QString);48 void message(const QString&);
49 void error(QString);49 void error (const QString&);
50 void stdOut(const QString&);
50 void finished(QString,int);51 void finished(QString,int);
51 void finished(const QProcess*,QString,int);52 void finished(const QProcess*,QString,int);
52 void started(QString);53 void started(QString);
5354
=== modified file 'src/ubuntu/ubunturemoterunconfiguration.cpp'
--- src/ubuntu/ubunturemoterunconfiguration.cpp 2014-04-10 11:04:55 +0000
+++ src/ubuntu/ubunturemoterunconfiguration.cpp 2014-04-27 13:29:17 +0000
@@ -95,6 +95,8 @@
95 env.appendOrSet(QLatin1String("QML2_IMPORT_PATH"),95 env.appendOrSet(QLatin1String("QML2_IMPORT_PATH"),
96 QString::fromLatin1("lib/%1").arg(clickTc->gnutriplet()),96 QString::fromLatin1("lib/%1").arg(clickTc->gnutriplet()),
97 QString::fromLatin1(":"));97 QString::fromLatin1(":"));
98 env.prependOrSetPath(QStringLiteral("lib/")+clickTc->gnutriplet()+QStringLiteral("/bin"));
99 env.appendOrSetPath(QStringLiteral("$PATH"));
98 }100 }
99 env.appendOrSet(QLatin1String("pkgdir"),workingDirectory());101 env.appendOrSet(QLatin1String("pkgdir"),workingDirectory());
100 env.appendOrSet(QLatin1String("APP_ID"),m_appId);102 env.appendOrSet(QLatin1String("APP_ID"),m_appId);
@@ -199,16 +201,24 @@
199 return false;201 return false;
200 } else {202 } else {
201 //looks like a application without a launcher203 //looks like a application without a launcher
202 m_localExecutable = target()->activeBuildConfiguration()->buildDirectory().toString()204 CMakeProjectManager::CMakeProject* pro = static_cast<CMakeProjectManager::CMakeProject*> (target()->project());
203 + QDir::separator()205 foreach(const CMakeProjectManager::CMakeBuildTarget &t, pro->buildTargets()) {
204 + QLatin1String(Constants::UBUNTU_DEPLOY_DESTDIR)206 if(t.library || t.executable.isEmpty())
205 + QDir::separator()207 continue;
206 + command;208
207209 QFileInfo execInfo(t.executable);
208 m_remoteExecutable = workingDirectory()210
209 + QDir::separator()211 if(execInfo.fileName() == commInfo.fileName())
210 + command;212 m_localExecutable = t.executable;
211213 }
214
215 if (m_localExecutable.isEmpty()) {
216 if(errorMessage)
217 *errorMessage = tr("Could not find %1 in the project targets").arg(command);
218 return false;
219 }
220
221 m_remoteExecutable = command;
212 }222 }
213223
214 QFileInfo desk(m_desktopFile);224 QFileInfo desk(m_desktopFile);
215225
=== modified file 'src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp'
--- src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp 2014-04-10 12:29:54 +0000
+++ src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp 2014-04-27 13:29:17 +0000
@@ -18,7 +18,6 @@
1818
19#include "ubuntusettingsdeviceconnectivitywidget.h"19#include "ubuntusettingsdeviceconnectivitywidget.h"
20#include "ui_ubuntusettingsdeviceconnectivitywidget.h"20#include "ui_ubuntusettingsdeviceconnectivitywidget.h"
21#include "ubuntudeviceswidget.h"
22#include "ubuntuconstants.h"21#include "ubuntuconstants.h"
2322
24using namespace Ubuntu;23using namespace Ubuntu;

Subscribers

People subscribed via source and target branches