2008-10-01
GNOME開發文件
在寫Maemo程式時,一直苦於GNOME環境沒有像Qt的assistant一樣方便的程式庫文件程式。今天,無意間發現居然有devhelp這玩意。顧名思義,這東西是寫GNOME平台程式的Help程式。他的功用和assistant一樣,將程式庫的說明文件整理好,包在一個程式中,方便使用者查詢。
Upgrade我的Maemo SDK 4.1
今天又一時手癢,將安裝好的Maemo 4.1整個移除掉,重新安裝4.1.1版。雖然說,可以從4.1直接以apt-get dist-update直接升級就好。但是怎麼試就是不成功,而且還搞壞原本的4.1版,只好又重新來一遍。就當作練習好了!
2008-09-30
Integrating applications into Maemo Application Framework
Maemo .desktop file
- To make an application visible in maemo Task navigator, a desktop file is needed for the application.
- /usr/share/applications/hildon/[application].desktop
- Use af-sb-init.sh restart to restart GUI again in order for the new entry to be seen in the task navigator.
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Example libOSSO <=== the name of the application Exec=/usr/bin/example_libosso ;; <== binary to launch X-Osso-Service=org.maemo.example_libosso ;; <=== D-BUS service name Icon=qgn_list_gene_default_app MimeType=application/x-example;
D-Bus Service File
- Only one instance of a D-BUS service can be run simultaneously, guaranteeing that each application is running only once.
- /usr/share/dbus-1/services/[application].service
- use af-sb-init.sh restart before D-BUS daemon recognizes it.
[D-BUS Service]
Name=org.maemo.example_libosso # D-Bus service name (has to be unique)
Exec=/usr/bin/example_libosso # binary to launch
Labels:
Linux/Ubuntu,
Maemo,
Programming
LibOSSO Library
Maemo initialization
All maemo applications need to be initialized correctly, or they will not work as expected.
Initializing application is performed with osso_initialize() function.
- Connects to D-Bus session bus and system bus.
- Should only be called once in the application.
- The structure of type osso_context_t type that is returned should be stored for later use.
osso_context_t* /* shoud be stored for later use */
osso_initialize(const gchar *application,/* D-BUS name */
const gchar* version, /* application version */
gboolean activation, /* TURE: application binary has been launched by the D-Bus
GMainContext *context /* GLib main-loop context to connect to */
)
osso_deinitialize() should be called to close the message bus connection and free all the memory allocated by the library.
void osso_deinitialize(osso_context_t* osso);
Remote Process Messages
System wide messages in maemo platform are handled with D-BUS system messaging, which is a Remote Process Communication (RPC) method.
osso_rpc_set_cb_f(...);
gint dbus_message_handler(const gchar* interface,
const gchar* method,
GArray* arguments,
gpointer data,
sso_rpc_t* retval);
osso_rpc_run(osso_context,
const gchar* service,
const gchar* object,
const gchar* interface,
const gchar* message,
...);
The receiving application does not even need to be started: D-BUS can automatically start the application based on its service file, and then pass the message to it!.
Hardware State Messages
Maemo applications can connect to listen the system D-BUS messages, like "battery low" and "shutdown".When these messages are received, the application may want to ask the user to save files that are open, or react however wanted.
void hw_event_handler(osso_hw_state_t* state, gpointer data);
state->memory_low_ind
state->system_inactivity_ind
osso_hw_set_event_cb( appdata->osso_context, NULL, hw_event_handler, (gpointer)appdata );
These hardware events are not sent to the SDK, testing them is only possible in maemo device.
System Exit Message
void exit_event_handler(gboolean die_now, goiinter data);
osso_application_set_exit_cb(appdata->osso_context,
exit_event_handler,
(gpointer)appdata);
whenever the system needs to close an application for any reason, exit_event_handler will be performed gracefully.
Information on how to implement state saving can be found in LibOSSO API document.
Labels:
Linux/Ubuntu,
Maemo,
Programming
2008-09-29
Install Maemo Dialo Development Platform 4.1.1
The installation of the Maemo Development Platform contains: Scratchbox,Maemo SDK and Nokia binaries. These three steps can be automated by the script written by Nokia or the community.
Install Scratchbox
Use,
Then, execute,
Install Scratchbox
Use,$ wget http://repository.maemo.org/stable/diablo/maemo-scratchbox-install_4.1.1.shIf the script comlains something about vdso_enabled or min_addr, insert the following settings into your /etc/sysctl.conf. Like,
$ chmod a+x ./maemo-scratchbox-install_4.1.1.sh
$ sudo ./maemo-scratchbox-install_4.1.1.sh
vm.vdso_enabled = 0
vm.mmap_min_addr = 4096
net.ipv4.ip_local_port_range = 1024 65535
Then, execute,
sudo sysctl -p
Install Maemo SDK
Use,
$ wget http://repository.maemo.org/stable/diablo/maemo-sdk-install_4.1.1.sh
$ chmod u+x maemo-sdk-install_4.1.1.sh
$ sudo ./maemo-sdk-install_4.1.1.sh
Install Nokia Binaries
Use,$ wget http://repository.maemo.org/stable/diablo/maemo-sdk-nokia-binaries_4.1.1.shThen, log into Scratchbox system, execute,
$ chmod +x maemo-sdk-nokia-binaries_4.1.1.sh
$ sh maemo-sdk-nokia-binaries_4.1.1.sh
$ /scratchbox/login
[sbox-DIABLO_ARMEL: ~] > fakeroot apt-get install maemo-explicit
Install Virtual X11 server (XEPHYR)
Before we can run applications from SDK, the Xephyr X11 Server has to be installed first.$ sudo apt-get install xserver-xephyr
Labels:
Linux/Ubuntu,
Maemo,
Programming
2008-09-28
Emacsclient in Scratchbox
I am using Emacs to program both at work and home. When I found I can't use Emacsclient inside ScratchBox, although, it is claimed OK in the documentation, I felt a bit surprised. The error reads,
Obviously, the socket file /tmp/esrv1000-yenliang-laptop is not created by Emacs server. I looked into the source code of Emacsclient shipped from Emacs and found that the socket file it is looking for is /tmp/emacs1000/server as indicated by the code below.
But, the code in ScratchBox version is,
I think if I change the socket file path above to match the one used by Emacs server and compiled a new emacsclient, it should work. And it does work.

The screenshot above says it works like a charm, though, the Emacs started the server is version 22.2, not CVS version. The emacsclient fails to connet to the server created by CVS version. My guess is that the CVS version returns the different ID as the client initializes the connection.
Another way you can try is to create a symbolic link at the home directory of the host pointing to the home directory in the ScratchBox system.
[sbox-DIABLO_ARMEL: /tmp] > emacsclient emacsclient-1.c
Can't stat /tmp/esrv1000-yenliang-laptop
[sbox-DIABLO_ARMEL: /tmp] > ls /tmp/esrv1000-yenliang-laptop
ls: /tmp/esrv1000-yenliang-laptop: No such file or directory
Obviously, the socket file /tmp/esrv1000-yenliang-laptop is not created by Emacs server. I looked into the source code of Emacsclient shipped from Emacs and found that the socket file it is looking for is /tmp/emacs1000/server as indicated by the code below.
sprintf(socket_name, "/tmp/emacs%d/%s",
(int)geteuid(), server_name);
But, the code in ScratchBox version is,
sprintf(server.sun_path, "/tmp/eserv%d-%s",
(int)geteuid(), system_name);
I think if I change the socket file path above to match the one used by Emacs server and compiled a new emacsclient, it should work. And it does work.

The screenshot above says it works like a charm, though, the Emacs started the server is version 22.2, not CVS version. The emacsclient fails to connet to the server created by CVS version. My guess is that the CVS version returns the different ID as the client initializes the connection.
Another way you can try is to create a symbolic link at the home directory of the host pointing to the home directory in the ScratchBox system.
ln -s /scratchbox/users/$USER/home/$USER sbox
Labels:
Emacs,
Linux/Ubuntu,
Maemo,
Programming
2008-09-24
HelloWorld example in Hildon Desktop
After a long installation of ScratchBox and Hildon SDK, everyone would like to see how Hildon Desktop looks like. The first thing we should do is to start a virtual X server with a display number different than the host, here we use :2.
The third thing we should do is to start up the Hildon Application Framework.
You should see the Hildon Desktop shown inside the window of the Xephyr, such as,

And now, time to invoke the HelloWorld example.

Cool! In fact, I've had a dilemma choosing OpenMoko or Nokia Internet Tablet to be my off-work hobby. I did try to install OpenMoko SDK, but honestly, it's not quite intuitive and hard to make it work. Inversely, Diablo is very easy to install and get started.
[yenlaingl@yenliangl-laptop:~] Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -extension CompositeThe second thing to do is to redirect the DISPLAY of all X clients in sbox to the :2
export DISPLAY=:2
The third thing we should do is to start up the Hildon Application Framework.
[sbox-DIABLO_ARMEL: ~/workspace]: af-sb-init.sh start
You should see the Hildon Desktop shown inside the window of the Xephyr, such as,

And now, time to invoke the HelloWorld example.
[sbox-DIABLO_ARMEL: ~/workspace]: run-standalone.sh ./hello

Cool! In fact, I've had a dilemma choosing OpenMoko or Nokia Internet Tablet to be my off-work hobby. I did try to install OpenMoko SDK, but honestly, it's not quite intuitive and hard to make it work. Inversely, Diablo is very easy to install and get started.
Labels:
Linux/Ubuntu,
Maemo,
Programming
2008-09-22
This mind map briefly describes the important widgets that can be used to create applications in Nokia internet tablet. It is drawn by FreeMind by the way.
Labels:
Linux/Ubuntu,
Maemo,
MindMap,
Programming
訂閱:
文章 (Atom)