1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
// ===============================
// 🟣 Creation de l'installeur et Initialisation de la page mot de passe
// ===============================
function Component() {
// Ajouter la page personnalisée avant la page "ReadyForInstallation"
component.loaded.connect(this, Component.prototype.installerLoaded);
// Cacher la page de sélection des composants: pour que tout s'installe il faut que dans le package.xml, on ait <default>true<default>
installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
}
Component.prototype.installerLoaded = function () {
if (installer.addWizardPage(component, "DynamicPasswordPage", QInstaller.ReadyForInstallation)) {
var welcomePage = gui.pageWidgetByObjectName("DynamicPasswordPage");
welcomePage.title = "Welcome to the SMSP-NG installer";
welcomePage.MessageLabel.text = "SMSP-NG installation for SMS4 maintenance.";
var imageLabel = new QLabel(welcomePage.widget);
var pixmap = new QPixmap("avion.png");
imageLabel.setPixmap(pixmap);
imageLabel.setAlignment(Qt.AlignCenter);
imageLabel.setScaledContents(true);
imageLabel.resize(400, 200);
var layout = welcomePage.widget.layout();
if (layout) {
layout.addWidget(imageLabel);
}
else {
console.log("Page Welcome introuvable");
}
}
}
// ===============================
// 🟣 Validation du formulaire
// ===============================
Component.prototype.DynamicPasswordPageValidatePage = function() {
console.log("DynamicPasswordPageValidatePage: OK");
var page = gui.pageWidgetByObjectName("DynamicPasswordPage");
if (!page)
{
console.log("page not found");
return true;
}
page.title = "Security for SMSP-NG";
page.subtitle = "Create an administrator password for the application";
//page.windowTitle = "Security for SMSP-NG \nCreate an administrator password for the application";
//page.description.setText("Create an administrator password for the application");
var pw = page.findChild("QLineEdit", "passwordField");
var pwc = page.findChild("QLineEdit", "confirmField");
if (!pw.text || pw.text.length < 6) {
gui.messageBox("warning", "Error", "The password must contain at least 6 characters!");
return false;
}
if (pw.text !== pwc.text) {
gui.messageBox("warning", "Error", "The passwords are different!");
return false;
}
installer.setValue("adminPassword", pw.text);
console.log("Mot de passe saisi (validatePage) :", pw.text);
return true;
};
// ===============================
// 🟣 Création
// ===============================
Component.prototype.createOperations = function()
{
component.createOperations();
// 🟣 Écriture du hash + création des raccourcis
var targetDir = installer.value("TargetDir");
//var exePath = "@TargetDir@/SMSP_NG.exe";
var exePath = targetDir + "/SMSP_NG.exe";
// 🔐 Écriture du mot de passe
var password = installer.value("adminPassword");
//installer.setValue("adminPassword", password);
console.log("Mot de passe saisi :", installer.value("adminPassword"));
var filePath = targetDir + "/SMSP.INI";
if (password && password.length > 0) {
var hash = sha1(password);
component.addOperation("CreateFile", filePath, "");
component.addOperation("AppendFile", filePath, hash + "\n");
}
else {
console.log("No password to write");
}
// 🖥️ Raccourci Bureau
component.addOperation(
"CreateShortcut",
exePath,
"@DesktopDir@/SMSP_NG.lnk",
"workingDirectory=@TargetDir@",
"iconPath=" + exePath
);
// 🪟 Raccourci Menu Démarrer
component.addOperation(
"CreateShortcut",
exePath,
"@StartMenuDir@/SMSP_NG.lnk",
"workingDirectory=@TargetDir@",
"iconPath=" + exePath
);
console.log("TargetDir:", installer.value("TargetDir"));
console.log("Password:", installer.value("adminPassword"));
console.log("File path:", targetDir + "/SMSP.INI");
console.log("Password hash:", hash);
}
// ===============================
// 🔐 SHA-1 identique à Qt
// ===============================
function sha1(msg)
{
...
} |