×
Namespaces

Variants
Actions

Archived:Python on Symbian/16. Standalone Applications

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Article Metadata
Code ExampleArticle
Created: hamishwillee (30 Nov 2010)
Last edited: hamishwillee (08 May 2013)

Original Authors: Hamish Willee, Pankaj Nathani, Marcelo Barros

This chapter explains how to package Python scripts as standard Symbian application installation files that can then be Symbian Signed and distributed through channels like Nokia's Ovi store. We'll also look at what you can do to protect your application from being pirated and how to add multilingual support.

Contents

Introduction

In Python on Symbian, 'standalone applications' are applications that are delivered in easy-to-install SIS files that bundle everything needed to run the application. After installation, the use can launch the application by selecting its icon on the phone's user interface. This approach means improves usability accessibility for ordinary phone users.

This chapter explains how to create standalone applications from scripts using a simple and intuitive application packager tool. If you haven't already studied it, you may want to refer to Chapter 15 as you read this chapter, since it will assume an understanding of application signing and platform security.

Application packager

The application packager makes it very easy to create standalone applications from your Python scripts. It creates the SIS files for you, adding everything needed to allow the script to be launched from the phone's user interface.

The packager is delivered as part of the Python Windows installation package (i.e. PythonForS60_2.0.0_Setup.exe) or in the Mac/Linux archive. As the packager is itself a Python application, you will first need to install Python 2.5.x on your computer (from http://www.python.org/download/releases/2.5.4/). Once Python is installed, you can launch the packager from the Windows Start button: Start | PythonForS60 2.0.0 | PySymbian Application Packager, or by selecting it in the file system: \PythonForS60\ensymble_gui.py.

Tip.pngTip: The application packager can also be used on Linux or Mac OS, but you'll have to execute ensymble_gui.py directly as there is no start bar shortcut. The systems that the packager has been tested with are listed in the release notes (README text file in the PySymbian installation root directory.)

The application packager opens in a minimal view, as shown in Figure 16.1. Specify either a single script or a folder that you want to package as an application - if you're specifying a folder you need to ensure that it contains a script default.py that can be used to start your application. Do not check 'Continue with missing dependencies' unless you're a power user.

Figure 16.1: The application packager.

Press Create to create a SIS installation file that contains the specified python script and any modules it needs to run. The resulting SIS file (ScriptFileOrFolderName_v1_0_0.sis) can be installed and run on a device in the same way as any other Symbian application. It is self signed using a dummy certificate and given the platform security capabilities that can be granted by the user on installation.

Once installed, the application is represented in the phone's UI by the default Python logo.

If you want to distribute the application, then you will need to change some of the settings in the application packager so that you can submit it to Symbian Signed. You can edit the settings by pressing the More button as shown in Figure 16.2. Some of the settings are specified as commands entered in the field Additional Options.

Figure 16.2: The application packager window (expanded).

We discuss the values you're likely to want to change in the next section. You can get more information on these and the other fields by pressing the Help button, and for the commands by pressing the Options button.

UID

Every Python standalone application has a unique identifier (UID) that defines the protected area of the file system where it can securely store its data. UIDs are free and are allocated by Symbian Signed. If you plan to Symbian Sign your application then you'll need to get a "protected" UID in the 0x2 range, and if you're self-signing your application, then you'll need to request an unprotected UID in the 0xA range.

You can enter the UID into the application packager dialog in hexadecimal. Note, however, that the information isn't stored between sessions so it is often easier to instead store the value permanently in your script using the SYMBIAN_UID keyword (e.g. SYMBIAN_UID = yourUID).

Note that the default UID allocated by the packager is allocated in the 0xE test range (and is based on a cryptographic hash of the script file name). This is fine for development, but is not suitable for distribution because there is no guarantee in this range that there won't be UID clashes with other applications.

Certificates

The application packager, by default, self-signs the application SIS file with a dummy untrusted certificate containing fictional names/information. When the application is installed, the fictional information in the certificate is displayed and the user is warned that the application is untrusted. The user is also told what platform security capabilities are requested by the application and is required to acknowledge the prompt before the application is installed.

This generated certificate is fine when developing an application, but if you want to distribute the application, Symbian Sign it, or use capabilities that cannot be granted to a self-signed application, then you will need to specify a new certificate, private key and pass phrase in the fields provided.

The different certificates you can use are discussed in Chapter 15.

Vendor name

The vendor name is your company name (this should be changed from the default: "Ensymble"). The vendor name is specified as an entry in the "Additional options" field, shown as follows:

--vendor="Vendor Name"

In a multilingual application, the names in each language are displayed as comma separated values.

Version

The version number of your application should be updated with every revision. This can be done in the "Additional options" field using the version keyword. The application major version, minor version, build number should be separated by a period or comma:

[--version=1.0.0]

Note that it is usually more convenient to specify the version in your script, using the SIS_VERSION keyword (e.g. SIS_VERSION = "1.0.0").

Icon

Adding a distinctive and attractive icon can make your application look more professional (if no icon is specified the application will be represented in the phone shell by the normal "Python" logo).

The icon is specified as a command in the "Additional options" field:

--icon=\FullPathToIcon_icon.svg

The icon must be in SVG-Tiny format[1]. Note that you must include the full path, and it can't have any spaces.

Platform UID

It is possible to restrict your application to install only on a particular product by specifying the product ID. Alternatively, you can limit installation to a particular platform (and compatible future releases of the platform) using the platform UID.

As discussed in the Targeting older devices section, one reason you may do this would do this to restrict your application to only those devices that will automatically download the Python core binaries when needed (Symbian^1/S60 5th Edition and later). To restrict installation in this way, the following text must be appended onto the "Additional Options" field:

--platform-uid=0x20022E6D

Additional platforms/products may be specified, separating the values with commas. Lists of platform and product UIDs are available on the wiki by searching for S60 Platform and device identification codes.

Platform security capabilities

The application packager gives your application all the "user" platform security capabilities by default. If required, the default capabilities can be replaced using the caps keyword in the "Additional options" field (capability names are separated using the "+" symbol):

--caps=LocalServices+NetworkServices+...

Capabilities are discussed further in Chapter 15, which covers platform security on Symbian.

Other options

The Additional Options field allows you to specify additional configuration settings (these are passed through to the underlying command line tool Ensymble). You can get a brief overview of what the options do by pressing the Options button. If you need more information, the Ensymble release notes contain very detailed explanations of what each command does, and are are included in the root of your Python for Symbian installation: PythonForS60\README.

In addition to those already covered, a small subset of the useful commands are:

  • textfile - A text file (or files) to be displayed during installation.
  • extrasdir - If your application needs to make some files available in a public area of the phone filesystem - for example an icon editor application might install some demonstration icons, you can specify these in a location under drive root.
  • autostart - The application is registered to start on each device boot
  • runinstall - The application is automatically started after installation
  • drive - The drive where the package will be installed. There is usually no reason to change this (default is application can be installed to any drive)

The keywords lang, shortcaption, and caption (and a little more about vendor and textfile) are discussed in the section Multilingual Applications

Targeting older devices

On newer Symbian devices, applications created using the Python 2.0.0 application packager will automatically download any missing Python core libraries when the application is started.

Note.pngNote: This feature is expected to be present on all future devices and, at the time of writing, is true for the following list: 6220 classic, N86 8 MP, N85, 6720 classic, 6730 classic, N96, 5730 XpressMusic, N78, 5630 XpressMusic, E52, E55, 6710 Navigator, E75, N79, 5800 XpressMusic, 5530 XpressMusic, 5230, X6, N97 mini, N97 and N8.

You can restrict your application to install on only these platforms using the platform UID setting in the application packager, as discussed in earlier in this chapter.

For older devices, users will need to install the Python runtime themselves (developers might add an installation note with the textfile option to this effect). It is also possible to bundle all the Python dependencies into your SIS file - this will increase the size of your installation files by about 3Mb (about the size of a typical song in mp3 format).

If you choose to bundle Python with your application, you will need to include the Python core libraries (installed on your PC in a SIS file by the PySymbian installer) and the Open C/C++ libraries (installed onto your Windows PC if you set up the Symbian SDK for Python development on the Emulator). Embedding the dependency SIS files can be done after creating the application SIS file using the ensymble.py command line tool "mergesis" option (see the file "README" in the Python installation root directory for instructions on how to use the command line tool).

Multilingual applications

Making your application multi-lingual can significantly increase the number of people it appeals to and boost your downloads and sales.

The application packager allows you to specify translations for all text that appears (during installation and on the phone's user interface). This includes application captions, vendor names and text files displayed during installation, so the phone can display the appropriate text and files for the current phone language at install time. It will also display the application caption in the current phone language (and change it if the phone's default language changes).

The platform is smart enough to use sensible fall-back languages; for example if you supply your files in Spanish, then these will be used even if the platform language is Latin American Spanish.

Note.pngNote: The application packager does not provide access to Symbian platform features like locale-specific application icons, and conditional installation of files based on the current locale. You don't need them!

Python on Symbian does not provide explicit support for localising your scripts, and there is (at time of writing) no extension to get the current locale from the phone. It is good practice to separate your translations from the rest of your code; we outline a simple method in the following section to show you how to keep translation files as separate Python modules, and load them based on a filename convention.

Packaging applications

The packager allows you to define the languages your installation will support, including the translated strings for the application's caption, short caption and the vendor name. You don't have to specify those translations, but if you do, then you need to specify them as comma separated values in the same order as your initial language list.

Tip.pngTip: The application packager creates default localisation values based on your language language codes. Unlike users of the C++ developer toolchain, you won't be stuck for hours ensuring that you've got exactly the right number of strings for the all the values!

The translations are specified as additional options using the following commands:

Table 16.2: Optional commands.
Command Description
lang Comma separated list of two-character language codes. A few common codes are: English UK (EN), French (FR), Italian (IT), German (GE), Spanish (SP), Japanese (JA), Chinese PRC (ZH). The full list can be found in the [

http://library.developer.nokia.com/index.jsp?topic=/GUID-E35887BB-7E58-438C-AA27-97B2CDE7E069/GUID-251A35C1-CC66-4DE4-9EBE-964026E89E7F/GUID-9DD1EA2B-DC59-315C-8E9C-CE6D9461B695.html Nokia Developer Library] (or search for "Language Codes" on the library.forum.nokia.com).

As an example, to specify that the package support English, French and German, you would add the following additional option to your installation package:

--lang=EN,FR,GE
caption Caption, or a comma separated list of (long) captions in all the supported languages. Note that the order is the same specified in the lang command:
--caption="English Caption","French Caption","German Caption"
shortcaption Short caption, or a comma separated list of short captions in all the supported languages. Short captions are used in views where there isn't sufficient space to use the normal caption. Note the declaration order is the same as specified in the lang command:
--shortcaption="EngCapt","FncCapt","GmCpt"
vendor Vendor name or a comma separated list of all supported vendor names. Note the declaration order is the same as specified in the lang command:
--vendor="BigCorp","French Big Corp","German Big Corp"

The application packager also allows you to specify a text file (in UTF8 Encoding) that is to be displayed during installation. You can create a file containing different translation for each supported language and the application will bundle these in the SIS file.

The format is something like:

--textfile=mytext_%C.txt

In the preceding example, the packager bundles files with names mytext_EN.txt, mytext_FR.txt and mytext_GE.txt. You can also specify different patterns, e.g.:

%%           - literal %
%n           - language number (01 - 99)
%c           - two-character language code in lowercase letters
%C           - two-character language code in capital letters
%l           - language name in English, using only lowercase letters
%l           - language name in English, using mixed case letters

The language number is a number assigned to each language, that can be used instead of the code. The numbers are also documented in the Nokia Developer Library (or just search for "Language abbreviations in lang-code alphabetical order" on library.forum.nokia.com).

Localising python scripts

Since Python on Symbian itself does not provide explicit support for localising your scripts, we will present a strategy for supporting multiple languages in a PySymbian [2]. Using this strategy it is possible to define the default language and additional translations may be added whenever needed. Moreover, missing translations are replaced by the default translation, allowing incremental translations without breaking the code.

The strategy is composed of a main script file (wm_locale.py) used for dynamic loading of the desired language, and localisation files that contain the actual translated text. The localisation files are also Python files and they are imported as modules. Using Python introspection, the translation may be loaded and missing translations are replaced by the default language. The main script is as follows:

wm_locale.py

# -*- coding: utf-8 -*-
 
__all__ = [ "Locale" ]
 
class Loc_Data(object):
"Translation data holder"
pass
 
class Default(object):
"Default language support"
def __init__(self):
self.loc = Loc_Data()
self.loc.zero = u'Zero'
self.loc.one = u'One'
self.loc.two = u'Two'
self.loc.three = u'Three'
self.loc.four = u'Four'
self.loc.five = u'Five'
self.loc.six = u'Six'
self.loc.seven = u'Seven'
self.loc.eight = u'Eight'
self.loc.nine = u'Nine'
self.loc.change_language = u'Change Language'
self.loc.english_us = u'English (USA)'
self.loc.finnish = u'Finnish'
self.loc.hungarian = u'Hungarian'
self.loc.portuguese_br = u'Portuguese (Brazil)'
self.loc.about = u'About'
self.loc.exit = u'Exit'
 
class Locale(Default):
"Multiple language support class"
 
LOC_MODULE = "wm_locale_%s"
 
def __init__(self,lang = ""):
"Load all locale strings for one specific language or default if empty"
self.set_locale(lang)
 
def set_locale(self,lang = ""):
"Load all locale strings for one specific language or default if empty"
Default.__init__(self)
 
try:
lang_mod = __import__( self.LOC_MODULE % ( lang ) )
except ImportError:
pass
else:
self.merge_locale(lang_mod)
 
def merge_locale(self, lang_mod):
"Merge new location string into default locale"
 
# replace existing strings and keep old ones
# if it is missing in the locale module
for k,v in self.loc.__dict__.iteritems():
if hasattr(lang_mod,k):
nv = lang_mod.__getattribute__(k)
self.loc.__setattr__(k,nv)

All default translations are defined in class Default using the attribute self.loc. Each string in your program should be represented by a different attribute in self.loc. Localisation modules are loaded dynamically and the files are named according to certain conventions. This is represented by the following expression:

LOC_MODULE = "wm_locale_%s"

So, if you have a pt_BR translation, create a file called wm_locale_pt_BR.py. Inside this module, translate all strings in class Default, removing any class or self.loc references. For instance, the pt_BR translation would be:

wm_locale_pt_BR.py

# -*- coding: utf-8 -*-
zero = u'Zero'
one = u'Um'
two = u'Dois'
three = u'Três'
four = u'Quatro'
five = u'Cinco'
six = u'Seis'
seven = u'Sete'
eight = u'Oito'
nine = u'Nove'
change_language = u'Mudar idioma'
english_us = u'Inglês (EUA)'
finnish = u'Finlandês'
hungarian = u'Húngaro'
portuguese_br = u'Português (Brasil)'
about = u'Sobre'
exit = u'Sair'

The next code snippet demonstrates how the locale class can be used.

wm_locale_demo.py

# -*- coding: utf-8 -*-
import sys
sys.path.append(r'e:\python')
 
import appuifw
import e32
import wm_locale
 
class Locale_Demo(object):
def __init__(self):
appuifw.app.exit_key_handler = self.close
appuifw.app.title = u"Locale Demo"
appuifw.app.screen = 'normal'
self.update_locale()
self.app_lock = e32.Ao_lock()
 
def close(self):
self.app_lock.signal()
 
def about(self):
appuifw.note( u"Locale Demo", "info" )
 
def update_locale(self,lang=""):
self.labels = wm_locale.Locale(lang)
self.refresh()
 
def refresh(self):
entries = [
self.labels.loc.zero,
self.labels.loc.one,
self.labels.loc.two,
self.labels.loc.three,
self.labels.loc.four,
self.labels.loc.five,
self.labels.loc.six,
self.labels.loc.seven,
self.labels.loc.eight,
self.labels.loc.nine
]
 
self.body = appuifw.Listbox(entries)
 
self.menu = [
(self.labels.loc.change_language, (
(self.labels.loc.english_us, lambda: self.update_locale("en_US")),
(self.labels.loc.finnish, lambda: self.update_locale("fi")),
(self.labels.loc.hungarian, lambda: self.update_locale("hu")),
(self.labels.loc.portuguese_br, lambda: self.update_locale("pt_BR"))
)
),
(self.labels.loc.about, self.about),
(self.labels.loc.exit, self.close)
]
 
appuifw.app.menu = self.menu
appuifw.app.body = self.body
 
def run(self):
self.app_lock.wait()
appuifw.app.menu = []
appuifw.app.body = None
appuifw.app.set_exit()
 
if __name__ == "__main__":
 
ld = Locale_Demo()
ld.run()

If you have more translation files, just add them to your project. The following translations were copied from [2] - you can see that there are missing translations.

wm_locale_en_US.py

# -*- coding: utf-8 -*-
zero = u'Zero'
one = u'One'
two = u'Two'
three = u'Three'
four = u'Four'
five = u'Five'
six = u'Six'
seven = u'Seven'
eight = u'Eight'
nine = u'Nine'
change_language = u'Change Language'
english_us = u'English (USA)'
finnish = u'Finnish'
hungarian = u'Hungarian'
portuguese_br = u'Portuguese (Brazil)'
about = u'About'
exit = u'Exit'

wm_locale_fi.py

# -*- coding: utf-8 -*-
zero = u'nolla'
one = u'yksi'
two = u'kaksi'
three = u'kolme'
four = u'neljä'
five = u'viisi'
six = u'kuusi'
seven = u'seitsemän'
eight = u'kahdeksan'
nine = u'yhdeksän'
change_language = u'Vaihda kieli'
english_us = u'englanti'
finnish = u'suomi'
hungarian = u'unkari'
about = u'Tietoja'
exit = u'Poistu'

wm_locale_hu.py

# -*- coding: utf-8 -*-
zero = u'nulla'
one = u'egy'
two = u'kett\u0151'
three = u'három'
four = u'négy'
five = u'öt'
six = u'hat'
seven = u'hét'
eight = u'nyolc'
nine = u'kilenc'
change_language = u'Nyelv változtatás'
english_us = u'angol'
finnish = u'finn'
hungarian = u'magyar'
about = u'Információ'
exit = u'Kijárat'

Figures 16.3 and 16.4 show some screenshots.

Figure 16.3: Screenshot: Localizing Python Applications
Figure 16.4: Screenshot: Localizing Python Applications

Commercial applications

Python can be used to create commercial applications for the Symbian platform.

From PySymbian 2.0, applications can now be Symbian Signed and distributed through channels like Nokia's Ovi store - in the same way as applications developed in native C++. In addition, even though the Python core libraries are still not automatically included in all devices, newer devices will automatically download Python when it is needed.

A common requirement of commercial applications is the need to fully enable applications only for licensed users. This section explains how to create an application that can only be unlocked with a valid registration code. The registration code can be verified at runtime on the device, or on the server side using SMS or a GPRS/Data connection.

Registration code

This section illustrates a simple and minimalistic approach for implementing a registration code algorithm. The code creates a registration code from the IMEI and compares it to a value entered by the user. If the values match, the fact that the application is registered is stored on the device and used to determine which options the user interface presents to the user.

The complete code is as follows:

import appuifw
import e32
import os
import sysinfo
 
pathtoapp=os.path.dirname(appuifw.app.full_name())
 
is_registered=0
 
timer = e32.Ao_timer()
app_lock = e32.Ao_lock()
 
phone_imei=sysinfo.imei()
reg_code = phone_imei[2]+phone_imei[0]+phone_imei[0]+phone_imei[8]
 
 
def write_settings():
# Write registration flag
global is_registered
REG_DIR='C:\\system\\data\\registration'
CONFIG_FILE=os.path.join(REG_DIR,'confg.set')
if not os.path.isdir(REG_DIR):
os.makedirs(REG_DIR)
REG_FILE=os.path.join(REG_DIR,'confg.set')
config={}
config['is_registered']= is_registered
f=open(REG_FILE,'wt')
f.write(repr(config))
f.close()
 
def read_settings():
# Read registration flag
global is_registered
REG_FILE='C:\\system\\data\\registration\\confg.set'
print "read settings 2"
try:
print "read settings 3"
f=open(REG_FILE,'rt')
try:
content = f.read()
config=eval(content)
f.close()
is_registered=config.get('is_registered','')
except:
appuifw.note(u"Cannot read settings file", "error")
except:
print "read settings 4"
appuifw.note(u"Creating settings file", "info")
 
def exit_key_handler():
write_settings()
appuifw.app.set_exit()
 
 
def quit():
write_settings()
appuifw.app.set_exit()
 
L_Unregistered = [u"Register",u"About", u"Exit"]
 
L_Registered = [u"About", u"Exit"]
 
def start_application():
# On start check if the application is registered or not and accordingly give menu pop-up
options
global is_registered
if is_registered == 0:
appuifw.app.title = u"Not Registered"
index = appuifw.popup_menu(L_Unregistered)
if index == 0:
register_application()
elif index == 1:
about()
elif index == 2:
quit()
else:
pass
elif is_registered == 1:
appuifw.app.title = u"Registered"
index = appuifw.popup_menu(L_Registered)
if index == 0:
about()
elif index == 1:
quit()
else:
pass
else:
pass
 
def about():
# About the application
appuifw.note(u"Registration Example\nPython on Symbian", "info")
start_application()
 
def promt_user():
# Prompt user for registration code
global is_registered
if is_registered == 0:
appuifw.note(u"Application not registered!", "info")
 
def register_application():
# Ask and check for registration
global is_registered
if is_registered == 0:
appuifw.note(u"Please enter the registration code", "info")
regtry = appuifw.query(u"Enter Registration code", "text")
if regtry == reg_code:
is_registered = 1 # Successfully registered!
appuifw.note(u"Thanks for registering!","info")
else:
appuifw.note(u"Invalid Registration Code!","error") # Registration failed!
else:
appuifw.note(u"Registered Application!","info")
 
start_application()
 
appuifw.app.exit_key_handler = exit_key_handler
appuifw.app.screen='normal'
 
read_settings() # Check if registered or not
promt_user() # Prompt user if not registered
start_application() # Show application to user, accordingly

Lets go through the code in sections.

The machine registration code is generated from the device IMEI at the start of the application using a very simple algorithm:

phone_imei=sysinfo.imei()
reg_code = phone_imei[2]+phone_imei[0]+phone_imei[0]+phone_imei[8]

We call the three functions - read_settings(), prompt_user() and start_application() in order. read_settings() checks whether the application is registered or not by checking the registration flag from a configuration file. The registration flag is stored in the is_registered variable and used in the other functions.

def read_settings():
# Read registration flag
global is_registered
REG_FILE='C:\\system\\data\\registration\\confg.set'
try:
f=open(REG_FILE,'rt')
try:
content = f.read()
config=eval(content)
f.close()
is_registered=config.get('is_registered','')
except:
appuifw.note(u"Cannot read settings file", "error")
except:
appuifw.note(u"Creating settings file", "info")

The prompt_user() function displays a note to the user if the application is not registered.

def promt_user():
# Prompt user for registration code
global is_registered
if is_registered == 0:
appuifw.note(u"Application not registered!", "info")

start_application() checks the registration flag (is_registered) read from the file in read_settings() function. If the application is found to be registered, the application is fully activated. On the other hand, if the application is not registered, the softkey menu shows only the registration option - the other options are not shown.

def start_application():
# On start check if the application is registered or not and accordingly give menu pop-up
options
global is_registered
if is_registered == 0:
appuifw.app.title = u"Not Registered"
index = appuifw.popup_menu(L_Unregistered)
if index == 0:
register_application()
elif index == 1:
about()
elif index == 2:
quit()
else:
pass
elif is_registered == 1:
appuifw.app.title = u"Registered"
index = appuifw.popup_menu(L_Registered)
if index == 0:
about()
elif index == 1:
quit()
else:
pass
else:
pass

If the user selects the Register" option they are asked to enter the registration code. If the registration code is successful, the "Thanks for registration" note is displayed, the registration flag (is_registered) flag is stored in the configuration file and the application is activated. If a wrong registration code is provided, the application is not activated and the user is not able to use the application unless he/she registers.

def register_application():
# Ask and check for registration
global is_registered
if is_registered == 0:
appuifw.note(u"Please enter the registration code", "info")
regtry = appuifw.query(u"Enter Registration code", "text")
if regtry == reg_code:
is_registered = 1 # Successfully registered!
appuifw.note(u"Thanks for registering!","info")
else:
appuifw.note(u"Invalid Registration Code!","error") # Registration failed!
else:
appuifw.note(u"Registered Application!","info")
 
start_application()

The application registration is very simplistic because it does not solve real-world issues like how the user gets the registration code in the first place. There are many ways this could be done - for example the application could directly supply the phone IMEI to a registration server via SMS or the Internet, which checks payment details and returns the registration key back to the application.

There are many other limitations of this particular implementation, including the fact that the registration key algorithm is very simple, it is stored in a public area of the file system, and the mechanism used can be reverse engineered from the script. While the mechanism is not perfect, it is probably sufficient to deter "casual" piracy. A more complicated mechanism such as DRM can be used to provide further protection.

Summary

Python applications can be nearly indistinguishable from those developed in native code, both in terms of appearance and installation behavior.

This chapter showed how to package and install applications using the application packager and how to write multilingual applications. It concluded with an explanation of what you can do to protect your application from software piracy, including example code demonstrating how to implement a registration code in your application.

References

  1. InkScape (www.inkscape.org) is an excellent open source SVG-Tiny based illustrator
  2. 2.0 2.1 Archived:Localization Example for PySymbian


Licence icon cc-by-sa 3.0-88x31.png© 2010 Symbian Foundation Limited. Portions copyright Bogdan Galiceanu, Hamish Willee, Marcelo Barros de Almeida, Mike Jipping, Pankaj Nathani and others in wiki document history list. This document is licensed under the Creative Commons Attribution-Share Alike 2.0 license. See http://creativecommons.org/licenses/by-sa/2.0/legalcode for the full terms of the license.
Note that this content was originally hosted on the Symbian Foundation developer wiki.

This page was last modified on 8 May 2013, at 09:02.
112 page views in the last 30 days.
×