Single Instance Harmattan Applications: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(Remove inaccurate statement about Maemo/MeeGo successor. See Talk:Support for Maemo)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=How to create single-instance applications for N9 Harmattan Meego 1.2=
{{Outdated|reason=The MeeGo/Harmattan platform is no longer supported.}}
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}


==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.
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
<code>
[TAB]$(MAKE)*[SPACE]*INSTALL_ROOT="$(CURDIR)"/debian/<application_name> install
</code>
to
<code>
[TAB]$(MAKE)[SPACE][SPACE]INSTALL_ROOT="$(CURDIR)"/debian/<application_name> install
</code>
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.
'''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
<code>
Icon=/usr/share/icons/hicolor/64x64/apps/<application_name>.png
</code>
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:
<code>
Exec=invoker —single-instance —type=d /opt/<application_name>/bin/<application_name>
</code>
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:
<code>
invoker: Invoking execution: '/opt/<application_name>/bin/<application_name>'
Booster: Loading symbol 'main'
failed: '/opt/<application_name>/bin/<application_name>:
undefined symbol: main'
</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:
<code>
Q_DECL_EXPORT int main(int argc, char *argv[])
{
}
</code>

Latest revision as of 15:06, 27 April 2015

IMPORTANT: The content of this page is outdated. Reason: The MeeGo/Harmattan platform is no longer supported.
If you have checked or updated this page and found the content to be suitable, please remove this notice.
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.


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

[TAB]$(MAKE)*[SPACE]*INSTALL_ROOT="$(CURDIR)"/debian/<application_name> install

to

[TAB]$(MAKE)[SPACE][SPACE]INSTALL_ROOT="$(CURDIR)"/debian/<application_name> install

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

Icon=/usr/share/icons/hicolor/64x64/apps/<application_name>.png

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:

Exec=invoker single-instance type=d /opt/<application_name>/bin/<application_name>

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:

invoker: Invoking execution: '/opt/<application_name>/bin/<application_name>'
Booster: Loading symbol 'main'
failed: '/opt/<application_name>/bin/<application_name>:
undefined symbol: main'

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:

Q_DECL_EXPORT int main(int argc, char *argv[])
{

}