Silent installation/uninstallation of application in Qt
Overview[edit | edit source]
This code snippet shows how to install/uninstall a Symbian application silently (without user intervention).
This snippet uses 76ytuiytuityutyutututyutyutyu and requires 76ytuiytuityutyutututyutyutyu 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[edit | edit source]
- 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[edit | edit source]
- 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[edit | edit source]
symbian:LIBS += -lswinstcli \
-lcommdb \
-lapparc \
-lefsrv \
-lapgrfx
symbian:TARGET.CAPABILITY += TrustedUI
Source[edit | edit 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 76ytuiytuityutyutututyutyutyu 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 76ytuiytuityutyutututyutyutyu or 76ytuiytuityutyutututyutyutyu 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 76ytuiytuityutyutututyutyutyu 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 76ytuiytuityutyutututyutyutyu or 76ytuiytuityutyutututyutyutyu 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[edit | edit source]
The code snippet is expected to install/uninstall helloworld application silently.
Code Example[edit | edit source]
- The Code Example will show how to install/uninstall application silently. The application is tested on Nokia 5800 XpressMusic.