Single Instance Harmattan Applications: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=How to create single-instance applications for N9 Harmattan Meego 1.2=
[toc align_right="yes" depth="3"]


==Important note, read before !!!==
= How to create single-instance applications for N9 Harmattan Meego 1.2 =
 
== Important note, read before [[Image:|Image:]]! ==


'''''This workaround will apply to the Qt 4.7.3 first release supporting Harmattan Meego 1.2 devices'''. The problem is superseeded buy the new Qt 4.7.4 update including the Qt Creator 2.3.0 release. (added Sept, 14, 2011)''
'''''This workaround will apply to the Qt 4.7.3 first release supporting Harmattan Meego 1.2 devices'''. The problem is superseeded buy the new Qt 4.7.4 update including the Qt Creator 2.3.0 release. (added Sept, 14, 2011)''


This How-to aims to reduce to other developers the amount of time that me and other contributors have already spent to find a workaround to build single-instance applications for the N950 / N9 platforms.<br /> At the actual date the problem refers to a bug in the <span class="caps">SDK</span> package 4.7.3 so it is possible hopefully that this page become unuseful in few time. To solve this problem I have found a lot of help but what I am trying here is to give too the reason that need this solution.
This How-to aims to reduce to other developers the amount of time that me and other contributors have already spent to find a workaround to build single-instance applications for the N950 / N9 platforms.<br />At the actual date the problem refers to a bug in the SDK package 4.7.3 so it is possible - hopefully - that this page become unuseful in few time. To solve this problem I have found a lot of help but what I am trying here is to give too the reason that need this solution.


Note: The behavior of the packages created with the Qt <span class="caps">SDK</span> 4.7.3 evidentiates only working on the physical device. Using the <span class="caps">QEMU</span> Harmattan emulator in Qt-Creator it is not clear it this issue can be seen. Thus all those developers that are developing/porting their applications on the Harmattan platform without the possibility to test them on a physical device (formerly the N950) probably ignore this problem at all.
Note: The behavior of the packages created with the Qt SDK 4.7.3 evidentiates only working on the physical device. Using the QEMU Harmattan emulator in Qt-Creator it is not clear it this issue can be seen. Thus all those developers that are developing/porting their applications on the Harmattan platform without the possibility to test them on a physical device (formerly the N950) probably ignore this problem at all.


==Starting point==
== Starting point ==


* The compiled/packaged applications for Qt-Meego are not single-instance
* The compiled/packaged applications for Qt-Meego are not single-instance
* Multi-instance is prohibitied
* Multi-instance is prohibitied
* This is a bug of Qt-Creator (or the <span class="caps">SDK</span> or both, not sure of the origin)
* This is a bug of Qt-Creator (or the SDK or both, not sure of the origin)


==Workaround==
== Workaround ==


===Modify the rules file===
=== Modify the rules file ===


Open with a external editor the ''rules'' file in the qtc_packaging/debian_harmattan folder changing the following line<br /> to<br /> as is add a second ''<span class="caps">SPACE</span>'' character after ''$(<span class="caps">MAKE</span>)'' leaving the initial ''<span class="caps">TAB</span>'' character <br />''This solve the problem of the multi-instance but at this point the _.desktop'' file don’work correctly
Open with a external editor the ''rules'' file in the qtc_packaging/debian_harmattan folder changing the following line<br /><code><br />[TAB]$(MAKE)*[SPACE]*INSTALL_ROOT=&quot;$(CURDIR)&quot;/debian/&amp;lt;application_name&amp;gt; install<br /></code><br />to<br /><code><br />[TAB]$(MAKE)[SPACE][SPACE]INSTALL_ROOT=&quot;$(CURDIR)&quot;/debian/&amp;lt;application_name&amp;gt; install<br /></code><br />as is add a second ''SPACE'' character after ''$(MAKE)'' leaving the initial ''TAB'' character<br />''This solve the problem of the multi-instance but at this point the''.desktop_ file don'work correctly


'''Please note:''' Do '''not''' open the ''rules'' file with Qt Creator but with emacs/vim/your editor. Qt Creator will substitute spaces for the tab and then your app will not install.
'''Please note:''' Do '''not''' open the ''rules'' file with Qt Creator but with emacs/vim/your editor. Qt Creator will substitute spaces for the tab and then your app will not install.


===Modify the .desktop file===
=== Modify the .desktop file ===
 
Edit in Qt-Creator the ''.desktop'' file setting the correct '''Icon''' pointer that should be<br /> At this point it is probable that the icon is now shown in the program. As a matter of fact the application icon (those shown on the device main page) depends from the encoded icon in the ''control'' file. To avoid this problem it is necessary to open the ''project'' section in Qt-Creator, open the ''run'' tab in the ''Harmattan'' target expanding the '''Create Package''' group. Select the icon again and confirm.


The ''.desktop'' file at this point works correctly trying to launch the application using the ''invoker'' command in a line like the following:<br /> Tapping on the application icon the program don’t start. Launching the invoker with the same command line from the device terminal this is the received error:<br />
Edit in Qt-Creator the ''.desktop'' file setting the correct '''Icon''' pointer that should be<br /><code><br />Icon=/usr/share/icons/hicolor/64x64/apps/&amp;lt;application_name&amp;gt;.png<br /></code><br />At this point it is probable that the icon is now shown in the program. As a matter of fact the application icon (those shown on the device main page) depends from the encoded icon in the ''control'' file. To avoid this problem it is necessary to open the ''project'' section in Qt-Creator, open the ''run'' tab in the ''Harmattan'' target expanding the '''Create Package''' group. Select the icon again and confirm.


===Modify the main.cpp source===
The ''.desktop'' file at this point works correctly trying to launch the application using the ''invoker'' command in a line like the following:<br /><code><br />Exec=invoker —single-instance —type=d /opt/&amp;lt;application_name&amp;gt;/bin/&amp;lt;application_name&amp;gt;<br /></code><br />Tapping on the application icon the program don't start. Launching the invoker with the same command line from the device terminal this is the received error:<br /><code><br />invoker: Invoking execution: '/opt/&amp;lt;application_name&amp;gt;/bin/&amp;lt;application_name&amp;gt;'<br />Booster: Loading symbol 'main'<br />failed: '/opt/&amp;lt;application_name&amp;gt;/bin/&amp;lt;application_name&amp;gt;:<br />undefined symbol: main'<br /></code>


The QtDeclarative main() is not exported by default so – as explained by matrixx – it is necessary to change the ''main()'' function declaration in the '''main.cpp''' source as follows:<br />
=== Modify the main.cpp source ===


At this point, recompiling, packaging and deploying to the device the application should works fine.
The QtDeclarative main() is not exported by default so - as explained by matrixx - it is necessary to change the ''main()'' function declaration in the '''main.cpp''' source as follows:<br /><code><br />Q_DECL_EXPORT int main(int argc, char *argv[])<br />{<br />…<br />}<br /></code>

Revision as of 10:56, 24 February 2015

[toc align_right="yes&quot; depth="3&quot;]

How to create single-instance applications for N9 Harmattan Meego 1.2

Important note, read before [[Image:|Image:]]!

This workaround will apply to the Qt 4.7.3 first release supporting Harmattan Meego 1.2 devices. The problem is superseeded buy the new Qt 4.7.4 update including the Qt Creator 2.3.0 release. (added Sept, 14, 2011)

This How-to aims to reduce to other developers the amount of time that me and other contributors have already spent to find a workaround to build single-instance applications for the N950 / N9 platforms.
At the actual date the problem refers to a bug in the SDK package 4.7.3 so it is possible - hopefully - that this page become unuseful in few time. To solve this problem I have found a lot of help but what I am trying here is to give too the reason that need this solution.

Note: The behavior of the packages created with the Qt SDK 4.7.3 evidentiates only working on the physical device. Using the QEMU Harmattan emulator in Qt-Creator it is not clear it this issue can be seen. Thus all those developers that are developing/porting their applications on the Harmattan platform without the possibility to test them on a physical device (formerly the N950) probably ignore this problem at all.

Starting point

  • The compiled/packaged applications for Qt-Meego are not single-instance
  • Multi-instance is prohibitied
  • This is a bug of Qt-Creator (or the SDK or both, not sure of the origin)

Workaround

Modify the rules file

Open with a external editor the rules file in the qtc_packaging/debian_harmattan folder changing the following line

<br />[TAB]$(MAKE)*[SPACE]*INSTALL_ROOT=&quot;$(CURDIR)&quot;/debian/&amp;lt;application_name&amp;gt; install<br />


to

<br />[TAB]$(MAKE)[SPACE][SPACE]INSTALL_ROOT=&quot;$(CURDIR)&quot;/debian/&amp;lt;application_name&amp;gt; install<br />


as is add a second SPACE character after $(MAKE) leaving the initial TAB character
This solve the problem of the multi-instance but at this point the.desktop_ file don'work correctly

Please note: Do not open the rules file with Qt Creator but with emacs/vim/your editor. Qt Creator will substitute spaces for the tab and then your app will not install.

Modify the .desktop file

Edit in Qt-Creator the .desktop file setting the correct Icon pointer that should be

<br />Icon=/usr/share/icons/hicolor/64x64/apps/&amp;lt;application_name&amp;gt;.png<br />


At this point it is probable that the icon is now shown in the program. As a matter of fact the application icon (those shown on the device main page) depends from the encoded icon in the control file. To avoid this problem it is necessary to open the project section in Qt-Creator, open the run tab in the Harmattan target expanding the Create Package group. Select the icon again and confirm. The .desktop file at this point works correctly trying to launch the application using the invoker command in a line like the following:

<br />Exec=invoker single-instance type=d /opt/&amp;lt;application_name&amp;gt;/bin/&amp;lt;application_name&amp;gt;<br />


Tapping on the application icon the program don't start. Launching the invoker with the same command line from the device terminal this is the received error:

<br />invoker: Invoking execution: '/opt/&amp;lt;application_name&amp;gt;/bin/&amp;lt;application_name&amp;gt;'<br />Booster: Loading symbol 'main'<br />failed: '/opt/&amp;lt;application_name&amp;gt;/bin/&amp;lt;application_name&amp;gt;:<br />undefined symbol: main'<br />

Modify the main.cpp source

The QtDeclarative main() is not exported by default so - as explained by matrixx - it is necessary to change the main() function declaration in the main.cpp source as follows:

<br />Q_DECL_EXPORT int main(int argc, char *argv[])<br />{<br /><br />}<br />