Symbian OS
read last symbian news on www.newlc.com read last symbian reviews on www.newlc.com
read last symbian tutorial on www.newlc.com read last symbian download on www.newlc.com
4 Sep 2006 - 13:43

I will explain, in this short article, how you can write a screensaver for S60 3rd. edition phones, such as: N91, N73,3250, and many others.

Here you can see our little screensaver running on a Nokia 3250 device:

<object width="425" height="350"></param></embed></object>

General info:

-  Download the Example screensaver source code here
-  Download the Example screensaver source code as a Carbide.C++ project here
-  Carbide.c++ project may not work at the first try, because there are some hardcoded paths in the project properties, but these should be easy to fix to fit your own paths
-  The .sis and .sisx files are signed with my own Developer Certificate, so they won't install in your test device. If you need to know how to obtain a Developer Certificate for your app, you must check the Symbian Developer Certificate web site

Applicability

This article is focused on building screensavers for s60 3rd. edition phones; if you want to create a screensaver for s60 2nd. edition, there's a good example here: Series 60 Platform 2nd Edition: Screen Saver Example, from Forum Nokia.

Creating the project

The first thing you need to do is create .mmp and bld.inf files for the project. In our example code, we have:

bld.jpg
bld.inf file

It's important to specify the DEFAULT GCCE directive: it instructs the build system to use the free GCC compiler instead of the commercial RCVT 2.2. As you're probably building this with CodeWarrior Personal or Carbide.c++ Express/Developer, you'll what to use GCC because it's the only compiler available.

mmp.jpg
ExampleScreenServer.mmp file

Some noteworthy points are:

-  Setting the TARGETTYPE directive to PLUGIN: this is new for s60 3rd. edition and specifies that you're building an ECom plug-in.
-  0x10009D8D is the ECom dll Recognition UID, while 0x01EF299A is our unique dll UID.
-  The CAPABILITY is also new to s60, due to the Platform Security feature. Unfortunately, due to the ReadDeviceData and WriteDeviceData capabilities requirement, you won't be able to write a screensaver without having a Developer Certificate bound to an ACS Publisher ID, because only those DevCerts have the extended capability set required by the screensaver plugin framework.

Plug-in registration resource file

As screensavers are now ECom plug-ins, you'll need to create a registration resource file, called ExampleScreenSaver.rss, that looks like this:

reg.jpg
ExampleScreenSaver.rss file

Important points in this file:
-  dll_uid and implementation_uid are our dll UID. interface_uid comes straight from the screensaverpluginintdef.hrh file and identifies this plugin as a plugin to the screensaver engine.
-  display_name is the friendly name which will be displayed in the Themes application when you configure the current theme to use your screensaver (see more details below).

The source code

You need to inherit your screensaver class from

CScreensaverPluginInterfaceDefinition,

which implements some ECom construction/destruction code and in turn inherits from

MScreensaverPlugin

which defines the actual interface you will implement in order to make your screensaver to perform the actual job of, well, saving the screen :)

Here's like the header file will look like:

header.jpg
ExampleScreenSaver.h file

The important functions you need to implement in order to have real funcionality in your plugin are:

InitializeL(MScreensaverPluginHost *aHost)

This is will be called once, when the plugin is initialized for the first time, and it will pass you a pointer to the plugin host (MScreensaverPluginHost class), that you can use for important things like: requesting the backlight to be on or off, setting the timer refresh value, setting the active display area (so you save power only activating screen areas where you're actually drawing something), among others.

Draw(CWindowGc& aGc);

This will be called each time the refresh timer expires, passing you a CWindowGc graphics context that you'll use to perform the actual drawing of your fancy animations.

HandleScreensaverEventL(TScreensaverEvent aEvent, TAny* aData);

Here you can handle some screensaver events that interest you. See TScreensaverEvent class documentation in the 3rd. edition SDK.

Here are the implementations of these functions in our example: code1.jpg code2.jpg
ExampleScreenSaver.cpp excerpt

The last thing you need to do is to export a function that provides the mapping between the UID of the implementation and its respective creation function. This is pretty standard ECom code and it's documented in our ImplementationProxy.cpp.

Building, packaging and installing the example

That's the easy part: if you're in Carbide.c++ or CodeWarrior, just perform a full rebuild of the project. If you're building it from the command line, just cd to the group folder and type the command:

abld build gcce urel

This will build ExampleScreenSaver.rsc and ExampleScreenSaver.dll files, which will be copied to

\resource\plugins

and

\sys\bin\

folders in the device, respectively.

Now we're going to create the .sis file that will be installed on the phone. Again, if you're using some IDE, the .sis file will be built (and signed, depending on your configuration) for you automatically. Otherwise, you must cd to the sis folder and build the package, typing:

makesis ExampleScreenSaver.pkg

which will build a ExampleScreenSaver.sis. Prior installing, you need to sign it by using the following command:

signsis ExampleScreenSaver.sis ExampleScreenSaver.sisx your_cert_file.cer your_key_file.key

where your_cert_file.cer is your Developer Certificate, obtained as described at the beginning of this article, and your_key_file.key is the private key file for this certificate.

Installing your screensaver on the device is easy: just transfer it via Bluetooth, cable (using Nokia PC Suite) or downloading it over the Internet.

Your screensaver in action

The following series of screenshots shows you how to activate your screen phone within the Themes application on a 3250 device:

Screenshot0010.jpg
Go to "My own"

Screenshot0011.jpg
Click on "Themes"

Screenshot0013.jpg
Select the current theme and choose "Edit" from the "Options" menu.

Screenshot0015.jpg
Configure your screensaver as the default for the current theme

Conclusion

Well, that's pretty much it. All you need to do is: build your screensaver as an ECom plugin, derive from CScreensaverPluginInterfaceDefinition class and implement the virtual methods from MScreensaverPlugin, build the whole thing, copy generated files to the right locations on the device, and you're done.

If you have any questions to ask or corrections to make, just post a comment :)

[]s
Daniel Rocha
rawsocket.org

Tutorial posted September 4th, 2006 by dcrocha

Submitted by H (not verified) on Mon, 2006-09-04 18:55.

Cool :-)

Tnx


Submitted by symbianwizard on Tue, 2006-09-12 10:39.

I have implemented it and its working

With Regards Bharat Uppal


Submitted by Anonymous on Fri, 2006-09-08 16:37.

How to set plugin as "active screen saver" through code?

Submitted by rahul.cogent on Mon, 2007-04-30 07:37.

Hi,

In the example we need to pass MScreensaverPluginHost* as an arguement of InitializeL() function of CExampleScreenSaver.

Does anyone know how can we implement MScreensaverPluginHost, I have created a class derived from
MScreensaverPluginHost, and overridden all the functions with empty bodies, but it's not working.

Can anyone help???


Submitted by m00gl3 on Fri, 2007-09-07 08:44.

Hi,
I compiled the code, but could not see the custom screensaver on the emulator.

Can someone please help me with this?
Is it possible to use the above sample with 3rd Edition FP1 SDK ?

And what are the steps to implement it in the emulator?
Again, I followed the above instructions but did not see the new screensaver in the list Sad


Submitted by MobileVisuals on Tue, 2008-02-12 09:42.

I tried to complie the project, but I get the error
"Undefined symbol: 'class CExampleScreenSaver * CExampleScreenSaver::NewL(void) (?NewL@CExampleScreenSaver@@SAPAV1@XZ)'[] on Carbide.

I couldn't open the project with Carbide, so I made a new project and then put the files from the example screensaver in the right directories in the created project. Is it OK to do so or does it mess up anything with the application UID?

I haven't worked with Carbide C++ before, but I want to make a Symbian C++ screensaver version of a Java product that my company has released:

http://www.mobile-visuals.com/mobilesoftware.php

It is an application with 10 hypnotic screensavers.


Submitted by MobileVisuals on Mon, 2008-02-18 17:28.

I managed to import the project to Carbide and compile it. But when I start it from the emulator
(configuration-->themes-->power saver) I get the message

themes system error (-2) symbian

Why do I get this message? It is mentioned that hardcoded paths in the project needs to be changed. Which are these paths?

I will give away a free download of my company's product Astral effects to anyone who helps me with this. It is an application with 10 hypnotic sreensavers.
It is hower written in Java, but I want to try and make Symbian C++ saver now.



copyright 2003-2009 NewLC SARL