Silent installation/uninstallation of application in Qt
Article Metadata
Code Example
Tested with
Compatibility
S60 5th Edition
Article
Contents |
Overview
The Installer API can be used to install and uninstall applications without notifying the user through the standard installation dialogs. So you can use this API silently to install applications or you can create for example your own installation user interface.
This code snippet shows how to install/uninstall a Symbian application silently (without user intervention).
This snippet uses XQInstaller and requires TrustedUI capabilities. Self-signing is not possible because a [[Developer Certificate] is needed.
Note: This snippet can not work on emulator, so need to test it on real device.
Preconditions
- Download and Install the Qt SDK (recommended when Using Symbian C++ in the Qt SDK)
- Go through this article: How to use Mobile Extension APIs in Qt
Headers file
#ifndef SILENTINSTALLUNINSTALL_H
#define SILENTINSTALLUNINSTALL_H
#include <QtGui/QMainWindow>
#include "ui_SilentInstallUninstall.h"
#include "xqinstaller.h"
class SilentInstallUninstall : public QMainWindow
{
Q_OBJECT
public:
SilentInstallUninstall(QWidget *parent = 0);
~SilentInstallUninstall();
public Q_SLOTS:
//slots to receive action of menu trigger.
void installHelloWorldAction();
void uninstallHelloWorldAction();
//slots to receive signal from XQInstaller.
void installationComplete();
void installationError();
void uninstallationComplete();
void uninstallationError();
public:
//new functios
void SilentInstall();
void SilentUninstall();
void createMyMenu();
private:
Ui::SilentInstallUninstallClass ui;
QAction* menu_installHelloWorldAction;
QAction* menu_uninstallHelloWorldAction;
QAction* menu_exitAction;
XQInstaller *installer;
bool result;
};
#endif // SILENTINSTALLUNINSTALL_H
.pro file
symbian:LIBS += -lswinstcli \
-lcommdb \
-lapparc \
-lefsrv \
-lapgrfx
symbian:TARGET.CAPABILITY += TrustedUI
Source
#include "SilentInstallUninstall.h"
#include <QMessageBox>
#include <QDir>
SilentInstallUninstall::~SilentInstallUninstall()
{
}
SilentInstallUninstall::SilentInstallUninstall(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
setWindowTitle("SilentInstallUninstall");
createMyMenu();
// Create the installer class
installer = new XQInstaller(this);
}
void SilentInstallUninstall::SilentUninstall()
{
connect(installer,SIGNAL(applicationRemoved()),this,SLOT(uninstallComplete()));
connect(installer,SIGNAL(error()),this,SLOT(uninstallError()));
/* ED8788DC is UID of helloworld
* convert UID from hex to decimal
*/
QString str = "0xED8788DC";
bool ok;
uint appId = str.toUInt(&ok,16);
/* Uninstall the application with the given UID
* Or result = installer->remove(3985082588);
*/
result = installer->remove(appId);
if (!result)
{
uninstallationError();
}
}
In SilentUninstall() function we uninstall an application without informing the user.Each application has a unique identifier, so this is how you specify which application to uninstall. After the process is completed, either an applicationRemoved() or error() signal is emitted depending on whether the uninstalling was successful or not.
void SilentInstallUninstall::SilentInstall()
{
// Connect to the applicationInstalled() signal
connect(installer,SIGNAL(applicationInstalled()),this,SLOT(installationComplete()));
connect(installer,SIGNAL(error()),this,SLOT(installationError()));
// Install HelloWorld.SISX from private path
QString fileName = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + "HelloWorld.SISX");
result = installer->install(fileName.replace("/","\\"));
if (!result)
{
installationError();
}
}
In SilentInstall() function we install an application from an installation file. On the Symbian platform, the installation package is referred to as a SIS file and has a .SISX extension. After installation is completed, either an applicationInstalled() or error() signal is emitted depending on whether the installation was successful or not . We catch the value in result and process it for error checking.
void SilentInstallUninstall::createMyMenu()
{
menu_installHelloWorldAction = new QAction(tr("Install HelloWorld"), this);
menuBar()->addAction(menu_installHelloWorldAction);
connect(menu_installHelloWorldAction, SIGNAL(triggered()), this, SLOT(installHelloWorldAction()));
menu_uninstallHelloWorldAction = new QAction(tr("Uninstall HelloWorld"), this);
menuBar()->addAction(menu_uninstallHelloWorldAction);
connect(menu_uninstallHelloWorldAction, SIGNAL(triggered()), this, SLOT(uninstallHelloWorldAction()));
menu_exitAction = new QAction(tr("Exit"), this);
menuBar()->addAction(menu_exitAction);
connect(menu_exitAction, SIGNAL(triggered()), this, SLOT(close()));
}
void SilentInstallUninstall::installHelloWorldAction()
{
SilentInstall();
}
void SilentInstallUninstall::uninstallHelloWorldAction()
{
SilentUninstall();
}
void SilentInstallUninstall::installationComplete()
{
QMessageBox::information(0,"Congrets!!!", "Application is installed sucessfully");
}
void SilentInstallUninstall::installationError()
{
QMessageBox msgBox;
msgBox.setText("Error in installation.");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
switch (installer->error())
{
case XQInstaller::OutOfMemoryError:
{
msgBox.setInformativeText("Not enough memory");
}
break;
case XQInstaller::AlreadyInUseError:
{
msgBox.setInformativeText("Installer is already in use");
}
break;
case XQInstaller::UserCancelError:
{
msgBox.setInformativeText("Installer cancelled by the user.");
}
break;
case XQInstaller::PackageNotSupportedError:
{
msgBox.setInformativeText("Package not supported");
}
break;
case XQInstaller::SecurityFailureError:
{
msgBox.setInformativeText("Security failure");
}
break;
case XQInstaller::MissingDependencyError:
{
msgBox.setInformativeText("Missing dependency");
}
break;
case XQInstaller::NoRightsError:
{
msgBox.setInformativeText("No rights ");
}
break;
case XQInstaller::BusyError:
{
msgBox.setInformativeText("Installer is busy");
}
break;
case XQInstaller::AccessDeniedError:
{
msgBox.setInformativeText(" Access denied");
}
break;
case XQInstaller::UpgradeError:
{
msgBox.setInformativeText(" Error while upgrading");
}
break;
case XQInstaller::UnknownError:
{
msgBox.setInformativeText("Unknown error.");
}
break;
default:
break;
}
msgBox.exec();
}
Postconditions
The code snippet is expected to install/uninstall helloworld application silently.
Code Example
- The Code Example will show how to install/uninstall application silently. The application is tested on Nokia 5800 XpressMusic.


14 Sep
2009
The article contains important information to install/ uninstall an application in Qt silently i.e. without user intervention.
The application presented here will install or uninstall a sisx or will show message according to the error occured during installation if installation fails. The API used is QInstaller. The code snippest contained will install/ uninstall HelloWorld application silently. Moreover the code was also tested on Nokia 5800 XPressMusic.
A good article for beginners and intermediate developers to use QInstaller class and study installation/ uninstallation of sisx application silently.
22 Sep
2009
Article shows the way of install and uninstall from the mobile. It uses to install new application in mobile. At the time of update of application in mobile there is a need of uninstall the last version and install new version. It’s a very common procedure of install and uninstalls application. As it’s a very common but its very vital thing.