You Are Here:

Community: Wiki

This page was last modified on 6 November 2009, at 08:37.

Silent installation/uninstallation of application in Qt

From Forum Nokia Wiki

Reviewer Approved   


ID ... Creation date June 22, 2009
Platform S60 3rd Edition, FP1, FP2
S60 5th Edition
Tested on devices Nokia 5800 XpressMusic
Category Qt for Symbian Subcategory


Keywords (APIs, classes, methods, functions): XQInstaller::install(), XQInstaller::remove().

Overview

This code snippets shows how to install/uninstall application silently. The XQInstaller can be used to silently install/uninstall the SISX without user intervention.

This snippet 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

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();
}
 
}
 
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();
}
 
}
 
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.


Related Links

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ