From 4e7d0d9c9ac3d1caa2b6f3ed0d9e0b2347507d70 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 20 Sep 2011 12:16:36 +0200 Subject: Introduce new "Madde" plugin. The new plugin contains everything specific to Maemo and MeeGo as supported by the MADDE framework. This leaves the RemoteLinux plugin with abstract base classes and generic implementations. Change-Id: I6068caa758214cf26a27fe9893e0817b7834b580 Reviewed-on: http://codereview.qt-project.org/5230 Reviewed-by: Tobias Hunger --- src/plugins/madde/Madde.pluginspec.in | 19 + src/plugins/madde/images/qemu-run.png | Bin 0 -> 1885 bytes src/plugins/madde/images/qemu-stop.png | Bin 0 -> 1790 bytes src/plugins/madde/images/qemu.xcf | Bin 0 -> 6050 bytes src/plugins/madde/madde.pri | 3 + src/plugins/madde/madde.pro | 117 ++ src/plugins/madde/madde_dependencies.pri | 1 + src/plugins/madde/madde_exports.h | 44 + .../madde/maddedeviceconfigurationfactory.cpp | 120 ++ .../madde/maddedeviceconfigurationfactory.h | 59 + src/plugins/madde/maddedevicetester.cpp | 291 +++++ src/plugins/madde/maddedevicetester.h | 85 ++ src/plugins/madde/maddeplugin.cpp | 90 ++ src/plugins/madde/maddeplugin.h | 55 + .../madde/maddeuploadandinstallpackagesteps.cpp | 220 ++++ .../madde/maddeuploadandinstallpackagesteps.h | 90 ++ src/plugins/madde/maemoconstants.h | 65 ++ src/plugins/madde/maemodebugsupport.cpp | 56 + src/plugins/madde/maemodebugsupport.h | 58 + src/plugins/madde/maemodeploybymountsteps.cpp | 495 ++++++++ src/plugins/madde/maemodeploybymountsteps.h | 89 ++ .../madde/maemodeployconfigurationwidget.cpp | 214 ++++ src/plugins/madde/maemodeployconfigurationwidget.h | 84 ++ .../madde/maemodeployconfigurationwidget.ui | 48 + src/plugins/madde/maemodeploymentmounter.cpp | 215 ++++ src/plugins/madde/maemodeploymentmounter.h | 108 ++ src/plugins/madde/maemodeploystepfactory.cpp | 204 ++++ src/plugins/madde/maemodeploystepfactory.h | 69 ++ src/plugins/madde/maemodeviceconfigwizard.cpp | 640 +++++++++++ src/plugins/madde/maemodeviceconfigwizard.h | 61 + .../maemodeviceconfigwizardkeycreationpage.ui | 79 ++ .../maemodeviceconfigwizardkeydeploymentpage.ui | 159 +++ ...odeviceconfigwizardpreviouskeysetupcheckpage.ui | 96 ++ .../maemodeviceconfigwizardreusekeyscheckpage.ui | 133 +++ .../madde/maemodeviceconfigwizardstartpage.ui | 133 +++ src/plugins/madde/maemoglobal.cpp | 297 +++++ src/plugins/madde/maemoglobal.h | 135 +++ src/plugins/madde/maemoinstalltosysrootstep.cpp | 422 +++++++ src/plugins/madde/maemoinstalltosysrootstep.h | 142 +++ src/plugins/madde/maemomountspecification.cpp | 48 + src/plugins/madde/maemomountspecification.h | 53 + src/plugins/madde/maemopackagecreationfactory.cpp | 155 +++ src/plugins/madde/maemopackagecreationfactory.h | 68 ++ src/plugins/madde/maemopackagecreationstep.cpp | 511 +++++++++ src/plugins/madde/maemopackagecreationstep.h | 154 +++ src/plugins/madde/maemopackagecreationwidget.cpp | 283 +++++ src/plugins/madde/maemopackagecreationwidget.h | 83 ++ src/plugins/madde/maemopackagecreationwidget.ui | 353 ++++++ src/plugins/madde/maemopackageinstaller.cpp | 101 ++ src/plugins/madde/maemopackageinstaller.h | 74 ++ src/plugins/madde/maemopublishedprojectmodel.cpp | 135 +++ src/plugins/madde/maemopublishedprojectmodel.h | 68 ++ src/plugins/madde/maemopublisherfremantlefree.cpp | 645 +++++++++++ src/plugins/madde/maemopublisherfremantlefree.h | 128 +++ ...emopublishingbuildsettingspagefremantlefree.cpp | 119 ++ ...maemopublishingbuildsettingspagefremantlefree.h | 75 ++ ...aemopublishingbuildsettingspagefremantlefree.ui | 75 ++ .../madde/maemopublishingfileselectiondialog.cpp | 65 ++ .../madde/maemopublishingfileselectiondialog.h | 65 ++ .../madde/maemopublishingfileselectiondialog.ui | 78 ++ .../maemopublishingresultpagefremantlefree.cpp | 108 ++ .../madde/maemopublishingresultpagefremantlefree.h | 77 ++ .../maemopublishingresultpagefremantlefree.ui | 33 + ...mopublishinguploadsettingspagefremantlefree.cpp | 116 ++ ...aemopublishinguploadsettingspagefremantlefree.h | 73 ++ ...emopublishinguploadsettingspagefremantlefree.ui | 95 ++ .../madde/maemopublishingwizardfactories.cpp | 102 ++ src/plugins/madde/maemopublishingwizardfactories.h | 60 + .../madde/maemopublishingwizardfremantlefree.cpp | 81 ++ .../madde/maemopublishingwizardfremantlefree.h | 68 ++ src/plugins/madde/maemoqemumanager.cpp | 628 ++++++++++ src/plugins/madde/maemoqemumanager.h | 149 +++ src/plugins/madde/maemoqemuruntime.h | 91 ++ src/plugins/madde/maemoqemuruntimeparser.cpp | 433 +++++++ src/plugins/madde/maemoqemuruntimeparser.h | 64 ++ src/plugins/madde/maemoqemusettings.cpp | 71 ++ src/plugins/madde/maemoqemusettings.h | 56 + src/plugins/madde/maemoqemusettingswidget.cpp | 86 ++ src/plugins/madde/maemoqemusettingswidget.h | 63 ++ src/plugins/madde/maemoqemusettingswidget.ui | 64 ++ src/plugins/madde/maemoqtversion.cpp | 198 ++++ src/plugins/madde/maemoqtversion.h | 72 ++ src/plugins/madde/maemoqtversionfactory.cpp | 91 ++ src/plugins/madde/maemoqtversionfactory.h | 57 + src/plugins/madde/maemoremotecopyfacility.cpp | 161 +++ src/plugins/madde/maemoremotecopyfacility.h | 94 ++ src/plugins/madde/maemoremotemounter.cpp | 413 +++++++ src/plugins/madde/maemoremotemounter.h | 150 +++ src/plugins/madde/maemoremotemountsmodel.cpp | 190 ++++ src/plugins/madde/maemoremotemountsmodel.h | 99 ++ src/plugins/madde/maemorunconfiguration.cpp | 202 ++++ src/plugins/madde/maemorunconfiguration.h | 81 ++ src/plugins/madde/maemorunconfigurationwidget.cpp | 249 ++++ src/plugins/madde/maemorunconfigurationwidget.h | 86 ++ src/plugins/madde/maemoruncontrol.cpp | 68 ++ src/plugins/madde/maemoruncontrol.h | 66 ++ src/plugins/madde/maemorunfactories.cpp | 200 ++++ src/plugins/madde/maemorunfactories.h | 90 ++ src/plugins/madde/maemosettingspages.cpp | 178 +++ src/plugins/madde/maemosettingspages.h | 70 ++ src/plugins/madde/maemosshrunner.cpp | 235 ++++ src/plugins/madde/maemosshrunner.h | 82 ++ src/plugins/madde/maemotoolchain.cpp | 296 +++++ src/plugins/madde/maemotoolchain.h | 123 ++ src/plugins/madde/qt-maemo.qrc | 6 + src/plugins/madde/qt4maemodeployconfiguration.cpp | 254 +++++ src/plugins/madde/qt4maemodeployconfiguration.h | 96 ++ src/plugins/madde/qt4maemotarget.cpp | 1197 ++++++++++++++++++++ src/plugins/madde/qt4maemotarget.h | 296 +++++ src/plugins/madde/qt4maemotargetfactory.cpp | 228 ++++ src/plugins/madde/qt4maemotargetfactory.h | 71 ++ src/plugins/plugins.pro | 4 + src/plugins/qttest/testconfigurations.cpp | 12 +- src/plugins/remotelinux/images/qemu-run.png | Bin 1885 -> 0 bytes src/plugins/remotelinux/images/qemu-stop.png | Bin 1790 -> 0 bytes src/plugins/remotelinux/images/qemu.xcf | Bin 6050 -> 0 bytes .../maddedeviceconfigurationfactory.cpp | 118 -- .../remotelinux/maddedeviceconfigurationfactory.h | 59 - src/plugins/remotelinux/maddedevicetester.cpp | 290 ----- src/plugins/remotelinux/maddedevicetester.h | 85 -- .../maddeuploadandinstallpackagesteps.cpp | 218 ---- .../maddeuploadandinstallpackagesteps.h | 88 -- src/plugins/remotelinux/maemoconstants.h | 65 -- src/plugins/remotelinux/maemodebugsupport.cpp | 54 - src/plugins/remotelinux/maemodebugsupport.h | 58 - .../remotelinux/maemodeploybymountsteps.cpp | 494 -------- src/plugins/remotelinux/maemodeploybymountsteps.h | 89 -- .../remotelinux/maemodeployconfigurationwidget.cpp | 212 ---- .../remotelinux/maemodeployconfigurationwidget.h | 82 -- .../remotelinux/maemodeployconfigurationwidget.ui | 48 - src/plugins/remotelinux/maemodeploymentmounter.cpp | 214 ---- src/plugins/remotelinux/maemodeploymentmounter.h | 105 -- src/plugins/remotelinux/maemodeploystepfactory.cpp | 203 ---- src/plugins/remotelinux/maemodeploystepfactory.h | 69 -- .../remotelinux/maemodeviceconfigwizard.cpp | 639 ----------- src/plugins/remotelinux/maemodeviceconfigwizard.h | 61 - .../maemodeviceconfigwizardkeycreationpage.ui | 79 -- .../maemodeviceconfigwizardkeydeploymentpage.ui | 159 --- ...odeviceconfigwizardpreviouskeysetupcheckpage.ui | 96 -- .../maemodeviceconfigwizardreusekeyscheckpage.ui | 133 --- .../maemodeviceconfigwizardstartpage.ui | 133 --- src/plugins/remotelinux/maemoglobal.cpp | 296 ----- src/plugins/remotelinux/maemoglobal.h | 134 --- .../remotelinux/maemoinstalltosysrootstep.cpp | 421 ------- .../remotelinux/maemoinstalltosysrootstep.h | 140 --- .../remotelinux/maemomountspecification.cpp | 48 - src/plugins/remotelinux/maemomountspecification.h | 54 - .../remotelinux/maemopackagecreationfactory.cpp | 155 --- .../remotelinux/maemopackagecreationfactory.h | 68 -- .../remotelinux/maemopackagecreationstep.cpp | 511 --------- src/plugins/remotelinux/maemopackagecreationstep.h | 152 --- .../remotelinux/maemopackagecreationwidget.cpp | 283 ----- .../remotelinux/maemopackagecreationwidget.h | 83 -- .../remotelinux/maemopackagecreationwidget.ui | 353 ------ src/plugins/remotelinux/maemopackageinstaller.cpp | 101 -- src/plugins/remotelinux/maemopackageinstaller.h | 74 -- .../remotelinux/maemopublishedprojectmodel.cpp | 135 --- .../remotelinux/maemopublishedprojectmodel.h | 68 -- .../remotelinux/maemopublisherfremantlefree.cpp | 644 ----------- .../remotelinux/maemopublisherfremantlefree.h | 128 --- ...emopublishingbuildsettingspagefremantlefree.cpp | 119 -- ...maemopublishingbuildsettingspagefremantlefree.h | 75 -- ...aemopublishingbuildsettingspagefremantlefree.ui | 75 -- .../maemopublishingfileselectiondialog.cpp | 65 -- .../maemopublishingfileselectiondialog.h | 65 -- .../maemopublishingfileselectiondialog.ui | 78 -- .../maemopublishingresultpagefremantlefree.cpp | 108 -- .../maemopublishingresultpagefremantlefree.h | 77 -- .../maemopublishingresultpagefremantlefree.ui | 33 - ...mopublishinguploadsettingspagefremantlefree.cpp | 116 -- ...aemopublishinguploadsettingspagefremantlefree.h | 73 -- ...emopublishinguploadsettingspagefremantlefree.ui | 95 -- .../remotelinux/maemopublishingwizardfactories.cpp | 102 -- .../remotelinux/maemopublishingwizardfactories.h | 60 - .../maemopublishingwizardfremantlefree.cpp | 81 -- .../maemopublishingwizardfremantlefree.h | 68 -- src/plugins/remotelinux/maemoqemumanager.cpp | 623 ---------- src/plugins/remotelinux/maemoqemumanager.h | 147 --- src/plugins/remotelinux/maemoqemuruntime.h | 91 -- src/plugins/remotelinux/maemoqemuruntimeparser.cpp | 431 ------- src/plugins/remotelinux/maemoqemuruntimeparser.h | 64 -- src/plugins/remotelinux/maemoqemusettings.cpp | 71 -- src/plugins/remotelinux/maemoqemusettings.h | 56 - .../remotelinux/maemoqemusettingswidget.cpp | 86 -- src/plugins/remotelinux/maemoqemusettingswidget.h | 63 -- src/plugins/remotelinux/maemoqemusettingswidget.ui | 64 -- src/plugins/remotelinux/maemoqtversion.cpp | 198 ---- src/plugins/remotelinux/maemoqtversion.h | 72 -- src/plugins/remotelinux/maemoqtversionfactory.cpp | 91 -- src/plugins/remotelinux/maemoqtversionfactory.h | 57 - .../remotelinux/maemoremotecopyfacility.cpp | 160 --- src/plugins/remotelinux/maemoremotecopyfacility.h | 92 -- src/plugins/remotelinux/maemoremotemounter.cpp | 412 ------- src/plugins/remotelinux/maemoremotemounter.h | 148 --- src/plugins/remotelinux/maemoremotemountsmodel.cpp | 190 ---- src/plugins/remotelinux/maemoremotemountsmodel.h | 99 -- src/plugins/remotelinux/maemorunconfiguration.cpp | 201 ---- src/plugins/remotelinux/maemorunconfiguration.h | 81 -- .../remotelinux/maemorunconfigurationwidget.cpp | 248 ---- .../remotelinux/maemorunconfigurationwidget.h | 84 -- src/plugins/remotelinux/maemoruncontrol.cpp | 67 -- src/plugins/remotelinux/maemoruncontrol.h | 64 -- src/plugins/remotelinux/maemorunfactories.cpp | 199 ---- src/plugins/remotelinux/maemorunfactories.h | 90 -- src/plugins/remotelinux/maemosettingspages.cpp | 178 --- src/plugins/remotelinux/maemosettingspages.h | 70 -- src/plugins/remotelinux/maemosshrunner.cpp | 234 ---- src/plugins/remotelinux/maemosshrunner.h | 81 -- src/plugins/remotelinux/maemotoolchain.cpp | 296 ----- src/plugins/remotelinux/maemotoolchain.h | 124 -- src/plugins/remotelinux/qt-maemo.qrc | 6 - .../remotelinux/qt4maemodeployconfiguration.cpp | 253 ----- .../remotelinux/qt4maemodeployconfiguration.h | 94 -- src/plugins/remotelinux/qt4maemotarget.cpp | 1197 -------------------- src/plugins/remotelinux/qt4maemotarget.h | 296 ----- src/plugins/remotelinux/qt4maemotargetfactory.cpp | 229 ---- src/plugins/remotelinux/qt4maemotargetfactory.h | 71 -- src/plugins/remotelinux/remotelinux.pro | 103 -- .../remotelinuxdeployconfigurationwidget.h | 2 +- src/plugins/remotelinux/remotelinuxplugin.cpp | 24 - 220 files changed, 16760 insertions(+), 16501 deletions(-) create mode 100644 src/plugins/madde/Madde.pluginspec.in create mode 100644 src/plugins/madde/images/qemu-run.png create mode 100644 src/plugins/madde/images/qemu-stop.png create mode 100644 src/plugins/madde/images/qemu.xcf create mode 100644 src/plugins/madde/madde.pri create mode 100644 src/plugins/madde/madde.pro create mode 100644 src/plugins/madde/madde_dependencies.pri create mode 100644 src/plugins/madde/madde_exports.h create mode 100644 src/plugins/madde/maddedeviceconfigurationfactory.cpp create mode 100644 src/plugins/madde/maddedeviceconfigurationfactory.h create mode 100644 src/plugins/madde/maddedevicetester.cpp create mode 100644 src/plugins/madde/maddedevicetester.h create mode 100644 src/plugins/madde/maddeplugin.cpp create mode 100644 src/plugins/madde/maddeplugin.h create mode 100644 src/plugins/madde/maddeuploadandinstallpackagesteps.cpp create mode 100644 src/plugins/madde/maddeuploadandinstallpackagesteps.h create mode 100644 src/plugins/madde/maemoconstants.h create mode 100644 src/plugins/madde/maemodebugsupport.cpp create mode 100644 src/plugins/madde/maemodebugsupport.h create mode 100644 src/plugins/madde/maemodeploybymountsteps.cpp create mode 100644 src/plugins/madde/maemodeploybymountsteps.h create mode 100644 src/plugins/madde/maemodeployconfigurationwidget.cpp create mode 100644 src/plugins/madde/maemodeployconfigurationwidget.h create mode 100644 src/plugins/madde/maemodeployconfigurationwidget.ui create mode 100644 src/plugins/madde/maemodeploymentmounter.cpp create mode 100644 src/plugins/madde/maemodeploymentmounter.h create mode 100644 src/plugins/madde/maemodeploystepfactory.cpp create mode 100644 src/plugins/madde/maemodeploystepfactory.h create mode 100644 src/plugins/madde/maemodeviceconfigwizard.cpp create mode 100644 src/plugins/madde/maemodeviceconfigwizard.h create mode 100644 src/plugins/madde/maemodeviceconfigwizardkeycreationpage.ui create mode 100644 src/plugins/madde/maemodeviceconfigwizardkeydeploymentpage.ui create mode 100644 src/plugins/madde/maemodeviceconfigwizardpreviouskeysetupcheckpage.ui create mode 100644 src/plugins/madde/maemodeviceconfigwizardreusekeyscheckpage.ui create mode 100644 src/plugins/madde/maemodeviceconfigwizardstartpage.ui create mode 100644 src/plugins/madde/maemoglobal.cpp create mode 100644 src/plugins/madde/maemoglobal.h create mode 100644 src/plugins/madde/maemoinstalltosysrootstep.cpp create mode 100644 src/plugins/madde/maemoinstalltosysrootstep.h create mode 100644 src/plugins/madde/maemomountspecification.cpp create mode 100644 src/plugins/madde/maemomountspecification.h create mode 100644 src/plugins/madde/maemopackagecreationfactory.cpp create mode 100644 src/plugins/madde/maemopackagecreationfactory.h create mode 100644 src/plugins/madde/maemopackagecreationstep.cpp create mode 100644 src/plugins/madde/maemopackagecreationstep.h create mode 100644 src/plugins/madde/maemopackagecreationwidget.cpp create mode 100644 src/plugins/madde/maemopackagecreationwidget.h create mode 100644 src/plugins/madde/maemopackagecreationwidget.ui create mode 100644 src/plugins/madde/maemopackageinstaller.cpp create mode 100644 src/plugins/madde/maemopackageinstaller.h create mode 100644 src/plugins/madde/maemopublishedprojectmodel.cpp create mode 100644 src/plugins/madde/maemopublishedprojectmodel.h create mode 100644 src/plugins/madde/maemopublisherfremantlefree.cpp create mode 100644 src/plugins/madde/maemopublisherfremantlefree.h create mode 100644 src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.cpp create mode 100644 src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.h create mode 100644 src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.ui create mode 100644 src/plugins/madde/maemopublishingfileselectiondialog.cpp create mode 100644 src/plugins/madde/maemopublishingfileselectiondialog.h create mode 100644 src/plugins/madde/maemopublishingfileselectiondialog.ui create mode 100644 src/plugins/madde/maemopublishingresultpagefremantlefree.cpp create mode 100644 src/plugins/madde/maemopublishingresultpagefremantlefree.h create mode 100644 src/plugins/madde/maemopublishingresultpagefremantlefree.ui create mode 100644 src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.cpp create mode 100644 src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.h create mode 100644 src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.ui create mode 100644 src/plugins/madde/maemopublishingwizardfactories.cpp create mode 100644 src/plugins/madde/maemopublishingwizardfactories.h create mode 100644 src/plugins/madde/maemopublishingwizardfremantlefree.cpp create mode 100644 src/plugins/madde/maemopublishingwizardfremantlefree.h create mode 100644 src/plugins/madde/maemoqemumanager.cpp create mode 100644 src/plugins/madde/maemoqemumanager.h create mode 100644 src/plugins/madde/maemoqemuruntime.h create mode 100644 src/plugins/madde/maemoqemuruntimeparser.cpp create mode 100644 src/plugins/madde/maemoqemuruntimeparser.h create mode 100644 src/plugins/madde/maemoqemusettings.cpp create mode 100644 src/plugins/madde/maemoqemusettings.h create mode 100644 src/plugins/madde/maemoqemusettingswidget.cpp create mode 100644 src/plugins/madde/maemoqemusettingswidget.h create mode 100644 src/plugins/madde/maemoqemusettingswidget.ui create mode 100644 src/plugins/madde/maemoqtversion.cpp create mode 100644 src/plugins/madde/maemoqtversion.h create mode 100644 src/plugins/madde/maemoqtversionfactory.cpp create mode 100644 src/plugins/madde/maemoqtversionfactory.h create mode 100644 src/plugins/madde/maemoremotecopyfacility.cpp create mode 100644 src/plugins/madde/maemoremotecopyfacility.h create mode 100644 src/plugins/madde/maemoremotemounter.cpp create mode 100644 src/plugins/madde/maemoremotemounter.h create mode 100644 src/plugins/madde/maemoremotemountsmodel.cpp create mode 100644 src/plugins/madde/maemoremotemountsmodel.h create mode 100644 src/plugins/madde/maemorunconfiguration.cpp create mode 100644 src/plugins/madde/maemorunconfiguration.h create mode 100644 src/plugins/madde/maemorunconfigurationwidget.cpp create mode 100644 src/plugins/madde/maemorunconfigurationwidget.h create mode 100644 src/plugins/madde/maemoruncontrol.cpp create mode 100644 src/plugins/madde/maemoruncontrol.h create mode 100644 src/plugins/madde/maemorunfactories.cpp create mode 100644 src/plugins/madde/maemorunfactories.h create mode 100644 src/plugins/madde/maemosettingspages.cpp create mode 100644 src/plugins/madde/maemosettingspages.h create mode 100644 src/plugins/madde/maemosshrunner.cpp create mode 100644 src/plugins/madde/maemosshrunner.h create mode 100644 src/plugins/madde/maemotoolchain.cpp create mode 100644 src/plugins/madde/maemotoolchain.h create mode 100644 src/plugins/madde/qt-maemo.qrc create mode 100644 src/plugins/madde/qt4maemodeployconfiguration.cpp create mode 100644 src/plugins/madde/qt4maemodeployconfiguration.h create mode 100644 src/plugins/madde/qt4maemotarget.cpp create mode 100644 src/plugins/madde/qt4maemotarget.h create mode 100644 src/plugins/madde/qt4maemotargetfactory.cpp create mode 100644 src/plugins/madde/qt4maemotargetfactory.h delete mode 100644 src/plugins/remotelinux/images/qemu-run.png delete mode 100644 src/plugins/remotelinux/images/qemu-stop.png delete mode 100644 src/plugins/remotelinux/images/qemu.xcf delete mode 100644 src/plugins/remotelinux/maddedeviceconfigurationfactory.cpp delete mode 100644 src/plugins/remotelinux/maddedeviceconfigurationfactory.h delete mode 100644 src/plugins/remotelinux/maddedevicetester.cpp delete mode 100644 src/plugins/remotelinux/maddedevicetester.h delete mode 100644 src/plugins/remotelinux/maddeuploadandinstallpackagesteps.cpp delete mode 100644 src/plugins/remotelinux/maddeuploadandinstallpackagesteps.h delete mode 100644 src/plugins/remotelinux/maemoconstants.h delete mode 100644 src/plugins/remotelinux/maemodebugsupport.cpp delete mode 100644 src/plugins/remotelinux/maemodebugsupport.h delete mode 100644 src/plugins/remotelinux/maemodeploybymountsteps.cpp delete mode 100644 src/plugins/remotelinux/maemodeploybymountsteps.h delete mode 100644 src/plugins/remotelinux/maemodeployconfigurationwidget.cpp delete mode 100644 src/plugins/remotelinux/maemodeployconfigurationwidget.h delete mode 100644 src/plugins/remotelinux/maemodeployconfigurationwidget.ui delete mode 100644 src/plugins/remotelinux/maemodeploymentmounter.cpp delete mode 100644 src/plugins/remotelinux/maemodeploymentmounter.h delete mode 100644 src/plugins/remotelinux/maemodeploystepfactory.cpp delete mode 100644 src/plugins/remotelinux/maemodeploystepfactory.h delete mode 100644 src/plugins/remotelinux/maemodeviceconfigwizard.cpp delete mode 100644 src/plugins/remotelinux/maemodeviceconfigwizard.h delete mode 100644 src/plugins/remotelinux/maemodeviceconfigwizardkeycreationpage.ui delete mode 100644 src/plugins/remotelinux/maemodeviceconfigwizardkeydeploymentpage.ui delete mode 100644 src/plugins/remotelinux/maemodeviceconfigwizardpreviouskeysetupcheckpage.ui delete mode 100644 src/plugins/remotelinux/maemodeviceconfigwizardreusekeyscheckpage.ui delete mode 100644 src/plugins/remotelinux/maemodeviceconfigwizardstartpage.ui delete mode 100644 src/plugins/remotelinux/maemoglobal.cpp delete mode 100644 src/plugins/remotelinux/maemoglobal.h delete mode 100644 src/plugins/remotelinux/maemoinstalltosysrootstep.cpp delete mode 100644 src/plugins/remotelinux/maemoinstalltosysrootstep.h delete mode 100644 src/plugins/remotelinux/maemomountspecification.cpp delete mode 100644 src/plugins/remotelinux/maemomountspecification.h delete mode 100644 src/plugins/remotelinux/maemopackagecreationfactory.cpp delete mode 100644 src/plugins/remotelinux/maemopackagecreationfactory.h delete mode 100644 src/plugins/remotelinux/maemopackagecreationstep.cpp delete mode 100644 src/plugins/remotelinux/maemopackagecreationstep.h delete mode 100644 src/plugins/remotelinux/maemopackagecreationwidget.cpp delete mode 100644 src/plugins/remotelinux/maemopackagecreationwidget.h delete mode 100644 src/plugins/remotelinux/maemopackagecreationwidget.ui delete mode 100644 src/plugins/remotelinux/maemopackageinstaller.cpp delete mode 100644 src/plugins/remotelinux/maemopackageinstaller.h delete mode 100644 src/plugins/remotelinux/maemopublishedprojectmodel.cpp delete mode 100644 src/plugins/remotelinux/maemopublishedprojectmodel.h delete mode 100644 src/plugins/remotelinux/maemopublisherfremantlefree.cpp delete mode 100644 src/plugins/remotelinux/maemopublisherfremantlefree.h delete mode 100644 src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.cpp delete mode 100644 src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.h delete mode 100644 src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.ui delete mode 100644 src/plugins/remotelinux/maemopublishingfileselectiondialog.cpp delete mode 100644 src/plugins/remotelinux/maemopublishingfileselectiondialog.h delete mode 100644 src/plugins/remotelinux/maemopublishingfileselectiondialog.ui delete mode 100644 src/plugins/remotelinux/maemopublishingresultpagefremantlefree.cpp delete mode 100644 src/plugins/remotelinux/maemopublishingresultpagefremantlefree.h delete mode 100644 src/plugins/remotelinux/maemopublishingresultpagefremantlefree.ui delete mode 100644 src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.cpp delete mode 100644 src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.h delete mode 100644 src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.ui delete mode 100644 src/plugins/remotelinux/maemopublishingwizardfactories.cpp delete mode 100644 src/plugins/remotelinux/maemopublishingwizardfactories.h delete mode 100644 src/plugins/remotelinux/maemopublishingwizardfremantlefree.cpp delete mode 100644 src/plugins/remotelinux/maemopublishingwizardfremantlefree.h delete mode 100644 src/plugins/remotelinux/maemoqemumanager.cpp delete mode 100644 src/plugins/remotelinux/maemoqemumanager.h delete mode 100644 src/plugins/remotelinux/maemoqemuruntime.h delete mode 100644 src/plugins/remotelinux/maemoqemuruntimeparser.cpp delete mode 100644 src/plugins/remotelinux/maemoqemuruntimeparser.h delete mode 100644 src/plugins/remotelinux/maemoqemusettings.cpp delete mode 100644 src/plugins/remotelinux/maemoqemusettings.h delete mode 100644 src/plugins/remotelinux/maemoqemusettingswidget.cpp delete mode 100644 src/plugins/remotelinux/maemoqemusettingswidget.h delete mode 100644 src/plugins/remotelinux/maemoqemusettingswidget.ui delete mode 100644 src/plugins/remotelinux/maemoqtversion.cpp delete mode 100644 src/plugins/remotelinux/maemoqtversion.h delete mode 100644 src/plugins/remotelinux/maemoqtversionfactory.cpp delete mode 100644 src/plugins/remotelinux/maemoqtversionfactory.h delete mode 100644 src/plugins/remotelinux/maemoremotecopyfacility.cpp delete mode 100644 src/plugins/remotelinux/maemoremotecopyfacility.h delete mode 100644 src/plugins/remotelinux/maemoremotemounter.cpp delete mode 100644 src/plugins/remotelinux/maemoremotemounter.h delete mode 100644 src/plugins/remotelinux/maemoremotemountsmodel.cpp delete mode 100644 src/plugins/remotelinux/maemoremotemountsmodel.h delete mode 100644 src/plugins/remotelinux/maemorunconfiguration.cpp delete mode 100644 src/plugins/remotelinux/maemorunconfiguration.h delete mode 100644 src/plugins/remotelinux/maemorunconfigurationwidget.cpp delete mode 100644 src/plugins/remotelinux/maemorunconfigurationwidget.h delete mode 100644 src/plugins/remotelinux/maemoruncontrol.cpp delete mode 100644 src/plugins/remotelinux/maemoruncontrol.h delete mode 100644 src/plugins/remotelinux/maemorunfactories.cpp delete mode 100644 src/plugins/remotelinux/maemorunfactories.h delete mode 100644 src/plugins/remotelinux/maemosettingspages.cpp delete mode 100644 src/plugins/remotelinux/maemosettingspages.h delete mode 100644 src/plugins/remotelinux/maemosshrunner.cpp delete mode 100644 src/plugins/remotelinux/maemosshrunner.h delete mode 100644 src/plugins/remotelinux/maemotoolchain.cpp delete mode 100644 src/plugins/remotelinux/maemotoolchain.h delete mode 100644 src/plugins/remotelinux/qt-maemo.qrc delete mode 100644 src/plugins/remotelinux/qt4maemodeployconfiguration.cpp delete mode 100644 src/plugins/remotelinux/qt4maemodeployconfiguration.h delete mode 100644 src/plugins/remotelinux/qt4maemotarget.cpp delete mode 100644 src/plugins/remotelinux/qt4maemotarget.h delete mode 100644 src/plugins/remotelinux/qt4maemotargetfactory.cpp delete mode 100644 src/plugins/remotelinux/qt4maemotargetfactory.h (limited to 'src') diff --git a/src/plugins/madde/Madde.pluginspec.in b/src/plugins/madde/Madde.pluginspec.in new file mode 100644 index 00000000000..68d0fd2f786 --- /dev/null +++ b/src/plugins/madde/Madde.pluginspec.in @@ -0,0 +1,19 @@ + + Nokia Corporation + (C) 2011 Nokia Corporation + +Commercial Usage + +Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. + +GNU Lesser General Public License Usage + +Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. Please review the following information to ensure the GNU Lesser General Public License version 2.1 requirements will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + + Support for MADDE-based platforms, including Fremantle and MeeGo 1.2 Harmattan. + Device Support + http://qt.nokia.com + + + + diff --git a/src/plugins/madde/images/qemu-run.png b/src/plugins/madde/images/qemu-run.png new file mode 100644 index 00000000000..c65d15faf73 Binary files /dev/null and b/src/plugins/madde/images/qemu-run.png differ diff --git a/src/plugins/madde/images/qemu-stop.png b/src/plugins/madde/images/qemu-stop.png new file mode 100644 index 00000000000..97bc159599a Binary files /dev/null and b/src/plugins/madde/images/qemu-stop.png differ diff --git a/src/plugins/madde/images/qemu.xcf b/src/plugins/madde/images/qemu.xcf new file mode 100644 index 00000000000..226dd2b30a6 Binary files /dev/null and b/src/plugins/madde/images/qemu.xcf differ diff --git a/src/plugins/madde/madde.pri b/src/plugins/madde/madde.pri new file mode 100644 index 00000000000..90a62b71b85 --- /dev/null +++ b/src/plugins/madde/madde.pri @@ -0,0 +1,3 @@ +include(madde_dependencies.pri) + +LIBS *= -l$$qtLibraryName(Madde) diff --git a/src/plugins/madde/madde.pro b/src/plugins/madde/madde.pro new file mode 100644 index 00000000000..b69ed8350d5 --- /dev/null +++ b/src/plugins/madde/madde.pro @@ -0,0 +1,117 @@ +TEMPLATE = lib +TARGET = Madde + +include(../../qtcreatorplugin.pri) +include(madde_dependencies.pri) + +HEADERS += \ + maddeplugin.h \ + maemoconstants.h \ + maemorunconfigurationwidget.h \ + maemoruncontrol.h \ + maemorunfactories.h \ + maemosettingspages.h \ + maemotoolchain.h \ + maemopackagecreationstep.h \ + maemopackagecreationfactory.h \ + maemopackagecreationwidget.h \ + maemoqemumanager.h \ + maemodeploystepfactory.h \ + maemoglobal.h \ + maemosshrunner.h \ + maemodebugsupport.h \ + maemoremotemountsmodel.h \ + maemomountspecification.h \ + maemoremotemounter.h \ + maemopublishingwizardfactories.h \ + maemopublishingbuildsettingspagefremantlefree.h \ + maemopublishingfileselectiondialog.h \ + maemopublishedprojectmodel.h \ + maemopublishinguploadsettingspagefremantlefree.h \ + maemopublishingwizardfremantlefree.h \ + maemopublishingresultpagefremantlefree.h \ + maemopublisherfremantlefree.h \ + maemoqemuruntime.h \ + maemoqemuruntimeparser.h \ + maemoqemusettingswidget.h \ + maemoqemusettings.h \ + qt4maemotargetfactory.h \ + qt4maemotarget.h \ + qt4maemodeployconfiguration.h \ + maemodeviceconfigwizard.h \ + maemodeployconfigurationwidget.h \ + maemoinstalltosysrootstep.h \ + maemodeploymentmounter.h \ + maemopackageinstaller.h \ + maemoremotecopyfacility.h \ + maemoqtversionfactory.h \ + maemoqtversion.h \ + maemorunconfiguration.h \ + maddeuploadandinstallpackagesteps.h \ + maemodeploybymountsteps.h \ + maddedevicetester.h \ + maddedeviceconfigurationfactory.h \ + +SOURCES += \ + maddeplugin.cpp \ + maemorunconfigurationwidget.cpp \ + maemoruncontrol.cpp \ + maemorunfactories.cpp \ + maemosettingspages.cpp \ + maemotoolchain.cpp \ + maemopackagecreationstep.cpp \ + maemopackagecreationfactory.cpp \ + maemopackagecreationwidget.cpp \ + maemoqemumanager.cpp \ + maemodeploystepfactory.cpp \ + maemoglobal.cpp \ + maemosshrunner.cpp \ + maemodebugsupport.cpp \ + maemoremotemountsmodel.cpp \ + maemomountspecification.cpp \ + maemoremotemounter.cpp \ + maemopublishingwizardfactories.cpp \ + maemopublishingbuildsettingspagefremantlefree.cpp \ + maemopublishingfileselectiondialog.cpp \ + maemopublishedprojectmodel.cpp \ + maemopublishinguploadsettingspagefremantlefree.cpp \ + maemopublishingwizardfremantlefree.cpp \ + maemopublishingresultpagefremantlefree.cpp \ + maemopublisherfremantlefree.cpp \ + maemoqemuruntimeparser.cpp \ + maemoqemusettingswidget.cpp \ + maemoqemusettings.cpp \ + qt4maemotargetfactory.cpp \ + qt4maemotarget.cpp \ + qt4maemodeployconfiguration.cpp \ + maemodeviceconfigwizard.cpp \ + maemodeployconfigurationwidget.cpp \ + maemoinstalltosysrootstep.cpp \ + maemodeploymentmounter.cpp \ + maemopackageinstaller.cpp \ + maemoremotecopyfacility.cpp \ + maemoqtversionfactory.cpp \ + maemoqtversion.cpp \ + maddedeviceconfigurationfactory.cpp \ + maddeuploadandinstallpackagesteps.cpp \ + maemodeploybymountsteps.cpp \ + maddedevicetester.cpp \ + maemorunconfiguration.cpp + +FORMS += \ + maemopackagecreationwidget.ui \ + maemopublishingbuildsettingspagefremantlefree.ui \ + maemopublishingfileselectiondialog.ui \ + maemopublishinguploadsettingspagefremantlefree.ui \ + maemopublishingresultpagefremantlefree.ui \ + maemoqemusettingswidget.ui \ + maemodeviceconfigwizardstartpage.ui \ + maemodeviceconfigwizardpreviouskeysetupcheckpage.ui \ + maemodeviceconfigwizardreusekeyscheckpage.ui \ + maemodeviceconfigwizardkeycreationpage.ui \ + maemodeviceconfigwizardkeydeploymentpage.ui \ + maemodeployconfigurationwidget.ui + +RESOURCES += qt-maemo.qrc +DEFINES += QT_NO_CAST_TO_ASCII +DEFINES += MADDE_LIBRARY diff --git a/src/plugins/madde/madde_dependencies.pri b/src/plugins/madde/madde_dependencies.pri new file mode 100644 index 00000000000..94d99fc73dc --- /dev/null +++ b/src/plugins/madde/madde_dependencies.pri @@ -0,0 +1 @@ +include(../../plugins/remotelinux/remotelinux.pri) diff --git a/src/plugins/madde/madde_exports.h b/src/plugins/madde/madde_exports.h new file mode 100644 index 00000000000..8d928264e08 --- /dev/null +++ b/src/plugins/madde/madde_exports.h @@ -0,0 +1,44 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MADDEEXPORT_H +#define MADDEEXPORT_H + +#include + +#if defined(MADDE_LIBRARY) +# define MADDE_EXPORT Q_DECL_EXPORT +#else +# define MADDE_EXPORT Q_DECL_IMPORT +#endif + +#endif // MADDEEXPORT_H diff --git a/src/plugins/madde/maddedeviceconfigurationfactory.cpp b/src/plugins/madde/maddedeviceconfigurationfactory.cpp new file mode 100644 index 00000000000..cad8cc7f148 --- /dev/null +++ b/src/plugins/madde/maddedeviceconfigurationfactory.cpp @@ -0,0 +1,120 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maddedeviceconfigurationfactory.h" + +#include "maddedevicetester.h" +#include "maemoconstants.h" +#include "maemodeviceconfigwizard.h" + +#include +#include +#include +#include +#include +#include + +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { +namespace { +const char MaddeDeviceTestActionId[] = "Madde.DeviceTestAction"; +const char MaddeRemoteProcessesActionId[] = "Madde.RemoteProcessesAction"; +} // anonymous namespace + +MaddeDeviceConfigurationFactory::MaddeDeviceConfigurationFactory(QObject *parent) + : ILinuxDeviceConfigurationFactory(parent) +{ +} + +QString MaddeDeviceConfigurationFactory::displayName() const +{ + return tr("Device with MADDE support (Fremantle, Harmattan, MeeGo)"); +} + +ILinuxDeviceConfigurationWizard *MaddeDeviceConfigurationFactory::createWizard(QWidget *parent) const +{ + return new MaemoDeviceConfigWizard(parent); +} + +bool MaddeDeviceConfigurationFactory::supportsOsType(const QString &osType) const +{ + return osType == QLatin1String(Maemo5OsType) || osType == QLatin1String(HarmattanOsType) + || osType == QLatin1String(MeeGoOsType); +} + +QString MaddeDeviceConfigurationFactory::displayNameForOsType(const QString &osType) const +{ + QTC_ASSERT(supportsOsType(osType), return QString()); + if (osType == QLatin1String(Maemo5OsType)) + return tr("Maemo5/Fremantle"); + if (osType == QLatin1String(HarmattanOsType)) + return tr("MeeGo 1.2 Harmattan"); + return tr("Other MeeGo OS"); +} + +QStringList MaddeDeviceConfigurationFactory::supportedDeviceActionIds() const +{ + return QStringList() << QLatin1String(MaddeDeviceTestActionId) + << QLatin1String(Constants::GenericDeployKeyToDeviceActionId) + << QLatin1String(MaddeRemoteProcessesActionId); +} + +QString MaddeDeviceConfigurationFactory::displayNameForActionId(const QString &actionId) const +{ + Q_ASSERT(supportedDeviceActionIds().contains(actionId)); + + if (actionId == QLatin1String(MaddeDeviceTestActionId)) + return tr("Test"); + if (actionId == QLatin1String(MaddeRemoteProcessesActionId)) + return tr("Remote Processes"); + if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId)) + return tr("Deploy Public Key"); + return QString(); // Can't happen. +} + +QDialog *MaddeDeviceConfigurationFactory::createDeviceAction(const QString &actionId, + const LinuxDeviceConfiguration::ConstPtr &deviceConfig, QWidget *parent) const +{ + Q_ASSERT(supportedDeviceActionIds().contains(actionId)); + + if (actionId == QLatin1String(MaddeDeviceTestActionId)) + return new LinuxDeviceTestDialog(deviceConfig, new MaddeDeviceTester, parent); + if (actionId == QLatin1String(MaddeRemoteProcessesActionId)) + return new RemoteLinuxProcessesDialog(new GenericRemoteLinuxProcessList(deviceConfig), parent); + if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId)) + return new PublicKeyDeploymentDialog(deviceConfig, parent); + return 0; // Can't happen. +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maddedeviceconfigurationfactory.h b/src/plugins/madde/maddedeviceconfigurationfactory.h new file mode 100644 index 00000000000..dfbd1588184 --- /dev/null +++ b/src/plugins/madde/maddedeviceconfigurationfactory.h @@ -0,0 +1,59 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MADDEDEVICECONFIGURATIONFACTORY_H +#define MADDEDEVICECONFIGURATIONFACTORY_H + +#include + +namespace Madde { +namespace Internal { + +class MaddeDeviceConfigurationFactory : public RemoteLinux::ILinuxDeviceConfigurationFactory +{ + Q_OBJECT +public: + MaddeDeviceConfigurationFactory(QObject *parent = 0); + + QString displayName() const; + RemoteLinux::ILinuxDeviceConfigurationWizard *createWizard(QWidget *parent) const; + bool supportsOsType(const QString &osType) const; + QString displayNameForOsType(const QString &osType) const; + QStringList supportedDeviceActionIds() const; + QString displayNameForActionId(const QString &actionId) const; + QDialog *createDeviceAction(const QString &actionId, + const RemoteLinux::LinuxDeviceConfiguration::ConstPtr &deviceConfig, QWidget *parent) const; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MADDEDEVICECONFIGURATIONFACTORY_H diff --git a/src/plugins/madde/maddedevicetester.cpp b/src/plugins/madde/maddedevicetester.cpp new file mode 100644 index 00000000000..120a465ba0c --- /dev/null +++ b/src/plugins/madde/maddedevicetester.cpp @@ -0,0 +1,291 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maddedevicetester.h" + +#include "maemoconstants.h" +#include "maemoglobal.h" + +#include +#include +#include + +#include + +using namespace RemoteLinux; +using namespace Utils; + +namespace Madde { +namespace Internal { +namespace { +const char QmlToolingDirectory[] = "/usr/lib/qt4/plugins/qmltooling"; +} // anonymous namespace + +MaddeDeviceTester::MaddeDeviceTester(QObject *parent) + : AbstractLinuxDeviceTester(parent), + m_genericTester(new GenericLinuxDeviceTester(this)), + m_state(Inactive) +{ +} + +MaddeDeviceTester::~MaddeDeviceTester() +{ +} + +void MaddeDeviceTester::testDevice(const LinuxDeviceConfiguration::ConstPtr &deviceConfiguration) +{ + QTC_ASSERT(m_state == Inactive, return); + + m_deviceConfiguration = deviceConfiguration; + m_result = TestSuccess; + + m_state = GenericTest; + connect(m_genericTester, SIGNAL(progressMessage(QString)), SIGNAL(progressMessage(QString))); + connect(m_genericTester, SIGNAL(errorMessage(QString)), SIGNAL(errorMessage(QString))); + connect(m_genericTester, SIGNAL(finished(RemoteLinux::AbstractLinuxDeviceTester::TestResult)), + SLOT(handleGenericTestFinished(RemoteLinux::AbstractLinuxDeviceTester::TestResult))); + m_genericTester->testDevice(deviceConfiguration); +} + +void MaddeDeviceTester::stopTest() +{ + QTC_ASSERT(m_state != Inactive, return); + + switch (m_state) { + case Inactive: + break; + case GenericTest: + m_genericTester->stopTest(); + break; + case QtTest: + case MadDeveloperTest: + case QmlToolingTest: + m_processRunner->process()->closeChannel(); + break; + } + + m_result = TestFailure; + setFinished(); +} + +void MaddeDeviceTester::handleGenericTestFinished(TestResult result) +{ + QTC_ASSERT(m_state == GenericTest, return); + + if (result == TestFailure) { + m_result = TestFailure; + setFinished(); + return; + } + + m_processRunner = SshRemoteProcessRunner::create(m_genericTester->connection()); + connect(m_processRunner.data(), SIGNAL(connectionError(Utils::SshError)), + SLOT(handleConnectionError())); + connect(m_processRunner.data(), SIGNAL(processOutputAvailable(QByteArray)), + SLOT(handleStdout(QByteArray))); + connect(m_processRunner.data(), SIGNAL(processErrorOutputAvailable(QByteArray)), + SLOT(handleStderr(QByteArray))); + connect(m_processRunner.data(), SIGNAL(processClosed(int)), SLOT(handleProcessFinished(int))); + + QString qtInfoCmd; + if (m_deviceConfiguration->osType() == QLatin1String(MeeGoOsType)) { + qtInfoCmd = QLatin1String("rpm -qa 'libqt*' --queryformat '%{NAME} %{VERSION}\\n'"); + } else { + qtInfoCmd = QLatin1String("dpkg-query -W -f " + "'${Package} ${Version} ${Status}\n' 'libqt*' |grep ' installed$'"); + } + + emit progressMessage(tr("Checking for Qt libraries...")); + m_stdout.clear(); + m_stderr.clear(); + m_state = QtTest; + m_processRunner->run(qtInfoCmd.toUtf8()); +} + +void MaddeDeviceTester::handleConnectionError() +{ + QTC_ASSERT(m_state != Inactive, return); + + emit errorMessage(tr("SSH connection error: %1\n") + .arg(m_processRunner->connection()->errorString())); + m_result = TestFailure; + setFinished(); +} + +void MaddeDeviceTester::handleStdout(const QByteArray &data) +{ + QTC_ASSERT(m_state == QtTest || m_state == MadDeveloperTest || m_state == QmlToolingTest, + return); + + m_stdout += data; +} + +void MaddeDeviceTester::handleStderr(const QByteArray &data) +{ + QTC_ASSERT(m_state == QtTest || m_state == MadDeveloperTest || m_state == QmlToolingTest, + return); + + m_stderr += data; +} + +void MaddeDeviceTester::handleProcessFinished(int exitStatus) +{ + switch (m_state) { + case QtTest: + handleQtTestFinished(exitStatus); + break; + case MadDeveloperTest: + handleMadDeveloperTestFinished(exitStatus); + break; + case QmlToolingTest: + handleQmlToolingTestFinished(exitStatus); + break; + default: + qWarning("%s: Unexpected state %d.", Q_FUNC_INFO, m_state); + } +} + +void MaddeDeviceTester::handleQtTestFinished(int exitStatus) +{ + if (exitStatus != SshRemoteProcess::ExitedNormally + || m_processRunner->process()->exitCode() != 0) { + if (!m_stderr.isEmpty()) { + emit errorMessage(tr("Error checking for Qt libraries: %1\n") + .arg(QString::fromUtf8(m_stderr))); + } else { + emit errorMessage(tr("Error checking for Qt libraries.\n")); + } + + m_result = TestFailure; + } else { + emit progressMessage(processedQtLibsList()); + } + + m_stdout.clear(); + m_stderr.clear(); + + emit progressMessage(tr("Checking for connectivity support...")); + m_state = MadDeveloperTest; + m_processRunner->run(QString(QLatin1String("test -x") + MaemoGlobal::devrootshPath()).toUtf8()); +} + +void MaddeDeviceTester::handleMadDeveloperTestFinished(int exitStatus) +{ + if (exitStatus != SshRemoteProcess::ExitedNormally) { + if (!m_stderr.isEmpty()) { + emit errorMessage(tr("Error checking for connectivity tool: %1\n") + .arg(QString::fromUtf8(m_stderr))); + } else { + emit errorMessage(tr("Error checking for connectivity tool.\n")); + } + m_result = TestFailure; + } else if (m_processRunner->process()->exitCode() != 0) { + QString message = tr("Connectivity tool not installed on device. " + "Deployment currently not possible."); + if (m_deviceConfiguration->osType() == QLatin1String(HarmattanOsType)) { + message += tr("Please switch the device to developer mode " + "via Settings -> Security."); + } + emit errorMessage(message + QLatin1Char('\n')); + m_result = TestFailure; + } else { + emit progressMessage(tr("Connectivity tool present.\n")); + } + + if (m_deviceConfiguration->osType() != QLatin1String(HarmattanOsType)) { + setFinished(); + return; + } + + m_stdout.clear(); + m_stderr.clear(); + + emit progressMessage(tr("Checking for QML tooling support...")); + m_state = QmlToolingTest; + m_processRunner->run(QString(QLatin1String("test -d ") + + QLatin1String(QmlToolingDirectory)).toUtf8()); +} + +void MaddeDeviceTester::handleQmlToolingTestFinished(int exitStatus) +{ + if (exitStatus != SshRemoteProcess::ExitedNormally) { + if (!m_stderr.isEmpty()) { + emit errorMessage(tr("Error checking for QML tooling support: %1\n") + .arg(QString::fromUtf8(m_stderr))); + } else { + emit errorMessage(tr("Error checking for QML tooling support.\n")); + } + m_result = TestFailure; + } else if (m_processRunner->process()->exitCode() != 0) { + emit errorMessage(tr("Missing directory '%1'. You will not be able to do " + "QML debugging on this device.\n").arg(QmlToolingDirectory)); + m_result = TestFailure; + } else { + emit progressMessage(tr("QML tooling support present.\n")); + } + + setFinished(); +} + +QString MaddeDeviceTester::processedQtLibsList() +{ + QString unfilteredLibs = QString::fromUtf8(m_stdout); + QString filteredLibs; + QString patternString; + if (m_deviceConfiguration->osType() == QLatin1String(MeeGoOsType)) + patternString = QLatin1String("(libqt\\S+) ((\\d+)\\.(\\d+)\\.(\\d+))"); + else + patternString = QLatin1String("(\\S+) (\\S*(\\d+)\\.(\\d+)\\.(\\d+)\\S*) \\S+ \\S+ \\S+"); + const QRegExp packagePattern(patternString); + int index = packagePattern.indexIn(unfilteredLibs); + if (index == -1) + return tr("No Qt packages installed."); + + do { + filteredLibs += QLatin1String(" ") + packagePattern.cap(1) + QLatin1String(": ") + + packagePattern.cap(2) + QLatin1Char('\n'); + index = packagePattern.indexIn(unfilteredLibs, index + packagePattern.cap(0).length()); + } while (index != -1); + return filteredLibs; +} + + void MaddeDeviceTester::setFinished() +{ + m_state = Inactive; + disconnect(m_genericTester, 0, this, 0); + if (m_processRunner) + disconnect(m_processRunner.data(), 0, this, 0); + m_processRunner.clear(); + emit finished(m_result); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maddedevicetester.h b/src/plugins/madde/maddedevicetester.h new file mode 100644 index 00000000000..41856c21990 --- /dev/null +++ b/src/plugins/madde/maddedevicetester.h @@ -0,0 +1,85 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MADDEDEVICETESTER_H +#define MADDEDEVICETESTER_H + +#include + +#include + +namespace Utils { +class SshRemoteProcessRunner; +} + +namespace Madde { +namespace Internal { + +class MaddeDeviceTester : public RemoteLinux::AbstractLinuxDeviceTester +{ + Q_OBJECT +public: + explicit MaddeDeviceTester(QObject *parent = 0); + ~MaddeDeviceTester(); + + void testDevice(const QSharedPointer &deviceConfiguration); + void stopTest(); + +private slots: + void handleGenericTestFinished(RemoteLinux::AbstractLinuxDeviceTester::TestResult result); + void handleConnectionError(); + void handleStdout(const QByteArray &data); + void handleStderr(const QByteArray &data); + void handleProcessFinished(int exitStatus); + +private: + enum State { Inactive, GenericTest, QtTest, MadDeveloperTest, QmlToolingTest }; + + void handleQtTestFinished(int exitStatus); + void handleMadDeveloperTestFinished(int exitStatus); + void handleQmlToolingTestFinished(int exitStatus); + + QString processedQtLibsList(); + void setFinished(); + + RemoteLinux::GenericLinuxDeviceTester * const m_genericTester; + State m_state; + TestResult m_result; + QSharedPointer m_processRunner; + QSharedPointer m_deviceConfiguration; + QByteArray m_stdout; + QByteArray m_stderr; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MADDEDEVICETESTER_H diff --git a/src/plugins/madde/maddeplugin.cpp b/src/plugins/madde/maddeplugin.cpp new file mode 100644 index 00000000000..c3165e87c6e --- /dev/null +++ b/src/plugins/madde/maddeplugin.cpp @@ -0,0 +1,90 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maddeplugin.h" + +#include "maddedeviceconfigurationfactory.h" +#include "maemoconstants.h" +#include "maemodeploystepfactory.h" +#include "maemopackagecreationfactory.h" +#include "maemopublishingwizardfactories.h" +#include "maemoqemumanager.h" +#include "maemorunfactories.h" +#include "maemosettingspages.h" +#include "maemotoolchain.h" +#include "qt4maemodeployconfiguration.h" +#include "maemoqtversionfactory.h" +#include "qt4maemotargetfactory.h" + +#include + +namespace Madde { +namespace Internal { + +MaddePlugin::MaddePlugin() +{ +} + +MaddePlugin::~MaddePlugin() +{ +} + +bool MaddePlugin::initialize(const QStringList &arguments, QString *error_message) +{ + Q_UNUSED(arguments) + Q_UNUSED(error_message) + + MaemoQemuManager::instance(this); + + addAutoReleasedObject(new MaemoRunControlFactory); + addAutoReleasedObject(new MaemoRunConfigurationFactory); + addAutoReleasedObject(new MaemoToolChainFactory); + addAutoReleasedObject(new Qt4MaemoDeployConfigurationFactory); + addAutoReleasedObject(new MaemoPackageCreationFactory); + addAutoReleasedObject(new MaemoDeployStepFactory); + addAutoReleasedObject(new MaemoQemuSettingsPage); + addAutoReleasedObject(new MaemoPublishingWizardFactoryFremantleFree); + addAutoReleasedObject(new Qt4MaemoTargetFactory); + addAutoReleasedObject(new MaemoQtVersionFactory); + addAutoReleasedObject(new MaddeDeviceConfigurationFactory); + + return true; +} + +void MaddePlugin::extensionsInitialized() +{ +} + +} // namespace Internal +} // namespace Madde + +Q_EXPORT_PLUGIN(Madde::Internal::MaddePlugin) diff --git a/src/plugins/madde/maddeplugin.h b/src/plugins/madde/maddeplugin.h new file mode 100644 index 00000000000..726a721cc02 --- /dev/null +++ b/src/plugins/madde/maddeplugin.h @@ -0,0 +1,55 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MADDEPLUGIN_H +#define MADDEPLUGIN_H + +#include + +namespace Madde { +namespace Internal { + +class MaddePlugin : public ExtensionSystem::IPlugin +{ + Q_OBJECT +public: + MaddePlugin(); + ~MaddePlugin(); + + bool initialize(const QStringList &arguments, QString *error_message); + void extensionsInitialized(); +}; + +} // namespace Internal +} // namespace Madde + +#endif // MADDEPLUGIN_H diff --git a/src/plugins/madde/maddeuploadandinstallpackagesteps.cpp b/src/plugins/madde/maddeuploadandinstallpackagesteps.cpp new file mode 100644 index 00000000000..f3f7d605898 --- /dev/null +++ b/src/plugins/madde/maddeuploadandinstallpackagesteps.cpp @@ -0,0 +1,220 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maddeuploadandinstallpackagesteps.h" + +#include "maemopackagecreationstep.h" +#include "maemopackageinstaller.h" +#include "maemoqemumanager.h" +#include "qt4maemodeployconfiguration.h" + +#include +#include +#include +#include + +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { +namespace { +class AbstractMaddeUploadAndInstallPackageAction : public AbstractUploadAndInstallPackageService +{ + Q_OBJECT + +protected: + explicit AbstractMaddeUploadAndInstallPackageAction(AbstractRemoteLinuxDeployStep *step) + : AbstractUploadAndInstallPackageService(step) + { + } + + void doDeviceSetup() + { + if (deviceConfiguration()->deviceType() == LinuxDeviceConfiguration::Hardware) { + handleDeviceSetupDone(true); + return; + } + + if (MaemoQemuManager::instance().qemuIsRunning()) { + handleDeviceSetupDone(true); + return; + } + + MaemoQemuRuntime rt; + const int qtId = qt4BuildConfiguration() && qt4BuildConfiguration()->qtVersion() + ? qt4BuildConfiguration()->qtVersion()->uniqueId() : -1; + if (MaemoQemuManager::instance().runtimeForQtVersion(qtId, &rt)) { + MaemoQemuManager::instance().startRuntime(); + emit errorMessage(tr("Cannot deploy: Qemu was not running. " + "It has now been started up for you, but it will take " + "a bit of time until it is ready. Please try again then.")); + } else { + emit errorMessage(tr("Cannot deploy: You want to deploy to Qemu, but it is not enabled " + "for this Qt version.")); + } + handleDeviceSetupDone(false); + } +}; + +class MaemoUploadAndInstallPackageAction : public AbstractMaddeUploadAndInstallPackageAction +{ + Q_OBJECT + +public: + MaemoUploadAndInstallPackageAction(AbstractRemoteLinuxDeployStep *step) + : AbstractMaddeUploadAndInstallPackageAction(step), + m_installer(new MaemoDebianPackageInstaller(this)) + { + } + + AbstractRemoteLinuxPackageInstaller *packageInstaller() const { return m_installer; } + +private: + MaemoDebianPackageInstaller * const m_installer; +}; + +class MeegoUploadAndInstallPackageAction : public AbstractMaddeUploadAndInstallPackageAction +{ + Q_OBJECT + +public: + MeegoUploadAndInstallPackageAction(AbstractRemoteLinuxDeployStep *step) + : AbstractMaddeUploadAndInstallPackageAction(step), + m_installer(new MaemoRpmPackageInstaller(this)) + { + } + + AbstractRemoteLinuxPackageInstaller *packageInstaller() const { return m_installer; } + +private: + MaemoRpmPackageInstaller * const m_installer; +}; + +} // anonymous namespace + + +MaemoUploadAndInstallPackageStep::MaemoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl) + : AbstractRemoteLinuxDeployStep(bsl, stepId()) +{ + ctor(); +} + +MaemoUploadAndInstallPackageStep::MaemoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl, + MaemoUploadAndInstallPackageStep *other) : AbstractRemoteLinuxDeployStep(bsl, other) +{ + ctor(); +} + +void MaemoUploadAndInstallPackageStep::ctor() +{ + setDefaultDisplayName(displayName()); + m_deployService = new MaemoUploadAndInstallPackageAction(this); +} + +AbstractRemoteLinuxDeployService *MaemoUploadAndInstallPackageStep::deployService() const +{ + return m_deployService; +} + +bool MaemoUploadAndInstallPackageStep::isDeploymentPossible(QString *whyNot) const +{ + const AbstractMaemoPackageCreationStep * const pStep + = deployConfiguration()->earlierBuildStep(this); + if (!pStep) { + if (whyNot) + *whyNot = tr("No Debian package creation step found."); + return false; + } + m_deployService->setPackageFilePath(pStep->packageFilePath()); + return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); +} + +QString MaemoUploadAndInstallPackageStep::stepId() +{ + return QLatin1String("MaemoUploadAndInstallDpkgPackageStep"); +} + +QString MaemoUploadAndInstallPackageStep::displayName() +{ + return tr("Deploy Debian package via SFTP upload"); +} + + +MeegoUploadAndInstallPackageStep::MeegoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl) + : AbstractRemoteLinuxDeployStep(bsl, stepId()) +{ + ctor(); +} + +MeegoUploadAndInstallPackageStep::MeegoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl, + MeegoUploadAndInstallPackageStep *other) : AbstractRemoteLinuxDeployStep(bsl, other) +{ + ctor(); +} + +void MeegoUploadAndInstallPackageStep::ctor() +{ + setDefaultDisplayName(displayName()); + m_deployService = new MeegoUploadAndInstallPackageAction(this); +} + +AbstractRemoteLinuxDeployService *MeegoUploadAndInstallPackageStep::deployService() const +{ + return m_deployService; +} + +bool MeegoUploadAndInstallPackageStep::isDeploymentPossible(QString *whyNot) const +{ + const AbstractMaemoPackageCreationStep * const pStep + = deployConfiguration()->earlierBuildStep(this); + if (!pStep) { + if (whyNot) + *whyNot = tr("No RPM package creation step found."); + return false; + } + m_deployService->setPackageFilePath(pStep->packageFilePath()); + return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); +} + +QString MeegoUploadAndInstallPackageStep::stepId() +{ + return QLatin1String("MaemoUploadAndInstallRpmPackageStep"); +} + +QString MeegoUploadAndInstallPackageStep::displayName() +{ + return tr("Deploy RPM package via SFTP upload"); +} + +} // namespace Internal +} // namespace Madde + +#include "maddeuploadandinstallpackagesteps.moc" diff --git a/src/plugins/madde/maddeuploadandinstallpackagesteps.h b/src/plugins/madde/maddeuploadandinstallpackagesteps.h new file mode 100644 index 00000000000..a4d7ce5a7f0 --- /dev/null +++ b/src/plugins/madde/maddeuploadandinstallpackagesteps.h @@ -0,0 +1,90 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MADDEUPLOADANDINSTALLPACKAGESTEPS_H +#define MADDEUPLOADANDINSTALLPACKAGESTEPS_H + +#include + +namespace RemoteLinux { +class AbstractUploadAndInstallPackageService; +} + +namespace Madde { +namespace Internal { + +class MaemoUploadAndInstallPackageStep : public RemoteLinux::AbstractRemoteLinuxDeployStep +{ + Q_OBJECT +public: + MaemoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl); + MaemoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl, + MaemoUploadAndInstallPackageStep *other); + + bool isDeploymentPossible(QString *whyNot = 0) const; + + static QString stepId(); + static QString displayName(); + +private: + RemoteLinux::AbstractRemoteLinuxDeployService *deployService() const; + + void ctor(); + + RemoteLinux::AbstractUploadAndInstallPackageService *m_deployService; +}; + + +class MeegoUploadAndInstallPackageStep : public RemoteLinux::AbstractRemoteLinuxDeployStep +{ + Q_OBJECT +public: + MeegoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl); + MeegoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl, + MeegoUploadAndInstallPackageStep *other); + + bool isDeploymentPossible(QString *whyNot) const; + + static QString stepId(); + static QString displayName(); + +private: + RemoteLinux::AbstractRemoteLinuxDeployService *deployService() const; + + void ctor(); + + RemoteLinux::AbstractUploadAndInstallPackageService *m_deployService; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MADDEUPLOADANDINSTALLPACKAGESTEPS_H diff --git a/src/plugins/madde/maemoconstants.h b/src/plugins/madde/maemoconstants.h new file mode 100644 index 00000000000..9b2d4425ccc --- /dev/null +++ b/src/plugins/madde/maemoconstants.h @@ -0,0 +1,65 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOCONSTANTS_H +#define MAEMOCONSTANTS_H + +#include + +namespace Madde { +namespace Internal { + +const char Maemo5OsType[] = "Maemo5OsType"; +const char HarmattanOsType[] = "HarmattanOsType"; +const char MeeGoOsType[] = "MeeGoOsType"; + +#define PREFIX "Qt4ProjectManager.MaemoRunConfiguration" + +#ifdef Q_OS_WIN32 +#define EXEC_SUFFIX ".exe" +#else +#define EXEC_SUFFIX "" +#endif + +static const QLatin1String MAEMO_RC_ID(PREFIX); +static const QLatin1String MAEMO_RC_ID_PREFIX(PREFIX "."); + +static const QLatin1String LastDeployedHostsKey(PREFIX ".LastDeployedHosts"); +static const QLatin1String LastDeployedFilesKey(PREFIX ".LastDeployedFiles"); +static const QLatin1String LastDeployedRemotePathsKey(PREFIX ".LastDeployedRemotePaths"); +static const QLatin1String LastDeployedTimesKey(PREFIX ".LastDeployedTimes"); +static const QLatin1String ExportedLocalDirsKey(PREFIX ".ExportedLocalDirs"); +static const QLatin1String RemoteMountPointsKey(PREFIX ".RemoteMountPoints"); + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOCONSTANTS_H diff --git a/src/plugins/madde/maemodebugsupport.cpp b/src/plugins/madde/maemodebugsupport.cpp new file mode 100644 index 00000000000..ab70423b5ce --- /dev/null +++ b/src/plugins/madde/maemodebugsupport.cpp @@ -0,0 +1,56 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemodebugsupport.h" + +#include "maemorunconfiguration.h" +#include "maemosshrunner.h" + +#include + +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { + +MaemoDebugSupport::MaemoDebugSupport(MaemoRunConfiguration *runConfig, Debugger::DebuggerEngine *engine) + : AbstractRemoteLinuxDebugSupport(runConfig, engine), + m_runner(new MaemoSshRunner(this, runConfig)) +{ +} + +MaemoDebugSupport::~MaemoDebugSupport() +{ +} + +AbstractRemoteLinuxApplicationRunner *MaemoDebugSupport::runner() const { return m_runner; } + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemodebugsupport.h b/src/plugins/madde/maemodebugsupport.h new file mode 100644 index 00000000000..9b67a83a95e --- /dev/null +++ b/src/plugins/madde/maemodebugsupport.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMODEBUGSUPPORT_H +#define MAEMODEBUGSUPPORT_H + +#include + +namespace Madde { +namespace Internal { +class MaemoRunConfiguration; +class MaemoSshRunner; + +class MaemoDebugSupport : public RemoteLinux::AbstractRemoteLinuxDebugSupport +{ + Q_OBJECT +public: + MaemoDebugSupport(MaemoRunConfiguration *runConfig, Debugger::DebuggerEngine *engine); + ~MaemoDebugSupport(); + +private: + RemoteLinux::AbstractRemoteLinuxApplicationRunner *runner() const; + + MaemoSshRunner * const m_runner; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMODEBUGSUPPORT_H diff --git a/src/plugins/madde/maemodeploybymountsteps.cpp b/src/plugins/madde/maemodeploybymountsteps.cpp new file mode 100644 index 00000000000..062176d6acc --- /dev/null +++ b/src/plugins/madde/maemodeploybymountsteps.cpp @@ -0,0 +1,495 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemodeploybymountsteps.h" + +#include "maemodeploymentmounter.h" +#include "maemoglobal.h" +#include "maemomountspecification.h" +#include "maemopackagecreationstep.h" +#include "maemopackageinstaller.h" +#include "maemoqemumanager.h" +#include "maemoremotecopyfacility.h" +#include "qt4maemodeployconfiguration.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace ProjectExplorer; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { +class AbstractMaemoDeployByMountService : public AbstractRemoteLinuxDeployService +{ + Q_OBJECT + Q_DISABLE_COPY(AbstractMaemoDeployByMountService) +protected: + AbstractMaemoDeployByMountService(QObject *parent); + + QString deployMountPoint() const; + +private slots: + void handleMounted(); + void handleUnmounted(); + void handleMountError(const QString &errorMsg); + void handleInstallationFinished(const QString &errorMsg); + +private: + virtual QList mountSpecifications() const=0; + virtual void doInstall() = 0; + virtual void cancelInstallation() = 0; + virtual void handleInstallationSuccess() = 0; + + void doDeviceSetup(); + void stopDeviceSetup(); + void doDeploy(); + void stopDeployment(); + + void unmount(); + void setFinished(); + + MaemoDeploymentMounter * const m_mounter; + enum State { Inactive, Mounting, Installing, Unmounting } m_state; + bool m_stopRequested; +}; + +class MaemoMountAndInstallPackageService : public AbstractMaemoDeployByMountService +{ + Q_OBJECT + +public: + MaemoMountAndInstallPackageService(QObject *parent); + + void setPackageFilePath(const QString &filePath) { m_packageFilePath = filePath; } + +private: + bool isDeploymentNecessary() const; + + QList mountSpecifications() const; + void doInstall(); + void cancelInstallation(); + void handleInstallationSuccess(); + + MaemoDebianPackageInstaller * const m_installer; + QString m_packageFilePath; +}; + +class MaemoMountAndCopyFilesService : public AbstractMaemoDeployByMountService +{ + Q_OBJECT + +public: + MaemoMountAndCopyFilesService(QObject *parent); + + void setDeployableFiles(const QList &deployableFiles) { + m_deployableFiles = deployableFiles; + } + +private: + bool isDeploymentNecessary() const; + + QList mountSpecifications() const; + void doInstall(); + void cancelInstallation(); + void handleInstallationSuccess(); + + Q_SLOT void handleFileCopied(const RemoteLinux::DeployableFile &deployable); + + MaemoRemoteCopyFacility * const m_copyFacility; + mutable QList m_filesToCopy; + QList m_deployableFiles; +}; + + +AbstractMaemoDeployByMountService::AbstractMaemoDeployByMountService(QObject *parent) + : AbstractRemoteLinuxDeployService(parent), + m_mounter(new MaemoDeploymentMounter(this)), + m_state(Inactive), + m_stopRequested(false) +{ + connect(m_mounter, SIGNAL(setupDone()), SLOT(handleMounted())); + connect(m_mounter, SIGNAL(tearDownDone()), SLOT(handleUnmounted())); + connect(m_mounter, SIGNAL(error(QString)), SLOT(handleMountError(QString))); + connect(m_mounter, SIGNAL(reportProgress(QString)), SIGNAL(progressMessage(QString))); + connect(m_mounter, SIGNAL(debugOutput(QString)), SIGNAL(stdErrData(QString))); +} + +void AbstractMaemoDeployByMountService::doDeviceSetup() +{ + QTC_ASSERT(m_state == Inactive, return); + + if (deviceConfiguration()->deviceType() == LinuxDeviceConfiguration::Hardware) { + handleDeviceSetupDone(true); + return; + } + + if (MaemoQemuManager::instance().qemuIsRunning()) { + handleDeviceSetupDone(true); + return; + } + + MaemoQemuRuntime rt; + const int qtId = qt4BuildConfiguration() && qt4BuildConfiguration()->qtVersion() + ? qt4BuildConfiguration()->qtVersion()->uniqueId() : -1; + if (MaemoQemuManager::instance().runtimeForQtVersion(qtId, &rt)) { + MaemoQemuManager::instance().startRuntime(); + emit errorMessage(tr("Cannot deploy: Qemu was not running. " + "It has now been started up for you, but it will take " + "a bit of time until it is ready. Please try again then.")); + } else { + emit errorMessage(tr("Cannot deploy: You want to deploy to Qemu, but it is not enabled " + "for this Qt version.")); + } + handleDeviceSetupDone(false); +} + +void AbstractMaemoDeployByMountService::stopDeviceSetup() +{ + QTC_ASSERT(m_state == Inactive, return); + + handleDeviceSetupDone(false); +} + +void AbstractMaemoDeployByMountService::doDeploy() +{ + QTC_ASSERT(m_state == Inactive, return); + + if (!qt4BuildConfiguration()) { + emit errorMessage(tr("Missing build configuration.")); + setFinished(); + return; + } + + m_state = Mounting; + m_mounter->setupMounts(connection(), deviceConfiguration(), mountSpecifications(), + qt4BuildConfiguration()); +} + +void AbstractMaemoDeployByMountService::stopDeployment() +{ + switch (m_state) { + case Installing: + m_stopRequested = true; + cancelInstallation(); + + // TODO: Possibly unsafe, because the mount point may still be in use if the + // application did not exit immediately. + unmount(); + break; + case Mounting: + case Unmounting: + m_stopRequested = true; + break; + case Inactive: + qWarning("%s: Unexpected state 'Inactive'.", Q_FUNC_INFO); + break; + } +} + +void AbstractMaemoDeployByMountService::unmount() +{ + m_state = Unmounting; + m_mounter->tearDownMounts(); +} + +void AbstractMaemoDeployByMountService::handleMounted() +{ + QTC_ASSERT(m_state == Mounting, return); + + if (m_stopRequested) { + unmount(); + return; + } + + m_state = Installing; + doInstall(); +} + +void AbstractMaemoDeployByMountService::handleUnmounted() +{ + QTC_ASSERT(m_state == Unmounting, return); + + setFinished(); +} + +void AbstractMaemoDeployByMountService::handleMountError(const QString &errorMsg) +{ + QTC_ASSERT(m_state == Mounting, return); + + emit errorMessage(errorMsg); + setFinished(); +} + +void AbstractMaemoDeployByMountService::handleInstallationFinished(const QString &errorMsg) +{ + QTC_ASSERT(m_state == Installing, return); + + if (errorMsg.isEmpty()) + handleInstallationSuccess(); + else + emit errorMessage(errorMsg); + unmount(); +} + +void AbstractMaemoDeployByMountService::setFinished() +{ + m_state = Inactive; + m_stopRequested = false; + handleDeploymentDone(); +} + +QString AbstractMaemoDeployByMountService::deployMountPoint() const +{ + return MaemoGlobal::homeDirOnDevice(deviceConfiguration()->sshParameters().userName) + + QLatin1String("/deployMountPoint_") + + qt4BuildConfiguration()->target()->project()->displayName(); +} + + +MaemoMountAndInstallPackageService::MaemoMountAndInstallPackageService(QObject *parent) + : AbstractMaemoDeployByMountService(parent), m_installer(new MaemoDebianPackageInstaller(this)) +{ + connect(m_installer, SIGNAL(stdoutData(QString)), SIGNAL(stdOutData(QString))); + connect(m_installer, SIGNAL(stderrData(QString)), SIGNAL(stdErrData(QString))); + connect(m_installer, SIGNAL(finished(QString)), SLOT(handleInstallationFinished(QString))); +} + +bool MaemoMountAndInstallPackageService::isDeploymentNecessary() const +{ + return hasChangedSinceLastDeployment(DeployableFile(m_packageFilePath, QString())); +} + +QList MaemoMountAndInstallPackageService::mountSpecifications() const +{ + const QString localDir = QFileInfo(m_packageFilePath).absolutePath(); + return QList() + << MaemoMountSpecification(localDir, deployMountPoint()); +} + +void MaemoMountAndInstallPackageService::doInstall() +{ + const QString remoteFilePath = deployMountPoint() + QLatin1Char('/') + + QFileInfo(m_packageFilePath).fileName(); + m_installer->installPackage(connection(), remoteFilePath, false); +} + +void MaemoMountAndInstallPackageService::cancelInstallation() +{ + m_installer->cancelInstallation(); +} + +void MaemoMountAndInstallPackageService::handleInstallationSuccess() +{ + saveDeploymentTimeStamp(DeployableFile(m_packageFilePath, QString())); + emit progressMessage(tr("Package installed.")); +} + + +MaemoMountAndCopyFilesService::MaemoMountAndCopyFilesService(QObject *parent) + : AbstractMaemoDeployByMountService(parent), m_copyFacility(new MaemoRemoteCopyFacility(this)) +{ + connect(m_copyFacility, SIGNAL(stdoutData(QString)), SIGNAL(stdOutData(QString))); + connect(m_copyFacility, SIGNAL(stderrData(QString)), SIGNAL(stdErrData(QString))); + connect(m_copyFacility, SIGNAL(progress(QString)), SIGNAL(progressMessage(QString))); + connect(m_copyFacility, SIGNAL(fileCopied(RemoteLinux::DeployableFile)), + SLOT(handleFileCopied(RemoteLinux::DeployableFile))); + connect(m_copyFacility, SIGNAL(finished(QString)), SLOT(handleInstallationFinished(QString))); +} + +bool MaemoMountAndCopyFilesService::isDeploymentNecessary() const +{ + m_filesToCopy.clear(); + for (int i = 0; i < m_deployableFiles.count(); ++i) { + const DeployableFile &d = m_deployableFiles.at(i); + if (hasChangedSinceLastDeployment(d) || QFileInfo(d.localFilePath).isDir()) + m_filesToCopy << d; + } + return !m_filesToCopy.isEmpty(); +} + +QList MaemoMountAndCopyFilesService::mountSpecifications() const +{ + QList mountSpecs; +#ifdef Q_OS_WIN + bool drivesToMount[26]; + qFill(drivesToMount, drivesToMount + sizeof drivesToMount / sizeof drivesToMount[0], false); + for (int i = 0; i < m_filesToCopy.count(); ++i) { + const QString localDir = QFileInfo(m_filesToCopy.at(i).localFilePath).canonicalPath(); + const char driveLetter = localDir.at(0).toLower().toLatin1(); + if (driveLetter < 'a' || driveLetter > 'z') { + qWarning("Weird: drive letter is '%c'.", driveLetter); + continue; + } + + const int index = driveLetter - 'a'; + if (drivesToMount[index]) + continue; + + const QString mountPoint = deployMountPoint() + QLatin1Char('/') + QLatin1Char(driveLetter); + const MaemoMountSpecification mountSpec(localDir.left(3), mountPoint); + mountSpecs << mountSpec; + drivesToMount[index] = true; + } +#else + mountSpecs << MaemoMountSpecification(QLatin1String("/"), deployMountPoint()); +#endif + return mountSpecs; +} + +void MaemoMountAndCopyFilesService::doInstall() +{ + m_copyFacility->copyFiles(connection(), deviceConfiguration(), m_filesToCopy, + deployMountPoint()); +} + +void MaemoMountAndCopyFilesService::cancelInstallation() +{ + m_copyFacility->cancel(); +} + +void MaemoMountAndCopyFilesService::handleInstallationSuccess() +{ + emit progressMessage(tr("All files copied.")); +} + +void MaemoMountAndCopyFilesService::handleFileCopied(const DeployableFile &deployable) +{ + saveDeploymentTimeStamp(deployable); +} + +MaemoInstallPackageViaMountStep::MaemoInstallPackageViaMountStep(BuildStepList *bsl) + : AbstractRemoteLinuxDeployStep(bsl, stepId()) +{ + ctor(); +} + +MaemoInstallPackageViaMountStep::MaemoInstallPackageViaMountStep(BuildStepList *bsl, + MaemoInstallPackageViaMountStep *other) + : AbstractRemoteLinuxDeployStep(bsl, other) +{ + ctor(); +} + +void MaemoInstallPackageViaMountStep::ctor() +{ + m_deployService = new MaemoMountAndInstallPackageService(this); + setDefaultDisplayName(displayName()); +} + +AbstractRemoteLinuxDeployService *MaemoInstallPackageViaMountStep::deployService() const +{ + return m_deployService; +} + +bool MaemoInstallPackageViaMountStep::isDeploymentPossible(QString *whyNot) const +{ + const AbstractMaemoPackageCreationStep * const pStep + = deployConfiguration()->earlierBuildStep(this); + if (!pStep) { + if (whyNot) + *whyNot = tr("No Debian package creation step found."); + return false; + } + m_deployService->setPackageFilePath(pStep->packageFilePath()); + return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); +} + +QString MaemoInstallPackageViaMountStep::stepId() +{ + return QLatin1String("MaemoMountAndInstallDeployStep"); +} + +QString MaemoInstallPackageViaMountStep::displayName() +{ + return tr("Deploy package via UTFS mount"); +} + + +MaemoCopyFilesViaMountStep::MaemoCopyFilesViaMountStep(BuildStepList *bsl) + : AbstractRemoteLinuxDeployStep(bsl, stepId()) +{ + ctor(); +} + +MaemoCopyFilesViaMountStep::MaemoCopyFilesViaMountStep(BuildStepList *bsl, + MaemoCopyFilesViaMountStep *other) + : AbstractRemoteLinuxDeployStep(bsl, other) +{ + ctor(); +} + +void MaemoCopyFilesViaMountStep::ctor() +{ + m_deployService = new MaemoMountAndCopyFilesService(this); + setDefaultDisplayName(displayName()); +} + +AbstractRemoteLinuxDeployService *MaemoCopyFilesViaMountStep::deployService() const +{ + return m_deployService; +} + +bool MaemoCopyFilesViaMountStep::isDeploymentPossible(QString *whyNot) const +{ + QList deployableFiles; + const QSharedPointer deploymentInfo = deployConfiguration()->deploymentInfo(); + const int deployableCount = deploymentInfo->deployableCount(); + for (int i = 0; i < deployableCount; ++i) + deployableFiles << deploymentInfo->deployableAt(i); + m_deployService->setDeployableFiles(deployableFiles); + return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); +} + +QString MaemoCopyFilesViaMountStep::stepId() +{ + return QLatin1String("MaemoMountAndCopyDeployStep"); +} + +QString MaemoCopyFilesViaMountStep::displayName() +{ + return tr("Deploy files via UTFS mount"); +} + +} // namespace Internal +} // namespace Madde + +#include "maemodeploybymountsteps.moc" diff --git a/src/plugins/madde/maemodeploybymountsteps.h b/src/plugins/madde/maemodeploybymountsteps.h new file mode 100644 index 00000000000..24870e36e92 --- /dev/null +++ b/src/plugins/madde/maemodeploybymountsteps.h @@ -0,0 +1,89 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMODEPLOYBYMOUNTSTEPS_H +#define MAEMODEPLOYBYMOUNTSTEPS_H + +#include + +namespace Madde { +namespace Internal { +class MaemoMountAndInstallPackageService; +class MaemoMountAndCopyFilesService; + +class MaemoInstallPackageViaMountStep : public RemoteLinux::AbstractRemoteLinuxDeployStep +{ + Q_OBJECT + +public: + MaemoInstallPackageViaMountStep(ProjectExplorer::BuildStepList *bsl); + MaemoInstallPackageViaMountStep(ProjectExplorer::BuildStepList *bsl, + MaemoInstallPackageViaMountStep *other); + + bool isDeploymentPossible(QString *whyNot = 0) const; + + static QString stepId(); + static QString displayName(); + +private: + RemoteLinux::AbstractRemoteLinuxDeployService *deployService() const; + + void ctor(); + + MaemoMountAndInstallPackageService *m_deployService; +}; + + +class MaemoCopyFilesViaMountStep : public RemoteLinux::AbstractRemoteLinuxDeployStep +{ + Q_OBJECT + +public: + MaemoCopyFilesViaMountStep(ProjectExplorer::BuildStepList *bsl); + MaemoCopyFilesViaMountStep(ProjectExplorer::BuildStepList *bsl, + MaemoCopyFilesViaMountStep *other); + + bool isDeploymentPossible(QString *whyNot = 0) const; + + static QString stepId(); + static QString displayName(); + +private: + RemoteLinux::AbstractRemoteLinuxDeployService *deployService() const; + + void ctor(); + + MaemoMountAndCopyFilesService *m_deployService; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMODEPLOYBYMOUNTSTEPS_H diff --git a/src/plugins/madde/maemodeployconfigurationwidget.cpp b/src/plugins/madde/maemodeployconfigurationwidget.cpp new file mode 100644 index 00000000000..e1b3d4331e1 --- /dev/null +++ b/src/plugins/madde/maemodeployconfigurationwidget.cpp @@ -0,0 +1,214 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemodeployconfigurationwidget.h" +#include "ui_maemodeployconfigurationwidget.h" + +#include "maemoglobal.h" +#include "qt4maemodeployconfiguration.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { + +MaemoDeployConfigurationWidget::MaemoDeployConfigurationWidget(QWidget *parent) + : DeployConfigurationWidget(parent), + ui(new Ui::MaemoDeployConfigurationWidget), + m_remoteLinuxWidget(new RemoteLinuxDeployConfigurationWidget) +{ + QVBoxLayout *mainLayout = new QVBoxLayout(this); + mainLayout->setSpacing(0); + mainLayout->addWidget(m_remoteLinuxWidget); + QWidget * const subWidget = new QWidget; + ui->setupUi(subWidget); + mainLayout->addWidget(subWidget); + mainLayout->addStretch(1); + + connect(m_remoteLinuxWidget, + SIGNAL(currentModelChanged(const RemoteLinux::DeployableFilesPerProFile *)), + SLOT(handleCurrentModelChanged(const RemoteLinux::DeployableFilesPerProFile *))); + handleCurrentModelChanged(m_remoteLinuxWidget->currentModel()); +} + +MaemoDeployConfigurationWidget::~MaemoDeployConfigurationWidget() +{ + delete ui; +} + +void MaemoDeployConfigurationWidget::init(DeployConfiguration *dc) +{ + m_remoteLinuxWidget->init(dc); + connect(ui->addDesktopFileButton, SIGNAL(clicked()), SLOT(addDesktopFile())); + connect(ui->addIconButton, SIGNAL(clicked()), SLOT(addIcon())); + connect(deployConfiguration()->deploymentInfo().data(), SIGNAL(modelAboutToBeReset()), + SLOT(handleDeploymentInfoToBeReset())); +} + +Qt4MaemoDeployConfiguration *MaemoDeployConfigurationWidget::deployConfiguration() const +{ + return qobject_cast(m_remoteLinuxWidget->deployConfiguration()); +} + +void MaemoDeployConfigurationWidget::handleDeploymentInfoToBeReset() +{ + ui->addDesktopFileButton->setEnabled(false); + ui->addIconButton->setEnabled(false); +} + +void MaemoDeployConfigurationWidget::handleCurrentModelChanged(const DeployableFilesPerProFile *proFileInfo) +{ + ui->addDesktopFileButton->setEnabled(canAddDesktopFile(proFileInfo)); + ui->addIconButton->setEnabled(canAddIcon(proFileInfo)); +} + +void MaemoDeployConfigurationWidget::addDesktopFile() +{ + DeployableFilesPerProFile * const proFileInfo = m_remoteLinuxWidget->currentModel(); + QTC_ASSERT(canAddDesktopFile(proFileInfo), return); + + const QString desktopFilePath = QFileInfo(proFileInfo->proFilePath()).path() + + QLatin1Char('/') + proFileInfo->projectName() + QLatin1String(".desktop"); + if (!QFile::exists(desktopFilePath)) { + const QString desktopTemplate = QLatin1String("[Desktop Entry]\nEncoding=UTF-8\n" + "Version=1.0\nType=Application\nTerminal=false\nName=%1\nExec=%2\n" + "Icon=%1\nX-Window-Icon=\nX-HildonDesk-ShowInToolbar=true\n" + "X-Osso-Type=application/x-executable\n"); + Utils::FileSaver saver(desktopFilePath); + saver.write(desktopTemplate.arg(proFileInfo->projectName(), + proFileInfo->remoteExecutableFilePath()).toUtf8()); + if (!saver.finalize(this)) + return; + } + + DeployableFile d; + d.remoteDir = QLatin1String("/usr/share/applications"); + if (qobject_cast(deployConfiguration()->target())) + d.remoteDir += QLatin1String("/hildon"); + d.localFilePath = desktopFilePath; + if (!deployConfiguration()->deploymentSettingsAssistant()->addDeployableToProFile(proFileInfo, + QLatin1String("desktopfile"), d)) { + QMessageBox::critical(this, tr("Project File Update Failed"), + tr("Could not update the project file.")); + } else { + ui->addDesktopFileButton->setEnabled(false); + } +} + +void MaemoDeployConfigurationWidget::addIcon() +{ + DeployableFilesPerProFile * const proFileInfo = m_remoteLinuxWidget->currentModel(); + const int iconDim = MaemoGlobal::applicationIconSize(deployConfiguration()->supportedOsType()); + const QString origFilePath = QFileDialog::getOpenFileName(this, + tr("Choose Icon (will be scaled to %1x%1 pixels, if necessary)").arg(iconDim), + proFileInfo->projectDir(), QLatin1String("(*.png)")); + if (origFilePath.isEmpty()) + return; + QPixmap pixmap(origFilePath); + if (pixmap.isNull()) { + QMessageBox::critical(this, tr("Invalid Icon"), + tr("Unable to read image")); + return; + } + const QSize iconSize(iconDim, iconDim); + if (pixmap.size() != iconSize) + pixmap = pixmap.scaled(iconSize); + const QString newFileName = proFileInfo->projectName() + QLatin1Char('.') + + QFileInfo(origFilePath).suffix(); + const QString newFilePath = proFileInfo->projectDir() + QLatin1Char('/') + newFileName; + if (!pixmap.save(newFilePath)) { + QMessageBox::critical(this, tr("Failed to Save Icon"), + tr("Could not save icon to '%1'.").arg(newFilePath)); + return; + } + + if (!deployConfiguration()->deploymentSettingsAssistant()->addDeployableToProFile(proFileInfo, + QLatin1String("icon"), DeployableFile(newFilePath, remoteIconDir()))) { + QMessageBox::critical(this, tr("Project File Update Failed"), + tr("Could not update the project file.")); + } else { + ui->addIconButton->setEnabled(false); + } +} + +bool MaemoDeployConfigurationWidget::canAddDesktopFile(const DeployableFilesPerProFile *proFileInfo) const +{ + return proFileInfo && proFileInfo->isApplicationProject() + && deployConfiguration()->localDesktopFilePath(proFileInfo).isEmpty(); +} + +bool MaemoDeployConfigurationWidget::canAddIcon(const DeployableFilesPerProFile *proFileInfo) const +{ + return proFileInfo && proFileInfo->isApplicationProject() + && remoteIconFilePath(proFileInfo).isEmpty(); +} + +QString MaemoDeployConfigurationWidget::remoteIconFilePath(const DeployableFilesPerProFile *proFileInfo) const +{ + QTC_ASSERT(proFileInfo->projectType() == ApplicationTemplate, return QString()); + + const QStringList imageTypes = QStringList() << QLatin1String("jpg") << QLatin1String("png") + << QLatin1String("svg"); + for (int i = 0; i < proFileInfo->rowCount(); ++i) { + const DeployableFile &d = proFileInfo->deployableAt(i); + const QString extension = QFileInfo(d.localFilePath).suffix(); + if (d.remoteDir.startsWith(remoteIconDir()) && imageTypes.contains(extension)) + return d.remoteDir + QLatin1Char('/') + QFileInfo(d.localFilePath).fileName(); + } + return QString(); +} + +QString MaemoDeployConfigurationWidget::remoteIconDir() const +{ + return QString::fromLocal8Bit("/usr/share/icons/hicolor/%1x%1/apps") + .arg(MaemoGlobal::applicationIconSize(deployConfiguration()->supportedOsType())); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemodeployconfigurationwidget.h b/src/plugins/madde/maemodeployconfigurationwidget.h new file mode 100644 index 00000000000..5c24f666a3a --- /dev/null +++ b/src/plugins/madde/maemodeployconfigurationwidget.h @@ -0,0 +1,84 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMODEPLOYCONFIGURATIONWIDGET_H +#define MAEMODEPLOYCONFIGURATIONWIDGET_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { +class MaemoDeployConfigurationWidget; +} +QT_END_NAMESPACE + +namespace RemoteLinux { +class DeployableFilesPerProFile; +class RemoteLinuxDeployConfigurationWidget; +} + +namespace Madde { +namespace Internal { +class Qt4MaemoDeployConfiguration; + +class MaemoDeployConfigurationWidget : public ProjectExplorer::DeployConfigurationWidget +{ + Q_OBJECT + +public: + explicit MaemoDeployConfigurationWidget(QWidget *parent = 0); + ~MaemoDeployConfigurationWidget(); + + void init(ProjectExplorer::DeployConfiguration *dc); + + Qt4MaemoDeployConfiguration *deployConfiguration() const; + +private slots: + void addDesktopFile(); + void addIcon(); + void handleDeploymentInfoToBeReset(); + void handleCurrentModelChanged(const RemoteLinux::DeployableFilesPerProFile *proFileInfo); + +private: + bool canAddDesktopFile(const RemoteLinux::DeployableFilesPerProFile *proFileInfo) const; + bool canAddIcon(const RemoteLinux::DeployableFilesPerProFile *proFileInfo) const; + QString remoteIconFilePath(const RemoteLinux::DeployableFilesPerProFile *proFileInfo) const; + QString remoteIconDir() const; + + Ui::MaemoDeployConfigurationWidget *ui; + RemoteLinux::RemoteLinuxDeployConfigurationWidget * const m_remoteLinuxWidget; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMODEPLOYCONFIGURATIONWIDGET_H diff --git a/src/plugins/madde/maemodeployconfigurationwidget.ui b/src/plugins/madde/maemodeployconfigurationwidget.ui new file mode 100644 index 00000000000..6cca3cac017 --- /dev/null +++ b/src/plugins/madde/maemodeployconfigurationwidget.ui @@ -0,0 +1,48 @@ + + + MaemoDeployConfigurationWidget + + + + 0 + 0 + 273 + 45 + + + + Form + + + + + + Add Desktop File + + + + + + + Add Launcher Icon... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + diff --git a/src/plugins/madde/maemodeploymentmounter.cpp b/src/plugins/madde/maemodeploymentmounter.cpp new file mode 100644 index 00000000000..677b3d0e9be --- /dev/null +++ b/src/plugins/madde/maemodeploymentmounter.cpp @@ -0,0 +1,215 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemodeploymentmounter.h" + +#include "maemoglobal.h" +#include "maemoremotemounter.h" + +#include +#include +#include +#include +#include + +using namespace Qt4ProjectManager; +using namespace RemoteLinux; +using namespace Utils; + +namespace Madde { +namespace Internal { + +MaemoDeploymentMounter::MaemoDeploymentMounter(QObject *parent) + : QObject(parent), + m_state(Inactive), + m_mounter(new MaemoRemoteMounter(this)), + m_portsGatherer(new RemoteLinuxUsedPortsGatherer(this)) +{ + connect(m_mounter, SIGNAL(error(QString)), SLOT(handleMountError(QString))); + connect(m_mounter, SIGNAL(mounted()), SLOT(handleMounted())); + connect(m_mounter, SIGNAL(unmounted()), SLOT(handleUnmounted())); + connect(m_mounter, SIGNAL(reportProgress(QString)), + SIGNAL(reportProgress(QString))); + connect(m_mounter, SIGNAL(debugOutput(QString)), + SIGNAL(debugOutput(QString))); + + connect(m_portsGatherer, SIGNAL(error(QString)), + SLOT(handlePortsGathererError(QString))); + connect(m_portsGatherer, SIGNAL(portListReady()), + SLOT(handlePortListReady())); +} + +MaemoDeploymentMounter::~MaemoDeploymentMounter() {} + +void MaemoDeploymentMounter::setupMounts(const SshConnection::Ptr &connection, + const LinuxDeviceConfiguration::ConstPtr &devConf, + const QList &mountSpecs, + const Qt4BuildConfiguration *bc) +{ + QTC_ASSERT(m_state == Inactive, return); + + m_mountSpecs = mountSpecs; + m_connection = connection; + m_devConf = devConf; + m_mounter->setConnection(m_connection, m_devConf); + m_buildConfig = bc; + connect(m_connection.data(), SIGNAL(error(Utils::SshError)), + SLOT(handleConnectionError())); + setState(UnmountingOldDirs); + unmount(); +} + +void MaemoDeploymentMounter::tearDownMounts() +{ + QTC_ASSERT(m_state == Mounted, return); + + setState(UnmountingCurrentMounts); + unmount(); +} + +void MaemoDeploymentMounter::setupMounter() +{ + QTC_ASSERT(m_state == UnmountingOldDirs, return); + + setState(UnmountingCurrentDirs); + + m_mounter->resetMountSpecifications(); + m_mounter->setBuildConfiguration(m_buildConfig); + foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs) + m_mounter->addMountSpecification(mountSpec, true); + unmount(); +} + +void MaemoDeploymentMounter::unmount() +{ + QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs + || m_state == UnmountingCurrentMounts, return); + + if (m_mounter->hasValidMountSpecifications()) + m_mounter->unmount(); + else + handleUnmounted(); +} + +void MaemoDeploymentMounter::handleMounted() +{ + QTC_ASSERT(m_state == Mounting || m_state == Inactive, return); + + if (m_state == Inactive) + return; + + setState(Mounted); + emit setupDone(); +} + +void MaemoDeploymentMounter::handleUnmounted() +{ + QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs + || m_state == UnmountingCurrentMounts || m_state == Inactive, return); + + switch (m_state) { + case UnmountingOldDirs: + setupMounter(); + break; + case UnmountingCurrentDirs: + setState(GatheringPorts); + m_portsGatherer->start(m_connection, m_devConf); + break; + case UnmountingCurrentMounts: + setState(Inactive); + emit tearDownDone(); + break; + case Inactive: + default: + break; + } +} + +void MaemoDeploymentMounter::handlePortsGathererError(const QString &errorMsg) +{ + QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return); + + if (m_state == Inactive) + return; + + setState(Inactive); + m_mounter->resetMountSpecifications(); + emit error(errorMsg); +} + +void MaemoDeploymentMounter::handlePortListReady() +{ + QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return); + + if (m_state == Inactive) + return; + + setState(Mounting); + m_freePorts = MaemoGlobal::freePorts(m_devConf, m_buildConfig->qtVersion()); + m_mounter->mount(&m_freePorts, m_portsGatherer); +} + +void MaemoDeploymentMounter::handleMountError(const QString &errorMsg) +{ + QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs + || m_state == UnmountingCurrentMounts || m_state == Mounting || m_state == Mounted + || m_state == Inactive, return); + + if (m_state == Inactive) + return; + + setState(Inactive); + emit error(errorMsg); +} + +void MaemoDeploymentMounter::handleConnectionError() +{ + if (m_state == Inactive) + return; + + setState(Inactive); + emit error(tr("Connection failed: %1").arg(m_connection->errorString())); +} + +void MaemoDeploymentMounter::setState(State newState) +{ + if (m_state == newState) + return; + if (newState == Inactive && m_connection) { + disconnect(m_connection.data(), 0, this, 0); + m_connection.clear(); + } + m_state = newState; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemodeploymentmounter.h b/src/plugins/madde/maemodeploymentmounter.h new file mode 100644 index 00000000000..ec594be101e --- /dev/null +++ b/src/plugins/madde/maemodeploymentmounter.h @@ -0,0 +1,108 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMODEPLOYMENTMOUNTER_H +#define MAEMODEPLOYMENTMOUNTER_H + +#include "maemomountspecification.h" + +#include + +#include +#include +#include + +namespace Utils { class SshConnection; } +namespace Qt4ProjectManager { class Qt4BuildConfiguration; } + +namespace RemoteLinux { +class LinuxDeviceConfiguration; +class RemoteLinuxUsedPortsGatherer; +} + +namespace Madde { +namespace Internal { +class MaemoRemoteMounter; + +class MaemoDeploymentMounter : public QObject +{ + Q_OBJECT +public: + explicit MaemoDeploymentMounter(QObject *parent = 0); + ~MaemoDeploymentMounter(); + + // Connection must be in connected state. + void setupMounts(const QSharedPointer &connection, + const QSharedPointer &devConf, + const QList &mountSpecs, + const Qt4ProjectManager::Qt4BuildConfiguration *bc); + void tearDownMounts(); + +signals: + void debugOutput(const QString &output); + void setupDone(); + void tearDownDone(); + void error(const QString &error); + void reportProgress(const QString &message); + +private slots: + void handleMounted(); + void handleUnmounted(); + void handleMountError(const QString &errorMsg); + void handlePortsGathererError(const QString &errorMsg); + void handlePortListReady(); + void handleConnectionError(); + +private: + enum State { + Inactive, UnmountingOldDirs, UnmountingCurrentDirs, GatheringPorts, + Mounting, Mounted, UnmountingCurrentMounts + }; + + void unmount(); + void setupMounter(); + void setState(State newState); + + State m_state; + QSharedPointer m_connection; + QSharedPointer m_devConf; + MaemoRemoteMounter * const m_mounter; + RemoteLinux::RemoteLinuxUsedPortsGatherer * const m_portsGatherer; + RemoteLinux::PortList m_freePorts; + QList m_mountSpecs; + const Qt4ProjectManager::Qt4BuildConfiguration *m_buildConfig; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMODEPLOYMENTMOUNTER_H diff --git a/src/plugins/madde/maemodeploystepfactory.cpp b/src/plugins/madde/maemodeploystepfactory.cpp new file mode 100644 index 00000000000..ad5b46fb502 --- /dev/null +++ b/src/plugins/madde/maemodeploystepfactory.cpp @@ -0,0 +1,204 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemodeploystepfactory.h" + +#include "maddeuploadandinstallpackagesteps.h" +#include "maemodeploybymountsteps.h" +#include "maemoinstalltosysrootstep.h" +#include "qt4maemotarget.h" +#include "qt4maemodeployconfiguration.h" + +#include +#include +#include +#include +#include +#include + +#include + +using namespace ProjectExplorer; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { +namespace { +const QString OldMaemoDeployStepId(QLatin1String("Qt4ProjectManager.MaemoDeployStep")); +} // anonymous namespace + +MaemoDeployStepFactory::MaemoDeployStepFactory(QObject *parent) + : IBuildStepFactory(parent) +{ +} + +QStringList MaemoDeployStepFactory::availableCreationIds(BuildStepList *parent) const +{ + QStringList ids; + if (!qobject_cast(parent->parent())) + return ids; + + AbstractQt4MaemoTarget * const maemoTarget + = qobject_cast(parent->target()); + if (maemoTarget) + ids << MaemoMakeInstallToSysrootStep::Id; + if (qobject_cast(parent->target())) { + ids << MaemoInstallDebianPackageToSysrootStep::Id; + ids << MaemoUploadAndInstallPackageStep::stepId(); + } else if (qobject_cast(parent->target())) { + ids << MaemoInstallRpmPackageToSysrootStep::Id; + ids << MeegoUploadAndInstallPackageStep::stepId(); + } + if (qobject_cast(parent->target())) + ids << GenericDirectUploadStep::stepId(); + if (qobject_cast(parent->target())) + ids << MaemoInstallPackageViaMountStep::stepId() << MaemoCopyFilesViaMountStep::stepId(); + + return ids; +} + +QString MaemoDeployStepFactory::displayNameForId(const QString &id) const +{ + if (id == MaemoInstallPackageViaMountStep::stepId()) + return MaemoInstallPackageViaMountStep::displayName(); + else if (id == MaemoCopyFilesViaMountStep::stepId()) + return MaemoCopyFilesViaMountStep::displayName(); + else if (id == MaemoUploadAndInstallPackageStep::stepId()) + return MaemoUploadAndInstallPackageStep::displayName(); + else if (id == MeegoUploadAndInstallPackageStep::stepId()) + return MeegoUploadAndInstallPackageStep::displayName(); + else if (id == MaemoInstallDebianPackageToSysrootStep::Id) + return MaemoInstallDebianPackageToSysrootStep::displayName(); + else if (id == MaemoInstallRpmPackageToSysrootStep::Id) + return MaemoInstallRpmPackageToSysrootStep::displayName(); + else if (id == MaemoCopyToSysrootStep::Id) + return MaemoCopyToSysrootStep::displayName(); + else if (id == MaemoMakeInstallToSysrootStep::Id) + return MaemoMakeInstallToSysrootStep::displayName(); + else if (id == GenericDirectUploadStep::stepId()) + return GenericDirectUploadStep::displayName(); + return QString(); +} + +bool MaemoDeployStepFactory::canCreate(BuildStepList *parent, const QString &id) const +{ + return availableCreationIds(parent).contains(id) && !parent->contains(id); +} + +BuildStep *MaemoDeployStepFactory::create(BuildStepList *parent, const QString &id) +{ + const Target * const t = parent->target(); + + if (id == MaemoInstallDebianPackageToSysrootStep::Id) { + return new MaemoInstallDebianPackageToSysrootStep(parent); + } else if (id == MaemoInstallRpmPackageToSysrootStep::Id) { + return new MaemoInstallRpmPackageToSysrootStep(parent); + } else if (id == MaemoCopyToSysrootStep::Id) { + return new MaemoCopyToSysrootStep(parent); + } else if (id == MaemoMakeInstallToSysrootStep::Id) { + return new MaemoMakeInstallToSysrootStep(parent); + } else if (id == MaemoInstallPackageViaMountStep::stepId() + || (id == OldMaemoDeployStepId && qobject_cast< const Qt4Maemo5Target *>(t))) { + return new MaemoInstallPackageViaMountStep(parent); + } else if (id == MaemoCopyFilesViaMountStep::stepId()) { + return new MaemoCopyFilesViaMountStep(parent); + } else if (id == MaemoUploadAndInstallPackageStep::stepId() + || (id == OldMaemoDeployStepId && (qobject_cast(t)))) { + return new MaemoUploadAndInstallPackageStep(parent); + } else if (id == MeegoUploadAndInstallPackageStep::stepId() + || (id == OldMaemoDeployStepId && (qobject_cast(t)))) { + return new MeegoUploadAndInstallPackageStep(parent); + } else if (id == GenericDirectUploadStep::stepId()) { + return new GenericDirectUploadStep(parent, id); + } + + return 0; +} + +bool MaemoDeployStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const +{ + return canCreate(parent, idFromMap(map)) + || idFromMap(map) == OldMaemoDeployStepId; +} + +BuildStep *MaemoDeployStepFactory::restore(BuildStepList *parent, const QVariantMap &map) +{ + Q_ASSERT(canRestore(parent, map)); + BuildStep * const step = create(parent, idFromMap(map)); + if (!step->fromMap(map)) { + delete step; + return 0; + } + return step; +} + +bool MaemoDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const +{ + return canCreate(parent, product->id()); +} + +BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *product) +{ + Q_ASSERT(canClone(parent, product)); + if (product->id() == MaemoInstallPackageViaMountStep::stepId()) { + return new MaemoInstallPackageViaMountStep(parent, + qobject_cast(product)); + } else if (product->id() == MaemoCopyFilesViaMountStep::stepId()) { + return new MaemoCopyFilesViaMountStep(parent, + qobject_cast(product)); + } else if (product->id() == MaemoUploadAndInstallPackageStep::stepId()) { + return new MaemoUploadAndInstallPackageStep(parent, + qobject_cast(product)); + } else if (product->id() == MeegoUploadAndInstallPackageStep::stepId()) { + return new MeegoUploadAndInstallPackageStep(parent, + qobject_cast(product)); + } else if (product->id() == MaemoInstallDebianPackageToSysrootStep::Id) { + return new MaemoInstallDebianPackageToSysrootStep(parent, + qobject_cast(product)); + } else if (product->id() == MaemoInstallRpmPackageToSysrootStep::Id) { + return new MaemoInstallRpmPackageToSysrootStep(parent, + qobject_cast(product)); + } else if (product->id() == MaemoCopyToSysrootStep::Id) { + return new MaemoCopyToSysrootStep(parent, + qobject_cast(product)); + } else if (product->id() == MaemoMakeInstallToSysrootStep::Id) { + return new MaemoMakeInstallToSysrootStep(parent, + qobject_cast(product)); + } else if (product->id() == GenericDirectUploadStep::stepId()) { + return new GenericDirectUploadStep(parent, + qobject_cast(product)); + } + return 0; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemodeploystepfactory.h b/src/plugins/madde/maemodeploystepfactory.h new file mode 100644 index 00000000000..96dd6073952 --- /dev/null +++ b/src/plugins/madde/maemodeploystepfactory.h @@ -0,0 +1,69 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMODEPLOYSTEPFACTORY_H +#define MAEMODEPLOYSTEPFACTORY_H + +#include + +namespace Madde { +namespace Internal { + +class MaemoDeployStepFactory : public ProjectExplorer::IBuildStepFactory +{ +public: + MaemoDeployStepFactory(QObject *parent = 0); + + virtual QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; + virtual QString displayNameForId(const QString &id) const; + + virtual bool canCreate(ProjectExplorer::BuildStepList *parent, + const QString &id) const; + virtual ProjectExplorer::BuildStep * + create(ProjectExplorer::BuildStepList *parent, const QString &id); + + virtual bool canRestore(ProjectExplorer::BuildStepList *parent, + const QVariantMap &map) const; + virtual ProjectExplorer::BuildStep * + restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); + + virtual bool canClone(ProjectExplorer::BuildStepList *parent, + ProjectExplorer::BuildStep *product) const; + virtual ProjectExplorer::BuildStep * + clone(ProjectExplorer::BuildStepList *parent, + ProjectExplorer::BuildStep *product); +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMODEPLOYSTEPFACTORY_H diff --git a/src/plugins/madde/maemodeviceconfigwizard.cpp b/src/plugins/madde/maemodeviceconfigwizard.cpp new file mode 100644 index 00000000000..e94f0d4bd9b --- /dev/null +++ b/src/plugins/madde/maemodeviceconfigwizard.cpp @@ -0,0 +1,640 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemodeviceconfigwizard.h" +#include "ui_maemodeviceconfigwizardkeycreationpage.h" +#include "ui_maemodeviceconfigwizardkeydeploymentpage.h" +#include "ui_maemodeviceconfigwizardpreviouskeysetupcheckpage.h" +#include "ui_maemodeviceconfigwizardreusekeyscheckpage.h" +#include "ui_maemodeviceconfigwizardstartpage.h" + +#include "maddedevicetester.h" +#include "maemoconstants.h" +#include "maemoglobal.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace RemoteLinux; +using namespace Utils; + +namespace Madde { +namespace Internal { +namespace { + +QString defaultUser(const QString &osType) +{ + if (osType == QLatin1String(MeeGoOsType)) + return QLatin1String("meego"); + return QLatin1String("developer"); +} + +QString defaultHost(LinuxDeviceConfiguration::DeviceType type) +{ + return QLatin1String(type == LinuxDeviceConfiguration::Hardware ? "192.168.2.15" : "localhost"); +} + +struct WizardData +{ + QString configName; + QString hostName; + QString osType; + SshConnectionParameters::AuthenticationType authType; + LinuxDeviceConfiguration::DeviceType deviceType; + QString privateKeyFilePath; + QString publicKeyFilePath; + QString userName; + QString password; + int sshPort; +}; + +enum PageId { + StartPageId, PreviousKeySetupCheckPageId, ReuseKeysCheckPageId, KeyCreationPageId, + KeyDeploymentPageId, FinalPageId +}; + +class MaemoDeviceConfigWizardStartPage : public QWizardPage +{ + Q_OBJECT + +public: + MaemoDeviceConfigWizardStartPage(QWidget *parent = 0) + : QWizardPage(parent), m_ui(new Ui::MaemoDeviceConfigWizardStartPage) + { + m_ui->setupUi(this); + setTitle(tr("General Information")); + setSubTitle(QLatin1String(" ")); // For Qt bug (background color) + + m_ui->osTypeComboBox->addItem(RemoteLinuxUtils::osTypeToString(QLatin1String(Maemo5OsType)), + QLatin1String(Maemo5OsType)); + m_ui->osTypeComboBox->addItem(RemoteLinuxUtils::osTypeToString(QLatin1String(HarmattanOsType)), + QLatin1String(HarmattanOsType)); + m_ui->osTypeComboBox->addItem(RemoteLinuxUtils::osTypeToString(QLatin1String(MeeGoOsType)), + QLatin1String(MeeGoOsType)); + + QButtonGroup *buttonGroup = new QButtonGroup(this); + buttonGroup->setExclusive(true); + buttonGroup->addButton(m_ui->hwButton); + buttonGroup->addButton(m_ui->emulatorButton); + connect(buttonGroup, SIGNAL(buttonClicked(int)), + SLOT(handleDeviceTypeChanged())); + + m_ui->nameLineEdit->setText(QLatin1String("(New Configuration)")); + m_ui->osTypeComboBox->setCurrentIndex(m_ui->osTypeComboBox->findData(QLatin1String(HarmattanOsType))); + m_ui->hwButton->setChecked(true); + handleDeviceTypeChanged(); + m_ui->hostNameLineEdit->setText(defaultHost(deviceType())); + m_ui->sshPortSpinBox->setMinimum(1); + m_ui->sshPortSpinBox->setMaximum(65535); + m_ui->sshPortSpinBox->setValue(22); + connect(m_ui->nameLineEdit, SIGNAL(textChanged(QString)), this, + SIGNAL(completeChanged())); + connect(m_ui->hostNameLineEdit, SIGNAL(textChanged(QString)), this, + SIGNAL(completeChanged())); + } + + virtual bool isComplete() const + { + return !configName().isEmpty() && !hostName().isEmpty(); + } + + QString configName() const { return m_ui->nameLineEdit->text().trimmed(); } + + QString hostName() const + { + return deviceType() == LinuxDeviceConfiguration::Emulator + ? defaultHost(LinuxDeviceConfiguration::Emulator) + : m_ui->hostNameLineEdit->text().trimmed(); + } + + QString osType() const + { + return m_ui->osTypeComboBox->itemData(m_ui->osTypeComboBox->currentIndex()).toString(); + } + + LinuxDeviceConfiguration::DeviceType deviceType() const + { + return m_ui->hwButton->isChecked() + ? LinuxDeviceConfiguration::Hardware : LinuxDeviceConfiguration::Emulator; + } + + int sshPort() const + { + return deviceType() == LinuxDeviceConfiguration::Emulator + ? 6666 : m_ui->sshPortSpinBox->value(); + } + +private slots: + void handleDeviceTypeChanged() + { + const bool enable = deviceType() == LinuxDeviceConfiguration::Hardware; + m_ui->hostNameLabel->setEnabled(enable); + m_ui->hostNameLineEdit->setEnabled(enable); + m_ui->sshPortLabel->setEnabled(enable); + m_ui->sshPortSpinBox->setEnabled(enable); + } + +private: + const QScopedPointer m_ui; +}; + +class MaemoDeviceConfigWizardPreviousKeySetupCheckPage : public QWizardPage +{ + Q_OBJECT +public: + MaemoDeviceConfigWizardPreviousKeySetupCheckPage(QWidget *parent) + : QWizardPage(parent), + m_ui(new Ui::MaemoDeviceConfigWizardCheckPreviousKeySetupPage) + { + m_ui->setupUi(this); + m_ui->privateKeyFilePathChooser->setExpectedKind(PathChooser::File); + setTitle(tr("Device Status Check")); + setSubTitle(QLatin1String(" ")); // For Qt bug (background color) + QButtonGroup * const buttonGroup = new QButtonGroup(this); + buttonGroup->setExclusive(true); + buttonGroup->addButton(m_ui->keyWasSetUpButton); + buttonGroup->addButton(m_ui->keyWasNotSetUpButton); + connect(buttonGroup, SIGNAL(buttonClicked(int)), + SLOT(handleSelectionChanged())); + connect(m_ui->privateKeyFilePathChooser, SIGNAL(changed(QString)), + this, SIGNAL(completeChanged())); + } + + virtual bool isComplete() const + { + return !keyBasedLoginWasSetup() + || m_ui->privateKeyFilePathChooser->isValid(); + } + + virtual void initializePage() + { + m_ui->keyWasNotSetUpButton->setChecked(true); + m_ui->privateKeyFilePathChooser->setPath(LinuxDeviceConfiguration::defaultPrivateKeyFilePath()); + handleSelectionChanged(); + } + + bool keyBasedLoginWasSetup() const { + return m_ui->keyWasSetUpButton->isChecked(); + } + + QString privateKeyFilePath() const { + return m_ui->privateKeyFilePathChooser->path(); + } + +private: + Q_SLOT void handleSelectionChanged() + { + m_ui->privateKeyFilePathChooser->setEnabled(keyBasedLoginWasSetup()); + emit completeChanged(); + } + + const QScopedPointer m_ui; +}; + +class MaemoDeviceConfigWizardReuseKeysCheckPage : public QWizardPage +{ + Q_OBJECT +public: + MaemoDeviceConfigWizardReuseKeysCheckPage(QWidget *parent) + : QWizardPage(parent), + m_ui(new Ui::MaemoDeviceConfigWizardReuseKeysCheckPage) + { + m_ui->setupUi(this); + setTitle(tr("Existing Keys Check")); + setSubTitle(QLatin1String(" ")); // For Qt bug (background color) + m_ui->publicKeyFilePathChooser->setExpectedKind(PathChooser::File); + m_ui->privateKeyFilePathChooser->setExpectedKind(PathChooser::File); + QButtonGroup * const buttonGroup = new QButtonGroup(this); + buttonGroup->setExclusive(true); + buttonGroup->addButton(m_ui->reuseButton); + buttonGroup->addButton(m_ui->dontReuseButton); + connect(buttonGroup, SIGNAL(buttonClicked(int)), + SLOT(handleSelectionChanged())); + connect(m_ui->privateKeyFilePathChooser, SIGNAL(changed(QString)), + this, SIGNAL(completeChanged())); + connect(m_ui->publicKeyFilePathChooser, SIGNAL(changed(QString)), + this, SIGNAL(completeChanged())); + } + + virtual bool isComplete() const + { + return !reuseKeys() || (m_ui->publicKeyFilePathChooser->isValid() + && m_ui->privateKeyFilePathChooser->isValid()); + } + + virtual void initializePage() + { + m_ui->dontReuseButton->setChecked(true); + m_ui->privateKeyFilePathChooser->setPath(LinuxDeviceConfiguration::defaultPrivateKeyFilePath()); + m_ui->publicKeyFilePathChooser->setPath(LinuxDeviceConfiguration::defaultPublicKeyFilePath()); + handleSelectionChanged(); + } + + bool reuseKeys() const { return m_ui->reuseButton->isChecked(); } + + QString privateKeyFilePath() const { + return m_ui->privateKeyFilePathChooser->path(); + } + + QString publicKeyFilePath() const { + return m_ui->publicKeyFilePathChooser->path(); + } + +private: + Q_SLOT void handleSelectionChanged() + { + m_ui->privateKeyFilePathLabel->setEnabled(reuseKeys()); + m_ui->privateKeyFilePathChooser->setEnabled(reuseKeys()); + m_ui->publicKeyFilePathLabel->setEnabled(reuseKeys()); + m_ui->publicKeyFilePathChooser->setEnabled(reuseKeys()); + emit completeChanged(); + } + + const QScopedPointer m_ui; +}; + +class MaemoDeviceConfigWizardKeyCreationPage : public QWizardPage +{ + Q_OBJECT +public: + MaemoDeviceConfigWizardKeyCreationPage(QWidget *parent) + : QWizardPage(parent), + m_ui(new Ui::MaemoDeviceConfigWizardKeyCreationPage) + { + m_ui->setupUi(this); + setTitle(tr("Key Creation")); + setSubTitle(QLatin1String(" ")); // For Qt bug (background color) + connect(m_ui->createKeysButton, SIGNAL(clicked()), SLOT(createKeys())); + } + + QString privateKeyFilePath() const { + return m_ui->keyDirPathChooser->path() + QLatin1String("/qtc_id_rsa"); + } + + QString publicKeyFilePath() const { + return privateKeyFilePath() + QLatin1String(".pub"); + } + + virtual void initializePage() + { + m_isComplete = false; + const QString &dir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + + QLatin1String("/.ssh"); + m_ui->keyDirPathChooser->setPath(dir); + enableInput(); + } + + virtual bool isComplete() const { return m_isComplete; } + +private: + + Q_SLOT void createKeys() + { + const QString &dirPath = m_ui->keyDirPathChooser->path(); + QFileInfo fi(dirPath); + if (fi.exists() && !fi.isDir()) { + QMessageBox::critical(this, tr("Cannot Create Keys"), + tr("The path you have entered is not a directory.")); + return; + } + if (!fi.exists() && !QDir::root().mkpath(dirPath)) { + QMessageBox::critical(this, tr("Cannot Create Keys"), + tr("The directory you have entered does not exist and " + "cannot be created.")); + return; + } + + m_ui->keyDirPathChooser->setEnabled(false); + m_ui->createKeysButton->setEnabled(false); + m_ui->statusLabel->setText(tr("Creating keys ... ")); + SshKeyGenerator keyGenerator; + if (!keyGenerator.generateKeys(SshKeyGenerator::Rsa, + SshKeyGenerator::Mixed, 1024)) { + QMessageBox::critical(this, tr("Cannot Create Keys"), + tr("Key creation failed: %1").arg(keyGenerator.error())); + enableInput(); + return; + } + + if (!saveFile(privateKeyFilePath(), keyGenerator.privateKey()) + || !saveFile(publicKeyFilePath(), keyGenerator.publicKey())) { + enableInput(); + return; + } + QFile::setPermissions(privateKeyFilePath(), + QFile::ReadOwner | QFile::WriteOwner); + + m_ui->statusLabel->setText(m_ui->statusLabel->text() + tr("Done.")); + m_isComplete = true; + emit completeChanged(); + } + + bool saveFile(const QString &filePath, const QByteArray &data) + { + Utils::FileSaver saver(filePath); + saver.write(data); + if (!saver.finalize()) { + QMessageBox::critical(this, tr("Could Not Save Key File"), saver.errorString()); + return false; + } + return true; + } + + void enableInput() + { + m_ui->keyDirPathChooser->setEnabled(true); + m_ui->createKeysButton->setEnabled(true); + m_ui->statusLabel->clear(); + } + + const QScopedPointer m_ui; + bool m_isComplete; +}; + +class MaemoDeviceConfigWizardKeyDeploymentPage : public QWizardPage +{ + Q_OBJECT +public: + MaemoDeviceConfigWizardKeyDeploymentPage(const WizardData &wizardData, + QWidget *parent = 0) + : QWizardPage(parent), + m_ui(new Ui::MaemoDeviceConfigWizardKeyDeploymentPage), + m_wizardData(wizardData), + m_keyDeployer(new SshKeyDeployer(this)) + { + m_ui->setupUi(this); + m_instructionTextTemplate = m_ui->instructionLabel->text(); + setTitle(tr("Key Deployment")); + setSubTitle(QLatin1String(" ")); // For Qt bug (background color) + connect(m_ui->deviceAddressLineEdit, SIGNAL(textChanged(QString)), + SLOT(enableOrDisableButton())); + connect(m_ui->passwordLineEdit, SIGNAL(textChanged(QString)), + SLOT(enableOrDisableButton())); + connect(m_ui->deployButton, SIGNAL(clicked()), SLOT(deployKey())); + connect(m_keyDeployer, SIGNAL(error(QString)), + SLOT(handleKeyDeploymentError(QString))); + connect(m_keyDeployer, SIGNAL(finishedSuccessfully()), + SLOT(handleKeyDeploymentSuccess())); + } + + virtual void initializePage() + { + m_isComplete = false; + m_ui->deviceAddressLineEdit->setText(m_wizardData.hostName); + m_ui->instructionLabel->setText(QString(m_instructionTextTemplate) + .replace(QLatin1String("%%%maddev%%%"), + MaemoGlobal::madDeveloperUiName(m_wizardData.osType))); + m_ui->passwordLineEdit->clear(); + enableInput(); + } + + virtual bool isComplete() const { return m_isComplete; } + + QString hostAddress() const { + return m_ui->deviceAddressLineEdit->text().trimmed(); + } + +private: + Q_SLOT void enableOrDisableButton() + { + m_ui->deployButton->setEnabled(!hostAddress().isEmpty() + && !password().isEmpty()); + } + + Q_SLOT void deployKey() + { + using namespace Utils; + m_ui->deviceAddressLineEdit->setEnabled(false); + m_ui->passwordLineEdit->setEnabled(false); + m_ui->deployButton->setEnabled(false); + SshConnectionParameters sshParams(SshConnectionParameters::NoProxy); + sshParams.authenticationType = SshConnectionParameters::AuthenticationByPassword; + sshParams.host = hostAddress(); + sshParams.port = m_wizardData.sshPort; + sshParams.password = password(); + sshParams.timeout = 10; + sshParams.userName = defaultUser(m_wizardData.osType); + m_ui->statusLabel->setText(tr("Deploying... ")); + m_keyDeployer->deployPublicKey(sshParams, m_wizardData.publicKeyFilePath); + } + + Q_SLOT void handleKeyDeploymentError(const QString &errorMsg) + { + QMessageBox::critical(this, tr("Key Deployment Failure"), errorMsg); + enableInput(); + } + + Q_SLOT void handleKeyDeploymentSuccess() + { + QMessageBox::information(this, tr("Key Deployment Success"), + tr("The key was successfully deployed. You may now close " + "the \"%1\" application and continue.") + .arg(MaemoGlobal::madDeveloperUiName(m_wizardData.osType))); + m_ui->statusLabel->setText(m_ui->statusLabel->text() + tr("Done.")); + m_isComplete = true; + emit completeChanged(); + } + + void enableInput() + { + m_ui->deviceAddressLineEdit->setEnabled(true); + m_ui->passwordLineEdit->setEnabled(true); + m_ui->statusLabel->clear(); + enableOrDisableButton(); + } + + QString password() const { + return m_ui->passwordLineEdit->text().trimmed(); + } + + + const QScopedPointer m_ui; + bool m_isComplete; + const WizardData &m_wizardData; + SshKeyDeployer * const m_keyDeployer; + QString m_instructionTextTemplate; +}; + +class MaemoDeviceConfigWizardFinalPage : public GenericLinuxDeviceConfigurationWizardFinalPage +{ + Q_OBJECT +public: + MaemoDeviceConfigWizardFinalPage(const WizardData &wizardData, QWidget *parent) + : GenericLinuxDeviceConfigurationWizardFinalPage(parent), m_wizardData(wizardData) + { + } + +private: + QString infoText() const + { + if (m_wizardData.deviceType == LinuxDeviceConfiguration::Emulator) + return tr("The new device configuration will now be created."); + return GenericLinuxDeviceConfigurationWizardFinalPage::infoText(); + } + + const WizardData &m_wizardData; +}; + +} // anonymous namespace + +struct MaemoDeviceConfigWizardPrivate +{ + MaemoDeviceConfigWizardPrivate(QWidget *parent) + : startPage(parent), + previousKeySetupPage(parent), + reuseKeysCheckPage(parent), + keyCreationPage(parent), + keyDeploymentPage(wizardData, parent), + finalPage(wizardData, parent) + { + } + + WizardData wizardData; + MaemoDeviceConfigWizardStartPage startPage; + MaemoDeviceConfigWizardPreviousKeySetupCheckPage previousKeySetupPage; + MaemoDeviceConfigWizardReuseKeysCheckPage reuseKeysCheckPage; + MaemoDeviceConfigWizardKeyCreationPage keyCreationPage; + MaemoDeviceConfigWizardKeyDeploymentPage keyDeploymentPage; + MaemoDeviceConfigWizardFinalPage finalPage; +}; + + +MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(QWidget *parent) + : ILinuxDeviceConfigurationWizard(parent), d(new MaemoDeviceConfigWizardPrivate(this)) +{ + setWindowTitle(tr("New Device Configuration Setup")); + setPage(StartPageId, &d->startPage); + setPage(PreviousKeySetupCheckPageId, &d->previousKeySetupPage); + setPage(ReuseKeysCheckPageId, &d->reuseKeysCheckPage); + setPage(KeyCreationPageId, &d->keyCreationPage); + setPage(KeyDeploymentPageId, &d->keyDeploymentPage); + setPage(FinalPageId, &d->finalPage); + d->finalPage.setCommitPage(true); +} + +MaemoDeviceConfigWizard::~MaemoDeviceConfigWizard() +{ + delete d; +} + +LinuxDeviceConfiguration::Ptr MaemoDeviceConfigWizard::deviceConfiguration() +{ + bool doTest; + QString freePortsSpec; + Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); + sshParams.userName = defaultUser(d->wizardData.osType); + sshParams.host = d->wizardData.hostName; + sshParams.port = d->wizardData.sshPort; + if (d->wizardData.deviceType == LinuxDeviceConfiguration::Emulator) { + sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByPassword; + sshParams.password = d->wizardData.osType == QLatin1String(MeeGoOsType) + ? QLatin1String("meego") : QString(); + sshParams.timeout = 30; + freePortsSpec = QLatin1String("13219,14168"); + doTest = false; + } else { + sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByKey; + sshParams.privateKeyFile = d->wizardData.privateKeyFilePath; + sshParams.timeout = 10; + freePortsSpec = QLatin1String("10000-10100"); + doTest = true; + } + const LinuxDeviceConfiguration::Ptr devConf = LinuxDeviceConfiguration::create(d->wizardData.configName, + d->wizardData.osType, d->wizardData.deviceType, PortList::fromString(freePortsSpec), + sshParams); + if (doTest) { + LinuxDeviceTestDialog dlg(devConf, new MaddeDeviceTester(this), this); + dlg.exec(); + } + return devConf; +} + +int MaemoDeviceConfigWizard::nextId() const +{ + switch (currentId()) { + case StartPageId: + d->wizardData.configName = d->startPage.configName(); + d->wizardData.osType = d->startPage.osType(); + d->wizardData.deviceType = d->startPage.deviceType(); + d->wizardData.hostName = d->startPage.hostName(); + d->wizardData.sshPort = d->startPage.sshPort(); + if (d->wizardData.deviceType == LinuxDeviceConfiguration::Emulator) + return FinalPageId; + return PreviousKeySetupCheckPageId; + case PreviousKeySetupCheckPageId: + if (d->previousKeySetupPage.keyBasedLoginWasSetup()) { + d->wizardData.privateKeyFilePath + = d->previousKeySetupPage.privateKeyFilePath(); + return FinalPageId; + } else { + return ReuseKeysCheckPageId; + } + case ReuseKeysCheckPageId: + if (d->reuseKeysCheckPage.reuseKeys()) { + d->wizardData.privateKeyFilePath + = d->reuseKeysCheckPage.privateKeyFilePath(); + d->wizardData.publicKeyFilePath + = d->reuseKeysCheckPage.publicKeyFilePath(); + return KeyDeploymentPageId; + } else { + return KeyCreationPageId; + } + case KeyCreationPageId: + d->wizardData.privateKeyFilePath + = d->keyCreationPage.privateKeyFilePath(); + d->wizardData.publicKeyFilePath + = d->keyCreationPage.publicKeyFilePath(); + return KeyDeploymentPageId; + case KeyDeploymentPageId: + d->wizardData.hostName = d->keyDeploymentPage.hostAddress(); + return FinalPageId; + case FinalPageId: return -1; + default: + Q_ASSERT(false); + return -1; + } +} + +} // namespace Internal +} // namespace Madde + +#include "maemodeviceconfigwizard.moc" diff --git a/src/plugins/madde/maemodeviceconfigwizard.h b/src/plugins/madde/maemodeviceconfigwizard.h new file mode 100644 index 00000000000..2b164382cb5 --- /dev/null +++ b/src/plugins/madde/maemodeviceconfigwizard.h @@ -0,0 +1,61 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMODEVICECONFIGWIZARD_H +#define MAEMODEVICECONFIGWIZARD_H + +#include + +namespace Madde { +namespace Internal { + +struct MaemoDeviceConfigWizardPrivate; + +class MaemoDeviceConfigWizard : public RemoteLinux::ILinuxDeviceConfigurationWizard +{ + Q_OBJECT + +public: + explicit MaemoDeviceConfigWizard(QWidget *parent = 0); + ~MaemoDeviceConfigWizard(); + + RemoteLinux::LinuxDeviceConfiguration::Ptr deviceConfiguration(); + + virtual int nextId() const; + +private: + MaemoDeviceConfigWizardPrivate *d; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMODEVICECONFIGWIZARD_H diff --git a/src/plugins/madde/maemodeviceconfigwizardkeycreationpage.ui b/src/plugins/madde/maemodeviceconfigwizardkeycreationpage.ui new file mode 100644 index 00000000000..2d38c79d3f0 --- /dev/null +++ b/src/plugins/madde/maemodeviceconfigwizardkeycreationpage.ui @@ -0,0 +1,79 @@ + + + MaemoDeviceConfigWizardKeyCreationPage + + + + 0 + 0 + 447 + 115 + + + + WizardPage + + + + + + Qt Creator will now generate a new pair of keys. Please enter the directory to save the key files in and then press "Create Keys". + + + true + + + + + + + + + Directory: + + + + + + + + + + Create Keys + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + Utils::PathChooser + QWidget +
utils/pathchooser.h
+
+
+ + +
diff --git a/src/plugins/madde/maemodeviceconfigwizardkeydeploymentpage.ui b/src/plugins/madde/maemodeviceconfigwizardkeydeploymentpage.ui new file mode 100644 index 00000000000..ec9069fff55 --- /dev/null +++ b/src/plugins/madde/maemodeviceconfigwizardkeydeploymentpage.ui @@ -0,0 +1,159 @@ + + + MaemoDeviceConfigWizardKeyDeploymentPage + + + + 0 + 0 + 470 + 322 + + + + WizardPage + + + + + + To deploy the public key to your device, please execute the following steps: +<ul> +<li>Connect the device to your computer (unless you plan to connect via WLAN).</li> +<li>On the device, start the "%%%maddev%%%" application.</li> +<li>In "%%%maddev%%%", configure the device's IP address to the one shown below (or edit the field below to match the address you have configured).</li> +<li>In "%%%maddev%%%", press "Developer Password" and enter it in the field below.</li> +<li>Click "Deploy Key"</li> + + + + Qt::RichText + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + Device address: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Password: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + Deploy Key + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + diff --git a/src/plugins/madde/maemodeviceconfigwizardpreviouskeysetupcheckpage.ui b/src/plugins/madde/maemodeviceconfigwizardpreviouskeysetupcheckpage.ui new file mode 100644 index 00000000000..46f20e9e1ad --- /dev/null +++ b/src/plugins/madde/maemodeviceconfigwizardpreviouskeysetupcheckpage.ui @@ -0,0 +1,96 @@ + + + MaemoDeviceConfigWizardCheckPreviousKeySetupPage + + + + 0 + 0 + 621 + 121 + + + + WizardPage + + + + + + Has a passwordless (key-based) login already been set up for this device? + + + true + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + Yes, and the private key is located at + + + + + + + + + + + + No + + + + + + + + + + + Qt::Vertical + + + + 20 + 44 + + + + + + + + + Utils::PathChooser + QWidget +
utils/pathchooser.h
+
+
+ + +
diff --git a/src/plugins/madde/maemodeviceconfigwizardreusekeyscheckpage.ui b/src/plugins/madde/maemodeviceconfigwizardreusekeyscheckpage.ui new file mode 100644 index 00000000000..8332f17a757 --- /dev/null +++ b/src/plugins/madde/maemodeviceconfigwizardreusekeyscheckpage.ui @@ -0,0 +1,133 @@ + + + MaemoDeviceConfigWizardReuseKeysCheckPage + + + + 0 + 0 + 574 + 185 + + + + WizardPage + + + + + + Do wou want to re-use an existing pair of keys or should a new one be created? + + + true + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + Re-use existing keys + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + File containing the public key: + + + + + + + File containing the private key: + + + + + + + + + + + + + + + + + Create new keys + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Utils::PathChooser + QWidget +
utils/pathchooser.h
+
+
+ + +
diff --git a/src/plugins/madde/maemodeviceconfigwizardstartpage.ui b/src/plugins/madde/maemodeviceconfigwizardstartpage.ui new file mode 100644 index 00000000000..4df4e3f8505 --- /dev/null +++ b/src/plugins/madde/maemodeviceconfigwizardstartpage.ui @@ -0,0 +1,133 @@ + + + MaemoDeviceConfigWizardStartPage + + + + 0 + 0 + 721 + 176 + + + + WizardPage + + + + + + The name to identify this configuration: + + + + + + + + + + The system running on the device: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + The kind of device: + + + + + + + + + Emulator + + + + + + + Hardware Device + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + The device's host name or IP address: + + + + + + + + + + The SSH server port: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/src/plugins/madde/maemoglobal.cpp b/src/plugins/madde/maemoglobal.cpp new file mode 100644 index 00000000000..1590034fc04 --- /dev/null +++ b/src/plugins/madde/maemoglobal.cpp @@ -0,0 +1,297 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemoglobal.h" + +#include "maemoconstants.h" +#include "maemoqemumanager.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Constants; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { +namespace { +static const QLatin1String binQmake("/bin/qmake" EXEC_SUFFIX); +} + +bool MaemoGlobal::isMaemoTargetId(const QString &id) +{ + return isFremantleTargetId(id) || isHarmattanTargetId(id) + || isMeegoTargetId(id); +} + +bool MaemoGlobal::isFremantleTargetId(const QString &id) +{ + return id == QLatin1String(MAEMO5_DEVICE_TARGET_ID); +} + +bool MaemoGlobal::isHarmattanTargetId(const QString &id) +{ + return id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID); +} + +bool MaemoGlobal::isMeegoTargetId(const QString &id) +{ + return id == QLatin1String(MEEGO_DEVICE_TARGET_ID); +} + +bool MaemoGlobal::isValidMaemo5QtVersion(const QString &qmakePath) +{ + return isValidMaemoQtVersion(qmakePath, QLatin1String(Maemo5OsType)); +} + +bool MaemoGlobal::isValidHarmattanQtVersion(const QString &qmakePath) +{ + return isValidMaemoQtVersion(qmakePath, QLatin1String(HarmattanOsType)); +} + +bool MaemoGlobal::isValidMeegoQtVersion(const QString &qmakePath) +{ + return isValidMaemoQtVersion(qmakePath, QLatin1String(MeeGoOsType)); +} + +bool MaemoGlobal::isValidMaemoQtVersion(const QString &qmakePath, const QString &osType) +{ + if (MaemoGlobal::osType(qmakePath) != osType) + return false; + QProcess madAdminProc; + const QStringList arguments(QLatin1String("list")); + if (!callMadAdmin(madAdminProc, arguments, qmakePath, false)) + return false; + if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished()) + return false; + + madAdminProc.setReadChannel(QProcess::StandardOutput); + const QByteArray tgtName = targetName(qmakePath).toAscii(); + while (madAdminProc.canReadLine()) { + const QByteArray &line = madAdminProc.readLine(); + if (line.contains(tgtName) + && (line.contains("(installed)") || line.contains("(default)"))) + return true; + } + return false; +} + + +QString MaemoGlobal::homeDirOnDevice(const QString &uname) +{ + return uname == QLatin1String("root") + ? QString::fromLatin1("/root") + : QLatin1String("/home/") + uname; +} + +QString MaemoGlobal::devrootshPath() +{ + return QLatin1String("/usr/lib/mad-developer/devrootsh"); +} + +int MaemoGlobal::applicationIconSize(const QString &osType) +{ + return osType == QLatin1String(HarmattanOsType) ? 80 : 64; +} + +QString MaemoGlobal::remoteSudo(const QString &osType, const QString &uname) +{ + if (uname == QLatin1String("root")) + return QString(); + if (osType == QLatin1String(Maemo5OsType) || osType == QLatin1String(HarmattanOsType) + || osType == QLatin1String(MeeGoOsType)) { + return devrootshPath(); + } + return QString(); // Using sudo would open a can of worms. +} + +QString MaemoGlobal::remoteSourceProfilesCommand() +{ + const QList profiles = QList() << "/etc/profile" + << "/home/user/.profile" << "~/.profile"; + QByteArray remoteCall(":"); + foreach (const QByteArray &profile, profiles) + remoteCall += "; test -f " + profile + " && source " + profile; + return QString::fromAscii(remoteCall); +} + +PortList MaemoGlobal::freePorts(const LinuxDeviceConfiguration::ConstPtr &devConf, + const QtSupport::BaseQtVersion *qtVersion) +{ + if (!devConf || !qtVersion) + return PortList(); + if (devConf->deviceType() == LinuxDeviceConfiguration::Emulator) { + MaemoQemuRuntime rt; + const int id = qtVersion->uniqueId(); + if (MaemoQemuManager::instance().runtimeForQtVersion(id, &rt)) + return rt.m_freePorts; + } + return devConf->freePorts(); +} + +QString MaemoGlobal::maddeRoot(const QString &qmakePath) +{ + QDir dir(targetRoot(qmakePath)); + dir.cdUp(); dir.cdUp(); + return dir.absolutePath(); +} + +QString MaemoGlobal::targetRoot(const QString &qmakePath) +{ + return QDir::cleanPath(qmakePath).remove(binQmake); +} + +QString MaemoGlobal::targetName(const QString &qmakePath) +{ + return QDir(targetRoot(qmakePath)).dirName(); +} + +QString MaemoGlobal::madAdminCommand(const QString &qmakePath) +{ + return maddeRoot(qmakePath) + QLatin1String("/bin/mad-admin"); +} + +QString MaemoGlobal::madCommand(const QString &qmakePath) +{ + return maddeRoot(qmakePath) + QLatin1String("/bin/mad"); +} + +QString MaemoGlobal::madDeveloperUiName(const QString &osType) +{ + return osType == QLatin1String(HarmattanOsType) + ? tr("SDK Connectivity") : tr("Mad Developer"); +} + +QString MaemoGlobal::osType(const QString &qmakePath) +{ + const QString &name = targetName(qmakePath); + if (name.startsWith(QLatin1String("fremantle"))) + return QLatin1String(Maemo5OsType); + if (name.startsWith(QLatin1String("harmattan"))) + return QLatin1String(HarmattanOsType); + if (name.startsWith(QLatin1String("meego"))) + return QLatin1String(MeeGoOsType); + return QLatin1String(RemoteLinux::Constants::GenericLinuxOsType); +} + +QString MaemoGlobal::architecture(const QString &qmakePath) +{ + QProcess proc; + const QStringList args = QStringList() << QLatin1String("uname") + << QLatin1String("-m"); + if (!callMad(proc, args, qmakePath, true)) + return QString(); + if (!proc.waitForFinished()) + return QString(); + QString arch = QString::fromUtf8(proc.readAllStandardOutput()); + arch.chop(1); // Newline + return arch; +} + +void MaemoGlobal::addMaddeEnvironment(Utils::Environment &env, const QString &qmakePath) +{ + Utils::Environment maddeEnv; +#ifdef Q_OS_WIN + const QString root = maddeRoot(qmakePath); + env.prependOrSetPath(root + QLatin1String("/bin")); + env.prependOrSet(QLatin1String("HOME"), + QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); +#else + Q_UNUSED(qmakePath); +#endif + for (Utils::Environment::const_iterator it = maddeEnv.constBegin(); it != maddeEnv.constEnd(); ++it) + env.prependOrSet(it.key(), it.value()); +} + +void MaemoGlobal::transformMaddeCall(QString &command, QStringList &args, const QString &qmakePath) +{ +#ifdef Q_OS_WIN + const QString root = maddeRoot(qmakePath); + args.prepend(command); + command = root + QLatin1String("/bin/sh.exe"); +#else + Q_UNUSED(command); + Q_UNUSED(args); + Q_UNUSED(qmakePath); +#endif +} + +bool MaemoGlobal::callMad(QProcess &proc, const QStringList &args, + const QString &qmakePath, bool useTarget) +{ + return callMaddeShellScript(proc, qmakePath, madCommand(qmakePath), args, + useTarget); +} + +bool MaemoGlobal::callMadAdmin(QProcess &proc, const QStringList &args, + const QString &qmakePath, bool useTarget) +{ + return callMaddeShellScript(proc, qmakePath, madAdminCommand(qmakePath), + args, useTarget); +} + +bool MaemoGlobal::callMaddeShellScript(QProcess &proc, + const QString &qmakePath, const QString &command, const QStringList &args, + bool useTarget) +{ + if (!QFileInfo(command).exists()) + return false; + QString actualCommand = command; + QStringList actualArgs = targetArgs(qmakePath, useTarget) + args; + Utils::Environment env(proc.systemEnvironment()); + addMaddeEnvironment(env, qmakePath); + proc.setEnvironment(env.toStringList()); + transformMaddeCall(actualCommand, actualArgs, qmakePath); + proc.start(actualCommand, actualArgs); + return true; +} + +QStringList MaemoGlobal::targetArgs(const QString &qmakePath, bool useTarget) +{ + QStringList args; + if (useTarget) { + args << QLatin1String("-t") << targetName(qmakePath); + } + return args; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoglobal.h b/src/plugins/madde/maemoglobal.h new file mode 100644 index 00000000000..a4d26f48346 --- /dev/null +++ b/src/plugins/madde/maemoglobal.h @@ -0,0 +1,135 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOGLOBAL_H +#define MAEMOGLOBAL_H + +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QProcess; +class QString; +QT_END_NAMESPACE + +namespace QtSupport { +class BaseQtVersion; +} + +namespace RemoteLinux { +class LinuxDeviceConfiguration; +} + +namespace Madde { +namespace Internal { + +class WatchableFile : public Core::IFile +{ + Q_OBJECT +public: + WatchableFile(const QString &fileName, QObject *parent = 0) + : Core::IFile(parent), m_fileName(fileName) {} + + bool save(QString *, const QString &, bool) { return false; } + QString fileName() const { return m_fileName; } + QString defaultPath() const { return QString(); } + QString suggestedFileName() const { return QString(); } + QString mimeType() const { return QLatin1String("text/plain"); } + bool isModified() const { return false; } + bool isReadOnly() const { return false; } + bool isSaveAsAllowed() const { return false; } + ReloadBehavior reloadBehavior(ChangeTrigger, ChangeType) const { return BehaviorSilent; } + bool reload(QString *, ReloadFlag, ChangeType) { emit modified(); return true; } + void rename(const QString &) {} + +signals: + void modified(); + +private: + QString m_fileName; +}; + +class MaemoGlobal +{ + Q_DECLARE_TR_FUNCTIONS(RemoteLinux::Internal::MaemoGlobal) +public: + enum PackagingSystem { Dpkg, Rpm, Tar }; + + static bool isMaemoTargetId(const QString &id); + static bool isFremantleTargetId(const QString &id); + static bool isHarmattanTargetId(const QString &id); + static bool isMeegoTargetId(const QString &id); + static bool isValidMaemo5QtVersion(const QString &qmakePath); + static bool isValidHarmattanQtVersion(const QString &qmakePath); + static bool isValidMeegoQtVersion(const QString &qmakePath); + + static QString homeDirOnDevice(const QString &uname); + static QString devrootshPath(); + static int applicationIconSize(const QString &osType); + static QString remoteSudo(const QString &osType, const QString &uname); + static QString remoteSourceProfilesCommand(); + static RemoteLinux::PortList freePorts(const QSharedPointer &devConf, + const QtSupport::BaseQtVersion *qtVersion); + + static void addMaddeEnvironment(Utils::Environment &env, const QString &qmakePath); + static void transformMaddeCall(QString &command, QStringList &args, const QString &qmakePath); + static QString maddeRoot(const QString &qmakePath); + static QString targetRoot(const QString &qmakePath); + static QString targetName(const QString &qmakePath); + static QString madCommand(const QString &qmakePath); + static QString madDeveloperUiName(const QString &osType); + static QString osType(const QString &qmakePath); + + // TODO: IS this still needed with Qt Version having an Abi? + static QString architecture(const QString &qmakePath); + + static bool callMad(QProcess &proc, const QStringList &args, + const QString &qmakePath, bool useTarget); + static bool callMadAdmin(QProcess &proc, const QStringList &args, + const QString &qmakePath, bool useTarget); + + static bool isValidMaemoQtVersion(const QString &qmakePath, const QString &osType); +private: + static QString madAdminCommand(const QString &qmakePath); + static bool callMaddeShellScript(QProcess &proc, const QString &qmakePath, + const QString &command, const QStringList &args, bool useTarget); + static QStringList targetArgs(const QString &qmakePath, bool useTarget); +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOGLOBAL_H diff --git a/src/plugins/madde/maemoinstalltosysrootstep.cpp b/src/plugins/madde/maemoinstalltosysrootstep.cpp new file mode 100644 index 00000000000..be2aacda076 --- /dev/null +++ b/src/plugins/madde/maemoinstalltosysrootstep.cpp @@ -0,0 +1,422 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoinstalltosysrootstep.h" + +#include "maemoglobal.h" +#include "maemopackagecreationstep.h" +#include "maemoqtversion.h" + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { + +class AbstractMaemoInstallPackageToSysrootWidget : public BuildStepConfigWidget +{ + Q_OBJECT +public: + AbstractMaemoInstallPackageToSysrootWidget(AbstractMaemoInstallPackageToSysrootStep *step) + : m_step(step) + { + BuildStepList * const list + = qobject_cast(m_step->parent()); + connect(list, SIGNAL(stepInserted(int)), SIGNAL(updateSummary())); + connect(list, SIGNAL(stepMoved(int,int)), SIGNAL(updateSummary())); + connect(list, SIGNAL(aboutToRemoveStep(int)), SLOT(handleStepToBeRemoved(int))); + connect(list, SIGNAL(stepRemoved(int)), SIGNAL(updateSummary())); + } + + virtual QString summaryText() const + { + if (!m_step->deployConfiguration()->earlierBuildStep(m_step)) { + return QLatin1String("") + + tr("Cannot deploy to sysroot: No packaging step found.") + + QLatin1String(""); + } + return QLatin1String("") + displayName() + QLatin1String(""); + } + +private: + Q_SLOT void handleStepToBeRemoved(int step) + { + BuildStepList * const list + = qobject_cast(m_step->parent()); + if (list->steps().at(step) == m_step) + disconnect(list, 0, this, 0); + } + + const AbstractMaemoInstallPackageToSysrootStep * const m_step; +}; + + +class MaemoInstallDebianPackageToSysrootWidget : public AbstractMaemoInstallPackageToSysrootWidget +{ + Q_OBJECT +public: + MaemoInstallDebianPackageToSysrootWidget(AbstractMaemoInstallPackageToSysrootStep *step) + : AbstractMaemoInstallPackageToSysrootWidget(step) {} + + virtual QString displayName() const { return MaemoInstallDebianPackageToSysrootStep::displayName(); } +}; + +class MaemoInstallRpmPackageToSysrootWidget : public AbstractMaemoInstallPackageToSysrootWidget +{ + Q_OBJECT +public: + MaemoInstallRpmPackageToSysrootWidget(AbstractMaemoInstallPackageToSysrootStep *step) + : AbstractMaemoInstallPackageToSysrootWidget(step) {} + + virtual QString displayName() const { return MaemoInstallRpmPackageToSysrootStep::displayName(); } +}; + +class MaemoCopyFilesToSysrootWidget : public BuildStepConfigWidget +{ + Q_OBJECT +public: + MaemoCopyFilesToSysrootWidget(const BuildStep *buildStep) + : m_buildStep(buildStep) + { + if (m_buildStep) { + connect(m_buildStep.data(), SIGNAL(displayNameChanged()), + SIGNAL(updateSummary())); + } + } + virtual QString summaryText() const { + return QLatin1String("") + displayName() + QLatin1String(""); } + virtual QString displayName() const { + return m_buildStep ? m_buildStep.data()->displayName() : QString(); + } +private: + const QWeakPointer m_buildStep; +}; + + +AbstractMaemoInstallPackageToSysrootStep::AbstractMaemoInstallPackageToSysrootStep(BuildStepList *bsl, + const QString &id) + : BuildStep(bsl, id) +{ +} + +AbstractMaemoInstallPackageToSysrootStep::AbstractMaemoInstallPackageToSysrootStep(BuildStepList *bsl, + AbstractMaemoInstallPackageToSysrootStep *other) + : BuildStep(bsl, other) +{ +} + +RemoteLinuxDeployConfiguration *AbstractMaemoInstallPackageToSysrootStep::deployConfiguration() const +{ + return qobject_cast(BuildStep::deployConfiguration()); +} + + +void AbstractMaemoInstallPackageToSysrootStep::run(QFutureInterface &fi) +{ + const Qt4BuildConfiguration * const bc + = qobject_cast(target())->activeQt4BuildConfiguration(); + if (!bc) { + addOutput(tr("Cannot install to sysroot without build configuration."), + ErrorMessageOutput); + fi.reportResult(false); + return; + } + + const AbstractMaemoPackageCreationStep * const pStep + = deployConfiguration()->earlierBuildStep(this); + if (!pStep) { + addOutput(tr("Cannot install package to sysroot without packaging step."), + ErrorMessageOutput); + fi.reportResult(false); + return; + } + + if (!bc->qtVersion()) { + addOutput(tr("Cannot install package to sysroot without a Qt version."), + ErrorMessageOutput); + fi.reportResult(false); + return; + } + + m_installerProcess = new QProcess; + connect(m_installerProcess, SIGNAL(readyReadStandardOutput()), + SLOT(handleInstallerStdout())); + connect(m_installerProcess, SIGNAL(readyReadStandardError()), + SLOT(handleInstallerStderr())); + + emit addOutput(tr("Installing package to sysroot ..."), MessageOutput); + const QtSupport::BaseQtVersion * const qtVersion = bc->qtVersion(); + const QString packageFilePath = pStep->packageFilePath(); + const int packageFileSize = QFileInfo(packageFilePath).size() / (1024*1024); + const QStringList args = madArguments() << packageFilePath; + MaemoGlobal::callMadAdmin(*m_installerProcess, args, qtVersion->qmakeCommand(), true); + if (!m_installerProcess->waitForFinished((2*packageFileSize + 10)*1000) + || m_installerProcess->exitStatus() != QProcess::NormalExit + || m_installerProcess->exitCode() != 0) { + emit addOutput(tr("Installation to sysroot failed, continuing anyway."), + ErrorMessageOutput); + if (m_installerProcess->state() != QProcess::NotRunning) { + m_installerProcess->terminate(); + m_installerProcess->waitForFinished(); + m_installerProcess->kill(); + } + fi.reportResult(true); + return; + } + + fi.reportResult(true); + m_installerProcess->deleteLater(); + m_installerProcess = 0; +} + +void AbstractMaemoInstallPackageToSysrootStep::handleInstallerStdout() +{ + if (m_installerProcess) + emit addOutput(QString::fromLocal8Bit(m_installerProcess->readAllStandardOutput()), NormalOutput); +} + +void AbstractMaemoInstallPackageToSysrootStep::handleInstallerStderr() +{ + if (m_installerProcess) + emit addOutput(QString::fromLocal8Bit(m_installerProcess->readAllStandardError()), ErrorOutput); +} + + +MaemoInstallDebianPackageToSysrootStep::MaemoInstallDebianPackageToSysrootStep(BuildStepList *bsl) + : AbstractMaemoInstallPackageToSysrootStep(bsl, Id) +{ + setDisplayName(displayName()); +} + +MaemoInstallDebianPackageToSysrootStep::MaemoInstallDebianPackageToSysrootStep(BuildStepList *bsl, + MaemoInstallDebianPackageToSysrootStep *other) + : AbstractMaemoInstallPackageToSysrootStep(bsl, other) +{ + setDisplayName(displayName()); +} + +BuildStepConfigWidget *MaemoInstallDebianPackageToSysrootStep::createConfigWidget() +{ + return new MaemoInstallDebianPackageToSysrootWidget(this); +} + +QStringList MaemoInstallDebianPackageToSysrootStep::madArguments() const +{ + return QStringList() << QLatin1String("xdpkg") << QLatin1String("--no-force-downgrade") + << QLatin1String("-i"); +} + +const QString MaemoInstallDebianPackageToSysrootStep::Id + = QLatin1String("MaemoInstallDebianPackageToSysrootStep"); + +QString MaemoInstallDebianPackageToSysrootStep::displayName() +{ + return tr("Install Debian package to sysroot"); +} + +MaemoInstallRpmPackageToSysrootStep::MaemoInstallRpmPackageToSysrootStep(BuildStepList *bsl) + : AbstractMaemoInstallPackageToSysrootStep(bsl, Id) +{ + setDisplayName(displayName()); +} + +MaemoInstallRpmPackageToSysrootStep::MaemoInstallRpmPackageToSysrootStep(BuildStepList *bsl, + MaemoInstallRpmPackageToSysrootStep *other) + : AbstractMaemoInstallPackageToSysrootStep(bsl, other) +{ + setDisplayName(displayName()); +} + +BuildStepConfigWidget *MaemoInstallRpmPackageToSysrootStep::createConfigWidget() +{ + return new MaemoInstallRpmPackageToSysrootWidget(this); +} + +QStringList MaemoInstallRpmPackageToSysrootStep::madArguments() const +{ + return QStringList() << QLatin1String("xrpm") << QLatin1String("-i"); +} + +const QString MaemoInstallRpmPackageToSysrootStep::Id + = QLatin1String("MaemoInstallRpmPackageToSysrootStep"); + +QString MaemoInstallRpmPackageToSysrootStep::displayName() +{ + return tr("Install RPM package to sysroot"); +} + +MaemoCopyToSysrootStep::MaemoCopyToSysrootStep(BuildStepList *bsl) + : BuildStep(bsl, Id) +{ + setDisplayName(displayName()); +} + +MaemoCopyToSysrootStep::MaemoCopyToSysrootStep(BuildStepList *bsl, + MaemoCopyToSysrootStep *other) + : BuildStep(bsl, other) +{ + setDisplayName(displayName()); +} + +void MaemoCopyToSysrootStep::run(QFutureInterface &fi) +{ + const Qt4BuildConfiguration * const bc + = qobject_cast(target())->activeQt4BuildConfiguration(); + if (!bc) { + addOutput(tr("Cannot copy to sysroot without build configuration."), + ErrorMessageOutput); + fi.reportResult(false); + return; + } + + const MaemoQtVersion * const qtVersion = dynamic_cast(bc->qtVersion()); + if (!qtVersion) { + addOutput(tr("Cannot copy to sysroot without valid Qt version."), + ErrorMessageOutput); + fi.reportResult(false); + return; + } + + emit addOutput(tr("Copying files to sysroot ..."), MessageOutput); + QDir sysrootDir(qtVersion->systemRoot()); + const QSharedPointer deploymentInfo + = qobject_cast(deployConfiguration())->deploymentInfo(); + const QChar sep = QLatin1Char('/'); + for (int i = 0; i < deploymentInfo->deployableCount(); ++i) { + const DeployableFile &deployable = deploymentInfo->deployableAt(i); + const QFileInfo localFileInfo(deployable.localFilePath); + const QString targetFilePath = qtVersion->systemRoot() + sep + + deployable.remoteDir + sep + localFileInfo.fileName(); + sysrootDir.mkpath(deployable.remoteDir.mid(1)); + QString errorMsg; + Utils::FileUtils::removeRecursively(targetFilePath, &errorMsg); + if (!Utils::FileUtils::copyRecursively(deployable.localFilePath, + targetFilePath, &errorMsg)) { + emit addOutput(tr("Sysroot installation failed: %1\n" + " Continuing anyway.").arg(errorMsg), ErrorMessageOutput); + } + QCoreApplication::processEvents(); + if (fi.isCanceled()) { + fi.reportResult(false); + return; + } + } + fi.reportResult(true); +} + +BuildStepConfigWidget *MaemoCopyToSysrootStep::createConfigWidget() +{ + return new MaemoCopyFilesToSysrootWidget(this); +} + +const QString MaemoCopyToSysrootStep::Id + = QLatin1String("MaemoCopyToSysrootStep"); +QString MaemoCopyToSysrootStep::displayName() +{ + return tr("Copy files to sysroot"); +} + +MaemoMakeInstallToSysrootStep::MaemoMakeInstallToSysrootStep(BuildStepList *bsl) + : AbstractProcessStep(bsl, Id) +{ + setDefaultDisplayName(displayName()); +} + +MaemoMakeInstallToSysrootStep::MaemoMakeInstallToSysrootStep(BuildStepList *bsl, + MaemoMakeInstallToSysrootStep *other) + : AbstractProcessStep(bsl, other) +{ + setDefaultDisplayName(displayName()); +} + +bool MaemoMakeInstallToSysrootStep::init() +{ + const Qt4BuildConfiguration * const bc + = qobject_cast(target()->activeBuildConfiguration()); + if (!bc) { + addOutput("Cannot deploy: No active build dconfiguration.", + ErrorMessageOutput); + return false; + } + const QtSupport::BaseQtVersion * const qtVersion = bc->qtVersion(); + if (!qtVersion) { + addOutput("Cannot deploy: Unusable build configuration.", + ErrorMessageOutput); + return false; + + } + Utils::Environment env = bc->environment(); + MaemoGlobal::addMaddeEnvironment(env, qtVersion->qmakeCommand()); + QString command = MaemoGlobal::madCommand(qtVersion->qmakeCommand()); + QStringList args = QStringList() << QLatin1String("-t") + << MaemoGlobal::targetName(qtVersion->qmakeCommand()) << QLatin1String("make") + << QLatin1String("install") << (QLatin1String("INSTALL_ROOT=") + qtVersion->systemRoot()); + MaemoGlobal::transformMaddeCall(command, args, qtVersion->qmakeCommand()); + processParameters()->setCommand(command); + processParameters()->setArguments(args.join(QLatin1String(" "))); + processParameters()->setEnvironment(env); + processParameters()->setWorkingDirectory(bc->buildDirectory()); + return true; +} + +BuildStepConfigWidget *MaemoMakeInstallToSysrootStep::createConfigWidget() +{ + return new MaemoCopyFilesToSysrootWidget(this); +} + +const QString MaemoMakeInstallToSysrootStep::Id + = QLatin1String("MaemoMakeInstallToSysrootStep"); +QString MaemoMakeInstallToSysrootStep::displayName() +{ + return tr("Copy files to sysroot"); +} + +} // namespace Internal +} // namespace Madde + +#include "maemoinstalltosysrootstep.moc" diff --git a/src/plugins/madde/maemoinstalltosysrootstep.h b/src/plugins/madde/maemoinstalltosysrootstep.h new file mode 100644 index 00000000000..90d5e626765 --- /dev/null +++ b/src/plugins/madde/maemoinstalltosysrootstep.h @@ -0,0 +1,142 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOINSTALLTOSYSROOTSTEP_H +#define MAEMOINSTALLTOSYSROOTSTEP_H + +#include +#include + +#include + +QT_FORWARD_DECLARE_CLASS(QProcess) + +namespace RemoteLinux { +class RemoteLinuxDeployConfiguration; +} + +namespace Madde { +namespace Internal { + +class AbstractMaemoInstallPackageToSysrootStep : public ProjectExplorer::BuildStep +{ + Q_OBJECT +public: + virtual bool init() { return true; } + virtual void run(QFutureInterface &fi); + + RemoteLinux::RemoteLinuxDeployConfiguration *deployConfiguration() const; + +protected: + AbstractMaemoInstallPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl, + const QString &id); + AbstractMaemoInstallPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl, + AbstractMaemoInstallPackageToSysrootStep *other); + +private slots: + void handleInstallerStdout(); + void handleInstallerStderr(); + +private: + virtual QStringList madArguments() const = 0; + + QProcess *m_installerProcess; +}; + +class MaemoInstallDebianPackageToSysrootStep : public AbstractMaemoInstallPackageToSysrootStep +{ + Q_OBJECT +public: + explicit MaemoInstallDebianPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl); + MaemoInstallDebianPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl, + MaemoInstallDebianPackageToSysrootStep *other); + + virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); + + static const QString Id; + static QString displayName(); +private: + virtual QStringList madArguments() const; +}; + +class MaemoInstallRpmPackageToSysrootStep : public AbstractMaemoInstallPackageToSysrootStep +{ + Q_OBJECT +public: + explicit MaemoInstallRpmPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl); + MaemoInstallRpmPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl, + MaemoInstallRpmPackageToSysrootStep *other); + + virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); + + static const QString Id; + static QString displayName(); +private: + virtual QStringList madArguments() const; +}; + +class MaemoCopyToSysrootStep : public ProjectExplorer::BuildStep +{ + Q_OBJECT +public: + explicit MaemoCopyToSysrootStep(ProjectExplorer::BuildStepList *bsl); + MaemoCopyToSysrootStep(ProjectExplorer::BuildStepList *bsl, + MaemoCopyToSysrootStep *other); + + virtual bool init() { return true; } + virtual void run(QFutureInterface &fi); + virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); + + static const QString Id; + static QString displayName(); +}; + +class MaemoMakeInstallToSysrootStep : public ProjectExplorer::AbstractProcessStep +{ + Q_OBJECT +public: + explicit MaemoMakeInstallToSysrootStep(ProjectExplorer::BuildStepList *bsl); + MaemoMakeInstallToSysrootStep(ProjectExplorer::BuildStepList *bsl, + MaemoMakeInstallToSysrootStep *other); + + virtual bool immutable() const { return false; } + virtual bool init(); + virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); + + static const QString Id; + static QString displayName(); +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOINSTALLTOSYSROOTSTEP_H diff --git a/src/plugins/madde/maemomountspecification.cpp b/src/plugins/madde/maemomountspecification.cpp new file mode 100644 index 00000000000..4f344450ba5 --- /dev/null +++ b/src/plugins/madde/maemomountspecification.cpp @@ -0,0 +1,48 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemomountspecification.h" + +namespace Madde { +namespace Internal { + +const QLatin1String MaemoMountSpecification::InvalidMountPoint("/"); + +MaemoMountSpecification::MaemoMountSpecification(const QString &localDir, + const QString &remoteDir) + : localDir(localDir), remoteMountPoint(remoteDir) +{ +} + +} // namespace Internal +} // namespace Madde + diff --git a/src/plugins/madde/maemomountspecification.h b/src/plugins/madde/maemomountspecification.h new file mode 100644 index 00000000000..c326c107b06 --- /dev/null +++ b/src/plugins/madde/maemomountspecification.h @@ -0,0 +1,53 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOMOUNTSPECIFICATION_H +#define MAEMOMOUNTSPECIFICATION_H + +#include + +namespace Madde { +namespace Internal { + +struct MaemoMountSpecification { + MaemoMountSpecification(const QString &localDir, const QString &remoteDir); + bool isValid() const { return remoteMountPoint != InvalidMountPoint; } + + static const QLatin1String InvalidMountPoint; + + QString localDir; + QString remoteMountPoint; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOMOUNTSPECIFICATION_H diff --git a/src/plugins/madde/maemopackagecreationfactory.cpp b/src/plugins/madde/maemopackagecreationfactory.cpp new file mode 100644 index 00000000000..dbf0da1c74d --- /dev/null +++ b/src/plugins/madde/maemopackagecreationfactory.cpp @@ -0,0 +1,155 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemopackagecreationfactory.h" + +#include "maemopackagecreationstep.h" +#include "qt4maemotarget.h" +#include "qt4maemodeployconfiguration.h" + +#include +#include +#include +#include +#include + +#include + +using ProjectExplorer::BuildStepList; +using ProjectExplorer::BuildStep; + +namespace Madde { +namespace Internal { +namespace { +const QString OldCreatePackageId("Qt4ProjectManager.MaemoPackageCreationStep"); +} // anonymous namespace + +MaemoPackageCreationFactory::MaemoPackageCreationFactory(QObject *parent) + : ProjectExplorer::IBuildStepFactory(parent) +{ +} + +QStringList MaemoPackageCreationFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const +{ + QStringList ids; + if (!qobject_cast(parent->parent())) + return ids; + if (qobject_cast(parent->target()) + && !parent->contains(MaemoDebianPackageCreationStep::CreatePackageId)) { + ids << MaemoDebianPackageCreationStep::CreatePackageId; + } else if (qobject_cast(parent->target()) + && !parent->contains(MaemoRpmPackageCreationStep::CreatePackageId)) { + ids << MaemoRpmPackageCreationStep::CreatePackageId; + } + return ids; +} + +QString MaemoPackageCreationFactory::displayNameForId(const QString &id) const +{ + if (id == MaemoDebianPackageCreationStep::CreatePackageId) { + return QCoreApplication::translate("RemoteLinux::Internal::MaemoPackageCreationFactory", + "Create Debian Package"); + } else if (id == MaemoRpmPackageCreationStep::CreatePackageId) { + return QCoreApplication::translate("RemoteLinux::Internal::MaemoPackageCreationFactory", + "Create RPM Package"); + } + return QString(); +} + +bool MaemoPackageCreationFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const +{ + return availableCreationIds(parent).contains(id); +} + +BuildStep *MaemoPackageCreationFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id) +{ + Q_ASSERT(canCreate(parent, id)); + if (id == MaemoDebianPackageCreationStep::CreatePackageId) + return new MaemoDebianPackageCreationStep(parent); + else if (id == MaemoRpmPackageCreationStep::CreatePackageId) + return new MaemoRpmPackageCreationStep(parent); + return 0; +} + +bool MaemoPackageCreationFactory::canRestore(ProjectExplorer::BuildStepList *parent, + const QVariantMap &map) const +{ + const QString id = ProjectExplorer::idFromMap(map); + return canCreate(parent, id) || id == OldCreatePackageId; +} + +BuildStep *MaemoPackageCreationFactory::restore(ProjectExplorer::BuildStepList *parent, + const QVariantMap &map) +{ + Q_ASSERT(canRestore(parent, map)); + BuildStep * step = 0; + const QString id = ProjectExplorer::idFromMap(map); + if (id == MaemoDebianPackageCreationStep::CreatePackageId + || (id == OldCreatePackageId + && qobject_cast(parent->target()))) { + step = new MaemoDebianPackageCreationStep(parent); + } else if (id == MaemoRpmPackageCreationStep::CreatePackageId + || (id == OldCreatePackageId + && qobject_cast(parent->target()))) { + step = new MaemoRpmPackageCreationStep(parent); + } + Q_ASSERT(step); + + if (!step->fromMap(map)) { + delete step; + return 0; + } + return step; +} + +bool MaemoPackageCreationFactory::canClone(ProjectExplorer::BuildStepList *parent, + ProjectExplorer::BuildStep *product) const +{ + return canCreate(parent, product->id()); +} + +BuildStep *MaemoPackageCreationFactory::clone(ProjectExplorer::BuildStepList *parent, + ProjectExplorer::BuildStep *product) +{ + Q_ASSERT(canClone(parent, product)); + if (MaemoDebianPackageCreationStep * const debianStep + = qobject_cast(product)) { + return new MaemoDebianPackageCreationStep(parent, debianStep); + } + if (MaemoRpmPackageCreationStep * const rpmStep + = qobject_cast(product)) { + return new MaemoRpmPackageCreationStep(parent, rpmStep); + } + return 0; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopackagecreationfactory.h b/src/plugins/madde/maemopackagecreationfactory.h new file mode 100644 index 00000000000..48fc9a2c7b1 --- /dev/null +++ b/src/plugins/madde/maemopackagecreationfactory.h @@ -0,0 +1,68 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOPACKAGECREATIONFACTORY_H +#define MAEMOPACKAGECREATIONFACTORY_H + +#include + +namespace Madde { +namespace Internal { + +class MaemoPackageCreationFactory : public ProjectExplorer::IBuildStepFactory +{ +public: + MaemoPackageCreationFactory(QObject *parent = 0); + + virtual QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; + virtual QString displayNameForId(const QString &id) const; + + virtual bool canCreate(ProjectExplorer::BuildStepList *parent, + const QString &id) const; + virtual ProjectExplorer::BuildStep * + create(ProjectExplorer::BuildStepList *parent, const QString &id); + + virtual bool canRestore(ProjectExplorer::BuildStepList *parent, + const QVariantMap &map) const; + virtual ProjectExplorer::BuildStep * + restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); + + virtual bool canClone(ProjectExplorer::BuildStepList *parent, + ProjectExplorer::BuildStep *product) const; + virtual ProjectExplorer::BuildStep * + clone(ProjectExplorer::BuildStepList *parent, + ProjectExplorer::BuildStep *product); +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPACKAGECREATIONFACTORY_H diff --git a/src/plugins/madde/maemopackagecreationstep.cpp b/src/plugins/madde/maemopackagecreationstep.cpp new file mode 100644 index 00000000000..ee2f8901498 --- /dev/null +++ b/src/plugins/madde/maemopackagecreationstep.cpp @@ -0,0 +1,511 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemopackagecreationstep.h" + +#include "maemoconstants.h" +#include "maemoglobal.h" +#include "maemopackagecreationwidget.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace { + const QLatin1String MagicFileName(".qtcreator"); +} + +using namespace ProjectExplorer::Constants; +using ProjectExplorer::BuildStepList; +using ProjectExplorer::BuildStepConfigWidget; +using ProjectExplorer::Task; +using namespace Qt4ProjectManager; + +namespace Madde { +namespace Internal { + +const QLatin1String AbstractMaemoPackageCreationStep::DefaultVersionNumber("0.0.1"); + +AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl, + const QString &id) : AbstractPackagingStep(bsl, id) +{ +} + +AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl, + AbstractMaemoPackageCreationStep *other) : AbstractPackagingStep(bsl, other) +{ +} + +AbstractMaemoPackageCreationStep::~AbstractMaemoPackageCreationStep() +{ +} + +void AbstractMaemoPackageCreationStep::run(QFutureInterface &fi) +{ + if (!isPackagingNeeded()) { + emit addOutput(tr("Package up to date."), MessageOutput); + fi.reportResult(true); + return; + } + + setPackagingStarted(); + // TODO: Make the build process asynchronous; i.e. no waitFor()-functions etc. + QProcess * const buildProc = new QProcess; + connect(buildProc, SIGNAL(readyReadStandardOutput()), this, + SLOT(handleBuildOutput())); + connect(buildProc, SIGNAL(readyReadStandardError()), this, + SLOT(handleBuildOutput())); + emit addOutput(tr("Creating package file ..."), MessageOutput); + const bool success = createPackage(buildProc, fi); + disconnect(buildProc, 0, this, 0); + buildProc->deleteLater(); + if (success) + emit addOutput(tr("Package created."), BuildStep::MessageOutput); + setPackagingFinished(success); + fi.reportResult(success); +} + +BuildStepConfigWidget *AbstractMaemoPackageCreationStep::createConfigWidget() +{ + return new MaemoPackageCreationWidget(this); +} + +void AbstractMaemoPackageCreationStep::handleBuildOutput() +{ + QProcess * const buildProc = qobject_cast(sender()); + if (!buildProc) + return; + QByteArray stdOut = buildProc->readAllStandardOutput(); + stdOut.replace('\0', QByteArray()); // Output contains NUL characters. + if (!stdOut.isEmpty()) + emit addOutput(QString::fromLocal8Bit(stdOut), BuildStep::NormalOutput, + BuildStep::DontAppendNewline); + QByteArray errorOut = buildProc->readAllStandardError(); + errorOut.replace('\0', QByteArray()); + if (!errorOut.isEmpty()) { + emit addOutput(QString::fromLocal8Bit(errorOut), BuildStep::ErrorOutput, + BuildStep::DontAppendNewline); + } +} + +const Qt4BuildConfiguration *AbstractMaemoPackageCreationStep::qt4BuildConfiguration() const +{ + return static_cast(buildConfiguration()); +} + +AbstractQt4MaemoTarget *AbstractMaemoPackageCreationStep::maemoTarget() const +{ + return qobject_cast(buildConfiguration()->target()); +} + +AbstractDebBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::debBasedMaemoTarget() const +{ + return qobject_cast(buildConfiguration()->target()); +} + +AbstractRpmBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::rpmBasedMaemoTarget() const +{ + return qobject_cast(buildConfiguration()->target()); +} + +QString AbstractMaemoPackageCreationStep::projectName() const +{ + return qt4BuildConfiguration()->qt4Target()->qt4Project() + ->rootProjectNode()->displayName().toLower(); +} + +bool AbstractMaemoPackageCreationStep::isPackagingNeeded() const +{ + if (AbstractPackagingStep::isPackagingNeeded()) + return true; + return isMetaDataNewerThan(QFileInfo(packageFilePath()).lastModified()); +} + +QString AbstractMaemoPackageCreationStep::packageFileName() const +{ + QString error; + const QString &version = versionString(&error); + if (version.isEmpty()) + return QString(); + QFileInfo fi(maemoTarget()->packageFileName()); + const QString baseName = replaceDots(fi.completeBaseName()); + return baseName + QLatin1Char('.') + fi.suffix(); +} + +QString AbstractMaemoPackageCreationStep::versionString(QString *error) const +{ + return maemoTarget()->projectVersion(error); +} + +bool AbstractMaemoPackageCreationStep::setVersionString(const QString &version, QString *error) +{ + const bool success = maemoTarget()->setProjectVersion(version, error); + if (success) + emit packageFilePathChanged(); + return success; +} + +QString AbstractMaemoPackageCreationStep::nativePath(const QFile &file) +{ + return QDir::toNativeSeparators(QFileInfo(file).filePath()); +} + +bool AbstractMaemoPackageCreationStep::callPackagingCommand(QProcess *proc, + const QStringList &arguments) +{ + preparePackagingProcess(proc, qt4BuildConfiguration(), packageDirectory()); + const QtSupport::BaseQtVersion * const qtVersion = qt4BuildConfiguration()->qtVersion(); + if (!qtVersion) { + raiseError(tr("Packaging failed: No Qt version.")); + return false; + } + const QString madCommand = MaemoGlobal::madCommand(qtVersion->qmakeCommand()); + const QString cmdLine = madCommand + QLatin1Char(' ') + + arguments.join(QLatin1String(" ")); + emit addOutput(tr("Package Creation: Running command '%1'.").arg(cmdLine), + BuildStep::MessageOutput); + MaemoGlobal::callMad(*proc, arguments, qtVersion->qmakeCommand(), true); + if (!proc->waitForStarted()) { + raiseError(tr("Packaging failed: Could not start command '%1'. Reason: %2") + .arg(cmdLine, proc->errorString())); + return false; + } + proc->waitForFinished(-1); + if (proc->error() != QProcess::UnknownError || proc->exitCode() != 0) { + QString mainMessage = tr("Packaging Error: Command '%1' failed.") + .arg(cmdLine); + if (proc->error() != QProcess::UnknownError) + mainMessage += tr(" Reason: %1").arg(proc->errorString()); + else + mainMessage += tr("Exit code: %1").arg(proc->exitCode()); + raiseError(mainMessage); + return false; + } + return true; +} + + +void AbstractMaemoPackageCreationStep::preparePackagingProcess(QProcess *proc, + const Qt4BuildConfiguration *bc, const QString &workingDir) +{ + Utils::Environment env = bc->environment(); + if (bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild) { + env.appendOrSet(QLatin1String("DEB_BUILD_OPTIONS"), + QLatin1String("nostrip"), QLatin1String(" ")); + } + proc->setEnvironment(env.toStringList()); + proc->setWorkingDirectory(workingDir); +} + +QString AbstractMaemoPackageCreationStep::replaceDots(const QString &name) const +{ + // Idiotic OVI store requirement for N900 (but not allowed for N9 ...). + if (qobject_cast(target())) { + QString adaptedName = name; + return adaptedName.replace(QLatin1Char('.'), QLatin1Char('_')); + } + return name; +} + + +MaemoDebianPackageCreationStep::MaemoDebianPackageCreationStep(BuildStepList *bsl) + : AbstractMaemoPackageCreationStep(bsl, CreatePackageId) +{ + ctor(); +} + +const QString MaemoDebianPackageCreationStep::CreatePackageId + = QLatin1String("MaemoDebianPackageCreationStep"); + +MaemoDebianPackageCreationStep::MaemoDebianPackageCreationStep(BuildStepList *buildConfig, + MaemoDebianPackageCreationStep *other) + : AbstractMaemoPackageCreationStep(buildConfig, other) +{ + ctor(); +} + +void MaemoDebianPackageCreationStep::ctor() +{ + setDefaultDisplayName(tr("Create Debian Package")); +} + +bool MaemoDebianPackageCreationStep::createPackage(QProcess *buildProc, + const QFutureInterface &fi) +{ + Q_UNUSED(fi); + checkProjectName(); + const QString projectDir = buildConfiguration()->target()->project()->projectDirectory(); + const bool inSourceBuild = QFileInfo(packageDirectory()) == QFileInfo(projectDir); + if (!copyDebianFiles(inSourceBuild)) + return false; + const QStringList args = QStringList() << QLatin1String("dpkg-buildpackage") + << QLatin1String("-nc") << QLatin1String("-uc") << QLatin1String("-us"); + if (!callPackagingCommand(buildProc, args)) + return false; + + QFile::remove(packageFilePath()); + + // Workaround for non-working dh_builddeb --destdir=. + if (!QDir(packageDirectory()).isRoot()) { + const AbstractQt4MaemoTarget * const target = maemoTarget(); + QString error; + const QString pkgFileName = target->packageFileName(); + if (!error.isEmpty()) + raiseError(tr("Packaging failed: Could not get package name.")); + const QString changesSourceFileName = QFileInfo(pkgFileName).completeBaseName() + + QLatin1String(".changes"); + const QString changesTargetFileName = replaceDots(QFileInfo(pkgFileName).completeBaseName()) + + QLatin1String(".changes"); + const QString packageSourceDir = packageDirectory() + QLatin1String("/../"); + const QString packageSourceFilePath = packageSourceDir + pkgFileName; + const QString changesSourceFilePath = packageSourceDir + changesSourceFileName; + const QString changesTargetFilePath + = packageDirectory() + QLatin1Char('/') + changesTargetFileName; + QFile::remove(changesTargetFilePath); + if (!QFile::rename(packageSourceFilePath, packageFilePath()) + || !QFile::rename(changesSourceFilePath, changesTargetFilePath)) { + raiseError(tr("Packaging failed: Could not move package files from '%1'' to '%2'.") + .arg(packageSourceDir, packageDirectory())); + return false; + } + } + + if (inSourceBuild) { + buildProc->start(packagingCommand(qt4BuildConfiguration(), QLatin1String("dh_clean"))); + buildProc->waitForFinished(); + buildProc->terminate(); + } + return true; +} + +bool MaemoDebianPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDate) const +{ + const QString debianPath = debBasedMaemoTarget()->debianDirPath(); + if (packageDate <= QFileInfo(debianPath).lastModified()) + return true; + const QStringList debianFiles = debBasedMaemoTarget()->debianFiles(); + foreach (const QString &debianFile, debianFiles) { + const QString absFilePath = debianPath + QLatin1Char('/') + debianFile; + if (packageDate <= QFileInfo(absFilePath).lastModified()) + return true; + } + return false; +} + +void MaemoDebianPackageCreationStep::checkProjectName() +{ + const QRegExp legalName(QLatin1String("[0-9-+a-z\\.]+")); + if (!legalName.exactMatch(buildConfiguration()->target()->project()->displayName())) { + emit addTask(Task(Task::Warning, + tr("Your project name contains characters not allowed in " + "Debian packages.\nThey must only use lower-case letters, " + "numbers, '-', '+' and '.'.\n""We will try to work around that, " + "but you may experience problems."), + QString(), -1, TASK_CATEGORY_BUILDSYSTEM)); + } +} + +bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild) +{ + const QString debianDirPath = packageDirectory() + QLatin1String("/debian"); + const QString magicFilePath + = debianDirPath + QLatin1Char('/') + MagicFileName; + if (inSourceBuild && QFileInfo(debianDirPath).isDir() + && !QFileInfo(magicFilePath).exists()) { + raiseError(tr("Packaging failed: Foreign debian directory detected. " + "You are not using a shadow build and there is a debian " + "directory in your project root ('%1'). Qt Creator will not " + "overwrite that directory. Please remove it or use the " + "shadow build feature.").arg(QDir::toNativeSeparators(debianDirPath))); + return false; + } + QString error; + if (!Utils::FileUtils::removeRecursively(debianDirPath, &error)) { + raiseError(tr("Packaging failed: Could not remove directory '%1': %2") + .arg(debianDirPath, error)); + return false; + } + QDir buildDir(packageDirectory()); + if (!buildDir.mkdir("debian")) { + raiseError(tr("Could not create Debian directory '%1'.").arg(debianDirPath)); + return false; + } + const QString templatesDirPath = debBasedMaemoTarget()->debianDirPath(); + QDir templatesDir(templatesDirPath); + const QStringList &files = templatesDir.entryList(QDir::Files); + foreach (const QString &fileName, files) { + const QString srcFile = templatesDirPath + QLatin1Char('/') + fileName; + QString newFileName = fileName; + if (newFileName == Qt4HarmattanTarget::aegisManifestFileName()) { + // If the user has touched the Aegis manifest file, we copy it for use + // by MADDE. Otherwise the required capabilities will be auto-detected. + if (QFileInfo(srcFile).size() == 0) + continue; + newFileName = maemoTarget()->packageName() + QLatin1String(".aegis"); + } + const QString destFile = debianDirPath + QLatin1Char('/') + newFileName; + if (fileName == QLatin1String("rules")) { + if (!adaptRulesFile(srcFile, destFile)) + return false; + } else if (!QFile::copy(srcFile, destFile)) { + raiseError(tr("Could not copy file '%1' to '%2'") + .arg(QDir::toNativeSeparators(srcFile), QDir::toNativeSeparators(destFile))); + return false; + } + } + + QFile magicFile(magicFilePath); + if (!magicFile.open(QIODevice::WriteOnly)) { + raiseError(tr("Error: Could not create file '%1'.") + .arg(QDir::toNativeSeparators(magicFilePath))); + return false; + } + + return true; +} + +QString MaemoDebianPackageCreationStep::packagingCommand(const Qt4BuildConfiguration *bc, + const QString &commandName) +{ + QString perl; + QtSupport::BaseQtVersion *v = bc->qtVersion(); + const QString maddeRoot = MaemoGlobal::maddeRoot(v->qmakeCommand()); +#ifdef Q_OS_WIN + perl = maddeRoot + QLatin1String("/bin/perl.exe "); +#endif + return perl + maddeRoot + QLatin1String("/madbin/") + commandName; +} + +void MaemoDebianPackageCreationStep::ensureShlibdeps(QByteArray &rulesContent) +{ + QString contentAsString = QString::fromLocal8Bit(rulesContent); + const QString whiteSpace(QLatin1String("[ \\t]*")); + const QString pattern = QLatin1String("\\n") + whiteSpace + + QLatin1Char('#') + whiteSpace + QLatin1String("dh_shlibdeps") + + QLatin1String("([^\\n]*)\\n"); + contentAsString.replace(QRegExp(pattern), + QLatin1String("\n\tdh_shlibdeps\\1\n")); + rulesContent = contentAsString.toLocal8Bit(); +} + +bool MaemoDebianPackageCreationStep::adaptRulesFile( + const QString &templatePath, const QString &rulesFilePath) +{ + Utils::FileReader reader; + if (!reader.fetch(templatePath)) { + raiseError(reader.errorString()); + return false; + } + QByteArray content = reader.data(); + const Qt4BuildConfiguration * const bc = qt4BuildConfiguration(); + + // Always check for dependencies in release builds. + if (!(bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild)) + ensureShlibdeps(content); + + Utils::FileSaver saver(rulesFilePath); + saver.write(content); + if (!saver.finalize()) { + raiseError(saver.errorString()); + return false; + } + QFile rulesFile(rulesFilePath); + rulesFile.setPermissions(rulesFile.permissions() | QFile::ExeUser); + return true; +} + + +MaemoRpmPackageCreationStep::MaemoRpmPackageCreationStep(BuildStepList *bsl) + : AbstractMaemoPackageCreationStep(bsl, CreatePackageId) +{ + ctor(); +} + +MaemoRpmPackageCreationStep::MaemoRpmPackageCreationStep(BuildStepList *buildConfig, + MaemoRpmPackageCreationStep *other) + : AbstractMaemoPackageCreationStep(buildConfig, other) +{ + ctor(); +} + +void MaemoRpmPackageCreationStep::ctor() +{ + setDefaultDisplayName(tr("Create RPM Package")); +} + +bool MaemoRpmPackageCreationStep::createPackage(QProcess *buildProc, + const QFutureInterface &fi) +{ + setPackagingStarted(); + + Q_UNUSED(fi); + const QStringList args = QStringList() << QLatin1String("rrpmbuild") + << QLatin1String("-bb") << rpmBasedMaemoTarget()->specFilePath(); + if (!callPackagingCommand(buildProc, args)) + return false; + QFile::remove(packageFilePath()); + const QString packageSourceFilePath = rpmBuildDir() + QLatin1Char('/') + + rpmBasedMaemoTarget()->packageFileName(); + if (!QFile::rename(packageSourceFilePath, packageFilePath())) { + raiseError(tr("Packaging failed: Could not move package file from %1 to %2.") + .arg(packageSourceFilePath, packageFilePath())); + return false; + } + + return true; +} + +bool MaemoRpmPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDate) const +{ + const QDateTime specFileChangeDate + = QFileInfo(rpmBasedMaemoTarget()->specFilePath()).lastModified(); + return packageDate <= specFileChangeDate; +} + +QString MaemoRpmPackageCreationStep::rpmBuildDir() const +{ + return packageDirectory() + QLatin1String("/rrpmbuild"); +} + +const QString MaemoRpmPackageCreationStep::CreatePackageId + = QLatin1String("MaemoRpmPackageCreationStep"); + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopackagecreationstep.h b/src/plugins/madde/maemopackagecreationstep.h new file mode 100644 index 00000000000..1c41a784808 --- /dev/null +++ b/src/plugins/madde/maemopackagecreationstep.h @@ -0,0 +1,154 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOPACKAGECREATIONSTEP_H +#define MAEMOPACKAGECREATIONSTEP_H + +#include + +QT_BEGIN_NAMESPACE +class QDateTime; +class QFile; +class QProcess; +QT_END_NAMESPACE + +namespace Qt4ProjectManager { class Qt4BuildConfiguration; } + +namespace RemoteLinux { +class RemoteLinuxDeployConfiguration; +} + +namespace Madde { +namespace Internal { +class AbstractQt4MaemoTarget; +class AbstractDebBasedQt4MaemoTarget; +class AbstractRpmBasedQt4MaemoTarget; + +class AbstractMaemoPackageCreationStep : public RemoteLinux::AbstractPackagingStep +{ + Q_OBJECT +public: + virtual ~AbstractMaemoPackageCreationStep(); + + QString versionString(QString *error) const; + bool setVersionString(const QString &version, QString *error); + + static void preparePackagingProcess(QProcess *proc, + const Qt4ProjectManager::Qt4BuildConfiguration *bc, + const QString &workingDir); + + const Qt4ProjectManager::Qt4BuildConfiguration *qt4BuildConfiguration() const; + AbstractQt4MaemoTarget *maemoTarget() const; + AbstractDebBasedQt4MaemoTarget *debBasedMaemoTarget() const; + AbstractRpmBasedQt4MaemoTarget *rpmBasedMaemoTarget() const; + + static const QLatin1String DefaultVersionNumber; + + +protected: + AbstractMaemoPackageCreationStep(ProjectExplorer::BuildStepList *bsl, + const QString &id); + AbstractMaemoPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig, + AbstractMaemoPackageCreationStep *other); + + bool callPackagingCommand(QProcess *proc, const QStringList &arguments); + QString replaceDots(const QString &name) const; + +private slots: + void handleBuildOutput(); + +private: + virtual void run(QFutureInterface &fi); + virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); + + virtual QString packageFileName() const; + + virtual bool createPackage(QProcess *buildProc, const QFutureInterface &fi) = 0; + virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const = 0; + + QString projectName() const; + static QString nativePath(const QFile &file); + bool isPackagingNeeded() const; + + const Qt4ProjectManager::Qt4BuildConfiguration *m_lastBuildConfig; +}; + + +class MaemoDebianPackageCreationStep : public AbstractMaemoPackageCreationStep +{ + Q_OBJECT + friend class MaemoPackageCreationFactory; +public: + MaemoDebianPackageCreationStep(ProjectExplorer::BuildStepList *bsl); + + static void ensureShlibdeps(QByteArray &rulesContent); + +private: + MaemoDebianPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig, + MaemoDebianPackageCreationStep *other); + + virtual bool createPackage(QProcess *buildProc, const QFutureInterface &fi); + virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const; + + void ctor(); + static QString packagingCommand(const Qt4ProjectManager::Qt4BuildConfiguration *bc, + const QString &commandName); + bool copyDebianFiles(bool inSourceBuild); + void checkProjectName(); + bool adaptRulesFile(const QString &templatePath, const QString &rulesFilePath); + + static const QString CreatePackageId; +}; + +class MaemoRpmPackageCreationStep : public AbstractMaemoPackageCreationStep +{ + Q_OBJECT + friend class MaemoPackageCreationFactory; +public: + MaemoRpmPackageCreationStep(ProjectExplorer::BuildStepList *bsl); + +private: + virtual bool createPackage(QProcess *buildProc, const QFutureInterface &fi); + virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const; + + MaemoRpmPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig, + MaemoRpmPackageCreationStep *other); + + void ctor(); + QString rpmBuildDir() const; + + static const QString CreatePackageId; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPACKAGECREATIONSTEP_H diff --git a/src/plugins/madde/maemopackagecreationwidget.cpp b/src/plugins/madde/maemopackagecreationwidget.cpp new file mode 100644 index 00000000000..0874cd8170a --- /dev/null +++ b/src/plugins/madde/maemopackagecreationwidget.cpp @@ -0,0 +1,283 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemopackagecreationwidget.h" +#include "ui_maemopackagecreationwidget.h" + +#include "maemoglobal.h" +#include "maemopackagecreationstep.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace ProjectExplorer; + +namespace Madde { +namespace Internal { + +// TODO: Split up into dedicated widgets for Debian and RPM steps. +MaemoPackageCreationWidget::MaemoPackageCreationWidget(AbstractMaemoPackageCreationStep *step) + : ProjectExplorer::BuildStepConfigWidget(), + m_step(step), + m_ui(new Ui::MaemoPackageCreationWidget) +{ + m_ui->setupUi(this); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + QTimer::singleShot(0, this, SLOT(initGui())); +} + +MaemoPackageCreationWidget::~MaemoPackageCreationWidget() +{ + delete m_ui; +} + +void MaemoPackageCreationWidget::initGui() +{ + m_ui->shortDescriptionLineEdit->setMaxLength(60); + updateVersionInfo(); + const AbstractDebBasedQt4MaemoTarget * const debBasedMaemoTarget + = m_step->debBasedMaemoTarget(); + if (debBasedMaemoTarget) { + const QSize iconSize = debBasedMaemoTarget->packageManagerIconSize(); + m_ui->packageManagerIconButton->setFixedSize(iconSize); + m_ui->packageManagerIconButton->setToolTip(tr("Size should be %1x%2 pixels") + .arg(iconSize.width()).arg(iconSize.height())); + m_ui->editSpecFileButton->setVisible(false); + updateDebianFileList(); + handleControlFileUpdate(); + connect(m_ui->packageManagerNameLineEdit, SIGNAL(editingFinished()), + SLOT(setPackageManagerName())); + connect(debBasedMaemoTarget, SIGNAL(debianDirContentsChanged()), + SLOT(updateDebianFileList())); + connect(debBasedMaemoTarget, SIGNAL(changeLogChanged()), + SLOT(updateVersionInfo())); + connect(debBasedMaemoTarget, SIGNAL(controlChanged()), + SLOT(handleControlFileUpdate())); + } else { + m_ui->packageManagerNameLabel->hide(); + m_ui->packageManagerNameLineEdit->hide(); + m_ui->packageManagerIconLabel->hide(); + m_ui->packageManagerIconButton->hide(); + m_ui->editDebianFileLabel->hide(); + m_ui->debianFilesComboBox->hide(); + m_ui->editDebianFileButton->hide(); + + // This is fragile; be careful when editing the UI file. + m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(4, QFormLayout::LabelRole)); + m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(4, QFormLayout::FieldRole)); + m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(5, QFormLayout::LabelRole)); + m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(5, QFormLayout::FieldRole)); + m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(6, QFormLayout::LabelRole)); + m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(6, QFormLayout::FieldRole)); + handleSpecFileUpdate(); + connect(m_step->rpmBasedMaemoTarget(), SIGNAL(specFileChanged()), + SLOT(handleSpecFileUpdate())); + connect(m_ui->editSpecFileButton, SIGNAL(clicked()), + SLOT(editSpecFile())); + } + connect(m_step, SIGNAL(packageFilePathChanged()), this, + SIGNAL(updateSummary())); + connect(m_ui->packageNameLineEdit, SIGNAL(editingFinished()), + SLOT(setPackageName())); + connect(m_ui->shortDescriptionLineEdit, SIGNAL(editingFinished()), + SLOT(setShortDescription())); +} + +void MaemoPackageCreationWidget::updateDebianFileList() +{ + m_ui->debianFilesComboBox->clear(); + const QStringList &debianFiles = m_step->debBasedMaemoTarget()->debianFiles(); + foreach (const QString &fileName, debianFiles) { + if (fileName != QLatin1String("compat") + && !fileName.endsWith(QLatin1Char('~'))) + m_ui->debianFilesComboBox->addItem(fileName); + } +} + +void MaemoPackageCreationWidget::updateVersionInfo() +{ + QString error; + QString versionString = m_step->versionString(&error); + if (versionString.isEmpty()) { + QMessageBox::critical(this, tr("No Version Available."), error); + versionString = AbstractMaemoPackageCreationStep::DefaultVersionNumber; + } + const QStringList list = versionString.split(QLatin1Char('.'), + QString::SkipEmptyParts); + const bool blocked = m_ui->major->signalsBlocked(); + m_ui->major->blockSignals(true); + m_ui->minor->blockSignals(true); + m_ui->patch->blockSignals(true); + m_ui->major->setValue(list.value(0, QLatin1String("0")).toInt()); + m_ui->minor->setValue(list.value(1, QLatin1String("0")).toInt()); + m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt()); + m_ui->major->blockSignals(blocked); + m_ui->minor->blockSignals(blocked); + m_ui->patch->blockSignals(blocked); + updateSummary(); +} + +void MaemoPackageCreationWidget::handleControlFileUpdate() +{ + updatePackageName(); + updateShortDescription(); + updatePackageManagerName(); + updatePackageManagerIcon(); + updateSummary(); +} + +void MaemoPackageCreationWidget::handleSpecFileUpdate() +{ + updatePackageName(); + updateShortDescription(); + updateVersionInfo(); + updateSummary(); +} + +void MaemoPackageCreationWidget::updatePackageManagerIcon() +{ + QString error; + const QIcon &icon = m_step->debBasedMaemoTarget()->packageManagerIcon(&error); + if (!error.isEmpty()) { + QMessageBox::critical(this, tr("Could not read icon"), error); + } else { + m_ui->packageManagerIconButton->setIcon(icon); + m_ui->packageManagerIconButton->setIconSize(m_ui->packageManagerIconButton->size()); + } +} + +void MaemoPackageCreationWidget::updatePackageName() +{ + m_ui->packageNameLineEdit->setText(m_step->maemoTarget()->packageName()); +} + +void MaemoPackageCreationWidget::updatePackageManagerName() +{ + m_ui->packageManagerNameLineEdit->setText(m_step->debBasedMaemoTarget()->packageManagerName()); +} + +void MaemoPackageCreationWidget::updateShortDescription() +{ + m_ui->shortDescriptionLineEdit->setText(m_step->maemoTarget()->shortDescription()); +} + +void MaemoPackageCreationWidget::setPackageManagerIcon() +{ + QString imageFilter = tr("Images") + QLatin1String("( "); + const QList &imageTypes = QImageReader::supportedImageFormats(); + foreach (const QByteArray &imageType, imageTypes) + imageFilter += "*." + QString::fromAscii(imageType) + QLatin1Char(' '); + imageFilter += QLatin1Char(')'); + const QString iconFileName = QFileDialog::getOpenFileName(this, + tr("Choose Image (will be scaled to 48x48 pixels if necessary)"), + QString(), imageFilter); + if (!iconFileName.isEmpty()) { + QString error; + if (!m_step->debBasedMaemoTarget()->setPackageManagerIcon(iconFileName, &error)) + QMessageBox::critical(this, tr("Could Not Set New Icon"), error); + } +} + +void MaemoPackageCreationWidget::setPackageName() +{ + if (!m_step->maemoTarget()->setPackageName(m_ui->packageNameLineEdit->text())) { + QMessageBox::critical(this, tr("File Error"), + tr("Could not set project name.")); + } +} + +void MaemoPackageCreationWidget::setPackageManagerName() +{ + if (!m_step->debBasedMaemoTarget()->setPackageManagerName(m_ui->packageManagerNameLineEdit->text())) { + QMessageBox::critical(this, tr("File Error"), + tr("Could not set package name for project manager.")); + } +} + +void MaemoPackageCreationWidget::setShortDescription() +{ + if (!m_step->maemoTarget()->setShortDescription(m_ui->shortDescriptionLineEdit->text())) { + QMessageBox::critical(this, tr("File Error"), + tr("Could not set project description.")); + } +} + +QString MaemoPackageCreationWidget::summaryText() const +{ + return tr("Create Package: ") + + QDir::toNativeSeparators(m_step->packageFilePath()); +} + +QString MaemoPackageCreationWidget::displayName() const +{ + return m_step->displayName(); +} + +void MaemoPackageCreationWidget::versionInfoChanged() +{ + QString error; + const bool success = m_step->setVersionString(m_ui->major->text() + + QLatin1Char('.') + m_ui->minor->text() + QLatin1Char('.') + + m_ui->patch->text(), &error); + if (!success) { + QMessageBox::critical(this, tr("Could Not Set Version Number"), error); + updateVersionInfo(); + } +} + +void MaemoPackageCreationWidget::editDebianFile() +{ + editFile(m_step->debBasedMaemoTarget()->debianDirPath() + + QLatin1Char('/') + m_ui->debianFilesComboBox->currentText()); +} + +void MaemoPackageCreationWidget::editSpecFile() +{ + editFile(m_step->rpmBasedMaemoTarget()->specFilePath()); +} + +void MaemoPackageCreationWidget::editFile(const QString &filePath) +{ + Core::EditorManager::instance()->openEditor(filePath, QString(), + Core::EditorManager::ModeSwitch); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopackagecreationwidget.h b/src/plugins/madde/maemopackagecreationwidget.h new file mode 100644 index 00000000000..207b066013a --- /dev/null +++ b/src/plugins/madde/maemopackagecreationwidget.h @@ -0,0 +1,83 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOPACKAGECREATIONWIDGET_H +#define MAEMOPACKAGECREATIONWIDGET_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { class MaemoPackageCreationWidget; } +QT_END_NAMESPACE + +namespace Madde { +namespace Internal { +class AbstractMaemoPackageCreationStep; + +class MaemoPackageCreationWidget : public ProjectExplorer::BuildStepConfigWidget +{ + Q_OBJECT +public: + MaemoPackageCreationWidget(AbstractMaemoPackageCreationStep *step); + ~MaemoPackageCreationWidget(); + + virtual QString summaryText() const; + virtual QString displayName() const; + +private slots: + void editDebianFile(); + void editSpecFile(); + void versionInfoChanged(); + void initGui(); + void updateDebianFileList(); + void updateVersionInfo(); + void handleControlFileUpdate(); + void handleSpecFileUpdate(); + void setPackageManagerIcon(); + void setPackageManagerName(); + void setPackageName(); + void setShortDescription(); + +private: + void updatePackageManagerIcon(); + void updatePackageName(); + void updatePackageManagerName(); + void updateShortDescription(); + void editFile(const QString &filePath); + + AbstractMaemoPackageCreationStep * const m_step; + Ui::MaemoPackageCreationWidget * const m_ui; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPACKAGECREATIONWIDGET_H diff --git a/src/plugins/madde/maemopackagecreationwidget.ui b/src/plugins/madde/maemopackagecreationwidget.ui new file mode 100644 index 00000000000..b7017f27270 --- /dev/null +++ b/src/plugins/madde/maemopackagecreationwidget.ui @@ -0,0 +1,353 @@ + + + MaemoPackageCreationWidget + + + + 0 + 0 + 615 + 284 + + + + + 1 + 1 + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Package name: + + + + + + + + + + + 0 + 0 + + + + + 50 + false + + + + Package version: + + + + + + + + + + 0 + 0 + + + + Major: + + + + + + + + 0 + 0 + + + + 99 + + + + + + + + 0 + 0 + + + + Minor: + + + + + + + + 0 + 0 + + + + 99 + + + + + + + + 0 + 0 + + + + Patch: + + + + + + + + 0 + 0 + + + + 99 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Short package description: + + + + + + + + + + + + + + Name to be displayed in Package Manager: + + + + + + + + + + + + + + + 0 + 48 + + + + Icon to be displayed in Package Manager: + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Adapt Debian file: + + + + + + + + + + + + Edit + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Edit spec file + + + + + + + + + + + major + valueChanged(int) + MaemoPackageCreationWidget + versionInfoChanged() + + + 352 + 88 + + + 461 + 32 + + + + + minor + valueChanged(int) + MaemoPackageCreationWidget + versionInfoChanged() + + + 449 + 88 + + + 5 + 15 + + + + + patch + valueChanged(int) + MaemoPackageCreationWidget + versionInfoChanged() + + + 546 + 88 + + + 466 + 0 + + + + + editDebianFileButton + clicked() + MaemoPackageCreationWidget + editDebianFile() + + + 398 + 218 + + + 8 + 86 + + + + + packageManagerIconButton + clicked() + MaemoPackageCreationWidget + setPackageManagerIcon() + + + 289 + 186 + + + 2 + 143 + + + + + + addFile() + removeFile() + handleSkipButtonToggled(bool) + versionInfoChanged() + editDebianFile() + setPackageManagerIcon() + + diff --git a/src/plugins/madde/maemopackageinstaller.cpp b/src/plugins/madde/maemopackageinstaller.cpp new file mode 100644 index 00000000000..729beb643c9 --- /dev/null +++ b/src/plugins/madde/maemopackageinstaller.cpp @@ -0,0 +1,101 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemopackageinstaller.h" + +#include "maemoglobal.h" + +namespace Madde { +namespace Internal { + +MaemoDebianPackageInstaller::MaemoDebianPackageInstaller(QObject *parent) + : AbstractRemoteLinuxPackageInstaller(parent) +{ + connect(this, SIGNAL(stderrData(QString)), SLOT(handleInstallerErrorOutput(QString))); +} + +void MaemoDebianPackageInstaller::prepareInstallation() +{ + m_installerStderr.clear(); +} + +QString MaemoDebianPackageInstaller::installCommandLine(const QString &packageFilePath) const +{ + return MaemoGlobal::devrootshPath() + QLatin1String(" dpkg -i --no-force-downgrade ") + + packageFilePath; +} + +QString MaemoDebianPackageInstaller::cancelInstallationCommandLine() const +{ + return QLatin1String("pkill dpkg"); +} + +void MaemoDebianPackageInstaller::handleInstallerErrorOutput(const QString &output) +{ + m_installerStderr += output; +} + +QString MaemoDebianPackageInstaller::errorString() const +{ + if (m_installerStderr.contains(QLatin1String("Will not downgrade"))) { + return tr("Installation failed: " + "You tried to downgrade a package, which is not allowed."); + } else { + return QString(); + } +} + + +MaemoRpmPackageInstaller::MaemoRpmPackageInstaller(QObject *parent) + : AbstractRemoteLinuxPackageInstaller(parent) +{ +} + +QString MaemoRpmPackageInstaller::installCommandLine(const QString &packageFilePath) const +{ + // rpm -U does not allow to re-install a package with the same version + // number, so we need --replacepkgs. Even then, it inexplicably reports + // a conflict if the files are not identical to the installed version, + // so we need --replacefiles as well. + // TODO: --replacefiles is dangerous. Is there perhaps a way around it + // after all? + return MaemoGlobal::devrootshPath() + QLatin1String(" rpm -Uhv --replacepkgs --replacefiles ") + + packageFilePath; +} + +QString MaemoRpmPackageInstaller::cancelInstallationCommandLine() const +{ + return QLatin1String("pkill rpm"); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopackageinstaller.h b/src/plugins/madde/maemopackageinstaller.h new file mode 100644 index 00000000000..3acc171a3b4 --- /dev/null +++ b/src/plugins/madde/maemopackageinstaller.h @@ -0,0 +1,74 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef ABSTRACTMAEMOPACKAGEINSTALLER_H +#define ABSTRACTMAEMOPACKAGEINSTALLER_H + +#include + +namespace Madde { +namespace Internal { + +class MaemoDebianPackageInstaller: public RemoteLinux::AbstractRemoteLinuxPackageInstaller +{ + Q_OBJECT +public: + explicit MaemoDebianPackageInstaller(QObject *parent); + +private slots: + void handleInstallerErrorOutput(const QString &output); + +private: + void prepareInstallation(); + QString errorString() const; + QString installCommandLine(const QString &packageFilePath) const; + QString cancelInstallationCommandLine() const; + + QString m_installerStderr; +}; + + +class MaemoRpmPackageInstaller : public RemoteLinux::AbstractRemoteLinuxPackageInstaller +{ + Q_OBJECT +public: + MaemoRpmPackageInstaller(QObject *parent); + +private: + QString installCommandLine(const QString &packageFilePath) const; + QString cancelInstallationCommandLine() const; +}; + +} // namespace Internal +} // namespace Madde + +#endif // ABSTRACTMAEMOPACKAGEINSTALLER_H diff --git a/src/plugins/madde/maemopublishedprojectmodel.cpp b/src/plugins/madde/maemopublishedprojectmodel.cpp new file mode 100644 index 00000000000..bf0f889ab65 --- /dev/null +++ b/src/plugins/madde/maemopublishedprojectmodel.cpp @@ -0,0 +1,135 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemopublishedprojectmodel.h" + +#include + +namespace Madde { +namespace Internal { +namespace { +const int IncludeColumn = 2; +} // anonymous namespace + +MaemoPublishedProjectModel::MaemoPublishedProjectModel(QObject *parent) + : QFileSystemModel(parent) +{ + setFilter(filter() | QDir::Hidden | QDir::System); +} + +void MaemoPublishedProjectModel::initFilesToExclude() +{ + initFilesToExclude(rootPath()); +} + +void MaemoPublishedProjectModel::initFilesToExclude(const QString &filePath) +{ + QFileInfo fi(filePath); + if (fi.isDir()) { + const QStringList fileNames = QDir(filePath).entryList(QDir::Files + | QDir::Dirs | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden); + foreach (const QString &fileName, fileNames) + initFilesToExclude(filePath + QLatin1Char('/') + fileName); + } else { + const QString &fileName = fi.fileName(); + if (fi.isHidden() || fileName.endsWith(QLatin1String(".o")) + || fileName == QLatin1String("Makefile") + || fileName.contains(QLatin1String(".pro.user")) + || fileName.contains(QLatin1String(".so")) + || fileName.endsWith(QLatin1String(".a"))) { + m_filesToExclude.insert(filePath); + } + } +} + +int MaemoPublishedProjectModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return IncludeColumn + 1; +} + +int MaemoPublishedProjectModel::rowCount(const QModelIndex &parent) const +{ + if (isDir(parent) && m_filesToExclude.contains(filePath(parent))) + return 0; + return QFileSystemModel::rowCount(parent); +} + +QVariant MaemoPublishedProjectModel::headerData(int section, + Qt::Orientation orientation, int role) const +{ + if (orientation != Qt::Horizontal || section != IncludeColumn) + return QFileSystemModel::headerData(section, orientation, role); + return tr("Include in package"); +} + +Qt::ItemFlags MaemoPublishedProjectModel::flags(const QModelIndex &index) const +{ + if (index.column() != IncludeColumn) + return QFileSystemModel::flags(index); + return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; +} + +QVariant MaemoPublishedProjectModel::data(const QModelIndex &index, + int role) const +{ + if (index.column() != IncludeColumn) + return QFileSystemModel::data(index, role); + const bool include = !m_filesToExclude.contains(filePath(index)); + if (role == Qt::DisplayRole) + return include ? tr("Include") : tr("Do not include"); + else if (role == Qt::CheckStateRole) + return include ? Qt::Checked : Qt::Unchecked; + else + return QVariant(); +} + +bool MaemoPublishedProjectModel::setData(const QModelIndex &index, + const QVariant &value, int role) +{ + if (index.column() != IncludeColumn) + return QFileSystemModel::setData(index, value, role); + if (role == Qt::CheckStateRole) { + if (value == Qt::Checked) { + m_filesToExclude.remove(filePath(index)); + } else { + m_filesToExclude.insert(filePath(index)); + } + if (isDir(index)) + emit layoutChanged(); + return true; + } + return false; +} + + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopublishedprojectmodel.h b/src/plugins/madde/maemopublishedprojectmodel.h new file mode 100644 index 00000000000..4309f5f9dfa --- /dev/null +++ b/src/plugins/madde/maemopublishedprojectmodel.h @@ -0,0 +1,68 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOPUBLISHEDPROJECTMODEL_H +#define MAEMOPUBLISHEDPROJECTMODEL_H + +#include +#include +#include + +namespace Madde { +namespace Internal { + +class MaemoPublishedProjectModel : public QFileSystemModel +{ + Q_OBJECT +public: + explicit MaemoPublishedProjectModel(QObject *parent = 0); + void initFilesToExclude(); + QStringList filesToExclude() const { return m_filesToExclude.toList(); } + +private: + virtual int columnCount(const QModelIndex &parent) const; + virtual int rowCount(const QModelIndex &parent) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, + int role) const; + virtual QVariant data(const QModelIndex &index, int role) const; + virtual bool setData(const QModelIndex &index, const QVariant &value, + int role); + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + + void initFilesToExclude(const QString &filePath); + + QSet m_filesToExclude; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPUBLISHEDPROJECTMODEL_H diff --git a/src/plugins/madde/maemopublisherfremantlefree.cpp b/src/plugins/madde/maemopublisherfremantlefree.cpp new file mode 100644 index 00000000000..a0dbe99bc43 --- /dev/null +++ b/src/plugins/madde/maemopublisherfremantlefree.cpp @@ -0,0 +1,645 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemopublisherfremantlefree.h" + +#include "maemoglobal.h" +#include "maemopackagecreationstep.h" +#include "maemopublishingfileselectiondialog.h" +#include "qt4maemodeployconfiguration.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace Core; +using namespace Qt4ProjectManager; +using namespace RemoteLinux; +using namespace Utils; + +namespace Madde { +namespace Internal { + +MaemoPublisherFremantleFree::MaemoPublisherFremantleFree(const ProjectExplorer::Project *project, + QObject *parent) : + QObject(parent), + m_project(project), + m_state(Inactive), + m_sshParams(SshConnectionParameters::DefaultProxy) +{ + m_sshParams.authenticationType = SshConnectionParameters::AuthenticationByKey; + m_sshParams.timeout = 30; + m_sshParams.port = 22; + m_process = new QProcess(this); + connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), + SLOT(handleProcessFinished())); + connect(m_process, SIGNAL(error(QProcess::ProcessError)), + SLOT(handleProcessError(QProcess::ProcessError))); + connect(m_process, SIGNAL(readyReadStandardOutput()), + SLOT(handleProcessStdOut())); + connect(m_process, SIGNAL(readyReadStandardError()), + SLOT(handleProcessStdErr())); +} + +MaemoPublisherFremantleFree::~MaemoPublisherFremantleFree() +{ + QTC_ASSERT(m_state == Inactive, return); + m_process->kill(); +} + +void MaemoPublisherFremantleFree::publish() +{ + createPackage(); +} + +void MaemoPublisherFremantleFree::setSshParams(const QString &hostName, + const QString &userName, const QString &keyFile, const QString &remoteDir) +{ + Q_ASSERT(m_doUpload); + m_sshParams.host = hostName; + m_sshParams.userName = userName; + m_sshParams.privateKeyFile = keyFile; + m_remoteDir = remoteDir; +} + +void MaemoPublisherFremantleFree::cancel() +{ + finishWithFailure(tr("Canceled."), tr("Publishing canceled by user.")); +} + +void MaemoPublisherFremantleFree::createPackage() +{ + setState(CopyingProjectDir); + + const QStringList &problems = findProblems(); + if (!problems.isEmpty()) { + const QLatin1String separator("\n- "); + finishWithFailure(tr("The project is missing some information " + "important to publishing:") + separator + problems.join(separator), + tr("Publishing failed: Missing project information.")); + return; + } + + m_tmpProjectDir = tmpDirContainer() + QLatin1Char('/') + + m_project->displayName(); + if (QFileInfo(tmpDirContainer()).exists()) { + emit progressReport(tr("Removing left-over temporary directory ...")); + QString error; + if (!Utils::FileUtils::removeRecursively(tmpDirContainer(), &error)) { + finishWithFailure(tr("Error removing temporary directory: %1").arg(error), + tr("Publishing failed: Could not create source package.")); + return; + } + } + + emit progressReport(tr("Setting up temporary directory ...")); + if (!QDir::temp().mkdir(QFileInfo(tmpDirContainer()).fileName())) { + finishWithFailure(tr("Error: Could not create temporary directory."), + tr("Publishing failed: Could not create source package.")); + return; + } + if (!copyRecursively(m_project->projectDirectory(), m_tmpProjectDir)) { + finishWithFailure(tr("Error: Could not copy project directory."), + tr("Publishing failed: Could not create source package.")); + return; + } + if (!fixNewlines()) { + finishWithFailure(tr("Error: Could not fix newlines."), + tr("Publishing failed: Could not create source package.")); + return; + } + + QString error; + if (!updateDesktopFiles(&error)) { + finishWithFailure(error, + tr("Publishing failed: Could not create package.")); + return; + } + + emit progressReport(tr("Cleaning up temporary directory ...")); + AbstractMaemoPackageCreationStep::preparePackagingProcess(m_process, + m_buildConfig, m_tmpProjectDir); + setState(RunningQmake); + ProjectExplorer::AbstractProcessStep * const qmakeStep + = m_buildConfig->qmakeStep(); + qmakeStep->init(); + const ProjectExplorer::ProcessParameters * const pp + = qmakeStep->processParameters(); + m_process->start(pp->effectiveCommand() + QLatin1String(" ") + + pp->effectiveArguments()); +} + +bool MaemoPublisherFremantleFree::copyRecursively(const QString &srcFilePath, + const QString &tgtFilePath) +{ + if (m_state == Inactive) + return true; + + QFileInfo srcFileInfo(srcFilePath); + if (srcFileInfo.isDir()) { + if (srcFileInfo == QFileInfo(m_project->projectDirectory() + + QLatin1String("/debian"))) + return true; + QString actualSourcePath = srcFilePath; + QString actualTargetPath = tgtFilePath; + + if (srcFileInfo.fileName() == QLatin1String("qtc_packaging")) { + actualSourcePath += QLatin1String("/debian_fremantle"); + actualTargetPath.replace(QRegExp(QLatin1String("qtc_packaging$")), + QLatin1String("debian")); + } + + QDir targetDir(actualTargetPath); + targetDir.cdUp(); + if (!targetDir.mkdir(QFileInfo(actualTargetPath).fileName())) { + emit progressReport(tr("Failed to create directory '%1'.") + .arg(QDir::toNativeSeparators(actualTargetPath)), ErrorOutput); + return false; + } + QDir sourceDir(actualSourcePath); + QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Hidden + | QDir::System | QDir::Dirs | QDir::NoDotAndDotDot); + foreach (const QString &fileName, fileNames) { + if (!copyRecursively(actualSourcePath + QLatin1Char('/') + fileName, + actualTargetPath + QLatin1Char('/') + fileName)) + return false; + } + } else { + if (tgtFilePath == m_tmpProjectDir + QLatin1String("/debian/rules")) { + Utils::FileReader reader; + if (!reader.fetch(srcFilePath)) { + emit progressReport(reader.errorString(), ErrorOutput); + return false; + } + QByteArray rulesContents = reader.data(); + rulesContents.replace("$(MAKE) clean", "# $(MAKE) clean"); + rulesContents.replace("# Add here commands to configure the package.", + "qmake " + QFileInfo(m_project->file()->fileName()).fileName().toLocal8Bit()); + MaemoDebianPackageCreationStep::ensureShlibdeps(rulesContents); + Utils::FileSaver saver(tgtFilePath); + saver.write(rulesContents); + if (!saver.finalize()) { + emit progressReport(saver.errorString(), ErrorOutput); + return false; + } + } else { + QFile srcFile(srcFilePath); + if (!srcFile.copy(tgtFilePath)) { + emit progressReport(tr("Could not copy file '%1' to '%2': %3.") + .arg(QDir::toNativeSeparators(srcFilePath), + QDir::toNativeSeparators(tgtFilePath), + srcFile.errorString())); + return false; + } + } + } + return true; +} + +bool MaemoPublisherFremantleFree::fixNewlines() +{ + QDir debianDir(m_tmpProjectDir + QLatin1String("/debian")); + const QStringList &fileNames = debianDir.entryList(QDir::Files); + foreach (const QString &fileName, fileNames) { + QString filePath = debianDir.filePath(fileName); + Utils::FileReader reader; + if (!reader.fetch(filePath)) + return false; + QByteArray contents = reader.data(); + const QByteArray crlf("\r\n"); + if (!contents.contains(crlf)) + continue; + contents.replace(crlf, "\n"); + Utils::FileSaver saver(filePath); + saver.write(contents); + if (!saver.finalize()) + return false; + } + return true; +} + +void MaemoPublisherFremantleFree::handleProcessError(QProcess::ProcessError error) +{ + if (error == QProcess::FailedToStart) + handleProcessFinished(true); +} + +void MaemoPublisherFremantleFree::handleProcessFinished() +{ + handleProcessFinished(false); +} + +void MaemoPublisherFremantleFree::handleProcessStdOut() +{ + if (m_state == RunningQmake || m_state == RunningMakeDistclean + || m_state == BuildingPackage) { + emit progressReport(QString::fromLocal8Bit(m_process->readAllStandardOutput()), + ToolStatusOutput); + } +} + +void MaemoPublisherFremantleFree::handleProcessStdErr() +{ + if (m_state == RunningQmake || m_state == RunningMakeDistclean + || m_state == BuildingPackage) { + emit progressReport(QString::fromLocal8Bit(m_process->readAllStandardError()), + ToolErrorOutput); + } +} + +void MaemoPublisherFremantleFree::handleProcessFinished(bool failedToStart) +{ + QTC_ASSERT(m_state == RunningQmake || m_state == RunningMakeDistclean + || m_state == BuildingPackage || m_state == Inactive, return); + + switch (m_state) { + case RunningQmake: + if (failedToStart || m_process->exitStatus() != QProcess::NormalExit + ||m_process->exitCode() != 0) { + runDpkgBuildPackage(); + } else { + setState(RunningMakeDistclean); + m_process->start(m_buildConfig->makeCommand(), + QStringList() << QLatin1String("distclean")); + } + break; + case RunningMakeDistclean: + runDpkgBuildPackage(); + break; + case BuildingPackage: { + QString error; + if (failedToStart) { + error = tr("Error: Failed to start dpkg-buildpackage."); + } else if (m_process->exitStatus() != QProcess::NormalExit + || m_process->exitCode() != 0) { + error = tr("Error: dpkg-buildpackage did not succeed."); + } + + if (!error.isEmpty()) { + finishWithFailure(error, tr("Package creation failed.")); + return; + } + + QDir dir(tmpDirContainer()); + const QStringList &fileNames = dir.entryList(QDir::Files); + foreach (const QString &fileName, fileNames) { + const QString filePath + = tmpDirContainer() + QLatin1Char('/') + fileName; + if (fileName.endsWith(QLatin1String(".dsc"))) + m_filesToUpload.append(filePath); + else + m_filesToUpload.prepend(filePath); + } + if (!m_doUpload) { + emit progressReport(tr("Done.")); + QStringList nativeFilePaths; + foreach (const QString &filePath, m_filesToUpload) + nativeFilePaths << QDir::toNativeSeparators(filePath); + m_resultString = tr("Packaging finished successfully. " + "The following files were created:\n") + + nativeFilePaths.join(QLatin1String("\n")); + setState(Inactive); + } else { + uploadPackage(); + } + break; + } + default: + break; + } +} + +void MaemoPublisherFremantleFree::runDpkgBuildPackage() +{ + MaemoPublishingFileSelectionDialog d(m_tmpProjectDir); + if (d.exec() == QDialog::Rejected) { + cancel(); + return; + } + foreach (const QString &filePath, d.filesToExclude()) { + QString error; + if (!Utils::FileUtils::removeRecursively(filePath, &error)) { + finishWithFailure(error, + tr("Publishing failed: Could not create package.")); + } + } + + QtSupport::BaseQtVersion *lqt = m_buildConfig->qtVersion(); + if (!lqt) + finishWithFailure(QString(), tr("No Qt version set.")); + + if (m_state == Inactive) + return; + setState(BuildingPackage); + emit progressReport(tr("Building source package...")); + const QStringList args = QStringList() << QLatin1String("dpkg-buildpackage") + << QLatin1String("-S") << QLatin1String("-us") << QLatin1String("-uc"); + MaemoGlobal::callMad(*m_process, args, lqt->qmakeCommand(), true); +} + +// We have to implement the SCP protocol, because the maemo.org +// webmaster refuses to enable SFTP "for security reasons" ... +void MaemoPublisherFremantleFree::uploadPackage() +{ + m_uploader = SshRemoteProcessRunner::create(m_sshParams); + connect(m_uploader.data(), SIGNAL(processStarted()), + SLOT(handleScpStarted())); + connect(m_uploader.data(), SIGNAL(connectionError(Utils::SshError)), + SLOT(handleConnectionError())); + connect(m_uploader.data(), SIGNAL(processClosed(int)), + SLOT(handleUploadJobFinished(int))); + connect(m_uploader.data(), SIGNAL(processOutputAvailable(QByteArray)), + SLOT(handleScpStdOut(QByteArray))); + emit progressReport(tr("Starting scp ...")); + setState(StartingScp); + m_uploader->run("scp -td " + m_remoteDir.toUtf8()); +} + +void MaemoPublisherFremantleFree::handleScpStarted() +{ + QTC_ASSERT(m_state == StartingScp || m_state == Inactive, return); + + if (m_state == StartingScp) + prepareToSendFile(); +} + +void MaemoPublisherFremantleFree::handleConnectionError() +{ + if (m_state != Inactive) { + finishWithFailure(tr("SSH error: %1").arg(m_uploader->connection()->errorString()), + tr("Upload failed.")); + } +} + +void MaemoPublisherFremantleFree::handleUploadJobFinished(int exitStatus) +{ + QTC_ASSERT(m_state == PreparingToUploadFile || m_state == UploadingFile || m_state ==Inactive, + return); + + if (m_state != Inactive && (exitStatus != SshRemoteProcess::ExitedNormally + || m_uploader->process()->exitCode() != 0)) { + QString error; + if (exitStatus != SshRemoteProcess::ExitedNormally) { + error = tr("Error uploading file: %1.") + .arg(m_uploader->process()->errorString()); + } else { + error = tr("Error uploading file."); + } + finishWithFailure(error, tr("Upload failed.")); + } +} + +void MaemoPublisherFremantleFree::prepareToSendFile() +{ + if (m_filesToUpload.isEmpty()) { + emit progressReport(tr("All files uploaded.")); + m_resultString = tr("Upload succeeded. You should shortly " + "receive an email informing you about the outcome " + "of the build process."); + setState(Inactive); + return; + } + + setState(PreparingToUploadFile); + const QString &nextFilePath = m_filesToUpload.first(); + emit progressReport(tr("Uploading file %1 ...") + .arg(QDir::toNativeSeparators(nextFilePath))); + QFileInfo info(nextFilePath); + m_uploader->process()->sendInput("C0644 " + QByteArray::number(info.size()) + + ' ' + info.fileName().toUtf8() + '\n'); +} + +void MaemoPublisherFremantleFree::sendFile() +{ + Q_ASSERT(!m_filesToUpload.isEmpty()); + Q_ASSERT(m_state == PreparingToUploadFile); + + setState(UploadingFile); + const QString filePath = m_filesToUpload.takeFirst(); + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly)) { + finishWithFailure(tr("Cannot open file for reading: %1.") + .arg(file.errorString()), tr("Upload failed.")); + return; + } + qint64 bytesToSend = file.size(); + while (bytesToSend > 0) { + const QByteArray &data + = file.read(qMin(bytesToSend, Q_INT64_C(1024*1024))); + if (data.count() == 0) { + finishWithFailure(tr("Cannot read file: %1").arg(file.errorString()), + tr("Upload failed.")); + return; + } + m_uploader->process()->sendInput(data); + bytesToSend -= data.size(); + QCoreApplication::processEvents(); + if (m_state == Inactive) + return; + } + m_uploader->process()->sendInput(QByteArray(1, '\0')); +} + +void MaemoPublisherFremantleFree::handleScpStdOut(const QByteArray &output) +{ + QTC_ASSERT(m_state == PreparingToUploadFile || m_state == UploadingFile || m_state == Inactive, + return); + + if (m_state == Inactive) + return; + + m_scpOutput += output; + if (m_scpOutput == QByteArray(1, '\0')) { + m_scpOutput.clear(); + switch (m_state) { + case PreparingToUploadFile: + sendFile(); + break; + case UploadingFile: + prepareToSendFile(); + break; + default: + break; + } + } else if (m_scpOutput.endsWith('\n')) { + const QByteArray error = m_scpOutput.mid(1, m_scpOutput.count() - 2); + QString progressError; + if (!error.isEmpty()) { + progressError = tr("Error uploading file: %1.") + .arg(QString::fromUtf8(error)); + } else { + progressError = tr("Error uploading file."); + } + finishWithFailure(progressError, tr("Upload failed.")); + } +} + +QString MaemoPublisherFremantleFree::tmpDirContainer() const +{ + return QDir::tempPath() + QLatin1String("/qtc_packaging_") + + m_project->displayName(); +} + +void MaemoPublisherFremantleFree::finishWithFailure(const QString &progressMsg, + const QString &resultMsg) +{ + if (!progressMsg.isEmpty()) + emit progressReport(progressMsg, ErrorOutput); + m_resultString = resultMsg; + setState(Inactive); +} + +bool MaemoPublisherFremantleFree::updateDesktopFiles(QString *error) const +{ + bool success = true; + const Qt4MaemoDeployConfiguration * const deployConfig + = qobject_cast(m_buildConfig->target()->activeDeployConfiguration()); + const QSharedPointer deploymentInfo + = deployConfig->deploymentInfo(); + for (int i = 0; i < deploymentInfo->modelCount(); ++i) { + const DeployableFilesPerProFile * const model = deploymentInfo->modelAt(i); + QString desktopFilePath = deployConfig->localDesktopFilePath(model); + if (desktopFilePath.isEmpty()) + continue; + desktopFilePath.replace(model->projectDir(), m_tmpProjectDir); + const QString executableFilePath = model->remoteExecutableFilePath(); + if (executableFilePath.isEmpty()) { + qDebug("%s: Skipping subproject %s with missing deployment information.", + Q_FUNC_INFO, qPrintable(model->proFilePath())); + continue; + } + Utils::FileReader reader; + if (!reader.fetch(desktopFilePath, error)) { + success = false; + continue; + } + QByteArray desktopFileContents = reader.data(); + bool fileNeedsUpdate = addOrReplaceDesktopFileValue(desktopFileContents, + "Exec", executableFilePath.toUtf8()); + if (fileNeedsUpdate) { + Utils::FileSaver saver(desktopFilePath); + saver.write(desktopFileContents); + if (!saver.finalize(error)) + success = false; + } + } + return success; +} + +bool MaemoPublisherFremantleFree::addOrReplaceDesktopFileValue(QByteArray &fileContent, + const QByteArray &key, const QByteArray &newValue) const +{ + const int keyPos = fileContent.indexOf(key + '='); + if (keyPos == -1) { + if (!fileContent.endsWith('\n')) + fileContent += '\n'; + fileContent += key + '=' + newValue + '\n'; + return true; + } + int nextNewlinePos = fileContent.indexOf('\n', keyPos); + if (nextNewlinePos == -1) + nextNewlinePos = fileContent.count(); + const int replacePos = keyPos + key.count() + 1; + const int replaceCount = nextNewlinePos - replacePos; + const QByteArray &oldValue = fileContent.mid(replacePos, replaceCount); + if (oldValue == newValue) + return false; + fileContent.replace(replacePos, replaceCount, newValue); + return true; +} + +QStringList MaemoPublisherFremantleFree::findProblems() const +{ + QStringList problems; + const Qt4Maemo5Target * const target + = qobject_cast(m_buildConfig->target()); + const QString &description = target->shortDescription(); + if (description.trimmed().isEmpty()) { + problems << tr("The package description is empty. You must set one " + "in Projects -> Run -> Create Package -> Details."); + } else if (description.contains(QLatin1String("insert up to"))) { + problems << tr("The package description is '%1', which is probably " + "not what you want. Please change it in " + "Projects -> Run -> Create Package -> Details.").arg(description); + } + QString dummy; + if (target->packageManagerIcon(&dummy).isNull()) + problems << tr("You have not set an icon for the package manager. " + "The icon must be set in Projects -> Run -> Create Package -> Details."); + return problems; +} + +void MaemoPublisherFremantleFree::setState(State newState) +{ + if (m_state == newState) + return; + const State oldState = m_state; + m_state = newState; + if (m_state == Inactive) { + switch (oldState) { + case RunningQmake: + case RunningMakeDistclean: + case BuildingPackage: + disconnect(m_process, 0, this, 0); + m_process->terminate(); + break; + case StartingScp: + case PreparingToUploadFile: + case UploadingFile: + // TODO: Can we ensure the remote scp exits, e.g. by sending + // an illegal sequence of bytes? (Probably not, if + // we are currently uploading a file.) + disconnect(m_uploader.data(), 0, this, 0); + m_uploader = SshRemoteProcessRunner::Ptr(); + break; + default: + break; + } + emit finished(); + } +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopublisherfremantlefree.h b/src/plugins/madde/maemopublisherfremantlefree.h new file mode 100644 index 00000000000..b300fc3126a --- /dev/null +++ b/src/plugins/madde/maemopublisherfremantlefree.h @@ -0,0 +1,128 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOPUBLISHERFREMANTLEFREE_H +#define MAEMOPUBLISHERFREMANTLEFREE_H + +#include + +#include +#include + +namespace ProjectExplorer { +class Project; +} + +namespace Qt4ProjectManager { +class Qt4BuildConfiguration; +} + +namespace Madde { +namespace Internal { + +class MaemoPublisherFremantleFree : public QObject +{ + Q_OBJECT +public: + enum OutputType { + StatusOutput, ErrorOutput, ToolStatusOutput, ToolErrorOutput + }; + + explicit MaemoPublisherFremantleFree(const ProjectExplorer::Project *project, + QObject *parent = 0); + ~MaemoPublisherFremantleFree(); + + void publish(); + void cancel(); + + void setBuildConfiguration(const Qt4ProjectManager::Qt4BuildConfiguration *buildConfig) { m_buildConfig = buildConfig; } + void setDoUpload(bool doUpload) { m_doUpload = doUpload; } + void setSshParams(const QString &hostName, const QString &userName, + const QString &keyFile, const QString &remoteDir); + + QString resultString() const { return m_resultString; } + +signals: + void progressReport(const QString &text, + MaemoPublisherFremantleFree::OutputType = StatusOutput); + void finished(); + +private slots: + void handleProcessFinished(); + void handleProcessStdOut(); + void handleProcessStdErr(); + void handleProcessError(QProcess::ProcessError error); + void handleScpStarted(); + void handleConnectionError(); + void handleUploadJobFinished(int exitStatus); + void handleScpStdOut(const QByteArray &output); + +private: + enum State { + Inactive, CopyingProjectDir, RunningQmake, RunningMakeDistclean, + BuildingPackage, StartingScp, PreparingToUploadFile, UploadingFile + }; + + void setState(State newState); + void createPackage(); + void uploadPackage(); + bool copyRecursively(const QString &srcFilePath, + const QString &tgtFilePath); + bool fixNewlines(); + void handleProcessFinished(bool failedToStart); + void runDpkgBuildPackage(); + QString tmpDirContainer() const; + void prepareToSendFile(); + void sendFile(); + void finishWithFailure(const QString &progressMsg, const QString &resultMsg); + bool updateDesktopFiles(QString *error = 0) const; + bool addOrReplaceDesktopFileValue(QByteArray &fileContent, + const QByteArray &key, const QByteArray &newValue) const; + QStringList findProblems() const; + + const ProjectExplorer::Project * const m_project; + bool m_doUpload; + const Qt4ProjectManager::Qt4BuildConfiguration *m_buildConfig; + State m_state; + QString m_tmpProjectDir; + QProcess *m_process; + Utils::SshConnectionParameters m_sshParams; + QString m_remoteDir; + QSharedPointer m_uploader; + QByteArray m_scpOutput; + QList m_filesToUpload; + QString m_resultString; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPUBLISHERFREMANTLEFREE_H diff --git a/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.cpp b/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.cpp new file mode 100644 index 00000000000..dd63c835b6a --- /dev/null +++ b/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.cpp @@ -0,0 +1,119 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemopublishingbuildsettingspagefremantlefree.h" +#include "ui_maemopublishingbuildsettingspagefremantlefree.h" + +#include "maemoconstants.h" +#include "maemoglobal.h" +#include "maemopublisherfremantlefree.h" + +#include +#include +#include +#include +#include +#include + +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; + +namespace Madde { +namespace Internal { + +MaemoPublishingBuildSettingsPageFremantleFree::MaemoPublishingBuildSettingsPageFremantleFree(const Project *project, + MaemoPublisherFremantleFree *publisher, QWidget *parent) : + QWizardPage(parent), + m_publisher(publisher), + ui(new Ui::MaemoPublishingWizardPageFremantleFree) +{ + ui->setupUi(this); + collectBuildConfigurations(project); + QTC_ASSERT(!m_buildConfigs.isEmpty(), return); + foreach (const Qt4BuildConfiguration * const bc, m_buildConfigs) { + ui->buildConfigComboBox->addItem(bc->displayName()); + } + ui->buildConfigComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow); + ui->buildConfigComboBox->setCurrentIndex(0); + connect(ui->skipUploadCheckBox, SIGNAL(toggled(bool)), + SLOT(handleNoUploadSettingChanged())); +} + +MaemoPublishingBuildSettingsPageFremantleFree::~MaemoPublishingBuildSettingsPageFremantleFree() +{ + delete ui; +} + +void MaemoPublishingBuildSettingsPageFremantleFree::collectBuildConfigurations(const Project *project) +{ + foreach (const Target *const target, project->targets()) { + if (target->id() != QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)) + continue; + foreach (BuildConfiguration * const bc, target->buildConfigurations()) { + Qt4BuildConfiguration * const qt4Bc + = qobject_cast(bc); + if (!qt4Bc) + continue; + + QtSupport::BaseQtVersion *lqt = qt4Bc->qtVersion(); + if (!lqt) + continue; + if (MaemoGlobal::osType(lqt->qmakeCommand()) == QLatin1String(Maemo5OsType)) + m_buildConfigs << qt4Bc; + } + break; + } +} + +void MaemoPublishingBuildSettingsPageFremantleFree::initializePage() +{ + ui->skipUploadCheckBox->setChecked(true); +} + +bool MaemoPublishingBuildSettingsPageFremantleFree::validatePage() +{ + m_publisher->setBuildConfiguration(m_buildConfigs.at(ui->buildConfigComboBox->currentIndex())); + m_publisher->setDoUpload(!skipUpload()); + return true; +} + +void MaemoPublishingBuildSettingsPageFremantleFree::handleNoUploadSettingChanged() +{ + setCommitPage(skipUpload()); +} + +bool MaemoPublishingBuildSettingsPageFremantleFree::skipUpload() const +{ + return ui->skipUploadCheckBox->isChecked(); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.h b/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.h new file mode 100644 index 00000000000..cd14336ac8b --- /dev/null +++ b/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.h @@ -0,0 +1,75 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOPUBLISHINGBUILDSETTINGSPAGEFREMANTLEFREE_H +#define MAEMOPUBLISHINGBUILDSETTINGSPAGEFREMANTLEFREE_H + +#include +#include + +QT_BEGIN_NAMESPACE +namespace Ui { + class MaemoPublishingWizardPageFremantleFree; +} +QT_END_NAMESPACE + +namespace ProjectExplorer { class Project; } +namespace Qt4ProjectManager { class Qt4BuildConfiguration; } + +namespace Madde { +namespace Internal { +class MaemoPublisherFremantleFree; + +class MaemoPublishingBuildSettingsPageFremantleFree : public QWizardPage +{ + Q_OBJECT + +public: + explicit MaemoPublishingBuildSettingsPageFremantleFree(const ProjectExplorer::Project *project, + MaemoPublisherFremantleFree *publisher, QWidget *parent = 0); + ~MaemoPublishingBuildSettingsPageFremantleFree(); + +private: + Q_SLOT void handleNoUploadSettingChanged(); + virtual void initializePage(); + virtual bool validatePage(); + void collectBuildConfigurations(const ProjectExplorer::Project *project); + bool skipUpload() const; + + QList m_buildConfigs; + MaemoPublisherFremantleFree * const m_publisher; + Ui::MaemoPublishingWizardPageFremantleFree *ui; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPUBLISHINGBUILDSETTINGSPAGEFREMANTLEFREE_H diff --git a/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.ui b/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.ui new file mode 100644 index 00000000000..6e536f6cc81 --- /dev/null +++ b/src/plugins/madde/maemopublishingbuildsettingspagefremantlefree.ui @@ -0,0 +1,75 @@ + + + MaemoPublishingWizardPageFremantleFree + + + + 0 + 0 + 433 + 149 + + + + WizardPage + + + + + + + + Choose build configuration: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + + + + Only create source package, do not upload + + + + + + + Qt::Vertical + + + + 20 + 78 + + + + + + + + + diff --git a/src/plugins/madde/maemopublishingfileselectiondialog.cpp b/src/plugins/madde/maemopublishingfileselectiondialog.cpp new file mode 100644 index 00000000000..7e862599e65 --- /dev/null +++ b/src/plugins/madde/maemopublishingfileselectiondialog.cpp @@ -0,0 +1,65 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemopublishingfileselectiondialog.h" +#include "ui_maemopublishingfileselectiondialog.h" + +#include "maemopublishedprojectmodel.h" + +namespace Madde { +namespace Internal { + +MaemoPublishingFileSelectionDialog::MaemoPublishingFileSelectionDialog(const QString &projectPath, + QWidget *parent) : + QDialog(parent), + ui(new Ui::MaemoPublishingFileSelectionDialog) +{ + ui->setupUi(this); + m_projectModel = new MaemoPublishedProjectModel(this); + const QModelIndex rootIndex = m_projectModel->setRootPath(projectPath); + m_projectModel->initFilesToExclude(); + ui->projectView->setModel(m_projectModel); + ui->projectView->setRootIndex(rootIndex); + ui->projectView->header()->setResizeMode(0, QHeaderView::ResizeToContents); +} + +MaemoPublishingFileSelectionDialog::~MaemoPublishingFileSelectionDialog() +{ + delete ui; +} + +QStringList MaemoPublishingFileSelectionDialog::filesToExclude() const +{ + return m_projectModel->filesToExclude(); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopublishingfileselectiondialog.h b/src/plugins/madde/maemopublishingfileselectiondialog.h new file mode 100644 index 00000000000..e3e901b23d3 --- /dev/null +++ b/src/plugins/madde/maemopublishingfileselectiondialog.h @@ -0,0 +1,65 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOPUBLISHINGFILESELECTIONDIALOG_H +#define MAEMOPUBLISHINGFILESELECTIONDIALOG_H + +#include +#include + +QT_BEGIN_NAMESPACE +namespace Ui { + class MaemoPublishingFileSelectionDialog; +} +QT_END_NAMESPACE + +namespace Madde { +namespace Internal { + +class MaemoPublishingFileSelectionDialog : public QDialog +{ + Q_OBJECT + +public: + explicit MaemoPublishingFileSelectionDialog(const QString &projectPath, + QWidget *parent = 0); + ~MaemoPublishingFileSelectionDialog(); + QStringList filesToExclude() const; + +private: + Ui::MaemoPublishingFileSelectionDialog *ui; + class MaemoPublishedProjectModel *m_projectModel; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPUBLISHINGFILESELECTIONDIALOG_H diff --git a/src/plugins/madde/maemopublishingfileselectiondialog.ui b/src/plugins/madde/maemopublishingfileselectiondialog.ui new file mode 100644 index 00000000000..a66247f9eef --- /dev/null +++ b/src/plugins/madde/maemopublishingfileselectiondialog.ui @@ -0,0 +1,78 @@ + + + MaemoPublishingFileSelectionDialog + + + + 0 + 0 + 704 + 528 + + + + Choose Package Contents + + + false + + + + + + <b>Please select the files you want to be included in the source tarball.</b> + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + MaemoPublishingFileSelectionDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + MaemoPublishingFileSelectionDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/plugins/madde/maemopublishingresultpagefremantlefree.cpp b/src/plugins/madde/maemopublishingresultpagefremantlefree.cpp new file mode 100644 index 00000000000..48eee34f434 --- /dev/null +++ b/src/plugins/madde/maemopublishingresultpagefremantlefree.cpp @@ -0,0 +1,108 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemopublishingresultpagefremantlefree.h" +#include "ui_maemopublishingresultpagefremantlefree.h" + +#include + +namespace Madde { +namespace Internal { +typedef MaemoPublisherFremantleFree MPFF; + +MaemoPublishingResultPageFremantleFree::MaemoPublishingResultPageFremantleFree(MPFF *publisher, + QWidget *parent) : QWizardPage(parent), m_publisher(publisher), + ui(new Ui::MaemoPublishingResultPageFremantleFree) +{ + m_lastOutputType = MPFF::StatusOutput; + ui->setupUi(this); +} + +MaemoPublishingResultPageFremantleFree::~MaemoPublishingResultPageFremantleFree() +{ + delete ui; +} + +void MaemoPublishingResultPageFremantleFree::initializePage() +{ + cancelButton()->disconnect(); + connect(cancelButton(), SIGNAL(clicked()), SLOT(handleCancelRequest())); + connect(m_publisher, SIGNAL(finished()), SLOT(handleFinished())); + connect(m_publisher, + SIGNAL(progressReport(QString, MaemoPublisherFremantleFree::OutputType)), + SLOT(handleProgress(QString, MaemoPublisherFremantleFree::OutputType))); + m_publisher->publish(); +} + +void MaemoPublishingResultPageFremantleFree::handleFinished() +{ + handleProgress(m_publisher->resultString(), MPFF::StatusOutput); + m_isComplete = true; + cancelButton()->setEnabled(false); + emit completeChanged(); +} + +void MaemoPublishingResultPageFremantleFree::handleProgress(const QString &text, + MPFF::OutputType type) +{ + const QString color = QLatin1String(type == MPFF::StatusOutput + || type == MPFF::ToolStatusOutput ? "blue" : "red"); + ui->progressTextEdit->setTextColor(QColor(color)); + const bool bold = type == MPFF::StatusOutput + || type == MPFF::ErrorOutput ? true : false; + QFont font = ui->progressTextEdit->currentFont(); + font.setBold(bold); + ui->progressTextEdit->setCurrentFont(font); + + if (type == MPFF::StatusOutput || type == MPFF::ErrorOutput + || m_lastOutputType == MPFF::StatusOutput + || m_lastOutputType == MPFF::ErrorOutput) { + ui->progressTextEdit->append(text); + } else { + ui->progressTextEdit->insertPlainText(text); + } + ui->progressTextEdit->moveCursor(QTextCursor::End); + m_lastOutputType = type; +} + +void MaemoPublishingResultPageFremantleFree::handleCancelRequest() +{ + cancelButton()->setEnabled(false); + m_publisher->cancel(); +} + +QAbstractButton *MaemoPublishingResultPageFremantleFree::cancelButton() const +{ + return wizard()->button(QWizard::CancelButton); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopublishingresultpagefremantlefree.h b/src/plugins/madde/maemopublishingresultpagefremantlefree.h new file mode 100644 index 00000000000..d5a6de6e627 --- /dev/null +++ b/src/plugins/madde/maemopublishingresultpagefremantlefree.h @@ -0,0 +1,77 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H +#define MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H + +#include "maemopublisherfremantlefree.h" +#include + +QT_BEGIN_NAMESPACE +namespace Ui { + class MaemoPublishingResultPageFremantleFree; +} +QT_END_NAMESPACE + +namespace Madde { +namespace Internal { + +class MaemoPublishingResultPageFremantleFree : public QWizardPage +{ + Q_OBJECT + +public: + explicit MaemoPublishingResultPageFremantleFree(MaemoPublisherFremantleFree *publisher, + QWidget *parent = 0); + ~MaemoPublishingResultPageFremantleFree(); + +private slots: + void handleFinished(); + void handleProgress(const QString &text, + MaemoPublisherFremantleFree::OutputType type); + void handleCancelRequest(); + +private: + virtual bool isComplete() const { return m_isComplete; } + virtual void initializePage(); + + QAbstractButton *cancelButton() const; + + MaemoPublisherFremantleFree * const m_publisher; + bool m_isComplete; + MaemoPublisherFremantleFree::OutputType m_lastOutputType; + Ui::MaemoPublishingResultPageFremantleFree *ui; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H diff --git a/src/plugins/madde/maemopublishingresultpagefremantlefree.ui b/src/plugins/madde/maemopublishingresultpagefremantlefree.ui new file mode 100644 index 00000000000..f7f429ccf8d --- /dev/null +++ b/src/plugins/madde/maemopublishingresultpagefremantlefree.ui @@ -0,0 +1,33 @@ + + + MaemoPublishingResultPageFremantleFree + + + + 0 + 0 + 414 + 337 + + + + WizardPage + + + + + + Progress + + + + + + + + + + + + + diff --git a/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.cpp b/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.cpp new file mode 100644 index 00000000000..0a0969c4602 --- /dev/null +++ b/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.cpp @@ -0,0 +1,116 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemopublishinguploadsettingspagefremantlefree.h" +#include "ui_maemopublishinguploadsettingspagefremantlefree.h" + +#include "maemopublisherfremantlefree.h" + +#include + +#include + +namespace Madde { +namespace Internal { + +MaemoPublishingUploadSettingsPageFremantleFree::MaemoPublishingUploadSettingsPageFremantleFree(MaemoPublisherFremantleFree *publisher, + QWidget *parent) : + QWizardPage(parent), + m_publisher(publisher), + ui(new Ui::MaemoPublishingUploadSettingsPageFremantleFree) +{ + ui->setupUi(this); + ui->serverAddressLabel->hide(); + ui->serverAddressLineEdit->hide(); + ui->targetDirectoryOnServerLabel->hide(); + ui->targetDirectoryOnServerLineEdit->hide(); + setTitle(tr("Publishing to Fremantle's \"Extras-devel/free\" Repository")); + setSubTitle(tr("Upload options")); + connect(ui->garageAccountLineEdit, SIGNAL(textChanged(QString)), + SIGNAL(completeChanged())); + connect(ui->privateKeyPathChooser, SIGNAL(changed(QString)), + SIGNAL(completeChanged())); + connect(ui->serverAddressLineEdit, SIGNAL(textChanged(QString)), + SIGNAL(completeChanged())); + connect(ui->targetDirectoryOnServerLineEdit, SIGNAL(textChanged(QString)), + SIGNAL(completeChanged())); +} + +MaemoPublishingUploadSettingsPageFremantleFree::~MaemoPublishingUploadSettingsPageFremantleFree() +{ + delete ui; +} + +void MaemoPublishingUploadSettingsPageFremantleFree::initializePage() +{ + ui->garageAccountLineEdit->clear(); + ui->privateKeyPathChooser->setExpectedKind(Utils::PathChooser::File); + ui->privateKeyPathChooser->setPromptDialogTitle(tr("Choose a private key file")); + ui->privateKeyPathChooser->setPath(QDir::toNativeSeparators(QDir::homePath() + QLatin1String("/.ssh/id_rsa"))); + ui->serverAddressLineEdit->setText(QLatin1String("drop.maemo.org")); + ui->targetDirectoryOnServerLineEdit->setText(QLatin1String("/var/www/extras-devel/incoming-builder/fremantle/")); +} + +bool MaemoPublishingUploadSettingsPageFremantleFree::isComplete() const +{ + return !garageAccountName().isEmpty() && !privateKeyFilePath().isEmpty() + && !serverName().isEmpty() && !directoryOnServer().isEmpty(); +} + +QString MaemoPublishingUploadSettingsPageFremantleFree::garageAccountName() const +{ + return ui->garageAccountLineEdit->text().trimmed(); +} + +QString MaemoPublishingUploadSettingsPageFremantleFree::privateKeyFilePath() const +{ + return ui->privateKeyPathChooser->path(); +} + +QString MaemoPublishingUploadSettingsPageFremantleFree::serverName() const +{ + return ui->serverAddressLineEdit->text().trimmed(); +} + +QString MaemoPublishingUploadSettingsPageFremantleFree::directoryOnServer() const +{ + return ui->targetDirectoryOnServerLineEdit->text().trimmed(); +} + +bool MaemoPublishingUploadSettingsPageFremantleFree::validatePage() +{ + m_publisher->setSshParams(serverName(), garageAccountName(), + privateKeyFilePath(), directoryOnServer()); + return true; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.h b/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.h new file mode 100644 index 00000000000..a93b8c7643d --- /dev/null +++ b/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.h @@ -0,0 +1,73 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOPUBLISHINGUPLOADSETTINGSWIZARDPAGE_H +#define MAEMOPUBLISHINGUPLOADSETTINGSWIZARDPAGE_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { + class MaemoPublishingUploadSettingsPageFremantleFree; +} +QT_END_NAMESPACE + +namespace Madde { +namespace Internal { +class MaemoPublisherFremantleFree; + +class MaemoPublishingUploadSettingsPageFremantleFree : public QWizardPage +{ + Q_OBJECT + +public: + explicit MaemoPublishingUploadSettingsPageFremantleFree(MaemoPublisherFremantleFree *publisher, + QWidget *parent = 0); + ~MaemoPublishingUploadSettingsPageFremantleFree(); + +private: + virtual void initializePage(); + virtual bool isComplete() const; + virtual bool validatePage(); + + QString garageAccountName() const; + QString privateKeyFilePath() const; + QString serverName() const; + QString directoryOnServer() const; + + MaemoPublisherFremantleFree * const m_publisher; + Ui::MaemoPublishingUploadSettingsPageFremantleFree *ui; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPUBLISHINGUPLOADSETTINGSWIZARDPAGE_H diff --git a/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.ui b/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.ui new file mode 100644 index 00000000000..48064654d37 --- /dev/null +++ b/src/plugins/madde/maemopublishinguploadsettingspagefremantlefree.ui @@ -0,0 +1,95 @@ + + + MaemoPublishingUploadSettingsPageFremantleFree + + + + 0 + 0 + 636 + 128 + + + + WizardPage + + + Upload Settings + + + + + + Garage account name: + + + + + + + + + + + + <a href="https://garage.maemo.org/account/register.php">Get an account</a> + + + true + + + + + + + <a href="https://garage.maemo.org/extras-assistant/index.php">Request upload rights</a> + + + true + + + + + + + + + Private key file: + + + + + + + + + + Server address: + + + + + + + + + + Target directory on server: + + + + + + + + + + + Utils::PathChooser + QWidget +
utils/pathchooser.h
+
+
+ + +
diff --git a/src/plugins/madde/maemopublishingwizardfactories.cpp b/src/plugins/madde/maemopublishingwizardfactories.cpp new file mode 100644 index 00000000000..47e40ce1644 --- /dev/null +++ b/src/plugins/madde/maemopublishingwizardfactories.cpp @@ -0,0 +1,102 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemopublishingwizardfactories.h" + +#include "maemoconstants.h" +#include "maemoglobal.h" +#include "maemopublishingwizardfremantlefree.h" + +#include +#include +#include +#include +#include +#include + +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; + +namespace Madde { +namespace Internal { + +MaemoPublishingWizardFactoryFremantleFree::MaemoPublishingWizardFactoryFremantleFree(QObject *parent) + : IPublishingWizardFactory(parent) +{ +} + +QString MaemoPublishingWizardFactoryFremantleFree::displayName() const +{ + return tr("Publish for \"Fremantle Extras-devel free\" repository"); +} + +QString MaemoPublishingWizardFactoryFremantleFree::description() const +{ + return tr("This wizard will create a source archive and optionally upload " + "it to a build server, where the project will be compiled and " + "packaged and then moved to the \"Extras-devel free\" " + "repository, from where users can install it onto their N900 " + "devices. For the upload functionality, an account at " + "garage.maemo.org is required."); +} + +bool MaemoPublishingWizardFactoryFremantleFree::canCreateWizard(const Project *project) const +{ + if (!qobject_cast(project)) + return false; + foreach (const Target *const target, project->targets()) { + if (target->id() != QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)) + continue; + foreach (const BuildConfiguration *const bc, target->buildConfigurations()) { + const Qt4BuildConfiguration *const qt4Bc + = qobject_cast(bc); + if (!qt4Bc) + continue; + + QtSupport::BaseQtVersion *qt = qt4Bc->qtVersion(); + if (!qt) + continue; + if (MaemoGlobal::osType(qt->qmakeCommand()) == QLatin1String(Maemo5OsType)) + return true; + } + break; + } + return false; +} + +QWizard *MaemoPublishingWizardFactoryFremantleFree::createWizard(const Project *project) const +{ + Q_ASSERT(canCreateWizard(project)); + return new MaemoPublishingWizardFremantleFree(project); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopublishingwizardfactories.h b/src/plugins/madde/maemopublishingwizardfactories.h new file mode 100644 index 00000000000..f19c833812a --- /dev/null +++ b/src/plugins/madde/maemopublishingwizardfactories.h @@ -0,0 +1,60 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOPUBLISHINGSERVICE_H +#define MAEMOPUBLISHINGSERVICE_H + +#include + +namespace Core { +class SshRemoteProcessRunner; +} + +namespace Madde { +namespace Internal { + +class MaemoPublishingWizardFactoryFremantleFree + : public ProjectExplorer::IPublishingWizardFactory +{ + Q_OBJECT +public: + explicit MaemoPublishingWizardFactoryFremantleFree(QObject *parent =0); +private: + virtual QString displayName() const; + virtual QString description() const; + virtual bool canCreateWizard(const ProjectExplorer::Project *project) const; + virtual QWizard *createWizard(const ProjectExplorer::Project *project) const; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPUBLISHINGSERVICE_H diff --git a/src/plugins/madde/maemopublishingwizardfremantlefree.cpp b/src/plugins/madde/maemopublishingwizardfremantlefree.cpp new file mode 100644 index 00000000000..cc5664782c2 --- /dev/null +++ b/src/plugins/madde/maemopublishingwizardfremantlefree.cpp @@ -0,0 +1,81 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemopublishingwizardfremantlefree.h" + +#include "maemopublishingresultpagefremantlefree.h" +#include "maemopublisherfremantlefree.h" +#include "maemopublishinguploadsettingspagefremantlefree.h" +#include "maemopublishingbuildsettingspagefremantlefree.h" + +using namespace ProjectExplorer; + +namespace Madde { +namespace Internal { +namespace { +enum PageId { BuildSettingsPageId, UploadSettingsPageId, ResultPageId }; +} // anonymous namespace + +MaemoPublishingWizardFremantleFree::MaemoPublishingWizardFremantleFree(const Project *project, + QWidget *parent) : + Wizard(parent), + m_project(project), + m_publisher(new MaemoPublisherFremantleFree(project, this)) +{ + setOption(NoCancelButton, false); + setWindowTitle(tr("Publishing to Fremantle's \"Extras-devel free\" Repository")); + + m_buildSettingsPage + = new MaemoPublishingBuildSettingsPageFremantleFree(project, m_publisher); + m_buildSettingsPage->setTitle(tr("Build Settings")); + setPage(BuildSettingsPageId, m_buildSettingsPage); + + m_uploadSettingsPage + = new MaemoPublishingUploadSettingsPageFremantleFree(m_publisher); + m_uploadSettingsPage->setTitle(tr("Upload Settings")); + m_uploadSettingsPage->setCommitPage(true); + setPage(UploadSettingsPageId, m_uploadSettingsPage); + + m_resultPage = new MaemoPublishingResultPageFremantleFree(m_publisher); + m_resultPage->setTitle(tr("Result")); + setPage(ResultPageId, m_resultPage); +} + +int MaemoPublishingWizardFremantleFree::nextId() const +{ + if (currentPage()->isCommitPage()) + return ResultPageId; + return QWizard::nextId(); +} + + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemopublishingwizardfremantlefree.h b/src/plugins/madde/maemopublishingwizardfremantlefree.h new file mode 100644 index 00000000000..ca08311ec9c --- /dev/null +++ b/src/plugins/madde/maemopublishingwizardfremantlefree.h @@ -0,0 +1,68 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOPUBLISHINGWIZARDFREMANTLEFREE_H +#define MAEMOPUBLISHINGWIZARDFREMANTLEFREE_H + +#include + +namespace ProjectExplorer { +class Project; +} + +namespace Madde { +namespace Internal { +class MaemoPublishingResultPageFremantleFree; +class MaemoPublisherFremantleFree; +class MaemoPublishingUploadSettingsPageFremantleFree; +class MaemoPublishingBuildSettingsPageFremantleFree; + +class MaemoPublishingWizardFremantleFree : public Utils::Wizard +{ + Q_OBJECT +public: + explicit MaemoPublishingWizardFremantleFree(const ProjectExplorer::Project *project, + QWidget *parent = 0); + +private: + virtual int nextId() const; + + const ProjectExplorer::Project * const m_project; + MaemoPublisherFremantleFree * const m_publisher; + MaemoPublishingBuildSettingsPageFremantleFree *m_buildSettingsPage; + MaemoPublishingUploadSettingsPageFremantleFree *m_uploadSettingsPage; + MaemoPublishingResultPageFremantleFree *m_resultPage; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOPUBLISHINGWIZARDFREMANTLEFREE_H diff --git a/src/plugins/madde/maemoqemumanager.cpp b/src/plugins/madde/maemoqemumanager.cpp new file mode 100644 index 00000000000..af7632420e8 --- /dev/null +++ b/src/plugins/madde/maemoqemumanager.cpp @@ -0,0 +1,628 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoqemumanager.h" + +#include "maemoglobal.h" +#include "maemoqemuruntimeparser.h" +#include "maemosettingspages.h" +#include "qt4maemotarget.h" +#include "maemoqtversion.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { + +MaemoQemuManager *MaemoQemuManager::m_instance = 0; + +const QSize iconSize = QSize(24, 20); + +MaemoQemuManager::MaemoQemuManager(QObject *parent) + : QObject(parent) + , m_qemuAction(0) + , m_qemuProcess(new QProcess(this)) + , m_runningQtId(INT_MIN) + , m_userTerminated(false) + , m_runtimeRootWatcher(0) + , m_runtimeFolderWatcher(0) +{ + m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-run.png", iconSize); + m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-stop.png", iconSize, + QIcon::Normal, QIcon::On); + + m_qemuAction = new QAction("MeeGo Emulator", this); + m_qemuAction->setIcon(m_qemuStarterIcon.pixmap(iconSize)); + m_qemuAction->setToolTip(tr("Start MeeGo Emulator")); + connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime())); + + Core::ICore *core = Core::ICore::instance(); + Core::ActionManager *actionManager = core->actionManager(); + Core::Command *qemuCommand = actionManager->registerAction(m_qemuAction, + "MaemoEmulator", Core::Context(Core::Constants::C_GLOBAL)); + qemuCommand->setAttribute(Core::Command::CA_UpdateText); + qemuCommand->setAttribute(Core::Command::CA_UpdateIcon); + + Core::ModeManager::instance()->addAction(qemuCommand->action(), 1); + m_qemuAction->setEnabled(false); + m_qemuAction->setVisible(false); + + // listen to qt version changes to update the start button + connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList)), + this, SLOT(qtVersionsChanged(QList))); + + // listen to project add, remove and startup changes to udate start button + SessionManager *session = ProjectExplorerPlugin::instance()->session(); + connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)), this, + SLOT(projectAdded(ProjectExplorer::Project*))); + connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, + SLOT(projectRemoved(ProjectExplorer::Project*))); + connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), + this, SLOT(projectChanged(ProjectExplorer::Project*))); + + connect(m_qemuProcess, SIGNAL(error(QProcess::ProcessError)), this, + SLOT(qemuProcessError(QProcess::ProcessError))); + connect(m_qemuProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, + SLOT(qemuProcessFinished())); + connect(m_qemuProcess, SIGNAL(readyReadStandardOutput()), this, + SLOT(qemuOutput())); + connect(m_qemuProcess, SIGNAL(readyReadStandardError()), this, + SLOT(qemuOutput())); + connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)), + this, SLOT(qemuStatusChanged(QemuStatus, QString))); +} + +Utils::FileSystemWatcher *MaemoQemuManager::runtimeRootWatcher() +{ + if (!m_runtimeRootWatcher) { + m_runtimeRootWatcher = new Utils::FileSystemWatcher(this); + m_runtimeRootWatcher->setObjectName(QLatin1String("MaemoQemuRuntimeRootWatcher")); + connect(m_runtimeRootWatcher, SIGNAL(directoryChanged(QString)), this, + SLOT(runtimeRootChanged(QString))); + } + return m_runtimeRootWatcher; +} + +Utils::FileSystemWatcher *MaemoQemuManager::runtimeFolderWatcher() +{ + if (!m_runtimeFolderWatcher) { + m_runtimeFolderWatcher = new Utils::FileSystemWatcher(this); + m_runtimeFolderWatcher->setObjectName(QLatin1String("MaemoQemuRuntimeFolderWatcher")); + connect(m_runtimeFolderWatcher, SIGNAL(directoryChanged(QString)), this, + SLOT(runtimeFolderChanged(QString))); + } + return m_runtimeFolderWatcher; +} + +MaemoQemuManager::~MaemoQemuManager() +{ + terminateRuntime(); + m_instance = 0; +} + +MaemoQemuManager &MaemoQemuManager::instance(QObject *parent) +{ + if (m_instance == 0) + m_instance = new MaemoQemuManager(parent); + return *m_instance; +} + +bool MaemoQemuManager::runtimeForQtVersion(int uniqueId, MaemoQemuRuntime *rt) const +{ + *rt = m_runtimes.value(uniqueId, MaemoQemuRuntime()); + return rt->isValid(); +} + +bool MaemoQemuManager::qemuIsRunning() const +{ + return m_runningQtId != INT_MIN; +} + +void MaemoQemuManager::qtVersionsChanged(const QList &uniqueIds) +{ + QtSupport::QtVersionManager *manager = QtSupport::QtVersionManager::instance(); + foreach (int uniqueId, uniqueIds) { + if (manager->isValidId(uniqueId)) { + MaemoQtVersion *version = dynamic_cast(manager->version(uniqueId)); + + if (version) { + MaemoQemuRuntime runtime + = MaemoQemuRuntimeParser::parseRuntime(version); + if (runtime.isValid()) { + m_runtimes.insert(uniqueId, runtime); + if (!runtimeRootWatcher()->watchesDirectory(runtime.m_watchPath)) + runtimeRootWatcher()->addDirectory(runtime.m_watchPath, + Utils::FileSystemWatcher::WatchAllChanges); + } else { + m_runtimes.remove(uniqueId); + } + } + } else { + // this qt version has been removed from the settings + m_runtimes.remove(uniqueId); + if (uniqueId == m_runningQtId) { + terminateRuntime(); + emit qemuProcessStatus(QemuUserReason, tr("Qemu has been shut " + "down, because you removed the corresponding Qt version.")); + } + } + } + + showOrHideQemuButton(); +} + +void MaemoQemuManager::projectAdded(ProjectExplorer::Project *project) +{ + // handle all target related changes, add, remove, etc... + connect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this, + SLOT(targetAdded(ProjectExplorer::Target*))); + connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this, + SLOT(targetRemoved(ProjectExplorer::Target*))); + connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), + this, SLOT(targetChanged(ProjectExplorer::Target*))); + + foreach (Target *target, project->targets()) + targetAdded(target); +} + +void MaemoQemuManager::projectRemoved(ProjectExplorer::Project *project) +{ + disconnect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this, + SLOT(targetAdded(ProjectExplorer::Target*))); + disconnect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this, + SLOT(targetRemoved(ProjectExplorer::Target*))); + disconnect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), + this, SLOT(targetChanged(ProjectExplorer::Target*))); + + foreach (Target *target, project->targets()) + targetRemoved(target); + showOrHideQemuButton(); +} + +void MaemoQemuManager::projectChanged(ProjectExplorer::Project *project) +{ + if (project) { + toggleStarterButton(project->activeTarget()); + deviceConfigurationChanged(project->activeTarget()); + } +} + +void MaemoQemuManager::targetAdded(ProjectExplorer::Target *target) +{ + if (!target || !MaemoGlobal::isMaemoTargetId(target->id())) + return; + + // handle all run configuration changes, add, remove, etc... + connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)), + this, SLOT(runConfigurationAdded(ProjectExplorer::RunConfiguration*))); + connect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)), + this, SLOT(runConfigurationRemoved(ProjectExplorer::RunConfiguration*))); + connect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), + this, SLOT(runConfigurationChanged(ProjectExplorer::RunConfiguration*))); + + // handle all build configuration changes, add, remove, etc... + connect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)), + this, SLOT(buildConfigurationAdded(ProjectExplorer::BuildConfiguration*))); + connect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)), + this, SLOT(buildConfigurationRemoved(ProjectExplorer::BuildConfiguration*))); + connect(target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), + this, SLOT(buildConfigurationChanged(ProjectExplorer::BuildConfiguration*))); + + // handle the qt version changes the build configuration uses + connect(target, SIGNAL(environmentChanged()), this, SLOT(environmentChanged())); + + foreach (RunConfiguration *rc, target->runConfigurations()) + toggleDeviceConnections(qobject_cast (rc), true); + toggleStarterButton(target); +} + +void MaemoQemuManager::targetRemoved(ProjectExplorer::Target *target) +{ + if (!target || !MaemoGlobal::isMaemoTargetId(target->id())) + return; + + disconnect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)), + this, SLOT(runConfigurationAdded(ProjectExplorer::RunConfiguration*))); + disconnect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)), + this, SLOT(runConfigurationRemoved(ProjectExplorer::RunConfiguration*))); + disconnect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), + this, SLOT(runConfigurationChanged(ProjectExplorer::RunConfiguration*))); + + disconnect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)), + this, SLOT(buildConfigurationAdded(ProjectExplorer::BuildConfiguration*))); + disconnect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)), + this, SLOT(buildConfigurationRemoved(ProjectExplorer::BuildConfiguration*))); + disconnect(target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), + this, SLOT(buildConfigurationChanged(ProjectExplorer::BuildConfiguration*))); + + disconnect(target, SIGNAL(environmentChanged()), this, SLOT(environmentChanged())); + + foreach (RunConfiguration *rc, target->runConfigurations()) + toggleDeviceConnections(qobject_cast (rc), false); + showOrHideQemuButton(); +} + +void MaemoQemuManager::targetChanged(ProjectExplorer::Target *target) +{ + if (target) { + toggleStarterButton(target); + deviceConfigurationChanged(target); + } +} + +void MaemoQemuManager::runConfigurationAdded(ProjectExplorer::RunConfiguration *rc) +{ + if (!rc || !MaemoGlobal::isMaemoTargetId(rc->target()->id())) + return; + toggleDeviceConnections(qobject_cast (rc), true); +} + +void MaemoQemuManager::runConfigurationRemoved(ProjectExplorer::RunConfiguration *rc) +{ + if (!rc || !MaemoGlobal::isMaemoTargetId(rc->target()->id())) + return; + toggleDeviceConnections(qobject_cast (rc), false); +} + +void MaemoQemuManager::runConfigurationChanged(ProjectExplorer::RunConfiguration *rc) +{ + if (rc) + m_qemuAction->setEnabled(targetUsesMatchingRuntimeConfig(rc->target())); +} + +void MaemoQemuManager::buildConfigurationAdded(ProjectExplorer::BuildConfiguration *bc) +{ + if (!bc || !MaemoGlobal::isMaemoTargetId(bc->target()->id())) + return; + + connect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentChanged())); +} + +void MaemoQemuManager::buildConfigurationRemoved(ProjectExplorer::BuildConfiguration *bc) +{ + if (!bc || !MaemoGlobal::isMaemoTargetId(bc->target()->id())) + return; + + disconnect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentChanged())); +} + +void MaemoQemuManager::buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc) +{ + if (bc) + toggleStarterButton(bc->target()); +} + +void MaemoQemuManager::environmentChanged() +{ + // likely to happen when the qt version changes the build config is using + if (ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance()) { + if (Project *project = explorer->session()->startupProject()) + toggleStarterButton(project->activeTarget()); + } +} + +void MaemoQemuManager::deviceConfigurationChanged(ProjectExplorer::Target *target) +{ + m_qemuAction->setEnabled(targetUsesMatchingRuntimeConfig(target)); +} + +void MaemoQemuManager::startRuntime() +{ + m_userTerminated = false; + Project *p = ProjectExplorerPlugin::instance()->session()->startupProject(); + if (!p) + return; + QtSupport::BaseQtVersion *version; + if (!targetUsesMatchingRuntimeConfig(p->activeTarget(), &version)) { + qWarning("Strange: Qemu button was enabled, but target does not match."); + return; + } + + m_runningQtId = version->uniqueId(); + const MaemoQemuRuntime rt = m_runtimes.value(version->uniqueId()); + m_qemuProcess->setProcessEnvironment(rt.environment()); + m_qemuProcess->setWorkingDirectory(rt.m_root); + m_qemuProcess->start(rt.m_bin % QLatin1Char(' ') % rt.m_args); + if (!m_qemuProcess->waitForStarted()) + return; + + emit qemuProcessStatus(QemuStarting); + connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(terminateRuntime())); + disconnect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime())); +} + +void MaemoQemuManager::terminateRuntime() +{ + m_userTerminated = true; + + if (m_qemuProcess->state() != QProcess::NotRunning) { + m_qemuProcess->terminate(); + m_qemuProcess->kill(); + } + + connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime())); + disconnect(m_qemuAction, SIGNAL(triggered()), this, SLOT(terminateRuntime())); +} + +void MaemoQemuManager::qemuProcessFinished() +{ + m_runningQtId = INT_MIN; + QemuStatus status = QemuFinished; + QString error; + + if (!m_userTerminated) { + if (m_qemuProcess->exitStatus() == QProcess::CrashExit) { + status = QemuCrashed; + error = m_qemuProcess->errorString(); + } else if (m_qemuProcess->exitCode() != 0) { + error = tr("Qemu finished with error: Exit code was %1.") + .arg(m_qemuProcess->exitCode()); + } + } + + m_userTerminated = false; + emit qemuProcessStatus(status, error); +} + +void MaemoQemuManager::qemuProcessError(QProcess::ProcessError error) +{ + if (error == QProcess::FailedToStart) + emit qemuProcessStatus(QemuFailedToStart, m_qemuProcess->errorString()); +} + +void MaemoQemuManager::qemuStatusChanged(QemuStatus status, const QString &error) +{ + bool running = false; + switch (status) { + case QemuStarting: + running = true; + break; + case QemuFailedToStart: + QMessageBox::warning(0, tr("Qemu error"), + tr("Qemu failed to start: %1")); + break; + case QemuCrashed: + MaemoQemuSettingsPage::showQemuCrashDialog(); + break; + case QemuFinished: + case QemuUserReason: + if (!error.isEmpty()) + QMessageBox::warning(0, tr("Qemu error"), error); + break; + default: + Q_ASSERT(!"Missing handling of Qemu status"); + } + + updateStarterIcon(running); +} + +void MaemoQemuManager::qemuOutput() +{ + qDebug("%s", m_qemuProcess->readAllStandardOutput().data()); + qDebug("%s", m_qemuProcess->readAllStandardError().data()); +} + +void MaemoQemuManager::runtimeRootChanged(const QString &directory) +{ + QList uniqueIds; + QMap::const_iterator it; + for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) { + if (QDir(it.value().m_watchPath) == QDir(directory)) + uniqueIds.append(it.key()); + } + + foreach (int uniqueId, uniqueIds) { + MaemoQemuRuntime runtime = m_runtimes.value(uniqueId, MaemoQemuRuntime()); + if (runtime.isValid()) { + if (QFile::exists(runtime.m_root)) { + // nothing changed, so we can remove it + uniqueIds.removeAll(uniqueId); + } + } else { + if (QFile::exists(runtime.m_root)) { + if (!QFile::exists(runtime.m_root + QLatin1String("/information"))) { + // install might be still in progress + uniqueIds.removeAll(uniqueId); + runtimeFolderWatcher()->addDirectory(runtime.m_root, + Utils::FileSystemWatcher::WatchAllChanges); + } + } + } + } + notify(uniqueIds); +} + +void MaemoQemuManager::runtimeFolderChanged(const QString &directory) +{ + if (QFile::exists(directory + QLatin1String("/information"))) { + QList uniqueIds; + QMap::const_iterator it; + for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) { + if (QDir(it.value().m_root) == QDir(directory)) + uniqueIds.append(it.key()); + } + notify(uniqueIds); + if (m_runtimeFolderWatcher) + m_runtimeFolderWatcher->removeDirectory(directory); + } +} + +// -- private + +void MaemoQemuManager::updateStarterIcon(bool running) +{ + QIcon::State state; + QString toolTip; + if (running) { + state = QIcon::On; + toolTip = tr("Stop MeeGo Emulator"); + } else { + state = QIcon::Off; + toolTip = tr("Start MeeGo Emulator"); + } + + m_qemuAction->setToolTip(toolTip); + m_qemuAction->setIcon(m_qemuStarterIcon.pixmap(iconSize, QIcon::Normal, + state)); +} + +void MaemoQemuManager::toggleStarterButton(Target *target) +{ + int uniqueId = -1; + if (target) { + if (AbstractQt4MaemoTarget *qt4Target = qobject_cast(target)) { + if (Qt4BuildConfiguration *bc = qt4Target->activeQt4BuildConfiguration()) { + if (QtSupport::BaseQtVersion *version = bc->qtVersion()) + uniqueId = version->uniqueId(); + } + } + } + + if (uniqueId >= 0 && (m_runtimes.isEmpty() || !m_runtimes.contains(uniqueId))) + qtVersionsChanged(QList() << uniqueId); + + bool isRunning = m_qemuProcess->state() != QProcess::NotRunning; + if (m_runningQtId == uniqueId) + isRunning = false; + + const Project * const p + = ProjectExplorerPlugin::instance()->session()->startupProject(); + const bool qemuButtonEnabled + = p && p->activeTarget() && MaemoGlobal::isMaemoTargetId(p->activeTarget()->id()) + && m_runtimes.value(uniqueId, MaemoQemuRuntime()).isValid() + && targetUsesMatchingRuntimeConfig(target) && !isRunning; + m_qemuAction->setEnabled(qemuButtonEnabled); + showOrHideQemuButton(); +} + +bool MaemoQemuManager::sessionHasMaemoTarget() const +{ + ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance(); + const QList &projects = explorer->session()->projects(); + foreach (const Project *p, projects) { + foreach (const Target * const target, p->targets()) { + if (MaemoGlobal::isMaemoTargetId(target->id())) + return true; + } + } + return false; +} + +bool MaemoQemuManager::targetUsesMatchingRuntimeConfig(Target *target, + QtSupport::BaseQtVersion **qtVersion) +{ + if (!target) + return false; + if (target != target->project()->activeTarget()) + return false; + + RemoteLinuxRunConfiguration *mrc = + qobject_cast (target->activeRunConfiguration()); + if (!mrc) + return false; + Qt4BuildConfiguration *bc + = qobject_cast(target->activeBuildConfiguration()); + if (!bc) + return false; + QtSupport::BaseQtVersion *version = bc->qtVersion(); + if (!version || !m_runtimes.value(version->uniqueId(), MaemoQemuRuntime()).isValid()) + return false; + + if (qtVersion) + *qtVersion = version; + const LinuxDeviceConfiguration::ConstPtr &config = mrc->deviceConfig(); + return config && config->deviceType() == LinuxDeviceConfiguration::Emulator; +} + +void MaemoQemuManager::notify(const QList uniqueIds) +{ + qtVersionsChanged(uniqueIds); + environmentChanged(); // to toggle the start button +} + +void MaemoQemuManager::toggleDeviceConnections(RemoteLinuxRunConfiguration *mrc, + bool _connect) +{ + if (!mrc) + return; + + if (_connect) { // handle device configuration changes + connect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)), + this, SLOT(deviceConfigurationChanged(ProjectExplorer::Target*))); + } else { + disconnect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)), + this, SLOT(deviceConfigurationChanged(ProjectExplorer::Target*))); + } +} + +void MaemoQemuManager::showOrHideQemuButton() +{ + const bool showButton = !m_runtimes.isEmpty() && sessionHasMaemoTarget(); + if (!showButton) + terminateRuntime(); + m_qemuAction->setVisible(showButton); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoqemumanager.h b/src/plugins/madde/maemoqemumanager.h new file mode 100644 index 00000000000..2ce954247fd --- /dev/null +++ b/src/plugins/madde/maemoqemumanager.h @@ -0,0 +1,149 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef QEMURUNTIMEMANAGER_H +#define QEMURUNTIMEMANAGER_H + +#include "maemoconstants.h" +#include "maemoqemuruntime.h" + +#include +#include +#include + +#include + +QT_FORWARD_DECLARE_CLASS(QAction) +QT_FORWARD_DECLARE_CLASS(QStringList) + +namespace Utils { +class FileSystemWatcher; +} + +namespace ProjectExplorer { +class BuildConfiguration; +class Project; +class RunConfiguration; +class Target; +} + +namespace QtSupport { +class BaseQtVersion; +} + +namespace RemoteLinux { +class RemoteLinuxRunConfiguration; +} + +namespace Madde { +namespace Internal { + +class MaemoQemuManager : public QObject +{ + Q_OBJECT + +public: + static MaemoQemuManager& instance(QObject *parent = 0); + + bool runtimeForQtVersion(int uniqueId, MaemoQemuRuntime *rt) const; + bool qemuIsRunning() const; + Q_SLOT void startRuntime(); + +signals: + void qemuProcessStatus(QemuStatus, const QString &error = QString()); + +private slots: + void qtVersionsChanged(const QList &uniqueIds); + + void projectAdded(ProjectExplorer::Project *project); + void projectRemoved(ProjectExplorer::Project *project); + void projectChanged(ProjectExplorer::Project *project); + + void targetAdded(ProjectExplorer::Target *target); + void targetRemoved(ProjectExplorer::Target *target); + void targetChanged(ProjectExplorer::Target *target); + + void runConfigurationAdded(ProjectExplorer::RunConfiguration *rc); + void runConfigurationRemoved(ProjectExplorer::RunConfiguration *rc); + void runConfigurationChanged(ProjectExplorer::RunConfiguration *rc); + + void buildConfigurationAdded(ProjectExplorer::BuildConfiguration *bc); + void buildConfigurationRemoved(ProjectExplorer::BuildConfiguration *bc); + void buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc); + + void environmentChanged(); // needed to check for qt version + void deviceConfigurationChanged(ProjectExplorer::Target *target); + + void terminateRuntime(); + + void qemuProcessFinished(); + void qemuProcessError(QProcess::ProcessError error); + void qemuStatusChanged(QemuStatus status, const QString &error); + void qemuOutput(); + + void runtimeRootChanged(const QString &directory); + void runtimeFolderChanged(const QString &directory); + +private: + MaemoQemuManager(QObject *parent); + ~MaemoQemuManager(); + + bool sessionHasMaemoTarget() const; + + void updateStarterIcon(bool running); + void toggleStarterButton(ProjectExplorer::Target *target); + bool targetUsesMatchingRuntimeConfig(ProjectExplorer::Target *target, + QtSupport::BaseQtVersion **qtVersion = 0); + + void notify(const QList uniqueIds); + void toggleDeviceConnections(RemoteLinux::RemoteLinuxRunConfiguration *mrc, bool connect); + void showOrHideQemuButton(); + +private: + QAction *m_qemuAction; + QProcess *m_qemuProcess; + Utils::FileSystemWatcher *runtimeRootWatcher(); + Utils::FileSystemWatcher *runtimeFolderWatcher(); + + int m_runningQtId; + bool m_userTerminated; + QIcon m_qemuStarterIcon; + QMap m_runtimes; + static MaemoQemuManager *m_instance; + Utils::FileSystemWatcher *m_runtimeRootWatcher; + Utils::FileSystemWatcher *m_runtimeFolderWatcher; +}; + +} // namespace Internal +} // namespace Madde + +#endif // QEMURUNTIMEMANAGER_H diff --git a/src/plugins/madde/maemoqemuruntime.h b/src/plugins/madde/maemoqemuruntime.h new file mode 100644 index 00000000000..572ee4e7a9c --- /dev/null +++ b/src/plugins/madde/maemoqemuruntime.h @@ -0,0 +1,91 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOQEMURUNTIME_H +#define MAEMOQEMURUNTIME_H + +#include "maemoqemusettings.h" + +#include + +#include +#include +#include +#include +#include + +namespace Madde { +namespace Internal { + +enum QemuStatus { + QemuStarting, + QemuFailedToStart, + QemuFinished, + QemuCrashed, + QemuUserReason +}; + +struct MaemoQemuRuntime +{ + typedef QPair Variable; + + MaemoQemuRuntime() {} + MaemoQemuRuntime(const QString &root) : m_root(root) {} + bool isValid() const { + return !m_bin.isEmpty(); + } + QProcessEnvironment environment() const { + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + foreach (const Variable &var, m_normalVars) + env.insert(var.first, var.second); + QHash::ConstIterator it + = m_openGlBackendVarValues.find(MaemoQemuSettings::openGlMode()); + if (it != m_openGlBackendVarValues.constEnd()) + env.insert(m_openGlBackendVarName, it.value()); + return env; + } + + QString m_name; + QString m_bin; + QString m_root; + QString m_args; + QString m_sshPort; + QString m_watchPath; + RemoteLinux::PortList m_freePorts; + QList m_normalVars; + QString m_openGlBackendVarName; + QHash m_openGlBackendVarValues; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOQEMURUNTIME_H diff --git a/src/plugins/madde/maemoqemuruntimeparser.cpp b/src/plugins/madde/maemoqemuruntimeparser.cpp new file mode 100644 index 00000000000..59e274144ab --- /dev/null +++ b/src/plugins/madde/maemoqemuruntimeparser.cpp @@ -0,0 +1,433 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemoqemuruntimeparser.h" + +#include "maemoglobal.h" +#include "maemoqemusettings.h" + +#include +#include + +#include +#include +#include +#include + +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { + +class MaemoQemuRuntimeParserV1 : public MaemoQemuRuntimeParser +{ +public: + MaemoQemuRuntimeParserV1(const QString &madInfoOutput, + const QString &targetName, const QString &maddeRoot); + MaemoQemuRuntime parseRuntime(); + +private: + void fillRuntimeInformation(MaemoQemuRuntime *runtime) const; + void setEnvironment(MaemoQemuRuntime *runTime, const QString &envSpec) const; +}; + +class MaemoQemuRuntimeParserV2 : public MaemoQemuRuntimeParser +{ +public: + MaemoQemuRuntimeParserV2(const QString &madInfoOutput, + const QString &targetName, const QString &maddeRoot); + MaemoQemuRuntime parseRuntime(); + +private: + struct Port { + Port() : port(-1), ssh(false) {} + int port; + bool ssh; + }; + + void handleTargetTag(QString &runtimeName); + MaemoQemuRuntime handleRuntimeTag(); + void handleEnvironmentTag(MaemoQemuRuntime &runtime); + void handleVariableTag(MaemoQemuRuntime &runtime); + QList handleTcpPortListTag(); + Port handlePortTag(); + MaemoQemuSettings::OpenGlMode openGlTagToEnum(const QString &tag) const; +}; + +MaemoQemuRuntimeParser::MaemoQemuRuntimeParser(const QString &madInfoOutput, + const QString &targetName, const QString &maddeRoot) + : m_targetName(targetName), + m_maddeRoot(maddeRoot), + m_madInfoReader(madInfoOutput) +{ +} + +MaemoQemuRuntime MaemoQemuRuntimeParser::parseRuntime(const QtSupport::BaseQtVersion *qtVersion) +{ + MaemoQemuRuntime runtime; + const QString maddeRootPath = MaemoGlobal::maddeRoot(qtVersion->qmakeCommand()); + QProcess madProc; + if (!MaemoGlobal::callMad(madProc, QStringList() << QLatin1String("info"), qtVersion->qmakeCommand(), false)) + return runtime; + if (!madProc.waitForStarted() || !madProc.waitForFinished()) + return runtime; + const QByteArray &madInfoOutput = madProc.readAllStandardOutput(); + const QString &targetName = MaemoGlobal::targetName(qtVersion->qmakeCommand()); + runtime = MaemoQemuRuntimeParserV2(madInfoOutput, targetName, maddeRootPath) + .parseRuntime(); + if (!runtime.m_name.isEmpty()) { + runtime.m_root = maddeRootPath + QLatin1String("/runtimes/") + + runtime.m_name; + } else { + runtime = MaemoQemuRuntimeParserV1(madInfoOutput, targetName, + maddeRootPath).parseRuntime(); + } + runtime.m_watchPath = runtime.m_root + .left(runtime.m_root.lastIndexOf(QLatin1Char('/'))); + + return runtime; +} + +MaemoQemuRuntimeParserV1::MaemoQemuRuntimeParserV1(const QString &madInfoOutput, + const QString &targetName, const QString &maddeRoot) + : MaemoQemuRuntimeParser(madInfoOutput, targetName, maddeRoot) +{ +} + +MaemoQemuRuntime MaemoQemuRuntimeParserV1::parseRuntime() +{ + QStringList installedRuntimes; + QString targetRuntime; + while (!m_madInfoReader.atEnd() && !installedRuntimes.contains(targetRuntime)) { + if (m_madInfoReader.readNext() == QXmlStreamReader::StartElement) { + if (targetRuntime.isEmpty() + && m_madInfoReader.name() == QLatin1String("target")) { + const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); + if (attrs.value(QLatin1String("target_id")) == m_targetName) + targetRuntime = attrs.value("runtime_id").toString(); + } else if (m_madInfoReader.name() == QLatin1String("runtime")) { + const QXmlStreamAttributes attrs = m_madInfoReader.attributes(); + while (!m_madInfoReader.atEnd()) { + if (m_madInfoReader.readNext() == QXmlStreamReader::EndElement + && m_madInfoReader.name() == QLatin1String("runtime")) + break; + if (m_madInfoReader.tokenType() == QXmlStreamReader::StartElement + && m_madInfoReader.name() == QLatin1String("installed")) { + if (m_madInfoReader.readNext() == QXmlStreamReader::Characters + && m_madInfoReader.text() == QLatin1String("true")) { + if (attrs.hasAttribute(QLatin1String("runtime_id"))) + installedRuntimes << attrs.value(QLatin1String("runtime_id")).toString(); + else if (attrs.hasAttribute(QLatin1String("id"))) { + // older MADDE seems to use only id + installedRuntimes << attrs.value(QLatin1String("id")).toString(); + } + } + break; + } + } + } + } + } + + MaemoQemuRuntime runtime; + if (installedRuntimes.contains(targetRuntime)) { + runtime.m_name = targetRuntime; + runtime.m_root = m_maddeRoot + QLatin1String("/runtimes/") + + targetRuntime; + fillRuntimeInformation(&runtime); + } + return runtime; + +} + +void MaemoQemuRuntimeParserV1::fillRuntimeInformation(MaemoQemuRuntime *runtime) const +{ + const QStringList files = QDir(runtime->m_root).entryList(QDir::Files + | QDir::NoSymLinks | QDir::NoDotAndDotDot); + + const QLatin1String infoFile("information"); + if (files.contains(infoFile)) { + QFile file(runtime->m_root + QLatin1Char('/') + infoFile); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QMap map; + QTextStream stream(&file); + while (!stream.atEnd()) { + const QString &line = stream.readLine().trimmed(); + const int index = line.indexOf(QLatin1Char('=')); + map.insert(line.mid(0, index).remove(QLatin1Char('\'')), + line.mid(index + 1).remove(QLatin1Char('\''))); + } + + runtime->m_bin = map.value(QLatin1String("qemu")); + runtime->m_args = map.value(QLatin1String("qemu_args")); + setEnvironment(runtime, map.value(QLatin1String("libpath"))); + runtime->m_sshPort = map.value(QLatin1String("sshport")); + runtime->m_freePorts = PortList(); + int i = 2; + while (true) { + const QString port = map.value(QLatin1String("redirport") + + QString::number(i++)); + if (port.isEmpty()) + break; + runtime->m_freePorts.addPort(port.toInt()); + } + + // This is complex because of extreme MADDE weirdness. + const QString root = m_maddeRoot + QLatin1Char('/'); + const bool pathIsRelative = QFileInfo(runtime->m_bin).isRelative(); + runtime->m_bin = + #ifdef Q_OS_WIN + root + (pathIsRelative + ? QLatin1String("madlib/") + runtime->m_bin // Fremantle. + : runtime->m_bin) // Harmattan. + + QLatin1String(".exe"); + #else + pathIsRelative + ? root + QLatin1String("madlib/") + runtime->m_bin // Fremantle. + : runtime->m_bin; // Harmattan. + #endif + } + } +} + +void MaemoQemuRuntimeParserV1::setEnvironment(MaemoQemuRuntime *runTime, + const QString &envSpec) const +{ + QString remainingEnvSpec = envSpec; + QString currentKey; + while (true) { + const int nextEqualsSignPos + = remainingEnvSpec.indexOf(QLatin1Char('=')); + if (nextEqualsSignPos == -1) { + if (!currentKey.isEmpty()) + runTime->m_normalVars << MaemoQemuRuntime::Variable(currentKey, + remainingEnvSpec); + break; + } + const int keyStartPos + = remainingEnvSpec.lastIndexOf(QRegExp(QLatin1String("\\s")), + nextEqualsSignPos) + 1; + if (!currentKey.isEmpty()) { + const int valueEndPos + = remainingEnvSpec.lastIndexOf(QRegExp(QLatin1String("\\S")), + qMax(0, keyStartPos - 1)) + 1; + runTime->m_normalVars << MaemoQemuRuntime::Variable(currentKey, + remainingEnvSpec.left(valueEndPos)); + } + currentKey = remainingEnvSpec.mid(keyStartPos, + nextEqualsSignPos - keyStartPos); + remainingEnvSpec.remove(0, nextEqualsSignPos + 1); + } +} + + +MaemoQemuRuntimeParserV2::MaemoQemuRuntimeParserV2(const QString &madInfoOutput, + const QString &targetName, const QString &maddeRoot) + : MaemoQemuRuntimeParser(madInfoOutput, targetName, maddeRoot) +{ +} + +MaemoQemuRuntime MaemoQemuRuntimeParserV2::parseRuntime() +{ + QString runtimeName; + QList runtimes; + while (m_madInfoReader.readNextStartElement()) { + if (m_madInfoReader.name() == QLatin1String("madde")) { + while (m_madInfoReader.readNextStartElement()) { + if (m_madInfoReader.name() == QLatin1String("targets")) { + while (m_madInfoReader.readNextStartElement()) + handleTargetTag(runtimeName); + } else if (m_madInfoReader.name() == QLatin1String("runtimes")) { + while (m_madInfoReader.readNextStartElement()) { + const MaemoQemuRuntime &rt = handleRuntimeTag(); + if (!rt.m_name.isEmpty() && !rt.m_bin.isEmpty() + && !rt.m_args.isEmpty()) { + runtimes << rt; + } + } + } else { + m_madInfoReader.skipCurrentElement(); + } + } + } + } + foreach (const MaemoQemuRuntime &rt, runtimes) { + if (rt.m_name == runtimeName) + return rt; + } + return MaemoQemuRuntime(); +} + +void MaemoQemuRuntimeParserV2::handleTargetTag(QString &runtimeName) +{ + const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); + if (m_madInfoReader.name() == QLatin1String("target") && runtimeName.isEmpty() + && attrs.value(QLatin1String("name")) == m_targetName + && attrs.value(QLatin1String("installed")) == QLatin1String("true")) { + while (m_madInfoReader.readNextStartElement()) { + if (m_madInfoReader.name() == QLatin1String("runtime")) + runtimeName = m_madInfoReader.readElementText(); + else + m_madInfoReader.skipCurrentElement(); + } + } else { + m_madInfoReader.skipCurrentElement(); + } +} + +MaemoQemuRuntime MaemoQemuRuntimeParserV2::handleRuntimeTag() +{ + MaemoQemuRuntime runtime; + const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); + if (m_madInfoReader.name() != QLatin1String("runtime") + || attrs.value(QLatin1String("installed")) != QLatin1String("true")) { + m_madInfoReader.skipCurrentElement(); + return runtime; + } + runtime.m_name = attrs.value(QLatin1String("name")).toString(); + while (m_madInfoReader.readNextStartElement()) { + if (m_madInfoReader.name() == QLatin1String("exec-path")) { + runtime.m_bin = m_madInfoReader.readElementText(); + } else if (m_madInfoReader.name() == QLatin1String("args")) { + runtime.m_args = m_madInfoReader.readElementText(); + } else if (m_madInfoReader.name() == QLatin1String("environment")) { + handleEnvironmentTag(runtime); + } else if (m_madInfoReader.name() == QLatin1String("tcpportmap")) { + const QList &ports = handleTcpPortListTag(); + foreach (const Port &port, ports) { + if (port.ssh) + runtime.m_sshPort = QString::number(port.port); + else + runtime.m_freePorts.addPort(port.port); + } + } else { + m_madInfoReader.skipCurrentElement(); + } + } + return runtime; +} + +void MaemoQemuRuntimeParserV2::handleEnvironmentTag(MaemoQemuRuntime &runtime) +{ + while (m_madInfoReader.readNextStartElement()) + handleVariableTag(runtime); + +#ifdef Q_OS_WIN + const QString root = QDir::toNativeSeparators(m_maddeRoot) + + QLatin1Char('/'); + const QLatin1Char colon(';'); + const QLatin1String key("PATH"); + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + runtime.m_normalVars << MaemoQemuRuntime::Variable(key, + root + QLatin1String("bin") + colon + env.value(key)); + runtime.m_normalVars << MaemoQemuRuntime::Variable(key, + root + QLatin1String("madlib") + colon + env.value(key)); +#endif +} + +void MaemoQemuRuntimeParserV2::handleVariableTag(MaemoQemuRuntime &runtime) +{ + if (m_madInfoReader.name() != QLatin1String("variable")) { + m_madInfoReader.skipCurrentElement(); + return; + } + + const bool isGlBackend = m_madInfoReader.attributes().value(QLatin1String("purpose")) + == QLatin1String("glbackend"); + QString varName; + QString varValue; + while (m_madInfoReader.readNextStartElement()) { + const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); + if (m_madInfoReader.name() == QLatin1String("name")) { + varName = m_madInfoReader.readElementText(); + } else if (m_madInfoReader.name() == QLatin1String("value") + && attrs.value(QLatin1String("set")) != QLatin1String("false")) { + varValue = m_madInfoReader.readElementText(); + if (isGlBackend) { + MaemoQemuSettings::OpenGlMode openGlMode + = openGlTagToEnum(attrs.value(QLatin1String("option")).toString()); + runtime.m_openGlBackendVarValues.insert(openGlMode, varValue); + } + } else { + m_madInfoReader.skipCurrentElement(); + } + } + + if (varName.isEmpty()) + return; + if (isGlBackend) { + runtime.m_openGlBackendVarName = varName; + } else { + runtime.m_normalVars << MaemoQemuRuntime::Variable(varName, varValue); + } +} + +QList MaemoQemuRuntimeParserV2::handleTcpPortListTag() +{ + QList ports; + while (m_madInfoReader.readNextStartElement()) { + const Port &port = handlePortTag(); + if (port.port != -1) + ports << port; + } + return ports; +} + +MaemoQemuRuntimeParserV2::Port MaemoQemuRuntimeParserV2::handlePortTag() +{ + Port port; + if (m_madInfoReader.name() == QLatin1String("port")) { + const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); + port.ssh = attrs.value(QLatin1String("service")) == QLatin1String("ssh"); + while (m_madInfoReader.readNextStartElement()) { + if (m_madInfoReader.name() == QLatin1String("host")) + port.port = m_madInfoReader.readElementText().toInt(); + else + m_madInfoReader.skipCurrentElement(); + } + } + return port; +} + +MaemoQemuSettings::OpenGlMode MaemoQemuRuntimeParserV2::openGlTagToEnum(const QString &tag) const +{ + if (tag == QLatin1String("hardware-acceleration")) + return MaemoQemuSettings::HardwareAcceleration; + if (tag == QLatin1String("software-rendering")) + return MaemoQemuSettings::SoftwareRendering; + if (tag == QLatin1String("autodetect")) + return MaemoQemuSettings::AutoDetect; + QTC_CHECK(false); + return MaemoQemuSettings::AutoDetect; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoqemuruntimeparser.h b/src/plugins/madde/maemoqemuruntimeparser.h new file mode 100644 index 00000000000..6dd472eea8f --- /dev/null +++ b/src/plugins/madde/maemoqemuruntimeparser.h @@ -0,0 +1,64 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOQEMURUNTIMEPARSER_H +#define MAEMOQEMURUNTIMEPARSER_H + +#include "maemoqemuruntime.h" + +#include +#include + +namespace QtSupport { +class BaseQtVersion; +} + +namespace Madde { +namespace Internal { + +class MaemoQemuRuntimeParser +{ +public: + static MaemoQemuRuntime parseRuntime(const QtSupport::BaseQtVersion *qtVersion); + +protected: + MaemoQemuRuntimeParser(const QString &madInfoOutput, + const QString &targetName, const QString &maddeRoot); + + const QString m_targetName; + const QString m_maddeRoot; + QXmlStreamReader m_madInfoReader; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOQEMURUNTIMEPARSER_H diff --git a/src/plugins/madde/maemoqemusettings.cpp b/src/plugins/madde/maemoqemusettings.cpp new file mode 100644 index 00000000000..e164773bb81 --- /dev/null +++ b/src/plugins/madde/maemoqemusettings.cpp @@ -0,0 +1,71 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoqemusettings.h" + +#include + +#include + +namespace Madde { +namespace Internal { +namespace { +const QString SettingsGroup = QLatin1String("Maemo Qemu Settings"); +const QString OpenGlModeKey = QLatin1String("OpenGl Mode"); +} // anonymous namespace + +MaemoQemuSettings::OpenGlMode MaemoQemuSettings::openGlMode() +{ + if (!m_initialized) { + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(SettingsGroup); + m_openGlMode = static_cast(settings->value(OpenGlModeKey, AutoDetect).toInt()); + settings->endGroup(); + m_initialized = true; + } + return m_openGlMode; +} + +void MaemoQemuSettings::setOpenGlMode(OpenGlMode openGlMode) +{ + Q_ASSERT(m_initialized); + m_openGlMode = openGlMode; + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(SettingsGroup); + settings->setValue(OpenGlModeKey, m_openGlMode); + settings->endGroup(); +} + +bool MaemoQemuSettings::m_initialized = false; +MaemoQemuSettings::OpenGlMode MaemoQemuSettings::m_openGlMode; + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoqemusettings.h b/src/plugins/madde/maemoqemusettings.h new file mode 100644 index 00000000000..35291bb2b59 --- /dev/null +++ b/src/plugins/madde/maemoqemusettings.h @@ -0,0 +1,56 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOQEMUSETTINGS_H +#define MAEMOQEMUSETTINGS_H + +namespace Madde { +namespace Internal { + +class MaemoQemuSettings +{ +public: + enum OpenGlMode { HardwareAcceleration, SoftwareRendering, AutoDetect }; + + static OpenGlMode openGlMode(); + static void setOpenGlMode(OpenGlMode openGlMode); + +private: + MaemoQemuSettings(); + + static bool m_initialized; + static OpenGlMode m_openGlMode; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOQEMUSETTINGS_H diff --git a/src/plugins/madde/maemoqemusettingswidget.cpp b/src/plugins/madde/maemoqemusettingswidget.cpp new file mode 100644 index 00000000000..9acb4e7398d --- /dev/null +++ b/src/plugins/madde/maemoqemusettingswidget.cpp @@ -0,0 +1,86 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoqemusettingswidget.h" +#include "ui_maemoqemusettingswidget.h" + +#include "maemoqemusettings.h" + +namespace Madde { +namespace Internal { + +MaemoQemuSettingsWidget::MaemoQemuSettingsWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::MaemoQemuSettingsWidget) +{ + ui->setupUi(this); + switch (MaemoQemuSettings::openGlMode()) { + case MaemoQemuSettings::HardwareAcceleration: + ui->hardwareAccelerationButton->setChecked(true); + break; + case MaemoQemuSettings::SoftwareRendering: + ui->softwareRenderingButton->setChecked(true); + break; + case MaemoQemuSettings::AutoDetect: + ui->autoDetectButton->setChecked(true); + break; + } +} + +MaemoQemuSettingsWidget::~MaemoQemuSettingsWidget() +{ + delete ui; +} + +QString MaemoQemuSettingsWidget::keywords() const +{ + const QChar space = QLatin1Char(' '); + QString keywords = ui->groupBox->title() + space + + ui->hardwareAccelerationButton->text() + space + + ui->softwareRenderingButton->text() + space + + ui->autoDetectButton->text(); + keywords.remove(QLatin1Char('&')); + return keywords; +} + +void MaemoQemuSettingsWidget::saveSettings() +{ + const MaemoQemuSettings::OpenGlMode openGlMode + = ui->hardwareAccelerationButton->isChecked() + ? MaemoQemuSettings::HardwareAcceleration + : ui->softwareRenderingButton->isChecked() + ? MaemoQemuSettings::SoftwareRendering + : MaemoQemuSettings::AutoDetect; + MaemoQemuSettings::setOpenGlMode(openGlMode); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoqemusettingswidget.h b/src/plugins/madde/maemoqemusettingswidget.h new file mode 100644 index 00000000000..6c434479306 --- /dev/null +++ b/src/plugins/madde/maemoqemusettingswidget.h @@ -0,0 +1,63 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOQEMUSETTINGSWIDGET_H +#define MAEMOQEMUSETTINGSWIDGET_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { + class MaemoQemuSettingsWidget; +} +QT_END_NAMESPACE + +namespace Madde { +namespace Internal { + +class MaemoQemuSettingsWidget : public QWidget +{ + Q_OBJECT + +public: + explicit MaemoQemuSettingsWidget(QWidget *parent = 0); + ~MaemoQemuSettingsWidget(); + void saveSettings(); + QString keywords() const; + +private: + Ui::MaemoQemuSettingsWidget *ui; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOQEMUSETTINGSWIDGET_H diff --git a/src/plugins/madde/maemoqemusettingswidget.ui b/src/plugins/madde/maemoqemusettingswidget.ui new file mode 100644 index 00000000000..f500f946808 --- /dev/null +++ b/src/plugins/madde/maemoqemusettingswidget.ui @@ -0,0 +1,64 @@ + + + MaemoQemuSettingsWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + OpenGL Mode + + + + + + &Hardware acceleration + + + + + + + &Software rendering + + + + + + + &Auto-detect + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/plugins/madde/maemoqtversion.cpp b/src/plugins/madde/maemoqtversion.cpp new file mode 100644 index 00000000000..f7b7a341162 --- /dev/null +++ b/src/plugins/madde/maemoqtversion.cpp @@ -0,0 +1,198 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemoqtversion.h" + +#include "maemoconstants.h" +#include "maemoglobal.h" + +#include +#include + +#include +#include +#include +#include + +using namespace Qt4ProjectManager; + +namespace Madde { +namespace Internal { + +MaemoQtVersion::MaemoQtVersion() : QtSupport::BaseQtVersion() +{ + +} + +MaemoQtVersion::MaemoQtVersion(const QString &path, bool isAutodetected, const QString &autodetectionSource) + : QtSupport::BaseQtVersion(path, isAutodetected, autodetectionSource), + m_osType(MaemoGlobal::osType(path)), + m_isvalidVersion(MaemoGlobal::isValidMaemoQtVersion(path, m_osType)) +{ + +} + +MaemoQtVersion::~MaemoQtVersion() +{ + +} + +void MaemoQtVersion::fromMap(const QVariantMap &map) +{ + QtSupport::BaseQtVersion::fromMap(map); + QString path = qmakeCommand(); + m_osType = MaemoGlobal::osType(path); + m_isvalidVersion = MaemoGlobal::isValidMaemoQtVersion(path, m_osType); +} + +QString MaemoQtVersion::type() const +{ + return QtSupport::Constants::MAEMOQT; +} + +bool MaemoQtVersion::isValid() const +{ + return BaseQtVersion::isValid() && m_isvalidVersion; +} + +MaemoQtVersion *MaemoQtVersion::clone() const +{ + return new MaemoQtVersion(*this); +} + +QString MaemoQtVersion::systemRoot() const +{ + if (m_systemRoot.isNull()) { + QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(qmakeCommand())) + + QLatin1String("/information")); + if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream stream(&file); + while (!stream.atEnd()) { + const QString &line = stream.readLine().trimmed(); + const QStringList &list = line.split(QLatin1Char(' ')); + if (list.count() <= 1) + continue; + if (list.at(0) == QLatin1String("sysroot")) { + m_systemRoot = MaemoGlobal::maddeRoot(qmakeCommand()) + + QLatin1String("/sysroots/") + list.at(1); + } + } + } + } + return m_systemRoot; +} + +QList MaemoQtVersion::detectQtAbis() const +{ + QList result; + if (!m_isvalidVersion) + return result; + if (m_osType == QLatin1String(Maemo5OsType)) { + result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, + ProjectExplorer::Abi::MaemoLinuxFlavor, ProjectExplorer::Abi::ElfFormat, + 32)); + } else if (m_osType == QLatin1String(HarmattanOsType)) { + result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, + ProjectExplorer::Abi::HarmattanLinuxFlavor, + ProjectExplorer::Abi::ElfFormat, + 32)); + } else if (m_osType == QLatin1String(MeeGoOsType)) { + result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, + ProjectExplorer::Abi::MeegoLinuxFlavor, + ProjectExplorer::Abi::ElfFormat, 32)); + } + return result; +} + +bool MaemoQtVersion::supportsTargetId(const QString &id) const +{ + return supportedTargetIds().contains(id); +} + +QSet MaemoQtVersion::supportedTargetIds() const +{ + QSet result; + if (!m_isvalidVersion) + return result; + if (m_osType == QLatin1String(Maemo5OsType)) { + result.insert(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)); + } else if (m_osType == QLatin1String(HarmattanOsType)) { + result.insert(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID)); + } else if (m_osType == QLatin1String(MeeGoOsType)) { + result.insert(QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID)); + } + return result; +} + +QString MaemoQtVersion::description() const +{ + if (m_osType == QLatin1String(Maemo5OsType)) + return QCoreApplication::translate("QtVersion", "Maemo", "Qt Version is meant for Maemo5"); + else if (m_osType == QLatin1String(HarmattanOsType)) + return QCoreApplication::translate("QtVersion", "Harmattan ", "Qt Version is meant for Harmattan"); + else if (m_osType == QLatin1String(MeeGoOsType)) + return QCoreApplication::translate("QtVersion", "Meego", "Qt Version is meant for Meego"); + return QString(); +} + +bool MaemoQtVersion::supportsShadowBuilds() const +{ +#ifdef Q_OS_WIN + return false; +#endif + return true; +} + +QString MaemoQtVersion::osType() const +{ + return m_osType; +} + +void MaemoQtVersion::addToEnvironment(Utils::Environment &env) const +{ + const QString maddeRoot = MaemoGlobal::maddeRoot(qmakeCommand()); + + // Needed to make pkg-config stuff work. + env.prependOrSet(QLatin1String("SYSROOT_DIR"), QDir::toNativeSeparators(systemRoot())); + env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madbin") + .arg(maddeRoot))); + env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madlib") + .arg(maddeRoot))); + env.prependOrSet(QLatin1String("PERL5LIB"), + QDir::toNativeSeparators(QString("%1/madlib/perl5").arg(maddeRoot))); + + env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin").arg(maddeRoot))); + env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin") + .arg(MaemoGlobal::targetRoot(qmakeCommand())))); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoqtversion.h b/src/plugins/madde/maemoqtversion.h new file mode 100644 index 00000000000..9d933f9ee04 --- /dev/null +++ b/src/plugins/madde/maemoqtversion.h @@ -0,0 +1,72 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOQTVERSION_H +#define MAEMOQTVERSION_H + +#include + +namespace Madde { +namespace Internal { + +class MaemoQtVersion : public QtSupport::BaseQtVersion +{ +public: + MaemoQtVersion(); + MaemoQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + ~MaemoQtVersion(); + + void fromMap(const QVariantMap &map); + MaemoQtVersion *clone() const; + + QString type() const; + bool isValid() const; + QString systemRoot() const; + QList detectQtAbis() const; + void addToEnvironment(Utils::Environment &env) const; + + bool supportsTargetId(const QString &id) const; + QSet supportedTargetIds() const; + + QString description() const; + + bool supportsShadowBuilds() const; + QString osType() const; +private: + mutable QString m_systemRoot; + mutable QString m_osType; + mutable bool m_isvalidVersion; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOQTVERSION_H diff --git a/src/plugins/madde/maemoqtversionfactory.cpp b/src/plugins/madde/maemoqtversionfactory.cpp new file mode 100644 index 00000000000..d385c0b4d7a --- /dev/null +++ b/src/plugins/madde/maemoqtversionfactory.cpp @@ -0,0 +1,91 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoqtversionfactory.h" +#include "maemoglobal.h" +#include "maemoqtversion.h" + +#include +#include + +#include + +namespace Madde { +namespace Internal { + +MaemoQtVersionFactory::MaemoQtVersionFactory(QObject *parent) + : QtSupport::QtVersionFactory(parent) +{ + +} + +MaemoQtVersionFactory::~MaemoQtVersionFactory() +{ + +} + +bool MaemoQtVersionFactory::canRestore(const QString &type) +{ + return type == QLatin1String(QtSupport::Constants::MAEMOQT); +} + +QtSupport::BaseQtVersion *MaemoQtVersionFactory::restore(const QString &type, + const QVariantMap &data) +{ + QTC_ASSERT(canRestore(type), return 0); + MaemoQtVersion *v = new MaemoQtVersion; + v->fromMap(data); + return v; +} + +int MaemoQtVersionFactory::priority() const +{ + return 50; +} + +QtSupport::BaseQtVersion *MaemoQtVersionFactory::create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) +{ + Q_UNUSED(evaluator); + // we are the fallback :) so we don't care what kinf of qt it is + QFileInfo fi(qmakePath); + if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) + return 0; + + if (MaemoGlobal::isValidMaemo5QtVersion(qmakePath) + || MaemoGlobal::isValidHarmattanQtVersion(qmakePath) + || MaemoGlobal::isValidMeegoQtVersion(qmakePath)) + return new MaemoQtVersion(qmakePath, isAutoDetected, autoDetectionSource); + return 0; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoqtversionfactory.h b/src/plugins/madde/maemoqtversionfactory.h new file mode 100644 index 00000000000..b4ea034d4db --- /dev/null +++ b/src/plugins/madde/maemoqtversionfactory.h @@ -0,0 +1,57 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOQTVERSIONFACTORY_H +#define MAEMOQTVERSIONFACTORY_H + +#include + +namespace Madde { +namespace Internal { + +class MaemoQtVersionFactory : public QtSupport::QtVersionFactory +{ +public: + explicit MaemoQtVersionFactory(QObject *parent = 0); + ~MaemoQtVersionFactory(); + + virtual bool canRestore(const QString &type); + virtual QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data); + + virtual int priority() const; + virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOQTVERSIONFACTORY_H diff --git a/src/plugins/madde/maemoremotecopyfacility.cpp b/src/plugins/madde/maemoremotecopyfacility.cpp new file mode 100644 index 00000000000..1776fa8ccd4 --- /dev/null +++ b/src/plugins/madde/maemoremotecopyfacility.cpp @@ -0,0 +1,161 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemoremotecopyfacility.h" + +#include "maemoglobal.h" + +#include +#include +#include + +#include + +using namespace RemoteLinux; +using namespace Utils; + +namespace Madde { +namespace Internal { + +MaemoRemoteCopyFacility::MaemoRemoteCopyFacility(QObject *parent) : + QObject(parent), m_isCopying(false) +{ +} + +MaemoRemoteCopyFacility::~MaemoRemoteCopyFacility() {} + +void MaemoRemoteCopyFacility::copyFiles(const SshConnection::Ptr &connection, + const LinuxDeviceConfiguration::ConstPtr &devConf, + const QList &deployables, const QString &mountPoint) +{ + Q_ASSERT(connection->state() == SshConnection::Connected); + Q_ASSERT(!m_isCopying); + + m_devConf = devConf; + m_deployables = deployables; + m_mountPoint = mountPoint; + + m_copyRunner = SshRemoteProcessRunner::create(connection); + connect(m_copyRunner.data(), SIGNAL(connectionError(Utils::SshError)), + SLOT(handleConnectionError())); + connect(m_copyRunner.data(), SIGNAL(processOutputAvailable(QByteArray)), + SLOT(handleRemoteStdout(QByteArray))); + connect(m_copyRunner.data(), + SIGNAL(processErrorOutputAvailable(QByteArray)), + SLOT(handleRemoteStderr(QByteArray))); + connect(m_copyRunner.data(), SIGNAL(processClosed(int)), + SLOT(handleCopyFinished(int))); + + m_isCopying = true; + copyNextFile(); +} + +void MaemoRemoteCopyFacility::cancel() +{ + Q_ASSERT(m_isCopying); + + SshRemoteProcessRunner::Ptr killProcess + = SshRemoteProcessRunner::create(m_copyRunner->connection()); + killProcess->run("pkill cp"); + setFinished(); +} + +void MaemoRemoteCopyFacility::handleConnectionError() +{ + const QString errMsg = m_copyRunner->connection()->errorString(); + setFinished(); + emit finished(tr("Connection failed: %1").arg(errMsg)); +} + +void MaemoRemoteCopyFacility::handleRemoteStdout(const QByteArray &output) +{ + emit stdoutData(QString::fromUtf8(output)); +} + +void MaemoRemoteCopyFacility::handleRemoteStderr(const QByteArray &output) +{ + emit stderrData(QString::fromUtf8(output)); +} + +void MaemoRemoteCopyFacility::handleCopyFinished(int exitStatus) +{ + if (!m_isCopying) + return; + + if (exitStatus != SshRemoteProcess::ExitedNormally + || m_copyRunner->process()->exitCode() != 0) { + setFinished(); + emit finished(tr("Error: Copy command failed.")); + } else { + emit fileCopied(m_deployables.takeFirst()); + copyNextFile(); + } +} + +void MaemoRemoteCopyFacility::copyNextFile() +{ + Q_ASSERT(m_isCopying); + + if (m_deployables.isEmpty()) { + setFinished(); + emit finished(); + return; + } + + const DeployableFile &d = m_deployables.first(); + QString sourceFilePath = m_mountPoint; +#ifdef Q_OS_WIN + const QString localFilePath = QDir::fromNativeSeparators(d.localFilePath); + sourceFilePath += QLatin1Char('/') + localFilePath.at(0).toLower() + + localFilePath.mid(2); +#else + sourceFilePath += d.localFilePath; +#endif + + QString command = QString::fromLatin1("%1 mkdir -p %3 && %1 cp -a %2 %3") + .arg(MaemoGlobal::remoteSudo(m_devConf->osType(), + m_copyRunner->connection()->connectionParameters().userName), + sourceFilePath, d.remoteDir); + emit progress(tr("Copying file '%1' to directory '%2' on the device...") + .arg(d.localFilePath, d.remoteDir)); + m_copyRunner->run(command.toUtf8()); +} + +void MaemoRemoteCopyFacility::setFinished() +{ + disconnect(m_copyRunner.data(), 0, this, 0); + m_copyRunner.clear(); + m_deployables.clear(); + m_isCopying = false; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoremotecopyfacility.h b/src/plugins/madde/maemoremotecopyfacility.h new file mode 100644 index 00000000000..c2ee128dc79 --- /dev/null +++ b/src/plugins/madde/maemoremotecopyfacility.h @@ -0,0 +1,94 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOREMOTECOPYFACILITY_H +#define MAEMOREMOTECOPYFACILITY_H + +#include + +#include +#include +#include +#include + +namespace Utils { +class SshConnection; +class SshRemoteProcessRunner; +} + +namespace RemoteLinux { +class LinuxDeviceConfiguration; +} + +namespace Madde { +namespace Internal { + +class MaemoRemoteCopyFacility : public QObject +{ + Q_OBJECT +public: + explicit MaemoRemoteCopyFacility(QObject *parent = 0); + ~MaemoRemoteCopyFacility(); + + void copyFiles(const QSharedPointer &connection, + const QSharedPointer &devConf, + const QList &deployables, const QString &mountPoint); + void cancel(); + +signals: + void stdoutData(const QString &output); + void stderrData(const QString &output); + void progress(const QString &message); + void fileCopied(const RemoteLinux::DeployableFile &deployable); + void finished(const QString &errorMsg = QString()); + +private slots: + void handleConnectionError(); + void handleCopyFinished(int exitStatus); + void handleRemoteStdout(const QByteArray &output); + void handleRemoteStderr(const QByteArray &output); + +private: + void copyNextFile(); + void setFinished(); + + QSharedPointer m_copyRunner; + QSharedPointer m_devConf; + QList m_deployables; + QString m_mountPoint; + bool m_isCopying; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOREMOTECOPYFACILITY_H diff --git a/src/plugins/madde/maemoremotemounter.cpp b/src/plugins/madde/maemoremotemounter.cpp new file mode 100644 index 00000000000..8e72cada1e3 --- /dev/null +++ b/src/plugins/madde/maemoremotemounter.cpp @@ -0,0 +1,413 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoremotemounter.h" + +#include "maemoglobal.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace Qt4ProjectManager; +using namespace RemoteLinux; +using namespace Utils; + +namespace Madde { +namespace Internal { + +MaemoRemoteMounter::MaemoRemoteMounter(QObject *parent) + : QObject(parent), m_utfsServerTimer(new QTimer(this)), m_state(Inactive) +{ + connect(m_utfsServerTimer, SIGNAL(timeout()), this, + SLOT(handleUtfsServerTimeout())); + m_utfsServerTimer->setSingleShot(true); +} + +MaemoRemoteMounter::~MaemoRemoteMounter() +{ + killAllUtfsServers(); +} + +void MaemoRemoteMounter::setConnection(const SshConnection::Ptr &connection, + const LinuxDeviceConfiguration::ConstPtr &devConf) +{ + QTC_ASSERT(m_state == Inactive, return); + + m_connection = connection; + m_devConf = devConf; +} + +void MaemoRemoteMounter::setBuildConfiguration(const Qt4BuildConfiguration *bc) +{ + QTC_ASSERT(m_state == Inactive, return); + + const QtSupport::BaseQtVersion * const qtVersion = bc->qtVersion(); + const AbstractQt4MaemoTarget * const maemoTarget + = qobject_cast(bc->target()); + m_remoteMountsAllowed = maemoTarget && maemoTarget->allowsRemoteMounts(); + m_maddeRoot = qtVersion ? MaemoGlobal::maddeRoot(qtVersion->qmakeCommand()) : QString(); +} + +void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec, + bool mountAsRoot) +{ + QTC_ASSERT(m_state == Inactive, return); + + if (m_remoteMountsAllowed && mountSpec.isValid()) + m_mountSpecs << MountInfo(mountSpec, mountAsRoot); +} + +bool MaemoRemoteMounter::hasValidMountSpecifications() const +{ + return !m_mountSpecs.isEmpty(); +} + +void MaemoRemoteMounter::mount(PortList *freePorts, + const RemoteLinuxUsedPortsGatherer *portsGatherer) +{ + QTC_ASSERT(m_state == Inactive, return); + + Q_ASSERT(m_utfsServers.isEmpty()); + Q_ASSERT(m_connection); + + if (m_mountSpecs.isEmpty()) { + setState(Inactive); + emit reportProgress(tr("No directories to mount")); + emit mounted(); + } else { + m_freePorts = freePorts; + m_portsGatherer = portsGatherer; + startUtfsClients(); + } +} + +void MaemoRemoteMounter::unmount() +{ + QTC_ASSERT(m_state == Inactive, return); + + if (m_mountSpecs.isEmpty()) { + emit reportProgress(tr("No directories to unmount")); + emit unmounted(); + return; + } + + QString remoteCall; + const QString remoteSudo = MaemoGlobal::remoteSudo(m_devConf->osType(), + m_connection->connectionParameters().userName); + for (int i = 0; i < m_mountSpecs.count(); ++i) { + remoteCall += QString::fromLocal8Bit("%1 umount %2 && %1 rmdir %2;") + .arg(remoteSudo, m_mountSpecs.at(i).mountSpec.remoteMountPoint); + } + + m_umountStderr.clear(); + m_unmountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8()); + connect(m_unmountProcess.data(), SIGNAL(closed(int)), this, + SLOT(handleUnmountProcessFinished(int))); + connect(m_unmountProcess.data(), SIGNAL(errorOutputAvailable(QByteArray)), + this, SLOT(handleUmountStderr(QByteArray))); + setState(Unmounting); + m_unmountProcess->start(); +} + +void MaemoRemoteMounter::handleUnmountProcessFinished(int exitStatus) +{ + QTC_ASSERT(m_state == Unmounting || m_state == Inactive, return); + + if (m_state == Inactive) + return; + setState(Inactive); + + QString errorMsg; + switch (exitStatus) { + case SshRemoteProcess::FailedToStart: + errorMsg = tr("Could not execute unmount request."); + break; + case SshRemoteProcess::KilledBySignal: + errorMsg = tr("Failure unmounting: %1") + .arg(m_unmountProcess->errorString()); + break; + case SshRemoteProcess::ExitedNormally: + break; + default: + Q_ASSERT_X(false, Q_FUNC_INFO, + "Impossible SshRemoteProcess exit status."); + } + + killAllUtfsServers(); + + if (errorMsg.isEmpty()) { + emit reportProgress(tr("Finished unmounting.")); + emit unmounted(); + } else { + if (!m_umountStderr.isEmpty()) { + errorMsg += tr("\nstderr was: '%1'") + .arg(QString::fromUtf8(m_umountStderr)); + } + emit error(errorMsg); + } +} + +void MaemoRemoteMounter::stop() +{ + setState(Inactive); +} + +void MaemoRemoteMounter::startUtfsClients() +{ + const QString userName = m_connection->connectionParameters().userName; + const QString chmodFuse = MaemoGlobal::remoteSudo(m_devConf->osType(), + userName) + QLatin1String(" chmod a+r+w /dev/fuse"); + const QString chmodUtfsClient + = QLatin1String("chmod a+x ") + utfsClientOnDevice(); + const QLatin1String andOp(" && "); + QString remoteCall = chmodFuse + andOp + chmodUtfsClient; + for (int i = 0; i < m_mountSpecs.count(); ++i) { + MountInfo &mountInfo = m_mountSpecs[i]; + mountInfo.remotePort + = m_portsGatherer->getNextFreePort(m_freePorts); + if (mountInfo.remotePort == -1) { + setState(Inactive); + emit error(tr("Error: Not enough free ports on device to fulfill all mount requests.")); + return; + } + + const QString remoteSudo + = MaemoGlobal::remoteSudo(m_devConf->osType(), userName); + const MaemoMountSpecification &mountSpec = mountInfo.mountSpec; + const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2") + .arg(remoteSudo, mountSpec.remoteMountPoint); + const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2") + .arg(remoteSudo, mountSpec.remoteMountPoint); + QString utfsClient + = QString::fromLocal8Bit("%1 -l %2 -r %2 -b %2 %4 -o nonempty") + .arg(utfsClientOnDevice()).arg(mountInfo.remotePort) + .arg(mountSpec.remoteMountPoint); + if (mountInfo.mountAsRoot) { + utfsClient.prepend(MaemoGlobal::remoteSudo(m_devConf->osType(), + userName) + QLatin1Char(' ')); + } + QLatin1String seqOp("; "); + remoteCall += seqOp + MaemoGlobal::remoteSourceProfilesCommand() + + seqOp + mkdir + andOp + chmod + andOp + utfsClient; + } + + emit reportProgress(tr("Starting remote UTFS clients...")); + m_utfsClientStderr.clear(); + m_mountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8()); + connect(m_mountProcess.data(), SIGNAL(started()), this, + SLOT(handleUtfsClientsStarted())); + connect(m_mountProcess.data(), SIGNAL(closed(int)), this, + SLOT(handleUtfsClientsFinished(int))); + connect(m_mountProcess.data(), SIGNAL(errorOutputAvailable(QByteArray)), + this, SLOT(handleUtfsClientStderr(QByteArray))); + m_mountProcess->start(); + + setState(UtfsClientsStarting); +} + +void MaemoRemoteMounter::handleUtfsClientsStarted() +{ + QTC_ASSERT(m_state == UtfsClientsStarting || m_state == Inactive, return); + + if (m_state == UtfsClientsStarting) { + setState(UtfsClientsStarted); + QTimer::singleShot(250, this, SLOT(startUtfsServers())); + } +} + +void MaemoRemoteMounter::handleUtfsClientsFinished(int exitStatus) +{ + QTC_ASSERT(m_state == UtfsClientsStarting || m_state == UtfsClientsStarted + || m_state == UtfsServersStarted || m_state == Inactive, return); + + if (m_state == Inactive) + return; + + setState(Inactive); + if (exitStatus == SshRemoteProcess::ExitedNormally + && m_mountProcess->exitCode() == 0) { + emit reportProgress(tr("Mount operation succeeded.")); + emit mounted(); + } else { + QString errMsg = tr("Failure running UTFS client: %1") + .arg(m_mountProcess->errorString()); + if (!m_utfsClientStderr.isEmpty()) + errMsg += tr("\nstderr was: '%1'") + .arg(QString::fromUtf8(m_utfsClientStderr)); + emit error(errMsg); + } +} + +void MaemoRemoteMounter::startUtfsServers() +{ + QTC_ASSERT(m_state == UtfsClientsStarted || m_state == Inactive, return); + + if (m_state == Inactive) + return; + + emit reportProgress(tr("Starting UTFS servers...")); + m_utfsServerTimer->start(30000); + for (int i = 0; i < m_mountSpecs.count(); ++i) { + const MountInfo &mountInfo = m_mountSpecs.at(i); + const MaemoMountSpecification &mountSpec = mountInfo.mountSpec; + const ProcPtr utfsServerProc(new QProcess); + const QString port = QString::number(mountInfo.remotePort); + const QString localSecretOpt = QLatin1String("-l"); + const QString remoteSecretOpt = QLatin1String("-r"); + const QStringList utfsServerArgs = QStringList() << localSecretOpt + << port << remoteSecretOpt << port << QLatin1String("-c") + << (m_connection->connectionParameters().host + QLatin1Char(':') + port) + << mountSpec.localDir; + connect(utfsServerProc.data(), + SIGNAL(finished(int,QProcess::ExitStatus)), this, + SLOT(handleUtfsServerFinished(int,QProcess::ExitStatus))); + connect(utfsServerProc.data(), SIGNAL(error(QProcess::ProcessError)), + this, SLOT(handleUtfsServerError(QProcess::ProcessError))); + connect(utfsServerProc.data(), SIGNAL(readyReadStandardError()), this, + SLOT(handleUtfsServerStderr())); + m_utfsServers << utfsServerProc; + utfsServerProc->start(utfsServer(), utfsServerArgs); + } + + setState(UtfsServersStarted); +} + +void MaemoRemoteMounter::handleUtfsServerStderr() +{ + if (m_state != Inactive) { + QProcess * const proc = static_cast(sender()); + const QByteArray &output = proc->readAllStandardError(); + emit debugOutput(QString::fromLocal8Bit(output)); + } +} + +void MaemoRemoteMounter::handleUtfsServerError(QProcess::ProcessError) +{ + if (m_state == Inactive || m_utfsServers.isEmpty()) + return; + + QProcess * const proc = static_cast(sender()); + QString errorString = proc->errorString(); + const QByteArray &errorOutput = proc->readAllStandardError(); + if (!errorOutput.isEmpty()) { + errorString += tr("\nstderr was: %1") + .arg(QString::fromLocal8Bit(errorOutput)); + } + killAllUtfsServers(); + emit error(tr("Error running UTFS server: %1").arg(errorString)); + + setState(Inactive); +} + +void MaemoRemoteMounter::handleUtfsServerFinished(int /* exitCode */, + QProcess::ExitStatus exitStatus) +{ + if (m_state != Inactive && exitStatus != QProcess::NormalExit) + handleUtfsServerError(static_cast(sender())->error()); +} + +void MaemoRemoteMounter::handleUtfsClientStderr(const QByteArray &output) +{ + if (m_state != Inactive) + m_utfsClientStderr += output; +} + +void MaemoRemoteMounter::handleUmountStderr(const QByteArray &output) +{ + if (m_state != Inactive) + m_umountStderr += output; +} + +QString MaemoRemoteMounter::utfsClientOnDevice() const +{ + return QLatin1String("/usr/lib/mad-developer/utfs-client"); +} + +QString MaemoRemoteMounter::utfsServer() const +{ + return m_maddeRoot + QLatin1String("/madlib/utfs-server"); +} + +void MaemoRemoteMounter::killAllUtfsServers() +{ + foreach (const ProcPtr &proc, m_utfsServers) + killUtfsServer(proc.data()); + m_utfsServers.clear(); +} + +void MaemoRemoteMounter::killUtfsServer(QProcess *proc) +{ + disconnect(proc, 0, this, 0); + proc->terminate(); + proc->waitForFinished(1000); + proc->kill(); +} + +void MaemoRemoteMounter::handleUtfsServerTimeout() +{ + QTC_ASSERT(m_state == UtfsServersStarted || m_state == Inactive, return); + + if (m_state == Inactive) + return; + + killAllUtfsServers(); + emit error(tr("Timeout waiting for UTFS servers to connect.")); + + setState(Inactive); +} + +void MaemoRemoteMounter::setState(State newState) +{ + if (newState == Inactive) { + m_utfsServerTimer->stop(); + if (m_mountProcess) { + disconnect(m_mountProcess.data(), 0, this, 0); + m_mountProcess->closeChannel(); + } + if (m_unmountProcess) { + disconnect(m_unmountProcess.data(), 0, this, 0); + m_unmountProcess->closeChannel(); + } + } + m_state = newState; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoremotemounter.h b/src/plugins/madde/maemoremotemounter.h new file mode 100644 index 00000000000..8e08b5e2577 --- /dev/null +++ b/src/plugins/madde/maemoremotemounter.h @@ -0,0 +1,150 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOREMOTEMOUNTER_H +#define MAEMOREMOTEMOUNTER_H + +#include "maemomountspecification.h" + +#include +#include +#include +#include +#include + +QT_FORWARD_DECLARE_CLASS(QTimer) + +namespace Utils { +class SftpChannel; +class SshConnection; +class SshRemoteProcess; +} + +namespace Qt4ProjectManager { class Qt4BuildConfiguration; } + +namespace RemoteLinux { +class LinuxDeviceConfiguration; +class PortList; +class RemoteLinuxUsedPortsGatherer; +} + +namespace Madde { +namespace Internal { + +class MaemoRemoteMounter : public QObject +{ + Q_OBJECT +public: + MaemoRemoteMounter(QObject *parent); + ~MaemoRemoteMounter(); + + // Must already be connected. + void setConnection(const QSharedPointer &connection, + const QSharedPointer &devConf); + + void setBuildConfiguration(const Qt4ProjectManager::Qt4BuildConfiguration *bc); + void addMountSpecification(const MaemoMountSpecification &mountSpec, + bool mountAsRoot); + bool hasValidMountSpecifications() const; + void resetMountSpecifications() { m_mountSpecs.clear(); } + void mount(RemoteLinux::PortList *freePorts, + const RemoteLinux::RemoteLinuxUsedPortsGatherer *portsGatherer); + void unmount(); + void stop(); + +signals: + void mounted(); + void unmounted(); + void error(const QString &reason); + void reportProgress(const QString &progressOutput); + void debugOutput(const QString &output); + +private slots: + void handleUtfsClientsStarted(); + void handleUtfsClientsFinished(int exitStatus); + void handleUtfsClientStderr(const QByteArray &output); + void handleUnmountProcessFinished(int exitStatus); + void handleUmountStderr(const QByteArray &output); + void handleUtfsServerError(QProcess::ProcessError procError); + void handleUtfsServerFinished(int exitCode, + QProcess::ExitStatus exitStatus); + void handleUtfsServerTimeout(); + void handleUtfsServerStderr(); + void startUtfsServers(); + +private: + enum State { + Inactive, Unmounting, UtfsClientsStarting, UtfsClientsStarted, + UtfsServersStarted + }; + + void setState(State newState); + + void startUtfsClients(); + void killUtfsServer(QProcess *proc); + void killAllUtfsServers(); + QString utfsClientOnDevice() const; + QString utfsServer() const; + + QTimer * const m_utfsServerTimer; + + struct MountInfo { + MountInfo(const MaemoMountSpecification &m, bool root) + : mountSpec(m), mountAsRoot(root), remotePort(-1) {} + MaemoMountSpecification mountSpec; + bool mountAsRoot; + int remotePort; + }; + + QSharedPointer m_connection; + QSharedPointer m_devConf; + QList m_mountSpecs; + QSharedPointer m_mountProcess; + QSharedPointer m_unmountProcess; + + typedef QSharedPointer ProcPtr; + QList m_utfsServers; + + QByteArray m_utfsClientStderr; + QByteArray m_umountStderr; + RemoteLinux::PortList *m_freePorts; + const RemoteLinux::RemoteLinuxUsedPortsGatherer *m_portsGatherer; + bool m_remoteMountsAllowed; + QString m_maddeRoot; + + State m_state; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOREMOTEMOUNTER_H diff --git a/src/plugins/madde/maemoremotemountsmodel.cpp b/src/plugins/madde/maemoremotemountsmodel.cpp new file mode 100644 index 00000000000..fb4d233bb0f --- /dev/null +++ b/src/plugins/madde/maemoremotemountsmodel.cpp @@ -0,0 +1,190 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoremotemountsmodel.h" + +#include "maemoconstants.h" + +namespace Madde { +namespace Internal { + +MaemoRemoteMountsModel::MaemoRemoteMountsModel(QObject *parent) : + QAbstractTableModel(parent) +{ +} + +void MaemoRemoteMountsModel::addMountSpecification(const QString &localDir) +{ + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + m_mountSpecs << MaemoMountSpecification(localDir, + MaemoMountSpecification::InvalidMountPoint); + endInsertRows(); +} + +void MaemoRemoteMountsModel::removeMountSpecificationAt(int pos) +{ + Q_ASSERT(pos >= 0 && pos < rowCount()); + beginRemoveRows(QModelIndex(), pos, pos); + m_mountSpecs.removeAt(pos); + endRemoveRows(); +} + +void MaemoRemoteMountsModel::setLocalDir(int pos, const QString &localDir) +{ + Q_ASSERT(pos >= 0 && pos < rowCount()); + m_mountSpecs[pos].localDir = localDir; + const QModelIndex currentIndex = index(pos, LocalDirRow); + emit dataChanged(currentIndex, currentIndex); +} + +int MaemoRemoteMountsModel::validMountSpecificationCount() const +{ + int count = 0; + foreach (const MaemoMountSpecification &m, m_mountSpecs) { + if (m.isValid()) + ++count; + } + return count; +} + +bool MaemoRemoteMountsModel::hasValidMountSpecifications() const +{ + foreach (const MaemoMountSpecification &m, m_mountSpecs) { + if (m.isValid()) + return true; + } + return false; +} + +QVariantMap MaemoRemoteMountsModel::toMap() const +{ + QVariantMap map; + QVariantList localDirsList; + QVariantList remoteMountPointsList; + foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs) { + localDirsList << mountSpec.localDir; + remoteMountPointsList << mountSpec.remoteMountPoint; + } + map.insert(ExportedLocalDirsKey, localDirsList); + map.insert(RemoteMountPointsKey, remoteMountPointsList); + return map; +} + +void MaemoRemoteMountsModel::fromMap(const QVariantMap &map) +{ + const QVariantList &localDirsList + = map.value(ExportedLocalDirsKey).toList(); + const QVariantList &remoteMountPointsList + = map.value(RemoteMountPointsKey).toList(); + const int count + = qMin(localDirsList.count(), remoteMountPointsList.count()); + for (int i = 0; i < count; ++i) { + const QString &localDir = localDirsList.at(i).toString(); + const QString &remoteMountPoint + = remoteMountPointsList.at(i).toString(); + m_mountSpecs << MaemoMountSpecification(localDir, remoteMountPoint); + } +} + +Qt::ItemFlags MaemoRemoteMountsModel::flags(const QModelIndex &index) const +{ + Qt::ItemFlags ourFlags = QAbstractTableModel::flags(index); + if (index.column() == RemoteMountPointRow) + ourFlags |= Qt::ItemIsEditable; + return ourFlags; +} + +QVariant MaemoRemoteMountsModel::headerData(int section, + Qt::Orientation orientation, int role) const +{ + if (role != Qt::DisplayRole || orientation != Qt::Horizontal) + return QVariant(); + + switch (section) { + case LocalDirRow: return tr("Local directory"); + case RemoteMountPointRow: return tr("Remote mount point"); + default: return QVariant(); + } +} + +QVariant MaemoRemoteMountsModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.row() >= rowCount()) + return QVariant(); + + const MaemoMountSpecification &mountSpec = mountSpecificationAt(index.row()); + switch (index.column()) { + case LocalDirRow: + if (role == Qt::DisplayRole) + return mountSpec.localDir; + break; + case RemoteMountPointRow: + if (role == Qt::DisplayRole || role == Qt::EditRole) + return mountSpec.remoteMountPoint; + break; + } + return QVariant(); +} + +bool MaemoRemoteMountsModel::setData(const QModelIndex &index, + const QVariant &value, int role) +{ + if (!index.isValid() || index.row() >= rowCount() || role != Qt::EditRole) + return false; + + bool set; + switch (index.column()) { + case RemoteMountPointRow: { + const QString &newRemoteMountPoint = value.toString(); + for (int i = 0; i < m_mountSpecs.count(); ++i) { + const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i); + if (i != index.row() && mountSpec.isValid() + && mountSpec.remoteMountPoint == newRemoteMountPoint) + return false; + } + m_mountSpecs[index.row()].remoteMountPoint = newRemoteMountPoint; + set = true; + break; + } + case LocalDirRow: + default: + set = false; + break; + } + + if (set) + emit dataChanged(index, index); + return set; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoremotemountsmodel.h b/src/plugins/madde/maemoremotemountsmodel.h new file mode 100644 index 00000000000..2df096cc14a --- /dev/null +++ b/src/plugins/madde/maemoremotemountsmodel.h @@ -0,0 +1,99 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOREMOTEMOUNTSMODEL_H +#define MAEMOREMOTEMOUNTSMODEL_H + +#include "maemomountspecification.h" + +#include +#include +#include +#include + +namespace Madde { +namespace Internal { + +class MaemoRemoteMountsModel : public QAbstractTableModel +{ + Q_OBJECT +public: + explicit MaemoRemoteMountsModel(QObject *parent = 0); + int mountSpecificationCount() const { return m_mountSpecs.count(); } + int validMountSpecificationCount() const; + MaemoMountSpecification mountSpecificationAt(int pos) const { return m_mountSpecs.at(pos); } + bool hasValidMountSpecifications() const; + const QList &mountSpecs() const { return m_mountSpecs; } + + void addMountSpecification(const QString &localDir); + void removeMountSpecificationAt(int pos); + void setLocalDir(int pos, const QString &localDir); + + QVariantMap toMap() const; + void fromMap(const QVariantMap &map); + + static const int LocalDirRow = 0; + static const int RemoteMountPointRow = 1; + +private: + virtual int columnCount(const QModelIndex& = QModelIndex()) const; + virtual int rowCount(const QModelIndex& = QModelIndex()) const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + virtual QModelIndex parent(const QModelIndex &child) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, + int role) const; + virtual QVariant data(const QModelIndex &index, int role) const; + virtual bool setData(const QModelIndex &index, const QVariant &value, + int role); + + QList m_mountSpecs; +}; + +inline int MaemoRemoteMountsModel::columnCount(const QModelIndex &) const +{ + return 2; +} + +inline int MaemoRemoteMountsModel::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : mountSpecificationCount(); +} + +inline QModelIndex MaemoRemoteMountsModel::parent(const QModelIndex &) const +{ + return QModelIndex(); +} + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOREMOTEMOUNTSMODEL_H diff --git a/src/plugins/madde/maemorunconfiguration.cpp b/src/plugins/madde/maemorunconfiguration.cpp new file mode 100644 index 00000000000..017302e13fa --- /dev/null +++ b/src/plugins/madde/maemorunconfiguration.cpp @@ -0,0 +1,202 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemorunconfiguration.h" + +#include "qt4maemotarget.h" +#include "maemoconstants.h" +#include "maemoglobal.h" +#include "maemoremotemountsmodel.h" +#include "maemorunconfigurationwidget.h" +#include "qt4maemodeployconfiguration.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { + +MaemoRunConfiguration::MaemoRunConfiguration(AbstractQt4MaemoTarget *parent, + const QString &proFilePath) + : RemoteLinuxRunConfiguration(parent, Id, proFilePath) +{ + init(); +} + +MaemoRunConfiguration::MaemoRunConfiguration(AbstractQt4MaemoTarget *parent, + MaemoRunConfiguration *source) + : RemoteLinuxRunConfiguration(parent, source) +{ + init(); +} + +void MaemoRunConfiguration::init() +{ + m_remoteMounts = new MaemoRemoteMountsModel(this); + connect(m_remoteMounts, SIGNAL(rowsInserted(QModelIndex, int, int)), this, + SLOT(handleRemoteMountsChanged())); + connect(m_remoteMounts, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, + SLOT(handleRemoteMountsChanged())); + connect(m_remoteMounts, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, + SLOT(handleRemoteMountsChanged())); + connect(m_remoteMounts, SIGNAL(modelReset()), SLOT(handleRemoteMountsChanged())); +} + +bool MaemoRunConfiguration::isEnabled() const +{ + if (!RemoteLinuxRunConfiguration::isEnabled()) + return false; + if (!hasEnoughFreePorts(ProjectExplorer::Constants::RUNMODE)) { + setDisabledReason(tr("Not enough free ports on the device.")); + return false; + } + return true; +} + +QWidget *MaemoRunConfiguration::createConfigurationWidget() +{ + return new MaemoRunConfigurationWidget(this); +} + +QVariantMap MaemoRunConfiguration::toMap() const +{ + QVariantMap map = RemoteLinuxRunConfiguration::toMap(); + map.unite(m_remoteMounts->toMap()); + return map; +} + +bool MaemoRunConfiguration::fromMap(const QVariantMap &map) +{ + if (!RemoteLinuxRunConfiguration::fromMap(map)) + return false; + m_remoteMounts->fromMap(map); + return true; +} + +QString MaemoRunConfiguration::environmentPreparationCommand() const +{ + return MaemoGlobal::remoteSourceProfilesCommand(); +} + +QString MaemoRunConfiguration::commandPrefix() const +{ + if (!deviceConfig()) + return QString(); + + QString prefix = environmentPreparationCommand() + QLatin1Char(';'); + if (deviceConfig()->osType() == QLatin1String(MeeGoOsType)) + prefix += QLatin1String("DISPLAY=:0.0 "); + + return QString::fromLocal8Bit("%1 %2").arg(prefix, userEnvironmentChangesAsString()); +} + +PortList MaemoRunConfiguration::freePorts() const +{ + const Qt4BuildConfiguration * const bc = activeQt4BuildConfiguration(); + return bc && deployConfig() + ? MaemoGlobal::freePorts(deployConfig()->deviceConfiguration(), bc->qtVersion()) + : PortList(); +} + +RemoteLinuxRunConfiguration::DebuggingType MaemoRunConfiguration::debuggingType() const +{ + if (!maemoTarget()->allowsQmlDebugging()) + return DebugCppOnly; + return RemoteLinuxRunConfiguration::debuggingType(); +} + +QString MaemoRunConfiguration::localDirToMountForRemoteGdb() const +{ + const QString projectDir + = QDir::fromNativeSeparators(QDir::cleanPath(activeBuildConfiguration() + ->target()->project()->projectDirectory())); + const QString execDir + = QDir::fromNativeSeparators(QFileInfo(localExecutableFilePath()).path()); + const int length = qMin(projectDir.length(), execDir.length()); + int lastSeparatorPos = 0; + for (int i = 0; i < length; ++i) { + if (projectDir.at(i) != execDir.at(i)) + return projectDir.left(lastSeparatorPos); + if (projectDir.at(i) == QLatin1Char('/')) + lastSeparatorPos = i; + } + return projectDir.length() == execDir.length() + ? projectDir : projectDir.left(lastSeparatorPos); +} + +QString MaemoRunConfiguration::remoteProjectSourcesMountPoint() const +{ + return MaemoGlobal::homeDirOnDevice(deviceConfig()->sshParameters().userName) + + QLatin1String("/gdbSourcesDir_") + + QFileInfo(localExecutableFilePath()).fileName(); +} + +bool MaemoRunConfiguration::hasEnoughFreePorts(const QString &mode) const +{ + const int freePortCount = freePorts().count(); + const bool remoteMountsAllowed = maemoTarget()->allowsRemoteMounts(); + const int mountDirCount = remoteMountsAllowed + ? remoteMounts()->validMountSpecificationCount() : 0; + if (mode == Debugger::Constants::DEBUGMODE) + return freePortCount >= mountDirCount + portsUsedByDebuggers(); + if (mode == ProjectExplorer::Constants::RUNMODE) + return freePortCount >= mountDirCount; + return false; +} + +void MaemoRunConfiguration::handleRemoteMountsChanged() +{ + emit remoteMountsChanged(); + updateEnabledState(); +} + +const AbstractQt4MaemoTarget *MaemoRunConfiguration::maemoTarget() const +{ + const AbstractQt4MaemoTarget * const maemoTarget + = qobject_cast(target()); + Q_ASSERT(maemoTarget); + return maemoTarget; +} + +const QString MaemoRunConfiguration::Id = QLatin1String(MAEMO_RC_ID); + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemorunconfiguration.h b/src/plugins/madde/maemorunconfiguration.h new file mode 100644 index 00000000000..8fcbb8a3791 --- /dev/null +++ b/src/plugins/madde/maemorunconfiguration.h @@ -0,0 +1,81 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMORUNCONFIGURATION_H +#define MAEMORUNCONFIGURATION_H + +#include + +namespace Madde { +namespace Internal { +class AbstractQt4MaemoTarget; +class MaemoRemoteMountsModel; + +class MaemoRunConfiguration : public RemoteLinux::RemoteLinuxRunConfiguration +{ + Q_OBJECT + +public: + MaemoRunConfiguration(AbstractQt4MaemoTarget *parent, const QString &proFilePath); + MaemoRunConfiguration(AbstractQt4MaemoTarget *parent, MaemoRunConfiguration *source); + + QVariantMap toMap() const; + bool fromMap(const QVariantMap &map); + bool isEnabled() const; + QWidget *createConfigurationWidget(); + QString environmentPreparationCommand() const; + QString commandPrefix() const; + RemoteLinux::PortList freePorts() const; + DebuggingType debuggingType() const; + + Internal::MaemoRemoteMountsModel *remoteMounts() const { return m_remoteMounts; } + bool hasEnoughFreePorts(const QString &mode) const; + QString localDirToMountForRemoteGdb() const; + QString remoteProjectSourcesMountPoint() const; + + static const QString Id; + +signals: + void remoteMountsChanged(); + +private slots: + void handleRemoteMountsChanged(); + +private: + void init(); + const AbstractQt4MaemoTarget *maemoTarget() const; + + MaemoRemoteMountsModel *m_remoteMounts; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMORUNCONFIGURATION_H diff --git a/src/plugins/madde/maemorunconfigurationwidget.cpp b/src/plugins/madde/maemorunconfigurationwidget.cpp new file mode 100644 index 00000000000..857cc8de598 --- /dev/null +++ b/src/plugins/madde/maemorunconfigurationwidget.cpp @@ -0,0 +1,249 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemorunconfigurationwidget.h" + +#include "maemoglobal.h" +#include "maemoremotemountsmodel.h" +#include "maemorunconfiguration.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Qt4ProjectManager; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { + +MaemoRunConfigurationWidget::MaemoRunConfigurationWidget( + MaemoRunConfiguration *runConfiguration, QWidget *parent) + : QWidget(parent), m_runConfiguration(runConfiguration) +{ + QVBoxLayout *topLayout = new QVBoxLayout(this); + topLayout->setMargin(0); + QWidget *topWidget = new QWidget; + topLayout->addWidget(topWidget); + QVBoxLayout *mainLayout = new QVBoxLayout(topWidget); + mainLayout->setMargin(0); + m_remoteLinuxRunConfigWidget = new RemoteLinuxRunConfigurationWidget(runConfiguration, parent); + mainLayout->addWidget(m_remoteLinuxRunConfigWidget); + m_subWidget = new QWidget; + mainLayout->addWidget(m_subWidget); + QVBoxLayout *subLayout = new QVBoxLayout(m_subWidget); + subLayout->setMargin(0); + addMountWidgets(subLayout); + connect(m_runConfiguration, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)), + this, SLOT(updateMountWarning())); + connect(m_runConfiguration, SIGNAL(debuggersChanged()), SLOT(updateMountWarning())); + updateMountWarning(); + + const AbstractQt4MaemoTarget * const maemoTarget + = qobject_cast(runConfiguration->target()); + m_mountDetailsContainer->setVisible(maemoTarget->allowsRemoteMounts()); + if (!maemoTarget->allowsQmlDebugging()) + m_remoteLinuxRunConfigWidget->suppressQmlDebuggingOptions(); + + connect(m_runConfiguration, SIGNAL(isEnabledChanged(bool)), + this, SLOT(runConfigurationEnabledChange(bool))); + runConfigurationEnabledChange(m_runConfiguration->isEnabled()); +} + +void MaemoRunConfigurationWidget::runConfigurationEnabledChange(bool enabled) +{ + m_subWidget->setEnabled(enabled); +} + +void MaemoRunConfigurationWidget::addMountWidgets(QVBoxLayout *mainLayout) +{ + m_mountDetailsContainer = new Utils::DetailsWidget(this); + QWidget *mountViewWidget = new QWidget; + m_mountDetailsContainer->setWidget(mountViewWidget); + mainLayout->addWidget(m_mountDetailsContainer); + QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewWidget); + m_mountWarningLabel = new QLabel; + mountViewLayout->addWidget(m_mountWarningLabel); + QHBoxLayout *tableLayout = new QHBoxLayout; + mountViewLayout->addLayout(tableLayout); + m_mountView = new QTableView; + m_mountView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); + m_mountView->setSelectionBehavior(QTableView::SelectRows); + m_mountView->setModel(m_runConfiguration->remoteMounts()); + tableLayout->addWidget(m_mountView); + QVBoxLayout *mountViewButtonsLayout = new QVBoxLayout; + tableLayout->addLayout(mountViewButtonsLayout); + QToolButton *addMountButton = new QToolButton; + QIcon plusIcon; + plusIcon.addFile(QLatin1String(Core::Constants::ICON_PLUS)); + addMountButton->setIcon(plusIcon); + mountViewButtonsLayout->addWidget(addMountButton); + m_removeMountButton = new QToolButton; + QIcon minusIcon; + minusIcon.addFile(QLatin1String(Core::Constants::ICON_MINUS)); + m_removeMountButton->setIcon(minusIcon); + mountViewButtonsLayout->addWidget(m_removeMountButton); + mountViewButtonsLayout->addStretch(1); + + connect(addMountButton, SIGNAL(clicked()), this, SLOT(addMount())); + connect(m_removeMountButton, SIGNAL(clicked()), this, SLOT(removeMount())); + connect(m_mountView, SIGNAL(doubleClicked(QModelIndex)), this, + SLOT(changeLocalMountDir(QModelIndex))); + connect(m_mountView->selectionModel(), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, + SLOT(enableOrDisableRemoveMountSpecButton())); + enableOrDisableRemoveMountSpecButton(); + connect(m_runConfiguration, SIGNAL(remoteMountsChanged()), SLOT(handleRemoteMountsChanged())); + handleRemoteMountsChanged(); +} + +void MaemoRunConfigurationWidget::enableOrDisableRemoveMountSpecButton() +{ + const QModelIndexList selectedRows + = m_mountView->selectionModel()->selectedRows(); + m_removeMountButton->setEnabled(!selectedRows.isEmpty()); +} + +void MaemoRunConfigurationWidget::addMount() +{ + const QString localDir = QFileDialog::getExistingDirectory(this, + tr("Choose directory to mount")); + if (!localDir.isEmpty()) { + MaemoRemoteMountsModel * const mountsModel + = m_runConfiguration->remoteMounts(); + mountsModel->addMountSpecification(localDir); + m_mountView->edit(mountsModel->index(mountsModel->mountSpecificationCount() - 1, + mountsModel->RemoteMountPointRow)); + } +} + +void MaemoRunConfigurationWidget::removeMount() +{ + const QModelIndexList selectedRows + = m_mountView->selectionModel()->selectedRows(); + if (!selectedRows.isEmpty()) { + m_runConfiguration->remoteMounts() + ->removeMountSpecificationAt(selectedRows.first().row()); + } +} + +void MaemoRunConfigurationWidget::changeLocalMountDir(const QModelIndex &index) +{ + if (index.column() == MaemoRemoteMountsModel::LocalDirRow) { + MaemoRemoteMountsModel * const mountsModel + = m_runConfiguration->remoteMounts(); + const QString oldDir + = mountsModel->mountSpecificationAt(index.row()).localDir; + const QString localDir = QFileDialog::getExistingDirectory(this, + tr("Choose directory to mount"), oldDir); + if (!localDir.isEmpty()) + mountsModel->setLocalDir(index.row(), localDir); + } +} + +void MaemoRunConfigurationWidget::handleRemoteMountsChanged() +{ + const int mountCount + = m_runConfiguration->remoteMounts()->validMountSpecificationCount(); + QString text; + switch (mountCount) { + case 0: + text = tr("No local directories to be mounted on the device."); + break; + case 1: + text = tr("One local directory to be mounted on the device."); + break; + default: + //: Note: Only mountCount>1 will occur here as 0, 1 are handled above. + text = tr("%n local directories to be mounted on the device.", 0, mountCount); + break; + } + m_mountDetailsContainer->setSummaryText(QLatin1String("") + text + + QLatin1String("")); + updateMountWarning(); +} + +void MaemoRunConfigurationWidget::updateMountWarning() +{ + QString mountWarning; + const PortList &portList = m_runConfiguration->freePorts(); + const int availablePortCount = portList.count(); + const int mountDirCount + = m_runConfiguration->remoteMounts()->validMountSpecificationCount(); + if (mountDirCount > availablePortCount) { + mountWarning = tr("WARNING: You want to mount %1 directories, but " + "your device has only %n free ports.
You will not be able " + "to run this configuration.", 0, availablePortCount) + .arg(mountDirCount); + } else if (mountDirCount > 0) { + const int portsLeftByDebuggers = availablePortCount + - m_runConfiguration->portsUsedByDebuggers(); + if (mountDirCount > portsLeftByDebuggers) { + mountWarning = tr("WARNING: You want to mount %1 directories, " + "but only %n ports on the device will be available " + "in debug mode.
You will not be able to debug your " + "application with this configuration.", 0, portsLeftByDebuggers) + .arg(mountDirCount); + } + } + if (mountWarning.isEmpty()) { + m_mountWarningLabel->hide(); + } else { + m_mountWarningLabel->setText(QLatin1String("") + + mountWarning + QLatin1String("")); + m_mountWarningLabel->show(); + m_mountDetailsContainer->setState(Utils::DetailsWidget::Expanded); + } +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemorunconfigurationwidget.h b/src/plugins/madde/maemorunconfigurationwidget.h new file mode 100644 index 00000000000..ff4e01a0265 --- /dev/null +++ b/src/plugins/madde/maemorunconfigurationwidget.h @@ -0,0 +1,86 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMORUNCONFIGURATIONWIDGET_H +#define MAEMORUNCONFIGURATIONWIDGET_H + +#include + +QT_BEGIN_NAMESPACE +class QLabel; +class QModelIndex; +class QTableView; +class QToolButton; +class QVBoxLayout; +QT_END_NAMESPACE + +namespace Utils { class DetailsWidget; } + +namespace RemoteLinux { +class RemoteLinuxRunConfigurationWidget; +} + +namespace Madde { +namespace Internal { +class MaemoRunConfiguration; + +class MaemoRunConfigurationWidget : public QWidget +{ + Q_OBJECT +public: + explicit MaemoRunConfigurationWidget(MaemoRunConfiguration *runConfiguration, + QWidget *parent = 0); + +private slots: + void addMount(); + void removeMount(); + void changeLocalMountDir(const QModelIndex &index); + void enableOrDisableRemoveMountSpecButton(); + void handleRemoteMountsChanged(); + void updateMountWarning(); + void runConfigurationEnabledChange(bool enabled); + +private: + void addMountWidgets(QVBoxLayout *mainLayout); + + QWidget *m_subWidget; + QLabel *m_mountWarningLabel; + QTableView *m_mountView; + QToolButton *m_removeMountButton; + Utils::DetailsWidget *m_mountDetailsContainer; + RemoteLinux::RemoteLinuxRunConfigurationWidget *m_remoteLinuxRunConfigWidget; + MaemoRunConfiguration *m_runConfiguration; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMORUNCONFIGURATIONWIDGET_H diff --git a/src/plugins/madde/maemoruncontrol.cpp b/src/plugins/madde/maemoruncontrol.cpp new file mode 100644 index 00000000000..5b31dac7fbb --- /dev/null +++ b/src/plugins/madde/maemoruncontrol.cpp @@ -0,0 +1,68 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoruncontrol.h" + +#include "maemoglobal.h" +#include "maemorunconfiguration.h" +#include "maemosshrunner.h" + +namespace Madde { +namespace Internal { + +using namespace RemoteLinux; +using ProjectExplorer::RunConfiguration; + +MaemoRunControl::MaemoRunControl(RunConfiguration *rc) + : AbstractRemoteLinuxRunControl(rc) + , m_runner(new MaemoSshRunner(this, qobject_cast(rc))) +{ +} + +MaemoRunControl::~MaemoRunControl() +{ +} + +void MaemoRunControl::start() +{ + AbstractRemoteLinuxRunControl::start(); + connect(m_runner, SIGNAL(mountDebugOutput(QString)), SLOT(handleMountDebugOutput(QString))); +} + +void MaemoRunControl::handleMountDebugOutput(const QString &output) +{ + appendMessage(output, Utils::StdErrFormatSameLine); +} + +AbstractRemoteLinuxApplicationRunner *MaemoRunControl::runner() const { return m_runner; } + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemoruncontrol.h b/src/plugins/madde/maemoruncontrol.h new file mode 100644 index 00000000000..7dc202f2a95 --- /dev/null +++ b/src/plugins/madde/maemoruncontrol.h @@ -0,0 +1,66 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMORUNCONTROL_H +#define MAEMORUNCONTROL_H + +#include + +namespace RemoteLinux { +class RemoteLinuxRunConfiguration; +} + +namespace Madde { +namespace Internal { +class MaemoSshRunner; + +class MaemoRunControl : public RemoteLinux::AbstractRemoteLinuxRunControl +{ + Q_OBJECT +public: + explicit MaemoRunControl(ProjectExplorer::RunConfiguration *runConfig); + virtual ~MaemoRunControl(); + + void start(); + +private slots: + void handleMountDebugOutput(const QString &output); + +private: + virtual RemoteLinux::AbstractRemoteLinuxApplicationRunner *runner() const; + + MaemoSshRunner * const m_runner; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMORUNCONTROL_H diff --git a/src/plugins/madde/maemorunfactories.cpp b/src/plugins/madde/maemorunfactories.cpp new file mode 100644 index 00000000000..7e3e4ea9b46 --- /dev/null +++ b/src/plugins/madde/maemorunfactories.cpp @@ -0,0 +1,200 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemorunfactories.h" + +#include "maemoconstants.h" +#include "maemodebugsupport.h" +#include "maemoremotemountsmodel.h" +#include "maemorunconfiguration.h" +#include "maemoruncontrol.h" +#include "maemotoolchain.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include +#include + +using namespace Debugger; +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { + +namespace { + +QString pathFromId(const QString &id) +{ + if (!id.startsWith(MAEMO_RC_ID_PREFIX)) + return QString(); + return id.mid(QString(MAEMO_RC_ID_PREFIX).size()); +} + +} // namespace + +MaemoRunConfigurationFactory::MaemoRunConfigurationFactory(QObject *parent) + : IRunConfigurationFactory(parent) +{ +} + +MaemoRunConfigurationFactory::~MaemoRunConfigurationFactory() +{ +} + +bool MaemoRunConfigurationFactory::canCreate(Target *parent, + const QString &id) const +{ + return qobject_cast(parent)->qt4Project() + ->hasApplicationProFile(pathFromId(id)); +} + +bool MaemoRunConfigurationFactory::canRestore(Target *parent, + const QVariantMap &map) const +{ + Q_UNUSED(parent); + return qobject_cast(parent) + && ProjectExplorer::idFromMap(map).startsWith(QLatin1String(MAEMO_RC_ID)); +} + +bool MaemoRunConfigurationFactory::canClone(Target *parent, + RunConfiguration *source) const +{ + const RemoteLinuxRunConfiguration * const rlrc + = qobject_cast(source); + return rlrc && canCreate(parent, source->id() + QLatin1Char('.') + rlrc->proFilePath()); +} + +QStringList MaemoRunConfigurationFactory::availableCreationIds(Target *parent) const +{ + if (AbstractQt4MaemoTarget *t = qobject_cast(parent)) + return t->qt4Project()->applicationProFilePathes(QLatin1String(MAEMO_RC_ID_PREFIX)); + return QStringList(); +} + +QString MaemoRunConfigurationFactory::displayNameForId(const QString &id) const +{ + return QFileInfo(pathFromId(id)).completeBaseName() + + QLatin1String(" (on remote Maemo device)"); +} + +RunConfiguration *MaemoRunConfigurationFactory::create(Target *parent, + const QString &id) +{ + if (!canCreate(parent, id)) + return 0; + return new MaemoRunConfiguration(qobject_cast(parent), + pathFromId(id)); +} + +RunConfiguration *MaemoRunConfigurationFactory::restore(Target *parent, + const QVariantMap &map) +{ + if (!canRestore(parent, map)) + return 0; + MaemoRunConfiguration *rc + = new MaemoRunConfiguration(qobject_cast(parent), QString()); + if (rc->fromMap(map)) + return rc; + + delete rc; + return 0; +} + +RunConfiguration *MaemoRunConfigurationFactory::clone(Target *parent, + RunConfiguration *source) +{ + if (!canClone(parent, source)) + return 0; + + MaemoRunConfiguration *old = static_cast(source); + return new MaemoRunConfiguration(static_cast(parent), old); +} + +// #pragma mark -- MaemoRunControlFactory + +MaemoRunControlFactory::MaemoRunControlFactory(QObject *parent) + : IRunControlFactory(parent) +{ +} + +MaemoRunControlFactory::~MaemoRunControlFactory() +{ +} + +bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration, + const QString &mode) const +{ + const MaemoRunConfiguration * const maemoRunConfig + = qobject_cast(runConfiguration); + if (!maemoRunConfig || !maemoRunConfig->isEnabled()) + return false; + return maemoRunConfig->hasEnoughFreePorts(mode); +} + +RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig, + const QString &mode) +{ + Q_ASSERT(mode == ProjectExplorer::Constants::RUNMODE || mode == Debugger::Constants::DEBUGMODE); + Q_ASSERT(canRun(runConfig, mode)); + + MaemoRunConfiguration *rc = qobject_cast(runConfig); + Q_ASSERT(rc); + + if (mode == ProjectExplorer::Constants::RUNMODE) + return new MaemoRunControl(rc); + + const DebuggerStartParameters params + = AbstractRemoteLinuxDebugSupport::startParameters(rc); + DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc); + if (!runControl) + return 0; + MaemoDebugSupport *debugSupport = new MaemoDebugSupport(rc, runControl->engine()); + connect(runControl, SIGNAL(finished()), debugSupport, SLOT(handleDebuggingFinished())); + return runControl; +} + +QString MaemoRunControlFactory::displayName() const +{ + return tr("Run on device"); +} + +RunConfigWidget *MaemoRunControlFactory::createConfigurationWidget(RunConfiguration *config) +{ + Q_UNUSED(config) + return 0; +} + + } // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemorunfactories.h b/src/plugins/madde/maemorunfactories.h new file mode 100644 index 00000000000..933c7d7237c --- /dev/null +++ b/src/plugins/madde/maemorunfactories.h @@ -0,0 +1,90 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMORUNFACTORIES_H +#define MAEMORUNFACTORIES_H + +#include + +namespace ProjectExplorer { + class RunConfiguration; + class RunControl; + class Target; +} +using ProjectExplorer::IRunConfigurationFactory; +using ProjectExplorer::IRunControlFactory; +using ProjectExplorer::RunConfiguration; +using ProjectExplorer::RunConfigWidget; +using ProjectExplorer::RunControl; +using ProjectExplorer::Target; + +namespace Madde { +namespace Internal { + +class MaemoRunConfigurationFactory : public IRunConfigurationFactory +{ + Q_OBJECT + +public: + explicit MaemoRunConfigurationFactory(QObject *parent = 0); + ~MaemoRunConfigurationFactory(); + + QString displayNameForId(const QString &id) const; + QStringList availableCreationIds(Target *parent) const; + + bool canCreate(Target *parent, const QString &id) const; + RunConfiguration *create(Target *parent, const QString &id); + + bool canRestore(Target *parent, const QVariantMap &map) const; + RunConfiguration *restore(Target *parent, const QVariantMap &map); + + bool canClone(Target *parent, RunConfiguration *source) const; + RunConfiguration *clone(Target *parent, RunConfiguration *source); +}; + +class MaemoRunControlFactory : public IRunControlFactory +{ + Q_OBJECT +public: + explicit MaemoRunControlFactory(QObject *parent = 0); + ~MaemoRunControlFactory(); + + QString displayName() const; + RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration); + + bool canRun(RunConfiguration *runConfiguration, const QString &mode) const; + RunControl *create(RunConfiguration *runConfiguration, const QString &mode); +}; + + } // namespace Internal +} // namespace Madde + +#endif // MAEMORUNFACTORIES_H diff --git a/src/plugins/madde/maemosettingspages.cpp b/src/plugins/madde/maemosettingspages.cpp new file mode 100644 index 00000000000..74d4d1dbae5 --- /dev/null +++ b/src/plugins/madde/maemosettingspages.cpp @@ -0,0 +1,178 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemosettingspages.h" + +#include "maemoqemusettings.h" +#include "maemoqemusettingswidget.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Madde { +namespace Internal { +namespace { + +class MaemoQemuCrashDialog : public QDialog +{ + Q_OBJECT +public: + MaemoQemuCrashDialog(QWidget *parent = 0) : QDialog(parent) + { + setWindowTitle(tr("Qemu error")); + QString message = tr("Qemu crashed.") + QLatin1String("

"); + const MaemoQemuSettings::OpenGlMode openGlMode + = MaemoQemuSettings::openGlMode(); + const QString linkString = QLatin1String("

") + + tr("Click here to change the OpenGL mode.") + + QLatin1String(""); + if (openGlMode == MaemoQemuSettings::HardwareAcceleration) { + message += tr("You have configured Qemu to use OpenGL " + "hardware acceleration, which might not be supported by " + "your system. You could try using software rendering instead."); + message += linkString; + } else if (openGlMode == MaemoQemuSettings::AutoDetect) { + message += tr("Qemu is currently configured to auto-detect the " + "OpenGL mode, which is known to not work in some cases. " + "You might want to use software rendering instead."); + message += linkString; + } + QLabel * const messageLabel = new QLabel(message, this); + messageLabel->setWordWrap(true); + messageLabel->setTextFormat(Qt::RichText); + connect(messageLabel, SIGNAL(linkActivated(QString)), + SLOT(showSettingsPage())); + QVBoxLayout *mainLayout = new QVBoxLayout(this); + mainLayout->addWidget(messageLabel); + QFrame * const separator = new QFrame; + separator->setFrameShape(QFrame::HLine); + separator->setFrameShadow(QFrame::Sunken); + mainLayout->addWidget(separator); + QDialogButtonBox * const buttonBox = new QDialogButtonBox; + buttonBox->addButton(QDialogButtonBox::Ok); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + mainLayout->addWidget(buttonBox); + } + +private: + Q_SLOT void showSettingsPage() + { + Core::ICore::instance()->showOptionsDialog(MaemoQemuSettingsPage::pageCategory(), + MaemoQemuSettingsPage::pageId()); + accept(); + } +}; + +} // anonymous namespace + + +MaemoQemuSettingsPage::MaemoQemuSettingsPage(QObject *parent) + : Core::IOptionsPage(parent) +{ +} + +MaemoQemuSettingsPage::~MaemoQemuSettingsPage() +{ +} + +QString MaemoQemuSettingsPage::id() const +{ + return pageId(); +} + +QString MaemoQemuSettingsPage::displayName() const +{ + return tr("MeeGo Qemu Settings"); +} + +QString MaemoQemuSettingsPage::category() const +{ + return pageCategory(); +} + +QString MaemoQemuSettingsPage::displayCategory() const +{ + return QString(); // Already set by device configurations page. +} + +QIcon MaemoQemuSettingsPage::categoryIcon() const +{ + return QIcon(); // See above. +} + +bool MaemoQemuSettingsPage::matches(const QString &searchKeyWord) const +{ + return m_widget->keywords().contains(searchKeyWord, Qt::CaseInsensitive); +} + +QWidget *MaemoQemuSettingsPage::createPage(QWidget *parent) +{ + m_widget = new MaemoQemuSettingsWidget(parent); + return m_widget; +} + +void MaemoQemuSettingsPage::apply() +{ + m_widget->saveSettings(); +} + +void MaemoQemuSettingsPage::finish() +{ +} + +void MaemoQemuSettingsPage::showQemuCrashDialog() +{ + MaemoQemuCrashDialog dlg(Core::ICore::instance()->mainWindow()); + dlg.exec(); +} + +QString MaemoQemuSettingsPage::pageId() +{ + return QLatin1String("ZZ.Qemu Settings"); +} + +QString MaemoQemuSettingsPage::pageCategory() +{ + return QLatin1String(RemoteLinux::Constants::RemoteLinuxSettingsCategory); +} + +} // namespace Internal +} // namespace Madde + +#include "maemosettingspages.moc" diff --git a/src/plugins/madde/maemosettingspages.h b/src/plugins/madde/maemosettingspages.h new file mode 100644 index 00000000000..77e278768ac --- /dev/null +++ b/src/plugins/madde/maemosettingspages.h @@ -0,0 +1,70 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOSETTINGSPAGES_H +#define MAEMOSETTINGSPAGES_H + +#include + +namespace Madde{ +namespace Internal { +class MaemoQemuSettingsWidget; + +class MaemoQemuSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + MaemoQemuSettingsPage(QObject *parent = 0); + ~MaemoQemuSettingsPage(); + + virtual QString id() const; + virtual QString displayName() const; + virtual QString category() const; + virtual QString displayCategory() const; + virtual QIcon categoryIcon() const; + virtual bool matches(const QString &searchKeyWord) const; + virtual QWidget *createPage(QWidget *parent); + virtual void apply(); + virtual void finish(); + + static void showQemuCrashDialog(); + static QString pageId(); + static QString pageCategory(); + +private: + QString m_keywords; + MaemoQemuSettingsWidget *m_widget; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOSETTINGSPAGES_H diff --git a/src/plugins/madde/maemosshrunner.cpp b/src/plugins/madde/maemosshrunner.cpp new file mode 100644 index 00000000000..c698d8b635f --- /dev/null +++ b/src/plugins/madde/maemosshrunner.cpp @@ -0,0 +1,235 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "maemosshrunner.h" + +#include "maemoqemumanager.h" +#include "maemoremotemounter.h" +#include "maemoremotemountsmodel.h" +#include "maemorunconfiguration.h" + +#include +#include +#include +#include + +using namespace Qt4ProjectManager; +using namespace RemoteLinux; +using namespace Utils; + +namespace Madde { +namespace Internal { + +MaemoSshRunner::MaemoSshRunner(QObject *parent, MaemoRunConfiguration *runConfig) + : AbstractRemoteLinuxApplicationRunner(runConfig, parent), + m_mounter(new MaemoRemoteMounter(this)), + m_mountSpecs(runConfig->remoteMounts()->mountSpecs()), + m_mountState(InactiveMountState) +{ + const Qt4BuildConfiguration * const bc = runConfig->activeQt4BuildConfiguration(); + m_qtId = bc && bc->qtVersion() ? bc->qtVersion()->uniqueId() : -1; + m_mounter->setBuildConfiguration(bc); + connect(m_mounter, SIGNAL(mounted()), this, SLOT(handleMounted())); + connect(m_mounter, SIGNAL(unmounted()), this, SLOT(handleUnmounted())); + connect(m_mounter, SIGNAL(error(QString)), this, + SLOT(handleMounterError(QString))); + connect(m_mounter, SIGNAL(reportProgress(QString)), this, + SIGNAL(reportProgress(QString))); + connect(m_mounter, SIGNAL(debugOutput(QString)), this, + SIGNAL(mountDebugOutput(QString))); +} + +MaemoSshRunner::~MaemoSshRunner() {} + +bool MaemoSshRunner::canRun(QString &whyNot) const +{ + if (!AbstractRemoteLinuxApplicationRunner::canRun(whyNot)) + return false; + + if (devConfig()->deviceType() == LinuxDeviceConfiguration::Emulator + && !MaemoQemuManager::instance().qemuIsRunning()) { + MaemoQemuRuntime rt; + if (MaemoQemuManager::instance().runtimeForQtVersion(m_qtId, &rt)) { + MaemoQemuManager::instance().startRuntime(); + whyNot = tr("Qemu was not running. It has now been started up for you, but it will " + "take a bit of time until it is ready. Please try again then."); + } else { + whyNot = tr("You want to run on Qemu, but it is not enabled for this Qt version."); + } + return false; + } + + return true; +} + +void MaemoSshRunner::doDeviceSetup() +{ + QTC_ASSERT(m_mountState == InactiveMountState, return); + + handleDeviceSetupDone(true); +} + +void MaemoSshRunner::doAdditionalInitialCleanup() +{ + QTC_ASSERT(m_mountState == InactiveMountState, return); + + m_mounter->setConnection(connection(), devConfig()); + m_mounter->resetMountSpecifications(); + for (int i = 0; i < m_mountSpecs.count(); ++i) + m_mounter->addMountSpecification(m_mountSpecs.at(i), false); + m_mountState = InitialUnmounting; + unmount(); +} + +void MaemoSshRunner::doAdditionalInitializations() +{ + mount(); +} + +void MaemoSshRunner::doPostRunCleanup() +{ + QTC_ASSERT(m_mountState == Mounted, return); + + m_mountState = PostRunUnmounting; + unmount(); +} + +void MaemoSshRunner::handleUnmounted() +{ + QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == PostRunUnmounting, return); + + switch (m_mountState) { + case InitialUnmounting: + m_mountState = InactiveMountState; + handleInitialCleanupDone(true); + break; + case PostRunUnmounting: + m_mountState = InactiveMountState; + handlePostRunCleanupDone(); + break; + default: + break; + } + m_mountState = InactiveMountState; +} + +void MaemoSshRunner::doAdditionalConnectionErrorHandling() +{ + m_mountState = InactiveMountState; +} + +void MaemoSshRunner::handleMounted() +{ + QTC_ASSERT(m_mountState == Mounting, return); + + if (m_mountState == Mounting) { + m_mountState = Mounted; + handleInitializationsDone(true); + } +} + +void MaemoSshRunner::handleMounterError(const QString &errorMsg) +{ + QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == Mounting + || m_mountState == PostRunUnmounting, return); + + const MountState oldMountState = m_mountState; + m_mountState = InactiveMountState; + emit error(errorMsg); + switch (oldMountState) { + case InitialUnmounting: + handleInitialCleanupDone(false); + break; + case Mounting: + handleInitializationsDone(false); + break; + case PostRunUnmounting: + handlePostRunCleanupDone(); + break; + default: + break; + } +} + +void MaemoSshRunner::mount() +{ + m_mountState = Mounting; + if (m_mounter->hasValidMountSpecifications()) { + emit reportProgress(tr("Mounting host directories...")); + m_mounter->mount(freePorts(), usedPortsGatherer()); + } else { + handleMounted(); + } +} + +void MaemoSshRunner::unmount() +{ + QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == PostRunUnmounting, return); + + if (m_mounter->hasValidMountSpecifications()) { + QString message; + switch (m_mountState) { + case InitialUnmounting: + message = tr("Potentially unmounting left-over host directory mounts..."); + break; + case PostRunUnmounting: + message = tr("Unmounting host directories..."); + break; + default: + break; + } + emit reportProgress(message); + m_mounter->unmount(); + } else { + handleUnmounted(); + } +} + +QString MaemoSshRunner::killApplicationCommandLine() const +{ + // Prevent pkill from matching our own pkill call. + QString pkillArg = remoteExecutable(); + const int lastPos = pkillArg.count() - 1; + pkillArg.replace(lastPos, 1, QLatin1Char('[') + pkillArg.at(lastPos) + QLatin1Char(']')); + + // Fremantle's busybox configuration is strange. + const char *killTemplate; + if (devConfig()->osType() == QLatin1String(Maemo5OsType)) + killTemplate = "pkill -f -%2 %1"; + else + killTemplate = "pkill -%2 -f %1"; + const QString niceKill = QString::fromLocal8Bit(killTemplate).arg(pkillArg).arg("SIGTERM"); + const QString brutalKill = QString::fromLocal8Bit(killTemplate).arg(pkillArg).arg("SIGKILL"); + return niceKill + QLatin1String("; sleep 1; ") + brutalKill; +} + +} // namespace Internal +} // namespace Madde + diff --git a/src/plugins/madde/maemosshrunner.h b/src/plugins/madde/maemosshrunner.h new file mode 100644 index 00000000000..e91c78f678e --- /dev/null +++ b/src/plugins/madde/maemosshrunner.h @@ -0,0 +1,82 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOSSHRUNNER_H +#define MAEMOSSHRUNNER_H + +#include "maemomountspecification.h" + +#include + +namespace Madde { +namespace Internal { +class MaemoRemoteMounter; +class MaemoRunConfiguration; + +class MaemoSshRunner : public RemoteLinux::AbstractRemoteLinuxApplicationRunner +{ + Q_OBJECT +public: + MaemoSshRunner(QObject *parent, MaemoRunConfiguration *runConfig); + ~MaemoSshRunner(); + +signals: + void mountDebugOutput(const QString &output); + +private slots: + void handleMounted(); + void handleUnmounted(); + void handleMounterError(const QString &errorMsg); + +private: + enum MountState { InactiveMountState, InitialUnmounting, Mounting, Mounted, PostRunUnmounting }; + + bool canRun(QString &whyNot) const; + void doDeviceSetup(); + void doAdditionalInitialCleanup(); + void doAdditionalInitializations(); + void doPostRunCleanup(); + void doAdditionalConnectionErrorHandling(); + QString killApplicationCommandLine() const; + + void mount(); + void unmount(); + + MaemoRemoteMounter * const m_mounter; + QList m_mountSpecs; + MountState m_mountState; + int m_qtId; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOSSHRUNNER_H diff --git a/src/plugins/madde/maemotoolchain.cpp b/src/plugins/madde/maemotoolchain.cpp new file mode 100644 index 00000000000..d174f473398 --- /dev/null +++ b/src/plugins/madde/maemotoolchain.cpp @@ -0,0 +1,296 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemotoolchain.h" + +#include "maemoglobal.h" +#include "maemoqtversion.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace Qt4ProjectManager; + +namespace Madde { +namespace Internal { + +static const char *const MAEMO_QT_VERSION_KEY = "Qt4ProjectManager.Maemo.QtVersion"; + +// -------------------------------------------------------------------------- +// MaemoToolChain +// -------------------------------------------------------------------------- + +MaemoToolChain::MaemoToolChain(bool autodetected) : + ProjectExplorer::GccToolChain(QLatin1String(Constants::MAEMO_TOOLCHAIN_ID), autodetected), + m_qtVersionId(-1) +{ + updateId(); +} + +MaemoToolChain::MaemoToolChain(const MaemoToolChain &tc) : + ProjectExplorer::GccToolChain(tc), + m_qtVersionId(tc.m_qtVersionId) +{ } + +MaemoToolChain::~MaemoToolChain() +{ } + +QString MaemoToolChain::typeName() const +{ + return MaemoToolChainFactory::tr("Maemo GCC"); +} + +ProjectExplorer::Abi MaemoToolChain::targetAbi() const +{ + return m_targetAbi; +} + +QString MaemoToolChain::mkspec() const +{ + return QString(); // always use default +} + +bool MaemoToolChain::isValid() const +{ + return GccToolChain::isValid() && m_qtVersionId >= 0 && m_targetAbi.isValid(); +} + +bool MaemoToolChain::canClone() const +{ + return false; +} + +void MaemoToolChain::addToEnvironment(Utils::Environment &env) const +{ + const QString manglePathsKey = QLatin1String("GCCWRAPPER_PATHMANGLE"); + if (!env.hasKey(manglePathsKey)) { + const QStringList pathsToMangle = QStringList() << QLatin1String("/lib") + << QLatin1String("/opt") << QLatin1String("/usr"); + env.set(manglePathsKey, QString()); + foreach (const QString &path, pathsToMangle) + env.appendOrSet(manglePathsKey, path, QLatin1String(":")); + } +} + +bool MaemoToolChain::operator ==(const ProjectExplorer::ToolChain &tc) const +{ + if (!ToolChain::operator ==(tc)) + return false; + + const MaemoToolChain *tcPtr = static_cast(&tc); + return m_qtVersionId == tcPtr->m_qtVersionId; +} + +ProjectExplorer::ToolChainConfigWidget *MaemoToolChain::configurationWidget() +{ + return new MaemoToolChainConfigWidget(this); +} + +QVariantMap MaemoToolChain::toMap() const +{ + QVariantMap result = GccToolChain::toMap(); + result.insert(QLatin1String(MAEMO_QT_VERSION_KEY), m_qtVersionId); + return result; +} + +bool MaemoToolChain::fromMap(const QVariantMap &data) +{ + if (!GccToolChain::fromMap(data)) + return false; + + m_qtVersionId = data.value(QLatin1String(MAEMO_QT_VERSION_KEY), -1).toInt(); + + return isValid(); +} + +void MaemoToolChain::setQtVersionId(int id) +{ + if (id < 0) { + m_targetAbi = ProjectExplorer::Abi(); + m_qtVersionId = -1; + updateId(); // Will trigger toolChainUpdated()! + return; + } + + MaemoQtVersion *version = dynamic_cast(QtSupport::QtVersionManager::instance()->version(id)); + Q_ASSERT(version); + if (!version->isValid()) + return; + Q_ASSERT(version->qtAbis().count() == 1); + + m_qtVersionId = id; + m_targetAbi = version->qtAbis().at(0); + + updateId(); // Will trigger toolChainUpdated()! + setDisplayName(MaemoToolChainFactory::tr("Maemo GCC for %1").arg(version->displayName())); +} + +int MaemoToolChain::qtVersionId() const +{ + return m_qtVersionId; +} + +void MaemoToolChain::updateId() +{ + setId(QString::fromLatin1("%1:%2.%3").arg(Constants::MAEMO_TOOLCHAIN_ID) + .arg(m_qtVersionId).arg(debuggerCommand())); +} + +// -------------------------------------------------------------------------- +// MaemoToolChainConfigWidget +// -------------------------------------------------------------------------- + +MaemoToolChainConfigWidget::MaemoToolChainConfigWidget(MaemoToolChain *tc) : + ProjectExplorer::ToolChainConfigWidget(tc) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + QLabel *label = new QLabel; + QtSupport::BaseQtVersion *v = QtSupport::QtVersionManager::instance()->version(tc->qtVersionId()); + Q_ASSERT(v); + label->setText(tr("" + "" + "" + "") + .arg(QDir::toNativeSeparators(MaemoGlobal::maddeRoot(v->qmakeCommand())), + QDir::toNativeSeparators(MaemoGlobal::targetRoot(v->qmakeCommand())), + QDir::toNativeSeparators(tc->debuggerCommand()))); + layout->addWidget(label); +} + +void MaemoToolChainConfigWidget::apply() +{ + // nothing to do! +} + +void MaemoToolChainConfigWidget::discard() +{ + // nothing to do! +} + +bool MaemoToolChainConfigWidget::isDirty() const +{ + return false; +} + +// -------------------------------------------------------------------------- +// MaemoToolChainFactory +// -------------------------------------------------------------------------- + +MaemoToolChainFactory::MaemoToolChainFactory() : + ProjectExplorer::ToolChainFactory() +{ } + +QString MaemoToolChainFactory::displayName() const +{ + return tr("Maemo GCC"); +} + +QString MaemoToolChainFactory::id() const +{ + return QLatin1String(Constants::MAEMO_TOOLCHAIN_ID); +} + +QList MaemoToolChainFactory::autoDetect() +{ + QtSupport::QtVersionManager *vm = QtSupport::QtVersionManager::instance(); + connect(vm, SIGNAL(qtVersionsChanged(QList)), + this, SLOT(handleQtVersionChanges(QList))); + + QList versionList; + foreach (QtSupport::BaseQtVersion *v, vm->versions()) + versionList.append(v->uniqueId()); + + return createToolChainList(versionList); +} + +void MaemoToolChainFactory::handleQtVersionChanges(const QList &changes) +{ + ProjectExplorer::ToolChainManager *tcm = ProjectExplorer::ToolChainManager::instance(); + QList tcList = createToolChainList(changes); + foreach (ProjectExplorer::ToolChain *tc, tcList) + tcm->registerToolChain(tc); +} + +QList MaemoToolChainFactory::createToolChainList(const QList &changes) +{ + ProjectExplorer::ToolChainManager *tcm = ProjectExplorer::ToolChainManager::instance(); + QtSupport::QtVersionManager *vm = QtSupport::QtVersionManager::instance(); + QList result; + + foreach (int i, changes) { + QtSupport::BaseQtVersion *v = vm->version(i); + // remove tool chain (on removal, change or addition: + QList toRemove; + foreach (ProjectExplorer::ToolChain *tc, tcm->toolChains()) { + if (!tc->id().startsWith(QLatin1String(Constants::MAEMO_TOOLCHAIN_ID))) + continue; + MaemoToolChain *mTc = static_cast(tc); + if (mTc->qtVersionId() == i) + toRemove.append(mTc); + } + foreach (ProjectExplorer::ToolChain *tc, toRemove) + tcm->deregisterToolChain(tc); + + const MaemoQtVersion * const mqv = dynamic_cast(v); + if (!mqv || !mqv->isValid()) + continue; + + // (Re-)add toolchain: + // add tool chain: + MaemoToolChain *mTc = new MaemoToolChain(true); + mTc->setQtVersionId(i); + QString target = "Maemo 5"; + if (v->supportsTargetId(Constants::HARMATTAN_DEVICE_TARGET_ID)) + target = "Maemo 6"; + else if (v->supportsTargetId(Constants::MEEGO_DEVICE_TARGET_ID)) + target = "Meego"; + mTc->setDisplayName(tr("%1 GCC (%2)").arg(target).arg(MaemoGlobal::maddeRoot(mqv->qmakeCommand()))); + mTc->setCompilerPath(MaemoGlobal::targetRoot(mqv->qmakeCommand()) + QLatin1String("/bin/gcc")); + mTc->setDebuggerCommand(ProjectExplorer::ToolChainManager::instance()->defaultDebugger(mqv->qtAbis().at(0))); + if (mTc->debuggerCommand().isEmpty()) + mTc->setDebuggerCommand(MaemoGlobal::targetRoot(mqv->qmakeCommand()) + QLatin1String("/bin/gdb")); + result.append(mTc); + } + return result; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/maemotoolchain.h b/src/plugins/madde/maemotoolchain.h new file mode 100644 index 00000000000..56b66976792 --- /dev/null +++ b/src/plugins/madde/maemotoolchain.h @@ -0,0 +1,123 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOTOOLCHAIN_H +#define MAEMOTOOLCHAIN_H + +#include +#include + +namespace Madde { +namespace Internal { + +// -------------------------------------------------------------------------- +// MaemoToolChain +// -------------------------------------------------------------------------- + +class MaemoToolChain : public ProjectExplorer::GccToolChain +{ +public: + ~MaemoToolChain(); + + QString typeName() const; + ProjectExplorer::Abi targetAbi() const; + QString mkspec() const; + + bool isValid() const; + bool canClone() const; + + void addToEnvironment(Utils::Environment &env) const; + + bool operator ==(const ProjectExplorer::ToolChain &) const; + + ProjectExplorer::ToolChainConfigWidget *configurationWidget(); + + QVariantMap toMap() const; + bool fromMap(const QVariantMap &data); + + void setQtVersionId(int); + int qtVersionId() const; + +private: + void updateId(); + + explicit MaemoToolChain(bool); + MaemoToolChain(const MaemoToolChain &); + + int m_qtVersionId; + mutable QString m_sysroot; + ProjectExplorer::Abi m_targetAbi; + + friend class MaemoToolChainFactory; +}; + +// -------------------------------------------------------------------------- +// MaemoToolChainConfigWidget +// -------------------------------------------------------------------------- + +class MaemoToolChainConfigWidget : public ProjectExplorer::ToolChainConfigWidget +{ + Q_OBJECT + +public: + MaemoToolChainConfigWidget(MaemoToolChain *); + + void apply(); + void discard(); + bool isDirty() const; +}; + +// -------------------------------------------------------------------------- +// MaemoToolChainFactory +// -------------------------------------------------------------------------- + +class MaemoToolChainFactory : public ProjectExplorer::ToolChainFactory +{ + Q_OBJECT + +public: + MaemoToolChainFactory(); + + QString displayName() const; + QString id() const; + + QList autoDetect(); + +private slots: + void handleQtVersionChanges(const QList &); + QList createToolChainList(const QList &); +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOTOOLCHAIN_H diff --git a/src/plugins/madde/qt-maemo.qrc b/src/plugins/madde/qt-maemo.qrc new file mode 100644 index 00000000000..354fe64d1be --- /dev/null +++ b/src/plugins/madde/qt-maemo.qrc @@ -0,0 +1,6 @@ + + + images/qemu-run.png + images/qemu-stop.png + + diff --git a/src/plugins/madde/qt4maemodeployconfiguration.cpp b/src/plugins/madde/qt4maemodeployconfiguration.cpp new file mode 100644 index 00000000000..9428cfd25f5 --- /dev/null +++ b/src/plugins/madde/qt4maemodeployconfiguration.cpp @@ -0,0 +1,254 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "qt4maemodeployconfiguration.h" + +#include "maddeuploadandinstallpackagesteps.h" +#include "maemoconstants.h" +#include "maemodeploybymountsteps.h" +#include "maemodeployconfigurationwidget.h" +#include "maemoinstalltosysrootstep.h" +#include "maemopackagecreationstep.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace ProjectExplorer; +using namespace Qt4ProjectManager; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { +namespace { +const QString OldDeployConfigId = QLatin1String("2.2MaemoDeployConfig"); +} // namespace + +Qt4MaemoDeployConfiguration::Qt4MaemoDeployConfiguration(ProjectExplorer::Target *target, + const QString &id, const QString &displayName, const QString &supportedOsType) + : RemoteLinuxDeployConfiguration(target, id, displayName, supportedOsType) +{ + const QList &deployConfigs = target->deployConfigurations(); + foreach (const DeployConfiguration * const dc, deployConfigs) { + const Qt4MaemoDeployConfiguration * const mdc + = qobject_cast(dc); + if (mdc) { + m_deploymentSettingsAssistant = mdc->deploymentSettingsAssistant(); + break; + } + } + if (!m_deploymentSettingsAssistant) { + QString qmakeScope; + if (supportedOsType == QLatin1String(Maemo5OsType)) + qmakeScope = QLatin1String("maemo5"); + else if (supportedOsType == QLatin1String(HarmattanOsType)) + qmakeScope = QLatin1String("contains(MEEGO_EDITION,harmattan)"); + else if (supportedOsType == QLatin1String(MeeGoOsType)) + qmakeScope = QLatin1String("!isEmpty(MEEGO_VERSION_MAJOR):!contains(MEEGO_EDITION,harmattan)"); + else + qDebug("%s: Unexpected OS type %s", Q_FUNC_INFO, qPrintable(supportedOsType)); + m_deploymentSettingsAssistant = QSharedPointer + (new DeploymentSettingsAssistant(qmakeScope, QLatin1String("/opt"), deploymentInfo())); + } +} + +Qt4MaemoDeployConfiguration::Qt4MaemoDeployConfiguration(ProjectExplorer::Target *target, + Qt4MaemoDeployConfiguration *source) + : RemoteLinuxDeployConfiguration(target, source) +{ + m_deploymentSettingsAssistant = source->deploymentSettingsAssistant(); +} + +QSharedPointer Qt4MaemoDeployConfiguration::deploymentSettingsAssistant() const +{ + return m_deploymentSettingsAssistant; +} + +QString Qt4MaemoDeployConfiguration::localDesktopFilePath(const DeployableFilesPerProFile *proFileInfo) const +{ + QTC_ASSERT(proFileInfo->projectType() == ApplicationTemplate, return QString()); + + for (int i = 0; i < proFileInfo->rowCount(); ++i) { + const DeployableFile &d = proFileInfo->deployableAt(i); + if (QFileInfo(d.localFilePath).fileName().endsWith(QLatin1String(".desktop"))) + return d.localFilePath; + } + return QString(); +} + + +DeployConfigurationWidget *Qt4MaemoDeployConfiguration::configurationWidget() const +{ + return new MaemoDeployConfigurationWidget; +} + +Qt4MaemoDeployConfiguration::~Qt4MaemoDeployConfiguration() {} + +QString Qt4MaemoDeployConfiguration::fremantleWithPackagingId() +{ + return QLatin1String("DeployToFremantleWithPackaging"); +} + +QString Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId() +{ + return QLatin1String("DeployToFremantleWithoutPackaging"); +} + +QString Qt4MaemoDeployConfiguration::harmattanId() +{ + return QLatin1String("DeployToHarmattan"); +} + +QString Qt4MaemoDeployConfiguration::meegoId() +{ + return QLatin1String("DeployToMeego"); +} + + +Qt4MaemoDeployConfigurationFactory::Qt4MaemoDeployConfigurationFactory(QObject *parent) + : DeployConfigurationFactory(parent) +{ } + +QStringList Qt4MaemoDeployConfigurationFactory::availableCreationIds(Target *parent) const +{ + QStringList ids; + if (qobject_cast(parent)) { + ids << Qt4MaemoDeployConfiguration::fremantleWithPackagingId() + << Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId(); + } else if (qobject_cast(parent)) { + ids << Qt4MaemoDeployConfiguration::harmattanId(); + } else if (qobject_cast(parent)) { + ids << Qt4MaemoDeployConfiguration::meegoId(); + } + + return ids; +} + +QString Qt4MaemoDeployConfigurationFactory::displayNameForId(const QString &id) const +{ + if (id == Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId()) + return tr("Copy Files to Maemo5 Device"); + else if (id == Qt4MaemoDeployConfiguration::fremantleWithPackagingId()) + return tr("Build Debian Package and Install to Maemo5 Device"); + else if (id == Qt4MaemoDeployConfiguration::harmattanId()) + return tr("Build Debian Package and Install to Harmattan Device"); + else if (id == Qt4MaemoDeployConfiguration::meegoId()) + return tr("Build RPM Package and Install to MeeGo Device"); + return QString(); +} + +bool Qt4MaemoDeployConfigurationFactory::canCreate(Target *parent, + const QString &id) const +{ + return availableCreationIds(parent).contains(id); +} + +DeployConfiguration *Qt4MaemoDeployConfigurationFactory::create(Target *parent, + const QString &id) +{ + Q_ASSERT(canCreate(parent, id)); + + DeployConfiguration *dc = 0; + const QString displayName = displayNameForId(id); + if (id == Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId()) { + dc = new Qt4MaemoDeployConfiguration(parent, id, displayName, QLatin1String(Maemo5OsType)); + dc->stepList()->insertStep(0, new MaemoMakeInstallToSysrootStep(dc->stepList())); + dc->stepList()->insertStep(1, new MaemoCopyFilesViaMountStep(dc->stepList())); + } else if (id == Qt4MaemoDeployConfiguration::fremantleWithPackagingId()) { + dc = new Qt4MaemoDeployConfiguration(parent, id, displayName, QLatin1String(Maemo5OsType)); + dc->stepList()->insertStep(0, new MaemoDebianPackageCreationStep(dc->stepList())); + dc->stepList()->insertStep(1, new MaemoInstallDebianPackageToSysrootStep(dc->stepList())); + dc->stepList()->insertStep(2, new MaemoInstallPackageViaMountStep(dc->stepList())); + } else if (id == Qt4MaemoDeployConfiguration::harmattanId()) { + dc = new Qt4MaemoDeployConfiguration(parent, id, displayName, + QLatin1String(HarmattanOsType)); + dc->stepList()->insertStep(0, new MaemoDebianPackageCreationStep(dc->stepList())); + dc->stepList()->insertStep(1, new MaemoInstallDebianPackageToSysrootStep(dc->stepList())); + dc->stepList()->insertStep(2, new MaemoUploadAndInstallPackageStep(dc->stepList())); + } else if (id == Qt4MaemoDeployConfiguration::meegoId()) { + dc = new Qt4MaemoDeployConfiguration(parent, id, displayName, QLatin1String(MeeGoOsType)); + dc->stepList()->insertStep(0, new MaemoRpmPackageCreationStep(dc->stepList())); + dc->stepList()->insertStep(1, new MaemoInstallRpmPackageToSysrootStep(dc->stepList())); + dc->stepList()->insertStep(2, new MeegoUploadAndInstallPackageStep(dc->stepList())); + } + return dc; +} + +bool Qt4MaemoDeployConfigurationFactory::canRestore(Target *parent, + const QVariantMap &map) const +{ + return canCreate(parent, idFromMap(map)) + || (idFromMap(map) == OldDeployConfigId + && qobject_cast(parent)); +} + +DeployConfiguration *Qt4MaemoDeployConfigurationFactory::restore(Target *parent, + const QVariantMap &map) +{ + if (!canRestore(parent, map)) + return 0; + QString id = idFromMap(map); + if (id == OldDeployConfigId) { + if (qobject_cast(parent)) + id = Qt4MaemoDeployConfiguration::fremantleWithPackagingId(); + else if (qobject_cast(parent)) + id = Qt4MaemoDeployConfiguration::harmattanId(); + else if (qobject_cast(parent)) + id = Qt4MaemoDeployConfiguration::meegoId(); + } + Qt4MaemoDeployConfiguration * const dc + = qobject_cast(create(parent, id)); + if (!dc->fromMap(map)) { + delete dc; + return 0; + } + return dc; +} + +DeployConfiguration *Qt4MaemoDeployConfigurationFactory::clone(Target *parent, + DeployConfiguration *product) +{ + if (!canClone(parent, product)) + return 0; + return new Qt4MaemoDeployConfiguration(parent, + qobject_cast(product)); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/qt4maemodeployconfiguration.h b/src/plugins/madde/qt4maemodeployconfiguration.h new file mode 100644 index 00000000000..c954cdec46d --- /dev/null +++ b/src/plugins/madde/qt4maemodeployconfiguration.h @@ -0,0 +1,96 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H +#define QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H + +#include + +namespace RemoteLinux { +class DeployableFilesPerProFile; +class DeploymentSettingsAssistant; +} + +namespace Madde { +namespace Internal { + +class Qt4MaemoDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory +{ + Q_OBJECT + +public: + explicit Qt4MaemoDeployConfigurationFactory(QObject *parent = 0); + + virtual QStringList availableCreationIds(ProjectExplorer::Target *parent) const; + virtual QString displayNameForId(const QString &id) const; + virtual bool canCreate(ProjectExplorer::Target *parent, const QString &id) const; + virtual ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, const QString &id); + virtual bool canRestore(ProjectExplorer::Target *parent, + const QVariantMap &map) const; + virtual ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, + const QVariantMap &map); + virtual ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent, + ProjectExplorer::DeployConfiguration *product); +}; + +class Qt4MaemoDeployConfiguration : public RemoteLinux::RemoteLinuxDeployConfiguration +{ + Q_OBJECT + +public: + ~Qt4MaemoDeployConfiguration(); + + ProjectExplorer::DeployConfigurationWidget *configurationWidget() const; + + QSharedPointer deploymentSettingsAssistant() const; + QString localDesktopFilePath(const RemoteLinux::DeployableFilesPerProFile *proFileInfo) const; + + static QString fremantleWithPackagingId(); + static QString fremantleWithoutPackagingId(); + static QString harmattanId(); + static QString meegoId(); + +private: + friend class Internal::Qt4MaemoDeployConfigurationFactory; + + Qt4MaemoDeployConfiguration(ProjectExplorer::Target *target, const QString &id, + const QString &displayName, const QString &supportedOsType); + Qt4MaemoDeployConfiguration(ProjectExplorer::Target *target, + Qt4MaemoDeployConfiguration *source); + + QSharedPointer m_deploymentSettingsAssistant; +}; + +} // namespace Internal +} // namespace Madde + +#endif // QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H diff --git a/src/plugins/madde/qt4maemotarget.cpp b/src/plugins/madde/qt4maemotarget.cpp new file mode 100644 index 00000000000..3814236159c --- /dev/null +++ b/src/plugins/madde/qt4maemotarget.cpp @@ -0,0 +1,1197 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "qt4maemotarget.h" + +#include "maemoglobal.h" +#include "maemopackagecreationstep.h" +#include "maemorunconfiguration.h" +#include "maemotoolchain.h" +#include "qt4maemodeployconfiguration.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace Qt4ProjectManager; + +namespace Madde { +namespace Internal { + +namespace { +const QByteArray NameFieldName("Package"); +const QByteArray IconFieldName("XB-Maemo-Icon-26"); +const QByteArray ShortDescriptionFieldName("Description"); +const QByteArray PackageFieldName("Package"); +const QLatin1String PackagingDirName("qtc_packaging"); +const QByteArray NameTag("Name"); +const QByteArray SummaryTag("Summary"); +const QByteArray VersionTag("Version"); +const QByteArray ReleaseTag("Release"); + +bool adaptTagValue(QByteArray &document, const QByteArray &fieldName, + const QByteArray &newFieldValue, bool caseSensitive) +{ + QByteArray adaptedLine = fieldName + ": " + newFieldValue; + const QByteArray completeTag = fieldName + ':'; + const int lineOffset = caseSensitive ? document.indexOf(completeTag) + : document.toLower().indexOf(completeTag.toLower()); + if (lineOffset == -1) { + document.append(adaptedLine).append('\n'); + return true; + } + + int newlineOffset = document.indexOf('\n', lineOffset); + bool updated = false; + if (newlineOffset == -1) { + newlineOffset = document.length(); + adaptedLine += '\n'; + updated = true; + } + const int replaceCount = newlineOffset - lineOffset; + if (!updated && document.mid(lineOffset, replaceCount) != adaptedLine) + updated = true; + if (updated) + document.replace(lineOffset, replaceCount, adaptedLine); + return updated; +} + + +} // anonymous namespace + + +AbstractQt4MaemoTarget::AbstractQt4MaemoTarget(Qt4Project *parent, const QString &id) : + Qt4BaseTarget(parent, id), + m_filesWatcher(new Utils::FileSystemWatcher(this)), + m_buildConfigurationFactory(new Qt4BuildConfigurationFactory(this)), + m_isInitialized(false) +{ + m_filesWatcher->setObjectName(QLatin1String("Qt4MaemoTarget")); + setIcon(QIcon(":/projectexplorer/images/MaemoDevice.png")); + connect(parent, SIGNAL(addedTarget(ProjectExplorer::Target*)), + this, SLOT(handleTargetAdded(ProjectExplorer::Target*))); + connect(parent, SIGNAL(fromMapFinished()), + this, SLOT(handleFromMapFinished())); +} + +AbstractQt4MaemoTarget::~AbstractQt4MaemoTarget() +{ } + +QList AbstractQt4MaemoTarget::possibleToolChains(ProjectExplorer::BuildConfiguration *bc) const +{ + QList result; + + Qt4BuildConfiguration *qt4Bc = qobject_cast(bc); + if (!qt4Bc) + return result; + + QList candidates = Qt4BaseTarget::possibleToolChains(bc); + foreach (ProjectExplorer::ToolChain *i, candidates) { + MaemoToolChain *tc = dynamic_cast(i); + if (!tc || !qt4Bc->qtVersion()) + continue; + if (tc->qtVersionId() == qt4Bc->qtVersion()->uniqueId()) + result.append(tc); + } + + return result; +} + +ProjectExplorer::IBuildConfigurationFactory *AbstractQt4MaemoTarget::buildConfigurationFactory() const +{ + return m_buildConfigurationFactory; +} + +void AbstractQt4MaemoTarget::createApplicationProFiles() +{ + removeUnconfiguredCustomExectutableRunConfigurations(); + + QList profiles = qt4Project()->applicationProFiles(); + QSet paths; + foreach (Qt4ProFileNode *pro, profiles) + paths << pro->path(); + + foreach (ProjectExplorer::RunConfiguration *rc, runConfigurations()) + if (MaemoRunConfiguration *qt4rc = qobject_cast(rc)) + paths.remove(qt4rc->proFilePath()); + + // Only add new runconfigurations if there are none. + foreach (const QString &path, paths) + addRunConfiguration(new MaemoRunConfiguration(this, path)); + + // Oh still none? Add a custom executable runconfiguration + if (runConfigurations().isEmpty()) { + addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(this)); + } +} + +QList AbstractQt4MaemoTarget::runConfigurationsForNode(ProjectExplorer::Node *n) +{ + QList result; + foreach (ProjectExplorer::RunConfiguration *rc, runConfigurations()) + if (MaemoRunConfiguration *mrc = qobject_cast(rc)) + if (mrc->proFilePath() == n->path()) + result << rc; + return result; +} + +bool AbstractQt4MaemoTarget::setProjectVersion(const QString &version, + QString *error) +{ + bool success = true; + foreach (Target * const target, project()->targets()) { + AbstractQt4MaemoTarget * const maemoTarget + = qobject_cast(target); + if (maemoTarget) { + if (!maemoTarget->setProjectVersionInternal(version, error)) + success = false; + } + } + return success; +} + +bool AbstractQt4MaemoTarget::setPackageName(const QString &name) +{ + bool success = true; + foreach (Target * const target, project()->targets()) { + AbstractQt4MaemoTarget * const maemoTarget + = qobject_cast(target); + if (maemoTarget) { + if (!maemoTarget->setPackageNameInternal(name)) + success = false; + } + } + return success; +} + +bool AbstractQt4MaemoTarget::setShortDescription(const QString &description) +{ + bool success = true; + foreach (Target * const target, project()->targets()) { + AbstractQt4MaemoTarget * const maemoTarget + = qobject_cast(target); + if (maemoTarget) { + if (!maemoTarget->setShortDescriptionInternal(description)) + success = false; + } + } + return success; +} + +QSharedPointer AbstractQt4MaemoTarget::openFile(const QString &filePath, + QIODevice::OpenMode mode, QString *error) const +{ + const QString nativePath = QDir::toNativeSeparators(filePath); + QSharedPointer file(new QFile(filePath)); + if (!file->open(mode)) { + if (error) { + *error = tr("Cannot open file '%1': %2") + .arg(nativePath, file->errorString()); + } + file.clear(); + } + return file; +} + +void AbstractQt4MaemoTarget::handleFromMapFinished() +{ + handleTargetAdded(this); +} + +void AbstractQt4MaemoTarget::handleTargetAdded(ProjectExplorer::Target *target) +{ + if (target != this) + return; + + if (!project()->rootProjectNode()) { + // Project is not fully setup yet, happens on new project + // we wait for the fromMapFinished that comes afterwards + return; + } + + disconnect(project(), SIGNAL(fromMapFinished()), + this, SLOT(handleFromMapFinished())); + disconnect(project(), SIGNAL(addedTarget(ProjectExplorer::Target*)), + this, SLOT(handleTargetAdded(ProjectExplorer::Target*))); + connect(project(), SIGNAL(aboutToRemoveTarget(ProjectExplorer::Target*)), + SLOT(handleTargetToBeRemoved(ProjectExplorer::Target*))); + const ActionStatus status = createTemplates(); + if (status == ActionFailed) + return; + if (status == ActionSuccessful) // Don't do this when the packaging data already exists. + initPackagingSettingsFromOtherTarget(); + handleTargetAddedSpecial(); + if (status == ActionSuccessful) { + const QStringList &files = packagingFilePaths(); + if (!files.isEmpty()) { + const QString list = QLatin1String("
  • ") + files.join(QLatin1String("
  • ")) + + QLatin1String("
"); + QMessageBox::StandardButton button = QMessageBox::question(Core::ICore::instance()->mainWindow(), + tr("Add Packaging Files to Project"), + tr("Qt Creator has set up the following files to enable " + "packaging:\n %1\nDo you want to add them to the project?") + .arg(list), QMessageBox::Yes | QMessageBox::No); + if (button == QMessageBox::Yes) { + ProjectExplorer::ProjectExplorerPlugin::instance() + ->addExistingFiles(project()->rootProjectNode(), files); + } + } + } + + m_isInitialized = true; +} + +void AbstractQt4MaemoTarget::handleTargetToBeRemoved(ProjectExplorer::Target *target) +{ + if (target != this) + return; + if (!targetCanBeRemoved()) + return; + + Core::ICore * const core = Core::ICore::instance(); + const int answer = QMessageBox::warning(core->mainWindow(), + tr("Qt Creator"), tr("Do you want to remove the packaging file(s) " + "associated with the target '%1'?").arg(displayName()), + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + if (answer == QMessageBox::No) + return; + const QStringList pkgFilePaths = packagingFilePaths(); + if (!pkgFilePaths.isEmpty()) { + project()->rootProjectNode()->removeFiles(ProjectExplorer::UnknownFileType, + pkgFilePaths); + Core::IVersionControl * const vcs = core->vcsManager() + ->findVersionControlForDirectory(QFileInfo(pkgFilePaths.first()).dir().path()); + if (vcs && vcs->supportsOperation(Core::IVersionControl::DeleteOperation)) { + foreach (const QString &filePath, pkgFilePaths) + vcs->vcsDelete(filePath); + } + } + delete m_filesWatcher; + removeTarget(); + QString error; + const QString packagingPath = project()->projectDirectory() + + QLatin1Char('/') + PackagingDirName; + const QStringList otherContents = QDir(packagingPath).entryList(QDir::Dirs + | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot); + if (otherContents.isEmpty()) { + if (!Utils::FileUtils::removeRecursively(packagingPath, &error)) + qDebug("%s", qPrintable(error)); + } +} + +AbstractQt4MaemoTarget::ActionStatus AbstractQt4MaemoTarget::createTemplates() +{ + QDir projectDir(project()->projectDirectory()); + if (!projectDir.exists(PackagingDirName) + && !projectDir.mkdir(PackagingDirName)) { + raiseError(tr("Error creating packaging directory '%1'.") + .arg(PackagingDirName)); + return ActionFailed; + } + + return createSpecialTemplates(); +} + +bool AbstractQt4MaemoTarget::initPackagingSettingsFromOtherTarget() +{ + bool success = true; + foreach (const Target * const target, project()->targets()) { + const AbstractQt4MaemoTarget * const maemoTarget + = qobject_cast(target); + if (maemoTarget && maemoTarget != this && maemoTarget->m_isInitialized) { + if (!setProjectVersionInternal(maemoTarget->projectVersion())) + success = false; + if (!setPackageNameInternal(maemoTarget->packageName())) + success = false; + if (!setShortDescriptionInternal(maemoTarget->shortDescription())) + success = false; + break; + } + } + return initAdditionalPackagingSettingsFromOtherTarget() && success; +} + +void AbstractQt4MaemoTarget::raiseError(const QString &reason) +{ + QMessageBox::critical(0, tr("Error creating MeeGo templates"), reason); +} + +AbstractDebBasedQt4MaemoTarget::AbstractDebBasedQt4MaemoTarget(Qt4Project *parent, + const QString &id) : AbstractQt4MaemoTarget(parent, id) +{ +} + +AbstractDebBasedQt4MaemoTarget::~AbstractDebBasedQt4MaemoTarget() {} + +QString AbstractDebBasedQt4MaemoTarget::projectVersion(QString *error) const +{ + QSharedPointer changeLog = openFile(changeLogFilePath(), + QIODevice::ReadOnly, error); + if (!changeLog) + return QString(); + const QByteArray &firstLine = changeLog->readLine(); + const int openParenPos = firstLine.indexOf('('); + if (openParenPos == -1) { + if (error) { + *error = tr("Debian changelog file '%1' has unexpected format.") + .arg(QDir::toNativeSeparators(changeLog->fileName())); + } + return QString(); + } + const int closeParenPos = firstLine.indexOf(')', openParenPos); + if (closeParenPos == -1) { + if (error) { + *error = tr("Debian changelog file '%1' has unexpected format.") + .arg(QDir::toNativeSeparators(changeLog->fileName())); + } + return QString(); + } + return QString::fromUtf8(firstLine.mid(openParenPos + 1, + closeParenPos - openParenPos - 1).data()); +} + +bool AbstractDebBasedQt4MaemoTarget::setProjectVersionInternal(const QString &version, + QString *error) +{ + const QString filePath = changeLogFilePath(); + Utils::FileReader reader; + if (!reader.fetch(filePath, error)) + return false; + QString content = QString::fromUtf8(reader.data()); + if (content.contains(QLatin1Char('(') + version + QLatin1Char(')'))) { + if (error) { + *error = tr("Refusing to update changelog file: Already contains version '%1'.") + .arg(version); + } + return false; + } + + int maintainerOffset = content.indexOf(QLatin1String("\n -- ")); + const int eolOffset = content.indexOf(QLatin1Char('\n'), maintainerOffset+1); + if (maintainerOffset == -1 || eolOffset == -1) { + if (error) { + *error = tr("Cannot update changelog: Invalid format (no maintainer entry found)."); + } + return false; + } + + ++maintainerOffset; + const QDateTime currentDateTime = QDateTime::currentDateTime(); + QDateTime utcDateTime = QDateTime(currentDateTime); + utcDateTime.setTimeSpec(Qt::UTC); + int utcOffsetSeconds = currentDateTime.secsTo(utcDateTime); + QChar sign; + if (utcOffsetSeconds < 0) { + utcOffsetSeconds = -utcOffsetSeconds; + sign = QLatin1Char('-'); + } else { + sign = QLatin1Char('+'); + } + const int utcOffsetMinutes = (utcOffsetSeconds / 60) % 60; + const int utcOffsetHours = utcOffsetSeconds / 3600; + const QString dateString = QString::fromLatin1("%1 %2%3%4") + .arg(currentDateTime.toString(QLatin1String("ddd, dd MMM yyyy hh:mm:ss"))).arg(sign) + .arg(utcOffsetHours, 2, 10, QLatin1Char('0')) + .arg(utcOffsetMinutes, 2, 10, QLatin1Char('0')); + const QString maintainerLine = content.mid(maintainerOffset, eolOffset - maintainerOffset + 1) + .replace(QRegExp(QLatin1String("> [^\\n]*\n")), + QString::fromLocal8Bit("> %1").arg(dateString)); + QString versionLine = content.left(content.indexOf(QLatin1Char('\n'))) + .replace(QRegExp(QLatin1String("\\([a-zA-Z0-9_\\.]+\\)")), + QLatin1Char('(') + version + QLatin1Char(')')); + const QString newEntry = versionLine + QLatin1String("\n * \n\n") + + maintainerLine + QLatin1String("\n\n"); + content.prepend(newEntry); + Core::FileChangeBlocker update(filePath); + Utils::FileSaver saver(filePath); + saver.write(content.toUtf8()); + return saver.finalize(error); +} + +QIcon AbstractDebBasedQt4MaemoTarget::packageManagerIcon(QString *error) const +{ + const QByteArray &base64Icon = controlFileFieldValue(IconFieldName, true); + if (base64Icon.isEmpty()) + return QIcon(); + QPixmap pixmap; + if (!pixmap.loadFromData(QByteArray::fromBase64(base64Icon))) { + if (error) + *error = tr("Invalid icon data in Debian control file."); + return QIcon(); + } + return QIcon(pixmap); +} + +bool AbstractDebBasedQt4MaemoTarget::setPackageManagerIconInternal(const QString &iconFilePath, + QString *error) +{ + const QString filePath = controlFilePath(); + Utils::FileReader reader; + if (!reader.fetch(filePath, error)) + return false; + const QPixmap pixmap(iconFilePath); + if (pixmap.isNull()) { + if (error) + *error = tr("Could not read image file '%1'.").arg(iconFilePath); + return false; + } + + QByteArray iconAsBase64; + QBuffer buffer(&iconAsBase64); + buffer.open(QIODevice::WriteOnly); + if (!pixmap.scaled(packageManagerIconSize()).save(&buffer, + QFileInfo(iconFilePath).suffix().toAscii())) { + if (error) + *error = tr("Could not export image file '%1'.").arg(iconFilePath); + return false; + } + buffer.close(); + iconAsBase64 = iconAsBase64.toBase64(); + QByteArray contents = reader.data(); + const QByteArray iconFieldNameWithColon = IconFieldName + ':'; + const int iconFieldPos = contents.startsWith(iconFieldNameWithColon) + ? 0 : contents.indexOf('\n' + iconFieldNameWithColon); + if (iconFieldPos == -1) { + if (!contents.endsWith('\n')) + contents += '\n'; + contents.append(iconFieldNameWithColon).append(' ').append(iconAsBase64) + .append('\n'); + } else { + const int oldIconStartPos = (iconFieldPos != 0) + iconFieldPos + + iconFieldNameWithColon.length(); + int nextEolPos = contents.indexOf('\n', oldIconStartPos); + while (nextEolPos != -1 && nextEolPos != contents.length() - 1 + && contents.at(nextEolPos + 1) != '\n' + && (contents.at(nextEolPos + 1) == '#' + || std::isspace(contents.at(nextEolPos + 1)))) + nextEolPos = contents.indexOf('\n', nextEolPos + 1); + if (nextEolPos == -1) + nextEolPos = contents.length(); + contents.replace(oldIconStartPos, nextEolPos - oldIconStartPos, + ' ' + iconAsBase64); + } + Core::FileChangeBlocker update(filePath); + Utils::FileSaver saver(filePath); + saver.write(contents); + return saver.finalize(error); +} + +QString AbstractDebBasedQt4MaemoTarget::packageName() const +{ + return QString::fromUtf8(controlFileFieldValue(NameFieldName, false)); +} + +bool AbstractDebBasedQt4MaemoTarget::setPackageNameInternal(const QString &packageName) +{ + const QString oldPackageName = this->packageName(); + + if (!setControlFieldValue(NameFieldName, packageName.toUtf8())) + return false; + if (!setControlFieldValue("Source", packageName.toUtf8())) + return false; + + Utils::FileReader reader; + if (!reader.fetch(changeLogFilePath())) + return false; + QString changelogContents = QString::fromUtf8(reader.data()); + QRegExp pattern(QLatin1String("[^\\s]+( \\(\\d\\.\\d\\.\\d\\))")); + changelogContents.replace(pattern, packageName + QLatin1String("\\1")); + Utils::FileSaver saver(changeLogFilePath()); + saver.write(changelogContents.toUtf8()); + if (!saver.finalize()) + return false; + + if (!reader.fetch(rulesFilePath())) + return false; + QByteArray rulesContents = reader.data(); + const QString oldString = QLatin1String("debian/") + oldPackageName; + const QString newString = QLatin1String("debian/") + packageName; + rulesContents.replace(oldString.toUtf8(), newString.toUtf8()); + Utils::FileSaver rulesSaver(rulesFilePath()); + rulesSaver.write(rulesContents); + return rulesSaver.finalize(); +} + +QString AbstractDebBasedQt4MaemoTarget::packageManagerName() const +{ + return QString::fromUtf8(controlFileFieldValue(packageManagerNameFieldName(), false)); +} + +bool AbstractDebBasedQt4MaemoTarget::setPackageManagerName(const QString &name, + QString *error) +{ + bool success = true; + foreach (Target * const t, project()->targets()) { + AbstractDebBasedQt4MaemoTarget * const target + = qobject_cast(t); + if (target) { + if (!target->setPackageManagerNameInternal(name, error)) + success = false; + } + } + return success; +} + +bool AbstractDebBasedQt4MaemoTarget::setPackageManagerNameInternal(const QString &name, + QString *error) +{ + Q_UNUSED(error); + return setControlFieldValue(packageManagerNameFieldName(), name.toUtf8()); +} + +QString AbstractDebBasedQt4MaemoTarget::shortDescription() const +{ + return QString::fromUtf8(controlFileFieldValue(ShortDescriptionFieldName, false)); +} + +QString AbstractDebBasedQt4MaemoTarget::packageFileName() const +{ + return QString::fromUtf8(controlFileFieldValue(PackageFieldName, false)) + + QLatin1Char('_') + projectVersion() + QLatin1String("_armel.deb"); +} + +bool AbstractDebBasedQt4MaemoTarget::setShortDescriptionInternal(const QString &description) +{ + return setControlFieldValue(ShortDescriptionFieldName, description.toUtf8()); +} + +QString AbstractDebBasedQt4MaemoTarget::debianDirPath() const +{ + return project()->projectDirectory() + QLatin1Char('/') + PackagingDirName + + QLatin1Char('/') + debianDirName(); +} + +QStringList AbstractDebBasedQt4MaemoTarget::debianFiles() const +{ + return QDir(debianDirPath()) + .entryList(QDir::Files, QDir::Name | QDir::IgnoreCase); +} + +QString AbstractDebBasedQt4MaemoTarget::changeLogFilePath() const +{ + return debianDirPath() + QLatin1String("/changelog"); +} + +QString AbstractDebBasedQt4MaemoTarget::controlFilePath() const +{ + return debianDirPath() + QLatin1String("/control"); +} + +QString AbstractDebBasedQt4MaemoTarget::rulesFilePath() const +{ + return debianDirPath() + QLatin1String("/rules"); +} + +QByteArray AbstractDebBasedQt4MaemoTarget::controlFileFieldValue(const QString &key, + bool multiLine) const +{ + QByteArray value; + Utils::FileReader reader; + if (!reader.fetch(controlFilePath())) + return value; + const QByteArray &contents = reader.data(); + const int keyPos = contents.indexOf(key.toUtf8() + ':'); + if (keyPos == -1) + return value; + int valueStartPos = keyPos + key.length() + 1; + int valueEndPos = contents.indexOf('\n', keyPos); + if (valueEndPos == -1) + valueEndPos = contents.count(); + value = contents.mid(valueStartPos, valueEndPos - valueStartPos).trimmed(); + if (multiLine) { + Q_FOREVER { + valueStartPos = valueEndPos + 1; + if (valueStartPos >= contents.count()) + break; + const char firstChar = contents.at(valueStartPos); + if (firstChar == '#' || isspace(firstChar)) { + valueEndPos = contents.indexOf('\n', valueStartPos); + if (valueEndPos == -1) + valueEndPos = contents.count(); + if (firstChar != '#') { + value += contents.mid(valueStartPos, + valueEndPos - valueStartPos).trimmed(); + } + } else { + break; + } + } + } + return value; +} + +bool AbstractDebBasedQt4MaemoTarget::setControlFieldValue(const QByteArray &fieldName, + const QByteArray &fieldValue) +{ + Utils::FileReader reader; + if (!reader.fetch(controlFilePath())) + return false; + QByteArray contents = reader.data(); + if (adaptControlFileField(contents, fieldName, fieldValue)) { + Core::FileChangeBlocker update(controlFilePath()); + Utils::FileSaver saver(controlFilePath()); + saver.write(contents); + return saver.finalize(); + } + return true; +} + +bool AbstractDebBasedQt4MaemoTarget::adaptControlFileField(QByteArray &document, + const QByteArray &fieldName, const QByteArray &newFieldValue) +{ + return adaptTagValue(document, fieldName, newFieldValue, true); +} + +void AbstractDebBasedQt4MaemoTarget::handleTargetAddedSpecial() +{ + if (controlFileFieldValue(IconFieldName, true).isEmpty()) { + // Such a file is created by the mobile wizards. + const QString iconPath = project()->projectDirectory() + + QLatin1Char('/') + project()->displayName() + + QLatin1String("64.png"); + if (QFileInfo(iconPath).exists()) + setPackageManagerIcon(iconPath); + } + + m_filesWatcher->addDirectory(debianDirPath(), Utils::FileSystemWatcher::WatchAllChanges); + m_controlFile = new WatchableFile(controlFilePath(), this); + connect(m_controlFile, SIGNAL(modified()), SIGNAL(controlChanged())); + m_changeLogFile = new WatchableFile(changeLogFilePath(), this); + connect(m_changeLogFile, SIGNAL(modified()), SIGNAL(changeLogChanged())); + Core::FileManager::instance()->addFiles(QList() + << m_controlFile << m_changeLogFile); + connect(m_filesWatcher, SIGNAL(directoryChanged(QString)), this, + SLOT(handleDebianDirContentsChanged())); + handleDebianDirContentsChanged(); + emit controlChanged(); + emit changeLogChanged(); +} + +bool AbstractDebBasedQt4MaemoTarget::targetCanBeRemoved() const +{ + return QFileInfo(debianDirPath()).exists(); +} + +void AbstractDebBasedQt4MaemoTarget::removeTarget() +{ + QString error; + if (!Utils::FileUtils::removeRecursively(debianDirPath(), &error)) + qDebug("%s", qPrintable(error)); +} + +void AbstractDebBasedQt4MaemoTarget::handleDebianDirContentsChanged() +{ + emit debianDirContentsChanged(); +} + +AbstractQt4MaemoTarget::ActionStatus AbstractDebBasedQt4MaemoTarget::createSpecialTemplates() +{ + if (QFileInfo(debianDirPath()).exists()) + return NoActionRequired; + QDir projectDir(project()->projectDirectory()); + QProcess dh_makeProc; + QString error; + const Qt4BuildConfiguration * const bc = qobject_cast(activeBuildConfiguration()); + AbstractMaemoPackageCreationStep::preparePackagingProcess(&dh_makeProc, bc, + projectDir.path() + QLatin1Char('/') + PackagingDirName); + const QString dhMakeDebianDir = projectDir.path() + QLatin1Char('/') + + PackagingDirName + QLatin1String("/debian"); + Utils::FileUtils::removeRecursively(dhMakeDebianDir, &error); + const QStringList dh_makeArgs = QStringList() << QLatin1String("dh_make") + << QLatin1String("-s") << QLatin1String("-n") << QLatin1String("-p") + << (defaultPackageFileName() + QLatin1Char('_') + + AbstractMaemoPackageCreationStep::DefaultVersionNumber); + QtSupport::BaseQtVersion *lqt = activeQt4BuildConfiguration()->qtVersion(); + if (!lqt) { + raiseError(tr("Unable to create Debian templates: No Qt version set")); + return ActionFailed; + } + if (!MaemoGlobal::callMad(dh_makeProc, dh_makeArgs, lqt->qmakeCommand(), true) + || !dh_makeProc.waitForStarted()) { + raiseError(tr("Unable to create Debian templates: dh_make failed (%1)") + .arg(dh_makeProc.errorString())); + return ActionFailed; + } + dh_makeProc.write("\n"); // Needs user input. + dh_makeProc.waitForFinished(-1); + if (dh_makeProc.error() != QProcess::UnknownError + || dh_makeProc.exitCode() != 0) { + raiseError(tr("Unable to create debian templates: dh_make failed (%1)") + .arg(dh_makeProc.errorString())); + return ActionFailed; + } + + if (!QFile::rename(dhMakeDebianDir, debianDirPath())) { + raiseError(tr("Unable to move new debian directory to '%1'.") + .arg(QDir::toNativeSeparators(debianDirPath()))); + Utils::FileUtils::removeRecursively(dhMakeDebianDir, &error); + return ActionFailed; + } + + QDir debianDir(debianDirPath()); + const QStringList &files = debianDir.entryList(QDir::Files); + foreach (const QString &fileName, files) { + if (fileName.endsWith(QLatin1String(".ex"), Qt::CaseInsensitive) + || fileName.compare(QLatin1String("README.debian"), Qt::CaseInsensitive) == 0 + || fileName.compare(QLatin1String("dirs"), Qt::CaseInsensitive) == 0 + || fileName.compare(QLatin1String("docs"), Qt::CaseInsensitive) == 0) { + debianDir.remove(fileName); + } + } + + return adaptRulesFile() && adaptControlFile() + ? ActionSuccessful : ActionFailed; +} + +bool AbstractDebBasedQt4MaemoTarget::adaptRulesFile() +{ + Utils::FileReader reader; + if (!reader.fetch(rulesFilePath())) { + raiseError(reader.errorString()); + return false; + } + QByteArray rulesContents = reader.data(); + const QByteArray comment("# Uncomment this line for use without Qt Creator"); + rulesContents.replace("DESTDIR", "INSTALL_ROOT"); + rulesContents.replace("dh_shlibdeps", "# dh_shlibdeps " + comment); + rulesContents.replace("# Add here commands to configure the package.", + "# qmake PREFIX=/usr" + comment); + rulesContents.replace("$(MAKE)\n", "# $(MAKE) " + comment + '\n'); + + // Would be the right solution, but does not work (on Windows), + // because dpkg-genchanges doesn't know about it (and can't be told). + // rulesContents.replace("dh_builddeb", "dh_builddeb --destdir=."); + + Utils::FileSaver saver(rulesFilePath()); + saver.write(rulesContents); + if (!saver.finalize()) { + raiseError(saver.errorString()); + return false; + } + return true; +} + +bool AbstractDebBasedQt4MaemoTarget::adaptControlFile() +{ + Utils::FileReader reader; + if (!reader.fetch(controlFilePath())) { + raiseError(reader.errorString()); + return false; + } + QByteArray controlContents = reader.data(); + + adaptControlFileField(controlContents, "Section", defaultSection()); + adaptControlFileField(controlContents, "Priority", "optional"); + adaptControlFileField(controlContents, packageManagerNameFieldName(), + project()->displayName().toUtf8()); + const int buildDependsOffset = controlContents.indexOf("Build-Depends:"); + if (buildDependsOffset == -1) { + qDebug("Unexpected: no Build-Depends field in debian control file."); + } else { + int buildDependsNewlineOffset + = controlContents.indexOf('\n', buildDependsOffset); + if (buildDependsNewlineOffset == -1) { + controlContents += '\n'; + buildDependsNewlineOffset = controlContents.length() - 1; + } + controlContents.insert(buildDependsNewlineOffset, + ", libqt4-dev"); + } + + addAdditionalControlFileFields(controlContents); + Utils::FileSaver saver(controlFilePath()); + saver.write(controlContents); + if (!saver.finalize()) { + raiseError(saver.errorString()); + return false; + } + return true; +} + +bool AbstractDebBasedQt4MaemoTarget::initAdditionalPackagingSettingsFromOtherTarget() +{ + foreach (const Target * const t, project()->targets()) { + const AbstractDebBasedQt4MaemoTarget *target + = qobject_cast(t); + if (target && target != this) { + return setControlFieldValue(IconFieldName, + target->controlFileFieldValue(IconFieldName, true)); + } + } + return true; +} + +QStringList AbstractDebBasedQt4MaemoTarget::packagingFilePaths() const +{ + QStringList filePaths; + const QString parentDir = debianDirPath(); + foreach (const QString &fileName, debianFiles()) + filePaths << parentDir + QLatin1Char('/') + fileName; + return filePaths; +} + +QString AbstractDebBasedQt4MaemoTarget::defaultPackageFileName() const +{ + QString packageName = project()->displayName().toLower(); + + // We also replace dots, because OVI store chokes on them. + const QRegExp legalLetter(QLatin1String("[a-z0-9+-]"), Qt::CaseSensitive, + QRegExp::WildcardUnix); + + for (int i = 0; i < packageName.length(); ++i) { + if (!legalLetter.exactMatch(packageName.mid(i, 1))) + packageName[i] = QLatin1Char('-'); + } + return packageName; +} + +bool AbstractDebBasedQt4MaemoTarget::setPackageManagerIcon(const QString &iconFilePath, + QString *error) +{ + bool success = true; + foreach (Target * const target, project()->targets()) { + AbstractDebBasedQt4MaemoTarget* const maemoTarget + = qobject_cast(target); + if (maemoTarget) { + if (!maemoTarget->setPackageManagerIconInternal(iconFilePath, error)) + success = false; + } + } + return success; +} + +AbstractRpmBasedQt4MaemoTarget::AbstractRpmBasedQt4MaemoTarget(Qt4Project *parent, + const QString &id) : AbstractQt4MaemoTarget(parent, id) +{ +} + +AbstractRpmBasedQt4MaemoTarget::~AbstractRpmBasedQt4MaemoTarget() +{ +} + +QString AbstractRpmBasedQt4MaemoTarget::specFilePath() const +{ + const QLatin1Char sep('/'); + return project()->projectDirectory() + sep + PackagingDirName + sep + + specFileName(); +} + +QString AbstractRpmBasedQt4MaemoTarget::projectVersion(QString *error) const +{ + return QString::fromUtf8(getValueForTag(VersionTag, error)); +} + +bool AbstractRpmBasedQt4MaemoTarget::setProjectVersionInternal(const QString &version, + QString *error) +{ + return setValueForTag(VersionTag, version.toUtf8(), error); +} + +QString AbstractRpmBasedQt4MaemoTarget::packageName() const +{ + return QString::fromUtf8(getValueForTag(NameTag, 0)); +} + +bool AbstractRpmBasedQt4MaemoTarget::setPackageNameInternal(const QString &name) +{ + return setValueForTag(NameTag, name.toUtf8(), 0); +} + +QString AbstractRpmBasedQt4MaemoTarget::shortDescription() const +{ + return QString::fromUtf8(getValueForTag(SummaryTag, 0)); +} + +QString AbstractRpmBasedQt4MaemoTarget::packageFileName() const +{ + QtSupport::BaseQtVersion *lqt = activeQt4BuildConfiguration()->qtVersion(); + if (!lqt) + return QString(); + return packageName() + QLatin1Char('-') + projectVersion() + QLatin1Char('-') + + QString::fromUtf8(getValueForTag(ReleaseTag, 0)) + QLatin1Char('.') + + MaemoGlobal::architecture(lqt->qmakeCommand()) + + QLatin1String(".rpm"); +} + +bool AbstractRpmBasedQt4MaemoTarget::setShortDescriptionInternal(const QString &description) +{ + return setValueForTag(SummaryTag, description.toUtf8(), 0); +} + +AbstractQt4MaemoTarget::ActionStatus AbstractRpmBasedQt4MaemoTarget::createSpecialTemplates() +{ + if (QFileInfo(specFilePath()).exists()) + return NoActionRequired; + QByteArray initialContent( + "Name: %%name%%\n" + "Summary: \n" + "Version: 0.0.1\n" + "Release: 1\n" + "License: \n" + "Group: \n" + "%description\n" + "\n" + "\n" + "%prep\n" + "%setup -q\n" + "\n" + "%build\n" + "# You can leave this empty for use with Qt Creator." + "\n" + "%install\n" + "rm -rf %{buildroot}\n" + "make INSTALL_ROOT=%{buildroot} install\n" + "\n" + "%clean\n" + "rm -rf %{buildroot}\n" + "\n" + "BuildRequires: \n" + "# %define _unpackaged_files_terminate_build 0\n" + "%files\n" + "%defattr(-,root,root,-)" + "/usr\n" + "/opt\n" + "# Add additional files to be included in the package here.\n" + "%pre\n" + "# Add pre-install scripts here." + "%post\n" + "/sbin/ldconfig # For shared libraries\n" + "%preun\n" + "# Add pre-uninstall scripts here." + "%postun\n" + "# Add post-uninstall scripts here." + ); + initialContent.replace("%%name%%", project()->displayName().toUtf8()); + Utils::FileSaver saver(specFilePath()); + saver.write(initialContent); + return saver.finalize() ? ActionSuccessful : ActionFailed; +} + +void AbstractRpmBasedQt4MaemoTarget::handleTargetAddedSpecial() +{ + m_specFile = new WatchableFile(specFilePath(), this); + connect(m_specFile, SIGNAL(modified()), SIGNAL(specFileChanged())); + Core::FileManager::instance()->addFile(m_specFile); + emit specFileChanged(); +} + +bool AbstractRpmBasedQt4MaemoTarget::targetCanBeRemoved() const +{ + return QFileInfo(specFilePath()).exists(); +} + +void AbstractRpmBasedQt4MaemoTarget::removeTarget() +{ + QFile::remove(specFilePath()); +} + +bool AbstractRpmBasedQt4MaemoTarget::initAdditionalPackagingSettingsFromOtherTarget() +{ + // Nothing to do here for now. + return true; +} + +QByteArray AbstractRpmBasedQt4MaemoTarget::getValueForTag(const QByteArray &tag, + QString *error) const +{ + Utils::FileReader reader; + if (!reader.fetch(specFilePath(), error)) + return QByteArray(); + const QByteArray &content = reader.data(); + const QByteArray completeTag = tag.toLower() + ':'; + int index = content.toLower().indexOf(completeTag); + if (index == -1) + return QByteArray(); + index += completeTag.count(); + int endIndex = content.indexOf('\n', index); + if (endIndex == -1) + endIndex = content.count(); + return content.mid(index, endIndex - index).trimmed(); +} + +bool AbstractRpmBasedQt4MaemoTarget::setValueForTag(const QByteArray &tag, + const QByteArray &value, QString *error) +{ + Utils::FileReader reader; + if (!reader.fetch(specFilePath(), error)) + return false; + QByteArray content = reader.data(); + if (adaptTagValue(content, tag, value, false)) { + Utils::FileSaver saver(specFilePath()); + saver.write(content); + return saver.finalize(error); + } + return true; +} + +Qt4Maemo5Target::Qt4Maemo5Target(Qt4Project *parent, const QString &id) + : AbstractDebBasedQt4MaemoTarget(parent, id) +{ + setDisplayName(defaultDisplayName()); +} + +Qt4Maemo5Target::~Qt4Maemo5Target() {} + +QString Qt4Maemo5Target::defaultDisplayName() +{ + return QApplication::translate("Qt4ProjectManager::Qt4Target", "Maemo5", + "Qt4 Maemo5 target display name"); +} + +void Qt4Maemo5Target::addAdditionalControlFileFields(QByteArray &controlContents) +{ + Q_UNUSED(controlContents); +} + +QString Qt4Maemo5Target::debianDirName() const +{ + return QLatin1String("debian_fremantle"); +} + +QByteArray Qt4Maemo5Target::packageManagerNameFieldName() const +{ + return "XB-Maemo-Display-Name"; +} + +QSize Qt4Maemo5Target::packageManagerIconSize() const +{ + return QSize(48, 48); +} + +QByteArray Qt4Maemo5Target::defaultSection() const +{ + return "user/hidden"; +} + +Qt4HarmattanTarget::Qt4HarmattanTarget(Qt4Project *parent, const QString &id) + : AbstractDebBasedQt4MaemoTarget(parent, id) +{ + setDisplayName(defaultDisplayName()); +} + +Qt4HarmattanTarget::~Qt4HarmattanTarget() {} + +QString Qt4HarmattanTarget::defaultDisplayName() +{ + return QApplication::translate("Qt4ProjectManager::Qt4Target", "Harmattan", + "Qt4 Harmattan target display name"); +} + +QString Qt4HarmattanTarget::aegisManifestFileName() +{ + return QLatin1String("manifest.aegis"); +} + +void Qt4HarmattanTarget::handleTargetAddedSpecial() +{ + AbstractDebBasedQt4MaemoTarget::handleTargetAddedSpecial(); + QFile aegisFile(debianDirPath() + QLatin1Char('/') + aegisManifestFileName()); + if (!aegisFile.exists()) + aegisFile.open(QIODevice::WriteOnly); +} + +void Qt4HarmattanTarget::addAdditionalControlFileFields(QByteArray &controlContents) +{ + Q_UNUSED(controlContents); +} + +QString Qt4HarmattanTarget::debianDirName() const +{ + return QLatin1String("debian_harmattan"); +} + +QByteArray Qt4HarmattanTarget::packageManagerNameFieldName() const +{ + return "XSBC-Maemo-Display-Name"; +} + +QSize Qt4HarmattanTarget::packageManagerIconSize() const +{ + return QSize(64, 64); +} + +QByteArray Qt4HarmattanTarget::defaultSection() const +{ + return "user/other"; +} + + +Qt4MeegoTarget::Qt4MeegoTarget(Qt4Project *parent, const QString &id) + : AbstractRpmBasedQt4MaemoTarget(parent, id) +{ + setDisplayName(defaultDisplayName()); +} + +Qt4MeegoTarget::~Qt4MeegoTarget() {} + +QString Qt4MeegoTarget::defaultDisplayName() +{ + return QApplication::translate("Qt4ProjectManager::Qt4Target", + "Meego", "Qt4 Meego target display name"); +} + +QString Qt4MeegoTarget::specFileName() const +{ + return QLatin1String("meego.spec"); +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/qt4maemotarget.h b/src/plugins/madde/qt4maemotarget.h new file mode 100644 index 00000000000..822678f140f --- /dev/null +++ b/src/plugins/madde/qt4maemotarget.h @@ -0,0 +1,296 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef QT4MAEMOTARGET_H +#define QT4MAEMOTARGET_H + +#include + +#include +#include +#include + +QT_FORWARD_DECLARE_CLASS(QFile) + +namespace Qt4ProjectManager { +class Qt4Project; +class Qt4BuildConfigurationFactory; +} +namespace Utils { class FileSystemWatcher; } + +namespace Madde { +namespace Internal { +class Qt4MaemoDeployConfigurationFactory; +class WatchableFile; + +class AbstractQt4MaemoTarget : public Qt4ProjectManager::Qt4BaseTarget +{ + friend class Qt4MaemoTargetFactory; + Q_OBJECT +public: + explicit AbstractQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, + const QString &id); + virtual ~AbstractQt4MaemoTarget(); + + ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const; + void createApplicationProFiles(); + QList runConfigurationsForNode(ProjectExplorer::Node *n); + QList possibleToolChains(ProjectExplorer::BuildConfiguration *bc) const; + + virtual bool allowsRemoteMounts() const = 0; + virtual bool allowsPackagingDisabling() const = 0; + virtual bool allowsQmlDebugging() const = 0; + + virtual QString projectVersion(QString *error = 0) const = 0; + virtual QString packageName() const = 0; + virtual QString shortDescription() const = 0; + virtual QString packageFileName() const = 0; + + bool setProjectVersion(const QString &version, QString *error = 0); + bool setPackageName(const QString &packageName); + bool setShortDescription(const QString &description); + +protected: + enum ActionStatus { NoActionRequired, ActionSuccessful, ActionFailed }; + + void raiseError(const QString &reason); + QSharedPointer openFile(const QString &filePath, + QIODevice::OpenMode mode, QString *error) const; + + Utils::FileSystemWatcher* const m_filesWatcher; + +private slots: + void handleTargetAdded(ProjectExplorer::Target *target); + void handleFromMapFinished(); + void handleTargetToBeRemoved(ProjectExplorer::Target *target); + +private: + virtual bool setProjectVersionInternal(const QString &version, + QString *error = 0) = 0; + virtual bool setPackageNameInternal(const QString &packageName) = 0; + virtual bool setShortDescriptionInternal(const QString &description) = 0; + virtual ActionStatus createSpecialTemplates() = 0; + virtual void handleTargetAddedSpecial() = 0; + virtual bool targetCanBeRemoved() const = 0; + virtual void removeTarget() = 0; + virtual QStringList packagingFilePaths() const = 0; + + ActionStatus createTemplates(); + bool initPackagingSettingsFromOtherTarget(); + virtual bool initAdditionalPackagingSettingsFromOtherTarget() = 0; + + Qt4ProjectManager::Qt4BuildConfigurationFactory *m_buildConfigurationFactory; + bool m_isInitialized; +}; + + +class AbstractDebBasedQt4MaemoTarget : public AbstractQt4MaemoTarget +{ + Q_OBJECT +public: + AbstractDebBasedQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, + const QString &id); + ~AbstractDebBasedQt4MaemoTarget(); + + QString debianDirPath() const; + QStringList debianFiles() const; + + virtual QString debianDirName() const = 0; + virtual QString projectVersion(QString *error = 0) const; + virtual QString packageName() const; + virtual QString shortDescription() const; + virtual QString packageFileName() const; + + bool setPackageManagerIcon(const QString &iconFilePath, QString *error = 0); + QIcon packageManagerIcon(QString *error = 0) const; + bool setPackageManagerName(const QString &name, QString *error = 0); + QString packageManagerName() const; + + virtual QSize packageManagerIconSize() const = 0; + +signals: + void debianDirContentsChanged(); + void changeLogChanged(); + void controlChanged(); + +protected: + virtual void handleTargetAddedSpecial(); + bool adaptControlFileField(QByteArray &document, const QByteArray &fieldName, + const QByteArray &newFieldValue); + +private slots: + void handleDebianDirContentsChanged(); + +private: + virtual bool setProjectVersionInternal(const QString &version, + QString *error = 0); + virtual bool setPackageNameInternal(const QString &packageName); + virtual bool setShortDescriptionInternal(const QString &description); + + virtual ActionStatus createSpecialTemplates(); + virtual bool targetCanBeRemoved() const; + virtual void removeTarget(); + virtual bool initAdditionalPackagingSettingsFromOtherTarget(); + virtual QStringList packagingFilePaths() const; + + virtual void addAdditionalControlFileFields(QByteArray &controlContents) = 0; + virtual QByteArray packageManagerNameFieldName() const = 0; + virtual QByteArray defaultSection() const = 0; + + QString changeLogFilePath() const; + QString controlFilePath() const; + QString rulesFilePath() const; + QByteArray controlFileFieldValue(const QString &key, bool multiLine) const; + bool setControlFieldValue(const QByteArray &fieldName, + const QByteArray &fieldValue); + bool adaptRulesFile(); + bool adaptControlFile(); + bool setPackageManagerIconInternal(const QString &iconFilePath, + QString *error = 0); + QString defaultPackageFileName() const; + bool setPackageManagerNameInternal(const QString &name, QString *error = 0); + + WatchableFile *m_controlFile; + WatchableFile *m_changeLogFile; +}; + + +class AbstractRpmBasedQt4MaemoTarget : public AbstractQt4MaemoTarget +{ + Q_OBJECT +public: + AbstractRpmBasedQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, + const QString &id); + ~AbstractRpmBasedQt4MaemoTarget(); + + virtual bool allowsRemoteMounts() const { return false; } + virtual bool allowsPackagingDisabling() const { return false; } + virtual bool allowsQmlDebugging() const { return false; } + + virtual QString projectVersion(QString *error = 0) const; + virtual QString packageName() const; + virtual QString shortDescription() const; + virtual QString packageFileName() const; + + QString specFilePath() const; + +signals: + void specFileChanged(); + +private: + virtual bool setProjectVersionInternal(const QString &version, + QString *error = 0); + virtual bool setPackageNameInternal(const QString &packageName); + virtual bool setShortDescriptionInternal(const QString &description); + virtual ActionStatus createSpecialTemplates(); + virtual void handleTargetAddedSpecial(); + virtual bool targetCanBeRemoved() const; + virtual void removeTarget(); + virtual bool initAdditionalPackagingSettingsFromOtherTarget(); + virtual QStringList packagingFilePaths() const { return QStringList(specFilePath()); } + + virtual QString specFileName() const = 0; + + QByteArray getValueForTag(const QByteArray &tag, QString *error) const; + bool setValueForTag(const QByteArray &tag, const QByteArray &value, + QString *error); + + WatchableFile *m_specFile; +}; + + +class Qt4Maemo5Target : public AbstractDebBasedQt4MaemoTarget +{ + Q_OBJECT +public: + explicit Qt4Maemo5Target(Qt4ProjectManager::Qt4Project *parent, + const QString &id); + virtual ~Qt4Maemo5Target(); + + virtual bool allowsRemoteMounts() const { return true; } + virtual bool allowsPackagingDisabling() const { return true; } + virtual bool allowsQmlDebugging() const { return false; } + + virtual QSize packageManagerIconSize() const; + + static QString defaultDisplayName(); + +private: + virtual void addAdditionalControlFileFields(QByteArray &controlContents); + virtual QString debianDirName() const; + virtual QByteArray packageManagerNameFieldName() const; + virtual QByteArray defaultSection() const; +}; + + +class Qt4HarmattanTarget : public AbstractDebBasedQt4MaemoTarget +{ + Q_OBJECT +public: + explicit Qt4HarmattanTarget(Qt4ProjectManager::Qt4Project *parent, + const QString &id); + virtual ~Qt4HarmattanTarget(); + + virtual bool allowsRemoteMounts() const { return false; } + virtual bool allowsPackagingDisabling() const { return false; } + virtual bool allowsQmlDebugging() const { return true; } + + virtual QSize packageManagerIconSize() const; + + static QString defaultDisplayName(); + static QString aegisManifestFileName(); + +private: + void handleTargetAddedSpecial(); + virtual void addAdditionalControlFileFields(QByteArray &controlContents); + virtual QString debianDirName() const; + virtual QByteArray packageManagerNameFieldName() const; + virtual QByteArray defaultSection() const; +}; + + +class Qt4MeegoTarget : public AbstractRpmBasedQt4MaemoTarget +{ + Q_OBJECT +public: + explicit Qt4MeegoTarget(Qt4ProjectManager::Qt4Project *parent, + const QString &id); + virtual ~Qt4MeegoTarget(); + static QString defaultDisplayName(); +private: + virtual QString specFileName() const; +}; + +} // namespace Internal +} // namespace Madde + +#endif // QT4MAEMOTARGET_H diff --git a/src/plugins/madde/qt4maemotargetfactory.cpp b/src/plugins/madde/qt4maemotargetfactory.cpp new file mode 100644 index 00000000000..c043c90c03e --- /dev/null +++ b/src/plugins/madde/qt4maemotargetfactory.cpp @@ -0,0 +1,228 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "qt4maemotargetfactory.h" +#include "maemoglobal.h" +#include "maemopackagecreationstep.h" +#include "qt4maemodeployconfiguration.h" +#include "qt4maemotarget.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Constants; +using ProjectExplorer::idFromMap; + +namespace Madde { +namespace Internal { + +// ------------------------------------------------------------------------- +// Qt4MaemoTargetFactory +// ------------------------------------------------------------------------- +Qt4MaemoTargetFactory::Qt4MaemoTargetFactory(QObject *parent) : + Qt4BaseTargetFactory(parent) +{ + connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList)), + this, SIGNAL(supportedTargetIdsChanged())); +} + +Qt4MaemoTargetFactory::~Qt4MaemoTargetFactory() +{ +} + +bool Qt4MaemoTargetFactory::supportsTargetId(const QString &id) const +{ + return MaemoGlobal::isMaemoTargetId(id); +} + +QStringList Qt4MaemoTargetFactory::supportedTargetIds(ProjectExplorer::Project *parent) const +{ + QStringList targetIds; + if (parent && !qobject_cast(parent)) + return targetIds; + if (!QtSupport::QtVersionManager::instance()->versionsForTargetId(QLatin1String(MAEMO5_DEVICE_TARGET_ID)).isEmpty()) + targetIds << QLatin1String(MAEMO5_DEVICE_TARGET_ID); + if (!QtSupport::QtVersionManager::instance()->versionsForTargetId(QLatin1String(HARMATTAN_DEVICE_TARGET_ID)).isEmpty()) + targetIds << QLatin1String(HARMATTAN_DEVICE_TARGET_ID); + if (!QtSupport::QtVersionManager::instance()->versionsForTargetId(QLatin1String(MEEGO_DEVICE_TARGET_ID)).isEmpty()) + targetIds << QLatin1String(MEEGO_DEVICE_TARGET_ID); + return targetIds; +} + +QString Qt4MaemoTargetFactory::displayNameForId(const QString &id) const +{ + if (id == QLatin1String(MAEMO5_DEVICE_TARGET_ID)) + return Qt4Maemo5Target::defaultDisplayName(); + else if (id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID)) + return Qt4HarmattanTarget::defaultDisplayName(); + else if (id == QLatin1String(MEEGO_DEVICE_TARGET_ID)) + return Qt4MeegoTarget::defaultDisplayName(); + return QString(); +} + +QIcon Qt4MaemoTargetFactory::iconForId(const QString &id) const +{ + Q_UNUSED(id) + return QIcon(":/projectexplorer/images/MaemoDevice.png"); +} + +bool Qt4MaemoTargetFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const +{ + if (!qobject_cast(parent)) + return false; + return supportsTargetId(id); +} + +bool Qt4MaemoTargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const +{ + return canCreate(parent, idFromMap(map)); +} + +ProjectExplorer::Target *Qt4MaemoTargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map) +{ + if (!canRestore(parent, map)) + return 0; + + const QString id = idFromMap(map); + AbstractQt4MaemoTarget *target = 0; + Qt4Project *qt4project = static_cast(parent); + if (id == QLatin1String(MAEMO5_DEVICE_TARGET_ID)) + target = new Qt4Maemo5Target(qt4project, QLatin1String("transient ID")); + else if (id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID)) + target = new Qt4HarmattanTarget(qt4project, QLatin1String("transient ID")); + else if (id == QLatin1String(MEEGO_DEVICE_TARGET_ID)) + target = new Qt4MeegoTarget(qt4project, QLatin1String("transient ID")); + if (target->fromMap(map)) + return target; + delete target; + return 0; +} + +QString Qt4MaemoTargetFactory::buildNameForId(const QString &id) const +{ + if (id == QLatin1String(MAEMO5_DEVICE_TARGET_ID)) + return QLatin1String("maemo"); + else if (id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID)) + return QLatin1String("harmattan"); + else if (id == QLatin1String(MEEGO_DEVICE_TARGET_ID)) + return QLatin1String("meego"); + else + return QString(); +} + +QString Qt4MaemoTargetFactory::shadowBuildDirectory(const QString &profilePath, const QString &id, const QString &suffix) +{ +#if defined(Q_OS_WIN) + // No shadowbuilding for windows! + Q_UNUSED(id); + Q_UNUSED(suffix); + return QFileInfo(profilePath).absolutePath(); +#else + return Qt4BaseTargetFactory::shadowBuildDirectory(profilePath, id, suffix); +#endif +} + +QSet Qt4MaemoTargetFactory::targetFeatures(const QString & /*id*/) const +{ + QSet features; + features << Qt4ProjectManager::Constants::MOBILE_TARGETFEATURE_ID; +#ifndef Q_OS_WIN + features << Qt4ProjectManager::Constants::SHADOWBUILD_TARGETFEATURE_ID; +#endif + // how to check check whether the component set is really installed? + features << Qt4ProjectManager::Constants::QTQUICKCOMPONENTS_MEEGO_TARGETFEATURE_ID; + return features; +} + +ProjectExplorer::Target *Qt4MaemoTargetFactory::create(ProjectExplorer::Project *parent, const QString &id) +{ + if (!canCreate(parent, id)) + return 0; + + QList knownVersions = QtSupport::QtVersionManager::instance()->versionsForTargetId(id); + if (knownVersions.isEmpty()) + return 0; + + QtSupport::BaseQtVersion *qtVersion = knownVersions.first(); + QtSupport::BaseQtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); + + QList infos; + infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString())); + infos.append(BuildConfigurationInfo(qtVersion, config ^ QtSupport::BaseQtVersion::DebugBuild, QString(), QString())); + + return create(parent, id, infos); +} + +ProjectExplorer::Target *Qt4MaemoTargetFactory::create(ProjectExplorer::Project *parent, + const QString &id, const QList &infos) +{ + if (!canCreate(parent, id)) + return 0; + + AbstractQt4MaemoTarget *target = 0; + QStringList deployConfigIds; + if (id == QLatin1String(MAEMO5_DEVICE_TARGET_ID)) { + target = new Qt4Maemo5Target(static_cast(parent), id); + deployConfigIds << Qt4MaemoDeployConfiguration::fremantleWithPackagingId() + << Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId(); + } else if (id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID)) { + target = new Qt4HarmattanTarget(static_cast(parent), id); + deployConfigIds << Qt4MaemoDeployConfiguration::harmattanId(); + } else if (id == QLatin1String(MEEGO_DEVICE_TARGET_ID)) { + target = new Qt4MeegoTarget(static_cast(parent), id); + deployConfigIds << Qt4MaemoDeployConfiguration::meegoId(); + } + Q_ASSERT(target); + + foreach (const BuildConfigurationInfo &info, infos) + target->addQt4BuildConfiguration(msgBuildConfigurationName(info), QString(), + info.version, info.buildConfig, + info.additionalArguments, info.directory, info.importing); + + foreach (const QString &deployConfigId, deployConfigIds) { + target->addDeployConfiguration(target->createDeployConfiguration(deployConfigId)); + } + target->createApplicationProFiles(); + if (target->runConfigurations().isEmpty()) + target->addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(target)); + return target; +} + +} // namespace Internal +} // namespace Madde diff --git a/src/plugins/madde/qt4maemotargetfactory.h b/src/plugins/madde/qt4maemotargetfactory.h new file mode 100644 index 00000000000..b34a9c70ecf --- /dev/null +++ b/src/plugins/madde/qt4maemotargetfactory.h @@ -0,0 +1,71 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef QT4MAEMOTARGETFACTORY_H +#define QT4MAEMOTARGETFACTORY_H + +#include + +namespace Madde { +namespace Internal { + +class Qt4MaemoTargetFactory : public Qt4ProjectManager::Qt4BaseTargetFactory +{ + Q_OBJECT +public: + Qt4MaemoTargetFactory(QObject *parent = 0); + ~Qt4MaemoTargetFactory(); + + QStringList supportedTargetIds(ProjectExplorer::Project *parent) const; + QString displayNameForId(const QString &id) const; + QIcon iconForId(const QString &id) const; + + bool canCreate(ProjectExplorer::Project *parent, const QString &id) const; + bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const; + ProjectExplorer::Target *restore(ProjectExplorer::Project *parent, const QVariantMap &map); + + QString shadowBuildDirectory(const QString &profilePath, const QString &id, const QString &suffix); + QString buildNameForId(const QString &id) const; + + bool supportsTargetId(const QString &id) const; + + ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id); + ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id, + const QList &infos); + + QSet targetFeatures(const QString &id) const; +}; + +} // namespace Internal +} // namespace Madde + +#endif // QT4MAEMOTARGETFACTORY_H diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index bc5ac35c158..9f7e3bf423f 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -44,6 +44,7 @@ SUBDIRS = plugin_coreplugin \ debugger/dumper.pro \ plugin_qmlprofiler \ plugin_remotelinux \ + plugin_madde \ plugin_qttest \ plugin_valgrind \ plugin_updateinfo @@ -160,6 +161,9 @@ plugin_remotelinux.depends += plugin_debugger plugin_remotelinux.depends += plugin_projectexplorer plugin_remotelinux.depends += plugin_qt4projectmanager +plugin_madde.subdir = madde +plugin_madde.depends += plugin_remotelinux + plugin_locator.subdir = locator plugin_locator.depends = plugin_coreplugin diff --git a/src/plugins/qttest/testconfigurations.cpp b/src/plugins/qttest/testconfigurations.cpp index 26c2d492fb4..0fa1105ac97 100644 --- a/src/plugins/qttest/testconfigurations.cpp +++ b/src/plugins/qttest/testconfigurations.cpp @@ -43,8 +43,8 @@ #include #include #include -#include #include +#include #include #include @@ -547,14 +547,14 @@ bool TestConfig::isRemoteTarget(QString &deviceName, QString &testDeviceType, if (m_activeProject && m_activeProject->activeTarget()) { ProjectExplorer::RunConfiguration *r = m_activeProject->activeTarget()->activeRunConfiguration(); if (r) { - if (r->id() == QLatin1String("Qt4ProjectManager.MaemoRunConfiguration")) { - RemoteLinux::Internal::MaemoRunConfiguration *mr = static_cast(r); + if (r->id() == QLatin1String("RemoteLinuxRunConfiguration")) { + RemoteLinux::RemoteLinuxRunConfiguration *mr = static_cast(r); if (mr) { QSharedPointer mc = mr->deviceConfig(); if (mc){ deviceName = mc->name(); sshParameters = mc->sshParameters(); - testDeviceType = QLatin1String("Maemo");//Qt4Test::TestController::Maemo; + testDeviceType = QLatin1String("RemoteLinux");//Qt4Test::TestController::Maemo; return true; }else{ qWarning() << "Invalid remote" << deviceName; @@ -989,9 +989,9 @@ QStringList *TestConfig::runEnvironment() } else if (rc->id() == QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration")) { m_runEnvironment = static_cast(rc)->environment().toStringList(); - } else if (rc->id() == QLatin1String("Qt4ProjectManager.MaemoRunConfiguration")) { + } else if (rc->id() == QLatin1String("RemoteLinuxRunConfiguration")) { m_runEnvironment = - static_cast(rc)->environment().toStringList(); + static_cast(rc)->environment().toStringList(); } } } diff --git a/src/plugins/remotelinux/images/qemu-run.png b/src/plugins/remotelinux/images/qemu-run.png deleted file mode 100644 index c65d15faf73..00000000000 Binary files a/src/plugins/remotelinux/images/qemu-run.png and /dev/null differ diff --git a/src/plugins/remotelinux/images/qemu-stop.png b/src/plugins/remotelinux/images/qemu-stop.png deleted file mode 100644 index 97bc159599a..00000000000 Binary files a/src/plugins/remotelinux/images/qemu-stop.png and /dev/null differ diff --git a/src/plugins/remotelinux/images/qemu.xcf b/src/plugins/remotelinux/images/qemu.xcf deleted file mode 100644 index 226dd2b30a6..00000000000 Binary files a/src/plugins/remotelinux/images/qemu.xcf and /dev/null differ diff --git a/src/plugins/remotelinux/maddedeviceconfigurationfactory.cpp b/src/plugins/remotelinux/maddedeviceconfigurationfactory.cpp deleted file mode 100644 index 8633de3d0eb..00000000000 --- a/src/plugins/remotelinux/maddedeviceconfigurationfactory.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maddedeviceconfigurationfactory.h" - -#include "maddedevicetester.h" -#include "maemoconstants.h" -#include "maemodeviceconfigwizard.h" -#include "publickeydeploymentdialog.h" - -#include -#include -#include -#include -#include - -namespace RemoteLinux { -namespace Internal { -namespace { -const char MaddeDeviceTestActionId[] = "Madde.DeviceTestAction"; -const char MaddeRemoteProcessesActionId[] = "Madde.RemoteProcessesAction"; -} // anonymous namespace - -MaddeDeviceConfigurationFactory::MaddeDeviceConfigurationFactory(QObject *parent) - : ILinuxDeviceConfigurationFactory(parent) -{ -} - -QString MaddeDeviceConfigurationFactory::displayName() const -{ - return tr("Device with MADDE support (Fremantle, Harmattan, MeeGo)"); -} - -ILinuxDeviceConfigurationWizard *MaddeDeviceConfigurationFactory::createWizard(QWidget *parent) const -{ - return new MaemoDeviceConfigWizard(parent); -} - -bool MaddeDeviceConfigurationFactory::supportsOsType(const QString &osType) const -{ - return osType == QLatin1String(Maemo5OsType) || osType == QLatin1String(HarmattanOsType) - || osType == QLatin1String(MeeGoOsType); -} - -QString MaddeDeviceConfigurationFactory::displayNameForOsType(const QString &osType) const -{ - QTC_ASSERT(supportsOsType(osType), return QString()); - if (osType == QLatin1String(Maemo5OsType)) - return tr("Maemo5/Fremantle"); - if (osType == QLatin1String(HarmattanOsType)) - return tr("MeeGo 1.2 Harmattan"); - return tr("Other MeeGo OS"); -} - -QStringList MaddeDeviceConfigurationFactory::supportedDeviceActionIds() const -{ - return QStringList() << QLatin1String(MaddeDeviceTestActionId) - << QLatin1String(Constants::GenericDeployKeyToDeviceActionId) - << QLatin1String(MaddeRemoteProcessesActionId); -} - -QString MaddeDeviceConfigurationFactory::displayNameForActionId(const QString &actionId) const -{ - Q_ASSERT(supportedDeviceActionIds().contains(actionId)); - - if (actionId == QLatin1String(MaddeDeviceTestActionId)) - return tr("Test"); - if (actionId == QLatin1String(MaddeRemoteProcessesActionId)) - return tr("Remote Processes"); - if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId)) - return tr("Deploy Public Key"); - return QString(); // Can't happen. -} - -QDialog *MaddeDeviceConfigurationFactory::createDeviceAction(const QString &actionId, - const LinuxDeviceConfiguration::ConstPtr &deviceConfig, QWidget *parent) const -{ - Q_ASSERT(supportedDeviceActionIds().contains(actionId)); - - if (actionId == QLatin1String(MaddeDeviceTestActionId)) - return new LinuxDeviceTestDialog(deviceConfig, new MaddeDeviceTester, parent); - if (actionId == QLatin1String(MaddeRemoteProcessesActionId)) - return new RemoteLinuxProcessesDialog(new GenericRemoteLinuxProcessList(deviceConfig), parent); - if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId)) - return new PublicKeyDeploymentDialog(deviceConfig, parent); - return 0; // Can't happen. -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maddedeviceconfigurationfactory.h b/src/plugins/remotelinux/maddedeviceconfigurationfactory.h deleted file mode 100644 index aa531f2c02b..00000000000 --- a/src/plugins/remotelinux/maddedeviceconfigurationfactory.h +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MADDEDEVICECONFIGURATIONFACTORY_H -#define MADDEDEVICECONFIGURATIONFACTORY_H - -#include - -namespace RemoteLinux { -namespace Internal { - -class MaddeDeviceConfigurationFactory : public RemoteLinux::ILinuxDeviceConfigurationFactory -{ - Q_OBJECT -public: - MaddeDeviceConfigurationFactory(QObject *parent = 0); - - QString displayName() const; - ILinuxDeviceConfigurationWizard *createWizard(QWidget *parent) const; - bool supportsOsType(const QString &osType) const; - QString displayNameForOsType(const QString &osType) const; - QStringList supportedDeviceActionIds() const; - QString displayNameForActionId(const QString &actionId) const; - QDialog *createDeviceAction(const QString &actionId, - const LinuxDeviceConfiguration::ConstPtr &deviceConfig, QWidget *parent) const; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MADDEDEVICECONFIGURATIONFACTORY_H diff --git a/src/plugins/remotelinux/maddedevicetester.cpp b/src/plugins/remotelinux/maddedevicetester.cpp deleted file mode 100644 index adb5ff83271..00000000000 --- a/src/plugins/remotelinux/maddedevicetester.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maddedevicetester.h" - -#include "maemoconstants.h" -#include "maemoglobal.h" - -#include -#include -#include - -#include - -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { -namespace { -const char QmlToolingDirectory[] = "/usr/lib/qt4/plugins/qmltooling"; -} // anonymous namespace - -MaddeDeviceTester::MaddeDeviceTester(QObject *parent) - : AbstractLinuxDeviceTester(parent), - m_genericTester(new GenericLinuxDeviceTester(this)), - m_state(Inactive) -{ -} - -MaddeDeviceTester::~MaddeDeviceTester() -{ -} - -void MaddeDeviceTester::testDevice(const LinuxDeviceConfiguration::ConstPtr &deviceConfiguration) -{ - QTC_ASSERT(m_state == Inactive, return); - - m_deviceConfiguration = deviceConfiguration; - m_result = TestSuccess; - - m_state = GenericTest; - connect(m_genericTester, SIGNAL(progressMessage(QString)), SIGNAL(progressMessage(QString))); - connect(m_genericTester, SIGNAL(errorMessage(QString)), SIGNAL(errorMessage(QString))); - connect(m_genericTester, SIGNAL(finished(RemoteLinux::AbstractLinuxDeviceTester::TestResult)), - SLOT(handleGenericTestFinished(RemoteLinux::AbstractLinuxDeviceTester::TestResult))); - m_genericTester->testDevice(deviceConfiguration); -} - -void MaddeDeviceTester::stopTest() -{ - QTC_ASSERT(m_state != Inactive, return); - - switch (m_state) { - case Inactive: - break; - case GenericTest: - m_genericTester->stopTest(); - break; - case QtTest: - case MadDeveloperTest: - case QmlToolingTest: - m_processRunner->process()->closeChannel(); - break; - } - - m_result = TestFailure; - setFinished(); -} - -void MaddeDeviceTester::handleGenericTestFinished(TestResult result) -{ - QTC_ASSERT(m_state == GenericTest, return); - - if (result == TestFailure) { - m_result = TestFailure; - setFinished(); - return; - } - - m_processRunner = SshRemoteProcessRunner::create(m_genericTester->connection()); - connect(m_processRunner.data(), SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); - connect(m_processRunner.data(), SIGNAL(processOutputAvailable(QByteArray)), - SLOT(handleStdout(QByteArray))); - connect(m_processRunner.data(), SIGNAL(processErrorOutputAvailable(QByteArray)), - SLOT(handleStderr(QByteArray))); - connect(m_processRunner.data(), SIGNAL(processClosed(int)), SLOT(handleProcessFinished(int))); - - QString qtInfoCmd; - if (m_deviceConfiguration->osType() == QLatin1String(MeeGoOsType)) { - qtInfoCmd = QLatin1String("rpm -qa 'libqt*' --queryformat '%{NAME} %{VERSION}\\n'"); - } else { - qtInfoCmd = QLatin1String("dpkg-query -W -f " - "'${Package} ${Version} ${Status}\n' 'libqt*' |grep ' installed$'"); - } - - emit progressMessage(tr("Checking for Qt libraries...")); - m_stdout.clear(); - m_stderr.clear(); - m_state = QtTest; - m_processRunner->run(qtInfoCmd.toUtf8()); -} - -void MaddeDeviceTester::handleConnectionError() -{ - QTC_ASSERT(m_state != Inactive, return); - - emit errorMessage(tr("SSH connection error: %1\n") - .arg(m_processRunner->connection()->errorString())); - m_result = TestFailure; - setFinished(); -} - -void MaddeDeviceTester::handleStdout(const QByteArray &data) -{ - QTC_ASSERT(m_state == QtTest || m_state == MadDeveloperTest || m_state == QmlToolingTest, - return); - - m_stdout += data; -} - -void MaddeDeviceTester::handleStderr(const QByteArray &data) -{ - QTC_ASSERT(m_state == QtTest || m_state == MadDeveloperTest || m_state == QmlToolingTest, - return); - - m_stderr += data; -} - -void MaddeDeviceTester::handleProcessFinished(int exitStatus) -{ - switch (m_state) { - case QtTest: - handleQtTestFinished(exitStatus); - break; - case MadDeveloperTest: - handleMadDeveloperTestFinished(exitStatus); - break; - case QmlToolingTest: - handleQmlToolingTestFinished(exitStatus); - break; - default: - qWarning("%s: Unexpected state %d.", Q_FUNC_INFO, m_state); - } -} - -void MaddeDeviceTester::handleQtTestFinished(int exitStatus) -{ - if (exitStatus != SshRemoteProcess::ExitedNormally - || m_processRunner->process()->exitCode() != 0) { - if (!m_stderr.isEmpty()) { - emit errorMessage(tr("Error checking for Qt libraries: %1\n") - .arg(QString::fromUtf8(m_stderr))); - } else { - emit errorMessage(tr("Error checking for Qt libraries.\n")); - } - - m_result = TestFailure; - } else { - emit progressMessage(processedQtLibsList()); - } - - m_stdout.clear(); - m_stderr.clear(); - - emit progressMessage(tr("Checking for connectivity support...")); - m_state = MadDeveloperTest; - m_processRunner->run(QString(QLatin1String("test -x") + MaemoGlobal::devrootshPath()).toUtf8()); -} - -void MaddeDeviceTester::handleMadDeveloperTestFinished(int exitStatus) -{ - if (exitStatus != SshRemoteProcess::ExitedNormally) { - if (!m_stderr.isEmpty()) { - emit errorMessage(tr("Error checking for connectivity tool: %1\n") - .arg(QString::fromUtf8(m_stderr))); - } else { - emit errorMessage(tr("Error checking for connectivity tool.\n")); - } - m_result = TestFailure; - } else if (m_processRunner->process()->exitCode() != 0) { - QString message = tr("Connectivity tool not installed on device. " - "Deployment currently not possible."); - if (m_deviceConfiguration->osType() == QLatin1String(HarmattanOsType)) { - message += tr("Please switch the device to developer mode " - "via Settings -> Security."); - } - emit errorMessage(message + QLatin1Char('\n')); - m_result = TestFailure; - } else { - emit progressMessage(tr("Connectivity tool present.\n")); - } - - if (m_deviceConfiguration->osType() != QLatin1String(HarmattanOsType)) { - setFinished(); - return; - } - - m_stdout.clear(); - m_stderr.clear(); - - emit progressMessage(tr("Checking for QML tooling support...")); - m_state = QmlToolingTest; - m_processRunner->run(QString(QLatin1String("test -d ") - + QLatin1String(QmlToolingDirectory)).toUtf8()); -} - -void MaddeDeviceTester::handleQmlToolingTestFinished(int exitStatus) -{ - if (exitStatus != SshRemoteProcess::ExitedNormally) { - if (!m_stderr.isEmpty()) { - emit errorMessage(tr("Error checking for QML tooling support: %1\n") - .arg(QString::fromUtf8(m_stderr))); - } else { - emit errorMessage(tr("Error checking for QML tooling support.\n")); - } - m_result = TestFailure; - } else if (m_processRunner->process()->exitCode() != 0) { - emit errorMessage(tr("Missing directory '%1'. You will not be able to do " - "QML debugging on this device.\n").arg(QmlToolingDirectory)); - m_result = TestFailure; - } else { - emit progressMessage(tr("QML tooling support present.\n")); - } - - setFinished(); -} - -QString MaddeDeviceTester::processedQtLibsList() -{ - QString unfilteredLibs = QString::fromUtf8(m_stdout); - QString filteredLibs; - QString patternString; - if (m_deviceConfiguration->osType() == QLatin1String(MeeGoOsType)) - patternString = QLatin1String("(libqt\\S+) ((\\d+)\\.(\\d+)\\.(\\d+))"); - else - patternString = QLatin1String("(\\S+) (\\S*(\\d+)\\.(\\d+)\\.(\\d+)\\S*) \\S+ \\S+ \\S+"); - const QRegExp packagePattern(patternString); - int index = packagePattern.indexIn(unfilteredLibs); - if (index == -1) - return tr("No Qt packages installed."); - - do { - filteredLibs += QLatin1String(" ") + packagePattern.cap(1) + QLatin1String(": ") - + packagePattern.cap(2) + QLatin1Char('\n'); - index = packagePattern.indexIn(unfilteredLibs, index + packagePattern.cap(0).length()); - } while (index != -1); - return filteredLibs; -} - - void MaddeDeviceTester::setFinished() -{ - m_state = Inactive; - disconnect(m_genericTester, 0, this, 0); - if (m_processRunner) - disconnect(m_processRunner.data(), 0, this, 0); - m_processRunner.clear(); - emit finished(m_result); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maddedevicetester.h b/src/plugins/remotelinux/maddedevicetester.h deleted file mode 100644 index 77aa2242d43..00000000000 --- a/src/plugins/remotelinux/maddedevicetester.h +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MADDEDEVICETESTER_H -#define MADDEDEVICETESTER_H - -#include - -#include - -namespace Utils { -class SshRemoteProcessRunner; -} - -namespace RemoteLinux { -namespace Internal { - -class MaddeDeviceTester : public RemoteLinux::AbstractLinuxDeviceTester -{ - Q_OBJECT -public: - explicit MaddeDeviceTester(QObject *parent = 0); - ~MaddeDeviceTester(); - - void testDevice(const QSharedPointer &deviceConfiguration); - void stopTest(); - -private slots: - void handleGenericTestFinished(RemoteLinux::AbstractLinuxDeviceTester::TestResult result); - void handleConnectionError(); - void handleStdout(const QByteArray &data); - void handleStderr(const QByteArray &data); - void handleProcessFinished(int exitStatus); - -private: - enum State { Inactive, GenericTest, QtTest, MadDeveloperTest, QmlToolingTest }; - - void handleQtTestFinished(int exitStatus); - void handleMadDeveloperTestFinished(int exitStatus); - void handleQmlToolingTestFinished(int exitStatus); - - QString processedQtLibsList(); - void setFinished(); - - RemoteLinux::GenericLinuxDeviceTester * const m_genericTester; - State m_state; - TestResult m_result; - QSharedPointer m_processRunner; - QSharedPointer m_deviceConfiguration; - QByteArray m_stdout; - QByteArray m_stderr; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MADDEDEVICETESTER_H diff --git a/src/plugins/remotelinux/maddeuploadandinstallpackagesteps.cpp b/src/plugins/remotelinux/maddeuploadandinstallpackagesteps.cpp deleted file mode 100644 index 0c942c97fc7..00000000000 --- a/src/plugins/remotelinux/maddeuploadandinstallpackagesteps.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maddeuploadandinstallpackagesteps.h" - -#include "maemopackagecreationstep.h" -#include "maemopackageinstaller.h" -#include "maemoqemumanager.h" -#include "qt4maemodeployconfiguration.h" - -#include -#include -#include -#include - -namespace RemoteLinux { -namespace Internal { -namespace { -class AbstractMaddeUploadAndInstallPackageAction : public AbstractUploadAndInstallPackageService -{ - Q_OBJECT - -protected: - explicit AbstractMaddeUploadAndInstallPackageAction(AbstractRemoteLinuxDeployStep *step) - : AbstractUploadAndInstallPackageService(step) - { - } - - void doDeviceSetup() - { - if (deviceConfiguration()->deviceType() == LinuxDeviceConfiguration::Hardware) { - handleDeviceSetupDone(true); - return; - } - - if (MaemoQemuManager::instance().qemuIsRunning()) { - handleDeviceSetupDone(true); - return; - } - - MaemoQemuRuntime rt; - const int qtId = qt4BuildConfiguration() && qt4BuildConfiguration()->qtVersion() - ? qt4BuildConfiguration()->qtVersion()->uniqueId() : -1; - if (MaemoQemuManager::instance().runtimeForQtVersion(qtId, &rt)) { - MaemoQemuManager::instance().startRuntime(); - emit errorMessage(tr("Cannot deploy: Qemu was not running. " - "It has now been started up for you, but it will take " - "a bit of time until it is ready. Please try again then.")); - } else { - emit errorMessage(tr("Cannot deploy: You want to deploy to Qemu, but it is not enabled " - "for this Qt version.")); - } - handleDeviceSetupDone(false); - } -}; - -class MaemoUploadAndInstallPackageAction : public AbstractMaddeUploadAndInstallPackageAction -{ - Q_OBJECT - -public: - MaemoUploadAndInstallPackageAction(AbstractRemoteLinuxDeployStep *step) - : AbstractMaddeUploadAndInstallPackageAction(step), - m_installer(new MaemoDebianPackageInstaller(this)) - { - } - - AbstractRemoteLinuxPackageInstaller *packageInstaller() const { return m_installer; } - -private: - MaemoDebianPackageInstaller * const m_installer; -}; - -class MeegoUploadAndInstallPackageAction : public AbstractMaddeUploadAndInstallPackageAction -{ - Q_OBJECT - -public: - MeegoUploadAndInstallPackageAction(AbstractRemoteLinuxDeployStep *step) - : AbstractMaddeUploadAndInstallPackageAction(step), - m_installer(new MaemoRpmPackageInstaller(this)) - { - } - - AbstractRemoteLinuxPackageInstaller *packageInstaller() const { return m_installer; } - -private: - MaemoRpmPackageInstaller * const m_installer; -}; - -} // anonymous namespace - - -MaemoUploadAndInstallPackageStep::MaemoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl) - : AbstractRemoteLinuxDeployStep(bsl, stepId()) -{ - ctor(); -} - -MaemoUploadAndInstallPackageStep::MaemoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl, - MaemoUploadAndInstallPackageStep *other) : AbstractRemoteLinuxDeployStep(bsl, other) -{ - ctor(); -} - -void MaemoUploadAndInstallPackageStep::ctor() -{ - setDefaultDisplayName(displayName()); - m_deployService = new MaemoUploadAndInstallPackageAction(this); -} - -AbstractRemoteLinuxDeployService *MaemoUploadAndInstallPackageStep::deployService() const -{ - return m_deployService; -} - -bool MaemoUploadAndInstallPackageStep::isDeploymentPossible(QString *whyNot) const -{ - const AbstractMaemoPackageCreationStep * const pStep - = deployConfiguration()->earlierBuildStep(this); - if (!pStep) { - if (whyNot) - *whyNot = tr("No Debian package creation step found."); - return false; - } - m_deployService->setPackageFilePath(pStep->packageFilePath()); - return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); -} - -QString MaemoUploadAndInstallPackageStep::stepId() -{ - return QLatin1String("MaemoUploadAndInstallDpkgPackageStep"); -} - -QString MaemoUploadAndInstallPackageStep::displayName() -{ - return tr("Deploy Debian package via SFTP upload"); -} - - -MeegoUploadAndInstallPackageStep::MeegoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl) - : AbstractRemoteLinuxDeployStep(bsl, stepId()) -{ - ctor(); -} - -MeegoUploadAndInstallPackageStep::MeegoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl, - MeegoUploadAndInstallPackageStep *other) : AbstractRemoteLinuxDeployStep(bsl, other) -{ - ctor(); -} - -void MeegoUploadAndInstallPackageStep::ctor() -{ - setDefaultDisplayName(displayName()); - m_deployService = new MeegoUploadAndInstallPackageAction(this); -} - -AbstractRemoteLinuxDeployService *MeegoUploadAndInstallPackageStep::deployService() const -{ - return m_deployService; -} - -bool MeegoUploadAndInstallPackageStep::isDeploymentPossible(QString *whyNot) const -{ - const AbstractMaemoPackageCreationStep * const pStep - = deployConfiguration()->earlierBuildStep(this); - if (!pStep) { - if (whyNot) - *whyNot = tr("No RPM package creation step found."); - return false; - } - m_deployService->setPackageFilePath(pStep->packageFilePath()); - return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); -} - -QString MeegoUploadAndInstallPackageStep::stepId() -{ - return QLatin1String("MaemoUploadAndInstallRpmPackageStep"); -} - -QString MeegoUploadAndInstallPackageStep::displayName() -{ - return tr("Deploy RPM package via SFTP upload"); -} - -} // namespace Internal -} // namespace RemoteLinux - -#include "maddeuploadandinstallpackagesteps.moc" diff --git a/src/plugins/remotelinux/maddeuploadandinstallpackagesteps.h b/src/plugins/remotelinux/maddeuploadandinstallpackagesteps.h deleted file mode 100644 index a3c7f4a7c8a..00000000000 --- a/src/plugins/remotelinux/maddeuploadandinstallpackagesteps.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MADDEUPLOADANDINSTALLPACKAGESTEPS_H -#define MADDEUPLOADANDINSTALLPACKAGESTEPS_H - -#include - -namespace RemoteLinux { -class AbstractUploadAndInstallPackageService; - -namespace Internal { - -class MaemoUploadAndInstallPackageStep : public RemoteLinux::AbstractRemoteLinuxDeployStep -{ - Q_OBJECT -public: - MaemoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl); - MaemoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl, - MaemoUploadAndInstallPackageStep *other); - - bool isDeploymentPossible(QString *whyNot = 0) const; - - static QString stepId(); - static QString displayName(); - -private: - AbstractRemoteLinuxDeployService *deployService() const; - - void ctor(); - - AbstractUploadAndInstallPackageService *m_deployService; -}; - - -class MeegoUploadAndInstallPackageStep : public RemoteLinux::AbstractRemoteLinuxDeployStep -{ - Q_OBJECT -public: - MeegoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl); - MeegoUploadAndInstallPackageStep(ProjectExplorer::BuildStepList *bsl, - MeegoUploadAndInstallPackageStep *other); - - bool isDeploymentPossible(QString *whyNot) const; - - static QString stepId(); - static QString displayName(); - -private: - AbstractRemoteLinuxDeployService *deployService() const; - - void ctor(); - - AbstractUploadAndInstallPackageService *m_deployService; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MADDEUPLOADANDINSTALLPACKAGESTEPS_H diff --git a/src/plugins/remotelinux/maemoconstants.h b/src/plugins/remotelinux/maemoconstants.h deleted file mode 100644 index d6a1fd80840..00000000000 --- a/src/plugins/remotelinux/maemoconstants.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOCONSTANTS_H -#define MAEMOCONSTANTS_H - -#include - -namespace RemoteLinux { -namespace Internal { - -const char Maemo5OsType[] = "Maemo5OsType"; -const char HarmattanOsType[] = "HarmattanOsType"; -const char MeeGoOsType[] = "MeeGoOsType"; - -#define PREFIX "Qt4ProjectManager.MaemoRunConfiguration" - -#ifdef Q_OS_WIN32 -#define EXEC_SUFFIX ".exe" -#else -#define EXEC_SUFFIX "" -#endif - -static const QLatin1String MAEMO_RC_ID(PREFIX); -static const QLatin1String MAEMO_RC_ID_PREFIX(PREFIX "."); - -static const QLatin1String LastDeployedHostsKey(PREFIX ".LastDeployedHosts"); -static const QLatin1String LastDeployedFilesKey(PREFIX ".LastDeployedFiles"); -static const QLatin1String LastDeployedRemotePathsKey(PREFIX ".LastDeployedRemotePaths"); -static const QLatin1String LastDeployedTimesKey(PREFIX ".LastDeployedTimes"); -static const QLatin1String ExportedLocalDirsKey(PREFIX ".ExportedLocalDirs"); -static const QLatin1String RemoteMountPointsKey(PREFIX ".RemoteMountPoints"); - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOCONSTANTS_H diff --git a/src/plugins/remotelinux/maemodebugsupport.cpp b/src/plugins/remotelinux/maemodebugsupport.cpp deleted file mode 100644 index ae67f50c3a6..00000000000 --- a/src/plugins/remotelinux/maemodebugsupport.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemodebugsupport.h" - -#include "maemorunconfiguration.h" -#include "maemosshrunner.h" - -#include - -namespace RemoteLinux { -namespace Internal { - -MaemoDebugSupport::MaemoDebugSupport(MaemoRunConfiguration *runConfig, Debugger::DebuggerEngine *engine) - : AbstractRemoteLinuxDebugSupport(runConfig, engine), - m_runner(new MaemoSshRunner(this, runConfig)) -{ -} - -MaemoDebugSupport::~MaemoDebugSupport() -{ -} - -AbstractRemoteLinuxApplicationRunner *MaemoDebugSupport::runner() const { return m_runner; } - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemodebugsupport.h b/src/plugins/remotelinux/maemodebugsupport.h deleted file mode 100644 index 94387e5e071..00000000000 --- a/src/plugins/remotelinux/maemodebugsupport.h +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMODEBUGSUPPORT_H -#define MAEMODEBUGSUPPORT_H - -#include - -namespace RemoteLinux { -namespace Internal { -class MaemoRunConfiguration; -class MaemoSshRunner; - -class MaemoDebugSupport : public AbstractRemoteLinuxDebugSupport -{ - Q_OBJECT -public: - MaemoDebugSupport(MaemoRunConfiguration *runConfig, Debugger::DebuggerEngine *engine); - ~MaemoDebugSupport(); - -private: - AbstractRemoteLinuxApplicationRunner *runner() const; - - MaemoSshRunner * const m_runner; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMODEBUGSUPPORT_H diff --git a/src/plugins/remotelinux/maemodeploybymountsteps.cpp b/src/plugins/remotelinux/maemodeploybymountsteps.cpp deleted file mode 100644 index fd1161a78e4..00000000000 --- a/src/plugins/remotelinux/maemodeploybymountsteps.cpp +++ /dev/null @@ -1,494 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemodeploybymountsteps.h" - -#include "maemodeploymentmounter.h" -#include "maemoglobal.h" -#include "maemomountspecification.h" -#include "maemopackagecreationstep.h" -#include "maemopackageinstaller.h" -#include "maemoqemumanager.h" -#include "maemoremotecopyfacility.h" -#include "qt4maemodeployconfiguration.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace ProjectExplorer; - -namespace RemoteLinux { -namespace Internal { -class AbstractMaemoDeployByMountService : public AbstractRemoteLinuxDeployService -{ - Q_OBJECT - Q_DISABLE_COPY(AbstractMaemoDeployByMountService) -protected: - AbstractMaemoDeployByMountService(QObject *parent); - - QString deployMountPoint() const; - -private slots: - void handleMounted(); - void handleUnmounted(); - void handleMountError(const QString &errorMsg); - void handleInstallationFinished(const QString &errorMsg); - -private: - virtual QList mountSpecifications() const=0; - virtual void doInstall() = 0; - virtual void cancelInstallation() = 0; - virtual void handleInstallationSuccess() = 0; - - void doDeviceSetup(); - void stopDeviceSetup(); - void doDeploy(); - void stopDeployment(); - - void unmount(); - void setFinished(); - - MaemoDeploymentMounter * const m_mounter; - enum State { Inactive, Mounting, Installing, Unmounting } m_state; - bool m_stopRequested; -}; - -class MaemoMountAndInstallPackageService : public AbstractMaemoDeployByMountService -{ - Q_OBJECT - -public: - MaemoMountAndInstallPackageService(QObject *parent); - - void setPackageFilePath(const QString &filePath) { m_packageFilePath = filePath; } - -private: - bool isDeploymentNecessary() const; - - QList mountSpecifications() const; - void doInstall(); - void cancelInstallation(); - void handleInstallationSuccess(); - - MaemoDebianPackageInstaller * const m_installer; - QString m_packageFilePath; -}; - -class MaemoMountAndCopyFilesService : public AbstractMaemoDeployByMountService -{ - Q_OBJECT - -public: - MaemoMountAndCopyFilesService(QObject *parent); - - void setDeployableFiles(const QList &deployableFiles) { - m_deployableFiles = deployableFiles; - } - -private: - bool isDeploymentNecessary() const; - - QList mountSpecifications() const; - void doInstall(); - void cancelInstallation(); - void handleInstallationSuccess(); - - Q_SLOT void handleFileCopied(const RemoteLinux::DeployableFile &deployable); - - MaemoRemoteCopyFacility * const m_copyFacility; - mutable QList m_filesToCopy; - QList m_deployableFiles; -}; - - -AbstractMaemoDeployByMountService::AbstractMaemoDeployByMountService(QObject *parent) - : AbstractRemoteLinuxDeployService(parent), - m_mounter(new MaemoDeploymentMounter(this)), - m_state(Inactive), - m_stopRequested(false) -{ - connect(m_mounter, SIGNAL(setupDone()), SLOT(handleMounted())); - connect(m_mounter, SIGNAL(tearDownDone()), SLOT(handleUnmounted())); - connect(m_mounter, SIGNAL(error(QString)), SLOT(handleMountError(QString))); - connect(m_mounter, SIGNAL(reportProgress(QString)), SIGNAL(progressMessage(QString))); - connect(m_mounter, SIGNAL(debugOutput(QString)), SIGNAL(stdErrData(QString))); -} - -void AbstractMaemoDeployByMountService::doDeviceSetup() -{ - QTC_ASSERT(m_state == Inactive, return); - - if (deviceConfiguration()->deviceType() == LinuxDeviceConfiguration::Hardware) { - handleDeviceSetupDone(true); - return; - } - - if (MaemoQemuManager::instance().qemuIsRunning()) { - handleDeviceSetupDone(true); - return; - } - - MaemoQemuRuntime rt; - const int qtId = qt4BuildConfiguration() && qt4BuildConfiguration()->qtVersion() - ? qt4BuildConfiguration()->qtVersion()->uniqueId() : -1; - if (MaemoQemuManager::instance().runtimeForQtVersion(qtId, &rt)) { - MaemoQemuManager::instance().startRuntime(); - emit errorMessage(tr("Cannot deploy: Qemu was not running. " - "It has now been started up for you, but it will take " - "a bit of time until it is ready. Please try again then.")); - } else { - emit errorMessage(tr("Cannot deploy: You want to deploy to Qemu, but it is not enabled " - "for this Qt version.")); - } - handleDeviceSetupDone(false); -} - -void AbstractMaemoDeployByMountService::stopDeviceSetup() -{ - QTC_ASSERT(m_state == Inactive, return); - - handleDeviceSetupDone(false); -} - -void AbstractMaemoDeployByMountService::doDeploy() -{ - QTC_ASSERT(m_state == Inactive, return); - - if (!qt4BuildConfiguration()) { - emit errorMessage(tr("Missing build configuration.")); - setFinished(); - return; - } - - m_state = Mounting; - m_mounter->setupMounts(connection(), deviceConfiguration(), mountSpecifications(), - qt4BuildConfiguration()); -} - -void AbstractMaemoDeployByMountService::stopDeployment() -{ - switch (m_state) { - case Installing: - m_stopRequested = true; - cancelInstallation(); - - // TODO: Possibly unsafe, because the mount point may still be in use if the - // application did not exit immediately. - unmount(); - break; - case Mounting: - case Unmounting: - m_stopRequested = true; - break; - case Inactive: - qWarning("%s: Unexpected state 'Inactive'.", Q_FUNC_INFO); - break; - } -} - -void AbstractMaemoDeployByMountService::unmount() -{ - m_state = Unmounting; - m_mounter->tearDownMounts(); -} - -void AbstractMaemoDeployByMountService::handleMounted() -{ - QTC_ASSERT(m_state == Mounting, return); - - if (m_stopRequested) { - unmount(); - return; - } - - m_state = Installing; - doInstall(); -} - -void AbstractMaemoDeployByMountService::handleUnmounted() -{ - QTC_ASSERT(m_state == Unmounting, return); - - setFinished(); -} - -void AbstractMaemoDeployByMountService::handleMountError(const QString &errorMsg) -{ - QTC_ASSERT(m_state == Mounting, return); - - emit errorMessage(errorMsg); - setFinished(); -} - -void AbstractMaemoDeployByMountService::handleInstallationFinished(const QString &errorMsg) -{ - QTC_ASSERT(m_state == Installing, return); - - if (errorMsg.isEmpty()) - handleInstallationSuccess(); - else - emit errorMessage(errorMsg); - unmount(); -} - -void AbstractMaemoDeployByMountService::setFinished() -{ - m_state = Inactive; - m_stopRequested = false; - handleDeploymentDone(); -} - -QString AbstractMaemoDeployByMountService::deployMountPoint() const -{ - return MaemoGlobal::homeDirOnDevice(deviceConfiguration()->sshParameters().userName) - + QLatin1String("/deployMountPoint_") - + qt4BuildConfiguration()->target()->project()->displayName(); -} - - -MaemoMountAndInstallPackageService::MaemoMountAndInstallPackageService(QObject *parent) - : AbstractMaemoDeployByMountService(parent), m_installer(new MaemoDebianPackageInstaller(this)) -{ - connect(m_installer, SIGNAL(stdoutData(QString)), SIGNAL(stdOutData(QString))); - connect(m_installer, SIGNAL(stderrData(QString)), SIGNAL(stdErrData(QString))); - connect(m_installer, SIGNAL(finished(QString)), SLOT(handleInstallationFinished(QString))); -} - -bool MaemoMountAndInstallPackageService::isDeploymentNecessary() const -{ - return hasChangedSinceLastDeployment(DeployableFile(m_packageFilePath, QString())); -} - -QList MaemoMountAndInstallPackageService::mountSpecifications() const -{ - const QString localDir = QFileInfo(m_packageFilePath).absolutePath(); - return QList() - << MaemoMountSpecification(localDir, deployMountPoint()); -} - -void MaemoMountAndInstallPackageService::doInstall() -{ - const QString remoteFilePath = deployMountPoint() + QLatin1Char('/') - + QFileInfo(m_packageFilePath).fileName(); - m_installer->installPackage(connection(), remoteFilePath, false); -} - -void MaemoMountAndInstallPackageService::cancelInstallation() -{ - m_installer->cancelInstallation(); -} - -void MaemoMountAndInstallPackageService::handleInstallationSuccess() -{ - saveDeploymentTimeStamp(DeployableFile(m_packageFilePath, QString())); - emit progressMessage(tr("Package installed.")); -} - - -MaemoMountAndCopyFilesService::MaemoMountAndCopyFilesService(QObject *parent) - : AbstractMaemoDeployByMountService(parent), m_copyFacility(new MaemoRemoteCopyFacility(this)) -{ - connect(m_copyFacility, SIGNAL(stdoutData(QString)), SIGNAL(stdOutData(QString))); - connect(m_copyFacility, SIGNAL(stderrData(QString)), SIGNAL(stdErrData(QString))); - connect(m_copyFacility, SIGNAL(progress(QString)), SIGNAL(progressMessage(QString))); - connect(m_copyFacility, SIGNAL(fileCopied(RemoteLinux::DeployableFile)), - SLOT(handleFileCopied(RemoteLinux::DeployableFile))); - connect(m_copyFacility, SIGNAL(finished(QString)), SLOT(handleInstallationFinished(QString))); -} - -bool MaemoMountAndCopyFilesService::isDeploymentNecessary() const -{ - m_filesToCopy.clear(); - for (int i = 0; i < m_deployableFiles.count(); ++i) { - const DeployableFile &d = m_deployableFiles.at(i); - if (hasChangedSinceLastDeployment(d) || QFileInfo(d.localFilePath).isDir()) - m_filesToCopy << d; - } - return !m_filesToCopy.isEmpty(); -} - -QList MaemoMountAndCopyFilesService::mountSpecifications() const -{ - QList mountSpecs; -#ifdef Q_OS_WIN - bool drivesToMount[26]; - qFill(drivesToMount, drivesToMount + sizeof drivesToMount / sizeof drivesToMount[0], false); - for (int i = 0; i < m_filesToCopy.count(); ++i) { - const QString localDir = QFileInfo(m_filesToCopy.at(i).localFilePath).canonicalPath(); - const char driveLetter = localDir.at(0).toLower().toLatin1(); - if (driveLetter < 'a' || driveLetter > 'z') { - qWarning("Weird: drive letter is '%c'.", driveLetter); - continue; - } - - const int index = driveLetter - 'a'; - if (drivesToMount[index]) - continue; - - const QString mountPoint = deployMountPoint() + QLatin1Char('/') + QLatin1Char(driveLetter); - const MaemoMountSpecification mountSpec(localDir.left(3), mountPoint); - mountSpecs << mountSpec; - drivesToMount[index] = true; - } -#else - mountSpecs << MaemoMountSpecification(QLatin1String("/"), deployMountPoint()); -#endif - return mountSpecs; -} - -void MaemoMountAndCopyFilesService::doInstall() -{ - m_copyFacility->copyFiles(connection(), deviceConfiguration(), m_filesToCopy, - deployMountPoint()); -} - -void MaemoMountAndCopyFilesService::cancelInstallation() -{ - m_copyFacility->cancel(); -} - -void MaemoMountAndCopyFilesService::handleInstallationSuccess() -{ - emit progressMessage(tr("All files copied.")); -} - -void MaemoMountAndCopyFilesService::handleFileCopied(const DeployableFile &deployable) -{ - saveDeploymentTimeStamp(deployable); -} - -MaemoInstallPackageViaMountStep::MaemoInstallPackageViaMountStep(BuildStepList *bsl) - : AbstractRemoteLinuxDeployStep(bsl, stepId()) -{ - ctor(); -} - -MaemoInstallPackageViaMountStep::MaemoInstallPackageViaMountStep(BuildStepList *bsl, - MaemoInstallPackageViaMountStep *other) - : AbstractRemoteLinuxDeployStep(bsl, other) -{ - ctor(); -} - -void MaemoInstallPackageViaMountStep::ctor() -{ - m_deployService = new MaemoMountAndInstallPackageService(this); - setDefaultDisplayName(displayName()); -} - -AbstractRemoteLinuxDeployService *MaemoInstallPackageViaMountStep::deployService() const -{ - return m_deployService; -} - -bool MaemoInstallPackageViaMountStep::isDeploymentPossible(QString *whyNot) const -{ - const AbstractMaemoPackageCreationStep * const pStep - = deployConfiguration()->earlierBuildStep(this); - if (!pStep) { - if (whyNot) - *whyNot = tr("No Debian package creation step found."); - return false; - } - m_deployService->setPackageFilePath(pStep->packageFilePath()); - return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); -} - -QString MaemoInstallPackageViaMountStep::stepId() -{ - return QLatin1String("MaemoMountAndInstallDeployStep"); -} - -QString MaemoInstallPackageViaMountStep::displayName() -{ - return tr("Deploy package via UTFS mount"); -} - - -MaemoCopyFilesViaMountStep::MaemoCopyFilesViaMountStep(BuildStepList *bsl) - : AbstractRemoteLinuxDeployStep(bsl, stepId()) -{ - ctor(); -} - -MaemoCopyFilesViaMountStep::MaemoCopyFilesViaMountStep(BuildStepList *bsl, - MaemoCopyFilesViaMountStep *other) - : AbstractRemoteLinuxDeployStep(bsl, other) -{ - ctor(); -} - -void MaemoCopyFilesViaMountStep::ctor() -{ - m_deployService = new MaemoMountAndCopyFilesService(this); - setDefaultDisplayName(displayName()); -} - -AbstractRemoteLinuxDeployService *MaemoCopyFilesViaMountStep::deployService() const -{ - return m_deployService; -} - -bool MaemoCopyFilesViaMountStep::isDeploymentPossible(QString *whyNot) const -{ - QList deployableFiles; - const QSharedPointer deploymentInfo = deployConfiguration()->deploymentInfo(); - const int deployableCount = deploymentInfo->deployableCount(); - for (int i = 0; i < deployableCount; ++i) - deployableFiles << deploymentInfo->deployableAt(i); - m_deployService->setDeployableFiles(deployableFiles); - return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); -} - -QString MaemoCopyFilesViaMountStep::stepId() -{ - return QLatin1String("MaemoMountAndCopyDeployStep"); -} - -QString MaemoCopyFilesViaMountStep::displayName() -{ - return tr("Deploy files via UTFS mount"); -} - -} // namespace Internal -} // namespace RemoteLinux - -#include "maemodeploybymountsteps.moc" diff --git a/src/plugins/remotelinux/maemodeploybymountsteps.h b/src/plugins/remotelinux/maemodeploybymountsteps.h deleted file mode 100644 index 584bfb54599..00000000000 --- a/src/plugins/remotelinux/maemodeploybymountsteps.h +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMODEPLOYBYMOUNTSTEPS_H -#define MAEMODEPLOYBYMOUNTSTEPS_H - -#include - -namespace RemoteLinux { -namespace Internal { -class MaemoMountAndInstallPackageService; -class MaemoMountAndCopyFilesService; - -class MaemoInstallPackageViaMountStep : public RemoteLinux::AbstractRemoteLinuxDeployStep -{ - Q_OBJECT - -public: - MaemoInstallPackageViaMountStep(ProjectExplorer::BuildStepList *bsl); - MaemoInstallPackageViaMountStep(ProjectExplorer::BuildStepList *bsl, - MaemoInstallPackageViaMountStep *other); - - bool isDeploymentPossible(QString *whyNot = 0) const; - - static QString stepId(); - static QString displayName(); - -private: - AbstractRemoteLinuxDeployService *deployService() const; - - void ctor(); - - MaemoMountAndInstallPackageService *m_deployService; -}; - - -class MaemoCopyFilesViaMountStep : public RemoteLinux::AbstractRemoteLinuxDeployStep -{ - Q_OBJECT - -public: - MaemoCopyFilesViaMountStep(ProjectExplorer::BuildStepList *bsl); - MaemoCopyFilesViaMountStep(ProjectExplorer::BuildStepList *bsl, - MaemoCopyFilesViaMountStep *other); - - bool isDeploymentPossible(QString *whyNot = 0) const; - - static QString stepId(); - static QString displayName(); - -private: - AbstractRemoteLinuxDeployService *deployService() const; - - void ctor(); - - MaemoMountAndCopyFilesService *m_deployService; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMODEPLOYBYMOUNTSTEPS_H diff --git a/src/plugins/remotelinux/maemodeployconfigurationwidget.cpp b/src/plugins/remotelinux/maemodeployconfigurationwidget.cpp deleted file mode 100644 index 9c5f79fd9a3..00000000000 --- a/src/plugins/remotelinux/maemodeployconfigurationwidget.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemodeployconfigurationwidget.h" -#include "ui_maemodeployconfigurationwidget.h" - -#include "deploymentsettingsassistant.h" -#include "maemoglobal.h" -#include "qt4maemodeployconfiguration.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -MaemoDeployConfigurationWidget::MaemoDeployConfigurationWidget(QWidget *parent) - : DeployConfigurationWidget(parent), - ui(new Ui::MaemoDeployConfigurationWidget), - m_remoteLinuxWidget(new RemoteLinuxDeployConfigurationWidget) -{ - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->setSpacing(0); - mainLayout->addWidget(m_remoteLinuxWidget); - QWidget * const subWidget = new QWidget; - ui->setupUi(subWidget); - mainLayout->addWidget(subWidget); - mainLayout->addStretch(1); - - connect(m_remoteLinuxWidget, SIGNAL(currentModelChanged(const DeployableFilesPerProFile*)), - SLOT(handleCurrentModelChanged(const DeployableFilesPerProFile*))); - handleCurrentModelChanged(m_remoteLinuxWidget->currentModel()); -} - -MaemoDeployConfigurationWidget::~MaemoDeployConfigurationWidget() -{ - delete ui; -} - -void MaemoDeployConfigurationWidget::init(DeployConfiguration *dc) -{ - m_remoteLinuxWidget->init(dc); - connect(ui->addDesktopFileButton, SIGNAL(clicked()), SLOT(addDesktopFile())); - connect(ui->addIconButton, SIGNAL(clicked()), SLOT(addIcon())); - connect(deployConfiguration()->deploymentInfo().data(), SIGNAL(modelAboutToBeReset()), - SLOT(handleDeploymentInfoToBeReset())); -} - -Qt4MaemoDeployConfiguration *MaemoDeployConfigurationWidget::deployConfiguration() const -{ - return qobject_cast(m_remoteLinuxWidget->deployConfiguration()); -} - -void MaemoDeployConfigurationWidget::handleDeploymentInfoToBeReset() -{ - ui->addDesktopFileButton->setEnabled(false); - ui->addIconButton->setEnabled(false); -} - -void MaemoDeployConfigurationWidget::handleCurrentModelChanged(const DeployableFilesPerProFile *proFileInfo) -{ - ui->addDesktopFileButton->setEnabled(canAddDesktopFile(proFileInfo)); - ui->addIconButton->setEnabled(canAddIcon(proFileInfo)); -} - -void MaemoDeployConfigurationWidget::addDesktopFile() -{ - DeployableFilesPerProFile * const proFileInfo = m_remoteLinuxWidget->currentModel(); - QTC_ASSERT(canAddDesktopFile(proFileInfo), return); - - const QString desktopFilePath = QFileInfo(proFileInfo->proFilePath()).path() - + QLatin1Char('/') + proFileInfo->projectName() + QLatin1String(".desktop"); - if (!QFile::exists(desktopFilePath)) { - const QString desktopTemplate = QLatin1String("[Desktop Entry]\nEncoding=UTF-8\n" - "Version=1.0\nType=Application\nTerminal=false\nName=%1\nExec=%2\n" - "Icon=%1\nX-Window-Icon=\nX-HildonDesk-ShowInToolbar=true\n" - "X-Osso-Type=application/x-executable\n"); - Utils::FileSaver saver(desktopFilePath); - saver.write(desktopTemplate.arg(proFileInfo->projectName(), - proFileInfo->remoteExecutableFilePath()).toUtf8()); - if (!saver.finalize(this)) - return; - } - - DeployableFile d; - d.remoteDir = QLatin1String("/usr/share/applications"); - if (qobject_cast(deployConfiguration()->target())) - d.remoteDir += QLatin1String("/hildon"); - d.localFilePath = desktopFilePath; - if (!deployConfiguration()->deploymentSettingsAssistant()->addDeployableToProFile(proFileInfo, - QLatin1String("desktopfile"), d)) { - QMessageBox::critical(this, tr("Project File Update Failed"), - tr("Could not update the project file.")); - } else { - ui->addDesktopFileButton->setEnabled(false); - } -} - -void MaemoDeployConfigurationWidget::addIcon() -{ - DeployableFilesPerProFile * const proFileInfo = m_remoteLinuxWidget->currentModel(); - const int iconDim = MaemoGlobal::applicationIconSize(deployConfiguration()->supportedOsType()); - const QString origFilePath = QFileDialog::getOpenFileName(this, - tr("Choose Icon (will be scaled to %1x%1 pixels, if necessary)").arg(iconDim), - proFileInfo->projectDir(), QLatin1String("(*.png)")); - if (origFilePath.isEmpty()) - return; - QPixmap pixmap(origFilePath); - if (pixmap.isNull()) { - QMessageBox::critical(this, tr("Invalid Icon"), - tr("Unable to read image")); - return; - } - const QSize iconSize(iconDim, iconDim); - if (pixmap.size() != iconSize) - pixmap = pixmap.scaled(iconSize); - const QString newFileName = proFileInfo->projectName() + QLatin1Char('.') - + QFileInfo(origFilePath).suffix(); - const QString newFilePath = proFileInfo->projectDir() + QLatin1Char('/') + newFileName; - if (!pixmap.save(newFilePath)) { - QMessageBox::critical(this, tr("Failed to Save Icon"), - tr("Could not save icon to '%1'.").arg(newFilePath)); - return; - } - - if (!deployConfiguration()->deploymentSettingsAssistant()->addDeployableToProFile(proFileInfo, - QLatin1String("icon"), DeployableFile(newFilePath, remoteIconDir()))) { - QMessageBox::critical(this, tr("Project File Update Failed"), - tr("Could not update the project file.")); - } else { - ui->addIconButton->setEnabled(false); - } -} - -bool MaemoDeployConfigurationWidget::canAddDesktopFile(const DeployableFilesPerProFile *proFileInfo) const -{ - return proFileInfo && proFileInfo->isApplicationProject() - && deployConfiguration()->localDesktopFilePath(proFileInfo).isEmpty(); -} - -bool MaemoDeployConfigurationWidget::canAddIcon(const DeployableFilesPerProFile *proFileInfo) const -{ - return proFileInfo && proFileInfo->isApplicationProject() - && remoteIconFilePath(proFileInfo).isEmpty(); -} - -QString MaemoDeployConfigurationWidget::remoteIconFilePath(const DeployableFilesPerProFile *proFileInfo) const -{ - QTC_ASSERT(proFileInfo->projectType() == ApplicationTemplate, return QString()); - - const QStringList imageTypes = QStringList() << QLatin1String("jpg") << QLatin1String("png") - << QLatin1String("svg"); - for (int i = 0; i < proFileInfo->rowCount(); ++i) { - const DeployableFile &d = proFileInfo->deployableAt(i); - const QString extension = QFileInfo(d.localFilePath).suffix(); - if (d.remoteDir.startsWith(remoteIconDir()) && imageTypes.contains(extension)) - return d.remoteDir + QLatin1Char('/') + QFileInfo(d.localFilePath).fileName(); - } - return QString(); -} - -QString MaemoDeployConfigurationWidget::remoteIconDir() const -{ - return QString::fromLocal8Bit("/usr/share/icons/hicolor/%1x%1/apps") - .arg(MaemoGlobal::applicationIconSize(deployConfiguration()->supportedOsType())); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemodeployconfigurationwidget.h b/src/plugins/remotelinux/maemodeployconfigurationwidget.h deleted file mode 100644 index ea9b7b62084..00000000000 --- a/src/plugins/remotelinux/maemodeployconfigurationwidget.h +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMODEPLOYCONFIGURATIONWIDGET_H -#define MAEMODEPLOYCONFIGURATIONWIDGET_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { -class MaemoDeployConfigurationWidget; -} -QT_END_NAMESPACE - -namespace RemoteLinux { -class DeployableFilesPerProFile; -class RemoteLinuxDeployConfigurationWidget; - -namespace Internal { -class Qt4MaemoDeployConfiguration; - -class MaemoDeployConfigurationWidget : public ProjectExplorer::DeployConfigurationWidget -{ - Q_OBJECT - -public: - explicit MaemoDeployConfigurationWidget(QWidget *parent = 0); - ~MaemoDeployConfigurationWidget(); - - void init(ProjectExplorer::DeployConfiguration *dc); - - Qt4MaemoDeployConfiguration *deployConfiguration() const; - -private slots: - void addDesktopFile(); - void addIcon(); - void handleDeploymentInfoToBeReset(); - void handleCurrentModelChanged(const DeployableFilesPerProFile *proFileInfo); - -private: - bool canAddDesktopFile(const DeployableFilesPerProFile *proFileInfo) const; - bool canAddIcon(const DeployableFilesPerProFile *proFileInfo) const; - QString remoteIconFilePath(const DeployableFilesPerProFile *proFileInfo) const; - QString remoteIconDir() const; - - Ui::MaemoDeployConfigurationWidget *ui; - RemoteLinuxDeployConfigurationWidget * const m_remoteLinuxWidget; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMODEPLOYCONFIGURATIONWIDGET_H diff --git a/src/plugins/remotelinux/maemodeployconfigurationwidget.ui b/src/plugins/remotelinux/maemodeployconfigurationwidget.ui deleted file mode 100644 index 6cca3cac017..00000000000 --- a/src/plugins/remotelinux/maemodeployconfigurationwidget.ui +++ /dev/null @@ -1,48 +0,0 @@ - - - MaemoDeployConfigurationWidget - - - - 0 - 0 - 273 - 45 - - - - Form - - - - - - Add Desktop File - - - - - - - Add Launcher Icon... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - diff --git a/src/plugins/remotelinux/maemodeploymentmounter.cpp b/src/plugins/remotelinux/maemodeploymentmounter.cpp deleted file mode 100644 index a0705416b94..00000000000 --- a/src/plugins/remotelinux/maemodeploymentmounter.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemodeploymentmounter.h" - -#include "maemoglobal.h" -#include "maemoremotemounter.h" - -#include -#include -#include -#include -#include - -using namespace Qt4ProjectManager; -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { - -MaemoDeploymentMounter::MaemoDeploymentMounter(QObject *parent) - : QObject(parent), - m_state(Inactive), - m_mounter(new MaemoRemoteMounter(this)), - m_portsGatherer(new RemoteLinuxUsedPortsGatherer(this)) -{ - connect(m_mounter, SIGNAL(error(QString)), SLOT(handleMountError(QString))); - connect(m_mounter, SIGNAL(mounted()), SLOT(handleMounted())); - connect(m_mounter, SIGNAL(unmounted()), SLOT(handleUnmounted())); - connect(m_mounter, SIGNAL(reportProgress(QString)), - SIGNAL(reportProgress(QString))); - connect(m_mounter, SIGNAL(debugOutput(QString)), - SIGNAL(debugOutput(QString))); - - connect(m_portsGatherer, SIGNAL(error(QString)), - SLOT(handlePortsGathererError(QString))); - connect(m_portsGatherer, SIGNAL(portListReady()), - SLOT(handlePortListReady())); -} - -MaemoDeploymentMounter::~MaemoDeploymentMounter() {} - -void MaemoDeploymentMounter::setupMounts(const SshConnection::Ptr &connection, - const LinuxDeviceConfiguration::ConstPtr &devConf, - const QList &mountSpecs, - const Qt4BuildConfiguration *bc) -{ - QTC_ASSERT(m_state == Inactive, return); - - m_mountSpecs = mountSpecs; - m_connection = connection; - m_devConf = devConf; - m_mounter->setConnection(m_connection, m_devConf); - m_buildConfig = bc; - connect(m_connection.data(), SIGNAL(error(Utils::SshError)), - SLOT(handleConnectionError())); - setState(UnmountingOldDirs); - unmount(); -} - -void MaemoDeploymentMounter::tearDownMounts() -{ - QTC_ASSERT(m_state == Mounted, return); - - setState(UnmountingCurrentMounts); - unmount(); -} - -void MaemoDeploymentMounter::setupMounter() -{ - QTC_ASSERT(m_state == UnmountingOldDirs, return); - - setState(UnmountingCurrentDirs); - - m_mounter->resetMountSpecifications(); - m_mounter->setBuildConfiguration(m_buildConfig); - foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs) - m_mounter->addMountSpecification(mountSpec, true); - unmount(); -} - -void MaemoDeploymentMounter::unmount() -{ - QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs - || m_state == UnmountingCurrentMounts, return); - - if (m_mounter->hasValidMountSpecifications()) - m_mounter->unmount(); - else - handleUnmounted(); -} - -void MaemoDeploymentMounter::handleMounted() -{ - QTC_ASSERT(m_state == Mounting || m_state == Inactive, return); - - if (m_state == Inactive) - return; - - setState(Mounted); - emit setupDone(); -} - -void MaemoDeploymentMounter::handleUnmounted() -{ - QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs - || m_state == UnmountingCurrentMounts || m_state == Inactive, return); - - switch (m_state) { - case UnmountingOldDirs: - setupMounter(); - break; - case UnmountingCurrentDirs: - setState(GatheringPorts); - m_portsGatherer->start(m_connection, m_devConf); - break; - case UnmountingCurrentMounts: - setState(Inactive); - emit tearDownDone(); - break; - case Inactive: - default: - break; - } -} - -void MaemoDeploymentMounter::handlePortsGathererError(const QString &errorMsg) -{ - QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return); - - if (m_state == Inactive) - return; - - setState(Inactive); - m_mounter->resetMountSpecifications(); - emit error(errorMsg); -} - -void MaemoDeploymentMounter::handlePortListReady() -{ - QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return); - - if (m_state == Inactive) - return; - - setState(Mounting); - m_freePorts = MaemoGlobal::freePorts(m_devConf, m_buildConfig->qtVersion()); - m_mounter->mount(&m_freePorts, m_portsGatherer); -} - -void MaemoDeploymentMounter::handleMountError(const QString &errorMsg) -{ - QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs - || m_state == UnmountingCurrentMounts || m_state == Mounting || m_state == Mounted - || m_state == Inactive, return); - - if (m_state == Inactive) - return; - - setState(Inactive); - emit error(errorMsg); -} - -void MaemoDeploymentMounter::handleConnectionError() -{ - if (m_state == Inactive) - return; - - setState(Inactive); - emit error(tr("Connection failed: %1").arg(m_connection->errorString())); -} - -void MaemoDeploymentMounter::setState(State newState) -{ - if (m_state == newState) - return; - if (newState == Inactive && m_connection) { - disconnect(m_connection.data(), 0, this, 0); - m_connection.clear(); - } - m_state = newState; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemodeploymentmounter.h b/src/plugins/remotelinux/maemodeploymentmounter.h deleted file mode 100644 index aac42add035..00000000000 --- a/src/plugins/remotelinux/maemodeploymentmounter.h +++ /dev/null @@ -1,105 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMODEPLOYMENTMOUNTER_H -#define MAEMODEPLOYMENTMOUNTER_H - -#include "maemomountspecification.h" -#include "portlist.h" - -#include -#include -#include - -namespace Utils { class SshConnection; } -namespace Qt4ProjectManager { class Qt4BuildConfiguration; } - -namespace RemoteLinux { -class LinuxDeviceConfiguration; -class RemoteLinuxUsedPortsGatherer; - -namespace Internal { -class MaemoRemoteMounter; - -class MaemoDeploymentMounter : public QObject -{ - Q_OBJECT -public: - explicit MaemoDeploymentMounter(QObject *parent = 0); - ~MaemoDeploymentMounter(); - - // Connection must be in connected state. - void setupMounts(const QSharedPointer &connection, - const QSharedPointer &devConf, - const QList &mountSpecs, - const Qt4ProjectManager::Qt4BuildConfiguration *bc); - void tearDownMounts(); - -signals: - void debugOutput(const QString &output); - void setupDone(); - void tearDownDone(); - void error(const QString &error); - void reportProgress(const QString &message); - -private slots: - void handleMounted(); - void handleUnmounted(); - void handleMountError(const QString &errorMsg); - void handlePortsGathererError(const QString &errorMsg); - void handlePortListReady(); - void handleConnectionError(); - -private: - enum State { - Inactive, UnmountingOldDirs, UnmountingCurrentDirs, GatheringPorts, - Mounting, Mounted, UnmountingCurrentMounts - }; - - void unmount(); - void setupMounter(); - void setState(State newState); - - State m_state; - QSharedPointer m_connection; - QSharedPointer m_devConf; - MaemoRemoteMounter * const m_mounter; - RemoteLinuxUsedPortsGatherer * const m_portsGatherer; - PortList m_freePorts; - QList m_mountSpecs; - const Qt4ProjectManager::Qt4BuildConfiguration *m_buildConfig; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMODEPLOYMENTMOUNTER_H diff --git a/src/plugins/remotelinux/maemodeploystepfactory.cpp b/src/plugins/remotelinux/maemodeploystepfactory.cpp deleted file mode 100644 index c6db2c03bb8..00000000000 --- a/src/plugins/remotelinux/maemodeploystepfactory.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemodeploystepfactory.h" - -#include "genericdirectuploadstep.h" -#include "maddeuploadandinstallpackagesteps.h" -#include "maemodeploybymountsteps.h" -#include "maemoinstalltosysrootstep.h" -#include "qt4maemotarget.h" -#include "qt4maemodeployconfiguration.h" -#include "uploadandinstalltarpackagestep.h" - -#include -#include -#include -#include - -#include - -using namespace ProjectExplorer; - -namespace RemoteLinux { -namespace Internal { -namespace { -const QString OldMaemoDeployStepId(QLatin1String("Qt4ProjectManager.MaemoDeployStep")); -} // anonymous namespace - -MaemoDeployStepFactory::MaemoDeployStepFactory(QObject *parent) - : IBuildStepFactory(parent) -{ -} - -QStringList MaemoDeployStepFactory::availableCreationIds(BuildStepList *parent) const -{ - QStringList ids; - if (!qobject_cast(parent->parent())) - return ids; - - AbstractQt4MaemoTarget * const maemoTarget - = qobject_cast(parent->target()); - if (maemoTarget) - ids << MaemoMakeInstallToSysrootStep::Id; - if (qobject_cast(parent->target())) { - ids << MaemoInstallDebianPackageToSysrootStep::Id; - ids << MaemoUploadAndInstallPackageStep::stepId(); - } else if (qobject_cast(parent->target())) { - ids << MaemoInstallRpmPackageToSysrootStep::Id; - ids << MeegoUploadAndInstallPackageStep::stepId(); - } - if (qobject_cast(parent->target())) - ids << GenericDirectUploadStep::stepId(); - if (qobject_cast(parent->target())) - ids << MaemoInstallPackageViaMountStep::stepId() << MaemoCopyFilesViaMountStep::stepId(); - - return ids; -} - -QString MaemoDeployStepFactory::displayNameForId(const QString &id) const -{ - if (id == MaemoInstallPackageViaMountStep::stepId()) - return MaemoInstallPackageViaMountStep::displayName(); - else if (id == MaemoCopyFilesViaMountStep::stepId()) - return MaemoCopyFilesViaMountStep::displayName(); - else if (id == MaemoUploadAndInstallPackageStep::stepId()) - return MaemoUploadAndInstallPackageStep::displayName(); - else if (id == MeegoUploadAndInstallPackageStep::stepId()) - return MeegoUploadAndInstallPackageStep::displayName(); - else if (id == MaemoInstallDebianPackageToSysrootStep::Id) - return MaemoInstallDebianPackageToSysrootStep::displayName(); - else if (id == MaemoInstallRpmPackageToSysrootStep::Id) - return MaemoInstallRpmPackageToSysrootStep::displayName(); - else if (id == MaemoCopyToSysrootStep::Id) - return MaemoCopyToSysrootStep::displayName(); - else if (id == MaemoMakeInstallToSysrootStep::Id) - return MaemoMakeInstallToSysrootStep::displayName(); - else if (id == GenericDirectUploadStep::stepId()) - return GenericDirectUploadStep::displayName(); - return QString(); -} - -bool MaemoDeployStepFactory::canCreate(BuildStepList *parent, const QString &id) const -{ - return availableCreationIds(parent).contains(id) && !parent->contains(id); -} - -BuildStep *MaemoDeployStepFactory::create(BuildStepList *parent, const QString &id) -{ - const Target * const t = parent->target(); - - if (id == MaemoInstallDebianPackageToSysrootStep::Id) { - return new MaemoInstallDebianPackageToSysrootStep(parent); - } else if (id == MaemoInstallRpmPackageToSysrootStep::Id) { - return new MaemoInstallRpmPackageToSysrootStep(parent); - } else if (id == MaemoCopyToSysrootStep::Id) { - return new MaemoCopyToSysrootStep(parent); - } else if (id == MaemoMakeInstallToSysrootStep::Id) { - return new MaemoMakeInstallToSysrootStep(parent); - } else if (id == MaemoInstallPackageViaMountStep::stepId() - || (id == OldMaemoDeployStepId && qobject_cast< const Qt4Maemo5Target *>(t))) { - return new MaemoInstallPackageViaMountStep(parent); - } else if (id == MaemoCopyFilesViaMountStep::stepId()) { - return new MaemoCopyFilesViaMountStep(parent); - } else if (id == MaemoUploadAndInstallPackageStep::stepId() - || (id == OldMaemoDeployStepId && (qobject_cast(t)))) { - return new MaemoUploadAndInstallPackageStep(parent); - } else if (id == MeegoUploadAndInstallPackageStep::stepId() - || (id == OldMaemoDeployStepId && (qobject_cast(t)))) { - return new MeegoUploadAndInstallPackageStep(parent); - } else if (id == GenericDirectUploadStep::stepId()) { - return new GenericDirectUploadStep(parent, id); - } - - return 0; -} - -bool MaemoDeployStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const -{ - return canCreate(parent, idFromMap(map)) - || idFromMap(map) == OldMaemoDeployStepId; -} - -BuildStep *MaemoDeployStepFactory::restore(BuildStepList *parent, const QVariantMap &map) -{ - Q_ASSERT(canRestore(parent, map)); - BuildStep * const step = create(parent, idFromMap(map)); - if (!step->fromMap(map)) { - delete step; - return 0; - } - return step; -} - -bool MaemoDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const -{ - return canCreate(parent, product->id()); -} - -BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *product) -{ - Q_ASSERT(canClone(parent, product)); - if (product->id() == MaemoInstallPackageViaMountStep::stepId()) { - return new MaemoInstallPackageViaMountStep(parent, - qobject_cast(product)); - } else if (product->id() == MaemoCopyFilesViaMountStep::stepId()) { - return new MaemoCopyFilesViaMountStep(parent, - qobject_cast(product)); - } else if (product->id() == MaemoUploadAndInstallPackageStep::stepId()) { - return new MaemoUploadAndInstallPackageStep(parent, - qobject_cast(product)); - } else if (product->id() == MeegoUploadAndInstallPackageStep::stepId()) { - return new MeegoUploadAndInstallPackageStep(parent, - qobject_cast(product)); - } else if (product->id() == MaemoInstallDebianPackageToSysrootStep::Id) { - return new MaemoInstallDebianPackageToSysrootStep(parent, - qobject_cast(product)); - } else if (product->id() == MaemoInstallRpmPackageToSysrootStep::Id) { - return new MaemoInstallRpmPackageToSysrootStep(parent, - qobject_cast(product)); - } else if (product->id() == MaemoCopyToSysrootStep::Id) { - return new MaemoCopyToSysrootStep(parent, - qobject_cast(product)); - } else if (product->id() == MaemoMakeInstallToSysrootStep::Id) { - return new MaemoMakeInstallToSysrootStep(parent, - qobject_cast(product)); - } else if (product->id() == GenericDirectUploadStep::stepId()) { - return new GenericDirectUploadStep(parent, - qobject_cast(product)); - } - return 0; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemodeploystepfactory.h b/src/plugins/remotelinux/maemodeploystepfactory.h deleted file mode 100644 index 8f0274ac5b1..00000000000 --- a/src/plugins/remotelinux/maemodeploystepfactory.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMODEPLOYSTEPFACTORY_H -#define MAEMODEPLOYSTEPFACTORY_H - -#include - -namespace RemoteLinux { -namespace Internal { - -class MaemoDeployStepFactory : public ProjectExplorer::IBuildStepFactory -{ -public: - MaemoDeployStepFactory(QObject *parent = 0); - - virtual QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; - virtual QString displayNameForId(const QString &id) const; - - virtual bool canCreate(ProjectExplorer::BuildStepList *parent, - const QString &id) const; - virtual ProjectExplorer::BuildStep * - create(ProjectExplorer::BuildStepList *parent, const QString &id); - - virtual bool canRestore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map) const; - virtual ProjectExplorer::BuildStep * - restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); - - virtual bool canClone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product) const; - virtual ProjectExplorer::BuildStep * - clone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product); -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMODEPLOYSTEPFACTORY_H diff --git a/src/plugins/remotelinux/maemodeviceconfigwizard.cpp b/src/plugins/remotelinux/maemodeviceconfigwizard.cpp deleted file mode 100644 index 73870f2f3db..00000000000 --- a/src/plugins/remotelinux/maemodeviceconfigwizard.cpp +++ /dev/null @@ -1,639 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemodeviceconfigwizard.h" -#include "ui_maemodeviceconfigwizardkeycreationpage.h" -#include "ui_maemodeviceconfigwizardkeydeploymentpage.h" -#include "ui_maemodeviceconfigwizardpreviouskeysetupcheckpage.h" -#include "ui_maemodeviceconfigwizardreusekeyscheckpage.h" -#include "ui_maemodeviceconfigwizardstartpage.h" - -#include "maddedevicetester.h" -#include "maemoconstants.h" -#include "maemoglobal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { -namespace { - -QString defaultUser(const QString &osType) -{ - if (osType == QLatin1String(MeeGoOsType)) - return QLatin1String("meego"); - return QLatin1String("developer"); -} - -QString defaultHost(LinuxDeviceConfiguration::DeviceType type) -{ - return QLatin1String(type == LinuxDeviceConfiguration::Hardware ? "192.168.2.15" : "localhost"); -} - -struct WizardData -{ - QString configName; - QString hostName; - QString osType; - SshConnectionParameters::AuthenticationType authType; - LinuxDeviceConfiguration::DeviceType deviceType; - QString privateKeyFilePath; - QString publicKeyFilePath; - QString userName; - QString password; - int sshPort; -}; - -enum PageId { - StartPageId, PreviousKeySetupCheckPageId, ReuseKeysCheckPageId, KeyCreationPageId, - KeyDeploymentPageId, FinalPageId -}; - -class MaemoDeviceConfigWizardStartPage : public QWizardPage -{ - Q_OBJECT - -public: - MaemoDeviceConfigWizardStartPage(QWidget *parent = 0) - : QWizardPage(parent), m_ui(new Ui::MaemoDeviceConfigWizardStartPage) - { - m_ui->setupUi(this); - setTitle(tr("General Information")); - setSubTitle(QLatin1String(" ")); // For Qt bug (background color) - - m_ui->osTypeComboBox->addItem(RemoteLinuxUtils::osTypeToString(QLatin1String(Maemo5OsType)), - QLatin1String(Maemo5OsType)); - m_ui->osTypeComboBox->addItem(RemoteLinuxUtils::osTypeToString(QLatin1String(HarmattanOsType)), - QLatin1String(HarmattanOsType)); - m_ui->osTypeComboBox->addItem(RemoteLinuxUtils::osTypeToString(QLatin1String(MeeGoOsType)), - QLatin1String(MeeGoOsType)); - - QButtonGroup *buttonGroup = new QButtonGroup(this); - buttonGroup->setExclusive(true); - buttonGroup->addButton(m_ui->hwButton); - buttonGroup->addButton(m_ui->emulatorButton); - connect(buttonGroup, SIGNAL(buttonClicked(int)), - SLOT(handleDeviceTypeChanged())); - - m_ui->nameLineEdit->setText(QLatin1String("(New Configuration)")); - m_ui->osTypeComboBox->setCurrentIndex(m_ui->osTypeComboBox->findData(QLatin1String(HarmattanOsType))); - m_ui->hwButton->setChecked(true); - handleDeviceTypeChanged(); - m_ui->hostNameLineEdit->setText(defaultHost(deviceType())); - m_ui->sshPortSpinBox->setMinimum(1); - m_ui->sshPortSpinBox->setMaximum(65535); - m_ui->sshPortSpinBox->setValue(22); - connect(m_ui->nameLineEdit, SIGNAL(textChanged(QString)), this, - SIGNAL(completeChanged())); - connect(m_ui->hostNameLineEdit, SIGNAL(textChanged(QString)), this, - SIGNAL(completeChanged())); - } - - virtual bool isComplete() const - { - return !configName().isEmpty() && !hostName().isEmpty(); - } - - QString configName() const { return m_ui->nameLineEdit->text().trimmed(); } - - QString hostName() const - { - return deviceType() == LinuxDeviceConfiguration::Emulator - ? defaultHost(LinuxDeviceConfiguration::Emulator) - : m_ui->hostNameLineEdit->text().trimmed(); - } - - QString osType() const - { - return m_ui->osTypeComboBox->itemData(m_ui->osTypeComboBox->currentIndex()).toString(); - } - - LinuxDeviceConfiguration::DeviceType deviceType() const - { - return m_ui->hwButton->isChecked() - ? LinuxDeviceConfiguration::Hardware : LinuxDeviceConfiguration::Emulator; - } - - int sshPort() const - { - return deviceType() == LinuxDeviceConfiguration::Emulator - ? 6666 : m_ui->sshPortSpinBox->value(); - } - -private slots: - void handleDeviceTypeChanged() - { - const bool enable = deviceType() == LinuxDeviceConfiguration::Hardware; - m_ui->hostNameLabel->setEnabled(enable); - m_ui->hostNameLineEdit->setEnabled(enable); - m_ui->sshPortLabel->setEnabled(enable); - m_ui->sshPortSpinBox->setEnabled(enable); - } - -private: - const QScopedPointer m_ui; -}; - -class MaemoDeviceConfigWizardPreviousKeySetupCheckPage : public QWizardPage -{ - Q_OBJECT -public: - MaemoDeviceConfigWizardPreviousKeySetupCheckPage(QWidget *parent) - : QWizardPage(parent), - m_ui(new Ui::MaemoDeviceConfigWizardCheckPreviousKeySetupPage) - { - m_ui->setupUi(this); - m_ui->privateKeyFilePathChooser->setExpectedKind(PathChooser::File); - setTitle(tr("Device Status Check")); - setSubTitle(QLatin1String(" ")); // For Qt bug (background color) - QButtonGroup * const buttonGroup = new QButtonGroup(this); - buttonGroup->setExclusive(true); - buttonGroup->addButton(m_ui->keyWasSetUpButton); - buttonGroup->addButton(m_ui->keyWasNotSetUpButton); - connect(buttonGroup, SIGNAL(buttonClicked(int)), - SLOT(handleSelectionChanged())); - connect(m_ui->privateKeyFilePathChooser, SIGNAL(changed(QString)), - this, SIGNAL(completeChanged())); - } - - virtual bool isComplete() const - { - return !keyBasedLoginWasSetup() - || m_ui->privateKeyFilePathChooser->isValid(); - } - - virtual void initializePage() - { - m_ui->keyWasNotSetUpButton->setChecked(true); - m_ui->privateKeyFilePathChooser->setPath(LinuxDeviceConfiguration::defaultPrivateKeyFilePath()); - handleSelectionChanged(); - } - - bool keyBasedLoginWasSetup() const { - return m_ui->keyWasSetUpButton->isChecked(); - } - - QString privateKeyFilePath() const { - return m_ui->privateKeyFilePathChooser->path(); - } - -private: - Q_SLOT void handleSelectionChanged() - { - m_ui->privateKeyFilePathChooser->setEnabled(keyBasedLoginWasSetup()); - emit completeChanged(); - } - - const QScopedPointer m_ui; -}; - -class MaemoDeviceConfigWizardReuseKeysCheckPage : public QWizardPage -{ - Q_OBJECT -public: - MaemoDeviceConfigWizardReuseKeysCheckPage(QWidget *parent) - : QWizardPage(parent), - m_ui(new Ui::MaemoDeviceConfigWizardReuseKeysCheckPage) - { - m_ui->setupUi(this); - setTitle(tr("Existing Keys Check")); - setSubTitle(QLatin1String(" ")); // For Qt bug (background color) - m_ui->publicKeyFilePathChooser->setExpectedKind(PathChooser::File); - m_ui->privateKeyFilePathChooser->setExpectedKind(PathChooser::File); - QButtonGroup * const buttonGroup = new QButtonGroup(this); - buttonGroup->setExclusive(true); - buttonGroup->addButton(m_ui->reuseButton); - buttonGroup->addButton(m_ui->dontReuseButton); - connect(buttonGroup, SIGNAL(buttonClicked(int)), - SLOT(handleSelectionChanged())); - connect(m_ui->privateKeyFilePathChooser, SIGNAL(changed(QString)), - this, SIGNAL(completeChanged())); - connect(m_ui->publicKeyFilePathChooser, SIGNAL(changed(QString)), - this, SIGNAL(completeChanged())); - } - - virtual bool isComplete() const - { - return !reuseKeys() || (m_ui->publicKeyFilePathChooser->isValid() - && m_ui->privateKeyFilePathChooser->isValid()); - } - - virtual void initializePage() - { - m_ui->dontReuseButton->setChecked(true); - m_ui->privateKeyFilePathChooser->setPath(LinuxDeviceConfiguration::defaultPrivateKeyFilePath()); - m_ui->publicKeyFilePathChooser->setPath(LinuxDeviceConfiguration::defaultPublicKeyFilePath()); - handleSelectionChanged(); - } - - bool reuseKeys() const { return m_ui->reuseButton->isChecked(); } - - QString privateKeyFilePath() const { - return m_ui->privateKeyFilePathChooser->path(); - } - - QString publicKeyFilePath() const { - return m_ui->publicKeyFilePathChooser->path(); - } - -private: - Q_SLOT void handleSelectionChanged() - { - m_ui->privateKeyFilePathLabel->setEnabled(reuseKeys()); - m_ui->privateKeyFilePathChooser->setEnabled(reuseKeys()); - m_ui->publicKeyFilePathLabel->setEnabled(reuseKeys()); - m_ui->publicKeyFilePathChooser->setEnabled(reuseKeys()); - emit completeChanged(); - } - - const QScopedPointer m_ui; -}; - -class MaemoDeviceConfigWizardKeyCreationPage : public QWizardPage -{ - Q_OBJECT -public: - MaemoDeviceConfigWizardKeyCreationPage(QWidget *parent) - : QWizardPage(parent), - m_ui(new Ui::MaemoDeviceConfigWizardKeyCreationPage) - { - m_ui->setupUi(this); - setTitle(tr("Key Creation")); - setSubTitle(QLatin1String(" ")); // For Qt bug (background color) - connect(m_ui->createKeysButton, SIGNAL(clicked()), SLOT(createKeys())); - } - - QString privateKeyFilePath() const { - return m_ui->keyDirPathChooser->path() + QLatin1String("/qtc_id_rsa"); - } - - QString publicKeyFilePath() const { - return privateKeyFilePath() + QLatin1String(".pub"); - } - - virtual void initializePage() - { - m_isComplete = false; - const QString &dir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation) - + QLatin1String("/.ssh"); - m_ui->keyDirPathChooser->setPath(dir); - enableInput(); - } - - virtual bool isComplete() const { return m_isComplete; } - -private: - - Q_SLOT void createKeys() - { - const QString &dirPath = m_ui->keyDirPathChooser->path(); - QFileInfo fi(dirPath); - if (fi.exists() && !fi.isDir()) { - QMessageBox::critical(this, tr("Cannot Create Keys"), - tr("The path you have entered is not a directory.")); - return; - } - if (!fi.exists() && !QDir::root().mkpath(dirPath)) { - QMessageBox::critical(this, tr("Cannot Create Keys"), - tr("The directory you have entered does not exist and " - "cannot be created.")); - return; - } - - m_ui->keyDirPathChooser->setEnabled(false); - m_ui->createKeysButton->setEnabled(false); - m_ui->statusLabel->setText(tr("Creating keys ... ")); - SshKeyGenerator keyGenerator; - if (!keyGenerator.generateKeys(SshKeyGenerator::Rsa, - SshKeyGenerator::Mixed, 1024)) { - QMessageBox::critical(this, tr("Cannot Create Keys"), - tr("Key creation failed: %1").arg(keyGenerator.error())); - enableInput(); - return; - } - - if (!saveFile(privateKeyFilePath(), keyGenerator.privateKey()) - || !saveFile(publicKeyFilePath(), keyGenerator.publicKey())) { - enableInput(); - return; - } - QFile::setPermissions(privateKeyFilePath(), - QFile::ReadOwner | QFile::WriteOwner); - - m_ui->statusLabel->setText(m_ui->statusLabel->text() + tr("Done.")); - m_isComplete = true; - emit completeChanged(); - } - - bool saveFile(const QString &filePath, const QByteArray &data) - { - Utils::FileSaver saver(filePath); - saver.write(data); - if (!saver.finalize()) { - QMessageBox::critical(this, tr("Could Not Save Key File"), saver.errorString()); - return false; - } - return true; - } - - void enableInput() - { - m_ui->keyDirPathChooser->setEnabled(true); - m_ui->createKeysButton->setEnabled(true); - m_ui->statusLabel->clear(); - } - - const QScopedPointer m_ui; - bool m_isComplete; -}; - -class MaemoDeviceConfigWizardKeyDeploymentPage : public QWizardPage -{ - Q_OBJECT -public: - MaemoDeviceConfigWizardKeyDeploymentPage(const WizardData &wizardData, - QWidget *parent = 0) - : QWizardPage(parent), - m_ui(new Ui::MaemoDeviceConfigWizardKeyDeploymentPage), - m_wizardData(wizardData), - m_keyDeployer(new SshKeyDeployer(this)) - { - m_ui->setupUi(this); - m_instructionTextTemplate = m_ui->instructionLabel->text(); - setTitle(tr("Key Deployment")); - setSubTitle(QLatin1String(" ")); // For Qt bug (background color) - connect(m_ui->deviceAddressLineEdit, SIGNAL(textChanged(QString)), - SLOT(enableOrDisableButton())); - connect(m_ui->passwordLineEdit, SIGNAL(textChanged(QString)), - SLOT(enableOrDisableButton())); - connect(m_ui->deployButton, SIGNAL(clicked()), SLOT(deployKey())); - connect(m_keyDeployer, SIGNAL(error(QString)), - SLOT(handleKeyDeploymentError(QString))); - connect(m_keyDeployer, SIGNAL(finishedSuccessfully()), - SLOT(handleKeyDeploymentSuccess())); - } - - virtual void initializePage() - { - m_isComplete = false; - m_ui->deviceAddressLineEdit->setText(m_wizardData.hostName); - m_ui->instructionLabel->setText(QString(m_instructionTextTemplate) - .replace(QLatin1String("%%%maddev%%%"), - MaemoGlobal::madDeveloperUiName(m_wizardData.osType))); - m_ui->passwordLineEdit->clear(); - enableInput(); - } - - virtual bool isComplete() const { return m_isComplete; } - - QString hostAddress() const { - return m_ui->deviceAddressLineEdit->text().trimmed(); - } - -private: - Q_SLOT void enableOrDisableButton() - { - m_ui->deployButton->setEnabled(!hostAddress().isEmpty() - && !password().isEmpty()); - } - - Q_SLOT void deployKey() - { - using namespace Utils; - m_ui->deviceAddressLineEdit->setEnabled(false); - m_ui->passwordLineEdit->setEnabled(false); - m_ui->deployButton->setEnabled(false); - SshConnectionParameters sshParams(SshConnectionParameters::NoProxy); - sshParams.authenticationType = SshConnectionParameters::AuthenticationByPassword; - sshParams.host = hostAddress(); - sshParams.port = m_wizardData.sshPort; - sshParams.password = password(); - sshParams.timeout = 10; - sshParams.userName = defaultUser(m_wizardData.osType); - m_ui->statusLabel->setText(tr("Deploying... ")); - m_keyDeployer->deployPublicKey(sshParams, m_wizardData.publicKeyFilePath); - } - - Q_SLOT void handleKeyDeploymentError(const QString &errorMsg) - { - QMessageBox::critical(this, tr("Key Deployment Failure"), errorMsg); - enableInput(); - } - - Q_SLOT void handleKeyDeploymentSuccess() - { - QMessageBox::information(this, tr("Key Deployment Success"), - tr("The key was successfully deployed. You may now close " - "the \"%1\" application and continue.") - .arg(MaemoGlobal::madDeveloperUiName(m_wizardData.osType))); - m_ui->statusLabel->setText(m_ui->statusLabel->text() + tr("Done.")); - m_isComplete = true; - emit completeChanged(); - } - - void enableInput() - { - m_ui->deviceAddressLineEdit->setEnabled(true); - m_ui->passwordLineEdit->setEnabled(true); - m_ui->statusLabel->clear(); - enableOrDisableButton(); - } - - QString password() const { - return m_ui->passwordLineEdit->text().trimmed(); - } - - - const QScopedPointer m_ui; - bool m_isComplete; - const WizardData &m_wizardData; - SshKeyDeployer * const m_keyDeployer; - QString m_instructionTextTemplate; -}; - -class MaemoDeviceConfigWizardFinalPage : public GenericLinuxDeviceConfigurationWizardFinalPage -{ - Q_OBJECT -public: - MaemoDeviceConfigWizardFinalPage(const WizardData &wizardData, QWidget *parent) - : GenericLinuxDeviceConfigurationWizardFinalPage(parent), m_wizardData(wizardData) - { - } - -private: - QString infoText() const - { - if (m_wizardData.deviceType == LinuxDeviceConfiguration::Emulator) - return tr("The new device configuration will now be created."); - return GenericLinuxDeviceConfigurationWizardFinalPage::infoText(); - } - - const WizardData &m_wizardData; -}; - -} // anonymous namespace - -struct MaemoDeviceConfigWizardPrivate -{ - MaemoDeviceConfigWizardPrivate(QWidget *parent) - : startPage(parent), - previousKeySetupPage(parent), - reuseKeysCheckPage(parent), - keyCreationPage(parent), - keyDeploymentPage(wizardData, parent), - finalPage(wizardData, parent) - { - } - - WizardData wizardData; - MaemoDeviceConfigWizardStartPage startPage; - MaemoDeviceConfigWizardPreviousKeySetupCheckPage previousKeySetupPage; - MaemoDeviceConfigWizardReuseKeysCheckPage reuseKeysCheckPage; - MaemoDeviceConfigWizardKeyCreationPage keyCreationPage; - MaemoDeviceConfigWizardKeyDeploymentPage keyDeploymentPage; - MaemoDeviceConfigWizardFinalPage finalPage; -}; - - -MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(QWidget *parent) - : ILinuxDeviceConfigurationWizard(parent), d(new MaemoDeviceConfigWizardPrivate(this)) -{ - setWindowTitle(tr("New Device Configuration Setup")); - setPage(StartPageId, &d->startPage); - setPage(PreviousKeySetupCheckPageId, &d->previousKeySetupPage); - setPage(ReuseKeysCheckPageId, &d->reuseKeysCheckPage); - setPage(KeyCreationPageId, &d->keyCreationPage); - setPage(KeyDeploymentPageId, &d->keyDeploymentPage); - setPage(FinalPageId, &d->finalPage); - d->finalPage.setCommitPage(true); -} - -MaemoDeviceConfigWizard::~MaemoDeviceConfigWizard() -{ - delete d; -} - -LinuxDeviceConfiguration::Ptr MaemoDeviceConfigWizard::deviceConfiguration() -{ - bool doTest; - QString freePortsSpec; - Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); - sshParams.userName = defaultUser(d->wizardData.osType); - sshParams.host = d->wizardData.hostName; - sshParams.port = d->wizardData.sshPort; - if (d->wizardData.deviceType == LinuxDeviceConfiguration::Emulator) { - sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByPassword; - sshParams.password = d->wizardData.osType == QLatin1String(MeeGoOsType) - ? QLatin1String("meego") : QString(); - sshParams.timeout = 30; - freePortsSpec = QLatin1String("13219,14168"); - doTest = false; - } else { - sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByKey; - sshParams.privateKeyFile = d->wizardData.privateKeyFilePath; - sshParams.timeout = 10; - freePortsSpec = QLatin1String("10000-10100"); - doTest = true; - } - const LinuxDeviceConfiguration::Ptr devConf = LinuxDeviceConfiguration::create(d->wizardData.configName, - d->wizardData.osType, d->wizardData.deviceType, PortList::fromString(freePortsSpec), - sshParams); - if (doTest) { - LinuxDeviceTestDialog dlg(devConf, new MaddeDeviceTester(this), this); - dlg.exec(); - } - return devConf; -} - -int MaemoDeviceConfigWizard::nextId() const -{ - switch (currentId()) { - case StartPageId: - d->wizardData.configName = d->startPage.configName(); - d->wizardData.osType = d->startPage.osType(); - d->wizardData.deviceType = d->startPage.deviceType(); - d->wizardData.hostName = d->startPage.hostName(); - d->wizardData.sshPort = d->startPage.sshPort(); - if (d->wizardData.deviceType == LinuxDeviceConfiguration::Emulator) - return FinalPageId; - return PreviousKeySetupCheckPageId; - case PreviousKeySetupCheckPageId: - if (d->previousKeySetupPage.keyBasedLoginWasSetup()) { - d->wizardData.privateKeyFilePath - = d->previousKeySetupPage.privateKeyFilePath(); - return FinalPageId; - } else { - return ReuseKeysCheckPageId; - } - case ReuseKeysCheckPageId: - if (d->reuseKeysCheckPage.reuseKeys()) { - d->wizardData.privateKeyFilePath - = d->reuseKeysCheckPage.privateKeyFilePath(); - d->wizardData.publicKeyFilePath - = d->reuseKeysCheckPage.publicKeyFilePath(); - return KeyDeploymentPageId; - } else { - return KeyCreationPageId; - } - case KeyCreationPageId: - d->wizardData.privateKeyFilePath - = d->keyCreationPage.privateKeyFilePath(); - d->wizardData.publicKeyFilePath - = d->keyCreationPage.publicKeyFilePath(); - return KeyDeploymentPageId; - case KeyDeploymentPageId: - d->wizardData.hostName = d->keyDeploymentPage.hostAddress(); - return FinalPageId; - case FinalPageId: return -1; - default: - Q_ASSERT(false); - return -1; - } -} - -} // namespace Internal -} // namespace RemoteLinux - -#include "maemodeviceconfigwizard.moc" diff --git a/src/plugins/remotelinux/maemodeviceconfigwizard.h b/src/plugins/remotelinux/maemodeviceconfigwizard.h deleted file mode 100644 index c3b93a48c03..00000000000 --- a/src/plugins/remotelinux/maemodeviceconfigwizard.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMODEVICECONFIGWIZARD_H -#define MAEMODEVICECONFIGWIZARD_H - -#include - -namespace RemoteLinux { -namespace Internal { - -struct MaemoDeviceConfigWizardPrivate; - -class MaemoDeviceConfigWizard : public RemoteLinux::ILinuxDeviceConfigurationWizard -{ - Q_OBJECT - -public: - explicit MaemoDeviceConfigWizard(QWidget *parent = 0); - ~MaemoDeviceConfigWizard(); - - LinuxDeviceConfiguration::Ptr deviceConfiguration(); - - virtual int nextId() const; - -private: - MaemoDeviceConfigWizardPrivate *d; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMODEVICECONFIGWIZARD_H diff --git a/src/plugins/remotelinux/maemodeviceconfigwizardkeycreationpage.ui b/src/plugins/remotelinux/maemodeviceconfigwizardkeycreationpage.ui deleted file mode 100644 index 2d38c79d3f0..00000000000 --- a/src/plugins/remotelinux/maemodeviceconfigwizardkeycreationpage.ui +++ /dev/null @@ -1,79 +0,0 @@ - - - MaemoDeviceConfigWizardKeyCreationPage - - - - 0 - 0 - 447 - 115 - - - - WizardPage - - - - - - Qt Creator will now generate a new pair of keys. Please enter the directory to save the key files in and then press "Create Keys". - - - true - - - - - - - - - Directory: - - - - - - - - - - Create Keys - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
-
-
- - -
diff --git a/src/plugins/remotelinux/maemodeviceconfigwizardkeydeploymentpage.ui b/src/plugins/remotelinux/maemodeviceconfigwizardkeydeploymentpage.ui deleted file mode 100644 index ec9069fff55..00000000000 --- a/src/plugins/remotelinux/maemodeviceconfigwizardkeydeploymentpage.ui +++ /dev/null @@ -1,159 +0,0 @@ - - - MaemoDeviceConfigWizardKeyDeploymentPage - - - - 0 - 0 - 470 - 322 - - - - WizardPage - - - - - - To deploy the public key to your device, please execute the following steps: -<ul> -<li>Connect the device to your computer (unless you plan to connect via WLAN).</li> -<li>On the device, start the "%%%maddev%%%" application.</li> -<li>In "%%%maddev%%%", configure the device's IP address to the one shown below (or edit the field below to match the address you have configured).</li> -<li>In "%%%maddev%%%", press "Developer Password" and enter it in the field below.</li> -<li>Click "Deploy Key"</li> - - - - Qt::RichText - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - - Device address: - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Password: - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - Deploy Key - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - diff --git a/src/plugins/remotelinux/maemodeviceconfigwizardpreviouskeysetupcheckpage.ui b/src/plugins/remotelinux/maemodeviceconfigwizardpreviouskeysetupcheckpage.ui deleted file mode 100644 index 46f20e9e1ad..00000000000 --- a/src/plugins/remotelinux/maemodeviceconfigwizardpreviouskeysetupcheckpage.ui +++ /dev/null @@ -1,96 +0,0 @@ - - - MaemoDeviceConfigWizardCheckPreviousKeySetupPage - - - - 0 - 0 - 621 - 121 - - - - WizardPage - - - - - - Has a passwordless (key-based) login already been set up for this device? - - - true - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - - - Yes, and the private key is located at - - - - - - - - - - - - No - - - - - - - - - - - Qt::Vertical - - - - 20 - 44 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
-
-
- - -
diff --git a/src/plugins/remotelinux/maemodeviceconfigwizardreusekeyscheckpage.ui b/src/plugins/remotelinux/maemodeviceconfigwizardreusekeyscheckpage.ui deleted file mode 100644 index 8332f17a757..00000000000 --- a/src/plugins/remotelinux/maemodeviceconfigwizardreusekeyscheckpage.ui +++ /dev/null @@ -1,133 +0,0 @@ - - - MaemoDeviceConfigWizardReuseKeysCheckPage - - - - 0 - 0 - 574 - 185 - - - - WizardPage - - - - - - Do wou want to re-use an existing pair of keys or should a new one be created? - - - true - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - Re-use existing keys - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - File containing the public key: - - - - - - - File containing the private key: - - - - - - - - - - - - - - - - - Create new keys - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
-
-
- - -
diff --git a/src/plugins/remotelinux/maemodeviceconfigwizardstartpage.ui b/src/plugins/remotelinux/maemodeviceconfigwizardstartpage.ui deleted file mode 100644 index 4df4e3f8505..00000000000 --- a/src/plugins/remotelinux/maemodeviceconfigwizardstartpage.ui +++ /dev/null @@ -1,133 +0,0 @@ - - - MaemoDeviceConfigWizardStartPage - - - - 0 - 0 - 721 - 176 - - - - WizardPage - - - - - - The name to identify this configuration: - - - - - - - - - - The system running on the device: - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - The kind of device: - - - - - - - - - Emulator - - - - - - - Hardware Device - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - The device's host name or IP address: - - - - - - - - - - The SSH server port: - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/src/plugins/remotelinux/maemoglobal.cpp b/src/plugins/remotelinux/maemoglobal.cpp deleted file mode 100644 index 73975037262..00000000000 --- a/src/plugins/remotelinux/maemoglobal.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemoglobal.h" - -#include "maemoconstants.h" -#include "maemoqemumanager.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace Qt4ProjectManager; -using namespace Qt4ProjectManager::Constants; - -namespace RemoteLinux { -namespace Internal { -namespace { -static const QLatin1String binQmake("/bin/qmake" EXEC_SUFFIX); -} - -bool MaemoGlobal::isMaemoTargetId(const QString &id) -{ - return isFremantleTargetId(id) || isHarmattanTargetId(id) - || isMeegoTargetId(id); -} - -bool MaemoGlobal::isFremantleTargetId(const QString &id) -{ - return id == QLatin1String(MAEMO5_DEVICE_TARGET_ID); -} - -bool MaemoGlobal::isHarmattanTargetId(const QString &id) -{ - return id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID); -} - -bool MaemoGlobal::isMeegoTargetId(const QString &id) -{ - return id == QLatin1String(MEEGO_DEVICE_TARGET_ID); -} - -bool MaemoGlobal::isValidMaemo5QtVersion(const QString &qmakePath) -{ - return isValidMaemoQtVersion(qmakePath, QLatin1String(Maemo5OsType)); -} - -bool MaemoGlobal::isValidHarmattanQtVersion(const QString &qmakePath) -{ - return isValidMaemoQtVersion(qmakePath, QLatin1String(HarmattanOsType)); -} - -bool MaemoGlobal::isValidMeegoQtVersion(const QString &qmakePath) -{ - return isValidMaemoQtVersion(qmakePath, QLatin1String(MeeGoOsType)); -} - -bool MaemoGlobal::isValidMaemoQtVersion(const QString &qmakePath, const QString &osType) -{ - if (MaemoGlobal::osType(qmakePath) != osType) - return false; - QProcess madAdminProc; - const QStringList arguments(QLatin1String("list")); - if (!callMadAdmin(madAdminProc, arguments, qmakePath, false)) - return false; - if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished()) - return false; - - madAdminProc.setReadChannel(QProcess::StandardOutput); - const QByteArray tgtName = targetName(qmakePath).toAscii(); - while (madAdminProc.canReadLine()) { - const QByteArray &line = madAdminProc.readLine(); - if (line.contains(tgtName) - && (line.contains("(installed)") || line.contains("(default)"))) - return true; - } - return false; -} - - -QString MaemoGlobal::homeDirOnDevice(const QString &uname) -{ - return uname == QLatin1String("root") - ? QString::fromLatin1("/root") - : QLatin1String("/home/") + uname; -} - -QString MaemoGlobal::devrootshPath() -{ - return QLatin1String("/usr/lib/mad-developer/devrootsh"); -} - -int MaemoGlobal::applicationIconSize(const QString &osType) -{ - return osType == QLatin1String(HarmattanOsType) ? 80 : 64; -} - -QString MaemoGlobal::remoteSudo(const QString &osType, const QString &uname) -{ - if (uname == QLatin1String("root")) - return QString(); - if (osType == QLatin1String(Maemo5OsType) || osType == QLatin1String(HarmattanOsType) - || osType == QLatin1String(MeeGoOsType)) { - return devrootshPath(); - } - return QString(); // Using sudo would open a can of worms. -} - -QString MaemoGlobal::remoteSourceProfilesCommand() -{ - const QList profiles = QList() << "/etc/profile" - << "/home/user/.profile" << "~/.profile"; - QByteArray remoteCall(":"); - foreach (const QByteArray &profile, profiles) - remoteCall += "; test -f " + profile + " && source " + profile; - return QString::fromAscii(remoteCall); -} - -PortList MaemoGlobal::freePorts(const LinuxDeviceConfiguration::ConstPtr &devConf, - const QtSupport::BaseQtVersion *qtVersion) -{ - if (!devConf || !qtVersion) - return PortList(); - if (devConf->deviceType() == LinuxDeviceConfiguration::Emulator) { - MaemoQemuRuntime rt; - const int id = qtVersion->uniqueId(); - if (MaemoQemuManager::instance().runtimeForQtVersion(id, &rt)) - return rt.m_freePorts; - } - return devConf->freePorts(); -} - -QString MaemoGlobal::maddeRoot(const QString &qmakePath) -{ - QDir dir(targetRoot(qmakePath)); - dir.cdUp(); dir.cdUp(); - return dir.absolutePath(); -} - -QString MaemoGlobal::targetRoot(const QString &qmakePath) -{ - return QDir::cleanPath(qmakePath).remove(binQmake); -} - -QString MaemoGlobal::targetName(const QString &qmakePath) -{ - return QDir(targetRoot(qmakePath)).dirName(); -} - -QString MaemoGlobal::madAdminCommand(const QString &qmakePath) -{ - return maddeRoot(qmakePath) + QLatin1String("/bin/mad-admin"); -} - -QString MaemoGlobal::madCommand(const QString &qmakePath) -{ - return maddeRoot(qmakePath) + QLatin1String("/bin/mad"); -} - -QString MaemoGlobal::madDeveloperUiName(const QString &osType) -{ - return osType == QLatin1String(HarmattanOsType) - ? tr("SDK Connectivity") : tr("Mad Developer"); -} - -QString MaemoGlobal::osType(const QString &qmakePath) -{ - const QString &name = targetName(qmakePath); - if (name.startsWith(QLatin1String("fremantle"))) - return QLatin1String(Maemo5OsType); - if (name.startsWith(QLatin1String("harmattan"))) - return QLatin1String(HarmattanOsType); - if (name.startsWith(QLatin1String("meego"))) - return QLatin1String(MeeGoOsType); - return QLatin1String(Constants::GenericLinuxOsType); -} - -QString MaemoGlobal::architecture(const QString &qmakePath) -{ - QProcess proc; - const QStringList args = QStringList() << QLatin1String("uname") - << QLatin1String("-m"); - if (!callMad(proc, args, qmakePath, true)) - return QString(); - if (!proc.waitForFinished()) - return QString(); - QString arch = QString::fromUtf8(proc.readAllStandardOutput()); - arch.chop(1); // Newline - return arch; -} - -void MaemoGlobal::addMaddeEnvironment(Utils::Environment &env, const QString &qmakePath) -{ - Utils::Environment maddeEnv; -#ifdef Q_OS_WIN - const QString root = maddeRoot(qmakePath); - env.prependOrSetPath(root + QLatin1String("/bin")); - env.prependOrSet(QLatin1String("HOME"), - QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); -#else - Q_UNUSED(qmakePath); -#endif - for (Utils::Environment::const_iterator it = maddeEnv.constBegin(); it != maddeEnv.constEnd(); ++it) - env.prependOrSet(it.key(), it.value()); -} - -void MaemoGlobal::transformMaddeCall(QString &command, QStringList &args, const QString &qmakePath) -{ -#ifdef Q_OS_WIN - const QString root = maddeRoot(qmakePath); - args.prepend(command); - command = root + QLatin1String("/bin/sh.exe"); -#else - Q_UNUSED(command); - Q_UNUSED(args); - Q_UNUSED(qmakePath); -#endif -} - -bool MaemoGlobal::callMad(QProcess &proc, const QStringList &args, - const QString &qmakePath, bool useTarget) -{ - return callMaddeShellScript(proc, qmakePath, madCommand(qmakePath), args, - useTarget); -} - -bool MaemoGlobal::callMadAdmin(QProcess &proc, const QStringList &args, - const QString &qmakePath, bool useTarget) -{ - return callMaddeShellScript(proc, qmakePath, madAdminCommand(qmakePath), - args, useTarget); -} - -bool MaemoGlobal::callMaddeShellScript(QProcess &proc, - const QString &qmakePath, const QString &command, const QStringList &args, - bool useTarget) -{ - if (!QFileInfo(command).exists()) - return false; - QString actualCommand = command; - QStringList actualArgs = targetArgs(qmakePath, useTarget) + args; - Utils::Environment env(proc.systemEnvironment()); - addMaddeEnvironment(env, qmakePath); - proc.setEnvironment(env.toStringList()); - transformMaddeCall(actualCommand, actualArgs, qmakePath); - proc.start(actualCommand, actualArgs); - return true; -} - -QStringList MaemoGlobal::targetArgs(const QString &qmakePath, bool useTarget) -{ - QStringList args; - if (useTarget) { - args << QLatin1String("-t") << targetName(qmakePath); - } - return args; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoglobal.h b/src/plugins/remotelinux/maemoglobal.h deleted file mode 100644 index ea07e9db252..00000000000 --- a/src/plugins/remotelinux/maemoglobal.h +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOGLOBAL_H -#define MAEMOGLOBAL_H - -#include "portlist.h" - -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE -class QProcess; -class QString; -QT_END_NAMESPACE - -namespace QtSupport { -class BaseQtVersion; -} - -namespace RemoteLinux { -class LinuxDeviceConfiguration; - -namespace Internal { - -class WatchableFile : public Core::IFile -{ - Q_OBJECT -public: - WatchableFile(const QString &fileName, QObject *parent = 0) - : Core::IFile(parent), m_fileName(fileName) {} - - bool save(QString *, const QString &, bool) { return false; } - QString fileName() const { return m_fileName; } - QString defaultPath() const { return QString(); } - QString suggestedFileName() const { return QString(); } - QString mimeType() const { return QLatin1String("text/plain"); } - bool isModified() const { return false; } - bool isReadOnly() const { return false; } - bool isSaveAsAllowed() const { return false; } - ReloadBehavior reloadBehavior(ChangeTrigger, ChangeType) const { return BehaviorSilent; } - bool reload(QString *, ReloadFlag, ChangeType) { emit modified(); return true; } - void rename(const QString &) {} - -signals: - void modified(); - -private: - QString m_fileName; -}; - -class MaemoGlobal -{ - Q_DECLARE_TR_FUNCTIONS(RemoteLinux::Internal::MaemoGlobal) -public: - enum PackagingSystem { Dpkg, Rpm, Tar }; - - static bool isMaemoTargetId(const QString &id); - static bool isFremantleTargetId(const QString &id); - static bool isHarmattanTargetId(const QString &id); - static bool isMeegoTargetId(const QString &id); - static bool isValidMaemo5QtVersion(const QString &qmakePath); - static bool isValidHarmattanQtVersion(const QString &qmakePath); - static bool isValidMeegoQtVersion(const QString &qmakePath); - - static QString homeDirOnDevice(const QString &uname); - static QString devrootshPath(); - static int applicationIconSize(const QString &osType); - static QString remoteSudo(const QString &osType, const QString &uname); - static QString remoteSourceProfilesCommand(); - static PortList freePorts(const QSharedPointer &devConf, - const QtSupport::BaseQtVersion *qtVersion); - - static void addMaddeEnvironment(Utils::Environment &env, const QString &qmakePath); - static void transformMaddeCall(QString &command, QStringList &args, const QString &qmakePath); - static QString maddeRoot(const QString &qmakePath); - static QString targetRoot(const QString &qmakePath); - static QString targetName(const QString &qmakePath); - static QString madCommand(const QString &qmakePath); - static QString madDeveloperUiName(const QString &osType); - static QString osType(const QString &qmakePath); - - // TODO: IS this still needed with Qt Version having an Abi? - static QString architecture(const QString &qmakePath); - - static bool callMad(QProcess &proc, const QStringList &args, - const QString &qmakePath, bool useTarget); - static bool callMadAdmin(QProcess &proc, const QStringList &args, - const QString &qmakePath, bool useTarget); - - static bool isValidMaemoQtVersion(const QString &qmakePath, const QString &osType); -private: - static QString madAdminCommand(const QString &qmakePath); - static bool callMaddeShellScript(QProcess &proc, const QString &qmakePath, - const QString &command, const QStringList &args, bool useTarget); - static QStringList targetArgs(const QString &qmakePath, bool useTarget); -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOGLOBAL_H diff --git a/src/plugins/remotelinux/maemoinstalltosysrootstep.cpp b/src/plugins/remotelinux/maemoinstalltosysrootstep.cpp deleted file mode 100644 index 64139c855ed..00000000000 --- a/src/plugins/remotelinux/maemoinstalltosysrootstep.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemoinstalltosysrootstep.h" - -#include "maemoglobal.h" -#include "maemopackagecreationstep.h" -#include "maemoqtversion.h" - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -class AbstractMaemoInstallPackageToSysrootWidget : public BuildStepConfigWidget -{ - Q_OBJECT -public: - AbstractMaemoInstallPackageToSysrootWidget(AbstractMaemoInstallPackageToSysrootStep *step) - : m_step(step) - { - BuildStepList * const list - = qobject_cast(m_step->parent()); - connect(list, SIGNAL(stepInserted(int)), SIGNAL(updateSummary())); - connect(list, SIGNAL(stepMoved(int,int)), SIGNAL(updateSummary())); - connect(list, SIGNAL(aboutToRemoveStep(int)), SLOT(handleStepToBeRemoved(int))); - connect(list, SIGNAL(stepRemoved(int)), SIGNAL(updateSummary())); - } - - virtual QString summaryText() const - { - if (!m_step->deployConfiguration()->earlierBuildStep(m_step)) { - return QLatin1String("") - + tr("Cannot deploy to sysroot: No packaging step found.") - + QLatin1String(""); - } - return QLatin1String("") + displayName() + QLatin1String(""); - } - -private: - Q_SLOT void handleStepToBeRemoved(int step) - { - BuildStepList * const list - = qobject_cast(m_step->parent()); - if (list->steps().at(step) == m_step) - disconnect(list, 0, this, 0); - } - - const AbstractMaemoInstallPackageToSysrootStep * const m_step; -}; - - -class MaemoInstallDebianPackageToSysrootWidget : public AbstractMaemoInstallPackageToSysrootWidget -{ - Q_OBJECT -public: - MaemoInstallDebianPackageToSysrootWidget(AbstractMaemoInstallPackageToSysrootStep *step) - : AbstractMaemoInstallPackageToSysrootWidget(step) {} - - virtual QString displayName() const { return MaemoInstallDebianPackageToSysrootStep::displayName(); } -}; - -class MaemoInstallRpmPackageToSysrootWidget : public AbstractMaemoInstallPackageToSysrootWidget -{ - Q_OBJECT -public: - MaemoInstallRpmPackageToSysrootWidget(AbstractMaemoInstallPackageToSysrootStep *step) - : AbstractMaemoInstallPackageToSysrootWidget(step) {} - - virtual QString displayName() const { return MaemoInstallRpmPackageToSysrootStep::displayName(); } -}; - -class MaemoCopyFilesToSysrootWidget : public BuildStepConfigWidget -{ - Q_OBJECT -public: - MaemoCopyFilesToSysrootWidget(const BuildStep *buildStep) - : m_buildStep(buildStep) - { - if (m_buildStep) { - connect(m_buildStep.data(), SIGNAL(displayNameChanged()), - SIGNAL(updateSummary())); - } - } - virtual QString summaryText() const { - return QLatin1String("") + displayName() + QLatin1String(""); } - virtual QString displayName() const { - return m_buildStep ? m_buildStep.data()->displayName() : QString(); - } -private: - const QWeakPointer m_buildStep; -}; - - -AbstractMaemoInstallPackageToSysrootStep::AbstractMaemoInstallPackageToSysrootStep(BuildStepList *bsl, - const QString &id) - : BuildStep(bsl, id) -{ -} - -AbstractMaemoInstallPackageToSysrootStep::AbstractMaemoInstallPackageToSysrootStep(BuildStepList *bsl, - AbstractMaemoInstallPackageToSysrootStep *other) - : BuildStep(bsl, other) -{ -} - -RemoteLinuxDeployConfiguration *AbstractMaemoInstallPackageToSysrootStep::deployConfiguration() const -{ - return qobject_cast(BuildStep::deployConfiguration()); -} - - -void AbstractMaemoInstallPackageToSysrootStep::run(QFutureInterface &fi) -{ - const Qt4BuildConfiguration * const bc - = qobject_cast(target())->activeQt4BuildConfiguration(); - if (!bc) { - addOutput(tr("Cannot install to sysroot without build configuration."), - ErrorMessageOutput); - fi.reportResult(false); - return; - } - - const AbstractMaemoPackageCreationStep * const pStep - = deployConfiguration()->earlierBuildStep(this); - if (!pStep) { - addOutput(tr("Cannot install package to sysroot without packaging step."), - ErrorMessageOutput); - fi.reportResult(false); - return; - } - - if (!bc->qtVersion()) { - addOutput(tr("Cannot install package to sysroot without a Qt version."), - ErrorMessageOutput); - fi.reportResult(false); - return; - } - - m_installerProcess = new QProcess; - connect(m_installerProcess, SIGNAL(readyReadStandardOutput()), - SLOT(handleInstallerStdout())); - connect(m_installerProcess, SIGNAL(readyReadStandardError()), - SLOT(handleInstallerStderr())); - - emit addOutput(tr("Installing package to sysroot ..."), MessageOutput); - const QtSupport::BaseQtVersion * const qtVersion = bc->qtVersion(); - const QString packageFilePath = pStep->packageFilePath(); - const int packageFileSize = QFileInfo(packageFilePath).size() / (1024*1024); - const QStringList args = madArguments() << packageFilePath; - MaemoGlobal::callMadAdmin(*m_installerProcess, args, qtVersion->qmakeCommand(), true); - if (!m_installerProcess->waitForFinished((2*packageFileSize + 10)*1000) - || m_installerProcess->exitStatus() != QProcess::NormalExit - || m_installerProcess->exitCode() != 0) { - emit addOutput(tr("Installation to sysroot failed, continuing anyway."), - ErrorMessageOutput); - if (m_installerProcess->state() != QProcess::NotRunning) { - m_installerProcess->terminate(); - m_installerProcess->waitForFinished(); - m_installerProcess->kill(); - } - fi.reportResult(true); - return; - } - - fi.reportResult(true); - m_installerProcess->deleteLater(); - m_installerProcess = 0; -} - -void AbstractMaemoInstallPackageToSysrootStep::handleInstallerStdout() -{ - if (m_installerProcess) - emit addOutput(QString::fromLocal8Bit(m_installerProcess->readAllStandardOutput()), NormalOutput); -} - -void AbstractMaemoInstallPackageToSysrootStep::handleInstallerStderr() -{ - if (m_installerProcess) - emit addOutput(QString::fromLocal8Bit(m_installerProcess->readAllStandardError()), ErrorOutput); -} - - -MaemoInstallDebianPackageToSysrootStep::MaemoInstallDebianPackageToSysrootStep(BuildStepList *bsl) - : AbstractMaemoInstallPackageToSysrootStep(bsl, Id) -{ - setDisplayName(displayName()); -} - -MaemoInstallDebianPackageToSysrootStep::MaemoInstallDebianPackageToSysrootStep(BuildStepList *bsl, - MaemoInstallDebianPackageToSysrootStep *other) - : AbstractMaemoInstallPackageToSysrootStep(bsl, other) -{ - setDisplayName(displayName()); -} - -BuildStepConfigWidget *MaemoInstallDebianPackageToSysrootStep::createConfigWidget() -{ - return new MaemoInstallDebianPackageToSysrootWidget(this); -} - -QStringList MaemoInstallDebianPackageToSysrootStep::madArguments() const -{ - return QStringList() << QLatin1String("xdpkg") << QLatin1String("--no-force-downgrade") - << QLatin1String("-i"); -} - -const QString MaemoInstallDebianPackageToSysrootStep::Id - = QLatin1String("MaemoInstallDebianPackageToSysrootStep"); - -QString MaemoInstallDebianPackageToSysrootStep::displayName() -{ - return tr("Install Debian package to sysroot"); -} - -MaemoInstallRpmPackageToSysrootStep::MaemoInstallRpmPackageToSysrootStep(BuildStepList *bsl) - : AbstractMaemoInstallPackageToSysrootStep(bsl, Id) -{ - setDisplayName(displayName()); -} - -MaemoInstallRpmPackageToSysrootStep::MaemoInstallRpmPackageToSysrootStep(BuildStepList *bsl, - MaemoInstallRpmPackageToSysrootStep *other) - : AbstractMaemoInstallPackageToSysrootStep(bsl, other) -{ - setDisplayName(displayName()); -} - -BuildStepConfigWidget *MaemoInstallRpmPackageToSysrootStep::createConfigWidget() -{ - return new MaemoInstallRpmPackageToSysrootWidget(this); -} - -QStringList MaemoInstallRpmPackageToSysrootStep::madArguments() const -{ - return QStringList() << QLatin1String("xrpm") << QLatin1String("-i"); -} - -const QString MaemoInstallRpmPackageToSysrootStep::Id - = QLatin1String("MaemoInstallRpmPackageToSysrootStep"); - -QString MaemoInstallRpmPackageToSysrootStep::displayName() -{ - return tr("Install RPM package to sysroot"); -} - -MaemoCopyToSysrootStep::MaemoCopyToSysrootStep(BuildStepList *bsl) - : BuildStep(bsl, Id) -{ - setDisplayName(displayName()); -} - -MaemoCopyToSysrootStep::MaemoCopyToSysrootStep(BuildStepList *bsl, - MaemoCopyToSysrootStep *other) - : BuildStep(bsl, other) -{ - setDisplayName(displayName()); -} - -void MaemoCopyToSysrootStep::run(QFutureInterface &fi) -{ - const Qt4BuildConfiguration * const bc - = qobject_cast(target())->activeQt4BuildConfiguration(); - if (!bc) { - addOutput(tr("Cannot copy to sysroot without build configuration."), - ErrorMessageOutput); - fi.reportResult(false); - return; - } - - const MaemoQtVersion * const qtVersion = dynamic_cast(bc->qtVersion()); - if (!qtVersion) { - addOutput(tr("Cannot copy to sysroot without valid Qt version."), - ErrorMessageOutput); - fi.reportResult(false); - return; - } - - emit addOutput(tr("Copying files to sysroot ..."), MessageOutput); - QDir sysrootDir(qtVersion->systemRoot()); - const QSharedPointer deploymentInfo - = qobject_cast(deployConfiguration())->deploymentInfo(); - const QChar sep = QLatin1Char('/'); - for (int i = 0; i < deploymentInfo->deployableCount(); ++i) { - const DeployableFile &deployable = deploymentInfo->deployableAt(i); - const QFileInfo localFileInfo(deployable.localFilePath); - const QString targetFilePath = qtVersion->systemRoot() + sep - + deployable.remoteDir + sep + localFileInfo.fileName(); - sysrootDir.mkpath(deployable.remoteDir.mid(1)); - QString errorMsg; - Utils::FileUtils::removeRecursively(targetFilePath, &errorMsg); - if (!Utils::FileUtils::copyRecursively(deployable.localFilePath, - targetFilePath, &errorMsg)) { - emit addOutput(tr("Sysroot installation failed: %1\n" - " Continuing anyway.").arg(errorMsg), ErrorMessageOutput); - } - QCoreApplication::processEvents(); - if (fi.isCanceled()) { - fi.reportResult(false); - return; - } - } - fi.reportResult(true); -} - -BuildStepConfigWidget *MaemoCopyToSysrootStep::createConfigWidget() -{ - return new MaemoCopyFilesToSysrootWidget(this); -} - -const QString MaemoCopyToSysrootStep::Id - = QLatin1String("MaemoCopyToSysrootStep"); -QString MaemoCopyToSysrootStep::displayName() -{ - return tr("Copy files to sysroot"); -} - -MaemoMakeInstallToSysrootStep::MaemoMakeInstallToSysrootStep(BuildStepList *bsl) - : AbstractProcessStep(bsl, Id) -{ - setDefaultDisplayName(displayName()); -} - -MaemoMakeInstallToSysrootStep::MaemoMakeInstallToSysrootStep(BuildStepList *bsl, - MaemoMakeInstallToSysrootStep *other) - : AbstractProcessStep(bsl, other) -{ - setDefaultDisplayName(displayName()); -} - -bool MaemoMakeInstallToSysrootStep::init() -{ - const Qt4BuildConfiguration * const bc - = qobject_cast(target()->activeBuildConfiguration()); - if (!bc) { - addOutput("Cannot deploy: No active build dconfiguration.", - ErrorMessageOutput); - return false; - } - const QtSupport::BaseQtVersion * const qtVersion = bc->qtVersion(); - if (!qtVersion) { - addOutput("Cannot deploy: Unusable build configuration.", - ErrorMessageOutput); - return false; - - } - Utils::Environment env = bc->environment(); - MaemoGlobal::addMaddeEnvironment(env, qtVersion->qmakeCommand()); - QString command = MaemoGlobal::madCommand(qtVersion->qmakeCommand()); - QStringList args = QStringList() << QLatin1String("-t") - << MaemoGlobal::targetName(qtVersion->qmakeCommand()) << QLatin1String("make") - << QLatin1String("install") << (QLatin1String("INSTALL_ROOT=") + qtVersion->systemRoot()); - MaemoGlobal::transformMaddeCall(command, args, qtVersion->qmakeCommand()); - processParameters()->setCommand(command); - processParameters()->setArguments(args.join(QLatin1String(" "))); - processParameters()->setEnvironment(env); - processParameters()->setWorkingDirectory(bc->buildDirectory()); - return true; -} - -BuildStepConfigWidget *MaemoMakeInstallToSysrootStep::createConfigWidget() -{ - return new MaemoCopyFilesToSysrootWidget(this); -} - -const QString MaemoMakeInstallToSysrootStep::Id - = QLatin1String("MaemoMakeInstallToSysrootStep"); -QString MaemoMakeInstallToSysrootStep::displayName() -{ - return tr("Copy files to sysroot"); -} - -} // namespace Internal -} // namespace RemoteLinux - -#include "maemoinstalltosysrootstep.moc" diff --git a/src/plugins/remotelinux/maemoinstalltosysrootstep.h b/src/plugins/remotelinux/maemoinstalltosysrootstep.h deleted file mode 100644 index 7e9fd97bb66..00000000000 --- a/src/plugins/remotelinux/maemoinstalltosysrootstep.h +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOINSTALLTOSYSROOTSTEP_H -#define MAEMOINSTALLTOSYSROOTSTEP_H - -#include -#include - -#include - -QT_FORWARD_DECLARE_CLASS(QProcess) - -namespace RemoteLinux { -class RemoteLinuxDeployConfiguration; - -namespace Internal { - -class AbstractMaemoInstallPackageToSysrootStep : public ProjectExplorer::BuildStep -{ - Q_OBJECT -public: - virtual bool init() { return true; } - virtual void run(QFutureInterface &fi); - - RemoteLinuxDeployConfiguration *deployConfiguration() const; - -protected: - AbstractMaemoInstallPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl, - const QString &id); - AbstractMaemoInstallPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl, - AbstractMaemoInstallPackageToSysrootStep *other); - -private slots: - void handleInstallerStdout(); - void handleInstallerStderr(); - -private: - virtual QStringList madArguments() const = 0; - - QProcess *m_installerProcess; -}; - -class MaemoInstallDebianPackageToSysrootStep : public AbstractMaemoInstallPackageToSysrootStep -{ - Q_OBJECT -public: - explicit MaemoInstallDebianPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl); - MaemoInstallDebianPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl, - MaemoInstallDebianPackageToSysrootStep *other); - - virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - - static const QString Id; - static QString displayName(); -private: - virtual QStringList madArguments() const; -}; - -class MaemoInstallRpmPackageToSysrootStep : public AbstractMaemoInstallPackageToSysrootStep -{ - Q_OBJECT -public: - explicit MaemoInstallRpmPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl); - MaemoInstallRpmPackageToSysrootStep(ProjectExplorer::BuildStepList *bsl, - MaemoInstallRpmPackageToSysrootStep *other); - - virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - - static const QString Id; - static QString displayName(); -private: - virtual QStringList madArguments() const; -}; - -class MaemoCopyToSysrootStep : public ProjectExplorer::BuildStep -{ - Q_OBJECT -public: - explicit MaemoCopyToSysrootStep(ProjectExplorer::BuildStepList *bsl); - MaemoCopyToSysrootStep(ProjectExplorer::BuildStepList *bsl, - MaemoCopyToSysrootStep *other); - - virtual bool init() { return true; } - virtual void run(QFutureInterface &fi); - virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - - static const QString Id; - static QString displayName(); -}; - -class MaemoMakeInstallToSysrootStep : public ProjectExplorer::AbstractProcessStep -{ - Q_OBJECT -public: - explicit MaemoMakeInstallToSysrootStep(ProjectExplorer::BuildStepList *bsl); - MaemoMakeInstallToSysrootStep(ProjectExplorer::BuildStepList *bsl, - MaemoMakeInstallToSysrootStep *other); - - virtual bool immutable() const { return false; } - virtual bool init(); - virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - - static const QString Id; - static QString displayName(); -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOINSTALLTOSYSROOTSTEP_H diff --git a/src/plugins/remotelinux/maemomountspecification.cpp b/src/plugins/remotelinux/maemomountspecification.cpp deleted file mode 100644 index 7c74dea4e9a..00000000000 --- a/src/plugins/remotelinux/maemomountspecification.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemomountspecification.h" - -namespace RemoteLinux { -namespace Internal { - -const QLatin1String MaemoMountSpecification::InvalidMountPoint("/"); - -MaemoMountSpecification::MaemoMountSpecification(const QString &localDir, - const QString &remoteDir) - : localDir(localDir), remoteMountPoint(remoteDir) -{ -} - -} // namespace Internal -} // namespace RemoteLinux - diff --git a/src/plugins/remotelinux/maemomountspecification.h b/src/plugins/remotelinux/maemomountspecification.h deleted file mode 100644 index 87300f33fc3..00000000000 --- a/src/plugins/remotelinux/maemomountspecification.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOMOUNTSPECIFICATION_H -#define MAEMOMOUNTSPECIFICATION_H - -#include - -namespace RemoteLinux { -namespace Internal { - -struct MaemoMountSpecification { - MaemoMountSpecification(const QString &localDir, const QString &remoteDir); - bool isValid() const { return remoteMountPoint != InvalidMountPoint; } - - static const QLatin1String InvalidMountPoint; - - QString localDir; - QString remoteMountPoint; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOMOUNTSPECIFICATION_H diff --git a/src/plugins/remotelinux/maemopackagecreationfactory.cpp b/src/plugins/remotelinux/maemopackagecreationfactory.cpp deleted file mode 100644 index 64d9883fddc..00000000000 --- a/src/plugins/remotelinux/maemopackagecreationfactory.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemopackagecreationfactory.h" - -#include "maemopackagecreationstep.h" -#include "qt4maemotarget.h" -#include "qt4maemodeployconfiguration.h" - -#include -#include -#include -#include -#include - -#include - -using ProjectExplorer::BuildStepList; -using ProjectExplorer::BuildStep; - -namespace RemoteLinux { -namespace Internal { -namespace { -const QString OldCreatePackageId("Qt4ProjectManager.MaemoPackageCreationStep"); -} // anonymous namespace - -MaemoPackageCreationFactory::MaemoPackageCreationFactory(QObject *parent) - : ProjectExplorer::IBuildStepFactory(parent) -{ -} - -QStringList MaemoPackageCreationFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const -{ - QStringList ids; - if (!qobject_cast(parent->parent())) - return ids; - if (qobject_cast(parent->target()) - && !parent->contains(MaemoDebianPackageCreationStep::CreatePackageId)) { - ids << MaemoDebianPackageCreationStep::CreatePackageId; - } else if (qobject_cast(parent->target()) - && !parent->contains(MaemoRpmPackageCreationStep::CreatePackageId)) { - ids << MaemoRpmPackageCreationStep::CreatePackageId; - } - return ids; -} - -QString MaemoPackageCreationFactory::displayNameForId(const QString &id) const -{ - if (id == MaemoDebianPackageCreationStep::CreatePackageId) { - return QCoreApplication::translate("RemoteLinux::Internal::MaemoPackageCreationFactory", - "Create Debian Package"); - } else if (id == MaemoRpmPackageCreationStep::CreatePackageId) { - return QCoreApplication::translate("RemoteLinux::Internal::MaemoPackageCreationFactory", - "Create RPM Package"); - } - return QString(); -} - -bool MaemoPackageCreationFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const -{ - return availableCreationIds(parent).contains(id); -} - -BuildStep *MaemoPackageCreationFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id) -{ - Q_ASSERT(canCreate(parent, id)); - if (id == MaemoDebianPackageCreationStep::CreatePackageId) - return new MaemoDebianPackageCreationStep(parent); - else if (id == MaemoRpmPackageCreationStep::CreatePackageId) - return new MaemoRpmPackageCreationStep(parent); - return 0; -} - -bool MaemoPackageCreationFactory::canRestore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map) const -{ - const QString id = ProjectExplorer::idFromMap(map); - return canCreate(parent, id) || id == OldCreatePackageId; -} - -BuildStep *MaemoPackageCreationFactory::restore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map) -{ - Q_ASSERT(canRestore(parent, map)); - BuildStep * step = 0; - const QString id = ProjectExplorer::idFromMap(map); - if (id == MaemoDebianPackageCreationStep::CreatePackageId - || (id == OldCreatePackageId - && qobject_cast(parent->target()))) { - step = new MaemoDebianPackageCreationStep(parent); - } else if (id == MaemoRpmPackageCreationStep::CreatePackageId - || (id == OldCreatePackageId - && qobject_cast(parent->target()))) { - step = new MaemoRpmPackageCreationStep(parent); - } - Q_ASSERT(step); - - if (!step->fromMap(map)) { - delete step; - return 0; - } - return step; -} - -bool MaemoPackageCreationFactory::canClone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product) const -{ - return canCreate(parent, product->id()); -} - -BuildStep *MaemoPackageCreationFactory::clone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product) -{ - Q_ASSERT(canClone(parent, product)); - if (MaemoDebianPackageCreationStep * const debianStep - = qobject_cast(product)) { - return new MaemoDebianPackageCreationStep(parent, debianStep); - } - if (MaemoRpmPackageCreationStep * const rpmStep - = qobject_cast(product)) { - return new MaemoRpmPackageCreationStep(parent, rpmStep); - } - return 0; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopackagecreationfactory.h b/src/plugins/remotelinux/maemopackagecreationfactory.h deleted file mode 100644 index 7f849dcde37..00000000000 --- a/src/plugins/remotelinux/maemopackagecreationfactory.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOPACKAGECREATIONFACTORY_H -#define MAEMOPACKAGECREATIONFACTORY_H - -#include - -namespace RemoteLinux { -namespace Internal { - -class MaemoPackageCreationFactory : public ProjectExplorer::IBuildStepFactory -{ -public: - MaemoPackageCreationFactory(QObject *parent = 0); - - virtual QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; - virtual QString displayNameForId(const QString &id) const; - - virtual bool canCreate(ProjectExplorer::BuildStepList *parent, - const QString &id) const; - virtual ProjectExplorer::BuildStep * - create(ProjectExplorer::BuildStepList *parent, const QString &id); - - virtual bool canRestore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map) const; - virtual ProjectExplorer::BuildStep * - restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); - - virtual bool canClone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product) const; - virtual ProjectExplorer::BuildStep * - clone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product); -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPACKAGECREATIONFACTORY_H diff --git a/src/plugins/remotelinux/maemopackagecreationstep.cpp b/src/plugins/remotelinux/maemopackagecreationstep.cpp deleted file mode 100644 index ac7a4697581..00000000000 --- a/src/plugins/remotelinux/maemopackagecreationstep.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemopackagecreationstep.h" - -#include "maemoconstants.h" -#include "maemoglobal.h" -#include "maemopackagecreationwidget.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace { - const QLatin1String MagicFileName(".qtcreator"); -} - -using namespace ProjectExplorer::Constants; -using ProjectExplorer::BuildStepList; -using ProjectExplorer::BuildStepConfigWidget; -using ProjectExplorer::Task; -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -const QLatin1String AbstractMaemoPackageCreationStep::DefaultVersionNumber("0.0.1"); - -AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl, - const QString &id) : AbstractPackagingStep(bsl, id) -{ -} - -AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl, - AbstractMaemoPackageCreationStep *other) : AbstractPackagingStep(bsl, other) -{ -} - -AbstractMaemoPackageCreationStep::~AbstractMaemoPackageCreationStep() -{ -} - -void AbstractMaemoPackageCreationStep::run(QFutureInterface &fi) -{ - if (!isPackagingNeeded()) { - emit addOutput(tr("Package up to date."), MessageOutput); - fi.reportResult(true); - return; - } - - setPackagingStarted(); - // TODO: Make the build process asynchronous; i.e. no waitFor()-functions etc. - QProcess * const buildProc = new QProcess; - connect(buildProc, SIGNAL(readyReadStandardOutput()), this, - SLOT(handleBuildOutput())); - connect(buildProc, SIGNAL(readyReadStandardError()), this, - SLOT(handleBuildOutput())); - emit addOutput(tr("Creating package file ..."), MessageOutput); - const bool success = createPackage(buildProc, fi); - disconnect(buildProc, 0, this, 0); - buildProc->deleteLater(); - if (success) - emit addOutput(tr("Package created."), BuildStep::MessageOutput); - setPackagingFinished(success); - fi.reportResult(success); -} - -BuildStepConfigWidget *AbstractMaemoPackageCreationStep::createConfigWidget() -{ - return new MaemoPackageCreationWidget(this); -} - -void AbstractMaemoPackageCreationStep::handleBuildOutput() -{ - QProcess * const buildProc = qobject_cast(sender()); - if (!buildProc) - return; - QByteArray stdOut = buildProc->readAllStandardOutput(); - stdOut.replace('\0', QByteArray()); // Output contains NUL characters. - if (!stdOut.isEmpty()) - emit addOutput(QString::fromLocal8Bit(stdOut), BuildStep::NormalOutput, - BuildStep::DontAppendNewline); - QByteArray errorOut = buildProc->readAllStandardError(); - errorOut.replace('\0', QByteArray()); - if (!errorOut.isEmpty()) { - emit addOutput(QString::fromLocal8Bit(errorOut), BuildStep::ErrorOutput, - BuildStep::DontAppendNewline); - } -} - -const Qt4BuildConfiguration *AbstractMaemoPackageCreationStep::qt4BuildConfiguration() const -{ - return static_cast(buildConfiguration()); -} - -AbstractQt4MaemoTarget *AbstractMaemoPackageCreationStep::maemoTarget() const -{ - return qobject_cast(buildConfiguration()->target()); -} - -AbstractDebBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::debBasedMaemoTarget() const -{ - return qobject_cast(buildConfiguration()->target()); -} - -AbstractRpmBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::rpmBasedMaemoTarget() const -{ - return qobject_cast(buildConfiguration()->target()); -} - -QString AbstractMaemoPackageCreationStep::projectName() const -{ - return qt4BuildConfiguration()->qt4Target()->qt4Project() - ->rootProjectNode()->displayName().toLower(); -} - -bool AbstractMaemoPackageCreationStep::isPackagingNeeded() const -{ - if (AbstractPackagingStep::isPackagingNeeded()) - return true; - return isMetaDataNewerThan(QFileInfo(packageFilePath()).lastModified()); -} - -QString AbstractMaemoPackageCreationStep::packageFileName() const -{ - QString error; - const QString &version = versionString(&error); - if (version.isEmpty()) - return QString(); - QFileInfo fi(maemoTarget()->packageFileName()); - const QString baseName = replaceDots(fi.completeBaseName()); - return baseName + QLatin1Char('.') + fi.suffix(); -} - -QString AbstractMaemoPackageCreationStep::versionString(QString *error) const -{ - return maemoTarget()->projectVersion(error); -} - -bool AbstractMaemoPackageCreationStep::setVersionString(const QString &version, QString *error) -{ - const bool success = maemoTarget()->setProjectVersion(version, error); - if (success) - emit packageFilePathChanged(); - return success; -} - -QString AbstractMaemoPackageCreationStep::nativePath(const QFile &file) -{ - return QDir::toNativeSeparators(QFileInfo(file).filePath()); -} - -bool AbstractMaemoPackageCreationStep::callPackagingCommand(QProcess *proc, - const QStringList &arguments) -{ - preparePackagingProcess(proc, qt4BuildConfiguration(), packageDirectory()); - const QtSupport::BaseQtVersion * const qtVersion = qt4BuildConfiguration()->qtVersion(); - if (!qtVersion) { - raiseError(tr("Packaging failed: No Qt version.")); - return false; - } - const QString madCommand = MaemoGlobal::madCommand(qtVersion->qmakeCommand()); - const QString cmdLine = madCommand + QLatin1Char(' ') - + arguments.join(QLatin1String(" ")); - emit addOutput(tr("Package Creation: Running command '%1'.").arg(cmdLine), - BuildStep::MessageOutput); - MaemoGlobal::callMad(*proc, arguments, qtVersion->qmakeCommand(), true); - if (!proc->waitForStarted()) { - raiseError(tr("Packaging failed: Could not start command '%1'. Reason: %2") - .arg(cmdLine, proc->errorString())); - return false; - } - proc->waitForFinished(-1); - if (proc->error() != QProcess::UnknownError || proc->exitCode() != 0) { - QString mainMessage = tr("Packaging Error: Command '%1' failed.") - .arg(cmdLine); - if (proc->error() != QProcess::UnknownError) - mainMessage += tr(" Reason: %1").arg(proc->errorString()); - else - mainMessage += tr("Exit code: %1").arg(proc->exitCode()); - raiseError(mainMessage); - return false; - } - return true; -} - - -void AbstractMaemoPackageCreationStep::preparePackagingProcess(QProcess *proc, - const Qt4BuildConfiguration *bc, const QString &workingDir) -{ - Utils::Environment env = bc->environment(); - if (bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild) { - env.appendOrSet(QLatin1String("DEB_BUILD_OPTIONS"), - QLatin1String("nostrip"), QLatin1String(" ")); - } - proc->setEnvironment(env.toStringList()); - proc->setWorkingDirectory(workingDir); -} - -QString AbstractMaemoPackageCreationStep::replaceDots(const QString &name) const -{ - // Idiotic OVI store requirement for N900 (but not allowed for N9 ...). - if (qobject_cast(target())) { - QString adaptedName = name; - return adaptedName.replace(QLatin1Char('.'), QLatin1Char('_')); - } - return name; -} - - -MaemoDebianPackageCreationStep::MaemoDebianPackageCreationStep(BuildStepList *bsl) - : AbstractMaemoPackageCreationStep(bsl, CreatePackageId) -{ - ctor(); -} - -const QString MaemoDebianPackageCreationStep::CreatePackageId - = QLatin1String("MaemoDebianPackageCreationStep"); - -MaemoDebianPackageCreationStep::MaemoDebianPackageCreationStep(BuildStepList *buildConfig, - MaemoDebianPackageCreationStep *other) - : AbstractMaemoPackageCreationStep(buildConfig, other) -{ - ctor(); -} - -void MaemoDebianPackageCreationStep::ctor() -{ - setDefaultDisplayName(tr("Create Debian Package")); -} - -bool MaemoDebianPackageCreationStep::createPackage(QProcess *buildProc, - const QFutureInterface &fi) -{ - Q_UNUSED(fi); - checkProjectName(); - const QString projectDir = buildConfiguration()->target()->project()->projectDirectory(); - const bool inSourceBuild = QFileInfo(packageDirectory()) == QFileInfo(projectDir); - if (!copyDebianFiles(inSourceBuild)) - return false; - const QStringList args = QStringList() << QLatin1String("dpkg-buildpackage") - << QLatin1String("-nc") << QLatin1String("-uc") << QLatin1String("-us"); - if (!callPackagingCommand(buildProc, args)) - return false; - - QFile::remove(packageFilePath()); - - // Workaround for non-working dh_builddeb --destdir=. - if (!QDir(packageDirectory()).isRoot()) { - const AbstractQt4MaemoTarget * const target = maemoTarget(); - QString error; - const QString pkgFileName = target->packageFileName(); - if (!error.isEmpty()) - raiseError(tr("Packaging failed: Could not get package name.")); - const QString changesSourceFileName = QFileInfo(pkgFileName).completeBaseName() - + QLatin1String(".changes"); - const QString changesTargetFileName = replaceDots(QFileInfo(pkgFileName).completeBaseName()) - + QLatin1String(".changes"); - const QString packageSourceDir = packageDirectory() + QLatin1String("/../"); - const QString packageSourceFilePath = packageSourceDir + pkgFileName; - const QString changesSourceFilePath = packageSourceDir + changesSourceFileName; - const QString changesTargetFilePath - = packageDirectory() + QLatin1Char('/') + changesTargetFileName; - QFile::remove(changesTargetFilePath); - if (!QFile::rename(packageSourceFilePath, packageFilePath()) - || !QFile::rename(changesSourceFilePath, changesTargetFilePath)) { - raiseError(tr("Packaging failed: Could not move package files from '%1'' to '%2'.") - .arg(packageSourceDir, packageDirectory())); - return false; - } - } - - if (inSourceBuild) { - buildProc->start(packagingCommand(qt4BuildConfiguration(), QLatin1String("dh_clean"))); - buildProc->waitForFinished(); - buildProc->terminate(); - } - return true; -} - -bool MaemoDebianPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDate) const -{ - const QString debianPath = debBasedMaemoTarget()->debianDirPath(); - if (packageDate <= QFileInfo(debianPath).lastModified()) - return true; - const QStringList debianFiles = debBasedMaemoTarget()->debianFiles(); - foreach (const QString &debianFile, debianFiles) { - const QString absFilePath = debianPath + QLatin1Char('/') + debianFile; - if (packageDate <= QFileInfo(absFilePath).lastModified()) - return true; - } - return false; -} - -void MaemoDebianPackageCreationStep::checkProjectName() -{ - const QRegExp legalName(QLatin1String("[0-9-+a-z\\.]+")); - if (!legalName.exactMatch(buildConfiguration()->target()->project()->displayName())) { - emit addTask(Task(Task::Warning, - tr("Your project name contains characters not allowed in " - "Debian packages.\nThey must only use lower-case letters, " - "numbers, '-', '+' and '.'.\n""We will try to work around that, " - "but you may experience problems."), - QString(), -1, TASK_CATEGORY_BUILDSYSTEM)); - } -} - -bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild) -{ - const QString debianDirPath = packageDirectory() + QLatin1String("/debian"); - const QString magicFilePath - = debianDirPath + QLatin1Char('/') + MagicFileName; - if (inSourceBuild && QFileInfo(debianDirPath).isDir() - && !QFileInfo(magicFilePath).exists()) { - raiseError(tr("Packaging failed: Foreign debian directory detected. " - "You are not using a shadow build and there is a debian " - "directory in your project root ('%1'). Qt Creator will not " - "overwrite that directory. Please remove it or use the " - "shadow build feature.").arg(QDir::toNativeSeparators(debianDirPath))); - return false; - } - QString error; - if (!Utils::FileUtils::removeRecursively(debianDirPath, &error)) { - raiseError(tr("Packaging failed: Could not remove directory '%1': %2") - .arg(debianDirPath, error)); - return false; - } - QDir buildDir(packageDirectory()); - if (!buildDir.mkdir("debian")) { - raiseError(tr("Could not create Debian directory '%1'.").arg(debianDirPath)); - return false; - } - const QString templatesDirPath = debBasedMaemoTarget()->debianDirPath(); - QDir templatesDir(templatesDirPath); - const QStringList &files = templatesDir.entryList(QDir::Files); - foreach (const QString &fileName, files) { - const QString srcFile = templatesDirPath + QLatin1Char('/') + fileName; - QString newFileName = fileName; - if (newFileName == Qt4HarmattanTarget::aegisManifestFileName()) { - // If the user has touched the Aegis manifest file, we copy it for use - // by MADDE. Otherwise the required capabilities will be auto-detected. - if (QFileInfo(srcFile).size() == 0) - continue; - newFileName = maemoTarget()->packageName() + QLatin1String(".aegis"); - } - const QString destFile = debianDirPath + QLatin1Char('/') + newFileName; - if (fileName == QLatin1String("rules")) { - if (!adaptRulesFile(srcFile, destFile)) - return false; - } else if (!QFile::copy(srcFile, destFile)) { - raiseError(tr("Could not copy file '%1' to '%2'") - .arg(QDir::toNativeSeparators(srcFile), QDir::toNativeSeparators(destFile))); - return false; - } - } - - QFile magicFile(magicFilePath); - if (!magicFile.open(QIODevice::WriteOnly)) { - raiseError(tr("Error: Could not create file '%1'.") - .arg(QDir::toNativeSeparators(magicFilePath))); - return false; - } - - return true; -} - -QString MaemoDebianPackageCreationStep::packagingCommand(const Qt4BuildConfiguration *bc, - const QString &commandName) -{ - QString perl; - QtSupport::BaseQtVersion *v = bc->qtVersion(); - const QString maddeRoot = MaemoGlobal::maddeRoot(v->qmakeCommand()); -#ifdef Q_OS_WIN - perl = maddeRoot + QLatin1String("/bin/perl.exe "); -#endif - return perl + maddeRoot + QLatin1String("/madbin/") + commandName; -} - -void MaemoDebianPackageCreationStep::ensureShlibdeps(QByteArray &rulesContent) -{ - QString contentAsString = QString::fromLocal8Bit(rulesContent); - const QString whiteSpace(QLatin1String("[ \\t]*")); - const QString pattern = QLatin1String("\\n") + whiteSpace - + QLatin1Char('#') + whiteSpace + QLatin1String("dh_shlibdeps") - + QLatin1String("([^\\n]*)\\n"); - contentAsString.replace(QRegExp(pattern), - QLatin1String("\n\tdh_shlibdeps\\1\n")); - rulesContent = contentAsString.toLocal8Bit(); -} - -bool MaemoDebianPackageCreationStep::adaptRulesFile( - const QString &templatePath, const QString &rulesFilePath) -{ - Utils::FileReader reader; - if (!reader.fetch(templatePath)) { - raiseError(reader.errorString()); - return false; - } - QByteArray content = reader.data(); - const Qt4BuildConfiguration * const bc = qt4BuildConfiguration(); - - // Always check for dependencies in release builds. - if (!(bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild)) - ensureShlibdeps(content); - - Utils::FileSaver saver(rulesFilePath); - saver.write(content); - if (!saver.finalize()) { - raiseError(saver.errorString()); - return false; - } - QFile rulesFile(rulesFilePath); - rulesFile.setPermissions(rulesFile.permissions() | QFile::ExeUser); - return true; -} - - -MaemoRpmPackageCreationStep::MaemoRpmPackageCreationStep(BuildStepList *bsl) - : AbstractMaemoPackageCreationStep(bsl, CreatePackageId) -{ - ctor(); -} - -MaemoRpmPackageCreationStep::MaemoRpmPackageCreationStep(BuildStepList *buildConfig, - MaemoRpmPackageCreationStep *other) - : AbstractMaemoPackageCreationStep(buildConfig, other) -{ - ctor(); -} - -void MaemoRpmPackageCreationStep::ctor() -{ - setDefaultDisplayName(tr("Create RPM Package")); -} - -bool MaemoRpmPackageCreationStep::createPackage(QProcess *buildProc, - const QFutureInterface &fi) -{ - setPackagingStarted(); - - Q_UNUSED(fi); - const QStringList args = QStringList() << QLatin1String("rrpmbuild") - << QLatin1String("-bb") << rpmBasedMaemoTarget()->specFilePath(); - if (!callPackagingCommand(buildProc, args)) - return false; - QFile::remove(packageFilePath()); - const QString packageSourceFilePath = rpmBuildDir() + QLatin1Char('/') - + rpmBasedMaemoTarget()->packageFileName(); - if (!QFile::rename(packageSourceFilePath, packageFilePath())) { - raiseError(tr("Packaging failed: Could not move package file from %1 to %2.") - .arg(packageSourceFilePath, packageFilePath())); - return false; - } - - return true; -} - -bool MaemoRpmPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDate) const -{ - const QDateTime specFileChangeDate - = QFileInfo(rpmBasedMaemoTarget()->specFilePath()).lastModified(); - return packageDate <= specFileChangeDate; -} - -QString MaemoRpmPackageCreationStep::rpmBuildDir() const -{ - return packageDirectory() + QLatin1String("/rrpmbuild"); -} - -const QString MaemoRpmPackageCreationStep::CreatePackageId - = QLatin1String("MaemoRpmPackageCreationStep"); - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopackagecreationstep.h b/src/plugins/remotelinux/maemopackagecreationstep.h deleted file mode 100644 index 4e8b74db692..00000000000 --- a/src/plugins/remotelinux/maemopackagecreationstep.h +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOPACKAGECREATIONSTEP_H -#define MAEMOPACKAGECREATIONSTEP_H - -#include - -QT_BEGIN_NAMESPACE -class QDateTime; -class QFile; -class QProcess; -QT_END_NAMESPACE - -namespace Qt4ProjectManager { class Qt4BuildConfiguration; } - -namespace RemoteLinux { -class RemoteLinuxDeployConfiguration; - -namespace Internal { -class AbstractQt4MaemoTarget; -class AbstractDebBasedQt4MaemoTarget; -class AbstractRpmBasedQt4MaemoTarget; - -class AbstractMaemoPackageCreationStep : public RemoteLinux::AbstractPackagingStep -{ - Q_OBJECT -public: - virtual ~AbstractMaemoPackageCreationStep(); - - QString versionString(QString *error) const; - bool setVersionString(const QString &version, QString *error); - - static void preparePackagingProcess(QProcess *proc, - const Qt4ProjectManager::Qt4BuildConfiguration *bc, - const QString &workingDir); - - const Qt4ProjectManager::Qt4BuildConfiguration *qt4BuildConfiguration() const; - AbstractQt4MaemoTarget *maemoTarget() const; - AbstractDebBasedQt4MaemoTarget *debBasedMaemoTarget() const; - AbstractRpmBasedQt4MaemoTarget *rpmBasedMaemoTarget() const; - - static const QLatin1String DefaultVersionNumber; - - -protected: - AbstractMaemoPackageCreationStep(ProjectExplorer::BuildStepList *bsl, - const QString &id); - AbstractMaemoPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig, - AbstractMaemoPackageCreationStep *other); - - bool callPackagingCommand(QProcess *proc, const QStringList &arguments); - QString replaceDots(const QString &name) const; - -private slots: - void handleBuildOutput(); - -private: - virtual void run(QFutureInterface &fi); - virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - - virtual QString packageFileName() const; - - virtual bool createPackage(QProcess *buildProc, const QFutureInterface &fi) = 0; - virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const = 0; - - QString projectName() const; - static QString nativePath(const QFile &file); - bool isPackagingNeeded() const; - - const Qt4ProjectManager::Qt4BuildConfiguration *m_lastBuildConfig; -}; - - -class MaemoDebianPackageCreationStep : public AbstractMaemoPackageCreationStep -{ - Q_OBJECT - friend class MaemoPackageCreationFactory; -public: - MaemoDebianPackageCreationStep(ProjectExplorer::BuildStepList *bsl); - - static void ensureShlibdeps(QByteArray &rulesContent); - -private: - MaemoDebianPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig, - MaemoDebianPackageCreationStep *other); - - virtual bool createPackage(QProcess *buildProc, const QFutureInterface &fi); - virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const; - - void ctor(); - static QString packagingCommand(const Qt4ProjectManager::Qt4BuildConfiguration *bc, - const QString &commandName); - bool copyDebianFiles(bool inSourceBuild); - void checkProjectName(); - bool adaptRulesFile(const QString &templatePath, const QString &rulesFilePath); - - static const QString CreatePackageId; -}; - -class MaemoRpmPackageCreationStep : public AbstractMaemoPackageCreationStep -{ - Q_OBJECT - friend class MaemoPackageCreationFactory; -public: - MaemoRpmPackageCreationStep(ProjectExplorer::BuildStepList *bsl); - -private: - virtual bool createPackage(QProcess *buildProc, const QFutureInterface &fi); - virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const; - - MaemoRpmPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig, - MaemoRpmPackageCreationStep *other); - - void ctor(); - QString rpmBuildDir() const; - - static const QString CreatePackageId; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPACKAGECREATIONSTEP_H diff --git a/src/plugins/remotelinux/maemopackagecreationwidget.cpp b/src/plugins/remotelinux/maemopackagecreationwidget.cpp deleted file mode 100644 index 121a5514f9f..00000000000 --- a/src/plugins/remotelinux/maemopackagecreationwidget.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemopackagecreationwidget.h" -#include "ui_maemopackagecreationwidget.h" - -#include "maemoglobal.h" -#include "maemopackagecreationstep.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace ProjectExplorer; - -namespace RemoteLinux { -namespace Internal { - -// TODO: Split up into dedicated widgets for Debian and RPM steps. -MaemoPackageCreationWidget::MaemoPackageCreationWidget(AbstractMaemoPackageCreationStep *step) - : ProjectExplorer::BuildStepConfigWidget(), - m_step(step), - m_ui(new Ui::MaemoPackageCreationWidget) -{ - m_ui->setupUi(this); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - QTimer::singleShot(0, this, SLOT(initGui())); -} - -MaemoPackageCreationWidget::~MaemoPackageCreationWidget() -{ - delete m_ui; -} - -void MaemoPackageCreationWidget::initGui() -{ - m_ui->shortDescriptionLineEdit->setMaxLength(60); - updateVersionInfo(); - const AbstractDebBasedQt4MaemoTarget * const debBasedMaemoTarget - = m_step->debBasedMaemoTarget(); - if (debBasedMaemoTarget) { - const QSize iconSize = debBasedMaemoTarget->packageManagerIconSize(); - m_ui->packageManagerIconButton->setFixedSize(iconSize); - m_ui->packageManagerIconButton->setToolTip(tr("Size should be %1x%2 pixels") - .arg(iconSize.width()).arg(iconSize.height())); - m_ui->editSpecFileButton->setVisible(false); - updateDebianFileList(); - handleControlFileUpdate(); - connect(m_ui->packageManagerNameLineEdit, SIGNAL(editingFinished()), - SLOT(setPackageManagerName())); - connect(debBasedMaemoTarget, SIGNAL(debianDirContentsChanged()), - SLOT(updateDebianFileList())); - connect(debBasedMaemoTarget, SIGNAL(changeLogChanged()), - SLOT(updateVersionInfo())); - connect(debBasedMaemoTarget, SIGNAL(controlChanged()), - SLOT(handleControlFileUpdate())); - } else { - m_ui->packageManagerNameLabel->hide(); - m_ui->packageManagerNameLineEdit->hide(); - m_ui->packageManagerIconLabel->hide(); - m_ui->packageManagerIconButton->hide(); - m_ui->editDebianFileLabel->hide(); - m_ui->debianFilesComboBox->hide(); - m_ui->editDebianFileButton->hide(); - - // This is fragile; be careful when editing the UI file. - m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(4, QFormLayout::LabelRole)); - m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(4, QFormLayout::FieldRole)); - m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(5, QFormLayout::LabelRole)); - m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(5, QFormLayout::FieldRole)); - m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(6, QFormLayout::LabelRole)); - m_ui->formLayout->removeItem(m_ui->formLayout->itemAt(6, QFormLayout::FieldRole)); - handleSpecFileUpdate(); - connect(m_step->rpmBasedMaemoTarget(), SIGNAL(specFileChanged()), - SLOT(handleSpecFileUpdate())); - connect(m_ui->editSpecFileButton, SIGNAL(clicked()), - SLOT(editSpecFile())); - } - connect(m_step, SIGNAL(packageFilePathChanged()), this, - SIGNAL(updateSummary())); - connect(m_ui->packageNameLineEdit, SIGNAL(editingFinished()), - SLOT(setPackageName())); - connect(m_ui->shortDescriptionLineEdit, SIGNAL(editingFinished()), - SLOT(setShortDescription())); -} - -void MaemoPackageCreationWidget::updateDebianFileList() -{ - m_ui->debianFilesComboBox->clear(); - const QStringList &debianFiles = m_step->debBasedMaemoTarget()->debianFiles(); - foreach (const QString &fileName, debianFiles) { - if (fileName != QLatin1String("compat") - && !fileName.endsWith(QLatin1Char('~'))) - m_ui->debianFilesComboBox->addItem(fileName); - } -} - -void MaemoPackageCreationWidget::updateVersionInfo() -{ - QString error; - QString versionString = m_step->versionString(&error); - if (versionString.isEmpty()) { - QMessageBox::critical(this, tr("No Version Available."), error); - versionString = AbstractMaemoPackageCreationStep::DefaultVersionNumber; - } - const QStringList list = versionString.split(QLatin1Char('.'), - QString::SkipEmptyParts); - const bool blocked = m_ui->major->signalsBlocked(); - m_ui->major->blockSignals(true); - m_ui->minor->blockSignals(true); - m_ui->patch->blockSignals(true); - m_ui->major->setValue(list.value(0, QLatin1String("0")).toInt()); - m_ui->minor->setValue(list.value(1, QLatin1String("0")).toInt()); - m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt()); - m_ui->major->blockSignals(blocked); - m_ui->minor->blockSignals(blocked); - m_ui->patch->blockSignals(blocked); - updateSummary(); -} - -void MaemoPackageCreationWidget::handleControlFileUpdate() -{ - updatePackageName(); - updateShortDescription(); - updatePackageManagerName(); - updatePackageManagerIcon(); - updateSummary(); -} - -void MaemoPackageCreationWidget::handleSpecFileUpdate() -{ - updatePackageName(); - updateShortDescription(); - updateVersionInfo(); - updateSummary(); -} - -void MaemoPackageCreationWidget::updatePackageManagerIcon() -{ - QString error; - const QIcon &icon = m_step->debBasedMaemoTarget()->packageManagerIcon(&error); - if (!error.isEmpty()) { - QMessageBox::critical(this, tr("Could not read icon"), error); - } else { - m_ui->packageManagerIconButton->setIcon(icon); - m_ui->packageManagerIconButton->setIconSize(m_ui->packageManagerIconButton->size()); - } -} - -void MaemoPackageCreationWidget::updatePackageName() -{ - m_ui->packageNameLineEdit->setText(m_step->maemoTarget()->packageName()); -} - -void MaemoPackageCreationWidget::updatePackageManagerName() -{ - m_ui->packageManagerNameLineEdit->setText(m_step->debBasedMaemoTarget()->packageManagerName()); -} - -void MaemoPackageCreationWidget::updateShortDescription() -{ - m_ui->shortDescriptionLineEdit->setText(m_step->maemoTarget()->shortDescription()); -} - -void MaemoPackageCreationWidget::setPackageManagerIcon() -{ - QString imageFilter = tr("Images") + QLatin1String("( "); - const QList &imageTypes = QImageReader::supportedImageFormats(); - foreach (const QByteArray &imageType, imageTypes) - imageFilter += "*." + QString::fromAscii(imageType) + QLatin1Char(' '); - imageFilter += QLatin1Char(')'); - const QString iconFileName = QFileDialog::getOpenFileName(this, - tr("Choose Image (will be scaled to 48x48 pixels if necessary)"), - QString(), imageFilter); - if (!iconFileName.isEmpty()) { - QString error; - if (!m_step->debBasedMaemoTarget()->setPackageManagerIcon(iconFileName, &error)) - QMessageBox::critical(this, tr("Could Not Set New Icon"), error); - } -} - -void MaemoPackageCreationWidget::setPackageName() -{ - if (!m_step->maemoTarget()->setPackageName(m_ui->packageNameLineEdit->text())) { - QMessageBox::critical(this, tr("File Error"), - tr("Could not set project name.")); - } -} - -void MaemoPackageCreationWidget::setPackageManagerName() -{ - if (!m_step->debBasedMaemoTarget()->setPackageManagerName(m_ui->packageManagerNameLineEdit->text())) { - QMessageBox::critical(this, tr("File Error"), - tr("Could not set package name for project manager.")); - } -} - -void MaemoPackageCreationWidget::setShortDescription() -{ - if (!m_step->maemoTarget()->setShortDescription(m_ui->shortDescriptionLineEdit->text())) { - QMessageBox::critical(this, tr("File Error"), - tr("Could not set project description.")); - } -} - -QString MaemoPackageCreationWidget::summaryText() const -{ - return tr("Create Package: ") - + QDir::toNativeSeparators(m_step->packageFilePath()); -} - -QString MaemoPackageCreationWidget::displayName() const -{ - return m_step->displayName(); -} - -void MaemoPackageCreationWidget::versionInfoChanged() -{ - QString error; - const bool success = m_step->setVersionString(m_ui->major->text() - + QLatin1Char('.') + m_ui->minor->text() + QLatin1Char('.') - + m_ui->patch->text(), &error); - if (!success) { - QMessageBox::critical(this, tr("Could Not Set Version Number"), error); - updateVersionInfo(); - } -} - -void MaemoPackageCreationWidget::editDebianFile() -{ - editFile(m_step->debBasedMaemoTarget()->debianDirPath() - + QLatin1Char('/') + m_ui->debianFilesComboBox->currentText()); -} - -void MaemoPackageCreationWidget::editSpecFile() -{ - editFile(m_step->rpmBasedMaemoTarget()->specFilePath()); -} - -void MaemoPackageCreationWidget::editFile(const QString &filePath) -{ - Core::EditorManager::instance()->openEditor(filePath, QString(), - Core::EditorManager::ModeSwitch); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopackagecreationwidget.h b/src/plugins/remotelinux/maemopackagecreationwidget.h deleted file mode 100644 index a119380f4fc..00000000000 --- a/src/plugins/remotelinux/maemopackagecreationwidget.h +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOPACKAGECREATIONWIDGET_H -#define MAEMOPACKAGECREATIONWIDGET_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MaemoPackageCreationWidget; } -QT_END_NAMESPACE - -namespace RemoteLinux { -namespace Internal { -class AbstractMaemoPackageCreationStep; - -class MaemoPackageCreationWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT -public: - MaemoPackageCreationWidget(AbstractMaemoPackageCreationStep *step); - ~MaemoPackageCreationWidget(); - - virtual QString summaryText() const; - virtual QString displayName() const; - -private slots: - void editDebianFile(); - void editSpecFile(); - void versionInfoChanged(); - void initGui(); - void updateDebianFileList(); - void updateVersionInfo(); - void handleControlFileUpdate(); - void handleSpecFileUpdate(); - void setPackageManagerIcon(); - void setPackageManagerName(); - void setPackageName(); - void setShortDescription(); - -private: - void updatePackageManagerIcon(); - void updatePackageName(); - void updatePackageManagerName(); - void updateShortDescription(); - void editFile(const QString &filePath); - - AbstractMaemoPackageCreationStep * const m_step; - Ui::MaemoPackageCreationWidget * const m_ui; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPACKAGECREATIONWIDGET_H diff --git a/src/plugins/remotelinux/maemopackagecreationwidget.ui b/src/plugins/remotelinux/maemopackagecreationwidget.ui deleted file mode 100644 index b7017f27270..00000000000 --- a/src/plugins/remotelinux/maemopackagecreationwidget.ui +++ /dev/null @@ -1,353 +0,0 @@ - - - MaemoPackageCreationWidget - - - - 0 - 0 - 615 - 284 - - - - - 1 - 1 - - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Package name: - - - - - - - - - - - 0 - 0 - - - - - 50 - false - - - - Package version: - - - - - - - - - - 0 - 0 - - - - Major: - - - - - - - - 0 - 0 - - - - 99 - - - - - - - - 0 - 0 - - - - Minor: - - - - - - - - 0 - 0 - - - - 99 - - - - - - - - 0 - 0 - - - - Patch: - - - - - - - - 0 - 0 - - - - 99 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Short package description: - - - - - - - - - - - - - - Name to be displayed in Package Manager: - - - - - - - - - - - - - - - 0 - 48 - - - - Icon to be displayed in Package Manager: - - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Adapt Debian file: - - - - - - - - - - - - Edit - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Edit spec file - - - - - - - - - - - major - valueChanged(int) - MaemoPackageCreationWidget - versionInfoChanged() - - - 352 - 88 - - - 461 - 32 - - - - - minor - valueChanged(int) - MaemoPackageCreationWidget - versionInfoChanged() - - - 449 - 88 - - - 5 - 15 - - - - - patch - valueChanged(int) - MaemoPackageCreationWidget - versionInfoChanged() - - - 546 - 88 - - - 466 - 0 - - - - - editDebianFileButton - clicked() - MaemoPackageCreationWidget - editDebianFile() - - - 398 - 218 - - - 8 - 86 - - - - - packageManagerIconButton - clicked() - MaemoPackageCreationWidget - setPackageManagerIcon() - - - 289 - 186 - - - 2 - 143 - - - - - - addFile() - removeFile() - handleSkipButtonToggled(bool) - versionInfoChanged() - editDebianFile() - setPackageManagerIcon() - - diff --git a/src/plugins/remotelinux/maemopackageinstaller.cpp b/src/plugins/remotelinux/maemopackageinstaller.cpp deleted file mode 100644 index 25964bf51e0..00000000000 --- a/src/plugins/remotelinux/maemopackageinstaller.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemopackageinstaller.h" - -#include "maemoglobal.h" - -namespace RemoteLinux { -namespace Internal { - -MaemoDebianPackageInstaller::MaemoDebianPackageInstaller(QObject *parent) - : AbstractRemoteLinuxPackageInstaller(parent) -{ - connect(this, SIGNAL(stderrData(QString)), SLOT(handleInstallerErrorOutput(QString))); -} - -void MaemoDebianPackageInstaller::prepareInstallation() -{ - m_installerStderr.clear(); -} - -QString MaemoDebianPackageInstaller::installCommandLine(const QString &packageFilePath) const -{ - return MaemoGlobal::devrootshPath() + QLatin1String(" dpkg -i --no-force-downgrade ") - + packageFilePath; -} - -QString MaemoDebianPackageInstaller::cancelInstallationCommandLine() const -{ - return QLatin1String("pkill dpkg"); -} - -void MaemoDebianPackageInstaller::handleInstallerErrorOutput(const QString &output) -{ - m_installerStderr += output; -} - -QString MaemoDebianPackageInstaller::errorString() const -{ - if (m_installerStderr.contains(QLatin1String("Will not downgrade"))) { - return tr("Installation failed: " - "You tried to downgrade a package, which is not allowed."); - } else { - return QString(); - } -} - - -MaemoRpmPackageInstaller::MaemoRpmPackageInstaller(QObject *parent) - : AbstractRemoteLinuxPackageInstaller(parent) -{ -} - -QString MaemoRpmPackageInstaller::installCommandLine(const QString &packageFilePath) const -{ - // rpm -U does not allow to re-install a package with the same version - // number, so we need --replacepkgs. Even then, it inexplicably reports - // a conflict if the files are not identical to the installed version, - // so we need --replacefiles as well. - // TODO: --replacefiles is dangerous. Is there perhaps a way around it - // after all? - return MaemoGlobal::devrootshPath() + QLatin1String(" rpm -Uhv --replacepkgs --replacefiles ") - + packageFilePath; -} - -QString MaemoRpmPackageInstaller::cancelInstallationCommandLine() const -{ - return QLatin1String("pkill rpm"); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopackageinstaller.h b/src/plugins/remotelinux/maemopackageinstaller.h deleted file mode 100644 index bd96b965ad2..00000000000 --- a/src/plugins/remotelinux/maemopackageinstaller.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef ABSTRACTMAEMOPACKAGEINSTALLER_H -#define ABSTRACTMAEMOPACKAGEINSTALLER_H - -#include - -namespace RemoteLinux { -namespace Internal { - -class MaemoDebianPackageInstaller: public RemoteLinux::AbstractRemoteLinuxPackageInstaller -{ - Q_OBJECT -public: - explicit MaemoDebianPackageInstaller(QObject *parent); - -private slots: - void handleInstallerErrorOutput(const QString &output); - -private: - void prepareInstallation(); - QString errorString() const; - QString installCommandLine(const QString &packageFilePath) const; - QString cancelInstallationCommandLine() const; - - QString m_installerStderr; -}; - - -class MaemoRpmPackageInstaller : public RemoteLinux::AbstractRemoteLinuxPackageInstaller -{ - Q_OBJECT -public: - MaemoRpmPackageInstaller(QObject *parent); - -private: - QString installCommandLine(const QString &packageFilePath) const; - QString cancelInstallationCommandLine() const; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // ABSTRACTMAEMOPACKAGEINSTALLER_H diff --git a/src/plugins/remotelinux/maemopublishedprojectmodel.cpp b/src/plugins/remotelinux/maemopublishedprojectmodel.cpp deleted file mode 100644 index e9af35dce1f..00000000000 --- a/src/plugins/remotelinux/maemopublishedprojectmodel.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemopublishedprojectmodel.h" - -#include - -namespace RemoteLinux { -namespace Internal { -namespace { -const int IncludeColumn = 2; -} // anonymous namespace - -MaemoPublishedProjectModel::MaemoPublishedProjectModel(QObject *parent) - : QFileSystemModel(parent) -{ - setFilter(filter() | QDir::Hidden | QDir::System); -} - -void MaemoPublishedProjectModel::initFilesToExclude() -{ - initFilesToExclude(rootPath()); -} - -void MaemoPublishedProjectModel::initFilesToExclude(const QString &filePath) -{ - QFileInfo fi(filePath); - if (fi.isDir()) { - const QStringList fileNames = QDir(filePath).entryList(QDir::Files - | QDir::Dirs | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden); - foreach (const QString &fileName, fileNames) - initFilesToExclude(filePath + QLatin1Char('/') + fileName); - } else { - const QString &fileName = fi.fileName(); - if (fi.isHidden() || fileName.endsWith(QLatin1String(".o")) - || fileName == QLatin1String("Makefile") - || fileName.contains(QLatin1String(".pro.user")) - || fileName.contains(QLatin1String(".so")) - || fileName.endsWith(QLatin1String(".a"))) { - m_filesToExclude.insert(filePath); - } - } -} - -int MaemoPublishedProjectModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return IncludeColumn + 1; -} - -int MaemoPublishedProjectModel::rowCount(const QModelIndex &parent) const -{ - if (isDir(parent) && m_filesToExclude.contains(filePath(parent))) - return 0; - return QFileSystemModel::rowCount(parent); -} - -QVariant MaemoPublishedProjectModel::headerData(int section, - Qt::Orientation orientation, int role) const -{ - if (orientation != Qt::Horizontal || section != IncludeColumn) - return QFileSystemModel::headerData(section, orientation, role); - return tr("Include in package"); -} - -Qt::ItemFlags MaemoPublishedProjectModel::flags(const QModelIndex &index) const -{ - if (index.column() != IncludeColumn) - return QFileSystemModel::flags(index); - return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; -} - -QVariant MaemoPublishedProjectModel::data(const QModelIndex &index, - int role) const -{ - if (index.column() != IncludeColumn) - return QFileSystemModel::data(index, role); - const bool include = !m_filesToExclude.contains(filePath(index)); - if (role == Qt::DisplayRole) - return include ? tr("Include") : tr("Do not include"); - else if (role == Qt::CheckStateRole) - return include ? Qt::Checked : Qt::Unchecked; - else - return QVariant(); -} - -bool MaemoPublishedProjectModel::setData(const QModelIndex &index, - const QVariant &value, int role) -{ - if (index.column() != IncludeColumn) - return QFileSystemModel::setData(index, value, role); - if (role == Qt::CheckStateRole) { - if (value == Qt::Checked) { - m_filesToExclude.remove(filePath(index)); - } else { - m_filesToExclude.insert(filePath(index)); - } - if (isDir(index)) - emit layoutChanged(); - return true; - } - return false; -} - - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopublishedprojectmodel.h b/src/plugins/remotelinux/maemopublishedprojectmodel.h deleted file mode 100644 index 45e25a5353e..00000000000 --- a/src/plugins/remotelinux/maemopublishedprojectmodel.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOPUBLISHEDPROJECTMODEL_H -#define MAEMOPUBLISHEDPROJECTMODEL_H - -#include -#include -#include - -namespace RemoteLinux { -namespace Internal { - -class MaemoPublishedProjectModel : public QFileSystemModel -{ - Q_OBJECT -public: - explicit MaemoPublishedProjectModel(QObject *parent = 0); - void initFilesToExclude(); - QStringList filesToExclude() const { return m_filesToExclude.toList(); } - -private: - virtual int columnCount(const QModelIndex &parent) const; - virtual int rowCount(const QModelIndex &parent) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role) const; - virtual QVariant data(const QModelIndex &index, int role) const; - virtual bool setData(const QModelIndex &index, const QVariant &value, - int role); - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - - void initFilesToExclude(const QString &filePath); - - QSet m_filesToExclude; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPUBLISHEDPROJECTMODEL_H diff --git a/src/plugins/remotelinux/maemopublisherfremantlefree.cpp b/src/plugins/remotelinux/maemopublisherfremantlefree.cpp deleted file mode 100644 index 9fd91d1ef37..00000000000 --- a/src/plugins/remotelinux/maemopublisherfremantlefree.cpp +++ /dev/null @@ -1,644 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemopublisherfremantlefree.h" - -#include "maemoglobal.h" -#include "maemopackagecreationstep.h" -#include "maemopublishingfileselectiondialog.h" -#include "qt4maemodeployconfiguration.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace Core; -using namespace Qt4ProjectManager; -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { - -MaemoPublisherFremantleFree::MaemoPublisherFremantleFree(const ProjectExplorer::Project *project, - QObject *parent) : - QObject(parent), - m_project(project), - m_state(Inactive), - m_sshParams(SshConnectionParameters::DefaultProxy) -{ - m_sshParams.authenticationType = SshConnectionParameters::AuthenticationByKey; - m_sshParams.timeout = 30; - m_sshParams.port = 22; - m_process = new QProcess(this); - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), - SLOT(handleProcessFinished())); - connect(m_process, SIGNAL(error(QProcess::ProcessError)), - SLOT(handleProcessError(QProcess::ProcessError))); - connect(m_process, SIGNAL(readyReadStandardOutput()), - SLOT(handleProcessStdOut())); - connect(m_process, SIGNAL(readyReadStandardError()), - SLOT(handleProcessStdErr())); -} - -MaemoPublisherFremantleFree::~MaemoPublisherFremantleFree() -{ - QTC_ASSERT(m_state == Inactive, return); - m_process->kill(); -} - -void MaemoPublisherFremantleFree::publish() -{ - createPackage(); -} - -void MaemoPublisherFremantleFree::setSshParams(const QString &hostName, - const QString &userName, const QString &keyFile, const QString &remoteDir) -{ - Q_ASSERT(m_doUpload); - m_sshParams.host = hostName; - m_sshParams.userName = userName; - m_sshParams.privateKeyFile = keyFile; - m_remoteDir = remoteDir; -} - -void MaemoPublisherFremantleFree::cancel() -{ - finishWithFailure(tr("Canceled."), tr("Publishing canceled by user.")); -} - -void MaemoPublisherFremantleFree::createPackage() -{ - setState(CopyingProjectDir); - - const QStringList &problems = findProblems(); - if (!problems.isEmpty()) { - const QLatin1String separator("\n- "); - finishWithFailure(tr("The project is missing some information " - "important to publishing:") + separator + problems.join(separator), - tr("Publishing failed: Missing project information.")); - return; - } - - m_tmpProjectDir = tmpDirContainer() + QLatin1Char('/') - + m_project->displayName(); - if (QFileInfo(tmpDirContainer()).exists()) { - emit progressReport(tr("Removing left-over temporary directory ...")); - QString error; - if (!Utils::FileUtils::removeRecursively(tmpDirContainer(), &error)) { - finishWithFailure(tr("Error removing temporary directory: %1").arg(error), - tr("Publishing failed: Could not create source package.")); - return; - } - } - - emit progressReport(tr("Setting up temporary directory ...")); - if (!QDir::temp().mkdir(QFileInfo(tmpDirContainer()).fileName())) { - finishWithFailure(tr("Error: Could not create temporary directory."), - tr("Publishing failed: Could not create source package.")); - return; - } - if (!copyRecursively(m_project->projectDirectory(), m_tmpProjectDir)) { - finishWithFailure(tr("Error: Could not copy project directory."), - tr("Publishing failed: Could not create source package.")); - return; - } - if (!fixNewlines()) { - finishWithFailure(tr("Error: Could not fix newlines."), - tr("Publishing failed: Could not create source package.")); - return; - } - - QString error; - if (!updateDesktopFiles(&error)) { - finishWithFailure(error, - tr("Publishing failed: Could not create package.")); - return; - } - - emit progressReport(tr("Cleaning up temporary directory ...")); - AbstractMaemoPackageCreationStep::preparePackagingProcess(m_process, - m_buildConfig, m_tmpProjectDir); - setState(RunningQmake); - ProjectExplorer::AbstractProcessStep * const qmakeStep - = m_buildConfig->qmakeStep(); - qmakeStep->init(); - const ProjectExplorer::ProcessParameters * const pp - = qmakeStep->processParameters(); - m_process->start(pp->effectiveCommand() + QLatin1String(" ") - + pp->effectiveArguments()); -} - -bool MaemoPublisherFremantleFree::copyRecursively(const QString &srcFilePath, - const QString &tgtFilePath) -{ - if (m_state == Inactive) - return true; - - QFileInfo srcFileInfo(srcFilePath); - if (srcFileInfo.isDir()) { - if (srcFileInfo == QFileInfo(m_project->projectDirectory() - + QLatin1String("/debian"))) - return true; - QString actualSourcePath = srcFilePath; - QString actualTargetPath = tgtFilePath; - - if (srcFileInfo.fileName() == QLatin1String("qtc_packaging")) { - actualSourcePath += QLatin1String("/debian_fremantle"); - actualTargetPath.replace(QRegExp(QLatin1String("qtc_packaging$")), - QLatin1String("debian")); - } - - QDir targetDir(actualTargetPath); - targetDir.cdUp(); - if (!targetDir.mkdir(QFileInfo(actualTargetPath).fileName())) { - emit progressReport(tr("Failed to create directory '%1'.") - .arg(QDir::toNativeSeparators(actualTargetPath)), ErrorOutput); - return false; - } - QDir sourceDir(actualSourcePath); - QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Hidden - | QDir::System | QDir::Dirs | QDir::NoDotAndDotDot); - foreach (const QString &fileName, fileNames) { - if (!copyRecursively(actualSourcePath + QLatin1Char('/') + fileName, - actualTargetPath + QLatin1Char('/') + fileName)) - return false; - } - } else { - if (tgtFilePath == m_tmpProjectDir + QLatin1String("/debian/rules")) { - Utils::FileReader reader; - if (!reader.fetch(srcFilePath)) { - emit progressReport(reader.errorString(), ErrorOutput); - return false; - } - QByteArray rulesContents = reader.data(); - rulesContents.replace("$(MAKE) clean", "# $(MAKE) clean"); - rulesContents.replace("# Add here commands to configure the package.", - "qmake " + QFileInfo(m_project->file()->fileName()).fileName().toLocal8Bit()); - MaemoDebianPackageCreationStep::ensureShlibdeps(rulesContents); - Utils::FileSaver saver(tgtFilePath); - saver.write(rulesContents); - if (!saver.finalize()) { - emit progressReport(saver.errorString(), ErrorOutput); - return false; - } - } else { - QFile srcFile(srcFilePath); - if (!srcFile.copy(tgtFilePath)) { - emit progressReport(tr("Could not copy file '%1' to '%2': %3.") - .arg(QDir::toNativeSeparators(srcFilePath), - QDir::toNativeSeparators(tgtFilePath), - srcFile.errorString())); - return false; - } - } - } - return true; -} - -bool MaemoPublisherFremantleFree::fixNewlines() -{ - QDir debianDir(m_tmpProjectDir + QLatin1String("/debian")); - const QStringList &fileNames = debianDir.entryList(QDir::Files); - foreach (const QString &fileName, fileNames) { - QString filePath = debianDir.filePath(fileName); - Utils::FileReader reader; - if (!reader.fetch(filePath)) - return false; - QByteArray contents = reader.data(); - const QByteArray crlf("\r\n"); - if (!contents.contains(crlf)) - continue; - contents.replace(crlf, "\n"); - Utils::FileSaver saver(filePath); - saver.write(contents); - if (!saver.finalize()) - return false; - } - return true; -} - -void MaemoPublisherFremantleFree::handleProcessError(QProcess::ProcessError error) -{ - if (error == QProcess::FailedToStart) - handleProcessFinished(true); -} - -void MaemoPublisherFremantleFree::handleProcessFinished() -{ - handleProcessFinished(false); -} - -void MaemoPublisherFremantleFree::handleProcessStdOut() -{ - if (m_state == RunningQmake || m_state == RunningMakeDistclean - || m_state == BuildingPackage) { - emit progressReport(QString::fromLocal8Bit(m_process->readAllStandardOutput()), - ToolStatusOutput); - } -} - -void MaemoPublisherFremantleFree::handleProcessStdErr() -{ - if (m_state == RunningQmake || m_state == RunningMakeDistclean - || m_state == BuildingPackage) { - emit progressReport(QString::fromLocal8Bit(m_process->readAllStandardError()), - ToolErrorOutput); - } -} - -void MaemoPublisherFremantleFree::handleProcessFinished(bool failedToStart) -{ - QTC_ASSERT(m_state == RunningQmake || m_state == RunningMakeDistclean - || m_state == BuildingPackage || m_state == Inactive, return); - - switch (m_state) { - case RunningQmake: - if (failedToStart || m_process->exitStatus() != QProcess::NormalExit - ||m_process->exitCode() != 0) { - runDpkgBuildPackage(); - } else { - setState(RunningMakeDistclean); - m_process->start(m_buildConfig->makeCommand(), - QStringList() << QLatin1String("distclean")); - } - break; - case RunningMakeDistclean: - runDpkgBuildPackage(); - break; - case BuildingPackage: { - QString error; - if (failedToStart) { - error = tr("Error: Failed to start dpkg-buildpackage."); - } else if (m_process->exitStatus() != QProcess::NormalExit - || m_process->exitCode() != 0) { - error = tr("Error: dpkg-buildpackage did not succeed."); - } - - if (!error.isEmpty()) { - finishWithFailure(error, tr("Package creation failed.")); - return; - } - - QDir dir(tmpDirContainer()); - const QStringList &fileNames = dir.entryList(QDir::Files); - foreach (const QString &fileName, fileNames) { - const QString filePath - = tmpDirContainer() + QLatin1Char('/') + fileName; - if (fileName.endsWith(QLatin1String(".dsc"))) - m_filesToUpload.append(filePath); - else - m_filesToUpload.prepend(filePath); - } - if (!m_doUpload) { - emit progressReport(tr("Done.")); - QStringList nativeFilePaths; - foreach (const QString &filePath, m_filesToUpload) - nativeFilePaths << QDir::toNativeSeparators(filePath); - m_resultString = tr("Packaging finished successfully. " - "The following files were created:\n") - + nativeFilePaths.join(QLatin1String("\n")); - setState(Inactive); - } else { - uploadPackage(); - } - break; - } - default: - break; - } -} - -void MaemoPublisherFremantleFree::runDpkgBuildPackage() -{ - MaemoPublishingFileSelectionDialog d(m_tmpProjectDir); - if (d.exec() == QDialog::Rejected) { - cancel(); - return; - } - foreach (const QString &filePath, d.filesToExclude()) { - QString error; - if (!Utils::FileUtils::removeRecursively(filePath, &error)) { - finishWithFailure(error, - tr("Publishing failed: Could not create package.")); - } - } - - QtSupport::BaseQtVersion *lqt = m_buildConfig->qtVersion(); - if (!lqt) - finishWithFailure(QString(), tr("No Qt version set.")); - - if (m_state == Inactive) - return; - setState(BuildingPackage); - emit progressReport(tr("Building source package...")); - const QStringList args = QStringList() << QLatin1String("dpkg-buildpackage") - << QLatin1String("-S") << QLatin1String("-us") << QLatin1String("-uc"); - MaemoGlobal::callMad(*m_process, args, lqt->qmakeCommand(), true); -} - -// We have to implement the SCP protocol, because the maemo.org -// webmaster refuses to enable SFTP "for security reasons" ... -void MaemoPublisherFremantleFree::uploadPackage() -{ - m_uploader = SshRemoteProcessRunner::create(m_sshParams); - connect(m_uploader.data(), SIGNAL(processStarted()), - SLOT(handleScpStarted())); - connect(m_uploader.data(), SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); - connect(m_uploader.data(), SIGNAL(processClosed(int)), - SLOT(handleUploadJobFinished(int))); - connect(m_uploader.data(), SIGNAL(processOutputAvailable(QByteArray)), - SLOT(handleScpStdOut(QByteArray))); - emit progressReport(tr("Starting scp ...")); - setState(StartingScp); - m_uploader->run("scp -td " + m_remoteDir.toUtf8()); -} - -void MaemoPublisherFremantleFree::handleScpStarted() -{ - QTC_ASSERT(m_state == StartingScp || m_state == Inactive, return); - - if (m_state == StartingScp) - prepareToSendFile(); -} - -void MaemoPublisherFremantleFree::handleConnectionError() -{ - if (m_state != Inactive) { - finishWithFailure(tr("SSH error: %1").arg(m_uploader->connection()->errorString()), - tr("Upload failed.")); - } -} - -void MaemoPublisherFremantleFree::handleUploadJobFinished(int exitStatus) -{ - QTC_ASSERT(m_state == PreparingToUploadFile || m_state == UploadingFile || m_state ==Inactive, - return); - - if (m_state != Inactive && (exitStatus != SshRemoteProcess::ExitedNormally - || m_uploader->process()->exitCode() != 0)) { - QString error; - if (exitStatus != SshRemoteProcess::ExitedNormally) { - error = tr("Error uploading file: %1.") - .arg(m_uploader->process()->errorString()); - } else { - error = tr("Error uploading file."); - } - finishWithFailure(error, tr("Upload failed.")); - } -} - -void MaemoPublisherFremantleFree::prepareToSendFile() -{ - if (m_filesToUpload.isEmpty()) { - emit progressReport(tr("All files uploaded.")); - m_resultString = tr("Upload succeeded. You should shortly " - "receive an email informing you about the outcome " - "of the build process."); - setState(Inactive); - return; - } - - setState(PreparingToUploadFile); - const QString &nextFilePath = m_filesToUpload.first(); - emit progressReport(tr("Uploading file %1 ...") - .arg(QDir::toNativeSeparators(nextFilePath))); - QFileInfo info(nextFilePath); - m_uploader->process()->sendInput("C0644 " + QByteArray::number(info.size()) - + ' ' + info.fileName().toUtf8() + '\n'); -} - -void MaemoPublisherFremantleFree::sendFile() -{ - Q_ASSERT(!m_filesToUpload.isEmpty()); - Q_ASSERT(m_state == PreparingToUploadFile); - - setState(UploadingFile); - const QString filePath = m_filesToUpload.takeFirst(); - QFile file(filePath); - if (!file.open(QIODevice::ReadOnly)) { - finishWithFailure(tr("Cannot open file for reading: %1.") - .arg(file.errorString()), tr("Upload failed.")); - return; - } - qint64 bytesToSend = file.size(); - while (bytesToSend > 0) { - const QByteArray &data - = file.read(qMin(bytesToSend, Q_INT64_C(1024*1024))); - if (data.count() == 0) { - finishWithFailure(tr("Cannot read file: %1").arg(file.errorString()), - tr("Upload failed.")); - return; - } - m_uploader->process()->sendInput(data); - bytesToSend -= data.size(); - QCoreApplication::processEvents(); - if (m_state == Inactive) - return; - } - m_uploader->process()->sendInput(QByteArray(1, '\0')); -} - -void MaemoPublisherFremantleFree::handleScpStdOut(const QByteArray &output) -{ - QTC_ASSERT(m_state == PreparingToUploadFile || m_state == UploadingFile || m_state == Inactive, - return); - - if (m_state == Inactive) - return; - - m_scpOutput += output; - if (m_scpOutput == QByteArray(1, '\0')) { - m_scpOutput.clear(); - switch (m_state) { - case PreparingToUploadFile: - sendFile(); - break; - case UploadingFile: - prepareToSendFile(); - break; - default: - break; - } - } else if (m_scpOutput.endsWith('\n')) { - const QByteArray error = m_scpOutput.mid(1, m_scpOutput.count() - 2); - QString progressError; - if (!error.isEmpty()) { - progressError = tr("Error uploading file: %1.") - .arg(QString::fromUtf8(error)); - } else { - progressError = tr("Error uploading file."); - } - finishWithFailure(progressError, tr("Upload failed.")); - } -} - -QString MaemoPublisherFremantleFree::tmpDirContainer() const -{ - return QDir::tempPath() + QLatin1String("/qtc_packaging_") - + m_project->displayName(); -} - -void MaemoPublisherFremantleFree::finishWithFailure(const QString &progressMsg, - const QString &resultMsg) -{ - if (!progressMsg.isEmpty()) - emit progressReport(progressMsg, ErrorOutput); - m_resultString = resultMsg; - setState(Inactive); -} - -bool MaemoPublisherFremantleFree::updateDesktopFiles(QString *error) const -{ - bool success = true; - const Qt4MaemoDeployConfiguration * const deployConfig - = qobject_cast(m_buildConfig->target()->activeDeployConfiguration()); - const QSharedPointer deploymentInfo - = deployConfig->deploymentInfo(); - for (int i = 0; i < deploymentInfo->modelCount(); ++i) { - const DeployableFilesPerProFile * const model = deploymentInfo->modelAt(i); - QString desktopFilePath = deployConfig->localDesktopFilePath(model); - if (desktopFilePath.isEmpty()) - continue; - desktopFilePath.replace(model->projectDir(), m_tmpProjectDir); - const QString executableFilePath = model->remoteExecutableFilePath(); - if (executableFilePath.isEmpty()) { - qDebug("%s: Skipping subproject %s with missing deployment information.", - Q_FUNC_INFO, qPrintable(model->proFilePath())); - continue; - } - Utils::FileReader reader; - if (!reader.fetch(desktopFilePath, error)) { - success = false; - continue; - } - QByteArray desktopFileContents = reader.data(); - bool fileNeedsUpdate = addOrReplaceDesktopFileValue(desktopFileContents, - "Exec", executableFilePath.toUtf8()); - if (fileNeedsUpdate) { - Utils::FileSaver saver(desktopFilePath); - saver.write(desktopFileContents); - if (!saver.finalize(error)) - success = false; - } - } - return success; -} - -bool MaemoPublisherFremantleFree::addOrReplaceDesktopFileValue(QByteArray &fileContent, - const QByteArray &key, const QByteArray &newValue) const -{ - const int keyPos = fileContent.indexOf(key + '='); - if (keyPos == -1) { - if (!fileContent.endsWith('\n')) - fileContent += '\n'; - fileContent += key + '=' + newValue + '\n'; - return true; - } - int nextNewlinePos = fileContent.indexOf('\n', keyPos); - if (nextNewlinePos == -1) - nextNewlinePos = fileContent.count(); - const int replacePos = keyPos + key.count() + 1; - const int replaceCount = nextNewlinePos - replacePos; - const QByteArray &oldValue = fileContent.mid(replacePos, replaceCount); - if (oldValue == newValue) - return false; - fileContent.replace(replacePos, replaceCount, newValue); - return true; -} - -QStringList MaemoPublisherFremantleFree::findProblems() const -{ - QStringList problems; - const Qt4Maemo5Target * const target - = qobject_cast(m_buildConfig->target()); - const QString &description = target->shortDescription(); - if (description.trimmed().isEmpty()) { - problems << tr("The package description is empty. You must set one " - "in Projects -> Run -> Create Package -> Details."); - } else if (description.contains(QLatin1String("insert up to"))) { - problems << tr("The package description is '%1', which is probably " - "not what you want. Please change it in " - "Projects -> Run -> Create Package -> Details.").arg(description); - } - QString dummy; - if (target->packageManagerIcon(&dummy).isNull()) - problems << tr("You have not set an icon for the package manager. " - "The icon must be set in Projects -> Run -> Create Package -> Details."); - return problems; -} - -void MaemoPublisherFremantleFree::setState(State newState) -{ - if (m_state == newState) - return; - const State oldState = m_state; - m_state = newState; - if (m_state == Inactive) { - switch (oldState) { - case RunningQmake: - case RunningMakeDistclean: - case BuildingPackage: - disconnect(m_process, 0, this, 0); - m_process->terminate(); - break; - case StartingScp: - case PreparingToUploadFile: - case UploadingFile: - // TODO: Can we ensure the remote scp exits, e.g. by sending - // an illegal sequence of bytes? (Probably not, if - // we are currently uploading a file.) - disconnect(m_uploader.data(), 0, this, 0); - m_uploader = SshRemoteProcessRunner::Ptr(); - break; - default: - break; - } - emit finished(); - } -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopublisherfremantlefree.h b/src/plugins/remotelinux/maemopublisherfremantlefree.h deleted file mode 100644 index 65d03f6a232..00000000000 --- a/src/plugins/remotelinux/maemopublisherfremantlefree.h +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMOPUBLISHERFREMANTLEFREE_H -#define MAEMOPUBLISHERFREMANTLEFREE_H - -#include - -#include -#include - -namespace ProjectExplorer { -class Project; -} - -namespace Qt4ProjectManager { -class Qt4BuildConfiguration; -} - -namespace RemoteLinux { -namespace Internal { - -class MaemoPublisherFremantleFree : public QObject -{ - Q_OBJECT -public: - enum OutputType { - StatusOutput, ErrorOutput, ToolStatusOutput, ToolErrorOutput - }; - - explicit MaemoPublisherFremantleFree(const ProjectExplorer::Project *project, - QObject *parent = 0); - ~MaemoPublisherFremantleFree(); - - void publish(); - void cancel(); - - void setBuildConfiguration(const Qt4ProjectManager::Qt4BuildConfiguration *buildConfig) { m_buildConfig = buildConfig; } - void setDoUpload(bool doUpload) { m_doUpload = doUpload; } - void setSshParams(const QString &hostName, const QString &userName, - const QString &keyFile, const QString &remoteDir); - - QString resultString() const { return m_resultString; } - -signals: - void progressReport(const QString &text, - MaemoPublisherFremantleFree::OutputType = StatusOutput); - void finished(); - -private slots: - void handleProcessFinished(); - void handleProcessStdOut(); - void handleProcessStdErr(); - void handleProcessError(QProcess::ProcessError error); - void handleScpStarted(); - void handleConnectionError(); - void handleUploadJobFinished(int exitStatus); - void handleScpStdOut(const QByteArray &output); - -private: - enum State { - Inactive, CopyingProjectDir, RunningQmake, RunningMakeDistclean, - BuildingPackage, StartingScp, PreparingToUploadFile, UploadingFile - }; - - void setState(State newState); - void createPackage(); - void uploadPackage(); - bool copyRecursively(const QString &srcFilePath, - const QString &tgtFilePath); - bool fixNewlines(); - void handleProcessFinished(bool failedToStart); - void runDpkgBuildPackage(); - QString tmpDirContainer() const; - void prepareToSendFile(); - void sendFile(); - void finishWithFailure(const QString &progressMsg, const QString &resultMsg); - bool updateDesktopFiles(QString *error = 0) const; - bool addOrReplaceDesktopFileValue(QByteArray &fileContent, - const QByteArray &key, const QByteArray &newValue) const; - QStringList findProblems() const; - - const ProjectExplorer::Project * const m_project; - bool m_doUpload; - const Qt4ProjectManager::Qt4BuildConfiguration *m_buildConfig; - State m_state; - QString m_tmpProjectDir; - QProcess *m_process; - Utils::SshConnectionParameters m_sshParams; - QString m_remoteDir; - QSharedPointer m_uploader; - QByteArray m_scpOutput; - QList m_filesToUpload; - QString m_resultString; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPUBLISHERFREMANTLEFREE_H diff --git a/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.cpp b/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.cpp deleted file mode 100644 index 436ce7dc795..00000000000 --- a/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemopublishingbuildsettingspagefremantlefree.h" -#include "ui_maemopublishingbuildsettingspagefremantlefree.h" - -#include "maemoconstants.h" -#include "maemoglobal.h" -#include "maemopublisherfremantlefree.h" - -#include -#include -#include -#include -#include -#include - -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -MaemoPublishingBuildSettingsPageFremantleFree::MaemoPublishingBuildSettingsPageFremantleFree(const Project *project, - MaemoPublisherFremantleFree *publisher, QWidget *parent) : - QWizardPage(parent), - m_publisher(publisher), - ui(new Ui::MaemoPublishingWizardPageFremantleFree) -{ - ui->setupUi(this); - collectBuildConfigurations(project); - QTC_ASSERT(!m_buildConfigs.isEmpty(), return); - foreach (const Qt4BuildConfiguration * const bc, m_buildConfigs) { - ui->buildConfigComboBox->addItem(bc->displayName()); - } - ui->buildConfigComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow); - ui->buildConfigComboBox->setCurrentIndex(0); - connect(ui->skipUploadCheckBox, SIGNAL(toggled(bool)), - SLOT(handleNoUploadSettingChanged())); -} - -MaemoPublishingBuildSettingsPageFremantleFree::~MaemoPublishingBuildSettingsPageFremantleFree() -{ - delete ui; -} - -void MaemoPublishingBuildSettingsPageFremantleFree::collectBuildConfigurations(const Project *project) -{ - foreach (const Target *const target, project->targets()) { - if (target->id() != QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)) - continue; - foreach (BuildConfiguration * const bc, target->buildConfigurations()) { - Qt4BuildConfiguration * const qt4Bc - = qobject_cast(bc); - if (!qt4Bc) - continue; - - QtSupport::BaseQtVersion *lqt = qt4Bc->qtVersion(); - if (!lqt) - continue; - if (MaemoGlobal::osType(lqt->qmakeCommand()) == QLatin1String(Maemo5OsType)) - m_buildConfigs << qt4Bc; - } - break; - } -} - -void MaemoPublishingBuildSettingsPageFremantleFree::initializePage() -{ - ui->skipUploadCheckBox->setChecked(true); -} - -bool MaemoPublishingBuildSettingsPageFremantleFree::validatePage() -{ - m_publisher->setBuildConfiguration(m_buildConfigs.at(ui->buildConfigComboBox->currentIndex())); - m_publisher->setDoUpload(!skipUpload()); - return true; -} - -void MaemoPublishingBuildSettingsPageFremantleFree::handleNoUploadSettingChanged() -{ - setCommitPage(skipUpload()); -} - -bool MaemoPublishingBuildSettingsPageFremantleFree::skipUpload() const -{ - return ui->skipUploadCheckBox->isChecked(); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.h b/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.h deleted file mode 100644 index 83dd6b7a2b9..00000000000 --- a/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.h +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMOPUBLISHINGBUILDSETTINGSPAGEFREMANTLEFREE_H -#define MAEMOPUBLISHINGBUILDSETTINGSPAGEFREMANTLEFREE_H - -#include -#include - -QT_BEGIN_NAMESPACE -namespace Ui { - class MaemoPublishingWizardPageFremantleFree; -} -QT_END_NAMESPACE - -namespace ProjectExplorer { class Project; } -namespace Qt4ProjectManager { class Qt4BuildConfiguration; } - -namespace RemoteLinux { -namespace Internal { -class MaemoPublisherFremantleFree; - -class MaemoPublishingBuildSettingsPageFremantleFree : public QWizardPage -{ - Q_OBJECT - -public: - explicit MaemoPublishingBuildSettingsPageFremantleFree(const ProjectExplorer::Project *project, - MaemoPublisherFremantleFree *publisher, QWidget *parent = 0); - ~MaemoPublishingBuildSettingsPageFremantleFree(); - -private: - Q_SLOT void handleNoUploadSettingChanged(); - virtual void initializePage(); - virtual bool validatePage(); - void collectBuildConfigurations(const ProjectExplorer::Project *project); - bool skipUpload() const; - - QList m_buildConfigs; - MaemoPublisherFremantleFree * const m_publisher; - Ui::MaemoPublishingWizardPageFremantleFree *ui; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPUBLISHINGBUILDSETTINGSPAGEFREMANTLEFREE_H diff --git a/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.ui b/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.ui deleted file mode 100644 index 6e536f6cc81..00000000000 --- a/src/plugins/remotelinux/maemopublishingbuildsettingspagefremantlefree.ui +++ /dev/null @@ -1,75 +0,0 @@ - - - MaemoPublishingWizardPageFremantleFree - - - - 0 - 0 - 433 - 149 - - - - WizardPage - - - - - - - - Choose build configuration: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - - - - Only create source package, do not upload - - - - - - - Qt::Vertical - - - - 20 - 78 - - - - - - - - - diff --git a/src/plugins/remotelinux/maemopublishingfileselectiondialog.cpp b/src/plugins/remotelinux/maemopublishingfileselectiondialog.cpp deleted file mode 100644 index 8feba7a678b..00000000000 --- a/src/plugins/remotelinux/maemopublishingfileselectiondialog.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemopublishingfileselectiondialog.h" -#include "ui_maemopublishingfileselectiondialog.h" - -#include "maemopublishedprojectmodel.h" - -namespace RemoteLinux { -namespace Internal { - -MaemoPublishingFileSelectionDialog::MaemoPublishingFileSelectionDialog(const QString &projectPath, - QWidget *parent) : - QDialog(parent), - ui(new Ui::MaemoPublishingFileSelectionDialog) -{ - ui->setupUi(this); - m_projectModel = new MaemoPublishedProjectModel(this); - const QModelIndex rootIndex = m_projectModel->setRootPath(projectPath); - m_projectModel->initFilesToExclude(); - ui->projectView->setModel(m_projectModel); - ui->projectView->setRootIndex(rootIndex); - ui->projectView->header()->setResizeMode(0, QHeaderView::ResizeToContents); -} - -MaemoPublishingFileSelectionDialog::~MaemoPublishingFileSelectionDialog() -{ - delete ui; -} - -QStringList MaemoPublishingFileSelectionDialog::filesToExclude() const -{ - return m_projectModel->filesToExclude(); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopublishingfileselectiondialog.h b/src/plugins/remotelinux/maemopublishingfileselectiondialog.h deleted file mode 100644 index b6dfe843667..00000000000 --- a/src/plugins/remotelinux/maemopublishingfileselectiondialog.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOPUBLISHINGFILESELECTIONDIALOG_H -#define MAEMOPUBLISHINGFILESELECTIONDIALOG_H - -#include -#include - -QT_BEGIN_NAMESPACE -namespace Ui { - class MaemoPublishingFileSelectionDialog; -} -QT_END_NAMESPACE - -namespace RemoteLinux { -namespace Internal { - -class MaemoPublishingFileSelectionDialog : public QDialog -{ - Q_OBJECT - -public: - explicit MaemoPublishingFileSelectionDialog(const QString &projectPath, - QWidget *parent = 0); - ~MaemoPublishingFileSelectionDialog(); - QStringList filesToExclude() const; - -private: - Ui::MaemoPublishingFileSelectionDialog *ui; - class MaemoPublishedProjectModel *m_projectModel; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPUBLISHINGFILESELECTIONDIALOG_H diff --git a/src/plugins/remotelinux/maemopublishingfileselectiondialog.ui b/src/plugins/remotelinux/maemopublishingfileselectiondialog.ui deleted file mode 100644 index a66247f9eef..00000000000 --- a/src/plugins/remotelinux/maemopublishingfileselectiondialog.ui +++ /dev/null @@ -1,78 +0,0 @@ - - - MaemoPublishingFileSelectionDialog - - - - 0 - 0 - 704 - 528 - - - - Choose Package Contents - - - false - - - - - - <b>Please select the files you want to be included in the source tarball.</b> - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - MaemoPublishingFileSelectionDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - MaemoPublishingFileSelectionDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.cpp b/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.cpp deleted file mode 100644 index be8a5c096c6..00000000000 --- a/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemopublishingresultpagefremantlefree.h" -#include "ui_maemopublishingresultpagefremantlefree.h" - -#include - -namespace RemoteLinux { -namespace Internal { -typedef MaemoPublisherFremantleFree MPFF; - -MaemoPublishingResultPageFremantleFree::MaemoPublishingResultPageFremantleFree(MPFF *publisher, - QWidget *parent) : QWizardPage(parent), m_publisher(publisher), - ui(new Ui::MaemoPublishingResultPageFremantleFree) -{ - m_lastOutputType = MPFF::StatusOutput; - ui->setupUi(this); -} - -MaemoPublishingResultPageFremantleFree::~MaemoPublishingResultPageFremantleFree() -{ - delete ui; -} - -void MaemoPublishingResultPageFremantleFree::initializePage() -{ - cancelButton()->disconnect(); - connect(cancelButton(), SIGNAL(clicked()), SLOT(handleCancelRequest())); - connect(m_publisher, SIGNAL(finished()), SLOT(handleFinished())); - connect(m_publisher, - SIGNAL(progressReport(QString, MaemoPublisherFremantleFree::OutputType)), - SLOT(handleProgress(QString, MaemoPublisherFremantleFree::OutputType))); - m_publisher->publish(); -} - -void MaemoPublishingResultPageFremantleFree::handleFinished() -{ - handleProgress(m_publisher->resultString(), MPFF::StatusOutput); - m_isComplete = true; - cancelButton()->setEnabled(false); - emit completeChanged(); -} - -void MaemoPublishingResultPageFremantleFree::handleProgress(const QString &text, - MPFF::OutputType type) -{ - const QString color = QLatin1String(type == MPFF::StatusOutput - || type == MPFF::ToolStatusOutput ? "blue" : "red"); - ui->progressTextEdit->setTextColor(QColor(color)); - const bool bold = type == MPFF::StatusOutput - || type == MPFF::ErrorOutput ? true : false; - QFont font = ui->progressTextEdit->currentFont(); - font.setBold(bold); - ui->progressTextEdit->setCurrentFont(font); - - if (type == MPFF::StatusOutput || type == MPFF::ErrorOutput - || m_lastOutputType == MPFF::StatusOutput - || m_lastOutputType == MPFF::ErrorOutput) { - ui->progressTextEdit->append(text); - } else { - ui->progressTextEdit->insertPlainText(text); - } - ui->progressTextEdit->moveCursor(QTextCursor::End); - m_lastOutputType = type; -} - -void MaemoPublishingResultPageFremantleFree::handleCancelRequest() -{ - cancelButton()->setEnabled(false); - m_publisher->cancel(); -} - -QAbstractButton *MaemoPublishingResultPageFremantleFree::cancelButton() const -{ - return wizard()->button(QWizard::CancelButton); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.h b/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.h deleted file mode 100644 index 6fc2ce5c5a8..00000000000 --- a/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H -#define MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H - -#include "maemopublisherfremantlefree.h" -#include - -QT_BEGIN_NAMESPACE -namespace Ui { - class MaemoPublishingResultPageFremantleFree; -} -QT_END_NAMESPACE - -namespace RemoteLinux { -namespace Internal { - -class MaemoPublishingResultPageFremantleFree : public QWizardPage -{ - Q_OBJECT - -public: - explicit MaemoPublishingResultPageFremantleFree(MaemoPublisherFremantleFree *publisher, - QWidget *parent = 0); - ~MaemoPublishingResultPageFremantleFree(); - -private slots: - void handleFinished(); - void handleProgress(const QString &text, - MaemoPublisherFremantleFree::OutputType type); - void handleCancelRequest(); - -private: - virtual bool isComplete() const { return m_isComplete; } - virtual void initializePage(); - - QAbstractButton *cancelButton() const; - - MaemoPublisherFremantleFree * const m_publisher; - bool m_isComplete; - MaemoPublisherFremantleFree::OutputType m_lastOutputType; - Ui::MaemoPublishingResultPageFremantleFree *ui; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPUBLISHINGRESULTPAGEFREMANTLEFREE_H diff --git a/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.ui b/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.ui deleted file mode 100644 index f7f429ccf8d..00000000000 --- a/src/plugins/remotelinux/maemopublishingresultpagefremantlefree.ui +++ /dev/null @@ -1,33 +0,0 @@ - - - MaemoPublishingResultPageFremantleFree - - - - 0 - 0 - 414 - 337 - - - - WizardPage - - - - - - Progress - - - - - - - - - - - - - diff --git a/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.cpp b/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.cpp deleted file mode 100644 index 98feae6536c..00000000000 --- a/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemopublishinguploadsettingspagefremantlefree.h" -#include "ui_maemopublishinguploadsettingspagefremantlefree.h" - -#include "maemopublisherfremantlefree.h" - -#include - -#include - -namespace RemoteLinux { -namespace Internal { - -MaemoPublishingUploadSettingsPageFremantleFree::MaemoPublishingUploadSettingsPageFremantleFree(MaemoPublisherFremantleFree *publisher, - QWidget *parent) : - QWizardPage(parent), - m_publisher(publisher), - ui(new Ui::MaemoPublishingUploadSettingsPageFremantleFree) -{ - ui->setupUi(this); - ui->serverAddressLabel->hide(); - ui->serverAddressLineEdit->hide(); - ui->targetDirectoryOnServerLabel->hide(); - ui->targetDirectoryOnServerLineEdit->hide(); - setTitle(tr("Publishing to Fremantle's \"Extras-devel/free\" Repository")); - setSubTitle(tr("Upload options")); - connect(ui->garageAccountLineEdit, SIGNAL(textChanged(QString)), - SIGNAL(completeChanged())); - connect(ui->privateKeyPathChooser, SIGNAL(changed(QString)), - SIGNAL(completeChanged())); - connect(ui->serverAddressLineEdit, SIGNAL(textChanged(QString)), - SIGNAL(completeChanged())); - connect(ui->targetDirectoryOnServerLineEdit, SIGNAL(textChanged(QString)), - SIGNAL(completeChanged())); -} - -MaemoPublishingUploadSettingsPageFremantleFree::~MaemoPublishingUploadSettingsPageFremantleFree() -{ - delete ui; -} - -void MaemoPublishingUploadSettingsPageFremantleFree::initializePage() -{ - ui->garageAccountLineEdit->clear(); - ui->privateKeyPathChooser->setExpectedKind(Utils::PathChooser::File); - ui->privateKeyPathChooser->setPromptDialogTitle(tr("Choose a private key file")); - ui->privateKeyPathChooser->setPath(QDir::toNativeSeparators(QDir::homePath() + QLatin1String("/.ssh/id_rsa"))); - ui->serverAddressLineEdit->setText(QLatin1String("drop.maemo.org")); - ui->targetDirectoryOnServerLineEdit->setText(QLatin1String("/var/www/extras-devel/incoming-builder/fremantle/")); -} - -bool MaemoPublishingUploadSettingsPageFremantleFree::isComplete() const -{ - return !garageAccountName().isEmpty() && !privateKeyFilePath().isEmpty() - && !serverName().isEmpty() && !directoryOnServer().isEmpty(); -} - -QString MaemoPublishingUploadSettingsPageFremantleFree::garageAccountName() const -{ - return ui->garageAccountLineEdit->text().trimmed(); -} - -QString MaemoPublishingUploadSettingsPageFremantleFree::privateKeyFilePath() const -{ - return ui->privateKeyPathChooser->path(); -} - -QString MaemoPublishingUploadSettingsPageFremantleFree::serverName() const -{ - return ui->serverAddressLineEdit->text().trimmed(); -} - -QString MaemoPublishingUploadSettingsPageFremantleFree::directoryOnServer() const -{ - return ui->targetDirectoryOnServerLineEdit->text().trimmed(); -} - -bool MaemoPublishingUploadSettingsPageFremantleFree::validatePage() -{ - m_publisher->setSshParams(serverName(), garageAccountName(), - privateKeyFilePath(), directoryOnServer()); - return true; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.h b/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.h deleted file mode 100644 index 5ffee819b59..00000000000 --- a/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.h +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMOPUBLISHINGUPLOADSETTINGSWIZARDPAGE_H -#define MAEMOPUBLISHINGUPLOADSETTINGSWIZARDPAGE_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { - class MaemoPublishingUploadSettingsPageFremantleFree; -} -QT_END_NAMESPACE - -namespace RemoteLinux { -namespace Internal { -class MaemoPublisherFremantleFree; - -class MaemoPublishingUploadSettingsPageFremantleFree : public QWizardPage -{ - Q_OBJECT - -public: - explicit MaemoPublishingUploadSettingsPageFremantleFree(MaemoPublisherFremantleFree *publisher, - QWidget *parent = 0); - ~MaemoPublishingUploadSettingsPageFremantleFree(); - -private: - virtual void initializePage(); - virtual bool isComplete() const; - virtual bool validatePage(); - - QString garageAccountName() const; - QString privateKeyFilePath() const; - QString serverName() const; - QString directoryOnServer() const; - - MaemoPublisherFremantleFree * const m_publisher; - Ui::MaemoPublishingUploadSettingsPageFremantleFree *ui; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPUBLISHINGUPLOADSETTINGSWIZARDPAGE_H diff --git a/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.ui b/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.ui deleted file mode 100644 index 48064654d37..00000000000 --- a/src/plugins/remotelinux/maemopublishinguploadsettingspagefremantlefree.ui +++ /dev/null @@ -1,95 +0,0 @@ - - - MaemoPublishingUploadSettingsPageFremantleFree - - - - 0 - 0 - 636 - 128 - - - - WizardPage - - - Upload Settings - - - - - - Garage account name: - - - - - - - - - - - - <a href="https://garage.maemo.org/account/register.php">Get an account</a> - - - true - - - - - - - <a href="https://garage.maemo.org/extras-assistant/index.php">Request upload rights</a> - - - true - - - - - - - - - Private key file: - - - - - - - - - - Server address: - - - - - - - - - - Target directory on server: - - - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
-
-
- - -
diff --git a/src/plugins/remotelinux/maemopublishingwizardfactories.cpp b/src/plugins/remotelinux/maemopublishingwizardfactories.cpp deleted file mode 100644 index 991a3c6e89a..00000000000 --- a/src/plugins/remotelinux/maemopublishingwizardfactories.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemopublishingwizardfactories.h" - -#include "maemoconstants.h" -#include "maemoglobal.h" -#include "maemopublishingwizardfremantlefree.h" - -#include -#include -#include -#include -#include -#include - -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -MaemoPublishingWizardFactoryFremantleFree::MaemoPublishingWizardFactoryFremantleFree(QObject *parent) - : IPublishingWizardFactory(parent) -{ -} - -QString MaemoPublishingWizardFactoryFremantleFree::displayName() const -{ - return tr("Publish for \"Fremantle Extras-devel free\" repository"); -} - -QString MaemoPublishingWizardFactoryFremantleFree::description() const -{ - return tr("This wizard will create a source archive and optionally upload " - "it to a build server, where the project will be compiled and " - "packaged and then moved to the \"Extras-devel free\" " - "repository, from where users can install it onto their N900 " - "devices. For the upload functionality, an account at " - "garage.maemo.org is required."); -} - -bool MaemoPublishingWizardFactoryFremantleFree::canCreateWizard(const Project *project) const -{ - if (!qobject_cast(project)) - return false; - foreach (const Target *const target, project->targets()) { - if (target->id() != QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)) - continue; - foreach (const BuildConfiguration *const bc, target->buildConfigurations()) { - const Qt4BuildConfiguration *const qt4Bc - = qobject_cast(bc); - if (!qt4Bc) - continue; - - QtSupport::BaseQtVersion *qt = qt4Bc->qtVersion(); - if (!qt) - continue; - if (MaemoGlobal::osType(qt->qmakeCommand()) == QLatin1String(Maemo5OsType)) - return true; - } - break; - } - return false; -} - -QWizard *MaemoPublishingWizardFactoryFremantleFree::createWizard(const Project *project) const -{ - Q_ASSERT(canCreateWizard(project)); - return new MaemoPublishingWizardFremantleFree(project); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopublishingwizardfactories.h b/src/plugins/remotelinux/maemopublishingwizardfactories.h deleted file mode 100644 index 1b56bf2cf2d..00000000000 --- a/src/plugins/remotelinux/maemopublishingwizardfactories.h +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMOPUBLISHINGSERVICE_H -#define MAEMOPUBLISHINGSERVICE_H - -#include - -namespace Core { -class SshRemoteProcessRunner; -} - -namespace RemoteLinux { -namespace Internal { - -class MaemoPublishingWizardFactoryFremantleFree - : public ProjectExplorer::IPublishingWizardFactory -{ - Q_OBJECT -public: - explicit MaemoPublishingWizardFactoryFremantleFree(QObject *parent =0); -private: - virtual QString displayName() const; - virtual QString description() const; - virtual bool canCreateWizard(const ProjectExplorer::Project *project) const; - virtual QWizard *createWizard(const ProjectExplorer::Project *project) const; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPUBLISHINGSERVICE_H diff --git a/src/plugins/remotelinux/maemopublishingwizardfremantlefree.cpp b/src/plugins/remotelinux/maemopublishingwizardfremantlefree.cpp deleted file mode 100644 index 7330ae06e48..00000000000 --- a/src/plugins/remotelinux/maemopublishingwizardfremantlefree.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemopublishingwizardfremantlefree.h" - -#include "maemopublishingresultpagefremantlefree.h" -#include "maemopublisherfremantlefree.h" -#include "maemopublishinguploadsettingspagefremantlefree.h" -#include "maemopublishingbuildsettingspagefremantlefree.h" - -using namespace ProjectExplorer; - -namespace RemoteLinux { -namespace Internal { -namespace { -enum PageId { BuildSettingsPageId, UploadSettingsPageId, ResultPageId }; -} // anonymous namespace - -MaemoPublishingWizardFremantleFree::MaemoPublishingWizardFremantleFree(const Project *project, - QWidget *parent) : - Wizard(parent), - m_project(project), - m_publisher(new MaemoPublisherFremantleFree(project, this)) -{ - setOption(NoCancelButton, false); - setWindowTitle(tr("Publishing to Fremantle's \"Extras-devel free\" Repository")); - - m_buildSettingsPage - = new MaemoPublishingBuildSettingsPageFremantleFree(project, m_publisher); - m_buildSettingsPage->setTitle(tr("Build Settings")); - setPage(BuildSettingsPageId, m_buildSettingsPage); - - m_uploadSettingsPage - = new MaemoPublishingUploadSettingsPageFremantleFree(m_publisher); - m_uploadSettingsPage->setTitle(tr("Upload Settings")); - m_uploadSettingsPage->setCommitPage(true); - setPage(UploadSettingsPageId, m_uploadSettingsPage); - - m_resultPage = new MaemoPublishingResultPageFremantleFree(m_publisher); - m_resultPage->setTitle(tr("Result")); - setPage(ResultPageId, m_resultPage); -} - -int MaemoPublishingWizardFremantleFree::nextId() const -{ - if (currentPage()->isCommitPage()) - return ResultPageId; - return QWizard::nextId(); -} - - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemopublishingwizardfremantlefree.h b/src/plugins/remotelinux/maemopublishingwizardfremantlefree.h deleted file mode 100644 index 03f6f33a454..00000000000 --- a/src/plugins/remotelinux/maemopublishingwizardfremantlefree.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOPUBLISHINGWIZARDFREMANTLEFREE_H -#define MAEMOPUBLISHINGWIZARDFREMANTLEFREE_H - -#include - -namespace ProjectExplorer { -class Project; -} - -namespace RemoteLinux { -namespace Internal { -class MaemoPublishingResultPageFremantleFree; -class MaemoPublisherFremantleFree; -class MaemoPublishingUploadSettingsPageFremantleFree; -class MaemoPublishingBuildSettingsPageFremantleFree; - -class MaemoPublishingWizardFremantleFree : public Utils::Wizard -{ - Q_OBJECT -public: - explicit MaemoPublishingWizardFremantleFree(const ProjectExplorer::Project *project, - QWidget *parent = 0); - -private: - virtual int nextId() const; - - const ProjectExplorer::Project * const m_project; - MaemoPublisherFremantleFree * const m_publisher; - MaemoPublishingBuildSettingsPageFremantleFree *m_buildSettingsPage; - MaemoPublishingUploadSettingsPageFremantleFree *m_uploadSettingsPage; - MaemoPublishingResultPageFremantleFree *m_resultPage; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOPUBLISHINGWIZARDFREMANTLEFREE_H diff --git a/src/plugins/remotelinux/maemoqemumanager.cpp b/src/plugins/remotelinux/maemoqemumanager.cpp deleted file mode 100644 index 18791c22026..00000000000 --- a/src/plugins/remotelinux/maemoqemumanager.cpp +++ /dev/null @@ -1,623 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemoqemumanager.h" - -#include "maemoglobal.h" -#include "maemoqemuruntimeparser.h" -#include "maemosettingspages.h" -#include "remotelinuxrunconfiguration.h" -#include "qt4maemotarget.h" -#include "maemoqtversion.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; -using namespace RemoteLinux; -using namespace RemoteLinux::Internal; - -MaemoQemuManager *MaemoQemuManager::m_instance = 0; - -const QSize iconSize = QSize(24, 20); - -MaemoQemuManager::MaemoQemuManager(QObject *parent) - : QObject(parent) - , m_qemuAction(0) - , m_qemuProcess(new QProcess(this)) - , m_runningQtId(INT_MIN) - , m_userTerminated(false) - , m_runtimeRootWatcher(0) - , m_runtimeFolderWatcher(0) -{ - m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-run.png", iconSize); - m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-stop.png", iconSize, - QIcon::Normal, QIcon::On); - - m_qemuAction = new QAction("MeeGo Emulator", this); - m_qemuAction->setIcon(m_qemuStarterIcon.pixmap(iconSize)); - m_qemuAction->setToolTip(tr("Start MeeGo Emulator")); - connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime())); - - Core::ICore *core = Core::ICore::instance(); - Core::ActionManager *actionManager = core->actionManager(); - Core::Command *qemuCommand = actionManager->registerAction(m_qemuAction, - "MaemoEmulator", Core::Context(Core::Constants::C_GLOBAL)); - qemuCommand->setAttribute(Core::Command::CA_UpdateText); - qemuCommand->setAttribute(Core::Command::CA_UpdateIcon); - - Core::ModeManager::instance()->addAction(qemuCommand->action(), 1); - m_qemuAction->setEnabled(false); - m_qemuAction->setVisible(false); - - // listen to qt version changes to update the start button - connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList)), - this, SLOT(qtVersionsChanged(QList))); - - // listen to project add, remove and startup changes to udate start button - SessionManager *session = ProjectExplorerPlugin::instance()->session(); - connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)), this, - SLOT(projectAdded(ProjectExplorer::Project*))); - connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, - SLOT(projectRemoved(ProjectExplorer::Project*))); - connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), - this, SLOT(projectChanged(ProjectExplorer::Project*))); - - connect(m_qemuProcess, SIGNAL(error(QProcess::ProcessError)), this, - SLOT(qemuProcessError(QProcess::ProcessError))); - connect(m_qemuProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, - SLOT(qemuProcessFinished())); - connect(m_qemuProcess, SIGNAL(readyReadStandardOutput()), this, - SLOT(qemuOutput())); - connect(m_qemuProcess, SIGNAL(readyReadStandardError()), this, - SLOT(qemuOutput())); - connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)), - this, SLOT(qemuStatusChanged(QemuStatus, QString))); -} - -Utils::FileSystemWatcher *MaemoQemuManager::runtimeRootWatcher() -{ - if (!m_runtimeRootWatcher) { - m_runtimeRootWatcher = new Utils::FileSystemWatcher(this); - m_runtimeRootWatcher->setObjectName(QLatin1String("MaemoQemuRuntimeRootWatcher")); - connect(m_runtimeRootWatcher, SIGNAL(directoryChanged(QString)), this, - SLOT(runtimeRootChanged(QString))); - } - return m_runtimeRootWatcher; -} - -Utils::FileSystemWatcher *MaemoQemuManager::runtimeFolderWatcher() -{ - if (!m_runtimeFolderWatcher) { - m_runtimeFolderWatcher = new Utils::FileSystemWatcher(this); - m_runtimeFolderWatcher->setObjectName(QLatin1String("MaemoQemuRuntimeFolderWatcher")); - connect(m_runtimeFolderWatcher, SIGNAL(directoryChanged(QString)), this, - SLOT(runtimeFolderChanged(QString))); - } - return m_runtimeFolderWatcher; -} - -MaemoQemuManager::~MaemoQemuManager() -{ - terminateRuntime(); - m_instance = 0; -} - -MaemoQemuManager &MaemoQemuManager::instance(QObject *parent) -{ - if (m_instance == 0) - m_instance = new MaemoQemuManager(parent); - return *m_instance; -} - -bool MaemoQemuManager::runtimeForQtVersion(int uniqueId, MaemoQemuRuntime *rt) const -{ - *rt = m_runtimes.value(uniqueId, MaemoQemuRuntime()); - return rt->isValid(); -} - -bool MaemoQemuManager::qemuIsRunning() const -{ - return m_runningQtId != INT_MIN; -} - -void MaemoQemuManager::qtVersionsChanged(const QList &uniqueIds) -{ - QtSupport::QtVersionManager *manager = QtSupport::QtVersionManager::instance(); - foreach (int uniqueId, uniqueIds) { - if (manager->isValidId(uniqueId)) { - MaemoQtVersion *version = dynamic_cast(manager->version(uniqueId)); - - if (version) { - MaemoQemuRuntime runtime - = MaemoQemuRuntimeParser::parseRuntime(version); - if (runtime.isValid()) { - m_runtimes.insert(uniqueId, runtime); - if (!runtimeRootWatcher()->watchesDirectory(runtime.m_watchPath)) - runtimeRootWatcher()->addDirectory(runtime.m_watchPath, - Utils::FileSystemWatcher::WatchAllChanges); - } else { - m_runtimes.remove(uniqueId); - } - } - } else { - // this qt version has been removed from the settings - m_runtimes.remove(uniqueId); - if (uniqueId == m_runningQtId) { - terminateRuntime(); - emit qemuProcessStatus(QemuUserReason, tr("Qemu has been shut " - "down, because you removed the corresponding Qt version.")); - } - } - } - - showOrHideQemuButton(); -} - -void MaemoQemuManager::projectAdded(ProjectExplorer::Project *project) -{ - // handle all target related changes, add, remove, etc... - connect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this, - SLOT(targetAdded(ProjectExplorer::Target*))); - connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this, - SLOT(targetRemoved(ProjectExplorer::Target*))); - connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), - this, SLOT(targetChanged(ProjectExplorer::Target*))); - - foreach (Target *target, project->targets()) - targetAdded(target); -} - -void MaemoQemuManager::projectRemoved(ProjectExplorer::Project *project) -{ - disconnect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this, - SLOT(targetAdded(ProjectExplorer::Target*))); - disconnect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this, - SLOT(targetRemoved(ProjectExplorer::Target*))); - disconnect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), - this, SLOT(targetChanged(ProjectExplorer::Target*))); - - foreach (Target *target, project->targets()) - targetRemoved(target); - showOrHideQemuButton(); -} - -void MaemoQemuManager::projectChanged(ProjectExplorer::Project *project) -{ - if (project) { - toggleStarterButton(project->activeTarget()); - deviceConfigurationChanged(project->activeTarget()); - } -} - -void MaemoQemuManager::targetAdded(ProjectExplorer::Target *target) -{ - if (!target || !MaemoGlobal::isMaemoTargetId(target->id())) - return; - - // handle all run configuration changes, add, remove, etc... - connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)), - this, SLOT(runConfigurationAdded(ProjectExplorer::RunConfiguration*))); - connect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)), - this, SLOT(runConfigurationRemoved(ProjectExplorer::RunConfiguration*))); - connect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), - this, SLOT(runConfigurationChanged(ProjectExplorer::RunConfiguration*))); - - // handle all build configuration changes, add, remove, etc... - connect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)), - this, SLOT(buildConfigurationAdded(ProjectExplorer::BuildConfiguration*))); - connect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)), - this, SLOT(buildConfigurationRemoved(ProjectExplorer::BuildConfiguration*))); - connect(target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), - this, SLOT(buildConfigurationChanged(ProjectExplorer::BuildConfiguration*))); - - // handle the qt version changes the build configuration uses - connect(target, SIGNAL(environmentChanged()), this, SLOT(environmentChanged())); - - foreach (RunConfiguration *rc, target->runConfigurations()) - toggleDeviceConnections(qobject_cast (rc), true); - toggleStarterButton(target); -} - -void MaemoQemuManager::targetRemoved(ProjectExplorer::Target *target) -{ - if (!target || !MaemoGlobal::isMaemoTargetId(target->id())) - return; - - disconnect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)), - this, SLOT(runConfigurationAdded(ProjectExplorer::RunConfiguration*))); - disconnect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)), - this, SLOT(runConfigurationRemoved(ProjectExplorer::RunConfiguration*))); - disconnect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), - this, SLOT(runConfigurationChanged(ProjectExplorer::RunConfiguration*))); - - disconnect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)), - this, SLOT(buildConfigurationAdded(ProjectExplorer::BuildConfiguration*))); - disconnect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)), - this, SLOT(buildConfigurationRemoved(ProjectExplorer::BuildConfiguration*))); - disconnect(target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), - this, SLOT(buildConfigurationChanged(ProjectExplorer::BuildConfiguration*))); - - disconnect(target, SIGNAL(environmentChanged()), this, SLOT(environmentChanged())); - - foreach (RunConfiguration *rc, target->runConfigurations()) - toggleDeviceConnections(qobject_cast (rc), false); - showOrHideQemuButton(); -} - -void MaemoQemuManager::targetChanged(ProjectExplorer::Target *target) -{ - if (target) { - toggleStarterButton(target); - deviceConfigurationChanged(target); - } -} - -void MaemoQemuManager::runConfigurationAdded(ProjectExplorer::RunConfiguration *rc) -{ - if (!rc || !MaemoGlobal::isMaemoTargetId(rc->target()->id())) - return; - toggleDeviceConnections(qobject_cast (rc), true); -} - -void MaemoQemuManager::runConfigurationRemoved(ProjectExplorer::RunConfiguration *rc) -{ - if (!rc || !MaemoGlobal::isMaemoTargetId(rc->target()->id())) - return; - toggleDeviceConnections(qobject_cast (rc), false); -} - -void MaemoQemuManager::runConfigurationChanged(ProjectExplorer::RunConfiguration *rc) -{ - if (rc) - m_qemuAction->setEnabled(targetUsesMatchingRuntimeConfig(rc->target())); -} - -void MaemoQemuManager::buildConfigurationAdded(ProjectExplorer::BuildConfiguration *bc) -{ - if (!bc || !MaemoGlobal::isMaemoTargetId(bc->target()->id())) - return; - - connect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentChanged())); -} - -void MaemoQemuManager::buildConfigurationRemoved(ProjectExplorer::BuildConfiguration *bc) -{ - if (!bc || !MaemoGlobal::isMaemoTargetId(bc->target()->id())) - return; - - disconnect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentChanged())); -} - -void MaemoQemuManager::buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc) -{ - if (bc) - toggleStarterButton(bc->target()); -} - -void MaemoQemuManager::environmentChanged() -{ - // likely to happen when the qt version changes the build config is using - if (ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance()) { - if (Project *project = explorer->session()->startupProject()) - toggleStarterButton(project->activeTarget()); - } -} - -void MaemoQemuManager::deviceConfigurationChanged(ProjectExplorer::Target *target) -{ - m_qemuAction->setEnabled(targetUsesMatchingRuntimeConfig(target)); -} - -void MaemoQemuManager::startRuntime() -{ - m_userTerminated = false; - Project *p = ProjectExplorerPlugin::instance()->session()->startupProject(); - if (!p) - return; - QtSupport::BaseQtVersion *version; - if (!targetUsesMatchingRuntimeConfig(p->activeTarget(), &version)) { - qWarning("Strange: Qemu button was enabled, but target does not match."); - return; - } - - m_runningQtId = version->uniqueId(); - const MaemoQemuRuntime rt = m_runtimes.value(version->uniqueId()); - m_qemuProcess->setProcessEnvironment(rt.environment()); - m_qemuProcess->setWorkingDirectory(rt.m_root); - m_qemuProcess->start(rt.m_bin % QLatin1Char(' ') % rt.m_args); - if (!m_qemuProcess->waitForStarted()) - return; - - emit qemuProcessStatus(QemuStarting); - connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(terminateRuntime())); - disconnect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime())); -} - -void MaemoQemuManager::terminateRuntime() -{ - m_userTerminated = true; - - if (m_qemuProcess->state() != QProcess::NotRunning) { - m_qemuProcess->terminate(); - m_qemuProcess->kill(); - } - - connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime())); - disconnect(m_qemuAction, SIGNAL(triggered()), this, SLOT(terminateRuntime())); -} - -void MaemoQemuManager::qemuProcessFinished() -{ - m_runningQtId = INT_MIN; - QemuStatus status = QemuFinished; - QString error; - - if (!m_userTerminated) { - if (m_qemuProcess->exitStatus() == QProcess::CrashExit) { - status = QemuCrashed; - error = m_qemuProcess->errorString(); - } else if (m_qemuProcess->exitCode() != 0) { - error = tr("Qemu finished with error: Exit code was %1.") - .arg(m_qemuProcess->exitCode()); - } - } - - m_userTerminated = false; - emit qemuProcessStatus(status, error); -} - -void MaemoQemuManager::qemuProcessError(QProcess::ProcessError error) -{ - if (error == QProcess::FailedToStart) - emit qemuProcessStatus(QemuFailedToStart, m_qemuProcess->errorString()); -} - -void MaemoQemuManager::qemuStatusChanged(QemuStatus status, const QString &error) -{ - bool running = false; - switch (status) { - case QemuStarting: - running = true; - break; - case QemuFailedToStart: - QMessageBox::warning(0, tr("Qemu error"), - tr("Qemu failed to start: %1")); - break; - case QemuCrashed: - MaemoQemuSettingsPage::showQemuCrashDialog(); - break; - case QemuFinished: - case QemuUserReason: - if (!error.isEmpty()) - QMessageBox::warning(0, tr("Qemu error"), error); - break; - default: - Q_ASSERT(!"Missing handling of Qemu status"); - } - - updateStarterIcon(running); -} - -void MaemoQemuManager::qemuOutput() -{ - qDebug("%s", m_qemuProcess->readAllStandardOutput().data()); - qDebug("%s", m_qemuProcess->readAllStandardError().data()); -} - -void MaemoQemuManager::runtimeRootChanged(const QString &directory) -{ - QList uniqueIds; - QMap::const_iterator it; - for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) { - if (QDir(it.value().m_watchPath) == QDir(directory)) - uniqueIds.append(it.key()); - } - - foreach (int uniqueId, uniqueIds) { - MaemoQemuRuntime runtime = m_runtimes.value(uniqueId, MaemoQemuRuntime()); - if (runtime.isValid()) { - if (QFile::exists(runtime.m_root)) { - // nothing changed, so we can remove it - uniqueIds.removeAll(uniqueId); - } - } else { - if (QFile::exists(runtime.m_root)) { - if (!QFile::exists(runtime.m_root + QLatin1String("/information"))) { - // install might be still in progress - uniqueIds.removeAll(uniqueId); - runtimeFolderWatcher()->addDirectory(runtime.m_root, - Utils::FileSystemWatcher::WatchAllChanges); - } - } - } - } - notify(uniqueIds); -} - -void MaemoQemuManager::runtimeFolderChanged(const QString &directory) -{ - if (QFile::exists(directory + QLatin1String("/information"))) { - QList uniqueIds; - QMap::const_iterator it; - for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) { - if (QDir(it.value().m_root) == QDir(directory)) - uniqueIds.append(it.key()); - } - notify(uniqueIds); - if (m_runtimeFolderWatcher) - m_runtimeFolderWatcher->removeDirectory(directory); - } -} - -// -- private - -void MaemoQemuManager::updateStarterIcon(bool running) -{ - QIcon::State state; - QString toolTip; - if (running) { - state = QIcon::On; - toolTip = tr("Stop MeeGo Emulator"); - } else { - state = QIcon::Off; - toolTip = tr("Start MeeGo Emulator"); - } - - m_qemuAction->setToolTip(toolTip); - m_qemuAction->setIcon(m_qemuStarterIcon.pixmap(iconSize, QIcon::Normal, - state)); -} - -void MaemoQemuManager::toggleStarterButton(Target *target) -{ - int uniqueId = -1; - if (target) { - if (AbstractQt4MaemoTarget *qt4Target = qobject_cast(target)) { - if (Qt4BuildConfiguration *bc = qt4Target->activeQt4BuildConfiguration()) { - if (QtSupport::BaseQtVersion *version = bc->qtVersion()) - uniqueId = version->uniqueId(); - } - } - } - - if (uniqueId >= 0 && (m_runtimes.isEmpty() || !m_runtimes.contains(uniqueId))) - qtVersionsChanged(QList() << uniqueId); - - bool isRunning = m_qemuProcess->state() != QProcess::NotRunning; - if (m_runningQtId == uniqueId) - isRunning = false; - - const Project * const p - = ProjectExplorerPlugin::instance()->session()->startupProject(); - const bool qemuButtonEnabled - = p && p->activeTarget() && MaemoGlobal::isMaemoTargetId(p->activeTarget()->id()) - && m_runtimes.value(uniqueId, MaemoQemuRuntime()).isValid() - && targetUsesMatchingRuntimeConfig(target) && !isRunning; - m_qemuAction->setEnabled(qemuButtonEnabled); - showOrHideQemuButton(); -} - -bool MaemoQemuManager::sessionHasMaemoTarget() const -{ - ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance(); - const QList &projects = explorer->session()->projects(); - foreach (const Project *p, projects) { - foreach (const Target * const target, p->targets()) { - if (MaemoGlobal::isMaemoTargetId(target->id())) - return true; - } - } - return false; -} - -bool MaemoQemuManager::targetUsesMatchingRuntimeConfig(Target *target, - QtSupport::BaseQtVersion **qtVersion) -{ - if (!target) - return false; - if (target != target->project()->activeTarget()) - return false; - - RemoteLinuxRunConfiguration *mrc = - qobject_cast (target->activeRunConfiguration()); - if (!mrc) - return false; - Qt4BuildConfiguration *bc - = qobject_cast(target->activeBuildConfiguration()); - if (!bc) - return false; - QtSupport::BaseQtVersion *version = bc->qtVersion(); - if (!version || !m_runtimes.value(version->uniqueId(), MaemoQemuRuntime()).isValid()) - return false; - - if (qtVersion) - *qtVersion = version; - const LinuxDeviceConfiguration::ConstPtr &config = mrc->deviceConfig(); - return config && config->deviceType() == LinuxDeviceConfiguration::Emulator; -} - -void MaemoQemuManager::notify(const QList uniqueIds) -{ - qtVersionsChanged(uniqueIds); - environmentChanged(); // to toggle the start button -} - -void MaemoQemuManager::toggleDeviceConnections(RemoteLinuxRunConfiguration *mrc, - bool _connect) -{ - if (!mrc) - return; - - if (_connect) { // handle device configuration changes - connect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)), - this, SLOT(deviceConfigurationChanged(ProjectExplorer::Target*))); - } else { - disconnect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)), - this, SLOT(deviceConfigurationChanged(ProjectExplorer::Target*))); - } -} - -void MaemoQemuManager::showOrHideQemuButton() -{ - const bool showButton = !m_runtimes.isEmpty() && sessionHasMaemoTarget(); - if (!showButton) - terminateRuntime(); - m_qemuAction->setVisible(showButton); -} diff --git a/src/plugins/remotelinux/maemoqemumanager.h b/src/plugins/remotelinux/maemoqemumanager.h deleted file mode 100644 index 91c6c5cb5c7..00000000000 --- a/src/plugins/remotelinux/maemoqemumanager.h +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef QEMURUNTIMEMANAGER_H -#define QEMURUNTIMEMANAGER_H - -#include "maemoconstants.h" -#include "maemoqemuruntime.h" - -#include -#include -#include - -#include - -QT_FORWARD_DECLARE_CLASS(QAction) -QT_FORWARD_DECLARE_CLASS(QStringList) - -namespace Utils { -class FileSystemWatcher; -} - -namespace ProjectExplorer { - class BuildConfiguration; - class Project; - class RunConfiguration; - class Target; -} - -namespace QtSupport { -class BaseQtVersion; -} - -namespace RemoteLinux { -class RemoteLinuxRunConfiguration; - -namespace Internal { - -class MaemoQemuManager : public QObject -{ - Q_OBJECT - -public: - static MaemoQemuManager& instance(QObject *parent = 0); - - bool runtimeForQtVersion(int uniqueId, MaemoQemuRuntime *rt) const; - bool qemuIsRunning() const; - Q_SLOT void startRuntime(); - -signals: - void qemuProcessStatus(QemuStatus, const QString &error = QString()); - -private slots: - void qtVersionsChanged(const QList &uniqueIds); - - void projectAdded(ProjectExplorer::Project *project); - void projectRemoved(ProjectExplorer::Project *project); - void projectChanged(ProjectExplorer::Project *project); - - void targetAdded(ProjectExplorer::Target *target); - void targetRemoved(ProjectExplorer::Target *target); - void targetChanged(ProjectExplorer::Target *target); - - void runConfigurationAdded(ProjectExplorer::RunConfiguration *rc); - void runConfigurationRemoved(ProjectExplorer::RunConfiguration *rc); - void runConfigurationChanged(ProjectExplorer::RunConfiguration *rc); - - void buildConfigurationAdded(ProjectExplorer::BuildConfiguration *bc); - void buildConfigurationRemoved(ProjectExplorer::BuildConfiguration *bc); - void buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc); - - void environmentChanged(); // needed to check for qt version - void deviceConfigurationChanged(ProjectExplorer::Target *target); - - void terminateRuntime(); - - void qemuProcessFinished(); - void qemuProcessError(QProcess::ProcessError error); - void qemuStatusChanged(QemuStatus status, const QString &error); - void qemuOutput(); - - void runtimeRootChanged(const QString &directory); - void runtimeFolderChanged(const QString &directory); - -private: - MaemoQemuManager(QObject *parent); - ~MaemoQemuManager(); - - bool sessionHasMaemoTarget() const; - - void updateStarterIcon(bool running); - void toggleStarterButton(ProjectExplorer::Target *target); - bool targetUsesMatchingRuntimeConfig(ProjectExplorer::Target *target, - QtSupport::BaseQtVersion **qtVersion = 0); - - void notify(const QList uniqueIds); - void toggleDeviceConnections(RemoteLinuxRunConfiguration *mrc, bool connect); - void showOrHideQemuButton(); - -private: - QAction *m_qemuAction; - QProcess *m_qemuProcess; - Utils::FileSystemWatcher *runtimeRootWatcher(); - Utils::FileSystemWatcher *runtimeFolderWatcher(); - - int m_runningQtId; - bool m_userTerminated; - QIcon m_qemuStarterIcon; - QMap m_runtimes; - static MaemoQemuManager *m_instance; - Utils::FileSystemWatcher *m_runtimeRootWatcher; - Utils::FileSystemWatcher *m_runtimeFolderWatcher; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // QEMURUNTIMEMANAGER_H diff --git a/src/plugins/remotelinux/maemoqemuruntime.h b/src/plugins/remotelinux/maemoqemuruntime.h deleted file mode 100644 index ce9088af03d..00000000000 --- a/src/plugins/remotelinux/maemoqemuruntime.h +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMOQEMURUNTIME_H -#define MAEMOQEMURUNTIME_H - -#include "maemoqemusettings.h" - -#include - -#include -#include -#include -#include -#include - -namespace RemoteLinux { -namespace Internal { - -enum QemuStatus { - QemuStarting, - QemuFailedToStart, - QemuFinished, - QemuCrashed, - QemuUserReason -}; - -struct MaemoQemuRuntime -{ - typedef QPair Variable; - - MaemoQemuRuntime() {} - MaemoQemuRuntime(const QString &root) : m_root(root) {} - bool isValid() const { - return !m_bin.isEmpty(); - } - QProcessEnvironment environment() const { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - foreach (const Variable &var, m_normalVars) - env.insert(var.first, var.second); - QHash::ConstIterator it - = m_openGlBackendVarValues.find(MaemoQemuSettings::openGlMode()); - if (it != m_openGlBackendVarValues.constEnd()) - env.insert(m_openGlBackendVarName, it.value()); - return env; - } - - QString m_name; - QString m_bin; - QString m_root; - QString m_args; - QString m_sshPort; - QString m_watchPath; - PortList m_freePorts; - QList m_normalVars; - QString m_openGlBackendVarName; - QHash m_openGlBackendVarValues; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOQEMURUNTIME_H diff --git a/src/plugins/remotelinux/maemoqemuruntimeparser.cpp b/src/plugins/remotelinux/maemoqemuruntimeparser.cpp deleted file mode 100644 index ff9c7c8c8d9..00000000000 --- a/src/plugins/remotelinux/maemoqemuruntimeparser.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemoqemuruntimeparser.h" - -#include "maemoglobal.h" -#include "maemoqemusettings.h" - -#include -#include - -#include -#include -#include -#include - -namespace RemoteLinux { -namespace Internal { - -class MaemoQemuRuntimeParserV1 : public MaemoQemuRuntimeParser -{ -public: - MaemoQemuRuntimeParserV1(const QString &madInfoOutput, - const QString &targetName, const QString &maddeRoot); - MaemoQemuRuntime parseRuntime(); - -private: - void fillRuntimeInformation(MaemoQemuRuntime *runtime) const; - void setEnvironment(MaemoQemuRuntime *runTime, const QString &envSpec) const; -}; - -class MaemoQemuRuntimeParserV2 : public MaemoQemuRuntimeParser -{ -public: - MaemoQemuRuntimeParserV2(const QString &madInfoOutput, - const QString &targetName, const QString &maddeRoot); - MaemoQemuRuntime parseRuntime(); - -private: - struct Port { - Port() : port(-1), ssh(false) {} - int port; - bool ssh; - }; - - void handleTargetTag(QString &runtimeName); - MaemoQemuRuntime handleRuntimeTag(); - void handleEnvironmentTag(MaemoQemuRuntime &runtime); - void handleVariableTag(MaemoQemuRuntime &runtime); - QList handleTcpPortListTag(); - Port handlePortTag(); - MaemoQemuSettings::OpenGlMode openGlTagToEnum(const QString &tag) const; -}; - -MaemoQemuRuntimeParser::MaemoQemuRuntimeParser(const QString &madInfoOutput, - const QString &targetName, const QString &maddeRoot) - : m_targetName(targetName), - m_maddeRoot(maddeRoot), - m_madInfoReader(madInfoOutput) -{ -} - -MaemoQemuRuntime MaemoQemuRuntimeParser::parseRuntime(const QtSupport::BaseQtVersion *qtVersion) -{ - MaemoQemuRuntime runtime; - const QString maddeRootPath = MaemoGlobal::maddeRoot(qtVersion->qmakeCommand()); - QProcess madProc; - if (!MaemoGlobal::callMad(madProc, QStringList() << QLatin1String("info"), qtVersion->qmakeCommand(), false)) - return runtime; - if (!madProc.waitForStarted() || !madProc.waitForFinished()) - return runtime; - const QByteArray &madInfoOutput = madProc.readAllStandardOutput(); - const QString &targetName = MaemoGlobal::targetName(qtVersion->qmakeCommand()); - runtime = MaemoQemuRuntimeParserV2(madInfoOutput, targetName, maddeRootPath) - .parseRuntime(); - if (!runtime.m_name.isEmpty()) { - runtime.m_root = maddeRootPath + QLatin1String("/runtimes/") - + runtime.m_name; - } else { - runtime = MaemoQemuRuntimeParserV1(madInfoOutput, targetName, - maddeRootPath).parseRuntime(); - } - runtime.m_watchPath = runtime.m_root - .left(runtime.m_root.lastIndexOf(QLatin1Char('/'))); - - return runtime; -} - -MaemoQemuRuntimeParserV1::MaemoQemuRuntimeParserV1(const QString &madInfoOutput, - const QString &targetName, const QString &maddeRoot) - : MaemoQemuRuntimeParser(madInfoOutput, targetName, maddeRoot) -{ -} - -MaemoQemuRuntime MaemoQemuRuntimeParserV1::parseRuntime() -{ - QStringList installedRuntimes; - QString targetRuntime; - while (!m_madInfoReader.atEnd() && !installedRuntimes.contains(targetRuntime)) { - if (m_madInfoReader.readNext() == QXmlStreamReader::StartElement) { - if (targetRuntime.isEmpty() - && m_madInfoReader.name() == QLatin1String("target")) { - const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); - if (attrs.value(QLatin1String("target_id")) == m_targetName) - targetRuntime = attrs.value("runtime_id").toString(); - } else if (m_madInfoReader.name() == QLatin1String("runtime")) { - const QXmlStreamAttributes attrs = m_madInfoReader.attributes(); - while (!m_madInfoReader.atEnd()) { - if (m_madInfoReader.readNext() == QXmlStreamReader::EndElement - && m_madInfoReader.name() == QLatin1String("runtime")) - break; - if (m_madInfoReader.tokenType() == QXmlStreamReader::StartElement - && m_madInfoReader.name() == QLatin1String("installed")) { - if (m_madInfoReader.readNext() == QXmlStreamReader::Characters - && m_madInfoReader.text() == QLatin1String("true")) { - if (attrs.hasAttribute(QLatin1String("runtime_id"))) - installedRuntimes << attrs.value(QLatin1String("runtime_id")).toString(); - else if (attrs.hasAttribute(QLatin1String("id"))) { - // older MADDE seems to use only id - installedRuntimes << attrs.value(QLatin1String("id")).toString(); - } - } - break; - } - } - } - } - } - - MaemoQemuRuntime runtime; - if (installedRuntimes.contains(targetRuntime)) { - runtime.m_name = targetRuntime; - runtime.m_root = m_maddeRoot + QLatin1String("/runtimes/") - + targetRuntime; - fillRuntimeInformation(&runtime); - } - return runtime; - -} - -void MaemoQemuRuntimeParserV1::fillRuntimeInformation(MaemoQemuRuntime *runtime) const -{ - const QStringList files = QDir(runtime->m_root).entryList(QDir::Files - | QDir::NoSymLinks | QDir::NoDotAndDotDot); - - const QLatin1String infoFile("information"); - if (files.contains(infoFile)) { - QFile file(runtime->m_root + QLatin1Char('/') + infoFile); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QMap map; - QTextStream stream(&file); - while (!stream.atEnd()) { - const QString &line = stream.readLine().trimmed(); - const int index = line.indexOf(QLatin1Char('=')); - map.insert(line.mid(0, index).remove(QLatin1Char('\'')), - line.mid(index + 1).remove(QLatin1Char('\''))); - } - - runtime->m_bin = map.value(QLatin1String("qemu")); - runtime->m_args = map.value(QLatin1String("qemu_args")); - setEnvironment(runtime, map.value(QLatin1String("libpath"))); - runtime->m_sshPort = map.value(QLatin1String("sshport")); - runtime->m_freePorts = PortList(); - int i = 2; - while (true) { - const QString port = map.value(QLatin1String("redirport") - + QString::number(i++)); - if (port.isEmpty()) - break; - runtime->m_freePorts.addPort(port.toInt()); - } - - // This is complex because of extreme MADDE weirdness. - const QString root = m_maddeRoot + QLatin1Char('/'); - const bool pathIsRelative = QFileInfo(runtime->m_bin).isRelative(); - runtime->m_bin = - #ifdef Q_OS_WIN - root + (pathIsRelative - ? QLatin1String("madlib/") + runtime->m_bin // Fremantle. - : runtime->m_bin) // Harmattan. - + QLatin1String(".exe"); - #else - pathIsRelative - ? root + QLatin1String("madlib/") + runtime->m_bin // Fremantle. - : runtime->m_bin; // Harmattan. - #endif - } - } -} - -void MaemoQemuRuntimeParserV1::setEnvironment(MaemoQemuRuntime *runTime, - const QString &envSpec) const -{ - QString remainingEnvSpec = envSpec; - QString currentKey; - while (true) { - const int nextEqualsSignPos - = remainingEnvSpec.indexOf(QLatin1Char('=')); - if (nextEqualsSignPos == -1) { - if (!currentKey.isEmpty()) - runTime->m_normalVars << MaemoQemuRuntime::Variable(currentKey, - remainingEnvSpec); - break; - } - const int keyStartPos - = remainingEnvSpec.lastIndexOf(QRegExp(QLatin1String("\\s")), - nextEqualsSignPos) + 1; - if (!currentKey.isEmpty()) { - const int valueEndPos - = remainingEnvSpec.lastIndexOf(QRegExp(QLatin1String("\\S")), - qMax(0, keyStartPos - 1)) + 1; - runTime->m_normalVars << MaemoQemuRuntime::Variable(currentKey, - remainingEnvSpec.left(valueEndPos)); - } - currentKey = remainingEnvSpec.mid(keyStartPos, - nextEqualsSignPos - keyStartPos); - remainingEnvSpec.remove(0, nextEqualsSignPos + 1); - } -} - - -MaemoQemuRuntimeParserV2::MaemoQemuRuntimeParserV2(const QString &madInfoOutput, - const QString &targetName, const QString &maddeRoot) - : MaemoQemuRuntimeParser(madInfoOutput, targetName, maddeRoot) -{ -} - -MaemoQemuRuntime MaemoQemuRuntimeParserV2::parseRuntime() -{ - QString runtimeName; - QList runtimes; - while (m_madInfoReader.readNextStartElement()) { - if (m_madInfoReader.name() == QLatin1String("madde")) { - while (m_madInfoReader.readNextStartElement()) { - if (m_madInfoReader.name() == QLatin1String("targets")) { - while (m_madInfoReader.readNextStartElement()) - handleTargetTag(runtimeName); - } else if (m_madInfoReader.name() == QLatin1String("runtimes")) { - while (m_madInfoReader.readNextStartElement()) { - const MaemoQemuRuntime &rt = handleRuntimeTag(); - if (!rt.m_name.isEmpty() && !rt.m_bin.isEmpty() - && !rt.m_args.isEmpty()) { - runtimes << rt; - } - } - } else { - m_madInfoReader.skipCurrentElement(); - } - } - } - } - foreach (const MaemoQemuRuntime &rt, runtimes) { - if (rt.m_name == runtimeName) - return rt; - } - return MaemoQemuRuntime(); -} - -void MaemoQemuRuntimeParserV2::handleTargetTag(QString &runtimeName) -{ - const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); - if (m_madInfoReader.name() == QLatin1String("target") && runtimeName.isEmpty() - && attrs.value(QLatin1String("name")) == m_targetName - && attrs.value(QLatin1String("installed")) == QLatin1String("true")) { - while (m_madInfoReader.readNextStartElement()) { - if (m_madInfoReader.name() == QLatin1String("runtime")) - runtimeName = m_madInfoReader.readElementText(); - else - m_madInfoReader.skipCurrentElement(); - } - } else { - m_madInfoReader.skipCurrentElement(); - } -} - -MaemoQemuRuntime MaemoQemuRuntimeParserV2::handleRuntimeTag() -{ - MaemoQemuRuntime runtime; - const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); - if (m_madInfoReader.name() != QLatin1String("runtime") - || attrs.value(QLatin1String("installed")) != QLatin1String("true")) { - m_madInfoReader.skipCurrentElement(); - return runtime; - } - runtime.m_name = attrs.value(QLatin1String("name")).toString(); - while (m_madInfoReader.readNextStartElement()) { - if (m_madInfoReader.name() == QLatin1String("exec-path")) { - runtime.m_bin = m_madInfoReader.readElementText(); - } else if (m_madInfoReader.name() == QLatin1String("args")) { - runtime.m_args = m_madInfoReader.readElementText(); - } else if (m_madInfoReader.name() == QLatin1String("environment")) { - handleEnvironmentTag(runtime); - } else if (m_madInfoReader.name() == QLatin1String("tcpportmap")) { - const QList &ports = handleTcpPortListTag(); - foreach (const Port &port, ports) { - if (port.ssh) - runtime.m_sshPort = QString::number(port.port); - else - runtime.m_freePorts.addPort(port.port); - } - } else { - m_madInfoReader.skipCurrentElement(); - } - } - return runtime; -} - -void MaemoQemuRuntimeParserV2::handleEnvironmentTag(MaemoQemuRuntime &runtime) -{ - while (m_madInfoReader.readNextStartElement()) - handleVariableTag(runtime); - -#ifdef Q_OS_WIN - const QString root = QDir::toNativeSeparators(m_maddeRoot) - + QLatin1Char('/'); - const QLatin1Char colon(';'); - const QLatin1String key("PATH"); - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - runtime.m_normalVars << MaemoQemuRuntime::Variable(key, - root + QLatin1String("bin") + colon + env.value(key)); - runtime.m_normalVars << MaemoQemuRuntime::Variable(key, - root + QLatin1String("madlib") + colon + env.value(key)); -#endif -} - -void MaemoQemuRuntimeParserV2::handleVariableTag(MaemoQemuRuntime &runtime) -{ - if (m_madInfoReader.name() != QLatin1String("variable")) { - m_madInfoReader.skipCurrentElement(); - return; - } - - const bool isGlBackend = m_madInfoReader.attributes().value(QLatin1String("purpose")) - == QLatin1String("glbackend"); - QString varName; - QString varValue; - while (m_madInfoReader.readNextStartElement()) { - const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); - if (m_madInfoReader.name() == QLatin1String("name")) { - varName = m_madInfoReader.readElementText(); - } else if (m_madInfoReader.name() == QLatin1String("value") - && attrs.value(QLatin1String("set")) != QLatin1String("false")) { - varValue = m_madInfoReader.readElementText(); - if (isGlBackend) { - MaemoQemuSettings::OpenGlMode openGlMode - = openGlTagToEnum(attrs.value(QLatin1String("option")).toString()); - runtime.m_openGlBackendVarValues.insert(openGlMode, varValue); - } - } else { - m_madInfoReader.skipCurrentElement(); - } - } - - if (varName.isEmpty()) - return; - if (isGlBackend) { - runtime.m_openGlBackendVarName = varName; - } else { - runtime.m_normalVars << MaemoQemuRuntime::Variable(varName, varValue); - } -} - -QList MaemoQemuRuntimeParserV2::handleTcpPortListTag() -{ - QList ports; - while (m_madInfoReader.readNextStartElement()) { - const Port &port = handlePortTag(); - if (port.port != -1) - ports << port; - } - return ports; -} - -MaemoQemuRuntimeParserV2::Port MaemoQemuRuntimeParserV2::handlePortTag() -{ - Port port; - if (m_madInfoReader.name() == QLatin1String("port")) { - const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); - port.ssh = attrs.value(QLatin1String("service")) == QLatin1String("ssh"); - while (m_madInfoReader.readNextStartElement()) { - if (m_madInfoReader.name() == QLatin1String("host")) - port.port = m_madInfoReader.readElementText().toInt(); - else - m_madInfoReader.skipCurrentElement(); - } - } - return port; -} - -MaemoQemuSettings::OpenGlMode MaemoQemuRuntimeParserV2::openGlTagToEnum(const QString &tag) const -{ - if (tag == QLatin1String("hardware-acceleration")) - return MaemoQemuSettings::HardwareAcceleration; - if (tag == QLatin1String("software-rendering")) - return MaemoQemuSettings::SoftwareRendering; - if (tag == QLatin1String("autodetect")) - return MaemoQemuSettings::AutoDetect; - QTC_CHECK(false); - return MaemoQemuSettings::AutoDetect; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoqemuruntimeparser.h b/src/plugins/remotelinux/maemoqemuruntimeparser.h deleted file mode 100644 index 77a052baf6e..00000000000 --- a/src/plugins/remotelinux/maemoqemuruntimeparser.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMOQEMURUNTIMEPARSER_H -#define MAEMOQEMURUNTIMEPARSER_H - -#include "maemoqemuruntime.h" - -#include -#include - -namespace QtSupport { -class BaseQtVersion; -} - -namespace RemoteLinux { -namespace Internal { - -class MaemoQemuRuntimeParser -{ -public: - static MaemoQemuRuntime parseRuntime(const QtSupport::BaseQtVersion *qtVersion); - -protected: - MaemoQemuRuntimeParser(const QString &madInfoOutput, - const QString &targetName, const QString &maddeRoot); - - const QString m_targetName; - const QString m_maddeRoot; - QXmlStreamReader m_madInfoReader; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOQEMURUNTIMEPARSER_H diff --git a/src/plugins/remotelinux/maemoqemusettings.cpp b/src/plugins/remotelinux/maemoqemusettings.cpp deleted file mode 100644 index 3e86f8b9306..00000000000 --- a/src/plugins/remotelinux/maemoqemusettings.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemoqemusettings.h" - -#include - -#include - -namespace RemoteLinux { -namespace Internal { -namespace { -const QString SettingsGroup = QLatin1String("Maemo Qemu Settings"); -const QString OpenGlModeKey = QLatin1String("OpenGl Mode"); -} // anonymous namespace - -MaemoQemuSettings::OpenGlMode MaemoQemuSettings::openGlMode() -{ - if (!m_initialized) { - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(SettingsGroup); - m_openGlMode = static_cast(settings->value(OpenGlModeKey, AutoDetect).toInt()); - settings->endGroup(); - m_initialized = true; - } - return m_openGlMode; -} - -void MaemoQemuSettings::setOpenGlMode(OpenGlMode openGlMode) -{ - Q_ASSERT(m_initialized); - m_openGlMode = openGlMode; - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(SettingsGroup); - settings->setValue(OpenGlModeKey, m_openGlMode); - settings->endGroup(); -} - -bool MaemoQemuSettings::m_initialized = false; -MaemoQemuSettings::OpenGlMode MaemoQemuSettings::m_openGlMode; - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoqemusettings.h b/src/plugins/remotelinux/maemoqemusettings.h deleted file mode 100644 index f1c11697c7a..00000000000 --- a/src/plugins/remotelinux/maemoqemusettings.h +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOQEMUSETTINGS_H -#define MAEMOQEMUSETTINGS_H - -namespace RemoteLinux { -namespace Internal { - -class MaemoQemuSettings -{ -public: - enum OpenGlMode { HardwareAcceleration, SoftwareRendering, AutoDetect }; - - static OpenGlMode openGlMode(); - static void setOpenGlMode(OpenGlMode openGlMode); - -private: - MaemoQemuSettings(); - - static bool m_initialized; - static OpenGlMode m_openGlMode; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOQEMUSETTINGS_H diff --git a/src/plugins/remotelinux/maemoqemusettingswidget.cpp b/src/plugins/remotelinux/maemoqemusettingswidget.cpp deleted file mode 100644 index 8b1d0bec991..00000000000 --- a/src/plugins/remotelinux/maemoqemusettingswidget.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemoqemusettingswidget.h" -#include "ui_maemoqemusettingswidget.h" - -#include "maemoqemusettings.h" - -namespace RemoteLinux { -namespace Internal { - -MaemoQemuSettingsWidget::MaemoQemuSettingsWidget(QWidget *parent) : - QWidget(parent), - ui(new Ui::MaemoQemuSettingsWidget) -{ - ui->setupUi(this); - switch (MaemoQemuSettings::openGlMode()) { - case MaemoQemuSettings::HardwareAcceleration: - ui->hardwareAccelerationButton->setChecked(true); - break; - case MaemoQemuSettings::SoftwareRendering: - ui->softwareRenderingButton->setChecked(true); - break; - case MaemoQemuSettings::AutoDetect: - ui->autoDetectButton->setChecked(true); - break; - } -} - -MaemoQemuSettingsWidget::~MaemoQemuSettingsWidget() -{ - delete ui; -} - -QString MaemoQemuSettingsWidget::keywords() const -{ - const QChar space = QLatin1Char(' '); - QString keywords = ui->groupBox->title() + space - + ui->hardwareAccelerationButton->text() + space - + ui->softwareRenderingButton->text() + space - + ui->autoDetectButton->text(); - keywords.remove(QLatin1Char('&')); - return keywords; -} - -void MaemoQemuSettingsWidget::saveSettings() -{ - const MaemoQemuSettings::OpenGlMode openGlMode - = ui->hardwareAccelerationButton->isChecked() - ? MaemoQemuSettings::HardwareAcceleration - : ui->softwareRenderingButton->isChecked() - ? MaemoQemuSettings::SoftwareRendering - : MaemoQemuSettings::AutoDetect; - MaemoQemuSettings::setOpenGlMode(openGlMode); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoqemusettingswidget.h b/src/plugins/remotelinux/maemoqemusettingswidget.h deleted file mode 100644 index 4b2d4c6fad1..00000000000 --- a/src/plugins/remotelinux/maemoqemusettingswidget.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOQEMUSETTINGSWIDGET_H -#define MAEMOQEMUSETTINGSWIDGET_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { - class MaemoQemuSettingsWidget; -} -QT_END_NAMESPACE - -namespace RemoteLinux { -namespace Internal { - -class MaemoQemuSettingsWidget : public QWidget -{ - Q_OBJECT - -public: - explicit MaemoQemuSettingsWidget(QWidget *parent = 0); - ~MaemoQemuSettingsWidget(); - void saveSettings(); - QString keywords() const; - -private: - Ui::MaemoQemuSettingsWidget *ui; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOQEMUSETTINGSWIDGET_H diff --git a/src/plugins/remotelinux/maemoqemusettingswidget.ui b/src/plugins/remotelinux/maemoqemusettingswidget.ui deleted file mode 100644 index f500f946808..00000000000 --- a/src/plugins/remotelinux/maemoqemusettingswidget.ui +++ /dev/null @@ -1,64 +0,0 @@ - - - MaemoQemuSettingsWidget - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - - OpenGL Mode - - - - - - &Hardware acceleration - - - - - - - &Software rendering - - - - - - - &Auto-detect - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/src/plugins/remotelinux/maemoqtversion.cpp b/src/plugins/remotelinux/maemoqtversion.cpp deleted file mode 100644 index 8f61abd941f..00000000000 --- a/src/plugins/remotelinux/maemoqtversion.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemoqtversion.h" - -#include "maemoconstants.h" -#include "maemoglobal.h" - -#include -#include - -#include -#include -#include -#include - -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -MaemoQtVersion::MaemoQtVersion() : QtSupport::BaseQtVersion() -{ - -} - -MaemoQtVersion::MaemoQtVersion(const QString &path, bool isAutodetected, const QString &autodetectionSource) - : QtSupport::BaseQtVersion(path, isAutodetected, autodetectionSource), - m_osType(MaemoGlobal::osType(path)), - m_isvalidVersion(MaemoGlobal::isValidMaemoQtVersion(path, m_osType)) -{ - -} - -MaemoQtVersion::~MaemoQtVersion() -{ - -} - -void MaemoQtVersion::fromMap(const QVariantMap &map) -{ - QtSupport::BaseQtVersion::fromMap(map); - QString path = qmakeCommand(); - m_osType = MaemoGlobal::osType(path); - m_isvalidVersion = MaemoGlobal::isValidMaemoQtVersion(path, m_osType); -} - -QString MaemoQtVersion::type() const -{ - return QtSupport::Constants::MAEMOQT; -} - -bool MaemoQtVersion::isValid() const -{ - return BaseQtVersion::isValid() && m_isvalidVersion; -} - -MaemoQtVersion *MaemoQtVersion::clone() const -{ - return new MaemoQtVersion(*this); -} - -QString MaemoQtVersion::systemRoot() const -{ - if (m_systemRoot.isNull()) { - QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(qmakeCommand())) - + QLatin1String("/information")); - if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream stream(&file); - while (!stream.atEnd()) { - const QString &line = stream.readLine().trimmed(); - const QStringList &list = line.split(QLatin1Char(' ')); - if (list.count() <= 1) - continue; - if (list.at(0) == QLatin1String("sysroot")) { - m_systemRoot = MaemoGlobal::maddeRoot(qmakeCommand()) - + QLatin1String("/sysroots/") + list.at(1); - } - } - } - } - return m_systemRoot; -} - -QList MaemoQtVersion::detectQtAbis() const -{ - QList result; - if (!m_isvalidVersion) - return result; - if (m_osType == QLatin1String(Maemo5OsType)) { - result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, - ProjectExplorer::Abi::MaemoLinuxFlavor, ProjectExplorer::Abi::ElfFormat, - 32)); - } else if (m_osType == QLatin1String(HarmattanOsType)) { - result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, - ProjectExplorer::Abi::HarmattanLinuxFlavor, - ProjectExplorer::Abi::ElfFormat, - 32)); - } else if (m_osType == QLatin1String(MeeGoOsType)) { - result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, - ProjectExplorer::Abi::MeegoLinuxFlavor, - ProjectExplorer::Abi::ElfFormat, 32)); - } - return result; -} - -bool MaemoQtVersion::supportsTargetId(const QString &id) const -{ - return supportedTargetIds().contains(id); -} - -QSet MaemoQtVersion::supportedTargetIds() const -{ - QSet result; - if (!m_isvalidVersion) - return result; - if (m_osType == QLatin1String(Maemo5OsType)) { - result.insert(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)); - } else if (m_osType == QLatin1String(HarmattanOsType)) { - result.insert(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID)); - } else if (m_osType == QLatin1String(MeeGoOsType)) { - result.insert(QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID)); - } - return result; -} - -QString MaemoQtVersion::description() const -{ - if (m_osType == QLatin1String(Maemo5OsType)) - return QCoreApplication::translate("QtVersion", "Maemo", "Qt Version is meant for Maemo5"); - else if (m_osType == QLatin1String(HarmattanOsType)) - return QCoreApplication::translate("QtVersion", "Harmattan ", "Qt Version is meant for Harmattan"); - else if (m_osType == QLatin1String(MeeGoOsType)) - return QCoreApplication::translate("QtVersion", "Meego", "Qt Version is meant for Meego"); - return QString(); -} - -bool MaemoQtVersion::supportsShadowBuilds() const -{ -#ifdef Q_OS_WIN - return false; -#endif - return true; -} - -QString MaemoQtVersion::osType() const -{ - return m_osType; -} - -void MaemoQtVersion::addToEnvironment(Utils::Environment &env) const -{ - const QString maddeRoot = MaemoGlobal::maddeRoot(qmakeCommand()); - - // Needed to make pkg-config stuff work. - env.prependOrSet(QLatin1String("SYSROOT_DIR"), QDir::toNativeSeparators(systemRoot())); - env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madbin") - .arg(maddeRoot))); - env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madlib") - .arg(maddeRoot))); - env.prependOrSet(QLatin1String("PERL5LIB"), - QDir::toNativeSeparators(QString("%1/madlib/perl5").arg(maddeRoot))); - - env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin").arg(maddeRoot))); - env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin") - .arg(MaemoGlobal::targetRoot(qmakeCommand())))); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoqtversion.h b/src/plugins/remotelinux/maemoqtversion.h deleted file mode 100644 index 6fcbccf0b9d..00000000000 --- a/src/plugins/remotelinux/maemoqtversion.h +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMOQTVERSION_H -#define MAEMOQTVERSION_H - -#include - -namespace RemoteLinux { -namespace Internal { - -class MaemoQtVersion : public QtSupport::BaseQtVersion -{ -public: - MaemoQtVersion(); - MaemoQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); - ~MaemoQtVersion(); - - void fromMap(const QVariantMap &map); - MaemoQtVersion *clone() const; - - QString type() const; - bool isValid() const; - QString systemRoot() const; - QList detectQtAbis() const; - void addToEnvironment(Utils::Environment &env) const; - - bool supportsTargetId(const QString &id) const; - QSet supportedTargetIds() const; - - QString description() const; - - bool supportsShadowBuilds() const; - QString osType() const; -private: - mutable QString m_systemRoot; - mutable QString m_osType; - mutable bool m_isvalidVersion; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOQTVERSION_H diff --git a/src/plugins/remotelinux/maemoqtversionfactory.cpp b/src/plugins/remotelinux/maemoqtversionfactory.cpp deleted file mode 100644 index 86bcc41d655..00000000000 --- a/src/plugins/remotelinux/maemoqtversionfactory.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemoqtversionfactory.h" -#include "maemoglobal.h" -#include "maemoqtversion.h" - -#include -#include - -#include - -namespace RemoteLinux { -namespace Internal { - -MaemoQtVersionFactory::MaemoQtVersionFactory(QObject *parent) - : QtSupport::QtVersionFactory(parent) -{ - -} - -MaemoQtVersionFactory::~MaemoQtVersionFactory() -{ - -} - -bool MaemoQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(QtSupport::Constants::MAEMOQT); -} - -QtSupport::BaseQtVersion *MaemoQtVersionFactory::restore(const QString &type, - const QVariantMap &data) -{ - QTC_ASSERT(canRestore(type), return 0); - MaemoQtVersion *v = new MaemoQtVersion; - v->fromMap(data); - return v; -} - -int MaemoQtVersionFactory::priority() const -{ - return 50; -} - -QtSupport::BaseQtVersion *MaemoQtVersionFactory::create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) -{ - Q_UNUSED(evaluator); - // we are the fallback :) so we don't care what kinf of qt it is - QFileInfo fi(qmakePath); - if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) - return 0; - - if (MaemoGlobal::isValidMaemo5QtVersion(qmakePath) - || MaemoGlobal::isValidHarmattanQtVersion(qmakePath) - || MaemoGlobal::isValidMeegoQtVersion(qmakePath)) - return new MaemoQtVersion(qmakePath, isAutoDetected, autoDetectionSource); - return 0; -} - -} // Internal -} // Qt4ProjectManager diff --git a/src/plugins/remotelinux/maemoqtversionfactory.h b/src/plugins/remotelinux/maemoqtversionfactory.h deleted file mode 100644 index 41234cd6142..00000000000 --- a/src/plugins/remotelinux/maemoqtversionfactory.h +++ /dev/null @@ -1,57 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOQTVERSIONFACTORY_H -#define MAEMOQTVERSIONFACTORY_H - -#include - -namespace RemoteLinux { -namespace Internal { - -class MaemoQtVersionFactory : public QtSupport::QtVersionFactory -{ -public: - explicit MaemoQtVersionFactory(QObject *parent = 0); - ~MaemoQtVersionFactory(); - - virtual bool canRestore(const QString &type); - virtual QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data); - - virtual int priority() const; - virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); -}; - -} // Internal -} // Qt4ProjectManager - -#endif // MAEMOQTVERSIONFACTORY_H diff --git a/src/plugins/remotelinux/maemoremotecopyfacility.cpp b/src/plugins/remotelinux/maemoremotecopyfacility.cpp deleted file mode 100644 index 796efbfe621..00000000000 --- a/src/plugins/remotelinux/maemoremotecopyfacility.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemoremotecopyfacility.h" - -#include "maemoglobal.h" - -#include -#include -#include - -#include - -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { - -MaemoRemoteCopyFacility::MaemoRemoteCopyFacility(QObject *parent) : - QObject(parent), m_isCopying(false) -{ -} - -MaemoRemoteCopyFacility::~MaemoRemoteCopyFacility() {} - -void MaemoRemoteCopyFacility::copyFiles(const SshConnection::Ptr &connection, - const LinuxDeviceConfiguration::ConstPtr &devConf, - const QList &deployables, const QString &mountPoint) -{ - Q_ASSERT(connection->state() == SshConnection::Connected); - Q_ASSERT(!m_isCopying); - - m_devConf = devConf; - m_deployables = deployables; - m_mountPoint = mountPoint; - - m_copyRunner = SshRemoteProcessRunner::create(connection); - connect(m_copyRunner.data(), SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); - connect(m_copyRunner.data(), SIGNAL(processOutputAvailable(QByteArray)), - SLOT(handleRemoteStdout(QByteArray))); - connect(m_copyRunner.data(), - SIGNAL(processErrorOutputAvailable(QByteArray)), - SLOT(handleRemoteStderr(QByteArray))); - connect(m_copyRunner.data(), SIGNAL(processClosed(int)), - SLOT(handleCopyFinished(int))); - - m_isCopying = true; - copyNextFile(); -} - -void MaemoRemoteCopyFacility::cancel() -{ - Q_ASSERT(m_isCopying); - - SshRemoteProcessRunner::Ptr killProcess - = SshRemoteProcessRunner::create(m_copyRunner->connection()); - killProcess->run("pkill cp"); - setFinished(); -} - -void MaemoRemoteCopyFacility::handleConnectionError() -{ - const QString errMsg = m_copyRunner->connection()->errorString(); - setFinished(); - emit finished(tr("Connection failed: %1").arg(errMsg)); -} - -void MaemoRemoteCopyFacility::handleRemoteStdout(const QByteArray &output) -{ - emit stdoutData(QString::fromUtf8(output)); -} - -void MaemoRemoteCopyFacility::handleRemoteStderr(const QByteArray &output) -{ - emit stderrData(QString::fromUtf8(output)); -} - -void MaemoRemoteCopyFacility::handleCopyFinished(int exitStatus) -{ - if (!m_isCopying) - return; - - if (exitStatus != SshRemoteProcess::ExitedNormally - || m_copyRunner->process()->exitCode() != 0) { - setFinished(); - emit finished(tr("Error: Copy command failed.")); - } else { - emit fileCopied(m_deployables.takeFirst()); - copyNextFile(); - } -} - -void MaemoRemoteCopyFacility::copyNextFile() -{ - Q_ASSERT(m_isCopying); - - if (m_deployables.isEmpty()) { - setFinished(); - emit finished(); - return; - } - - const DeployableFile &d = m_deployables.first(); - QString sourceFilePath = m_mountPoint; -#ifdef Q_OS_WIN - const QString localFilePath = QDir::fromNativeSeparators(d.localFilePath); - sourceFilePath += QLatin1Char('/') + localFilePath.at(0).toLower() - + localFilePath.mid(2); -#else - sourceFilePath += d.localFilePath; -#endif - - QString command = QString::fromLatin1("%1 mkdir -p %3 && %1 cp -a %2 %3") - .arg(MaemoGlobal::remoteSudo(m_devConf->osType(), - m_copyRunner->connection()->connectionParameters().userName), - sourceFilePath, d.remoteDir); - emit progress(tr("Copying file '%1' to directory '%2' on the device...") - .arg(d.localFilePath, d.remoteDir)); - m_copyRunner->run(command.toUtf8()); -} - -void MaemoRemoteCopyFacility::setFinished() -{ - disconnect(m_copyRunner.data(), 0, this, 0); - m_copyRunner.clear(); - m_deployables.clear(); - m_isCopying = false; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoremotecopyfacility.h b/src/plugins/remotelinux/maemoremotecopyfacility.h deleted file mode 100644 index 58e484a6f69..00000000000 --- a/src/plugins/remotelinux/maemoremotecopyfacility.h +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOREMOTECOPYFACILITY_H -#define MAEMOREMOTECOPYFACILITY_H - -#include "deployablefile.h" - -#include -#include -#include -#include - -namespace Utils { -class SshConnection; -class SshRemoteProcessRunner; -} - -namespace RemoteLinux { -class LinuxDeviceConfiguration; - -namespace Internal { - -class MaemoRemoteCopyFacility : public QObject -{ - Q_OBJECT -public: - explicit MaemoRemoteCopyFacility(QObject *parent = 0); - ~MaemoRemoteCopyFacility(); - - void copyFiles(const QSharedPointer &connection, - const QSharedPointer &devConf, - const QList &deployables, const QString &mountPoint); - void cancel(); - -signals: - void stdoutData(const QString &output); - void stderrData(const QString &output); - void progress(const QString &message); - void fileCopied(const RemoteLinux::DeployableFile &deployable); - void finished(const QString &errorMsg = QString()); - -private slots: - void handleConnectionError(); - void handleCopyFinished(int exitStatus); - void handleRemoteStdout(const QByteArray &output); - void handleRemoteStderr(const QByteArray &output); - -private: - void copyNextFile(); - void setFinished(); - - QSharedPointer m_copyRunner; - QSharedPointer m_devConf; - QList m_deployables; - QString m_mountPoint; - bool m_isCopying; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOREMOTECOPYFACILITY_H diff --git a/src/plugins/remotelinux/maemoremotemounter.cpp b/src/plugins/remotelinux/maemoremotemounter.cpp deleted file mode 100644 index d84be8abb83..00000000000 --- a/src/plugins/remotelinux/maemoremotemounter.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemoremotemounter.h" - -#include "maemoglobal.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace Qt4ProjectManager; -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { - -MaemoRemoteMounter::MaemoRemoteMounter(QObject *parent) - : QObject(parent), m_utfsServerTimer(new QTimer(this)), m_state(Inactive) -{ - connect(m_utfsServerTimer, SIGNAL(timeout()), this, - SLOT(handleUtfsServerTimeout())); - m_utfsServerTimer->setSingleShot(true); -} - -MaemoRemoteMounter::~MaemoRemoteMounter() -{ - killAllUtfsServers(); -} - -void MaemoRemoteMounter::setConnection(const SshConnection::Ptr &connection, - const LinuxDeviceConfiguration::ConstPtr &devConf) -{ - QTC_ASSERT(m_state == Inactive, return); - - m_connection = connection; - m_devConf = devConf; -} - -void MaemoRemoteMounter::setBuildConfiguration(const Qt4BuildConfiguration *bc) -{ - QTC_ASSERT(m_state == Inactive, return); - - const QtSupport::BaseQtVersion * const qtVersion = bc->qtVersion(); - const AbstractQt4MaemoTarget * const maemoTarget - = qobject_cast(bc->target()); - m_remoteMountsAllowed = maemoTarget && maemoTarget->allowsRemoteMounts(); - m_maddeRoot = qtVersion ? MaemoGlobal::maddeRoot(qtVersion->qmakeCommand()) : QString(); -} - -void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec, - bool mountAsRoot) -{ - QTC_ASSERT(m_state == Inactive, return); - - if (m_remoteMountsAllowed && mountSpec.isValid()) - m_mountSpecs << MountInfo(mountSpec, mountAsRoot); -} - -bool MaemoRemoteMounter::hasValidMountSpecifications() const -{ - return !m_mountSpecs.isEmpty(); -} - -void MaemoRemoteMounter::mount(PortList *freePorts, - const RemoteLinuxUsedPortsGatherer *portsGatherer) -{ - QTC_ASSERT(m_state == Inactive, return); - - Q_ASSERT(m_utfsServers.isEmpty()); - Q_ASSERT(m_connection); - - if (m_mountSpecs.isEmpty()) { - setState(Inactive); - emit reportProgress(tr("No directories to mount")); - emit mounted(); - } else { - m_freePorts = freePorts; - m_portsGatherer = portsGatherer; - startUtfsClients(); - } -} - -void MaemoRemoteMounter::unmount() -{ - QTC_ASSERT(m_state == Inactive, return); - - if (m_mountSpecs.isEmpty()) { - emit reportProgress(tr("No directories to unmount")); - emit unmounted(); - return; - } - - QString remoteCall; - const QString remoteSudo = MaemoGlobal::remoteSudo(m_devConf->osType(), - m_connection->connectionParameters().userName); - for (int i = 0; i < m_mountSpecs.count(); ++i) { - remoteCall += QString::fromLocal8Bit("%1 umount %2 && %1 rmdir %2;") - .arg(remoteSudo, m_mountSpecs.at(i).mountSpec.remoteMountPoint); - } - - m_umountStderr.clear(); - m_unmountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8()); - connect(m_unmountProcess.data(), SIGNAL(closed(int)), this, - SLOT(handleUnmountProcessFinished(int))); - connect(m_unmountProcess.data(), SIGNAL(errorOutputAvailable(QByteArray)), - this, SLOT(handleUmountStderr(QByteArray))); - setState(Unmounting); - m_unmountProcess->start(); -} - -void MaemoRemoteMounter::handleUnmountProcessFinished(int exitStatus) -{ - QTC_ASSERT(m_state == Unmounting || m_state == Inactive, return); - - if (m_state == Inactive) - return; - setState(Inactive); - - QString errorMsg; - switch (exitStatus) { - case SshRemoteProcess::FailedToStart: - errorMsg = tr("Could not execute unmount request."); - break; - case SshRemoteProcess::KilledBySignal: - errorMsg = tr("Failure unmounting: %1") - .arg(m_unmountProcess->errorString()); - break; - case SshRemoteProcess::ExitedNormally: - break; - default: - Q_ASSERT_X(false, Q_FUNC_INFO, - "Impossible SshRemoteProcess exit status."); - } - - killAllUtfsServers(); - - if (errorMsg.isEmpty()) { - emit reportProgress(tr("Finished unmounting.")); - emit unmounted(); - } else { - if (!m_umountStderr.isEmpty()) { - errorMsg += tr("\nstderr was: '%1'") - .arg(QString::fromUtf8(m_umountStderr)); - } - emit error(errorMsg); - } -} - -void MaemoRemoteMounter::stop() -{ - setState(Inactive); -} - -void MaemoRemoteMounter::startUtfsClients() -{ - const QString userName = m_connection->connectionParameters().userName; - const QString chmodFuse = MaemoGlobal::remoteSudo(m_devConf->osType(), - userName) + QLatin1String(" chmod a+r+w /dev/fuse"); - const QString chmodUtfsClient - = QLatin1String("chmod a+x ") + utfsClientOnDevice(); - const QLatin1String andOp(" && "); - QString remoteCall = chmodFuse + andOp + chmodUtfsClient; - for (int i = 0; i < m_mountSpecs.count(); ++i) { - MountInfo &mountInfo = m_mountSpecs[i]; - mountInfo.remotePort - = m_portsGatherer->getNextFreePort(m_freePorts); - if (mountInfo.remotePort == -1) { - setState(Inactive); - emit error(tr("Error: Not enough free ports on device to fulfill all mount requests.")); - return; - } - - const QString remoteSudo - = MaemoGlobal::remoteSudo(m_devConf->osType(), userName); - const MaemoMountSpecification &mountSpec = mountInfo.mountSpec; - const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2") - .arg(remoteSudo, mountSpec.remoteMountPoint); - const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2") - .arg(remoteSudo, mountSpec.remoteMountPoint); - QString utfsClient - = QString::fromLocal8Bit("%1 -l %2 -r %2 -b %2 %4 -o nonempty") - .arg(utfsClientOnDevice()).arg(mountInfo.remotePort) - .arg(mountSpec.remoteMountPoint); - if (mountInfo.mountAsRoot) { - utfsClient.prepend(MaemoGlobal::remoteSudo(m_devConf->osType(), - userName) + QLatin1Char(' ')); - } - QLatin1String seqOp("; "); - remoteCall += seqOp + MaemoGlobal::remoteSourceProfilesCommand() - + seqOp + mkdir + andOp + chmod + andOp + utfsClient; - } - - emit reportProgress(tr("Starting remote UTFS clients...")); - m_utfsClientStderr.clear(); - m_mountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8()); - connect(m_mountProcess.data(), SIGNAL(started()), this, - SLOT(handleUtfsClientsStarted())); - connect(m_mountProcess.data(), SIGNAL(closed(int)), this, - SLOT(handleUtfsClientsFinished(int))); - connect(m_mountProcess.data(), SIGNAL(errorOutputAvailable(QByteArray)), - this, SLOT(handleUtfsClientStderr(QByteArray))); - m_mountProcess->start(); - - setState(UtfsClientsStarting); -} - -void MaemoRemoteMounter::handleUtfsClientsStarted() -{ - QTC_ASSERT(m_state == UtfsClientsStarting || m_state == Inactive, return); - - if (m_state == UtfsClientsStarting) { - setState(UtfsClientsStarted); - QTimer::singleShot(250, this, SLOT(startUtfsServers())); - } -} - -void MaemoRemoteMounter::handleUtfsClientsFinished(int exitStatus) -{ - QTC_ASSERT(m_state == UtfsClientsStarting || m_state == UtfsClientsStarted - || m_state == UtfsServersStarted || m_state == Inactive, return); - - if (m_state == Inactive) - return; - - setState(Inactive); - if (exitStatus == SshRemoteProcess::ExitedNormally - && m_mountProcess->exitCode() == 0) { - emit reportProgress(tr("Mount operation succeeded.")); - emit mounted(); - } else { - QString errMsg = tr("Failure running UTFS client: %1") - .arg(m_mountProcess->errorString()); - if (!m_utfsClientStderr.isEmpty()) - errMsg += tr("\nstderr was: '%1'") - .arg(QString::fromUtf8(m_utfsClientStderr)); - emit error(errMsg); - } -} - -void MaemoRemoteMounter::startUtfsServers() -{ - QTC_ASSERT(m_state == UtfsClientsStarted || m_state == Inactive, return); - - if (m_state == Inactive) - return; - - emit reportProgress(tr("Starting UTFS servers...")); - m_utfsServerTimer->start(30000); - for (int i = 0; i < m_mountSpecs.count(); ++i) { - const MountInfo &mountInfo = m_mountSpecs.at(i); - const MaemoMountSpecification &mountSpec = mountInfo.mountSpec; - const ProcPtr utfsServerProc(new QProcess); - const QString port = QString::number(mountInfo.remotePort); - const QString localSecretOpt = QLatin1String("-l"); - const QString remoteSecretOpt = QLatin1String("-r"); - const QStringList utfsServerArgs = QStringList() << localSecretOpt - << port << remoteSecretOpt << port << QLatin1String("-c") - << (m_connection->connectionParameters().host + QLatin1Char(':') + port) - << mountSpec.localDir; - connect(utfsServerProc.data(), - SIGNAL(finished(int,QProcess::ExitStatus)), this, - SLOT(handleUtfsServerFinished(int,QProcess::ExitStatus))); - connect(utfsServerProc.data(), SIGNAL(error(QProcess::ProcessError)), - this, SLOT(handleUtfsServerError(QProcess::ProcessError))); - connect(utfsServerProc.data(), SIGNAL(readyReadStandardError()), this, - SLOT(handleUtfsServerStderr())); - m_utfsServers << utfsServerProc; - utfsServerProc->start(utfsServer(), utfsServerArgs); - } - - setState(UtfsServersStarted); -} - -void MaemoRemoteMounter::handleUtfsServerStderr() -{ - if (m_state != Inactive) { - QProcess * const proc = static_cast(sender()); - const QByteArray &output = proc->readAllStandardError(); - emit debugOutput(QString::fromLocal8Bit(output)); - } -} - -void MaemoRemoteMounter::handleUtfsServerError(QProcess::ProcessError) -{ - if (m_state == Inactive || m_utfsServers.isEmpty()) - return; - - QProcess * const proc = static_cast(sender()); - QString errorString = proc->errorString(); - const QByteArray &errorOutput = proc->readAllStandardError(); - if (!errorOutput.isEmpty()) { - errorString += tr("\nstderr was: %1") - .arg(QString::fromLocal8Bit(errorOutput)); - } - killAllUtfsServers(); - emit error(tr("Error running UTFS server: %1").arg(errorString)); - - setState(Inactive); -} - -void MaemoRemoteMounter::handleUtfsServerFinished(int /* exitCode */, - QProcess::ExitStatus exitStatus) -{ - if (m_state != Inactive && exitStatus != QProcess::NormalExit) - handleUtfsServerError(static_cast(sender())->error()); -} - -void MaemoRemoteMounter::handleUtfsClientStderr(const QByteArray &output) -{ - if (m_state != Inactive) - m_utfsClientStderr += output; -} - -void MaemoRemoteMounter::handleUmountStderr(const QByteArray &output) -{ - if (m_state != Inactive) - m_umountStderr += output; -} - -QString MaemoRemoteMounter::utfsClientOnDevice() const -{ - return QLatin1String("/usr/lib/mad-developer/utfs-client"); -} - -QString MaemoRemoteMounter::utfsServer() const -{ - return m_maddeRoot + QLatin1String("/madlib/utfs-server"); -} - -void MaemoRemoteMounter::killAllUtfsServers() -{ - foreach (const ProcPtr &proc, m_utfsServers) - killUtfsServer(proc.data()); - m_utfsServers.clear(); -} - -void MaemoRemoteMounter::killUtfsServer(QProcess *proc) -{ - disconnect(proc, 0, this, 0); - proc->terminate(); - proc->waitForFinished(1000); - proc->kill(); -} - -void MaemoRemoteMounter::handleUtfsServerTimeout() -{ - QTC_ASSERT(m_state == UtfsServersStarted || m_state == Inactive, return); - - if (m_state == Inactive) - return; - - killAllUtfsServers(); - emit error(tr("Timeout waiting for UTFS servers to connect.")); - - setState(Inactive); -} - -void MaemoRemoteMounter::setState(State newState) -{ - if (newState == Inactive) { - m_utfsServerTimer->stop(); - if (m_mountProcess) { - disconnect(m_mountProcess.data(), 0, this, 0); - m_mountProcess->closeChannel(); - } - if (m_unmountProcess) { - disconnect(m_unmountProcess.data(), 0, this, 0); - m_unmountProcess->closeChannel(); - } - } - m_state = newState; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoremotemounter.h b/src/plugins/remotelinux/maemoremotemounter.h deleted file mode 100644 index 324ba281a59..00000000000 --- a/src/plugins/remotelinux/maemoremotemounter.h +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOREMOTEMOUNTER_H -#define MAEMOREMOTEMOUNTER_H - -#include "maemomountspecification.h" - -#include -#include -#include -#include -#include - -QT_FORWARD_DECLARE_CLASS(QTimer) - -namespace Utils { -class SftpChannel; -class SshConnection; -class SshRemoteProcess; -} - -namespace Qt4ProjectManager { class Qt4BuildConfiguration; } - -namespace RemoteLinux { -class LinuxDeviceConfiguration; -class PortList; -class RemoteLinuxUsedPortsGatherer; - -namespace Internal { - -class MaemoRemoteMounter : public QObject -{ - Q_OBJECT -public: - MaemoRemoteMounter(QObject *parent); - ~MaemoRemoteMounter(); - - // Must already be connected. - void setConnection(const QSharedPointer &connection, - const QSharedPointer &devConf); - - void setBuildConfiguration(const Qt4ProjectManager::Qt4BuildConfiguration *bc); - void addMountSpecification(const MaemoMountSpecification &mountSpec, - bool mountAsRoot); - bool hasValidMountSpecifications() const; - void resetMountSpecifications() { m_mountSpecs.clear(); } - void mount(PortList *freePorts, - const RemoteLinuxUsedPortsGatherer *portsGatherer); - void unmount(); - void stop(); - -signals: - void mounted(); - void unmounted(); - void error(const QString &reason); - void reportProgress(const QString &progressOutput); - void debugOutput(const QString &output); - -private slots: - void handleUtfsClientsStarted(); - void handleUtfsClientsFinished(int exitStatus); - void handleUtfsClientStderr(const QByteArray &output); - void handleUnmountProcessFinished(int exitStatus); - void handleUmountStderr(const QByteArray &output); - void handleUtfsServerError(QProcess::ProcessError procError); - void handleUtfsServerFinished(int exitCode, - QProcess::ExitStatus exitStatus); - void handleUtfsServerTimeout(); - void handleUtfsServerStderr(); - void startUtfsServers(); - -private: - enum State { - Inactive, Unmounting, UtfsClientsStarting, UtfsClientsStarted, - UtfsServersStarted - }; - - void setState(State newState); - - void startUtfsClients(); - void killUtfsServer(QProcess *proc); - void killAllUtfsServers(); - QString utfsClientOnDevice() const; - QString utfsServer() const; - - QTimer * const m_utfsServerTimer; - - struct MountInfo { - MountInfo(const MaemoMountSpecification &m, bool root) - : mountSpec(m), mountAsRoot(root), remotePort(-1) {} - MaemoMountSpecification mountSpec; - bool mountAsRoot; - int remotePort; - }; - - QSharedPointer m_connection; - QSharedPointer m_devConf; - QList m_mountSpecs; - QSharedPointer m_mountProcess; - QSharedPointer m_unmountProcess; - - typedef QSharedPointer ProcPtr; - QList m_utfsServers; - - QByteArray m_utfsClientStderr; - QByteArray m_umountStderr; - PortList *m_freePorts; - const RemoteLinuxUsedPortsGatherer *m_portsGatherer; - bool m_remoteMountsAllowed; - QString m_maddeRoot; - - State m_state; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOREMOTEMOUNTER_H diff --git a/src/plugins/remotelinux/maemoremotemountsmodel.cpp b/src/plugins/remotelinux/maemoremotemountsmodel.cpp deleted file mode 100644 index 99a77d4e20b..00000000000 --- a/src/plugins/remotelinux/maemoremotemountsmodel.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemoremotemountsmodel.h" - -#include "maemoconstants.h" - -namespace RemoteLinux { -namespace Internal { - -MaemoRemoteMountsModel::MaemoRemoteMountsModel(QObject *parent) : - QAbstractTableModel(parent) -{ -} - -void MaemoRemoteMountsModel::addMountSpecification(const QString &localDir) -{ - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_mountSpecs << MaemoMountSpecification(localDir, - MaemoMountSpecification::InvalidMountPoint); - endInsertRows(); -} - -void MaemoRemoteMountsModel::removeMountSpecificationAt(int pos) -{ - Q_ASSERT(pos >= 0 && pos < rowCount()); - beginRemoveRows(QModelIndex(), pos, pos); - m_mountSpecs.removeAt(pos); - endRemoveRows(); -} - -void MaemoRemoteMountsModel::setLocalDir(int pos, const QString &localDir) -{ - Q_ASSERT(pos >= 0 && pos < rowCount()); - m_mountSpecs[pos].localDir = localDir; - const QModelIndex currentIndex = index(pos, LocalDirRow); - emit dataChanged(currentIndex, currentIndex); -} - -int MaemoRemoteMountsModel::validMountSpecificationCount() const -{ - int count = 0; - foreach (const MaemoMountSpecification &m, m_mountSpecs) { - if (m.isValid()) - ++count; - } - return count; -} - -bool MaemoRemoteMountsModel::hasValidMountSpecifications() const -{ - foreach (const MaemoMountSpecification &m, m_mountSpecs) { - if (m.isValid()) - return true; - } - return false; -} - -QVariantMap MaemoRemoteMountsModel::toMap() const -{ - QVariantMap map; - QVariantList localDirsList; - QVariantList remoteMountPointsList; - foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs) { - localDirsList << mountSpec.localDir; - remoteMountPointsList << mountSpec.remoteMountPoint; - } - map.insert(ExportedLocalDirsKey, localDirsList); - map.insert(RemoteMountPointsKey, remoteMountPointsList); - return map; -} - -void MaemoRemoteMountsModel::fromMap(const QVariantMap &map) -{ - const QVariantList &localDirsList - = map.value(ExportedLocalDirsKey).toList(); - const QVariantList &remoteMountPointsList - = map.value(RemoteMountPointsKey).toList(); - const int count - = qMin(localDirsList.count(), remoteMountPointsList.count()); - for (int i = 0; i < count; ++i) { - const QString &localDir = localDirsList.at(i).toString(); - const QString &remoteMountPoint - = remoteMountPointsList.at(i).toString(); - m_mountSpecs << MaemoMountSpecification(localDir, remoteMountPoint); - } -} - -Qt::ItemFlags MaemoRemoteMountsModel::flags(const QModelIndex &index) const -{ - Qt::ItemFlags ourFlags = QAbstractTableModel::flags(index); - if (index.column() == RemoteMountPointRow) - ourFlags |= Qt::ItemIsEditable; - return ourFlags; -} - -QVariant MaemoRemoteMountsModel::headerData(int section, - Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole || orientation != Qt::Horizontal) - return QVariant(); - - switch (section) { - case LocalDirRow: return tr("Local directory"); - case RemoteMountPointRow: return tr("Remote mount point"); - default: return QVariant(); - } -} - -QVariant MaemoRemoteMountsModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.row() >= rowCount()) - return QVariant(); - - const MaemoMountSpecification &mountSpec = mountSpecificationAt(index.row()); - switch (index.column()) { - case LocalDirRow: - if (role == Qt::DisplayRole) - return mountSpec.localDir; - break; - case RemoteMountPointRow: - if (role == Qt::DisplayRole || role == Qt::EditRole) - return mountSpec.remoteMountPoint; - break; - } - return QVariant(); -} - -bool MaemoRemoteMountsModel::setData(const QModelIndex &index, - const QVariant &value, int role) -{ - if (!index.isValid() || index.row() >= rowCount() || role != Qt::EditRole) - return false; - - bool set; - switch (index.column()) { - case RemoteMountPointRow: { - const QString &newRemoteMountPoint = value.toString(); - for (int i = 0; i < m_mountSpecs.count(); ++i) { - const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i); - if (i != index.row() && mountSpec.isValid() - && mountSpec.remoteMountPoint == newRemoteMountPoint) - return false; - } - m_mountSpecs[index.row()].remoteMountPoint = newRemoteMountPoint; - set = true; - break; - } - case LocalDirRow: - default: - set = false; - break; - } - - if (set) - emit dataChanged(index, index); - return set; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoremotemountsmodel.h b/src/plugins/remotelinux/maemoremotemountsmodel.h deleted file mode 100644 index e7d5b7bb5c4..00000000000 --- a/src/plugins/remotelinux/maemoremotemountsmodel.h +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOREMOTEMOUNTSMODEL_H -#define MAEMOREMOTEMOUNTSMODEL_H - -#include "maemomountspecification.h" - -#include -#include -#include -#include - -namespace RemoteLinux { -namespace Internal { - -class MaemoRemoteMountsModel : public QAbstractTableModel -{ - Q_OBJECT -public: - explicit MaemoRemoteMountsModel(QObject *parent = 0); - int mountSpecificationCount() const { return m_mountSpecs.count(); } - int validMountSpecificationCount() const; - MaemoMountSpecification mountSpecificationAt(int pos) const { return m_mountSpecs.at(pos); } - bool hasValidMountSpecifications() const; - const QList &mountSpecs() const { return m_mountSpecs; } - - void addMountSpecification(const QString &localDir); - void removeMountSpecificationAt(int pos); - void setLocalDir(int pos, const QString &localDir); - - QVariantMap toMap() const; - void fromMap(const QVariantMap &map); - - static const int LocalDirRow = 0; - static const int RemoteMountPointRow = 1; - -private: - virtual int columnCount(const QModelIndex& = QModelIndex()) const; - virtual int rowCount(const QModelIndex& = QModelIndex()) const; - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual QModelIndex parent(const QModelIndex &child) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role) const; - virtual QVariant data(const QModelIndex &index, int role) const; - virtual bool setData(const QModelIndex &index, const QVariant &value, - int role); - - QList m_mountSpecs; -}; - -inline int MaemoRemoteMountsModel::columnCount(const QModelIndex &) const -{ - return 2; -} - -inline int MaemoRemoteMountsModel::rowCount(const QModelIndex &parent) const -{ - return parent.isValid() ? 0 : mountSpecificationCount(); -} - -inline QModelIndex MaemoRemoteMountsModel::parent(const QModelIndex &) const -{ - return QModelIndex(); -} - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOREMOTEMOUNTSMODEL_H diff --git a/src/plugins/remotelinux/maemorunconfiguration.cpp b/src/plugins/remotelinux/maemorunconfiguration.cpp deleted file mode 100644 index ecc0e5914e6..00000000000 --- a/src/plugins/remotelinux/maemorunconfiguration.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemorunconfiguration.h" - -#include "qt4maemotarget.h" -#include "maemoconstants.h" -#include "maemoglobal.h" -#include "maemoremotemountsmodel.h" -#include "maemorunconfigurationwidget.h" -#include "qt4maemodeployconfiguration.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -MaemoRunConfiguration::MaemoRunConfiguration(AbstractQt4MaemoTarget *parent, - const QString &proFilePath) - : RemoteLinuxRunConfiguration(parent, Id, proFilePath) -{ - init(); -} - -MaemoRunConfiguration::MaemoRunConfiguration(AbstractQt4MaemoTarget *parent, - MaemoRunConfiguration *source) - : RemoteLinuxRunConfiguration(parent, source) -{ - init(); -} - -void MaemoRunConfiguration::init() -{ - m_remoteMounts = new MaemoRemoteMountsModel(this); - connect(m_remoteMounts, SIGNAL(rowsInserted(QModelIndex, int, int)), this, - SLOT(handleRemoteMountsChanged())); - connect(m_remoteMounts, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, - SLOT(handleRemoteMountsChanged())); - connect(m_remoteMounts, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, - SLOT(handleRemoteMountsChanged())); - connect(m_remoteMounts, SIGNAL(modelReset()), SLOT(handleRemoteMountsChanged())); -} - -bool MaemoRunConfiguration::isEnabled() const -{ - if (!RemoteLinuxRunConfiguration::isEnabled()) - return false; - if (!hasEnoughFreePorts(ProjectExplorer::Constants::RUNMODE)) { - setDisabledReason(tr("Not enough free ports on the device.")); - return false; - } - return true; -} - -QWidget *MaemoRunConfiguration::createConfigurationWidget() -{ - return new MaemoRunConfigurationWidget(this); -} - -QVariantMap MaemoRunConfiguration::toMap() const -{ - QVariantMap map = RemoteLinuxRunConfiguration::toMap(); - map.unite(m_remoteMounts->toMap()); - return map; -} - -bool MaemoRunConfiguration::fromMap(const QVariantMap &map) -{ - if (!RemoteLinuxRunConfiguration::fromMap(map)) - return false; - m_remoteMounts->fromMap(map); - return true; -} - -QString MaemoRunConfiguration::environmentPreparationCommand() const -{ - return MaemoGlobal::remoteSourceProfilesCommand(); -} - -QString MaemoRunConfiguration::commandPrefix() const -{ - if (!deviceConfig()) - return QString(); - - QString prefix = environmentPreparationCommand() + QLatin1Char(';'); - if (deviceConfig()->osType() == QLatin1String(MeeGoOsType)) - prefix += QLatin1String("DISPLAY=:0.0 "); - - return QString::fromLocal8Bit("%1 %2").arg(prefix, userEnvironmentChangesAsString()); -} - -PortList MaemoRunConfiguration::freePorts() const -{ - const Qt4BuildConfiguration * const bc = activeQt4BuildConfiguration(); - return bc && deployConfig() - ? MaemoGlobal::freePorts(deployConfig()->deviceConfiguration(), bc->qtVersion()) - : PortList(); -} - -RemoteLinuxRunConfiguration::DebuggingType MaemoRunConfiguration::debuggingType() const -{ - if (!maemoTarget()->allowsQmlDebugging()) - return DebugCppOnly; - return RemoteLinuxRunConfiguration::debuggingType(); -} - -QString MaemoRunConfiguration::localDirToMountForRemoteGdb() const -{ - const QString projectDir - = QDir::fromNativeSeparators(QDir::cleanPath(activeBuildConfiguration() - ->target()->project()->projectDirectory())); - const QString execDir - = QDir::fromNativeSeparators(QFileInfo(localExecutableFilePath()).path()); - const int length = qMin(projectDir.length(), execDir.length()); - int lastSeparatorPos = 0; - for (int i = 0; i < length; ++i) { - if (projectDir.at(i) != execDir.at(i)) - return projectDir.left(lastSeparatorPos); - if (projectDir.at(i) == QLatin1Char('/')) - lastSeparatorPos = i; - } - return projectDir.length() == execDir.length() - ? projectDir : projectDir.left(lastSeparatorPos); -} - -QString MaemoRunConfiguration::remoteProjectSourcesMountPoint() const -{ - return MaemoGlobal::homeDirOnDevice(deviceConfig()->sshParameters().userName) - + QLatin1String("/gdbSourcesDir_") - + QFileInfo(localExecutableFilePath()).fileName(); -} - -bool MaemoRunConfiguration::hasEnoughFreePorts(const QString &mode) const -{ - const int freePortCount = freePorts().count(); - const bool remoteMountsAllowed = maemoTarget()->allowsRemoteMounts(); - const int mountDirCount = remoteMountsAllowed - ? remoteMounts()->validMountSpecificationCount() : 0; - if (mode == Debugger::Constants::DEBUGMODE) - return freePortCount >= mountDirCount + portsUsedByDebuggers(); - if (mode == ProjectExplorer::Constants::RUNMODE) - return freePortCount >= mountDirCount; - return false; -} - -void MaemoRunConfiguration::handleRemoteMountsChanged() -{ - emit remoteMountsChanged(); - updateEnabledState(); -} - -const AbstractQt4MaemoTarget *MaemoRunConfiguration::maemoTarget() const -{ - const AbstractQt4MaemoTarget * const maemoTarget - = qobject_cast(target()); - Q_ASSERT(maemoTarget); - return maemoTarget; -} - -const QString MaemoRunConfiguration::Id = QLatin1String(MAEMO_RC_ID); - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemorunconfiguration.h b/src/plugins/remotelinux/maemorunconfiguration.h deleted file mode 100644 index 7146f9cadf5..00000000000 --- a/src/plugins/remotelinux/maemorunconfiguration.h +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef MAEMORUNCONFIGURATION_H -#define MAEMORUNCONFIGURATION_H - -#include "remotelinuxrunconfiguration.h" - -namespace RemoteLinux { -namespace Internal { -class AbstractQt4MaemoTarget; -class MaemoRemoteMountsModel; - -class MaemoRunConfiguration : public RemoteLinuxRunConfiguration -{ - Q_OBJECT - -public: - MaemoRunConfiguration(AbstractQt4MaemoTarget *parent, const QString &proFilePath); - MaemoRunConfiguration(AbstractQt4MaemoTarget *parent, MaemoRunConfiguration *source); - - QVariantMap toMap() const; - bool fromMap(const QVariantMap &map); - bool isEnabled() const; - QWidget *createConfigurationWidget(); - QString environmentPreparationCommand() const; - QString commandPrefix() const; - PortList freePorts() const; - DebuggingType debuggingType() const; - - Internal::MaemoRemoteMountsModel *remoteMounts() const { return m_remoteMounts; } - bool hasEnoughFreePorts(const QString &mode) const; - QString localDirToMountForRemoteGdb() const; - QString remoteProjectSourcesMountPoint() const; - - static const QString Id; - -signals: - void remoteMountsChanged(); - -private slots: - void handleRemoteMountsChanged(); - -private: - void init(); - const AbstractQt4MaemoTarget *maemoTarget() const; - - MaemoRemoteMountsModel *m_remoteMounts; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMORUNCONFIGURATION_H diff --git a/src/plugins/remotelinux/maemorunconfigurationwidget.cpp b/src/plugins/remotelinux/maemorunconfigurationwidget.cpp deleted file mode 100644 index b7a64cbd3da..00000000000 --- a/src/plugins/remotelinux/maemorunconfigurationwidget.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemorunconfigurationwidget.h" - -#include "maemoglobal.h" -#include "maemoremotemountsmodel.h" -#include "maemorunconfiguration.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -MaemoRunConfigurationWidget::MaemoRunConfigurationWidget( - MaemoRunConfiguration *runConfiguration, QWidget *parent) - : QWidget(parent), m_runConfiguration(runConfiguration) -{ - QVBoxLayout *topLayout = new QVBoxLayout(this); - topLayout->setMargin(0); - QWidget *topWidget = new QWidget; - topLayout->addWidget(topWidget); - QVBoxLayout *mainLayout = new QVBoxLayout(topWidget); - mainLayout->setMargin(0); - m_remoteLinuxRunConfigWidget = new RemoteLinuxRunConfigurationWidget(runConfiguration, parent); - mainLayout->addWidget(m_remoteLinuxRunConfigWidget); - m_subWidget = new QWidget; - mainLayout->addWidget(m_subWidget); - QVBoxLayout *subLayout = new QVBoxLayout(m_subWidget); - subLayout->setMargin(0); - addMountWidgets(subLayout); - connect(m_runConfiguration, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)), - this, SLOT(updateMountWarning())); - connect(m_runConfiguration, SIGNAL(debuggersChanged()), SLOT(updateMountWarning())); - updateMountWarning(); - - const AbstractQt4MaemoTarget * const maemoTarget - = qobject_cast(runConfiguration->target()); - m_mountDetailsContainer->setVisible(maemoTarget->allowsRemoteMounts()); - if (!maemoTarget->allowsQmlDebugging()) - m_remoteLinuxRunConfigWidget->suppressQmlDebuggingOptions(); - - connect(m_runConfiguration, SIGNAL(isEnabledChanged(bool)), - this, SLOT(runConfigurationEnabledChange(bool))); - runConfigurationEnabledChange(m_runConfiguration->isEnabled()); -} - -void MaemoRunConfigurationWidget::runConfigurationEnabledChange(bool enabled) -{ - m_subWidget->setEnabled(enabled); -} - -void MaemoRunConfigurationWidget::addMountWidgets(QVBoxLayout *mainLayout) -{ - m_mountDetailsContainer = new Utils::DetailsWidget(this); - QWidget *mountViewWidget = new QWidget; - m_mountDetailsContainer->setWidget(mountViewWidget); - mainLayout->addWidget(m_mountDetailsContainer); - QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewWidget); - m_mountWarningLabel = new QLabel; - mountViewLayout->addWidget(m_mountWarningLabel); - QHBoxLayout *tableLayout = new QHBoxLayout; - mountViewLayout->addLayout(tableLayout); - m_mountView = new QTableView; - m_mountView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); - m_mountView->setSelectionBehavior(QTableView::SelectRows); - m_mountView->setModel(m_runConfiguration->remoteMounts()); - tableLayout->addWidget(m_mountView); - QVBoxLayout *mountViewButtonsLayout = new QVBoxLayout; - tableLayout->addLayout(mountViewButtonsLayout); - QToolButton *addMountButton = new QToolButton; - QIcon plusIcon; - plusIcon.addFile(QLatin1String(Core::Constants::ICON_PLUS)); - addMountButton->setIcon(plusIcon); - mountViewButtonsLayout->addWidget(addMountButton); - m_removeMountButton = new QToolButton; - QIcon minusIcon; - minusIcon.addFile(QLatin1String(Core::Constants::ICON_MINUS)); - m_removeMountButton->setIcon(minusIcon); - mountViewButtonsLayout->addWidget(m_removeMountButton); - mountViewButtonsLayout->addStretch(1); - - connect(addMountButton, SIGNAL(clicked()), this, SLOT(addMount())); - connect(m_removeMountButton, SIGNAL(clicked()), this, SLOT(removeMount())); - connect(m_mountView, SIGNAL(doubleClicked(QModelIndex)), this, - SLOT(changeLocalMountDir(QModelIndex))); - connect(m_mountView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, - SLOT(enableOrDisableRemoveMountSpecButton())); - enableOrDisableRemoveMountSpecButton(); - connect(m_runConfiguration, SIGNAL(remoteMountsChanged()), SLOT(handleRemoteMountsChanged())); - handleRemoteMountsChanged(); -} - -void MaemoRunConfigurationWidget::enableOrDisableRemoveMountSpecButton() -{ - const QModelIndexList selectedRows - = m_mountView->selectionModel()->selectedRows(); - m_removeMountButton->setEnabled(!selectedRows.isEmpty()); -} - -void MaemoRunConfigurationWidget::addMount() -{ - const QString localDir = QFileDialog::getExistingDirectory(this, - tr("Choose directory to mount")); - if (!localDir.isEmpty()) { - MaemoRemoteMountsModel * const mountsModel - = m_runConfiguration->remoteMounts(); - mountsModel->addMountSpecification(localDir); - m_mountView->edit(mountsModel->index(mountsModel->mountSpecificationCount() - 1, - mountsModel->RemoteMountPointRow)); - } -} - -void MaemoRunConfigurationWidget::removeMount() -{ - const QModelIndexList selectedRows - = m_mountView->selectionModel()->selectedRows(); - if (!selectedRows.isEmpty()) { - m_runConfiguration->remoteMounts() - ->removeMountSpecificationAt(selectedRows.first().row()); - } -} - -void MaemoRunConfigurationWidget::changeLocalMountDir(const QModelIndex &index) -{ - if (index.column() == MaemoRemoteMountsModel::LocalDirRow) { - MaemoRemoteMountsModel * const mountsModel - = m_runConfiguration->remoteMounts(); - const QString oldDir - = mountsModel->mountSpecificationAt(index.row()).localDir; - const QString localDir = QFileDialog::getExistingDirectory(this, - tr("Choose directory to mount"), oldDir); - if (!localDir.isEmpty()) - mountsModel->setLocalDir(index.row(), localDir); - } -} - -void MaemoRunConfigurationWidget::handleRemoteMountsChanged() -{ - const int mountCount - = m_runConfiguration->remoteMounts()->validMountSpecificationCount(); - QString text; - switch (mountCount) { - case 0: - text = tr("No local directories to be mounted on the device."); - break; - case 1: - text = tr("One local directory to be mounted on the device."); - break; - default: - //: Note: Only mountCount>1 will occur here as 0, 1 are handled above. - text = tr("%n local directories to be mounted on the device.", 0, mountCount); - break; - } - m_mountDetailsContainer->setSummaryText(QLatin1String("") + text - + QLatin1String("")); - updateMountWarning(); -} - -void MaemoRunConfigurationWidget::updateMountWarning() -{ - QString mountWarning; - const PortList &portList = m_runConfiguration->freePorts(); - const int availablePortCount = portList.count(); - const int mountDirCount - = m_runConfiguration->remoteMounts()->validMountSpecificationCount(); - if (mountDirCount > availablePortCount) { - mountWarning = tr("WARNING: You want to mount %1 directories, but " - "your device has only %n free ports.
You will not be able " - "to run this configuration.", 0, availablePortCount) - .arg(mountDirCount); - } else if (mountDirCount > 0) { - const int portsLeftByDebuggers = availablePortCount - - m_runConfiguration->portsUsedByDebuggers(); - if (mountDirCount > portsLeftByDebuggers) { - mountWarning = tr("WARNING: You want to mount %1 directories, " - "but only %n ports on the device will be available " - "in debug mode.
You will not be able to debug your " - "application with this configuration.", 0, portsLeftByDebuggers) - .arg(mountDirCount); - } - } - if (mountWarning.isEmpty()) { - m_mountWarningLabel->hide(); - } else { - m_mountWarningLabel->setText(QLatin1String("") - + mountWarning + QLatin1String("")); - m_mountWarningLabel->show(); - m_mountDetailsContainer->setState(Utils::DetailsWidget::Expanded); - } -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemorunconfigurationwidget.h b/src/plugins/remotelinux/maemorunconfigurationwidget.h deleted file mode 100644 index c3349e94b75..00000000000 --- a/src/plugins/remotelinux/maemorunconfigurationwidget.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMORUNCONFIGURATIONWIDGET_H -#define MAEMORUNCONFIGURATIONWIDGET_H - -#include - -QT_BEGIN_NAMESPACE -class QLabel; -class QModelIndex; -class QTableView; -class QToolButton; -class QVBoxLayout; -QT_END_NAMESPACE - -namespace Utils { class DetailsWidget; } - -namespace RemoteLinux { -class RemoteLinuxRunConfigurationWidget; - -namespace Internal { -class MaemoRunConfiguration; - -class MaemoRunConfigurationWidget : public QWidget -{ - Q_OBJECT -public: - explicit MaemoRunConfigurationWidget(MaemoRunConfiguration *runConfiguration, - QWidget *parent = 0); - -private slots: - void addMount(); - void removeMount(); - void changeLocalMountDir(const QModelIndex &index); - void enableOrDisableRemoveMountSpecButton(); - void handleRemoteMountsChanged(); - void updateMountWarning(); - void runConfigurationEnabledChange(bool enabled); - -private: - void addMountWidgets(QVBoxLayout *mainLayout); - - QWidget *m_subWidget; - QLabel *m_mountWarningLabel; - QTableView *m_mountView; - QToolButton *m_removeMountButton; - Utils::DetailsWidget *m_mountDetailsContainer; - RemoteLinuxRunConfigurationWidget *m_remoteLinuxRunConfigWidget; - MaemoRunConfiguration *m_runConfiguration; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMORUNCONFIGURATIONWIDGET_H diff --git a/src/plugins/remotelinux/maemoruncontrol.cpp b/src/plugins/remotelinux/maemoruncontrol.cpp deleted file mode 100644 index c32a66ccce4..00000000000 --- a/src/plugins/remotelinux/maemoruncontrol.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemoruncontrol.h" - -#include "maemoglobal.h" -#include "maemorunconfiguration.h" -#include "maemosshrunner.h" - -namespace RemoteLinux { -namespace Internal { - -using ProjectExplorer::RunConfiguration; - -MaemoRunControl::MaemoRunControl(RunConfiguration *rc) - : AbstractRemoteLinuxRunControl(rc) - , m_runner(new MaemoSshRunner(this, qobject_cast(rc))) -{ -} - -MaemoRunControl::~MaemoRunControl() -{ -} - -void MaemoRunControl::start() -{ - AbstractRemoteLinuxRunControl::start(); - connect(m_runner, SIGNAL(mountDebugOutput(QString)), SLOT(handleMountDebugOutput(QString))); -} - -void MaemoRunControl::handleMountDebugOutput(const QString &output) -{ - appendMessage(output, Utils::StdErrFormatSameLine); -} - -AbstractRemoteLinuxApplicationRunner *MaemoRunControl::runner() const { return m_runner; } - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemoruncontrol.h b/src/plugins/remotelinux/maemoruncontrol.h deleted file mode 100644 index 19e45b00a69..00000000000 --- a/src/plugins/remotelinux/maemoruncontrol.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMORUNCONTROL_H -#define MAEMORUNCONTROL_H - -#include - -namespace RemoteLinux { -class RemoteLinuxRunConfiguration; - -namespace Internal { -class MaemoSshRunner; - -class MaemoRunControl : public AbstractRemoteLinuxRunControl -{ - Q_OBJECT -public: - explicit MaemoRunControl(ProjectExplorer::RunConfiguration *runConfig); - virtual ~MaemoRunControl(); - - void start(); - -private slots: - void handleMountDebugOutput(const QString &output); - -private: - virtual AbstractRemoteLinuxApplicationRunner *runner() const; - - MaemoSshRunner * const m_runner; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMORUNCONTROL_H diff --git a/src/plugins/remotelinux/maemorunfactories.cpp b/src/plugins/remotelinux/maemorunfactories.cpp deleted file mode 100644 index 1a4c98d5841..00000000000 --- a/src/plugins/remotelinux/maemorunfactories.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemorunfactories.h" - -#include "maemoconstants.h" -#include "maemodebugsupport.h" -#include "maemoremotemountsmodel.h" -#include "maemorunconfiguration.h" -#include "maemoruncontrol.h" -#include "maemotoolchain.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include -#include - -using namespace Debugger; -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -namespace { - -QString pathFromId(const QString &id) -{ - if (!id.startsWith(MAEMO_RC_ID_PREFIX)) - return QString(); - return id.mid(QString(MAEMO_RC_ID_PREFIX).size()); -} - -} // namespace - -MaemoRunConfigurationFactory::MaemoRunConfigurationFactory(QObject *parent) - : IRunConfigurationFactory(parent) -{ -} - -MaemoRunConfigurationFactory::~MaemoRunConfigurationFactory() -{ -} - -bool MaemoRunConfigurationFactory::canCreate(Target *parent, - const QString &id) const -{ - return qobject_cast(parent)->qt4Project() - ->hasApplicationProFile(pathFromId(id)); -} - -bool MaemoRunConfigurationFactory::canRestore(Target *parent, - const QVariantMap &map) const -{ - Q_UNUSED(parent); - return qobject_cast(parent) - && ProjectExplorer::idFromMap(map).startsWith(QLatin1String(MAEMO_RC_ID)); -} - -bool MaemoRunConfigurationFactory::canClone(Target *parent, - RunConfiguration *source) const -{ - const RemoteLinuxRunConfiguration * const rlrc - = qobject_cast(source); - return rlrc && canCreate(parent, source->id() + QLatin1Char('.') + rlrc->proFilePath()); -} - -QStringList MaemoRunConfigurationFactory::availableCreationIds(Target *parent) const -{ - if (AbstractQt4MaemoTarget *t = qobject_cast(parent)) - return t->qt4Project()->applicationProFilePathes(QLatin1String(MAEMO_RC_ID_PREFIX)); - return QStringList(); -} - -QString MaemoRunConfigurationFactory::displayNameForId(const QString &id) const -{ - return QFileInfo(pathFromId(id)).completeBaseName() - + QLatin1String(" (on remote Maemo device)"); -} - -RunConfiguration *MaemoRunConfigurationFactory::create(Target *parent, - const QString &id) -{ - if (!canCreate(parent, id)) - return 0; - return new MaemoRunConfiguration(qobject_cast(parent), - pathFromId(id)); -} - -RunConfiguration *MaemoRunConfigurationFactory::restore(Target *parent, - const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - MaemoRunConfiguration *rc - = new MaemoRunConfiguration(qobject_cast(parent), QString()); - if (rc->fromMap(map)) - return rc; - - delete rc; - return 0; -} - -RunConfiguration *MaemoRunConfigurationFactory::clone(Target *parent, - RunConfiguration *source) -{ - if (!canClone(parent, source)) - return 0; - - MaemoRunConfiguration *old = static_cast(source); - return new MaemoRunConfiguration(static_cast(parent), old); -} - -// #pragma mark -- MaemoRunControlFactory - -MaemoRunControlFactory::MaemoRunControlFactory(QObject *parent) - : IRunControlFactory(parent) -{ -} - -MaemoRunControlFactory::~MaemoRunControlFactory() -{ -} - -bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration, - const QString &mode) const -{ - const MaemoRunConfiguration * const maemoRunConfig - = qobject_cast(runConfiguration); - if (!maemoRunConfig || !maemoRunConfig->isEnabled()) - return false; - return maemoRunConfig->hasEnoughFreePorts(mode); -} - -RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig, - const QString &mode) -{ - Q_ASSERT(mode == ProjectExplorer::Constants::RUNMODE || mode == Debugger::Constants::DEBUGMODE); - Q_ASSERT(canRun(runConfig, mode)); - - MaemoRunConfiguration *rc = qobject_cast(runConfig); - Q_ASSERT(rc); - - if (mode == ProjectExplorer::Constants::RUNMODE) - return new MaemoRunControl(rc); - - const DebuggerStartParameters params - = AbstractRemoteLinuxDebugSupport::startParameters(rc); - DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc); - if (!runControl) - return 0; - MaemoDebugSupport *debugSupport = new MaemoDebugSupport(rc, runControl->engine()); - connect(runControl, SIGNAL(finished()), debugSupport, SLOT(handleDebuggingFinished())); - return runControl; -} - -QString MaemoRunControlFactory::displayName() const -{ - return tr("Run on device"); -} - -RunConfigWidget *MaemoRunControlFactory::createConfigurationWidget(RunConfiguration *config) -{ - Q_UNUSED(config) - return 0; -} - - } // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemorunfactories.h b/src/plugins/remotelinux/maemorunfactories.h deleted file mode 100644 index 954093aed09..00000000000 --- a/src/plugins/remotelinux/maemorunfactories.h +++ /dev/null @@ -1,90 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMORUNFACTORIES_H -#define MAEMORUNFACTORIES_H - -#include - -namespace ProjectExplorer { - class RunConfiguration; - class RunControl; - class Target; -} -using ProjectExplorer::IRunConfigurationFactory; -using ProjectExplorer::IRunControlFactory; -using ProjectExplorer::RunConfiguration; -using ProjectExplorer::RunConfigWidget; -using ProjectExplorer::RunControl; -using ProjectExplorer::Target; - -namespace RemoteLinux { -namespace Internal { - -class MaemoRunConfigurationFactory : public IRunConfigurationFactory -{ - Q_OBJECT - -public: - explicit MaemoRunConfigurationFactory(QObject *parent = 0); - ~MaemoRunConfigurationFactory(); - - QString displayNameForId(const QString &id) const; - QStringList availableCreationIds(Target *parent) const; - - bool canCreate(Target *parent, const QString &id) const; - RunConfiguration *create(Target *parent, const QString &id); - - bool canRestore(Target *parent, const QVariantMap &map) const; - RunConfiguration *restore(Target *parent, const QVariantMap &map); - - bool canClone(Target *parent, RunConfiguration *source) const; - RunConfiguration *clone(Target *parent, RunConfiguration *source); -}; - -class MaemoRunControlFactory : public IRunControlFactory -{ - Q_OBJECT -public: - explicit MaemoRunControlFactory(QObject *parent = 0); - ~MaemoRunControlFactory(); - - QString displayName() const; - RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration); - - bool canRun(RunConfiguration *runConfiguration, const QString &mode) const; - RunControl *create(RunConfiguration *runConfiguration, const QString &mode); -}; - - } // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMORUNFACTORIES_H diff --git a/src/plugins/remotelinux/maemosettingspages.cpp b/src/plugins/remotelinux/maemosettingspages.cpp deleted file mode 100644 index c5c232ce8ec..00000000000 --- a/src/plugins/remotelinux/maemosettingspages.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemosettingspages.h" - -#include "maemoqemusettings.h" -#include "maemoqemusettingswidget.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace RemoteLinux { -namespace Internal { -namespace { - -class MaemoQemuCrashDialog : public QDialog -{ - Q_OBJECT -public: - MaemoQemuCrashDialog(QWidget *parent = 0) : QDialog(parent) - { - setWindowTitle(tr("Qemu error")); - QString message = tr("Qemu crashed.") + QLatin1String("

"); - const MaemoQemuSettings::OpenGlMode openGlMode - = MaemoQemuSettings::openGlMode(); - const QString linkString = QLatin1String("

") - + tr("Click here to change the OpenGL mode.") - + QLatin1String(""); - if (openGlMode == MaemoQemuSettings::HardwareAcceleration) { - message += tr("You have configured Qemu to use OpenGL " - "hardware acceleration, which might not be supported by " - "your system. You could try using software rendering instead."); - message += linkString; - } else if (openGlMode == MaemoQemuSettings::AutoDetect) { - message += tr("Qemu is currently configured to auto-detect the " - "OpenGL mode, which is known to not work in some cases. " - "You might want to use software rendering instead."); - message += linkString; - } - QLabel * const messageLabel = new QLabel(message, this); - messageLabel->setWordWrap(true); - messageLabel->setTextFormat(Qt::RichText); - connect(messageLabel, SIGNAL(linkActivated(QString)), - SLOT(showSettingsPage())); - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->addWidget(messageLabel); - QFrame * const separator = new QFrame; - separator->setFrameShape(QFrame::HLine); - separator->setFrameShadow(QFrame::Sunken); - mainLayout->addWidget(separator); - QDialogButtonBox * const buttonBox = new QDialogButtonBox; - buttonBox->addButton(QDialogButtonBox::Ok); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - mainLayout->addWidget(buttonBox); - } - -private: - Q_SLOT void showSettingsPage() - { - Core::ICore::instance()->showOptionsDialog(MaemoQemuSettingsPage::pageCategory(), - MaemoQemuSettingsPage::pageId()); - accept(); - } -}; - -} // anonymous namespace - - -MaemoQemuSettingsPage::MaemoQemuSettingsPage(QObject *parent) - : Core::IOptionsPage(parent) -{ -} - -MaemoQemuSettingsPage::~MaemoQemuSettingsPage() -{ -} - -QString MaemoQemuSettingsPage::id() const -{ - return pageId(); -} - -QString MaemoQemuSettingsPage::displayName() const -{ - return tr("MeeGo Qemu Settings"); -} - -QString MaemoQemuSettingsPage::category() const -{ - return pageCategory(); -} - -QString MaemoQemuSettingsPage::displayCategory() const -{ - return QString(); // Already set by device configurations page. -} - -QIcon MaemoQemuSettingsPage::categoryIcon() const -{ - return QIcon(); // See above. -} - -bool MaemoQemuSettingsPage::matches(const QString &searchKeyWord) const -{ - return m_widget->keywords().contains(searchKeyWord, Qt::CaseInsensitive); -} - -QWidget *MaemoQemuSettingsPage::createPage(QWidget *parent) -{ - m_widget = new MaemoQemuSettingsWidget(parent); - return m_widget; -} - -void MaemoQemuSettingsPage::apply() -{ - m_widget->saveSettings(); -} - -void MaemoQemuSettingsPage::finish() -{ -} - -void MaemoQemuSettingsPage::showQemuCrashDialog() -{ - MaemoQemuCrashDialog dlg(Core::ICore::instance()->mainWindow()); - dlg.exec(); -} - -QString MaemoQemuSettingsPage::pageId() -{ - return QLatin1String("ZZ.Qemu Settings"); -} - -QString MaemoQemuSettingsPage::pageCategory() -{ - return QLatin1String(Constants::RemoteLinuxSettingsCategory); -} - -} // namespace Internal -} // namespace RemoteLinux - -#include "maemosettingspages.moc" diff --git a/src/plugins/remotelinux/maemosettingspages.h b/src/plugins/remotelinux/maemosettingspages.h deleted file mode 100644 index 6048369fe65..00000000000 --- a/src/plugins/remotelinux/maemosettingspages.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOSETTINGSPAGES_H -#define MAEMOSETTINGSPAGES_H - -#include - -namespace RemoteLinux{ -namespace Internal { -class MaemoQemuSettingsWidget; - -class MaemoQemuSettingsPage : public Core::IOptionsPage -{ - Q_OBJECT -public: - MaemoQemuSettingsPage(QObject *parent = 0); - ~MaemoQemuSettingsPage(); - - virtual QString id() const; - virtual QString displayName() const; - virtual QString category() const; - virtual QString displayCategory() const; - virtual QIcon categoryIcon() const; - virtual bool matches(const QString &searchKeyWord) const; - virtual QWidget *createPage(QWidget *parent); - virtual void apply(); - virtual void finish(); - - static void showQemuCrashDialog(); - static QString pageId(); - static QString pageCategory(); - -private: - QString m_keywords; - MaemoQemuSettingsWidget *m_widget; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOSETTINGSPAGES_H diff --git a/src/plugins/remotelinux/maemosshrunner.cpp b/src/plugins/remotelinux/maemosshrunner.cpp deleted file mode 100644 index 86d33826d80..00000000000 --- a/src/plugins/remotelinux/maemosshrunner.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "maemosshrunner.h" - -#include "maemoqemumanager.h" -#include "maemoremotemounter.h" -#include "maemoremotemountsmodel.h" -#include "maemorunconfiguration.h" - -#include -#include -#include -#include - -using namespace Qt4ProjectManager; -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { - -MaemoSshRunner::MaemoSshRunner(QObject *parent, MaemoRunConfiguration *runConfig) - : AbstractRemoteLinuxApplicationRunner(runConfig, parent), - m_mounter(new MaemoRemoteMounter(this)), - m_mountSpecs(runConfig->remoteMounts()->mountSpecs()), - m_mountState(InactiveMountState) -{ - const Qt4BuildConfiguration * const bc = runConfig->activeQt4BuildConfiguration(); - m_qtId = bc && bc->qtVersion() ? bc->qtVersion()->uniqueId() : -1; - m_mounter->setBuildConfiguration(bc); - connect(m_mounter, SIGNAL(mounted()), this, SLOT(handleMounted())); - connect(m_mounter, SIGNAL(unmounted()), this, SLOT(handleUnmounted())); - connect(m_mounter, SIGNAL(error(QString)), this, - SLOT(handleMounterError(QString))); - connect(m_mounter, SIGNAL(reportProgress(QString)), this, - SIGNAL(reportProgress(QString))); - connect(m_mounter, SIGNAL(debugOutput(QString)), this, - SIGNAL(mountDebugOutput(QString))); -} - -MaemoSshRunner::~MaemoSshRunner() {} - -bool MaemoSshRunner::canRun(QString &whyNot) const -{ - if (!AbstractRemoteLinuxApplicationRunner::canRun(whyNot)) - return false; - - if (devConfig()->deviceType() == LinuxDeviceConfiguration::Emulator - && !MaemoQemuManager::instance().qemuIsRunning()) { - MaemoQemuRuntime rt; - if (MaemoQemuManager::instance().runtimeForQtVersion(m_qtId, &rt)) { - MaemoQemuManager::instance().startRuntime(); - whyNot = tr("Qemu was not running. It has now been started up for you, but it will " - "take a bit of time until it is ready. Please try again then."); - } else { - whyNot = tr("You want to run on Qemu, but it is not enabled for this Qt version."); - } - return false; - } - - return true; -} - -void MaemoSshRunner::doDeviceSetup() -{ - QTC_ASSERT(m_mountState == InactiveMountState, return); - - handleDeviceSetupDone(true); -} - -void MaemoSshRunner::doAdditionalInitialCleanup() -{ - QTC_ASSERT(m_mountState == InactiveMountState, return); - - m_mounter->setConnection(connection(), devConfig()); - m_mounter->resetMountSpecifications(); - for (int i = 0; i < m_mountSpecs.count(); ++i) - m_mounter->addMountSpecification(m_mountSpecs.at(i), false); - m_mountState = InitialUnmounting; - unmount(); -} - -void MaemoSshRunner::doAdditionalInitializations() -{ - mount(); -} - -void MaemoSshRunner::doPostRunCleanup() -{ - QTC_ASSERT(m_mountState == Mounted, return); - - m_mountState = PostRunUnmounting; - unmount(); -} - -void MaemoSshRunner::handleUnmounted() -{ - QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == PostRunUnmounting, return); - - switch (m_mountState) { - case InitialUnmounting: - m_mountState = InactiveMountState; - handleInitialCleanupDone(true); - break; - case PostRunUnmounting: - m_mountState = InactiveMountState; - handlePostRunCleanupDone(); - break; - default: - break; - } - m_mountState = InactiveMountState; -} - -void MaemoSshRunner::doAdditionalConnectionErrorHandling() -{ - m_mountState = InactiveMountState; -} - -void MaemoSshRunner::handleMounted() -{ - QTC_ASSERT(m_mountState == Mounting, return); - - if (m_mountState == Mounting) { - m_mountState = Mounted; - handleInitializationsDone(true); - } -} - -void MaemoSshRunner::handleMounterError(const QString &errorMsg) -{ - QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == Mounting - || m_mountState == PostRunUnmounting, return); - - const MountState oldMountState = m_mountState; - m_mountState = InactiveMountState; - emit error(errorMsg); - switch (oldMountState) { - case InitialUnmounting: - handleInitialCleanupDone(false); - break; - case Mounting: - handleInitializationsDone(false); - break; - case PostRunUnmounting: - handlePostRunCleanupDone(); - break; - default: - break; - } -} - -void MaemoSshRunner::mount() -{ - m_mountState = Mounting; - if (m_mounter->hasValidMountSpecifications()) { - emit reportProgress(tr("Mounting host directories...")); - m_mounter->mount(freePorts(), usedPortsGatherer()); - } else { - handleMounted(); - } -} - -void MaemoSshRunner::unmount() -{ - QTC_ASSERT(m_mountState == InitialUnmounting || m_mountState == PostRunUnmounting, return); - - if (m_mounter->hasValidMountSpecifications()) { - QString message; - switch (m_mountState) { - case InitialUnmounting: - message = tr("Potentially unmounting left-over host directory mounts..."); - break; - case PostRunUnmounting: - message = tr("Unmounting host directories..."); - break; - default: - break; - } - emit reportProgress(message); - m_mounter->unmount(); - } else { - handleUnmounted(); - } -} - -QString MaemoSshRunner::killApplicationCommandLine() const -{ - // Prevent pkill from matching our own pkill call. - QString pkillArg = remoteExecutable(); - const int lastPos = pkillArg.count() - 1; - pkillArg.replace(lastPos, 1, QLatin1Char('[') + pkillArg.at(lastPos) + QLatin1Char(']')); - - // Fremantle's busybox configuration is strange. - const char *killTemplate; - if (devConfig()->osType() == QLatin1String(Maemo5OsType)) - killTemplate = "pkill -f -%2 %1"; - else - killTemplate = "pkill -%2 -f %1"; - const QString niceKill = QString::fromLocal8Bit(killTemplate).arg(pkillArg).arg("SIGTERM"); - const QString brutalKill = QString::fromLocal8Bit(killTemplate).arg(pkillArg).arg("SIGKILL"); - return niceKill + QLatin1String("; sleep 1; ") + brutalKill; -} - -} // namespace Internal -} // namespace RemoteLinux - diff --git a/src/plugins/remotelinux/maemosshrunner.h b/src/plugins/remotelinux/maemosshrunner.h deleted file mode 100644 index f283f79a494..00000000000 --- a/src/plugins/remotelinux/maemosshrunner.h +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOSSHRUNNER_H -#define MAEMOSSHRUNNER_H - -#include "remotelinuxapplicationrunner.h" -#include "maemomountspecification.h" - -namespace RemoteLinux { -namespace Internal { -class MaemoRemoteMounter; -class MaemoRunConfiguration; - -class MaemoSshRunner : public AbstractRemoteLinuxApplicationRunner -{ - Q_OBJECT -public: - MaemoSshRunner(QObject *parent, MaemoRunConfiguration *runConfig); - ~MaemoSshRunner(); - -signals: - void mountDebugOutput(const QString &output); - -private slots: - void handleMounted(); - void handleUnmounted(); - void handleMounterError(const QString &errorMsg); - -private: - enum MountState { InactiveMountState, InitialUnmounting, Mounting, Mounted, PostRunUnmounting }; - - bool canRun(QString &whyNot) const; - void doDeviceSetup(); - void doAdditionalInitialCleanup(); - void doAdditionalInitializations(); - void doPostRunCleanup(); - void doAdditionalConnectionErrorHandling(); - QString killApplicationCommandLine() const; - - void mount(); - void unmount(); - - MaemoRemoteMounter * const m_mounter; - QList m_mountSpecs; - MountState m_mountState; - int m_qtId; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOSSHRUNNER_H diff --git a/src/plugins/remotelinux/maemotoolchain.cpp b/src/plugins/remotelinux/maemotoolchain.cpp deleted file mode 100644 index d008cbdc565..00000000000 --- a/src/plugins/remotelinux/maemotoolchain.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "maemotoolchain.h" - -#include "maemoglobal.h" -#include "maemoqtversion.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -static const char *const MAEMO_QT_VERSION_KEY = "Qt4ProjectManager.Maemo.QtVersion"; - -// -------------------------------------------------------------------------- -// MaemoToolChain -// -------------------------------------------------------------------------- - -MaemoToolChain::MaemoToolChain(bool autodetected) : - ProjectExplorer::GccToolChain(QLatin1String(Constants::MAEMO_TOOLCHAIN_ID), autodetected), - m_qtVersionId(-1) -{ - updateId(); -} - -MaemoToolChain::MaemoToolChain(const MaemoToolChain &tc) : - ProjectExplorer::GccToolChain(tc), - m_qtVersionId(tc.m_qtVersionId) -{ } - -MaemoToolChain::~MaemoToolChain() -{ } - -QString MaemoToolChain::typeName() const -{ - return MaemoToolChainFactory::tr("Maemo GCC"); -} - -ProjectExplorer::Abi MaemoToolChain::targetAbi() const -{ - return m_targetAbi; -} - -QString MaemoToolChain::mkspec() const -{ - return QString(); // always use default -} - -bool MaemoToolChain::isValid() const -{ - return GccToolChain::isValid() && m_qtVersionId >= 0 && m_targetAbi.isValid(); -} - -bool MaemoToolChain::canClone() const -{ - return false; -} - -void MaemoToolChain::addToEnvironment(Utils::Environment &env) const -{ - const QString manglePathsKey = QLatin1String("GCCWRAPPER_PATHMANGLE"); - if (!env.hasKey(manglePathsKey)) { - const QStringList pathsToMangle = QStringList() << QLatin1String("/lib") - << QLatin1String("/opt") << QLatin1String("/usr"); - env.set(manglePathsKey, QString()); - foreach (const QString &path, pathsToMangle) - env.appendOrSet(manglePathsKey, path, QLatin1String(":")); - } -} - -bool MaemoToolChain::operator ==(const ProjectExplorer::ToolChain &tc) const -{ - if (!ToolChain::operator ==(tc)) - return false; - - const MaemoToolChain *tcPtr = static_cast(&tc); - return m_qtVersionId == tcPtr->m_qtVersionId; -} - -ProjectExplorer::ToolChainConfigWidget *MaemoToolChain::configurationWidget() -{ - return new MaemoToolChainConfigWidget(this); -} - -QVariantMap MaemoToolChain::toMap() const -{ - QVariantMap result = GccToolChain::toMap(); - result.insert(QLatin1String(MAEMO_QT_VERSION_KEY), m_qtVersionId); - return result; -} - -bool MaemoToolChain::fromMap(const QVariantMap &data) -{ - if (!GccToolChain::fromMap(data)) - return false; - - m_qtVersionId = data.value(QLatin1String(MAEMO_QT_VERSION_KEY), -1).toInt(); - - return isValid(); -} - -void MaemoToolChain::setQtVersionId(int id) -{ - if (id < 0) { - m_targetAbi = ProjectExplorer::Abi(); - m_qtVersionId = -1; - updateId(); // Will trigger toolChainUpdated()! - return; - } - - MaemoQtVersion *version = dynamic_cast(QtSupport::QtVersionManager::instance()->version(id)); - Q_ASSERT(version); - if (!version->isValid()) - return; - Q_ASSERT(version->qtAbis().count() == 1); - - m_qtVersionId = id; - m_targetAbi = version->qtAbis().at(0); - - updateId(); // Will trigger toolChainUpdated()! - setDisplayName(MaemoToolChainFactory::tr("Maemo GCC for %1").arg(version->displayName())); -} - -int MaemoToolChain::qtVersionId() const -{ - return m_qtVersionId; -} - -void MaemoToolChain::updateId() -{ - setId(QString::fromLatin1("%1:%2.%3").arg(Constants::MAEMO_TOOLCHAIN_ID) - .arg(m_qtVersionId).arg(debuggerCommand())); -} - -// -------------------------------------------------------------------------- -// MaemoToolChainConfigWidget -// -------------------------------------------------------------------------- - -MaemoToolChainConfigWidget::MaemoToolChainConfigWidget(MaemoToolChain *tc) : - ProjectExplorer::ToolChainConfigWidget(tc) -{ - QVBoxLayout *layout = new QVBoxLayout(this); - QLabel *label = new QLabel; - QtSupport::BaseQtVersion *v = QtSupport::QtVersionManager::instance()->version(tc->qtVersionId()); - Q_ASSERT(v); - label->setText(tr("
Path to MADDE:%1
Path to MADDE target:%2
Debugger:%3
" - "" - "" - "") - .arg(QDir::toNativeSeparators(MaemoGlobal::maddeRoot(v->qmakeCommand())), - QDir::toNativeSeparators(MaemoGlobal::targetRoot(v->qmakeCommand())), - QDir::toNativeSeparators(tc->debuggerCommand()))); - layout->addWidget(label); -} - -void MaemoToolChainConfigWidget::apply() -{ - // nothing to do! -} - -void MaemoToolChainConfigWidget::discard() -{ - // nothing to do! -} - -bool MaemoToolChainConfigWidget::isDirty() const -{ - return false; -} - -// -------------------------------------------------------------------------- -// MaemoToolChainFactory -// -------------------------------------------------------------------------- - -MaemoToolChainFactory::MaemoToolChainFactory() : - ProjectExplorer::ToolChainFactory() -{ } - -QString MaemoToolChainFactory::displayName() const -{ - return tr("Maemo GCC"); -} - -QString MaemoToolChainFactory::id() const -{ - return QLatin1String(Constants::MAEMO_TOOLCHAIN_ID); -} - -QList MaemoToolChainFactory::autoDetect() -{ - QtSupport::QtVersionManager *vm = QtSupport::QtVersionManager::instance(); - connect(vm, SIGNAL(qtVersionsChanged(QList)), - this, SLOT(handleQtVersionChanges(QList))); - - QList versionList; - foreach (QtSupport::BaseQtVersion *v, vm->versions()) - versionList.append(v->uniqueId()); - - return createToolChainList(versionList); -} - -void MaemoToolChainFactory::handleQtVersionChanges(const QList &changes) -{ - ProjectExplorer::ToolChainManager *tcm = ProjectExplorer::ToolChainManager::instance(); - QList tcList = createToolChainList(changes); - foreach (ProjectExplorer::ToolChain *tc, tcList) - tcm->registerToolChain(tc); -} - -QList MaemoToolChainFactory::createToolChainList(const QList &changes) -{ - ProjectExplorer::ToolChainManager *tcm = ProjectExplorer::ToolChainManager::instance(); - QtSupport::QtVersionManager *vm = QtSupport::QtVersionManager::instance(); - QList result; - - foreach (int i, changes) { - QtSupport::BaseQtVersion *v = vm->version(i); - // remove tool chain (on removal, change or addition: - QList toRemove; - foreach (ProjectExplorer::ToolChain *tc, tcm->toolChains()) { - if (!tc->id().startsWith(QLatin1String(Constants::MAEMO_TOOLCHAIN_ID))) - continue; - MaemoToolChain *mTc = static_cast(tc); - if (mTc->qtVersionId() == i) - toRemove.append(mTc); - } - foreach (ProjectExplorer::ToolChain *tc, toRemove) - tcm->deregisterToolChain(tc); - - const MaemoQtVersion * const mqv = dynamic_cast(v); - if (!mqv || !mqv->isValid()) - continue; - - // (Re-)add toolchain: - // add tool chain: - MaemoToolChain *mTc = new MaemoToolChain(true); - mTc->setQtVersionId(i); - QString target = "Maemo 5"; - if (v->supportsTargetId(Constants::HARMATTAN_DEVICE_TARGET_ID)) - target = "Maemo 6"; - else if (v->supportsTargetId(Constants::MEEGO_DEVICE_TARGET_ID)) - target = "Meego"; - mTc->setDisplayName(tr("%1 GCC (%2)").arg(target).arg(MaemoGlobal::maddeRoot(mqv->qmakeCommand()))); - mTc->setCompilerPath(MaemoGlobal::targetRoot(mqv->qmakeCommand()) + QLatin1String("/bin/gcc")); - mTc->setDebuggerCommand(ProjectExplorer::ToolChainManager::instance()->defaultDebugger(mqv->qtAbis().at(0))); - if (mTc->debuggerCommand().isEmpty()) - mTc->setDebuggerCommand(MaemoGlobal::targetRoot(mqv->qmakeCommand()) + QLatin1String("/bin/gdb")); - result.append(mTc); - } - return result; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maemotoolchain.h b/src/plugins/remotelinux/maemotoolchain.h deleted file mode 100644 index 9e3128014b6..00000000000 --- a/src/plugins/remotelinux/maemotoolchain.h +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef MAEMOTOOLCHAIN_H -#define MAEMOTOOLCHAIN_H - -#include -#include - -namespace RemoteLinux { - -namespace Internal { - -// -------------------------------------------------------------------------- -// MaemoToolChain -// -------------------------------------------------------------------------- - -class MaemoToolChain : public ProjectExplorer::GccToolChain -{ -public: - ~MaemoToolChain(); - - QString typeName() const; - ProjectExplorer::Abi targetAbi() const; - QString mkspec() const; - - bool isValid() const; - bool canClone() const; - - void addToEnvironment(Utils::Environment &env) const; - - bool operator ==(const ProjectExplorer::ToolChain &) const; - - ProjectExplorer::ToolChainConfigWidget *configurationWidget(); - - QVariantMap toMap() const; - bool fromMap(const QVariantMap &data); - - void setQtVersionId(int); - int qtVersionId() const; - -private: - void updateId(); - - explicit MaemoToolChain(bool); - MaemoToolChain(const MaemoToolChain &); - - int m_qtVersionId; - mutable QString m_sysroot; - ProjectExplorer::Abi m_targetAbi; - - friend class MaemoToolChainFactory; -}; - -// -------------------------------------------------------------------------- -// MaemoToolChainConfigWidget -// -------------------------------------------------------------------------- - -class MaemoToolChainConfigWidget : public ProjectExplorer::ToolChainConfigWidget -{ - Q_OBJECT - -public: - MaemoToolChainConfigWidget(MaemoToolChain *); - - void apply(); - void discard(); - bool isDirty() const; -}; - -// -------------------------------------------------------------------------- -// MaemoToolChainFactory -// -------------------------------------------------------------------------- - -class MaemoToolChainFactory : public ProjectExplorer::ToolChainFactory -{ - Q_OBJECT - -public: - MaemoToolChainFactory(); - - QString displayName() const; - QString id() const; - - QList autoDetect(); - -private slots: - void handleQtVersionChanges(const QList &); - QList createToolChainList(const QList &); -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // MAEMOTOOLCHAIN_H diff --git a/src/plugins/remotelinux/qt-maemo.qrc b/src/plugins/remotelinux/qt-maemo.qrc deleted file mode 100644 index 354fe64d1be..00000000000 --- a/src/plugins/remotelinux/qt-maemo.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - images/qemu-run.png - images/qemu-stop.png - - diff --git a/src/plugins/remotelinux/qt4maemodeployconfiguration.cpp b/src/plugins/remotelinux/qt4maemodeployconfiguration.cpp deleted file mode 100644 index 9f9498ab269..00000000000 --- a/src/plugins/remotelinux/qt4maemodeployconfiguration.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "qt4maemodeployconfiguration.h" - -#include "maddeuploadandinstallpackagesteps.h" -#include "maemoconstants.h" -#include "maemodeploybymountsteps.h" -#include "maemodeployconfigurationwidget.h" -#include "maemoinstalltosysrootstep.h" -#include "maemopackagecreationstep.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace ProjectExplorer; -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { -namespace { -const QString OldDeployConfigId = QLatin1String("2.2MaemoDeployConfig"); -} // namespace - -Qt4MaemoDeployConfiguration::Qt4MaemoDeployConfiguration(ProjectExplorer::Target *target, - const QString &id, const QString &displayName, const QString &supportedOsType) - : RemoteLinuxDeployConfiguration(target, id, displayName, supportedOsType) -{ - const QList &deployConfigs = target->deployConfigurations(); - foreach (const DeployConfiguration * const dc, deployConfigs) { - const Qt4MaemoDeployConfiguration * const mdc - = qobject_cast(dc); - if (mdc) { - m_deploymentSettingsAssistant = mdc->deploymentSettingsAssistant(); - break; - } - } - if (!m_deploymentSettingsAssistant) { - QString qmakeScope; - if (supportedOsType == QLatin1String(Maemo5OsType)) - qmakeScope = QLatin1String("maemo5"); - else if (supportedOsType == QLatin1String(HarmattanOsType)) - qmakeScope = QLatin1String("contains(MEEGO_EDITION,harmattan)"); - else if (supportedOsType == QLatin1String(MeeGoOsType)) - qmakeScope = QLatin1String("!isEmpty(MEEGO_VERSION_MAJOR):!contains(MEEGO_EDITION,harmattan)"); - else - qDebug("%s: Unexpected OS type %s", Q_FUNC_INFO, qPrintable(supportedOsType)); - m_deploymentSettingsAssistant = QSharedPointer - (new DeploymentSettingsAssistant(qmakeScope, QLatin1String("/opt"), deploymentInfo())); - } -} - -Qt4MaemoDeployConfiguration::Qt4MaemoDeployConfiguration(ProjectExplorer::Target *target, - Qt4MaemoDeployConfiguration *source) - : RemoteLinuxDeployConfiguration(target, source) -{ - m_deploymentSettingsAssistant = source->deploymentSettingsAssistant(); -} - -QSharedPointer Qt4MaemoDeployConfiguration::deploymentSettingsAssistant() const -{ - return m_deploymentSettingsAssistant; -} - -QString Qt4MaemoDeployConfiguration::localDesktopFilePath(const DeployableFilesPerProFile *proFileInfo) const -{ - QTC_ASSERT(proFileInfo->projectType() == ApplicationTemplate, return QString()); - - for (int i = 0; i < proFileInfo->rowCount(); ++i) { - const DeployableFile &d = proFileInfo->deployableAt(i); - if (QFileInfo(d.localFilePath).fileName().endsWith(QLatin1String(".desktop"))) - return d.localFilePath; - } - return QString(); -} - - -DeployConfigurationWidget *Qt4MaemoDeployConfiguration::configurationWidget() const -{ - return new MaemoDeployConfigurationWidget; -} - -Qt4MaemoDeployConfiguration::~Qt4MaemoDeployConfiguration() {} - -QString Qt4MaemoDeployConfiguration::fremantleWithPackagingId() -{ - return QLatin1String("DeployToFremantleWithPackaging"); -} - -QString Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId() -{ - return QLatin1String("DeployToFremantleWithoutPackaging"); -} - -QString Qt4MaemoDeployConfiguration::harmattanId() -{ - return QLatin1String("DeployToHarmattan"); -} - -QString Qt4MaemoDeployConfiguration::meegoId() -{ - return QLatin1String("DeployToMeego"); -} - - -Qt4MaemoDeployConfigurationFactory::Qt4MaemoDeployConfigurationFactory(QObject *parent) - : DeployConfigurationFactory(parent) -{ } - -QStringList Qt4MaemoDeployConfigurationFactory::availableCreationIds(Target *parent) const -{ - QStringList ids; - if (qobject_cast(parent)) { - ids << Qt4MaemoDeployConfiguration::fremantleWithPackagingId() - << Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId(); - } else if (qobject_cast(parent)) { - ids << Qt4MaemoDeployConfiguration::harmattanId(); - } else if (qobject_cast(parent)) { - ids << Qt4MaemoDeployConfiguration::meegoId(); - } - - return ids; -} - -QString Qt4MaemoDeployConfigurationFactory::displayNameForId(const QString &id) const -{ - if (id == Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId()) - return tr("Copy Files to Maemo5 Device"); - else if (id == Qt4MaemoDeployConfiguration::fremantleWithPackagingId()) - return tr("Build Debian Package and Install to Maemo5 Device"); - else if (id == Qt4MaemoDeployConfiguration::harmattanId()) - return tr("Build Debian Package and Install to Harmattan Device"); - else if (id == Qt4MaemoDeployConfiguration::meegoId()) - return tr("Build RPM Package and Install to MeeGo Device"); - return QString(); -} - -bool Qt4MaemoDeployConfigurationFactory::canCreate(Target *parent, - const QString &id) const -{ - return availableCreationIds(parent).contains(id); -} - -DeployConfiguration *Qt4MaemoDeployConfigurationFactory::create(Target *parent, - const QString &id) -{ - Q_ASSERT(canCreate(parent, id)); - - DeployConfiguration *dc = 0; - const QString displayName = displayNameForId(id); - if (id == Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId()) { - dc = new Qt4MaemoDeployConfiguration(parent, id, displayName, QLatin1String(Maemo5OsType)); - dc->stepList()->insertStep(0, new MaemoMakeInstallToSysrootStep(dc->stepList())); - dc->stepList()->insertStep(1, new MaemoCopyFilesViaMountStep(dc->stepList())); - } else if (id == Qt4MaemoDeployConfiguration::fremantleWithPackagingId()) { - dc = new Qt4MaemoDeployConfiguration(parent, id, displayName, QLatin1String(Maemo5OsType)); - dc->stepList()->insertStep(0, new MaemoDebianPackageCreationStep(dc->stepList())); - dc->stepList()->insertStep(1, new MaemoInstallDebianPackageToSysrootStep(dc->stepList())); - dc->stepList()->insertStep(2, new MaemoInstallPackageViaMountStep(dc->stepList())); - } else if (id == Qt4MaemoDeployConfiguration::harmattanId()) { - dc = new Qt4MaemoDeployConfiguration(parent, id, displayName, - QLatin1String(HarmattanOsType)); - dc->stepList()->insertStep(0, new MaemoDebianPackageCreationStep(dc->stepList())); - dc->stepList()->insertStep(1, new MaemoInstallDebianPackageToSysrootStep(dc->stepList())); - dc->stepList()->insertStep(2, new MaemoUploadAndInstallPackageStep(dc->stepList())); - } else if (id == Qt4MaemoDeployConfiguration::meegoId()) { - dc = new Qt4MaemoDeployConfiguration(parent, id, displayName, QLatin1String(MeeGoOsType)); - dc->stepList()->insertStep(0, new MaemoRpmPackageCreationStep(dc->stepList())); - dc->stepList()->insertStep(1, new MaemoInstallRpmPackageToSysrootStep(dc->stepList())); - dc->stepList()->insertStep(2, new MeegoUploadAndInstallPackageStep(dc->stepList())); - } - return dc; -} - -bool Qt4MaemoDeployConfigurationFactory::canRestore(Target *parent, - const QVariantMap &map) const -{ - return canCreate(parent, idFromMap(map)) - || (idFromMap(map) == OldDeployConfigId - && qobject_cast(parent)); -} - -DeployConfiguration *Qt4MaemoDeployConfigurationFactory::restore(Target *parent, - const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - QString id = idFromMap(map); - if (id == OldDeployConfigId) { - if (qobject_cast(parent)) - id = Qt4MaemoDeployConfiguration::fremantleWithPackagingId(); - else if (qobject_cast(parent)) - id = Qt4MaemoDeployConfiguration::harmattanId(); - else if (qobject_cast(parent)) - id = Qt4MaemoDeployConfiguration::meegoId(); - } - Qt4MaemoDeployConfiguration * const dc - = qobject_cast(create(parent, id)); - if (!dc->fromMap(map)) { - delete dc; - return 0; - } - return dc; -} - -DeployConfiguration *Qt4MaemoDeployConfigurationFactory::clone(Target *parent, - DeployConfiguration *product) -{ - if (!canClone(parent, product)) - return 0; - return new Qt4MaemoDeployConfiguration(parent, - qobject_cast(product)); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/qt4maemodeployconfiguration.h b/src/plugins/remotelinux/qt4maemodeployconfiguration.h deleted file mode 100644 index be7226bdf8a..00000000000 --- a/src/plugins/remotelinux/qt4maemodeployconfiguration.h +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H -#define QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H - -#include - -namespace RemoteLinux { -class DeployableFilesPerProFile; -class DeploymentSettingsAssistant; - -namespace Internal { - -class Qt4MaemoDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory -{ - Q_OBJECT - -public: - explicit Qt4MaemoDeployConfigurationFactory(QObject *parent = 0); - - virtual QStringList availableCreationIds(ProjectExplorer::Target *parent) const; - virtual QString displayNameForId(const QString &id) const; - virtual bool canCreate(ProjectExplorer::Target *parent, const QString &id) const; - virtual ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, const QString &id); - virtual bool canRestore(ProjectExplorer::Target *parent, - const QVariantMap &map) const; - virtual ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, - const QVariantMap &map); - virtual ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent, - ProjectExplorer::DeployConfiguration *product); -}; - -class Qt4MaemoDeployConfiguration : public RemoteLinux::RemoteLinuxDeployConfiguration -{ - Q_OBJECT - -public: - ~Qt4MaemoDeployConfiguration(); - - ProjectExplorer::DeployConfigurationWidget *configurationWidget() const; - - QSharedPointer deploymentSettingsAssistant() const; - QString localDesktopFilePath(const DeployableFilesPerProFile *proFileInfo) const; - - static QString fremantleWithPackagingId(); - static QString fremantleWithoutPackagingId(); - static QString harmattanId(); - static QString meegoId(); - -private: - friend class Internal::Qt4MaemoDeployConfigurationFactory; - - Qt4MaemoDeployConfiguration(ProjectExplorer::Target *target, const QString &id, - const QString &displayName, const QString &supportedOsType); - Qt4MaemoDeployConfiguration(ProjectExplorer::Target *target, - Qt4MaemoDeployConfiguration *source); - - QSharedPointer m_deploymentSettingsAssistant; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H diff --git a/src/plugins/remotelinux/qt4maemotarget.cpp b/src/plugins/remotelinux/qt4maemotarget.cpp deleted file mode 100644 index 1a46836ac62..00000000000 --- a/src/plugins/remotelinux/qt4maemotarget.cpp +++ /dev/null @@ -1,1197 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "qt4maemotarget.h" - -#include "maemoglobal.h" -#include "maemopackagecreationstep.h" -#include "maemorunconfiguration.h" -#include "maemotoolchain.h" -#include "qt4maemodeployconfiguration.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace Qt4ProjectManager; - -namespace RemoteLinux { -namespace Internal { - -namespace { -const QByteArray NameFieldName("Package"); -const QByteArray IconFieldName("XB-Maemo-Icon-26"); -const QByteArray ShortDescriptionFieldName("Description"); -const QByteArray PackageFieldName("Package"); -const QLatin1String PackagingDirName("qtc_packaging"); -const QByteArray NameTag("Name"); -const QByteArray SummaryTag("Summary"); -const QByteArray VersionTag("Version"); -const QByteArray ReleaseTag("Release"); - -bool adaptTagValue(QByteArray &document, const QByteArray &fieldName, - const QByteArray &newFieldValue, bool caseSensitive) -{ - QByteArray adaptedLine = fieldName + ": " + newFieldValue; - const QByteArray completeTag = fieldName + ':'; - const int lineOffset = caseSensitive ? document.indexOf(completeTag) - : document.toLower().indexOf(completeTag.toLower()); - if (lineOffset == -1) { - document.append(adaptedLine).append('\n'); - return true; - } - - int newlineOffset = document.indexOf('\n', lineOffset); - bool updated = false; - if (newlineOffset == -1) { - newlineOffset = document.length(); - adaptedLine += '\n'; - updated = true; - } - const int replaceCount = newlineOffset - lineOffset; - if (!updated && document.mid(lineOffset, replaceCount) != adaptedLine) - updated = true; - if (updated) - document.replace(lineOffset, replaceCount, adaptedLine); - return updated; -} - - -} // anonymous namespace - - -AbstractQt4MaemoTarget::AbstractQt4MaemoTarget(Qt4Project *parent, const QString &id) : - Qt4BaseTarget(parent, id), - m_filesWatcher(new Utils::FileSystemWatcher(this)), - m_buildConfigurationFactory(new Qt4BuildConfigurationFactory(this)), - m_isInitialized(false) -{ - m_filesWatcher->setObjectName(QLatin1String("Qt4MaemoTarget")); - setIcon(QIcon(":/projectexplorer/images/MaemoDevice.png")); - connect(parent, SIGNAL(addedTarget(ProjectExplorer::Target*)), - this, SLOT(handleTargetAdded(ProjectExplorer::Target*))); - connect(parent, SIGNAL(fromMapFinished()), - this, SLOT(handleFromMapFinished())); -} - -AbstractQt4MaemoTarget::~AbstractQt4MaemoTarget() -{ } - -QList AbstractQt4MaemoTarget::possibleToolChains(ProjectExplorer::BuildConfiguration *bc) const -{ - QList result; - - Qt4BuildConfiguration *qt4Bc = qobject_cast(bc); - if (!qt4Bc) - return result; - - QList candidates = Qt4BaseTarget::possibleToolChains(bc); - foreach (ProjectExplorer::ToolChain *i, candidates) { - MaemoToolChain *tc = dynamic_cast(i); - if (!tc || !qt4Bc->qtVersion()) - continue; - if (tc->qtVersionId() == qt4Bc->qtVersion()->uniqueId()) - result.append(tc); - } - - return result; -} - -ProjectExplorer::IBuildConfigurationFactory *AbstractQt4MaemoTarget::buildConfigurationFactory() const -{ - return m_buildConfigurationFactory; -} - -void AbstractQt4MaemoTarget::createApplicationProFiles() -{ - removeUnconfiguredCustomExectutableRunConfigurations(); - - QList profiles = qt4Project()->applicationProFiles(); - QSet paths; - foreach (Qt4ProFileNode *pro, profiles) - paths << pro->path(); - - foreach (ProjectExplorer::RunConfiguration *rc, runConfigurations()) - if (MaemoRunConfiguration *qt4rc = qobject_cast(rc)) - paths.remove(qt4rc->proFilePath()); - - // Only add new runconfigurations if there are none. - foreach (const QString &path, paths) - addRunConfiguration(new MaemoRunConfiguration(this, path)); - - // Oh still none? Add a custom executable runconfiguration - if (runConfigurations().isEmpty()) { - addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(this)); - } -} - -QList AbstractQt4MaemoTarget::runConfigurationsForNode(ProjectExplorer::Node *n) -{ - QList result; - foreach (ProjectExplorer::RunConfiguration *rc, runConfigurations()) - if (MaemoRunConfiguration *mrc = qobject_cast(rc)) - if (mrc->proFilePath() == n->path()) - result << rc; - return result; -} - -bool AbstractQt4MaemoTarget::setProjectVersion(const QString &version, - QString *error) -{ - bool success = true; - foreach (Target * const target, project()->targets()) { - AbstractQt4MaemoTarget * const maemoTarget - = qobject_cast(target); - if (maemoTarget) { - if (!maemoTarget->setProjectVersionInternal(version, error)) - success = false; - } - } - return success; -} - -bool AbstractQt4MaemoTarget::setPackageName(const QString &name) -{ - bool success = true; - foreach (Target * const target, project()->targets()) { - AbstractQt4MaemoTarget * const maemoTarget - = qobject_cast(target); - if (maemoTarget) { - if (!maemoTarget->setPackageNameInternal(name)) - success = false; - } - } - return success; -} - -bool AbstractQt4MaemoTarget::setShortDescription(const QString &description) -{ - bool success = true; - foreach (Target * const target, project()->targets()) { - AbstractQt4MaemoTarget * const maemoTarget - = qobject_cast(target); - if (maemoTarget) { - if (!maemoTarget->setShortDescriptionInternal(description)) - success = false; - } - } - return success; -} - -QSharedPointer AbstractQt4MaemoTarget::openFile(const QString &filePath, - QIODevice::OpenMode mode, QString *error) const -{ - const QString nativePath = QDir::toNativeSeparators(filePath); - QSharedPointer file(new QFile(filePath)); - if (!file->open(mode)) { - if (error) { - *error = tr("Cannot open file '%1': %2") - .arg(nativePath, file->errorString()); - } - file.clear(); - } - return file; -} - -void AbstractQt4MaemoTarget::handleFromMapFinished() -{ - handleTargetAdded(this); -} - -void AbstractQt4MaemoTarget::handleTargetAdded(ProjectExplorer::Target *target) -{ - if (target != this) - return; - - if (!project()->rootProjectNode()) { - // Project is not fully setup yet, happens on new project - // we wait for the fromMapFinished that comes afterwards - return; - } - - disconnect(project(), SIGNAL(fromMapFinished()), - this, SLOT(handleFromMapFinished())); - disconnect(project(), SIGNAL(addedTarget(ProjectExplorer::Target*)), - this, SLOT(handleTargetAdded(ProjectExplorer::Target*))); - connect(project(), SIGNAL(aboutToRemoveTarget(ProjectExplorer::Target*)), - SLOT(handleTargetToBeRemoved(ProjectExplorer::Target*))); - const ActionStatus status = createTemplates(); - if (status == ActionFailed) - return; - if (status == ActionSuccessful) // Don't do this when the packaging data already exists. - initPackagingSettingsFromOtherTarget(); - handleTargetAddedSpecial(); - if (status == ActionSuccessful) { - const QStringList &files = packagingFilePaths(); - if (!files.isEmpty()) { - const QString list = QLatin1String("
  • ") + files.join(QLatin1String("
  • ")) - + QLatin1String("
"); - QMessageBox::StandardButton button = QMessageBox::question(Core::ICore::instance()->mainWindow(), - tr("Add Packaging Files to Project"), - tr("Qt Creator has set up the following files to enable " - "packaging:\n %1\nDo you want to add them to the project?") - .arg(list), QMessageBox::Yes | QMessageBox::No); - if (button == QMessageBox::Yes) { - ProjectExplorer::ProjectExplorerPlugin::instance() - ->addExistingFiles(project()->rootProjectNode(), files); - } - } - } - - m_isInitialized = true; -} - -void AbstractQt4MaemoTarget::handleTargetToBeRemoved(ProjectExplorer::Target *target) -{ - if (target != this) - return; - if (!targetCanBeRemoved()) - return; - - Core::ICore * const core = Core::ICore::instance(); - const int answer = QMessageBox::warning(core->mainWindow(), - tr("Qt Creator"), tr("Do you want to remove the packaging file(s) " - "associated with the target '%1'?").arg(displayName()), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No); - if (answer == QMessageBox::No) - return; - const QStringList pkgFilePaths = packagingFilePaths(); - if (!pkgFilePaths.isEmpty()) { - project()->rootProjectNode()->removeFiles(ProjectExplorer::UnknownFileType, - pkgFilePaths); - Core::IVersionControl * const vcs = core->vcsManager() - ->findVersionControlForDirectory(QFileInfo(pkgFilePaths.first()).dir().path()); - if (vcs && vcs->supportsOperation(Core::IVersionControl::DeleteOperation)) { - foreach (const QString &filePath, pkgFilePaths) - vcs->vcsDelete(filePath); - } - } - delete m_filesWatcher; - removeTarget(); - QString error; - const QString packagingPath = project()->projectDirectory() - + QLatin1Char('/') + PackagingDirName; - const QStringList otherContents = QDir(packagingPath).entryList(QDir::Dirs - | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot); - if (otherContents.isEmpty()) { - if (!Utils::FileUtils::removeRecursively(packagingPath, &error)) - qDebug("%s", qPrintable(error)); - } -} - -AbstractQt4MaemoTarget::ActionStatus AbstractQt4MaemoTarget::createTemplates() -{ - QDir projectDir(project()->projectDirectory()); - if (!projectDir.exists(PackagingDirName) - && !projectDir.mkdir(PackagingDirName)) { - raiseError(tr("Error creating packaging directory '%1'.") - .arg(PackagingDirName)); - return ActionFailed; - } - - return createSpecialTemplates(); -} - -bool AbstractQt4MaemoTarget::initPackagingSettingsFromOtherTarget() -{ - bool success = true; - foreach (const Target * const target, project()->targets()) { - const AbstractQt4MaemoTarget * const maemoTarget - = qobject_cast(target); - if (maemoTarget && maemoTarget != this && maemoTarget->m_isInitialized) { - if (!setProjectVersionInternal(maemoTarget->projectVersion())) - success = false; - if (!setPackageNameInternal(maemoTarget->packageName())) - success = false; - if (!setShortDescriptionInternal(maemoTarget->shortDescription())) - success = false; - break; - } - } - return initAdditionalPackagingSettingsFromOtherTarget() && success; -} - -void AbstractQt4MaemoTarget::raiseError(const QString &reason) -{ - QMessageBox::critical(0, tr("Error creating MeeGo templates"), reason); -} - -AbstractDebBasedQt4MaemoTarget::AbstractDebBasedQt4MaemoTarget(Qt4Project *parent, - const QString &id) : AbstractQt4MaemoTarget(parent, id) -{ -} - -AbstractDebBasedQt4MaemoTarget::~AbstractDebBasedQt4MaemoTarget() {} - -QString AbstractDebBasedQt4MaemoTarget::projectVersion(QString *error) const -{ - QSharedPointer changeLog = openFile(changeLogFilePath(), - QIODevice::ReadOnly, error); - if (!changeLog) - return QString(); - const QByteArray &firstLine = changeLog->readLine(); - const int openParenPos = firstLine.indexOf('('); - if (openParenPos == -1) { - if (error) { - *error = tr("Debian changelog file '%1' has unexpected format.") - .arg(QDir::toNativeSeparators(changeLog->fileName())); - } - return QString(); - } - const int closeParenPos = firstLine.indexOf(')', openParenPos); - if (closeParenPos == -1) { - if (error) { - *error = tr("Debian changelog file '%1' has unexpected format.") - .arg(QDir::toNativeSeparators(changeLog->fileName())); - } - return QString(); - } - return QString::fromUtf8(firstLine.mid(openParenPos + 1, - closeParenPos - openParenPos - 1).data()); -} - -bool AbstractDebBasedQt4MaemoTarget::setProjectVersionInternal(const QString &version, - QString *error) -{ - const QString filePath = changeLogFilePath(); - Utils::FileReader reader; - if (!reader.fetch(filePath, error)) - return false; - QString content = QString::fromUtf8(reader.data()); - if (content.contains(QLatin1Char('(') + version + QLatin1Char(')'))) { - if (error) { - *error = tr("Refusing to update changelog file: Already contains version '%1'.") - .arg(version); - } - return false; - } - - int maintainerOffset = content.indexOf(QLatin1String("\n -- ")); - const int eolOffset = content.indexOf(QLatin1Char('\n'), maintainerOffset+1); - if (maintainerOffset == -1 || eolOffset == -1) { - if (error) { - *error = tr("Cannot update changelog: Invalid format (no maintainer entry found)."); - } - return false; - } - - ++maintainerOffset; - const QDateTime currentDateTime = QDateTime::currentDateTime(); - QDateTime utcDateTime = QDateTime(currentDateTime); - utcDateTime.setTimeSpec(Qt::UTC); - int utcOffsetSeconds = currentDateTime.secsTo(utcDateTime); - QChar sign; - if (utcOffsetSeconds < 0) { - utcOffsetSeconds = -utcOffsetSeconds; - sign = QLatin1Char('-'); - } else { - sign = QLatin1Char('+'); - } - const int utcOffsetMinutes = (utcOffsetSeconds / 60) % 60; - const int utcOffsetHours = utcOffsetSeconds / 3600; - const QString dateString = QString::fromLatin1("%1 %2%3%4") - .arg(currentDateTime.toString(QLatin1String("ddd, dd MMM yyyy hh:mm:ss"))).arg(sign) - .arg(utcOffsetHours, 2, 10, QLatin1Char('0')) - .arg(utcOffsetMinutes, 2, 10, QLatin1Char('0')); - const QString maintainerLine = content.mid(maintainerOffset, eolOffset - maintainerOffset + 1) - .replace(QRegExp(QLatin1String("> [^\\n]*\n")), - QString::fromLocal8Bit("> %1").arg(dateString)); - QString versionLine = content.left(content.indexOf(QLatin1Char('\n'))) - .replace(QRegExp(QLatin1String("\\([a-zA-Z0-9_\\.]+\\)")), - QLatin1Char('(') + version + QLatin1Char(')')); - const QString newEntry = versionLine + QLatin1String("\n * \n\n") - + maintainerLine + QLatin1String("\n\n"); - content.prepend(newEntry); - Core::FileChangeBlocker update(filePath); - Utils::FileSaver saver(filePath); - saver.write(content.toUtf8()); - return saver.finalize(error); -} - -QIcon AbstractDebBasedQt4MaemoTarget::packageManagerIcon(QString *error) const -{ - const QByteArray &base64Icon = controlFileFieldValue(IconFieldName, true); - if (base64Icon.isEmpty()) - return QIcon(); - QPixmap pixmap; - if (!pixmap.loadFromData(QByteArray::fromBase64(base64Icon))) { - if (error) - *error = tr("Invalid icon data in Debian control file."); - return QIcon(); - } - return QIcon(pixmap); -} - -bool AbstractDebBasedQt4MaemoTarget::setPackageManagerIconInternal(const QString &iconFilePath, - QString *error) -{ - const QString filePath = controlFilePath(); - Utils::FileReader reader; - if (!reader.fetch(filePath, error)) - return false; - const QPixmap pixmap(iconFilePath); - if (pixmap.isNull()) { - if (error) - *error = tr("Could not read image file '%1'.").arg(iconFilePath); - return false; - } - - QByteArray iconAsBase64; - QBuffer buffer(&iconAsBase64); - buffer.open(QIODevice::WriteOnly); - if (!pixmap.scaled(packageManagerIconSize()).save(&buffer, - QFileInfo(iconFilePath).suffix().toAscii())) { - if (error) - *error = tr("Could not export image file '%1'.").arg(iconFilePath); - return false; - } - buffer.close(); - iconAsBase64 = iconAsBase64.toBase64(); - QByteArray contents = reader.data(); - const QByteArray iconFieldNameWithColon = IconFieldName + ':'; - const int iconFieldPos = contents.startsWith(iconFieldNameWithColon) - ? 0 : contents.indexOf('\n' + iconFieldNameWithColon); - if (iconFieldPos == -1) { - if (!contents.endsWith('\n')) - contents += '\n'; - contents.append(iconFieldNameWithColon).append(' ').append(iconAsBase64) - .append('\n'); - } else { - const int oldIconStartPos = (iconFieldPos != 0) + iconFieldPos - + iconFieldNameWithColon.length(); - int nextEolPos = contents.indexOf('\n', oldIconStartPos); - while (nextEolPos != -1 && nextEolPos != contents.length() - 1 - && contents.at(nextEolPos + 1) != '\n' - && (contents.at(nextEolPos + 1) == '#' - || std::isspace(contents.at(nextEolPos + 1)))) - nextEolPos = contents.indexOf('\n', nextEolPos + 1); - if (nextEolPos == -1) - nextEolPos = contents.length(); - contents.replace(oldIconStartPos, nextEolPos - oldIconStartPos, - ' ' + iconAsBase64); - } - Core::FileChangeBlocker update(filePath); - Utils::FileSaver saver(filePath); - saver.write(contents); - return saver.finalize(error); -} - -QString AbstractDebBasedQt4MaemoTarget::packageName() const -{ - return QString::fromUtf8(controlFileFieldValue(NameFieldName, false)); -} - -bool AbstractDebBasedQt4MaemoTarget::setPackageNameInternal(const QString &packageName) -{ - const QString oldPackageName = this->packageName(); - - if (!setControlFieldValue(NameFieldName, packageName.toUtf8())) - return false; - if (!setControlFieldValue("Source", packageName.toUtf8())) - return false; - - Utils::FileReader reader; - if (!reader.fetch(changeLogFilePath())) - return false; - QString changelogContents = QString::fromUtf8(reader.data()); - QRegExp pattern(QLatin1String("[^\\s]+( \\(\\d\\.\\d\\.\\d\\))")); - changelogContents.replace(pattern, packageName + QLatin1String("\\1")); - Utils::FileSaver saver(changeLogFilePath()); - saver.write(changelogContents.toUtf8()); - if (!saver.finalize()) - return false; - - if (!reader.fetch(rulesFilePath())) - return false; - QByteArray rulesContents = reader.data(); - const QString oldString = QLatin1String("debian/") + oldPackageName; - const QString newString = QLatin1String("debian/") + packageName; - rulesContents.replace(oldString.toUtf8(), newString.toUtf8()); - Utils::FileSaver rulesSaver(rulesFilePath()); - rulesSaver.write(rulesContents); - return rulesSaver.finalize(); -} - -QString AbstractDebBasedQt4MaemoTarget::packageManagerName() const -{ - return QString::fromUtf8(controlFileFieldValue(packageManagerNameFieldName(), false)); -} - -bool AbstractDebBasedQt4MaemoTarget::setPackageManagerName(const QString &name, - QString *error) -{ - bool success = true; - foreach (Target * const t, project()->targets()) { - AbstractDebBasedQt4MaemoTarget * const target - = qobject_cast(t); - if (target) { - if (!target->setPackageManagerNameInternal(name, error)) - success = false; - } - } - return success; -} - -bool AbstractDebBasedQt4MaemoTarget::setPackageManagerNameInternal(const QString &name, - QString *error) -{ - Q_UNUSED(error); - return setControlFieldValue(packageManagerNameFieldName(), name.toUtf8()); -} - -QString AbstractDebBasedQt4MaemoTarget::shortDescription() const -{ - return QString::fromUtf8(controlFileFieldValue(ShortDescriptionFieldName, false)); -} - -QString AbstractDebBasedQt4MaemoTarget::packageFileName() const -{ - return QString::fromUtf8(controlFileFieldValue(PackageFieldName, false)) - + QLatin1Char('_') + projectVersion() + QLatin1String("_armel.deb"); -} - -bool AbstractDebBasedQt4MaemoTarget::setShortDescriptionInternal(const QString &description) -{ - return setControlFieldValue(ShortDescriptionFieldName, description.toUtf8()); -} - -QString AbstractDebBasedQt4MaemoTarget::debianDirPath() const -{ - return project()->projectDirectory() + QLatin1Char('/') + PackagingDirName - + QLatin1Char('/') + debianDirName(); -} - -QStringList AbstractDebBasedQt4MaemoTarget::debianFiles() const -{ - return QDir(debianDirPath()) - .entryList(QDir::Files, QDir::Name | QDir::IgnoreCase); -} - -QString AbstractDebBasedQt4MaemoTarget::changeLogFilePath() const -{ - return debianDirPath() + QLatin1String("/changelog"); -} - -QString AbstractDebBasedQt4MaemoTarget::controlFilePath() const -{ - return debianDirPath() + QLatin1String("/control"); -} - -QString AbstractDebBasedQt4MaemoTarget::rulesFilePath() const -{ - return debianDirPath() + QLatin1String("/rules"); -} - -QByteArray AbstractDebBasedQt4MaemoTarget::controlFileFieldValue(const QString &key, - bool multiLine) const -{ - QByteArray value; - Utils::FileReader reader; - if (!reader.fetch(controlFilePath())) - return value; - const QByteArray &contents = reader.data(); - const int keyPos = contents.indexOf(key.toUtf8() + ':'); - if (keyPos == -1) - return value; - int valueStartPos = keyPos + key.length() + 1; - int valueEndPos = contents.indexOf('\n', keyPos); - if (valueEndPos == -1) - valueEndPos = contents.count(); - value = contents.mid(valueStartPos, valueEndPos - valueStartPos).trimmed(); - if (multiLine) { - Q_FOREVER { - valueStartPos = valueEndPos + 1; - if (valueStartPos >= contents.count()) - break; - const char firstChar = contents.at(valueStartPos); - if (firstChar == '#' || isspace(firstChar)) { - valueEndPos = contents.indexOf('\n', valueStartPos); - if (valueEndPos == -1) - valueEndPos = contents.count(); - if (firstChar != '#') { - value += contents.mid(valueStartPos, - valueEndPos - valueStartPos).trimmed(); - } - } else { - break; - } - } - } - return value; -} - -bool AbstractDebBasedQt4MaemoTarget::setControlFieldValue(const QByteArray &fieldName, - const QByteArray &fieldValue) -{ - Utils::FileReader reader; - if (!reader.fetch(controlFilePath())) - return false; - QByteArray contents = reader.data(); - if (adaptControlFileField(contents, fieldName, fieldValue)) { - Core::FileChangeBlocker update(controlFilePath()); - Utils::FileSaver saver(controlFilePath()); - saver.write(contents); - return saver.finalize(); - } - return true; -} - -bool AbstractDebBasedQt4MaemoTarget::adaptControlFileField(QByteArray &document, - const QByteArray &fieldName, const QByteArray &newFieldValue) -{ - return adaptTagValue(document, fieldName, newFieldValue, true); -} - -void AbstractDebBasedQt4MaemoTarget::handleTargetAddedSpecial() -{ - if (controlFileFieldValue(IconFieldName, true).isEmpty()) { - // Such a file is created by the mobile wizards. - const QString iconPath = project()->projectDirectory() - + QLatin1Char('/') + project()->displayName() - + QLatin1String("64.png"); - if (QFileInfo(iconPath).exists()) - setPackageManagerIcon(iconPath); - } - - m_filesWatcher->addDirectory(debianDirPath(), Utils::FileSystemWatcher::WatchAllChanges); - m_controlFile = new WatchableFile(controlFilePath(), this); - connect(m_controlFile, SIGNAL(modified()), SIGNAL(controlChanged())); - m_changeLogFile = new WatchableFile(changeLogFilePath(), this); - connect(m_changeLogFile, SIGNAL(modified()), SIGNAL(changeLogChanged())); - Core::FileManager::instance()->addFiles(QList() - << m_controlFile << m_changeLogFile); - connect(m_filesWatcher, SIGNAL(directoryChanged(QString)), this, - SLOT(handleDebianDirContentsChanged())); - handleDebianDirContentsChanged(); - emit controlChanged(); - emit changeLogChanged(); -} - -bool AbstractDebBasedQt4MaemoTarget::targetCanBeRemoved() const -{ - return QFileInfo(debianDirPath()).exists(); -} - -void AbstractDebBasedQt4MaemoTarget::removeTarget() -{ - QString error; - if (!Utils::FileUtils::removeRecursively(debianDirPath(), &error)) - qDebug("%s", qPrintable(error)); -} - -void AbstractDebBasedQt4MaemoTarget::handleDebianDirContentsChanged() -{ - emit debianDirContentsChanged(); -} - -AbstractQt4MaemoTarget::ActionStatus AbstractDebBasedQt4MaemoTarget::createSpecialTemplates() -{ - if (QFileInfo(debianDirPath()).exists()) - return NoActionRequired; - QDir projectDir(project()->projectDirectory()); - QProcess dh_makeProc; - QString error; - const Qt4BuildConfiguration * const bc = qobject_cast(activeBuildConfiguration()); - AbstractMaemoPackageCreationStep::preparePackagingProcess(&dh_makeProc, bc, - projectDir.path() + QLatin1Char('/') + PackagingDirName); - const QString dhMakeDebianDir = projectDir.path() + QLatin1Char('/') - + PackagingDirName + QLatin1String("/debian"); - Utils::FileUtils::removeRecursively(dhMakeDebianDir, &error); - const QStringList dh_makeArgs = QStringList() << QLatin1String("dh_make") - << QLatin1String("-s") << QLatin1String("-n") << QLatin1String("-p") - << (defaultPackageFileName() + QLatin1Char('_') - + AbstractMaemoPackageCreationStep::DefaultVersionNumber); - QtSupport::BaseQtVersion *lqt = activeQt4BuildConfiguration()->qtVersion(); - if (!lqt) { - raiseError(tr("Unable to create Debian templates: No Qt version set")); - return ActionFailed; - } - if (!MaemoGlobal::callMad(dh_makeProc, dh_makeArgs, lqt->qmakeCommand(), true) - || !dh_makeProc.waitForStarted()) { - raiseError(tr("Unable to create Debian templates: dh_make failed (%1)") - .arg(dh_makeProc.errorString())); - return ActionFailed; - } - dh_makeProc.write("\n"); // Needs user input. - dh_makeProc.waitForFinished(-1); - if (dh_makeProc.error() != QProcess::UnknownError - || dh_makeProc.exitCode() != 0) { - raiseError(tr("Unable to create debian templates: dh_make failed (%1)") - .arg(dh_makeProc.errorString())); - return ActionFailed; - } - - if (!QFile::rename(dhMakeDebianDir, debianDirPath())) { - raiseError(tr("Unable to move new debian directory to '%1'.") - .arg(QDir::toNativeSeparators(debianDirPath()))); - Utils::FileUtils::removeRecursively(dhMakeDebianDir, &error); - return ActionFailed; - } - - QDir debianDir(debianDirPath()); - const QStringList &files = debianDir.entryList(QDir::Files); - foreach (const QString &fileName, files) { - if (fileName.endsWith(QLatin1String(".ex"), Qt::CaseInsensitive) - || fileName.compare(QLatin1String("README.debian"), Qt::CaseInsensitive) == 0 - || fileName.compare(QLatin1String("dirs"), Qt::CaseInsensitive) == 0 - || fileName.compare(QLatin1String("docs"), Qt::CaseInsensitive) == 0) { - debianDir.remove(fileName); - } - } - - return adaptRulesFile() && adaptControlFile() - ? ActionSuccessful : ActionFailed; -} - -bool AbstractDebBasedQt4MaemoTarget::adaptRulesFile() -{ - Utils::FileReader reader; - if (!reader.fetch(rulesFilePath())) { - raiseError(reader.errorString()); - return false; - } - QByteArray rulesContents = reader.data(); - const QByteArray comment("# Uncomment this line for use without Qt Creator"); - rulesContents.replace("DESTDIR", "INSTALL_ROOT"); - rulesContents.replace("dh_shlibdeps", "# dh_shlibdeps " + comment); - rulesContents.replace("# Add here commands to configure the package.", - "# qmake PREFIX=/usr" + comment); - rulesContents.replace("$(MAKE)\n", "# $(MAKE) " + comment + '\n'); - - // Would be the right solution, but does not work (on Windows), - // because dpkg-genchanges doesn't know about it (and can't be told). - // rulesContents.replace("dh_builddeb", "dh_builddeb --destdir=."); - - Utils::FileSaver saver(rulesFilePath()); - saver.write(rulesContents); - if (!saver.finalize()) { - raiseError(saver.errorString()); - return false; - } - return true; -} - -bool AbstractDebBasedQt4MaemoTarget::adaptControlFile() -{ - Utils::FileReader reader; - if (!reader.fetch(controlFilePath())) { - raiseError(reader.errorString()); - return false; - } - QByteArray controlContents = reader.data(); - - adaptControlFileField(controlContents, "Section", defaultSection()); - adaptControlFileField(controlContents, "Priority", "optional"); - adaptControlFileField(controlContents, packageManagerNameFieldName(), - project()->displayName().toUtf8()); - const int buildDependsOffset = controlContents.indexOf("Build-Depends:"); - if (buildDependsOffset == -1) { - qDebug("Unexpected: no Build-Depends field in debian control file."); - } else { - int buildDependsNewlineOffset - = controlContents.indexOf('\n', buildDependsOffset); - if (buildDependsNewlineOffset == -1) { - controlContents += '\n'; - buildDependsNewlineOffset = controlContents.length() - 1; - } - controlContents.insert(buildDependsNewlineOffset, - ", libqt4-dev"); - } - - addAdditionalControlFileFields(controlContents); - Utils::FileSaver saver(controlFilePath()); - saver.write(controlContents); - if (!saver.finalize()) { - raiseError(saver.errorString()); - return false; - } - return true; -} - -bool AbstractDebBasedQt4MaemoTarget::initAdditionalPackagingSettingsFromOtherTarget() -{ - foreach (const Target * const t, project()->targets()) { - const AbstractDebBasedQt4MaemoTarget *target - = qobject_cast(t); - if (target && target != this) { - return setControlFieldValue(IconFieldName, - target->controlFileFieldValue(IconFieldName, true)); - } - } - return true; -} - -QStringList AbstractDebBasedQt4MaemoTarget::packagingFilePaths() const -{ - QStringList filePaths; - const QString parentDir = debianDirPath(); - foreach (const QString &fileName, debianFiles()) - filePaths << parentDir + QLatin1Char('/') + fileName; - return filePaths; -} - -QString AbstractDebBasedQt4MaemoTarget::defaultPackageFileName() const -{ - QString packageName = project()->displayName().toLower(); - - // We also replace dots, because OVI store chokes on them. - const QRegExp legalLetter(QLatin1String("[a-z0-9+-]"), Qt::CaseSensitive, - QRegExp::WildcardUnix); - - for (int i = 0; i < packageName.length(); ++i) { - if (!legalLetter.exactMatch(packageName.mid(i, 1))) - packageName[i] = QLatin1Char('-'); - } - return packageName; -} - -bool AbstractDebBasedQt4MaemoTarget::setPackageManagerIcon(const QString &iconFilePath, - QString *error) -{ - bool success = true; - foreach (Target * const target, project()->targets()) { - AbstractDebBasedQt4MaemoTarget* const maemoTarget - = qobject_cast(target); - if (maemoTarget) { - if (!maemoTarget->setPackageManagerIconInternal(iconFilePath, error)) - success = false; - } - } - return success; -} - -AbstractRpmBasedQt4MaemoTarget::AbstractRpmBasedQt4MaemoTarget(Qt4Project *parent, - const QString &id) : AbstractQt4MaemoTarget(parent, id) -{ -} - -AbstractRpmBasedQt4MaemoTarget::~AbstractRpmBasedQt4MaemoTarget() -{ -} - -QString AbstractRpmBasedQt4MaemoTarget::specFilePath() const -{ - const QLatin1Char sep('/'); - return project()->projectDirectory() + sep + PackagingDirName + sep - + specFileName(); -} - -QString AbstractRpmBasedQt4MaemoTarget::projectVersion(QString *error) const -{ - return QString::fromUtf8(getValueForTag(VersionTag, error)); -} - -bool AbstractRpmBasedQt4MaemoTarget::setProjectVersionInternal(const QString &version, - QString *error) -{ - return setValueForTag(VersionTag, version.toUtf8(), error); -} - -QString AbstractRpmBasedQt4MaemoTarget::packageName() const -{ - return QString::fromUtf8(getValueForTag(NameTag, 0)); -} - -bool AbstractRpmBasedQt4MaemoTarget::setPackageNameInternal(const QString &name) -{ - return setValueForTag(NameTag, name.toUtf8(), 0); -} - -QString AbstractRpmBasedQt4MaemoTarget::shortDescription() const -{ - return QString::fromUtf8(getValueForTag(SummaryTag, 0)); -} - -QString AbstractRpmBasedQt4MaemoTarget::packageFileName() const -{ - QtSupport::BaseQtVersion *lqt = activeQt4BuildConfiguration()->qtVersion(); - if (!lqt) - return QString(); - return packageName() + QLatin1Char('-') + projectVersion() + QLatin1Char('-') - + QString::fromUtf8(getValueForTag(ReleaseTag, 0)) + QLatin1Char('.') - + MaemoGlobal::architecture(lqt->qmakeCommand()) - + QLatin1String(".rpm"); -} - -bool AbstractRpmBasedQt4MaemoTarget::setShortDescriptionInternal(const QString &description) -{ - return setValueForTag(SummaryTag, description.toUtf8(), 0); -} - -AbstractQt4MaemoTarget::ActionStatus AbstractRpmBasedQt4MaemoTarget::createSpecialTemplates() -{ - if (QFileInfo(specFilePath()).exists()) - return NoActionRequired; - QByteArray initialContent( - "Name: %%name%%\n" - "Summary: \n" - "Version: 0.0.1\n" - "Release: 1\n" - "License: \n" - "Group: \n" - "%description\n" - "\n" - "\n" - "%prep\n" - "%setup -q\n" - "\n" - "%build\n" - "# You can leave this empty for use with Qt Creator." - "\n" - "%install\n" - "rm -rf %{buildroot}\n" - "make INSTALL_ROOT=%{buildroot} install\n" - "\n" - "%clean\n" - "rm -rf %{buildroot}\n" - "\n" - "BuildRequires: \n" - "# %define _unpackaged_files_terminate_build 0\n" - "%files\n" - "%defattr(-,root,root,-)" - "/usr\n" - "/opt\n" - "# Add additional files to be included in the package here.\n" - "%pre\n" - "# Add pre-install scripts here." - "%post\n" - "/sbin/ldconfig # For shared libraries\n" - "%preun\n" - "# Add pre-uninstall scripts here." - "%postun\n" - "# Add post-uninstall scripts here." - ); - initialContent.replace("%%name%%", project()->displayName().toUtf8()); - Utils::FileSaver saver(specFilePath()); - saver.write(initialContent); - return saver.finalize() ? ActionSuccessful : ActionFailed; -} - -void AbstractRpmBasedQt4MaemoTarget::handleTargetAddedSpecial() -{ - m_specFile = new WatchableFile(specFilePath(), this); - connect(m_specFile, SIGNAL(modified()), SIGNAL(specFileChanged())); - Core::FileManager::instance()->addFile(m_specFile); - emit specFileChanged(); -} - -bool AbstractRpmBasedQt4MaemoTarget::targetCanBeRemoved() const -{ - return QFileInfo(specFilePath()).exists(); -} - -void AbstractRpmBasedQt4MaemoTarget::removeTarget() -{ - QFile::remove(specFilePath()); -} - -bool AbstractRpmBasedQt4MaemoTarget::initAdditionalPackagingSettingsFromOtherTarget() -{ - // Nothing to do here for now. - return true; -} - -QByteArray AbstractRpmBasedQt4MaemoTarget::getValueForTag(const QByteArray &tag, - QString *error) const -{ - Utils::FileReader reader; - if (!reader.fetch(specFilePath(), error)) - return QByteArray(); - const QByteArray &content = reader.data(); - const QByteArray completeTag = tag.toLower() + ':'; - int index = content.toLower().indexOf(completeTag); - if (index == -1) - return QByteArray(); - index += completeTag.count(); - int endIndex = content.indexOf('\n', index); - if (endIndex == -1) - endIndex = content.count(); - return content.mid(index, endIndex - index).trimmed(); -} - -bool AbstractRpmBasedQt4MaemoTarget::setValueForTag(const QByteArray &tag, - const QByteArray &value, QString *error) -{ - Utils::FileReader reader; - if (!reader.fetch(specFilePath(), error)) - return false; - QByteArray content = reader.data(); - if (adaptTagValue(content, tag, value, false)) { - Utils::FileSaver saver(specFilePath()); - saver.write(content); - return saver.finalize(error); - } - return true; -} - -Qt4Maemo5Target::Qt4Maemo5Target(Qt4Project *parent, const QString &id) - : AbstractDebBasedQt4MaemoTarget(parent, id) -{ - setDisplayName(defaultDisplayName()); -} - -Qt4Maemo5Target::~Qt4Maemo5Target() {} - -QString Qt4Maemo5Target::defaultDisplayName() -{ - return QApplication::translate("Qt4ProjectManager::Qt4Target", "Maemo5", - "Qt4 Maemo5 target display name"); -} - -void Qt4Maemo5Target::addAdditionalControlFileFields(QByteArray &controlContents) -{ - Q_UNUSED(controlContents); -} - -QString Qt4Maemo5Target::debianDirName() const -{ - return QLatin1String("debian_fremantle"); -} - -QByteArray Qt4Maemo5Target::packageManagerNameFieldName() const -{ - return "XB-Maemo-Display-Name"; -} - -QSize Qt4Maemo5Target::packageManagerIconSize() const -{ - return QSize(48, 48); -} - -QByteArray Qt4Maemo5Target::defaultSection() const -{ - return "user/hidden"; -} - -Qt4HarmattanTarget::Qt4HarmattanTarget(Qt4Project *parent, const QString &id) - : AbstractDebBasedQt4MaemoTarget(parent, id) -{ - setDisplayName(defaultDisplayName()); -} - -Qt4HarmattanTarget::~Qt4HarmattanTarget() {} - -QString Qt4HarmattanTarget::defaultDisplayName() -{ - return QApplication::translate("Qt4ProjectManager::Qt4Target", "Harmattan", - "Qt4 Harmattan target display name"); -} - -QString Qt4HarmattanTarget::aegisManifestFileName() -{ - return QLatin1String("manifest.aegis"); -} - -void Qt4HarmattanTarget::handleTargetAddedSpecial() -{ - AbstractDebBasedQt4MaemoTarget::handleTargetAddedSpecial(); - QFile aegisFile(debianDirPath() + QLatin1Char('/') + aegisManifestFileName()); - if (!aegisFile.exists()) - aegisFile.open(QIODevice::WriteOnly); -} - -void Qt4HarmattanTarget::addAdditionalControlFileFields(QByteArray &controlContents) -{ - Q_UNUSED(controlContents); -} - -QString Qt4HarmattanTarget::debianDirName() const -{ - return QLatin1String("debian_harmattan"); -} - -QByteArray Qt4HarmattanTarget::packageManagerNameFieldName() const -{ - return "XSBC-Maemo-Display-Name"; -} - -QSize Qt4HarmattanTarget::packageManagerIconSize() const -{ - return QSize(64, 64); -} - -QByteArray Qt4HarmattanTarget::defaultSection() const -{ - return "user/other"; -} - - -Qt4MeegoTarget::Qt4MeegoTarget(Qt4Project *parent, const QString &id) - : AbstractRpmBasedQt4MaemoTarget(parent, id) -{ - setDisplayName(defaultDisplayName()); -} - -Qt4MeegoTarget::~Qt4MeegoTarget() {} - -QString Qt4MeegoTarget::defaultDisplayName() -{ - return QApplication::translate("Qt4ProjectManager::Qt4Target", - "Meego", "Qt4 Meego target display name"); -} - -QString Qt4MeegoTarget::specFileName() const -{ - return QLatin1String("meego.spec"); -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/qt4maemotarget.h b/src/plugins/remotelinux/qt4maemotarget.h deleted file mode 100644 index 1aac85fbf7b..00000000000 --- a/src/plugins/remotelinux/qt4maemotarget.h +++ /dev/null @@ -1,296 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef QT4MAEMOTARGET_H -#define QT4MAEMOTARGET_H - -#include - -#include -#include -#include - -QT_FORWARD_DECLARE_CLASS(QFile) - -namespace Qt4ProjectManager { -class Qt4Project; -class Qt4BuildConfigurationFactory; -} -namespace Utils { class FileSystemWatcher; } - -namespace RemoteLinux { -namespace Internal { -class Qt4MaemoDeployConfigurationFactory; -class WatchableFile; - -class AbstractQt4MaemoTarget : public Qt4ProjectManager::Qt4BaseTarget -{ - friend class Qt4MaemoTargetFactory; - Q_OBJECT -public: - explicit AbstractQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, - const QString &id); - virtual ~AbstractQt4MaemoTarget(); - - ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const; - void createApplicationProFiles(); - QList runConfigurationsForNode(ProjectExplorer::Node *n); - QList possibleToolChains(ProjectExplorer::BuildConfiguration *bc) const; - - virtual bool allowsRemoteMounts() const = 0; - virtual bool allowsPackagingDisabling() const = 0; - virtual bool allowsQmlDebugging() const = 0; - - virtual QString projectVersion(QString *error = 0) const = 0; - virtual QString packageName() const = 0; - virtual QString shortDescription() const = 0; - virtual QString packageFileName() const = 0; - - bool setProjectVersion(const QString &version, QString *error = 0); - bool setPackageName(const QString &packageName); - bool setShortDescription(const QString &description); - -protected: - enum ActionStatus { NoActionRequired, ActionSuccessful, ActionFailed }; - - void raiseError(const QString &reason); - QSharedPointer openFile(const QString &filePath, - QIODevice::OpenMode mode, QString *error) const; - - Utils::FileSystemWatcher* const m_filesWatcher; - -private slots: - void handleTargetAdded(ProjectExplorer::Target *target); - void handleFromMapFinished(); - void handleTargetToBeRemoved(ProjectExplorer::Target *target); - -private: - virtual bool setProjectVersionInternal(const QString &version, - QString *error = 0) = 0; - virtual bool setPackageNameInternal(const QString &packageName) = 0; - virtual bool setShortDescriptionInternal(const QString &description) = 0; - virtual ActionStatus createSpecialTemplates() = 0; - virtual void handleTargetAddedSpecial() = 0; - virtual bool targetCanBeRemoved() const = 0; - virtual void removeTarget() = 0; - virtual QStringList packagingFilePaths() const = 0; - - ActionStatus createTemplates(); - bool initPackagingSettingsFromOtherTarget(); - virtual bool initAdditionalPackagingSettingsFromOtherTarget() = 0; - - Qt4ProjectManager::Qt4BuildConfigurationFactory *m_buildConfigurationFactory; - bool m_isInitialized; -}; - - -class AbstractDebBasedQt4MaemoTarget : public AbstractQt4MaemoTarget -{ - Q_OBJECT -public: - AbstractDebBasedQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, - const QString &id); - ~AbstractDebBasedQt4MaemoTarget(); - - QString debianDirPath() const; - QStringList debianFiles() const; - - virtual QString debianDirName() const = 0; - virtual QString projectVersion(QString *error = 0) const; - virtual QString packageName() const; - virtual QString shortDescription() const; - virtual QString packageFileName() const; - - bool setPackageManagerIcon(const QString &iconFilePath, QString *error = 0); - QIcon packageManagerIcon(QString *error = 0) const; - bool setPackageManagerName(const QString &name, QString *error = 0); - QString packageManagerName() const; - - virtual QSize packageManagerIconSize() const = 0; - -signals: - void debianDirContentsChanged(); - void changeLogChanged(); - void controlChanged(); - -protected: - virtual void handleTargetAddedSpecial(); - bool adaptControlFileField(QByteArray &document, const QByteArray &fieldName, - const QByteArray &newFieldValue); - -private slots: - void handleDebianDirContentsChanged(); - -private: - virtual bool setProjectVersionInternal(const QString &version, - QString *error = 0); - virtual bool setPackageNameInternal(const QString &packageName); - virtual bool setShortDescriptionInternal(const QString &description); - - virtual ActionStatus createSpecialTemplates(); - virtual bool targetCanBeRemoved() const; - virtual void removeTarget(); - virtual bool initAdditionalPackagingSettingsFromOtherTarget(); - virtual QStringList packagingFilePaths() const; - - virtual void addAdditionalControlFileFields(QByteArray &controlContents) = 0; - virtual QByteArray packageManagerNameFieldName() const = 0; - virtual QByteArray defaultSection() const = 0; - - QString changeLogFilePath() const; - QString controlFilePath() const; - QString rulesFilePath() const; - QByteArray controlFileFieldValue(const QString &key, bool multiLine) const; - bool setControlFieldValue(const QByteArray &fieldName, - const QByteArray &fieldValue); - bool adaptRulesFile(); - bool adaptControlFile(); - bool setPackageManagerIconInternal(const QString &iconFilePath, - QString *error = 0); - QString defaultPackageFileName() const; - bool setPackageManagerNameInternal(const QString &name, QString *error = 0); - - WatchableFile *m_controlFile; - WatchableFile *m_changeLogFile; -}; - - -class AbstractRpmBasedQt4MaemoTarget : public AbstractQt4MaemoTarget -{ - Q_OBJECT -public: - AbstractRpmBasedQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, - const QString &id); - ~AbstractRpmBasedQt4MaemoTarget(); - - virtual bool allowsRemoteMounts() const { return false; } - virtual bool allowsPackagingDisabling() const { return false; } - virtual bool allowsQmlDebugging() const { return false; } - - virtual QString projectVersion(QString *error = 0) const; - virtual QString packageName() const; - virtual QString shortDescription() const; - virtual QString packageFileName() const; - - QString specFilePath() const; - -signals: - void specFileChanged(); - -private: - virtual bool setProjectVersionInternal(const QString &version, - QString *error = 0); - virtual bool setPackageNameInternal(const QString &packageName); - virtual bool setShortDescriptionInternal(const QString &description); - virtual ActionStatus createSpecialTemplates(); - virtual void handleTargetAddedSpecial(); - virtual bool targetCanBeRemoved() const; - virtual void removeTarget(); - virtual bool initAdditionalPackagingSettingsFromOtherTarget(); - virtual QStringList packagingFilePaths() const { return QStringList(specFilePath()); } - - virtual QString specFileName() const = 0; - - QByteArray getValueForTag(const QByteArray &tag, QString *error) const; - bool setValueForTag(const QByteArray &tag, const QByteArray &value, - QString *error); - - WatchableFile *m_specFile; -}; - - -class Qt4Maemo5Target : public AbstractDebBasedQt4MaemoTarget -{ - Q_OBJECT -public: - explicit Qt4Maemo5Target(Qt4ProjectManager::Qt4Project *parent, - const QString &id); - virtual ~Qt4Maemo5Target(); - - virtual bool allowsRemoteMounts() const { return true; } - virtual bool allowsPackagingDisabling() const { return true; } - virtual bool allowsQmlDebugging() const { return false; } - - virtual QSize packageManagerIconSize() const; - - static QString defaultDisplayName(); - -private: - virtual void addAdditionalControlFileFields(QByteArray &controlContents); - virtual QString debianDirName() const; - virtual QByteArray packageManagerNameFieldName() const; - virtual QByteArray defaultSection() const; -}; - - -class Qt4HarmattanTarget : public AbstractDebBasedQt4MaemoTarget -{ - Q_OBJECT -public: - explicit Qt4HarmattanTarget(Qt4ProjectManager::Qt4Project *parent, - const QString &id); - virtual ~Qt4HarmattanTarget(); - - virtual bool allowsRemoteMounts() const { return false; } - virtual bool allowsPackagingDisabling() const { return false; } - virtual bool allowsQmlDebugging() const { return true; } - - virtual QSize packageManagerIconSize() const; - - static QString defaultDisplayName(); - static QString aegisManifestFileName(); - -private: - void handleTargetAddedSpecial(); - virtual void addAdditionalControlFileFields(QByteArray &controlContents); - virtual QString debianDirName() const; - virtual QByteArray packageManagerNameFieldName() const; - virtual QByteArray defaultSection() const; -}; - - -class Qt4MeegoTarget : public AbstractRpmBasedQt4MaemoTarget -{ - Q_OBJECT -public: - explicit Qt4MeegoTarget(Qt4ProjectManager::Qt4Project *parent, - const QString &id); - virtual ~Qt4MeegoTarget(); - static QString defaultDisplayName(); -private: - virtual QString specFileName() const; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // QT4MAEMOTARGET_H diff --git a/src/plugins/remotelinux/qt4maemotargetfactory.cpp b/src/plugins/remotelinux/qt4maemotargetfactory.cpp deleted file mode 100644 index afacc185cf4..00000000000 --- a/src/plugins/remotelinux/qt4maemotargetfactory.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "qt4maemotargetfactory.h" -#include "maemoglobal.h" -#include "maemopackagecreationstep.h" -#include "remotelinuxrunconfiguration.h" -#include "qt4maemodeployconfiguration.h" -#include "qt4maemotarget.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Qt4ProjectManager; -using namespace Qt4ProjectManager::Constants; -using ProjectExplorer::idFromMap; - -namespace RemoteLinux { -namespace Internal { - -// ------------------------------------------------------------------------- -// Qt4MaemoTargetFactory -// ------------------------------------------------------------------------- -Qt4MaemoTargetFactory::Qt4MaemoTargetFactory(QObject *parent) : - Qt4BaseTargetFactory(parent) -{ - connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList)), - this, SIGNAL(supportedTargetIdsChanged())); -} - -Qt4MaemoTargetFactory::~Qt4MaemoTargetFactory() -{ -} - -bool Qt4MaemoTargetFactory::supportsTargetId(const QString &id) const -{ - return MaemoGlobal::isMaemoTargetId(id); -} - -QStringList Qt4MaemoTargetFactory::supportedTargetIds(ProjectExplorer::Project *parent) const -{ - QStringList targetIds; - if (parent && !qobject_cast(parent)) - return targetIds; - if (!QtSupport::QtVersionManager::instance()->versionsForTargetId(QLatin1String(MAEMO5_DEVICE_TARGET_ID)).isEmpty()) - targetIds << QLatin1String(MAEMO5_DEVICE_TARGET_ID); - if (!QtSupport::QtVersionManager::instance()->versionsForTargetId(QLatin1String(HARMATTAN_DEVICE_TARGET_ID)).isEmpty()) - targetIds << QLatin1String(HARMATTAN_DEVICE_TARGET_ID); - if (!QtSupport::QtVersionManager::instance()->versionsForTargetId(QLatin1String(MEEGO_DEVICE_TARGET_ID)).isEmpty()) - targetIds << QLatin1String(MEEGO_DEVICE_TARGET_ID); - return targetIds; -} - -QString Qt4MaemoTargetFactory::displayNameForId(const QString &id) const -{ - if (id == QLatin1String(MAEMO5_DEVICE_TARGET_ID)) - return Qt4Maemo5Target::defaultDisplayName(); - else if (id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID)) - return Qt4HarmattanTarget::defaultDisplayName(); - else if (id == QLatin1String(MEEGO_DEVICE_TARGET_ID)) - return Qt4MeegoTarget::defaultDisplayName(); - return QString(); -} - -QIcon Qt4MaemoTargetFactory::iconForId(const QString &id) const -{ - Q_UNUSED(id) - return QIcon(":/projectexplorer/images/MaemoDevice.png"); -} - -bool Qt4MaemoTargetFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const -{ - if (!qobject_cast(parent)) - return false; - return supportsTargetId(id); -} - -bool Qt4MaemoTargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const -{ - return canCreate(parent, idFromMap(map)); -} - -ProjectExplorer::Target *Qt4MaemoTargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - - const QString id = idFromMap(map); - AbstractQt4MaemoTarget *target = 0; - Qt4Project *qt4project = static_cast(parent); - if (id == QLatin1String(MAEMO5_DEVICE_TARGET_ID)) - target = new Qt4Maemo5Target(qt4project, QLatin1String("transient ID")); - else if (id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID)) - target = new Qt4HarmattanTarget(qt4project, QLatin1String("transient ID")); - else if (id == QLatin1String(MEEGO_DEVICE_TARGET_ID)) - target = new Qt4MeegoTarget(qt4project, QLatin1String("transient ID")); - if (target->fromMap(map)) - return target; - delete target; - return 0; -} - -QString Qt4MaemoTargetFactory::buildNameForId(const QString &id) const -{ - if (id == QLatin1String(MAEMO5_DEVICE_TARGET_ID)) - return QLatin1String("maemo"); - else if (id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID)) - return QLatin1String("harmattan"); - else if (id == QLatin1String(MEEGO_DEVICE_TARGET_ID)) - return QLatin1String("meego"); - else - return QString(); -} - -QString Qt4MaemoTargetFactory::shadowBuildDirectory(const QString &profilePath, const QString &id, const QString &suffix) -{ -#if defined(Q_OS_WIN) - // No shadowbuilding for windows! - Q_UNUSED(id); - Q_UNUSED(suffix); - return QFileInfo(profilePath).absolutePath(); -#else - return Qt4BaseTargetFactory::shadowBuildDirectory(profilePath, id, suffix); -#endif -} - -QSet Qt4MaemoTargetFactory::targetFeatures(const QString & /*id*/) const -{ - QSet features; - features << Qt4ProjectManager::Constants::MOBILE_TARGETFEATURE_ID; -#ifndef Q_OS_WIN - features << Qt4ProjectManager::Constants::SHADOWBUILD_TARGETFEATURE_ID; -#endif - // how to check check whether the component set is really installed? - features << Qt4ProjectManager::Constants::QTQUICKCOMPONENTS_MEEGO_TARGETFEATURE_ID; - return features; -} - -ProjectExplorer::Target *Qt4MaemoTargetFactory::create(ProjectExplorer::Project *parent, const QString &id) -{ - if (!canCreate(parent, id)) - return 0; - - QList knownVersions = QtSupport::QtVersionManager::instance()->versionsForTargetId(id); - if (knownVersions.isEmpty()) - return 0; - - QtSupport::BaseQtVersion *qtVersion = knownVersions.first(); - QtSupport::BaseQtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); - - QList infos; - infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString())); - infos.append(BuildConfigurationInfo(qtVersion, config ^ QtSupport::BaseQtVersion::DebugBuild, QString(), QString())); - - return create(parent, id, infos); -} - -ProjectExplorer::Target *Qt4MaemoTargetFactory::create(ProjectExplorer::Project *parent, - const QString &id, const QList &infos) -{ - if (!canCreate(parent, id)) - return 0; - - AbstractQt4MaemoTarget *target = 0; - QStringList deployConfigIds; - if (id == QLatin1String(MAEMO5_DEVICE_TARGET_ID)) { - target = new Qt4Maemo5Target(static_cast(parent), id); - deployConfigIds << Qt4MaemoDeployConfiguration::fremantleWithPackagingId() - << Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId(); - } else if (id == QLatin1String(HARMATTAN_DEVICE_TARGET_ID)) { - target = new Qt4HarmattanTarget(static_cast(parent), id); - deployConfigIds << Qt4MaemoDeployConfiguration::harmattanId(); - } else if (id == QLatin1String(MEEGO_DEVICE_TARGET_ID)) { - target = new Qt4MeegoTarget(static_cast(parent), id); - deployConfigIds << Qt4MaemoDeployConfiguration::meegoId(); - } - Q_ASSERT(target); - - foreach (const BuildConfigurationInfo &info, infos) - target->addQt4BuildConfiguration(msgBuildConfigurationName(info), QString(), - info.version, info.buildConfig, - info.additionalArguments, info.directory, info.importing); - - foreach (const QString &deployConfigId, deployConfigIds) { - target->addDeployConfiguration(target->createDeployConfiguration(deployConfigId)); - } - target->createApplicationProFiles(); - if (target->runConfigurations().isEmpty()) - target->addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(target)); - return target; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/qt4maemotargetfactory.h b/src/plugins/remotelinux/qt4maemotargetfactory.h deleted file mode 100644 index 592131d5039..00000000000 --- a/src/plugins/remotelinux/qt4maemotargetfactory.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef QT4MAEMOTARGETFACTORY_H -#define QT4MAEMOTARGETFACTORY_H - -#include - -namespace RemoteLinux { -namespace Internal { - -class Qt4MaemoTargetFactory : public Qt4ProjectManager::Qt4BaseTargetFactory -{ - Q_OBJECT -public: - Qt4MaemoTargetFactory(QObject *parent = 0); - ~Qt4MaemoTargetFactory(); - - QStringList supportedTargetIds(ProjectExplorer::Project *parent) const; - QString displayNameForId(const QString &id) const; - QIcon iconForId(const QString &id) const; - - bool canCreate(ProjectExplorer::Project *parent, const QString &id) const; - bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const; - ProjectExplorer::Target *restore(ProjectExplorer::Project *parent, const QVariantMap &map); - - QString shadowBuildDirectory(const QString &profilePath, const QString &id, const QString &suffix); - QString buildNameForId(const QString &id) const; - - bool supportsTargetId(const QString &id) const; - - ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id); - ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id, - const QList &infos); - - QSet targetFeatures(const QString &id) const; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // QT4MAEMOTARGETFACTORY_H diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index 351be477cc0..a616927a1e3 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -7,46 +7,6 @@ include(remotelinux_dependencies.pri) HEADERS += \ remotelinuxplugin.h \ remotelinux_export.h \ - maemoconstants.h \ - maemorunconfigurationwidget.h \ - maemoruncontrol.h \ - maemorunfactories.h \ - maemosettingspages.h \ - maemotoolchain.h \ - maemopackagecreationstep.h \ - maemopackagecreationfactory.h \ - maemopackagecreationwidget.h \ - maemoqemumanager.h \ - maemodeploystepfactory.h \ - maemoglobal.h \ - maemosshrunner.h \ - maemodebugsupport.h \ - maemoremotemountsmodel.h \ - maemomountspecification.h \ - maemoremotemounter.h \ - maemopublishingwizardfactories.h \ - maemopublishingbuildsettingspagefremantlefree.h \ - maemopublishingfileselectiondialog.h \ - maemopublishedprojectmodel.h \ - maemopublishinguploadsettingspagefremantlefree.h \ - maemopublishingwizardfremantlefree.h \ - maemopublishingresultpagefremantlefree.h \ - maemopublisherfremantlefree.h \ - maemoqemuruntime.h \ - maemoqemuruntimeparser.h \ - maemoqemusettingswidget.h \ - maemoqemusettings.h \ - qt4maemotargetfactory.h \ - qt4maemotarget.h \ - qt4maemodeployconfiguration.h \ - maemodeviceconfigwizard.h \ - maemodeployconfigurationwidget.h \ - maemoinstalltosysrootstep.h \ - maemodeploymentmounter.h \ - maemopackageinstaller.h \ - maemoremotecopyfacility.h \ - maemoqtversionfactory.h \ - maemoqtversion.h \ linuxdeviceconfiguration.h \ linuxdeviceconfigurations.h \ remotelinuxrunconfiguration.h \ @@ -54,8 +14,6 @@ HEADERS += \ publickeydeploymentdialog.h \ genericlinuxdeviceconfigurationwizard.h \ genericlinuxdeviceconfigurationfactory.h \ - maddedeviceconfigurationfactory.h \ - maemorunconfiguration.h \ remotelinuxrunconfigurationwidget.h \ remotelinuxrunconfigurationfactory.h \ remotelinuxapplicationrunner.h \ @@ -69,9 +27,7 @@ HEADERS += \ deploymentinfo.h \ abstractremotelinuxdeploystep.h \ genericdirectuploadstep.h \ - maddeuploadandinstallpackagesteps.h \ uploadandinstalltarpackagestep.h \ - maemodeploybymountsteps.h \ abstractremotelinuxdeployservice.h \ abstractuploadandinstallpackageservice.h \ genericdirectuploadservice.h \ @@ -83,7 +39,6 @@ HEADERS += \ remotelinuxpackageinstaller.h \ packageuploader.h \ linuxdevicetester.h \ - maddedevicetester.h \ remotelinux_constants.h \ linuxdevicetestdialog.h \ remotelinuxprocesslist.h \ @@ -103,44 +58,6 @@ HEADERS += \ SOURCES += \ remotelinuxplugin.cpp \ - maemorunconfigurationwidget.cpp \ - maemoruncontrol.cpp \ - maemorunfactories.cpp \ - maemosettingspages.cpp \ - maemotoolchain.cpp \ - maemopackagecreationstep.cpp \ - maemopackagecreationfactory.cpp \ - maemopackagecreationwidget.cpp \ - maemoqemumanager.cpp \ - maemodeploystepfactory.cpp \ - maemoglobal.cpp \ - maemosshrunner.cpp \ - maemodebugsupport.cpp \ - maemoremotemountsmodel.cpp \ - maemomountspecification.cpp \ - maemoremotemounter.cpp \ - maemopublishingwizardfactories.cpp \ - maemopublishingbuildsettingspagefremantlefree.cpp \ - maemopublishingfileselectiondialog.cpp \ - maemopublishedprojectmodel.cpp \ - maemopublishinguploadsettingspagefremantlefree.cpp \ - maemopublishingwizardfremantlefree.cpp \ - maemopublishingresultpagefremantlefree.cpp \ - maemopublisherfremantlefree.cpp \ - maemoqemuruntimeparser.cpp \ - maemoqemusettingswidget.cpp \ - maemoqemusettings.cpp \ - qt4maemotargetfactory.cpp \ - qt4maemotarget.cpp \ - qt4maemodeployconfiguration.cpp \ - maemodeviceconfigwizard.cpp \ - maemodeployconfigurationwidget.cpp \ - maemoinstalltosysrootstep.cpp \ - maemodeploymentmounter.cpp \ - maemopackageinstaller.cpp \ - maemoremotecopyfacility.cpp \ - maemoqtversionfactory.cpp \ - maemoqtversion.cpp \ linuxdeviceconfiguration.cpp \ linuxdeviceconfigurations.cpp \ remotelinuxrunconfiguration.cpp \ @@ -148,8 +65,6 @@ SOURCES += \ publickeydeploymentdialog.cpp \ genericlinuxdeviceconfigurationwizard.cpp \ genericlinuxdeviceconfigurationfactory.cpp \ - maddedeviceconfigurationfactory.cpp \ - maemorunconfiguration.cpp \ remotelinuxrunconfigurationwidget.cpp \ remotelinuxrunconfigurationfactory.cpp \ remotelinuxapplicationrunner.cpp \ @@ -162,9 +77,7 @@ SOURCES += \ deploymentinfo.cpp \ abstractremotelinuxdeploystep.cpp \ genericdirectuploadstep.cpp \ - maddeuploadandinstallpackagesteps.cpp \ uploadandinstalltarpackagestep.cpp \ - maemodeploybymountsteps.cpp \ abstractremotelinuxdeployservice.cpp \ abstractuploadandinstallpackageservice.cpp \ genericdirectuploadservice.cpp \ @@ -176,7 +89,6 @@ SOURCES += \ remotelinuxpackageinstaller.cpp \ packageuploader.cpp \ linuxdevicetester.cpp \ - maddedevicetester.cpp \ linuxdevicetestdialog.cpp \ remotelinuxprocesslist.cpp \ remotelinuxprocessesdialog.cpp \ @@ -194,18 +106,6 @@ SOURCES += \ profilesupdatedialog.cpp FORMS += \ - maemopackagecreationwidget.ui \ - maemopublishingbuildsettingspagefremantlefree.ui \ - maemopublishingfileselectiondialog.ui \ - maemopublishinguploadsettingspagefremantlefree.ui \ - maemopublishingresultpagefremantlefree.ui \ - maemoqemusettingswidget.ui \ - maemodeviceconfigwizardstartpage.ui \ - maemodeviceconfigwizardpreviouskeysetupcheckpage.ui \ - maemodeviceconfigwizardreusekeyscheckpage.ui \ - maemodeviceconfigwizardkeycreationpage.ui \ - maemodeviceconfigwizardkeydeploymentpage.ui \ - maemodeployconfigurationwidget.ui \ linuxdevicefactoryselectiondialog.ui \ genericlinuxdeviceconfigurationwizardsetuppage.ui \ linuxdevicetestdialog.ui \ @@ -215,8 +115,5 @@ FORMS += \ remotelinuxdeployconfigurationwidget.ui \ profilesupdatedialog.ui -RESOURCES += qt-maemo.qrc DEFINES += QT_NO_CAST_TO_ASCII DEFINES += REMOTELINUX_LIBRARY - - diff --git a/src/plugins/remotelinux/remotelinuxdeployconfigurationwidget.h b/src/plugins/remotelinux/remotelinuxdeployconfigurationwidget.h index 67924fe34aa..45af354ef72 100644 --- a/src/plugins/remotelinux/remotelinuxdeployconfigurationwidget.h +++ b/src/plugins/remotelinux/remotelinuxdeployconfigurationwidget.h @@ -58,7 +58,7 @@ public: DeployableFilesPerProFile *currentModel() const; signals: - void currentModelChanged(const DeployableFilesPerProFile *proFileInfo); + void currentModelChanged(const RemoteLinux::DeployableFilesPerProFile *proFileInfo); private slots: void handleModelListToBeReset(); diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index a2e31498f3e..f821834fa2e 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -35,19 +35,7 @@ #include "deployablefile.h" #include "genericlinuxdeviceconfigurationfactory.h" #include "genericremotelinuxdeploystepfactory.h" -#include "maddedeviceconfigurationfactory.h" -#include "maemoconstants.h" -#include "maemodeploystepfactory.h" #include "linuxdeviceconfigurations.h" -#include "maemopackagecreationfactory.h" -#include "maemopublishingwizardfactories.h" -#include "maemoqemumanager.h" -#include "maemorunfactories.h" -#include "maemosettingspages.h" -#include "maemotoolchain.h" -#include "qt4maemodeployconfiguration.h" -#include "maemoqtversionfactory.h" -#include "qt4maemotargetfactory.h" #include "qt4projectmanager/qt4projectmanagerconstants.h" #include "remotelinuxdeployconfigurationfactory.h" #include "remotelinuxrunconfigurationfactory.h" @@ -73,22 +61,10 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments, Q_UNUSED(arguments) Q_UNUSED(errorMessage) - MaemoQemuManager::instance(this); LinuxDeviceConfigurations::instance(this); - addAutoReleasedObject(new MaemoRunControlFactory); - addAutoReleasedObject(new MaemoRunConfigurationFactory); - addAutoReleasedObject(new MaemoToolChainFactory); - addAutoReleasedObject(new Qt4MaemoDeployConfigurationFactory); - addAutoReleasedObject(new MaemoPackageCreationFactory); - addAutoReleasedObject(new MaemoDeployStepFactory); addAutoReleasedObject(new LinuxDeviceConfigurationsSettingsPage); - addAutoReleasedObject(new MaemoQemuSettingsPage); - addAutoReleasedObject(new MaemoPublishingWizardFactoryFremantleFree); - addAutoReleasedObject(new Qt4MaemoTargetFactory); - addAutoReleasedObject(new MaemoQtVersionFactory); addAutoReleasedObject(new GenericLinuxDeviceConfigurationFactory); - addAutoReleasedObject(new MaddeDeviceConfigurationFactory); addAutoReleasedObject(new RemoteLinuxRunConfigurationFactory); addAutoReleasedObject(new RemoteLinuxRunControlFactory); addAutoReleasedObject(new RemoteLinuxDeployConfigurationFactory); -- cgit v1.2.3
Path to MADDE:%1
Path to MADDE target:%2
Debugger:%3