diff options
| author | 2015-09-15 01:26:01 +0200 | |
|---|---|---|
| committer | 2015-09-15 01:26:01 +0200 | |
| commit | 70e16a4faeaabdaf7ebd80e74c4df6900a4d5171 (patch) | |
| tree | 18b8686ea4b9c66f5b5aabeb5146a10176bd6dbd /src/modules/addon | |
| parent | Merge branch 'master' of https://github.com/kvirc/KVIrc (diff) | |
| download | KVIrc-70e16a4faeaabdaf7ebd80e74c4df6900a4d5171.tar.gz KVIrc-70e16a4faeaabdaf7ebd80e74c4df6900a4d5171.tar.bz2 KVIrc-70e16a4faeaabdaf7ebd80e74c4df6900a4d5171.zip | |
More work on addon management
Diffstat (limited to 'src/modules/addon')
| -rw-r--r-- | src/modules/addon/PackAddonDialog.cpp | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/src/modules/addon/PackAddonDialog.cpp b/src/modules/addon/PackAddonDialog.cpp index 0abec8bc2..6f5a79b04 100644 --- a/src/modules/addon/PackAddonDialog.cpp +++ b/src/modules/addon/PackAddonDialog.cpp @@ -130,134 +130,6 @@ void PackAddonDialog::accept() QWizard::accept(); } - -#if 0 -bool PackAddonDialog::checkDirTree(QString * pszError) -{ - if(pszError) - *pszError = ""; - - QDir addon(m_szDirPath); - if(!addon.exists()) - { - *pszError = __tr2qs_ctx("The selected directory does not exist.","addon"); - return false; - } - - QFileInfo init(m_szDirPath + "/install.kvs"); - if(!init.exists()) - { - *pszError = __tr2qs_ctx("The initialization script (install.kvs) does not exist.","addon"); - return false; - } - - return true; -} -bool PackAddonDialog::createInstaller(QString * pszError) -{ - if(pszError) - *pszError = ""; - - // Start creating install.kvs: header - QString szTmp; - szTmp += QString("# This file is generated automatically. Do NOT touch unless you know what are you doing\n#\n"); - szTmp += QString("# %1 %2\n# Written by %3\n# %4\n\n").arg(m_szName, m_szVersion, m_szAuthor, m_szDescription); - szTmp += "# Register the script: this must be the first instruction executed\n# since it will abort with an error when a greater version is already installed\n"; - - // install.kvs: addon registration - /* FIXME: re-add in KVIrc 4.1! - * implement a backend with full automatic cleaning for aliases, classes, popups, - * actions, ... via snapshot/diff of kvirc state before/after installing a package - - szTmp += QString("addon.register(\"%1\",\"%2\",\"%1\",\"%3\",\"%4\",\"%5\")\n").arg(m_szName, m_szVersion, m_szDescription, m_szMinVersion, m_szIcon); - szTmp += "{\n"; - szTmp += "\t# This is our uninstall callback: it will be called by KVIrc when addon.uninstall is invoked\n"; - szTmp += QString("\t%1::uninstall::uninstall\n").arg(m_szName); - szTmp += QString("\t%1::uninstall::uninstallfiles\n").arg(m_szName); - szTmp += QString("\t%1::uninstall::uninstallaliases\n").arg(m_szName); - szTmp += "}\n\n"; - szTmp += "# Ok, addon.register succeeded. We can go on with the installation.\n\n"; - */ - - // install.kvs: run path - szTmp += "# Get the path that this script was launched from\n"; - szTmp += "%mypath = $file.extractPath($0)\n\n"; - - // install.kvs: create an instance of the installer class - szTmp += "# The installer will copy our files and generate automatically an uninstallation\n# alias for them\n"; - szTmp += "%installer = $new(installer,0,myaddon)\n\n"; - - // install.kvs: copy files - szTmp += "# Copy files in each subdirectory\n# the pics\n"; - - szTmp += QString("%installer->$copyFiles(\"%mypath/pics\",\"*.png\",$file.localdir(\"pics\"))\n\n"); - szTmp += "# the translations\n"; - szTmp += "%installer->$copyFiles(\"%mypath/locale\",\"*.mo\",$file.localdir(\"locale\"))\n\n"; - - szTmp += "# the documentation\n"; - szTmp += QString("%installer->$copyFiles(\"%mypath/help/\",\"*.html\",$file.localdir(\"help/\"))\n\n"); - - // install.kvs: generate uninstall alias - szTmp += "# Generate the uninstall alias\n"; - szTmp += QString("%installer->$generateUninstallAlias(\"%1::uninstallfiles\")\n\n") \ - .arg(m_szName); - - // kviinstall.kvs: kill the installer class - szTmp += "# Kill the installer helper\n"; - szTmp += "delete %installer\n\n"; - -#if 0 - // install.kvs: fetch the complete script - szTmp += "# Fetch the complete script\n"; - szTmp += "%files[] = $file.ls($file.extractpath($0)/src,f)\n"; - szTmp += QString("%alias = \"alias(%1::uninstall::uninstallaliases){$lf\"\n") \ - .arg(m_szName); - szTmp += "for(%i=0; %i<$length(%files[]); %i++)\n{\n"; - szTmp += "\tinclude $file.extractpath($0)/src/%files[%i]\n"; - szTmp += "\t%flt = $str.left(%files[%i],$($str.len(%files[%i])-4))\n"; - szTmp += "\t%file = $str.replace(%flt,\"_\",\"::\")\n"; - szTmp += "\t%alias .= \"alias(%file){};$lf\"\n}\n"; - szTmp += QString("\t%alias .= \"alias(%1::uninstall::uninstallfiles){};$lf\"\n") \ - .arg(m_szName); - szTmp += QString("\t%alias .= \"alias(%1::uninstall::uninstallaliases){};$lf\"\n") \ - .arg(m_szName); - szTmp += "%alias .= \"}\"\n"; - szTmp += "eval %alias\n\n"; -#endif - - // install.kvs: include initialization file - szTmp += "# Include initialization file\n"; - szTmp += "include \"init.kvs\" %mypath\n\n"; - - // Put the install.kvs in the buffer - QByteArray buffer; - buffer.append(szTmp.toUtf8()); - - // We don't need to check dir existance since it was checked just before - QDir addon(m_szDirPath); - - // Open file for writing - QFile installer(addon.filePath("install.kvs")); - if(!installer.open(QIODevice::WriteOnly)) - { - *pszError = __tr2qs_ctx("Cannot open file for writing.","addon"); - return false; - } - - // Write the buffer to the file descriptor - if(installer.write(buffer) == -1) - { - *pszError = __tr2qs_ctx("Cannot write to the file descriptor.","addon"); - return false; - } - - return true; -} -#endif - - - - bool PackAddonDialog::packAddon() { // Get data from registered fields |
