tag:blogger.com,1999:blog-16381892585365596242024-03-21T19:24:07.796+01:00FlyingSheep on Sailfish FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.comBlogger33125tag:blogger.com,1999:blog-1638189258536559624.post-24123259343535843552014-02-16T17:58:00.001+01:002014-02-16T17:58:50.516+01:00New Sailfish Demos Posted to Github<p>Hi All</p>
<p>I have been very busy recently, porting apps to my new Jolla (which arrived in the nick of time for the close of 2013). As a result I have rather neglected this blog.</p>
<p>That notwithstanding, I have created a number of mini-demos to illustrate interesting things I came across while porting to Sailfish.</p>
<p>I hope to post more details on some of these over then next few weeks, but for the moment here are links to the demos on Github.</p><br /><a name='more'></a><br /><p><span style="font-size: 12px;"><span style="color: #ff9300;"><strong>An "Initial Picker" modelled that in the Sailifsh People app</strong></span></span></p>
<p><a href="https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/InitialPickerDemo2">https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/InitialPickerDemo2</a></p>
<p><span style="font-size: 12px;"><span style="color: #ff9300;"><strong>A Torch App, using Gstreamer, and Resource Permissions.</strong></span></span></p>
<p><a href="https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/GSTTorch2">https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/GSTTorch2</a></p>
<p><span style="font-size: 12px;"><span style="color: #ff9300;"><strong>Using a json file instead of a LocalStorageDB thanks to JsonPath</strong></span></span></p>
<p><a href="https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/JsonDBDemo">https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/JsonDBDemo</a></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-55117575786028127912014-01-05T21:55:00.001+01:002014-01-05T21:55:33.475+01:00Connecting to a Jolla via SSH over USB from OSX<p>Out of the box it is not possible to connect to your new Jolla via SSH over USB from OSX.</p>
<p>This is inconvenient: for instance I do lots of development work on the train, where there is no WLAN (or rather it there is, but not free), or at work, where I can't connect the Jolla to the corporate network, and have not got it (yet) to connect to the Visitor WLAN.</p>
<p>But with a bit of tweaking it is possible to get an SSH over USB connection going.</p><br /><a name='more'></a><br /><p>I found the main idea here: <a href="https://plus.google.com/+MikkoAhlroth/posts/ZQFRBfCjRsy">https://plus.google.com/+MikkoAhlroth/posts/ZQFRBfCjRsy</a> Thanks to Mikko for shown me how.</p>
<p>This uses the <span style="font-family: Helvetica; font-size: 12px;"><strong>horndis</strong></span> driver available at <a href="http://joshuawise.com/horndis">http://joshuawise.com/horndis</a> It's tiny, so it will take only seconds to download.</p>
<p>Before you start, make sure you are not already connected to your Jolla via SSH over WLAN. if so disconnect.</p>
<p>Install the <span style="font-family: Helvetica; font-size: 12px;"><strong>horndis</strong></span> driver to your OSX development host.</p>
<p>On your Jolla open System Settings / Developer Mode / Developer Tools. Select the USB Connection. If you have a Nokia N9, then you will need to change the Jolla's default IP number from 192.168.2.15 to something else. This is because this number is already used by the N9. I chose 192.168.2.17. Don't chose 19.168.2.16, as this IP number will be used by the development host.</p>
<p>Plugin your Jolla via USB. You should get get a blue popup allowing you to select Developer Mode. Select Developer Mode.</p>
<p>Next on your OSX development host open System Preferences / Network. You should have a new entry Sailfish.</p>
<p>Set:</p>
<p>Configure IPv4: Manually</p>
<p>IP Address 192.168.2.16 (this will be IP of your OSX developer host, as seen from your Jolla)</p>
<p>Subnet Mask 255.255.255.0</p>
<p>Router 192.168.2.17 (the IP number you set on your Jolla under Developer Tools)</p>
<p>DNS Server 192.168.2.17 (set this via Advanced)</p>
<p>Press Apply at the bottom of the Network Dialog.</p>
<p><img title="NewImage.png" src="http://lh6.ggpht.com/-6E_vBFmRsVE/Usm_0V3jEfI/AAAAAAAAADk/2HnwroS8vGI/NewImage.png?imgmax=800" alt="NewImage" width="600" height="520" border="0" /></p>
<p>Now you should be able to connect via SSH over USB</p>
<p><span style="font-family: Courier; font-size: 12px;">ssh nemo@192.168.2.17</span></p>
<p>Or, if you read my last post, and have setup a RSA file for connection to your Jolla:</p>
<p><span style="font-family: Courier; font-size: 12px;">ssh -i ~/.ssh/jolla_rsa nemo@192.168.2.17</span></p>
<p>If you get asked:</p>
<p><span style="font-family: Courier; font-size: 12px;"><span style="color: #011993;">The authenticity of host '192.168.2.17 (192.168.2.17)' can't be established.<br />RSA key fingerprint is ca:c9:59:e8:dd:78:67:51:74:c4:d5:9b:6f:83:20:a9.<br />Are you sure you want to continue connecting (yes/no)?</span></span></p>
<p>Answer with yes</p>
<p>P.s. you may need to restart your OSX host during the process if this does not work first time.</p>
<p>Enjoy!</p>
<p> </p>
<p> </p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com2tag:blogger.com,1999:blog-1638189258536559624.post-25844578708331279702014-01-05T18:19:00.001+01:002014-01-05T18:19:50.663+01:00Connecting to a Jolla with a RSA Key File for password-less SSH Access<p style="font-family: 'Lucida Grande';">In a much earlier article, I showed how we can connect to a Nokia N9 phone with an RSA key for pas wordless SSH access in much the same way we connect to the Sailfish Emulator and SDK.</p>
<p style="font-family: 'Lucida Grande';">Surprise surprise, exactly the same is possible with a real Jolla device. No more typing in long passwords!</p>
<p style="font-family: 'Lucida Grande';"><span style="font-family: Courier; font-size: 12px;">Black Courier</span> shows commands typed on your development host.</p>
<p style="font-family: 'Lucida Grande';"><span style="font-family: Courier; font-size: 12px;"><span style="color: #011993;">Blue Courier</span></span> shows commands typed on your Jolla (via SSH).</p>
<p style="font-family: 'Lucida Grande';">This article show how to do this for OSX and Linux. With a few extra steps, the same should be possible from Windows using Putty. See the previous example on connecting via Putty.</p><br /><a name='more'></a><br /><p style="font-family: 'Lucida Grande';">Please note: you do this at your own risk! In my case this operation was absolutely painless, but if it turns your new toy into a useless brick, don't come running to me!</p>
<p style="font-family: 'Lucida Grande';">Firstly we need to generate a key pair on our development host. In this case I will be using Apple-pip my MacBookAir. This will give us a public key and a private key. The private key will remain securely on Apple-pip (the client in the connection), and the public key will be put on to the connection server - the Jolla.</p>
<p style="font-family: 'Lucida Grande';">So on Apple-Pip: let's move the .ssh directory, then list what's already there</p>
<p style="font-family: 'Lucida Grande';"><span style="font-family: Courier; font-size: 12px;">cd ~/.ssh</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">ls -ahl</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">Now we will generate a key pair called jolla_rsa, with an empty passphrase.</p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">ssh-keygen -t rsa</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">Generating public/private rsa key pair.</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">Enter file in which to save the key (~/.ssh/id_rsa): jolla_rsa</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">Enter passphrase (empty for no passphrase): </span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">Enter same passphrase again: </span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">Your identification has been saved in jolla_rsa.</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">Your public key has been saved in jolla_rsa.pub.</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">The key fingerprint is:</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">f1:8e:51:ab:d8:0c:fb:2f:ee:9c:fd:d5:02:25:69:d6 xxxxxxx@Apple-Pip.local</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">The key's randomart image is:</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">+--[ RSA 2048]----+</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| |</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| o |</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| . . = E |</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| + + o |</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| . S o . |</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| * = . . |</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| o = . o .|</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| o.o . . |</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">| o*oo.. |</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">+-----------------+</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">Now if we ls again we should find 2 additional files, </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">* private key jolla_rsa</p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">* and the public key jolla_rsa.pub</p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px; min-height: 14px;">Now we need to transfer the public key to the Jolla:</p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;">scp ~/.ssh/jolla_rsa.pub nemo@192.168.72.100:/home/nemo/</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">Note, for the time being I am using SSH via WLAN (because the more obvious SSH via USB does not work on OSX yet). However you are connect: substitute your Jolla's IP number, as shown on the developer tools page in Settings.</p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">Then we connect to the Jolla as we always have done, with password <span style="font-family: 'Lucida Grande';">(using your Jolla's IP number):</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier; font-size: 12px;">nemo@192.168.72.100</span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">Once connected, move to the .ssh directory.</p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;"><span style="color: #011993;">cd .ssh</span></span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">Now we want to concatenate the contents of the public key to the authorized_keys file</p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;"><span style="color: #011993;">cat ../jolla_rsa.pub >> authorized_keys</span></span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;">Then we cleanup by removing the public key file from the Jolla.</p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;"><span style="color: #011993;">cd ..</span></span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;"><span style="color: #011993;"><br /></span></span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"><span style="font-family: Courier;"><span style="color: #011993;">rm jolla_rsa.pub</span></span></p>
<p style="font-size: 12px; font-family: 'Lucida Grande'; margin: 0px;"> </p>
<p style="font-family: 'Lucida Grande';">Exit, and try reconnecting from your development host as follows (using your Jolla's IP number):</p>
<p style="font-family: 'Lucida Grande';"><span style="font-size: 12px; font-family: Courier;">ssh -i ~/.ssh/jolla_rsa <span style="font-family: Courier; font-size: 12px;">nemo@192.168.72.100</span></span></p>
<p style="font-family: 'Lucida Grande';">And Voila! we are in.</p>
<p><span style="color: #011993;"><span style="font-family: Courier; font-size: 12px;">Last login: Sun Jan 5 17:18:30 2014 from 192.168.72.113</span><br /><span style="font-family: Courier; font-size: 12px;">,---</span><br /><span style="font-family: Courier; font-size: 12px;">| SailfishOS 1.0.2.5 (Maadajävri) (armv7hl)</span><br /><span style="font-family: Courier; font-size: 12px;">'---</span><br /></span><span style="font-family: Courier; font-size: 12px;"><span style="color: #011993;">[nemo@localhost ~]$</span></span></p>
<p style="font-family: 'Lucida Grande';"><span style="font-size: 12px; font-family: Courier;"><span style="font-family: Courier; font-size: 12px;"><br /></span></span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com2tag:blogger.com,1999:blog-1638189258536559624.post-15616437448783431542013-12-22T23:49:00.001+01:002013-12-23T11:19:03.497+01:00Deploying Additional Packages to the Sailfish Emulator and SDK updated<p>As new versions of the Sailfish SDK are released, so installing stuff changes a little.</p>
<p>Because of that, over the past few days I have made several updates to this article to reflect these changes, especially the use of PkCon / PackageKit.</p>
<p><a href="http://flyingsheeponsailfish.blogspot.ch/2013/11/deploying-additional-packages-to.html">http://flyingsheeponsailfish.blogspot.ch/2013/11/deploying-additional-packages-to.html</a></p>
<p>As I used QtLocation and QtPositioning in the examples, I am also posting a link to this tutorial</p>
<p><a href="https://github.com/b0bben/SailfishOS_MapTutorial">https://github.com/b0bben/SailfishOS_MapTutorial</a></p>
<p>This tutorial gives more in-depth advice on the use of QtLocation and QtPositioning, in addition to how to install.</p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-26908798810534463692013-11-02T17:26:00.001+01:002013-12-24T11:41:32.794+01:00Deploying Additional Packages to the Sailfish Emulator and SDK<p><span style="font-family: Helvetica; font-size: 12px;"><em><span style="color: #ff2600;">Latest update is 24 Dec 2013 11:40 UK time.</span></em></span></p>
<p>One of the areas that raises the most questions on the Sailfish Developers' mailing list is the sticky topic of Installing additional packages to the Sailfish Emulator and SDK. Many developers, including myself have found installation very confusing.</p>
<p>The reasons for the confusion are clear: there is no official documentation on this topic yet, thought it is promised; there are a number of different ways that a package can be installed; both the Emulator and SDK may required installation; each package is available in a number of flavours; and then there is the challenge of identifying the correct package in the first page, and determining the correct name of that package. And if that was not enough, due to the refactoring of Qt Mobility from Qt 4 to Qt 5, some of our favourite components are now offered by quite different packages.</p>
<p>This post should give you a broad understanding of the different installation techniques. To those who live and breath Linux, who first compiled the kernel before they went to school, much of this may be obvious. To the rest of us from different development backgrounds it is less so, hence this post</p>
<p>We will look at <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span>, <span style="font-family: Helvetica; font-size: 12px;"><strong>PkCon</strong></span>, <span style="font-family: Helvetica; font-size: 12px;"><strong>ScratchBox2</strong></span>, <span style="font-family: Helvetica; font-size: 12px;"><strong>yaml</strong></span> and <span style="font-family: Helvetica; font-size: 12px;"><strong>spectacle. </strong><span style="font-size: 12px;">We will find out how to install "by hand*, and automatically on building and running</span><strong>.</strong></span></p><br /><a name='more'></a><br /><p>If your app does anything interesting at all, then fairly soon you will want to use functionality not included in the packages pre-installed on the Sailfish Alpha Emulator / SDK. I am sure that the number of default packages will increase as Sailfish moves on to Beta and to real physical devices, but even then you app may need "something extra"; and one of the great things about the Sailfish world is that being based on Qt, Nemo and Meego there is a lot of stuff out there. Unfortunately some of these super packages will make you application ineligible for Jolla Harbour inclusion, but that is a problem for another day. That notwithstanding you can "easily" install these packages to your device.</p>
<p>Except that the "easily" turns out not to be quite that "easy" until you have spent some time understanding how <span style="font-family: Helvetica; font-size: 12px;">installation</span> works.</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Installation Targets</strong></span></span></p>
<p>The first stumbling block is that there are two targets you may potentially need to install stuff to. For want of a better word I will use the term "Installation Target". In the first evolutions of the Sailfish Alpha this was more obvious then it is now, as there were two visible virtual machines running, the Emulator, and the SDK build machine. As of the end of October 2013 the second of these is still very much there, and just as important as ever, but it now runs in stealth "headless" mode. </p>
<p>The <span style="font-family: Helvetica; font-size: 12px;"><strong>Emulator</strong></span> is the bit that looks like a Sailfish phone, and is the thing that (for the time-being) our apps will run on. Later when we get real Sailfish hardware in our grubby paws, then we will be able to substitute "Sailfish phone" for Emulator in this post. Packages that you install to the Emulator are packages that your application requires to run.</p>
<p>The second Installation Target is the<span style="font-family: Helvetica; font-size: 12px;"><strong> SDK Build Engine Virtual Machine</strong></span>. This is a Nemo Linux installation in its own right. On this runs <span style="font-family: Helvetica; font-size: 12px;"><strong>Scratchbox2 (SB2)</strong></span> with the ARM and i486 Targets to which we will need to install packages in order to build and run our code. Note that the <span style="font-family: Helvetica; font-size: 12px;"><strong>SB2</strong></span> Targets should not be confused with the underlying operating system / build engine: it is also possible to install stuff to the OS, but for development purposes we need to install to <span style="font-family: Helvetica; font-size: 12px;"><strong>SB2</strong></span> Target(s) chain, not the OS. More on this later. Packages that you install to <span style="font-family: Helvetica; font-size: 12px;"><strong>SB2 Targets</strong></span> are packages that your application requires to build, and for <span style="font-family: Helvetica; font-size: 12px;"><strong>QtCreator</strong></span> auto-code-completion to work properly.</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Package Types</strong></span></span></p>
<p>Somehow or other you have come across a package that you want to use. But as you look into the detail of the package, you find that it is available in different flavours. You will come across versions with devel in the name or with import-declarative, or even debug. All clearly related, but which do you need, and where?</p>
<p>Not all package developers follow the rules, but many do follow these rules of thumb.</p>
<p>The first thing to ascertain is the Qt version of the Package. As we are developing for Sailfish, we will want <span style="font-family: Helvetica; font-size: 12px;"><strong>Qt5</strong></span> packages, and normally the Qt5 version of a package will have <span style="font-family: Helvetica; font-size: 12px;"><strong>Qt5</strong></span> in the name, so plumb for that one first.</p>
<p>Packages with <span style="font-family: Helvetica; font-size: 12px;"><strong>devel</strong></span> in the name are required for C++ development, and should be installed to the SKD Build Engine, but not to the Emulator / Real Device. Installing a <span style="font-family: Helvetica; font-size: 12px;"><strong>devel</strong></span> package should normally automatically also install the main package of the same name.</p>
<p>The main package (i.e. the flavour without devel, debug, declarative etc.) in the name should be installed to both the SDK Build Engine and the Emulator / Real Device.</p>
<p>Packages with <span style="font-family: Helvetica; font-size: 12px;"><strong>import-declarative</strong></span> in the name are required for QML development and should be installed to both the SDK Build Engine and the Emulator / Real Device. If they are not present on the Emulator, then if you app imports and uses QML components offered by the package, then your app will not run. It is possible that you may be able to build your app if the import-declarative package is not present on the Build Engine, but Qt Creator will not recognise the import statement or the imported QML component, and auto-code-completion won't hep you, so programming with the components won't be much fun.</p>
<p>Packages with <span style="font-family: Helvetica; font-size: 12px;"><strong>debug</strong></span> in the name are used for debugging.</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Installation Routes</strong></span></span></p>
<p>Thee are 2 principal routes to installing additional packages: "By Hand", and "Automatically on Build via Spectacle". While the results are identical, we will see later that installing automatically on build is the preferred option, yet installing by hand is still useful, an important part of the learning curve, and some of the tools are even more useful for locating packages.</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff9300;"><strong>A Refresher: Connecting to the Emulator and SDK via SSH</strong></span></span></p>
<p>In the next sections we will learn how to install by hand. To do so we will need to connect via SSH to the SDK and Emulator. I have posted articles in the past focussing on this, but her is a refresher of the commands used by the latest release of the SDK.</p>
<p style="margin: 0px; font-size: 12px;">//Connect to SDK</p>
<p style="margin: 0px; font-size: 12px;">ssh -p 2222 -i ~/SailfishOS/vmshare/ssh/private_keys/engine/mersdk mersdk@localhost</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">ssh -p 2222 -i ~/SailfishOS/vmshare/ssh/private_keys/engine/root root@localhost</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">//Connect to Emulator</p>
<p style="margin: 0px; font-size: 12px;">ssh -p 2223 -i ~/SailfishOS/vmshare/ssh/private_keys/SailfishOS_Emulator/root root@localhost</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">ssh -p 2223 -i ~/SailfishOS/vmshare/ssh/private_keys/SailfishOS_Emulator/nemo nemo@localhost</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><strong><span style="color: #ff9300;">Installing By Hand to the Emulator via PkCon and <span style="font-family: Courier; font-size: 20px;">zypper</span></span></strong></span></p>
<p>To install packages "by hand", we'll connect by SSH and use the RPM package management tools <span style="font-family: Helvetica; font-size: 12px;"><strong>PkCon</strong></span> and <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span>.</p>
<p>Why 2 tools?</p>
<p>Early version of the SDK used <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> as the default package manager on the Emulator, and it is still used on the SDK Build Engine / SB2. However with the current version of the SDK , the Emulator now uses <span style="font-family: Helvetica; font-size: 12px;"><strong>PkCon</strong></span>.</p>
<p>Both tools are similar in scope, so which you use is a matter of personal taste and experience. I still prefer <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span>, but am gradually getting the hang of <span style="font-family: Helvetica; font-size: 12px;"><strong>PkCon</strong></span>.</p>
<p>You will find plenty of advice on the internet on <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> - look out for <a href="https://en.opensuse.org/images/3/30/Zypper-cheat-sheet-2.pdf">"zypper cheat sheet",</a> so I won't go into more detail here.</p>
<p>Update 20.12.2013: The latest SDK release no longer includes <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> by default on the Emulator. But you can easily install it by running: </p>
<p><span style="font-family: Courier; font-size: 12px;">pkcon install zypper</span></p>
<p>Once <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> is installed the first useful call is:</p>
<p><span style="font-family: Courier; font-size: 12px;">zypper se</span></p>
<p>This searches the Emulator and repositories to which it is connected for all installed and available packages. Packages marked with "i" are installed, those without are not installed (yet). </p>
<p>If you only have packages with "i", then you should try "<span style="font-family: Courier; font-size: 12px;">zypper refresh</span>" to refresh the available packages.</p>
<p><span style="font-family: Courier; font-size: 12px;">"zypper se"</span> should present you with a very long list of candidate packages, too long to be useful, so lets narrow down our search a bit. Let's say that we want GPS functionality, and we have heard that this is offered by QtLocation. In which case we could try this search:</p>
<p><span style="font-family: Courier; font-size: 12px;">zypper se location</span></p>
<p>This will present us all packages available with location in the name. On my Emulator this is:</p>
<p><span style="font-family: Courier; font-size: 12px;">S | Name | Zusammenfassung | Typ </span><br /><span style="font-family: Courier; font-size: 12px;">--+---------------------------------------------+-----------------------------------------------------------------+-----------</span><br /><span style="font-family: Courier; font-size: 12px;"> | libdeclarative-location | Qt Mobility Location QML plugin | Paket </span><br /><span style="font-family: Courier; font-size: 12px;"> | libqtlocation1 | Qt Mobility Location module | Paket </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt5-qtdeclarative-import-location | QtDeclarative location import | Paket </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt5-qtdeclarative-import-location-debuginfo | Debug information for package qt5-qtdeclarative-import-location | Paket </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt5-qtlocation | The QtLocation library | Paket </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt5-qtlocation-debuginfo | Debug information for package qt5-qtlocation | Paket </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt5-qtlocation-devel | Development files for QtLocation | Paket </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt5-qtlocation-source | Cross-platform application and UI framework | Quellpaket</span><br /><span style="font-family: Courier; font-size: 12px;"> | qt5-qtlocation-source-debugsource | Debug sources for package qt5-qtlocation-source | Paket </span><br /><span style="font-family: Courier; font-size: 12px;"> | statefs-provider-inout-location | Statefs inout provider: location information | Paket</span></p>
<p>So if we want to install <span style="font-family: Courier; font-size: 12px;">qt5-qtlocation, <span style="font-family: Helvetica; font-size: 12px;">we do the following:</span></span></p>
<p><span style="font-family: Courier; font-size: 12px;"><span style="font-size: 12px;">zypper in <span style="font-size: 12px;">qt5-qtlocation</span></span></span></p>
<p>Of course we can also remove packages with <span style="font-family: Courier; font-size: 12px;">zypper rm</span>, so real free to play around, and add and remove things.</p>
<p>The <span style="font-family: Helvetica; font-size: 12px;"><strong>PkCon</strong></span> equivalent calls are:</p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">pkcon search name location</span></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"><span style="font-family: Courier; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">pkcon install qt5-location</span></p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Installing By Hand to the SDK Build Engine via the Control Center</strong></span></span></p>
<p>We could use <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> to install to<span style="font-family: Helvetica; font-size: 12px;"><strong> SB2 Targets</strong></span> (and we look at how later), but it much easier to use the "SDK Control Center" to do so, as this is conveniently found in Qt Creator. Press the Sailfish Icon on the lefthand edge of QtCreator and chose the Targets tab.</p>
<p>We now have a choice of 2 targets. At a later date, when we finally get real hardware we will be able to use<span style="font-family: Helvetica;"> the </span><span style="font-size: 12px; text-align: left;"><span style="font-size: 12px;"><strong>SailfishOS-armv7hl</strong> </span>target, but for the moment we will take the we will chose <span style="font-family: Helvetica; font-size: 12px;"><strong>SailfishOS-i486-x86</strong></span> to test with the emulator. So click</span> the "manage" button next to the <span style="font-size: 12px; text-align: left; font-family: Helvetica;"><strong>SailfishOS-i486-x86</strong></span> build target.</p>
<p>Just like <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper </strong><span style="font-size: 12px;">or</span><strong> PkCon</strong></span>, we can use the Control Center to search for packages using part of the name The control center will start to suggest packages as soon as you start typing, so type slowly, and no enter is required! Some packages will be listed twice, as source packages are also listed. Once you have found a candidate package, you can install or deinstall by the buttons next to the package name. So using our location example, here we might chose to install <span style="font-family: Courier; font-size: 12px;">qt5-qtlocation-devel <span style="font-family: Helvetica; font-size: 12px;">which should automatically also install</span> <span style="font-family: Courier; font-size: 12px;">qt5-qtlocation.</span></span></p>
<p>Having installed manually via <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> to the Emulator, and via the Control Center to the SDK Build Engine your app should now build and run - assuming of course that you have identified and installed the correct package "flavours" to the appropriate Installation Target.</p>
<p>Even though I now tend to install via the applications yaml file (more of which later), I find the control centre a good way of checking what is currently installed, and of searching for available packages. I note the name found in Control Center and add that to the yaml file.</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><strong><span style="color: #ff9300;">Installing by Hand to the SDK Build Engine using zypper.</span></strong></span></p>
<p>Connect to the SDK VM as user <span style="font-family: Helvetica; font-size: 12px;"><strong>mersdk</strong></span>, and search for all Qt5 packages already installed with:</p>
<p><span style="font-family: Courier; font-size: 12px;">zypper se qt5 | grep "i |"</span></p>
<p>Then search for Qt5 packages in the SDK Control Center.</p>
<p>Notice anything?</p>
<p>The list of installed Qt5 packages found by zypper will be much shorter than that found by the Control Center.</p>
<p>So what's up?</p>
<p>To prove a point I have deliberately guided you to look in the wrong place! Remember I said that we should not confuse the SDK Operating System with the Build Engine?. Well using zypper directly tells us what is installed to the OS. It tells us noting about the packages available to the Build Engine. Installing a missing package here with zypper will have no effect on your build. Instead we need to enter the world of the build engine by typing:</p>
<p><span style="font-family: Courier; font-size: 12px;">sb2 -t SailfishOS-i486-x86</span></p>
<p>and then repeat <span style="font-family: Courier; font-size: 12px;">zypper se qt5 | grep "i |"</span></p>
<p>This should give us a very different result to before; and even more crucially the same result as a search from the SDK Control Center.</p>
<p>Alternatively you can combine both commands in one:</p>
<p><span style="font-family: Courier; font-size: 12px;">sb2 -t SailfishOS-i486-x86 zypper se qt | grep "i |"</span></p>
<p>This calls the <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> search from within <span style="font-family: Helvetica; font-size: 12px;"><strong>sb2</strong></span>, then exits.</p>
<p>If we want to install something to the build engine, then taking the example of qt5-qtlocation-devel, we would execute the following.</p>
<p><span style="font-family: Courier; font-size: 12px;">sb2 -t SailfishOS-i486-x86 -m sdk-install -R zypper in qt5-qtlocation-devel</span></p>
<p>While this technique does work, you still have to visit the SDK Control Center to press the "sync" button. This is to ensure that Qt Creator is fully synced with your newly installed packages.</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>What is ScratchBox2 (SB2)?</strong></span></span></p>
<p>To build for the Emulator, and for a real device, the build engine needs to cross-compile: i.e. compile code for a different chip architecture. <span style="font-family: Helvetica; font-size: 12px;"><strong>SB2</strong></span> is the bit that achieves this magic, and allows us to compile for an ARM chip on a PC with a i486-x86 architecture. It also offers the advantage that we can use the power of the host CPU, even though it may be completely different from that of the target.</p>
<p> </p>
<p>In the next section we will look at installing automatically as part of the build / run process. While I think that is the preferred technique, I still like to have SSH sessions open against the Emualtor and SDK, and use zypper to search for packages, and to identify the full name.</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Installing Automatically as Part of a Build using Spectacle.</strong></span></span></p>
<p>While installing packages manually can be fun in a nerdy sort of way, it does have one strong downside. Namely anyone else who tries to build and run you app will have to work out what are the required modules, and install those too. Yes you could add a list of required packages in your README file, but such documentation has a habit of going out-fo-date, So it would be great if there was a way of programatically declaring required packages, and have them installed automatically if not already present.</p>
<p>Such a system already exists. It's called <span style="font-family: Helvetica; font-size: 12px;"><strong>spectacle</strong></span>, and is configured by the application's .<span style="font-family: Helvetica; font-size: 12px;"><strong>yaml</strong></span> file, located in the RPM directory.</p>
<p>Yaml refers to format of the file, rather than to what it is does, but for want of anything better I will call it the .yaml file for the moment. In the same directory as the .yaml file is the spectacle file. You should not edit the spectacle file, as it is auto generated based on the config you perform in the .yaml file. Any changes you make to the .<span style="font-family: Helvetica; font-size: 12px;"><strong>spec </strong></span>file will end up being over-written.<span style="font-family: Helvetica; font-size: 12px;"> The Spec file does have sections that are safe to tune. These are marked with >> and <<. If you change anything outside those areas and later modify the .yaml your changes in spec will be lost.</span></p>
<p>In the .yaml file are three config sections of interest to install packages: <span style="font-family: Helvetica;"><strong style="font-size: 12px;">Requires:, </strong> </span><span style="font-size: 12px;"><strong>PkgBR</strong></span>: , and <strong style="font-size: 12px;">PkgConfigBR:.</strong></p>
<p>Let's look at these in reverse order:</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff9300;"><strong>Requires:</strong></span></span> causes packages to be installed to the Emulator: i.e. packages required to run. The format of the package names it accepts is the same as we used with zypper, so using Requires: is functionally identical to installing manually with zypper, except that it happens automatically when you (or someone else) builds your application.</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff9300;"><strong>PkgBR</strong></span></span>: stands for Package Build Requires, and is used to configure packages that are required to build your app: i.e. any package configured here will automatically be installed to the SDK Build Engine, just as though we had installed it via the SDK Control Center, or via SB2 zypper. The format of the package names is the same as those used by the control centre.</p>
<p><span style="font-size: 12px;"><strong><span style="color: #ff9300;"><span style="font-family: Helvetica;">PkgConfigBR:</span> </span></strong></span>is in someways a functional duplication of PkgBR: in that it also allows the configuration of packages to be installed that the SDK requires to build your application. However it uses a different format of package name, namely those required by <a href="http://www.freedesktop.org/wiki/Software/pkg-config/">pkgconfig</a>. These names are "published" in .pc files which are normally found within devel packages. You can list all such packages already installed with:</p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-family: Courier; font-size: 12px;">pkg-config --list-all</span></p>
<p>As PkgBR and PkgConfigBR do much the same thing, a particular package need only be specified in one of the two, and as far as I can assertion, it is mainly devel packages that have pkgconfig names.</p>
<p>Then when we build and run our application the specified packages will be installed to the SDK and Emulator if not already present.</p>
<p><span style="color: #ff2600;">Note 1: This requires the application to be run with the option "Deploy as RPM Package". It will not work with the option "Deploy as By Copying Binaries.</span></p>
<p><span style="color: #ff2600;">Note 2: You will require a network connection to access the repository hosting the missing package(s). If you have no network connection you will get an error like the one below:</span></p>
<p> <span style="font-family: Courier; font-size: 12px;">Retrieving: geoclue-0.12.99.2-1.3.1.i486.rpm [error]</span></p>
<p> <span style="color: #aa0000; font-family: Courier; font-size: 12px;">Download (curl) error for 'http://releases.sailfishos.org/sdk/latest/jolla/i486/mw/i486/geoclue-0.12.99.2-1.3.1.i486.rpm':</span></p>
<p> <span style="color: #aa0000; font-family: Courier; font-size: 12px;">Error code: Unrecognized error</span></p>
<p> <span style="color: #aa0000; font-family: Courier; font-size: 12px;">Error message: Empty reply from server</span></p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff2600;">Note 3: After installing packages this way, you may need to visit the SDK Control Center and press the Sync button in order for Qt Creator to become aware of the changes. You may also need to select Tools / QML/JS / Reset Code Model.</span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"> </p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>Examples to install Qt5Location and Qt5Positioning</strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;">Let us take a hypothetical app using GPS functionality as an example. In Qt5 GPS functionality is divided across 2 packages - Location and Positioning. Let us assume that we need both, and that we want to use both C++ and QML.</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;">This means we need to end up with the following packages installed (if not already present):</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><strong><span style="color: #ff9300;">On the SDK Build Engine (SB2)</span></strong></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-family: Helvetica;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-family: 'Lucida Console'; font-size: 12px;"> qt5-qtdeclarative-import-location // for </span><span style="font-family: 'Lucida Console';">mL</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: 'Lucida Console';"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: 'Lucida Console';"> qt5-qtdeclarative-import-positioning // for qml</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: 'Lucida Console';"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: 'Lucida Console';"> qt5-qtlocation-devel // for C++</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: 'Lucida Console';"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: 'Lucida Console';"> qt5-qtpositioning-devel // for C++</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: 'Lucida Console';"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: 'Lucida Console';"> qt5-qtlocation // required by <span style="font-size: 12px;">qt5-qtlocation-devel and <span style="font-size: 12px;">qt5-qtdeclarative-import-location</span></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-family: 'Lucida Console';"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-family: 'Lucida Console';"> qt5-qtpositioning // required by <span style="font-size: 12px;">qt5-qtpositioning-devel and <span style="font-size: 12px;">qt5-qtdeclarative-import-positioning</span></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"> </p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff9300;"><strong><strong style="font-size: 12px;"><span style="color: #ff9300;">On</span></strong> the Emulator / Real Device</strong></span></span></p>
<p style="margin: 0px;"><span style="font-size: 12px; font-family: Helvetica;"><br /></span></p>
<p style="margin: 0px;"><span style="font-size: 12px; font-family: 'Lucida Console';"> qt5-qtdeclarative-import-location // for qml</span></p>
<p style="margin: 0px;"><span style="font-size: 12px; font-family: 'Lucida Console';"><br /></span></p>
<p style="margin: 0px;"><span style="font-size: 12px; font-family: 'Lucida Console';"> qt5-qtdeclarative-import-positioning // for qml</span></p>
<p style="margin: 0px;"><span style="font-size: 12px; font-family: 'Lucida Console';"><br /></span></p>
<p style="margin: 0px;"><span style="font-size: 12px; font-family: 'Lucida Console';"> qt5-qtlocation // required by qt5-qtdeclarative-import-location</span></p>
<p style="margin: 0px;"><span style="font-family: 'Lucida Console'; font-size: 12px;"><br /></span></p>
<p style="margin: 0px;"><span style="font-family: 'Lucida Console'; font-size: 12px;"> qt5-qtpositioning // required by qt5-qtdeclarative-import-positioning</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;">To achieve this our .yaml file could have the following entries:</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><strong style="color: #ff9300; font-size: 12px;"><br /></strong></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-family: Courier;"><strong style="color: #ff9300; font-size: 12px;"> PkgConfigBR:</strong></span></p>
<p><span style="font-family: Courier;"> Qt5Core</span></p>
<p><span style="font-family: Courier;"> Qt5Qml</span></p>
<p><span style="font-family: Courier;"> Qt5Quick</span></p>
<p><span style="font-family: Courier;"> sailfishapp</span></p>
<p><span style="font-family: Courier; font-size: 12px;"><strong><span style="color: #ff9300;"> </span></strong></span><span style="font-size: 12px; font-family: Courier;"><strong><span style="color: #ff9300;">Requires:</span></strong></span></p>
<p><span style="font-family: Courier;"> sailfishsilica-qt5</span></p>
<p><span style="font-family: Courier;"> qt5-qtdeclarative-import-location</span></p>
<p><span style="font-family: Courier;"> qt5-qtdeclarative-import-positioning</span></p>
<p><span style="font-family: Courier; font-size: 12px;"><span style="color: #ff9300;"><strong> PkgBR:</strong></span></span></p>
<p><span style="font-family: Courier;"> qt5-qtdeclarative-import-location</span></p>
<p><span style="font-family: Courier;"><span style="font-family: Courier;"> qt5-qtdeclarative-import-positioning</span></span></p>
<p><span style="font-family: Courier;"> qt5-qtlocation-devel</span></p>
<p><span style="font-family: Courier;"> qt5-qtpositioning-devel</span></p>
<p>Note that for both the Emulator (Requires:) and the SDK Build Engine (PkgBR:) I have not explicitly added entries for <span style="font-family: Courier;">qt5-qtlocation</span>. This is because it will be installed by the dependant packages <span style="font-family: Courier;">qt5-qtdeclarative-import-location <span style="font-family: Helvetica; font-size: 12px;">and</span> <span style="font-family: Courier;">qt5-qtlocation-devel. <span style="font-family: Helvetica; font-size: 12px;">The same applies to</span> <span style="font-family: Courier;">qt5-qtpositioning.</span></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>References</strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span style="color: #ff9300;"><strong><br /></strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>Packaging in general</strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span><span style="font-family: 'Lucida Console';"><span style="color: #011993; font-size: 12px; padding: 0px; margin: 0px; text-align: left;"><br /></span></span></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span><span style="font-family: 'Lucida Console'; font-size: 12px;"><span style="color: #011993; padding: 0px; margin: 0px; text-align: left;">https</span><a style="font-size: 12px; padding: 0px; margin: 0px; color: #333399; text-decoration: none; font-family: 'Lucida Console', Courier, 'Courier New'; text-align: left;" href="https://sailfishos.org/develop-packaging-apps.html" target="_blank"><span style="color: #011993;">://sailfishos.org/develop-packaging-apps.html</span></a></span><span style="font-size: 12px; font-family: Helvetica; text-align: left;"><span style="font-family: 'Lucida Console';"> </span>under Tips and Tricks</span></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span><span style="font-size: 12px; font-family: Helvetica; text-align: left;"><br /></span></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>Scratchbox2:</strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span style="color: #ff9300;"><strong><br /></strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px;"><span style="color: #ff9300;"><a href="http://www.scratchbox.org/documentation/user/scratchbox-1.0/html/tutorial.html">http://www.scratchbox.org/documentation/user/scratchbox-1.0/html/tutorial.html</a></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span style="color: #ff9300;"><strong><br /></strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Lucida Console';"><span style="font-size: 12px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>PkCon:</strong></span></span></p>
<p style="font-size: 12px; margin: 0px; font-family: 'Lucida Console';"> </p>
<p style="font-size: 12px; margin: 0px; font-family: 'Lucida Console';"><span style="font-family: 'Lucida Console';"><a href="https://lists.sailfishos.org/pipermail/devel/2013-October/000845.html">https://lists.sailfishos.org/pipermail/devel/2013-October/000845.html</a></span></p>
<p><span style="font-family: 'Lucida Console';"><a style="font-family: 'Lucida Console'; font-size: 12px;" href="http://www.mail-archive.com/devel@lists.sailfishos.org/msg00863.html">http://www.mail-archive.com/devel@lists.sailfishos.org/msg00863.html</a></span></p>
<p><span style="font-family: 'Lucida Console';"><a style="font-family: 'Lucida Console'; font-size: 12px;" href="http://www.packagekit.org/pk-intro.html">http://www.packagekit.org/pk-intro.html</a></span></p>
<p><span style="font-family: 'Lucida Console';"><a style="font-size: 12px; font-family: 'Lucida Console';" href="http://www.packagekit.org/pk-intro.html">http://www.packagekit.org/pk-using.html</a></span></p>
<p> </p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Thanks</strong></span></span></p>
<p>This post draws on a number of threads on the Sailfish Developers' mailing list. Thanks go to: Thomas Perl, Jarko Vihriala, Roberto Collstete, bolek, Dmitry, David Greaves and others who contributed to these thread<span style="font-family: Helvetica;">s<span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><span style="white-space: nowrap;">,</span></span></span><span style="font-size: 12px; font-family: Helvetica;"><span style="white-space: nowrap;"> or have given feedback to </span><span style="white-space: nowrap;">earlier versions of this post.</span></span></p>
<p> </p>
<p> </p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com1tag:blogger.com,1999:blog-1638189258536559624.post-15667583451418887922013-10-25T11:01:00.001+02:002013-10-25T17:10:50.834+02:00Alpha 2: After the update of 22 Oct 2013<p>Hi All</p>
<p>As announced by Jarko <a href="https://lists.sailfishos.org/pipermail/devel/2013-October/000845.html">here</a> there is a refresh of the Sailfish Alpha available now.</p>
<p>This post lists some immediate differences I have noticed, and some changes I had to make to get "things" working again.</p>
<p>As / If I discover other stuff, I will update this post</p><br /><a name='more'></a><br /><p> </p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Where is my SDK VM?</strong></span></span></p>
<p>The most obvious thing (and mentioned deep in Jarko's post) is that the SDK Build Engine VM now starts without a GUI. But the GUI can be reactivated if required via tools/options/mer menu.</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><strong><span style="color: #ff9300;">SSH Fun</span></strong></span></p>
<p style="margin: 0px; font-size: 12px;">If, after the SDK update, you get the following errors when SSHing to the Emulator or SDK VMs read on.</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">apple-pip:abstractui christopherlamb$ ssh -p 2223 -i ~/.ssh/mer-qt-creator-rsa nemo@localhost</p>
<p style="margin: 0px; font-size: 12px;">@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@</p>
<p style="margin: 0px; font-size: 12px;">@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @</p>
<p style="margin: 0px; font-size: 12px;">@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@</p>
<p style="margin: 0px; font-size: 12px;">IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!</p>
<p style="margin: 0px; font-size: 12px;">Someone could be eavesdropping on you right now (man-in-the-middle attack)!</p>
<p style="margin: 0px; font-size: 12px;">It is also possible that a host key has just been changed.</p>
<p style="margin: 0px; font-size: 12px;">The fingerprint for the RSA key sent by the remote host is</p>
<p style="margin: 0px; font-size: 12px;">83:7e:fe:55:2a:dc:22:e7:69:dc:fb:6c:a3:bd:5c:2d.</p>
<p style="margin: 0px; font-size: 12px;">Please contact your system administrator.</p>
<p style="margin: 0px; font-size: 12px;">Add correct host key in /Users/christopherlamb/.ssh/known_hosts to get rid of this message.</p>
<p style="margin: 0px; font-size: 12px;">Offending RSA key in /Users/christopherlamb/.ssh/known_hosts:8</p>
<p style="margin: 0px; font-size: 12px;">RSA host key for [localhost]:2223 has changed and you have requested strict checking.</p>
<p style="margin: 0px; font-size: 12px;">Host key verification failed.</p>
<p style="margin: 0px; font-size: 12px;">apple-pip:abstractui christopherlamb$ zypper se</p>
<p style="margin: 0px; font-size: 12px;">-bash: zypper: command not found</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">The solution is very easy, but it is one of those that always has me for scratching my head for a few minutes trying to remember how I last did this:</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">Find the know_hosts file in ./ssh</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">Make a back up copy of the file</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">From the original, remove the two entries starting with:</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">[localhost]:2223</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">[localhost]:2222</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">Note you may have multiple entries with the same port number. In the error above we see the correct one to remove is line 8.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">You will find more advice in <a href="https://lists.sailfishos.org/pipermail/devel/2013-October/000870.html">this thread.</a></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">Previously I used to SSH to the Emulator / SDK as follows:</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">ssh -p 2222 -i ~/.ssh/mer-qt-creator-rsa nemo@localhost</span></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"><span style="font-family: Courier; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">ssh -p 2223 -i ~/.ssh/mer-qt-creator-rsa nemo@localhost</span></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">As the SDK and Emulator have been newly installed (rather than being updated) it means we have to use new keys</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><strong><span style="color: #ff9300;">To connect to the SDK BuildEngine VM:</span></strong></span></p>
<p><span style="font-family: Courier; font-size: 12px;">ssh -p 2222 -i ~/<SailfishOSInstallLocation>/vmshare/ssh/private_keys/engine/mersdk mersdk@localhost</span></p>
<p><span style="font-family: Courier; font-size: 12px;">ssh -p 2222 -i ~/<SailfishOSInstallLocation>/vmshare/ssh/private_keys/engine/root root@localhost</span></p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff9300;"><strong>To connect to the Emulator:</strong></span></span></p>
<p><span style="font-family: Courier; font-size: 12px;">ssh -p 2223 -i ~/<SailfishOSInstallLocation>/vmshare/ssh/private_keys/1/nemo nemo@localhost</span></p>
<p><span style="font-family: Courier; font-size: 12px;">ssh -p 2223 -i ~/<SailfishOSInstallLocation>/vmshare/ssh/private_keys/1/root root@localhost</span></p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Zypper</strong></span></span></p>
<p>Zypper may need refreshing. To verify this, first run "<span style="font-family: Courier; font-size: 12px;">zypper se</span>". If only lists the installed modules, and not those available but not yet installed then you will need to run the following:</p>
<p><span style="font-family: Courier; font-size: 12px;">sudo zypper refresh</span></p>
<p>After this zypper se should give a much longer list of modules.</p>
<p> </p>
<p> </p>
<p> </p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-20853160651092474982013-10-12T17:57:00.001+02:002013-11-06T17:36:37.988+01:00Alpha 2: Migrating Landed<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff2600;"><em>Note this article is work-in-profess, reflecting work that is work-in-progress, and will be updated / corrected as the migration moves forwards . . .</em></span></span></p>
<p><span><span><em><span style="color: #ff2600;">Last update is: 06 Nove 2013</span></em></span></span></p>
<p>It is the weekend, but as it is wet and cold outside, with new snow only a few hundred metres higher, there is no flying today. So I am back to programming, and more importantly porting my app <span style="font-family: Helvetica; font-size: 12px;"><strong>Landed</strong></span> to the Sailfish Alpha 2.</p>
<p>As I explained in my last post, recently I have concentrated on the Harmattan version of Landed, making it easier to use, and adding more functionality. While it is not yet finished (will it ever be?). <span style="font-family: Helvetica; font-size: 12px;"><strong>Landed</strong></span> is now fully functional, and thus another stab at porting to the Sailfish Alpha 2 makes sense.</p>
<p>This time, rather than porting all of Landed, I decided to cut out the section I had spent most time on recently into a throwaway demo, and port that. I know from my first attempt that porting all of <span style="font-family: Helvetica; font-size: 12px;"><strong>Landed</strong></span> will take quite some effort: Porting part of it first follows the old software engineering concept of solving large problems by dividing into smaller problems.</p>
<p>The demo is called <span style="font-family: Helvetica; font-size: 12px;"><strong>MigratePhoneContactsDemo</strong></span>. I will soon post the Harmattan code, and the ported Sailfish equivalent code to Github, and add links here.</p>
<p>This article charts the progress of the porting. As the porting is not yet finished at the time I start this article, I will revisit the article over the next few days and make updates as I find solutions, and as I walk into new problems. I will try and keep the article at a high level, and will add child posts if I need to go into detail on particular challenges.</p><br /><a name='more'></a><br /><p> </p>
<p>To recap: <span style="font-family: Helvetica; font-size: 12px;"><strong>Landed</strong></span> is an app for paraglider pilots. Upon landing the pilot can use it to send his GPS coordinates via SMS to a recovery team. It should be easy to use, with only a few button presses to generate the SMS, as the pilot may be tired, or worse have crashed or be hanging in a tree. Thus the SMS body comes from a stored template with a preselected contact.</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><strong>Landed</strong></span> was originally written for the Nokia N9 running Meego Harmattan. Using an abstraction library <span style="font-family: Helvetica; font-size: 12px;"><strong>AbstractUI</strong></span> I was able to use a common code base to target both Harmattan and the Sailfish Alpha 1 as both used very similar versions of Qt (4.7.4 vs 4.8.3). But now Sailfish Alpha 2 is Qt 5 based, which brings a whole bag of changes.</p>
<p>These changes are extensive enough that my original aim of supporting both Harmattan and Sailfish from a common code base may no longer be achievable (though I have not yet totally given up on this). Nevertheless, even if I have to live with two sets of code, the aim is still to keep these as similar as possible, with the differences limited to clearly identified parts of the code, and not spread everywhere.</p>
<p>At the time that I have started this article my demo now starts on the Sailfish Alpha 2. Some of it even works, though not everything does; and even if it runs, it looks pretty ropey.</p>
<p>My porting methodology was this: create a new Sailfish project, copy in the Harmattan code, compile, analyse the errors and correct as required. The changes I have found can be categorised as follows:</p>
<p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>a) .pro file</strong></span></span></p>
<p><span style="font-size: 12px;">As a standard Sailfish .pro file is quite a bit different from the standard Harmattan .pro file, rather than trying to migrate the file, I chose to create a new Sailfish project from the Sailfish SDK Qt Creator. This gives me a new .pro file (as well as a new standard .cpp file). This also allows me to ditch a lot of Symbian related content that was lurking in the Harmattan .pro file.</span></p>
<p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>b) main.cpp file</strong></span></span></p>
<p>The Harmattan and Sailfish default main.cpp files are also quite different in detail - especially the Qt Modules included, which reflects the restructuring and renaming of Qt Modules from Qt 4.x to 5.x.</p>
<p><span style="font-size: 12px;">So my starting point is a new main.cpp file from a new Sailfish project, and then port in selected content from the Harmattan version.</span></p>
<p><span style="font-size: 12px;"><span style="font-family: Helvetica; font-size: 12px;"><strong>Landed</strong></span> makes uses of several c++ plugins which expose functionality to the QML side of the project (e.g. for SMS and Torch functionality). However the MigratePhoneContactsDemo scope was chosen not to need these, but I do still set some ContextProperties via calls to </span>setContextProperty().</p>
<p>As importing plugins and context properties requires changes to the sailfishapplication.cpp file as well as in the main.cpp file to work properly, I will post a separate post on this topic later and link from here.</p>
<p> <strong style="font-size: 20px;"><span style="color: #ff9300;">c) General project structure</span></strong></p>
<p><span style="font-size: 12px;">One of the most obvious differences between a Harmattan and a Sailfish project is the structure of the project, and especially where the QML files are buried. Once again, our new default project gives us the expected structure and default content.</span></p>
<p><span style="font-size: 12px;">Some of the differences are:</span></p>
<p><span style="font-size: 12px;"><span style="font-family: Helvetica; font-size: 12px;"><strong>qmlapplicationviewer</strong></span> folder is now </span><span style="font-family: Helvetica; font-size: 12px;"><strong>sailfishapplication</strong></span>. This contains files used by the .pro file. Normally you should not need to touch these (unless like me you have c++ plugins in your project</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><strong>qtc_packaging</strong></span> is replaced by an <span style="font-family: Helvetica; font-size: 12px;"><strong>rpm</strong></span> folder. If our project has dependencies on other packages that should be preinstalled on the target device, then we may need to make changes to the files within the rpm folder, but that is a story for another day.</p>
<p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>d) qml location</strong></span></span></p>
<p><span style="font-size: 12px;">By default a Harmattan project has a folder called <span style="font-family: Helvetica; font-size: 12px;"><strong>qml</strong></span> containing a subfolder with the project name, which in turn contains all the qml files, including the main.qml referenced in the main.cpp file.</span></p>
<p><span style="font-size: 12px;">The default Sailfish structure is different. The main.qml lives in the project root. Other qml files live in one of two folders, <span style="font-family: Helvetica; font-size: 12px;"><strong>pages</strong></span> or <span style="font-family: Helvetica; font-size: 12px;"><strong>cover</strong></span>. I like this approach, and extend it by adding further folders alongside pages. For this demo I have added a folder <span style="font-family: Helvetica; font-size: 12px;"><strong>otherqml</strong></span>. If you add such custom folders, you will need to reference these in the .pro file, and import them as required in .qml files.</span></p>
<p><span style="font-size: 20px; font-family: Helvetica;"><strong><span style="color: #ff9300;">e) Imports of QtQuick</span></strong></span></p>
<p><span style="font-size: 12px;">The Sailfish Alpha 2, or rather Qt 5.x introduces QtQuick 2.0, whereas the Alpha 1 and Harmattan used QtQuick 1.x. Now while it would be possible to install QtQuick 1.x to the Emulator and continue to use that, somehow that seems to avoiding the point of porting! Instead i have replaced all the imports </span></p>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">import </span>QtQuick 1.1</pre>
<pre style="margin: 0px;"><!--EndFragment--></pre>
<p> <span style="font-size: 12px;">with</span></p>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">import </span>QtQuick 2.0</pre>
<p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>f) QtMobility </strong></span></span></p>
<p><span style="font-size: 12px;">The full <span style="font-family: Helvetica; font-size: 12px;"><strong>Landed</strong></span> makes extensive use of QtMobility for SMS messaging, Torch, GPS Location<span style="font-size: 12px;">, Sensors, Contacts</span>, Haptic Feedback, and Multimedia functionality. Unfortunately with QT 5.x, the QtMobility module has been extensively rearranged, with some sub modules becoming modules in their own right, and others having an uncertain future. As migrating all of these in one blow was always going to be a challenge, I deliberately chose the scope of this demo to only include Contacts, Feedback and Multimedia. </span></p>
<p><span style="font-size: 12px;">The easy part is changing the imports in the .qml files thus</span> </p>
<pre style="margin: 0px;"><!--StartFragment--></pre>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">import </span>QtMultimediaKit 1.1<!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="color: #808000;">import </span>QtMobility.feedback 1.1</pre>
<pre style="margin: 0px;"><span style="color: #808000;">import </span>QtMobility.contacts 1.1</pre>
<pre style="margin: 0px;"><!--EndFragment--></pre>
<p>are replaced by:</p>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">import </span>QtMultimedia 5.0</pre>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">import </span>QtFeedback 5.0<!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="color: #808000;">import </span>QtContacts 5.0<!--EndFragment--></pre>
<pre style="margin: 0px;"><!--EndFragment--></pre>
<p><span style="font-size: 12px;">Not all of these are installed as standard to the Sailfish Alpha 2 SDK or Emulator, and thus may need installing to one or both. As an example Qt Contacts 5.0 was not installed to my Emulator, so I had to ssh in, and run </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;">zypper in qt5-qtdeclarative-pim-contacts</p>
<p><span style="font-size: 12px;">From frequent queries to the Sailfish Developers's mailing list installing "missing" modules is a tricky area, so I will add a<a href="http://flyingsheeponsailfish.blogspot.com/2013/11/deploying-additional-packages-to.html"> post on this topic later.</a></span></p>
<p><span style="font-size: 12px;">Note also that some QtMobility functionality has been split into different packages, rather than being moved en-bloc as in the examples above. GPS functionality which used to be in Location is now split between Qt5Location and Qt5Positioning.</span></p>
<p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>g) "Missing" Sailfish Components</strong></span></span></p>
<p><span style="font-size: 12px;">This is one of the most tricky areas: There a quite a few Harmattan components that have no Sailfish equivalents. Some examples are:</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">ButtonRow </span>Element</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica;">Sheet Element</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica;">TabGroup Element</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica;">TabButton Element</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica;">SelectionDialog Element.</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica;">Now in the bad old days of the Alpha 1 the solution was to install the Harmattan components to the Sailfish SDK and Emulator, and use these when required. With my AbstractUI I was able to hide this from the core application, wrapping a Sailfish equivalent where available, and a Harmattan where required. But as the Harmattan components are based on Qt Quick 1.x installing these won't be quite so easy on the Sailfish Alpha 2.</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">This leaves 4 options</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">1) Abandon the missing component, find a better UI metaphor that is available in both Harmattan and Sailfish.</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">My original implementation used a Sheet element. The ContactsSelection page displayed a list of favourite contacts from an SQLite DB, plus a "Phone Contacts" button. Pressing the button opened a Sheet Control which hosted tabs with a Dialer for dialling custom numbers, and a list of the phone's contacts.</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">I was never entirely happy with this design, and now I found that Sailfish did not support the Sheet Control. So after a rethink I decided that it would be cleaner to dispense with the sheet control entirely: Instead the ContactsSelectionPage would host 3 tabs. The first tab would contain the original list of favourite contacts, the second the diaper, and the third the phone's contacts.</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">This solution was both cleaner on both platforms, and allowed me to junk a control not available on Sailfish, so I retrofitted this to the Harmattan original. Unfortunately tabs are also not available in Sailfish - by design - but that is a story for another time</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">2I Port the missing component from Harmattan to Sailfish.</span></p>
<p>As the Harmattan components are available as plaintext qml, It should be (from a technical point of view) possible to port individual components to the Sailfish Alpha 2 / Qt 5 7 Qt Quick 2.0. However this will have licensing implications, and may result in different parts of your application being under different licences. I will take some time to review the licences of the Harmattan components and update this post accordingly.</p>
<p>3) Write your own equivalent component and use on both platforms.</p>
<p>This is probably the cleanest solution, providing you do not get overly inspired by the source code of the original Harmattan equivalents.</p>
<p>4) Request equivalents from Jolla.</p>
<p>I am not sure how successful this will be, but if enough of us bombard the mailing list with "we need component X …" who knows what will happen ….</p>
<p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>h) Equivalent Components, but missing properties / functions</strong></span></span></p>
<p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>i) Sailfish functionality not available in Harmattan</strong></span></span></p>
<p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>j) Sailfish look and feel - different handling</strong></span></span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><span style="color: #ff9300; font-size: 20px; font-family: Helvetica;"><strong>k) theme vs Theme</strong></span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com1tag:blogger.com,1999:blog-1638189258536559624.post-77609427323453052942013-09-26T16:45:00.001+02:002013-09-26T16:45:50.560+02:00A Status Update<p>The eagle-eyed will have noticed that I have not updated this blog for several weeks. For this I apologise.</p>
<p>The evil-minded will probably have suspected that I have thrown in the towel, and have moved on to better things. They are wrong, I have been very busy, fighting on two fronts.</p>
<p>I spent quite a bit of time porting Landed and LandedSettings to the new Sailfish Alpha 2 (Qt 5.x), and was on the point of writing an article on the lessons learned when I went on holiday to Greece.</p><br /><a name='more'></a><br /><p>And then it happened: For the second time this year I found myself under a SAR helicopter on a mountain as darkness approached, and was able to use the "Help Me!" functionality of Landed.</p>
<p>The first time was early this year in deep snow on a steep mountain in Switzerland. I was the unfortunate soul who needed extraction. Immediately afterwards I added the torch functionality, allowing the user to flash the camera flash led to a searching helicopter.</p>
<p>The second time happened during our paragliding holiday in Greece. A colleague was unfortunate enough to crash into the side of a mountain, and needed recovery. Once we had got to the crash site over very terrain that would challenge a mountain goat I was able to use Landed to communicate the GPS coordinate. Then once the EMAK mountain rescue had arrived and the Hellenic Airforce SuperPuma was approaching in the gathering darkness I could use the newly added torch functionality to signal exactly where we were on the mountainside to the pilot. (b.t.w, full congratulations to EMAK6 and 112PM / 384MED for their highly professional work).</p>
<p>In the week that followed I made a host of minor improvements, and completed some unfinished functionality: all intended to make Landed even easier and flexible to use in a stressful situation. As an example Landed now automatically choses the closest group / location (on the mountain mine was still set to Switzerland). Naturally I made these changes to the Harmattan version - the one that was actually on my real-life phone.</p>
<p>Which brings me to versions, or flavours.</p>
<p>While with the Sailfish Alpha 1 I was able to use an identical code base for both Harmattan and Sailfish thanks to AbstractUI, I had not yet succeeded in doing so with the new Sailfish Alpha 2.</p>
<p>This meant that I had 2 versions, the original Harmattan / Alpha 1, and a ported to Sailfish Alpha 2. The versions were very similar, with the differences in clearly identifiable places, and I was working on re-establishing a common code base when the second hell incident happened, and I added new functionality to the Harmattan / Sailfish Alpha 1 version.</p>
<p>The latest version of the Harmattan / Sailfish Alpha 1 version of Landed22 is posted to Github here: <a href="https://github.com/sailfishapps/landed">https://github.com/sailfishapps/landed</a></p>
<p>In the next days and weeks I will:</p>
<p>a) back-port the latest Landed22 functionality to the Sailfish Alpha 2 migrated version, or report Landed22 to Sailfish Alpha 2 (which may be easier).</p>
<p>b) post an article here on porting from Sailfish Alpha 1 to Sailfish Alpha 2. What is easy, and what were the challenges I faced.</p>
<p>c) workout how to re-establish a single (or near-single) codebase for Harmattan and Sailfish Alpha 2 - and post here how this can be achieved (or not if not possible).</p>
<p>d) post an article here on using rsync to deploy AbstractUI to the Nokia N9 in a similar way that I do to the Sailfish Emulator.</p>
<p>e) continue completing Landed and LandedSettings core functionality so that these can be used by others.</p>
<p> </p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-23653907054759206282013-08-06T20:35:00.001+02:002013-08-06T20:35:24.507+02:00Alpha 2: Passing simple C++ properties from main.cpp to the QML Side with Qt5<p>One of the first challenges in migrating LandedSettings from the Sailfish Alpha 1 7 Qtt to Alpha 2 / Qt5 was that I pass a simple property from the main.cpp file (C++) to the QML side via <span style="font-size: 12px; font-family: Helvetica;">a </span><span style="font-family: Courier; font-size: 12px;"><strong>setContextProperty </strong><span style="font-family: Helvetica;">call</span></span><span style="font-family: Helvetica;">.</span></p>
<p>The property was platform, and was intended to allow the Qml side to change font size etc according to the platform it was running on. I originally added this functionality to handle differences between the Nokia Simulator and the Haramattan Emulator (QEMU).</p>
<p>In Qt4 I was able to pass such properties via a call to <span style="font-family: Courier; font-size: 12px;"><strong>setContextProperty</strong></span>, offered by a bit of Nokia code called the <span style="font-family: Courier; font-size: 12px;"><strong>QmlApplicationViewer</strong></span>. As this is no longer included with the Sailfish Alpha 2, and will not run unchanged, I needed to migrate this to something different. As we will see their were a number of approaches I could have taken.</p><br /><a name='more'></a><br /><p><strong style="font-size: 14px;"><span style="color: #ffd479;">Qt 4 Style using QmlApplicationViewer</span></strong></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #018000;"><span style="font-family: Helvetica; font-size: 12px;">Below is an extract from my Qt4 main.cpp file</span>.</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #018000;"><span style="color: #011480;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #018000;"><span style="color: #011480;">#include </span>"qmlapplicationviewer.h"</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #011480;">Q_DECL_EXPORT </span><span style="color: #808000;">int </span>main(<span style="color: #808000;">int </span>argc, <span style="color: #808000;">char </span>*argv[])</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;">{</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> <span style="color: #011480; font-family: Courier; font-size: 12px;">//Some C++ code here to determine the platform and set an int platformId</span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #801b80;"> QScopedPointer</span><<span style="color: #801b80;">QApplication</span>> app(createApplication(argc, argv));</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span>QmlApplicationViewer viewer;</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span><span style="font-family: Courier; font-size: 14px;"><strong><span style="color: #ff2600;">viewer.rootContext()->setContextProperty(<span>"platform"</span>,<span> </span>platformId);</span></strong></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span>viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #018000;"><span style="color: #c0c0c0;"> </span><span style="color: #000000;">viewer.setMainQmlFile(</span><span style="color: #801b80;">QLatin1String</span><span style="color: #000000;">(</span>"qml/landedsettings21/main.qml"<span style="color: #000000;">));</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span>viewer.showExpanded();</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span><span style="color: #808000;">return</span>app->exec();</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;">}</p>
<p>Having set a variable platform of type int, I could then pass it to QML via the <span style="font-family: Courier; font-size: 12px;"><strong>setContextProperty</strong></span> call in red above. This exposed a property "platform" that could be used anywhere in my QML.</p>
<p>So what where the options to migrate this to Qt5, and which did I chose? I found 3, and chose the last of these.</p>
<p><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong>Keep the QmlApplicationViewerCode, Migrate it to Qt5</strong></span></span></p>
<p>In theory I could have copied the <span style="font-family: Helvetica; font-size: 12px;"><strong>QmlApplicationViewer</strong></span> code files from a Harmattan project, and migrated these to Qt5.</p>
<p>This technique is suggested in a <a href="https://qt-project.org/doc/qt-5.0/qtdoc/portingqmlapp.html">porting tutorial from the Qt Project</a>, but somehow this seemed like carting old baggage around with me.</p>
<p><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong>Use qmlRegisterXXXType</strong></span></span></p>
<p>This is a valuable technique I have used elsewhere (e.g. AbstractUI, Landed) to C++ / QML interaction. I use this for exposing C++ objects with properties, methods, signals etc. that can be manipulated by QML.</p>
<p>To use this technique I would need to create one or more classes in C++, and to use it QML include an "import" statement in each QML file that wanted to access the property. This all seems a bit much given that "platform" is a primitive type (and could even have been a string literal).</p>
<p>So while this would be a valid approach, I decided to keep this as a backup option, and see if I could find a more direct equivalent of the setContextProperty. However I plan to look at this technique in more detail in a future post.</p>
<p><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong>setContextProperty the Qt5 Way</strong></span></span></p>
<p>After some experimentation, and with suggestions from the <a href="https://lists.sailfishos.org/cgi-bin/mailman/listinfo/devel">Sailfish Developers Mailing List,</a> I arrived at a solution that is close to the Qt 4 setContextProperty solution, but does not require the <span style="font-family: Courier; font-size: 12px;"><strong>QmlApplicationViewer</strong></span> code.:</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #011480;">Q_DECL_EXPORT </span><span style="color: #808000;">int </span>main(<span style="color: #808000;">int </span>argc, <span style="color: #808000;">char </span>*argv[])</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;">{</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"> <span style="color: #801b80;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> <span style="color: #011480; font-family: Courier; font-size: 12px;">//Some C++ code here to determine the platform and set an int platformId</span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #801b80;"> QScopedPointer</span><<span style="color: #801b80;">QGuiApplication</span>> app(<span style="color: #801b80;">Sailfish</span>::createApplication(argc, argv));</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #801b80;"><span style="color: #c0c0c0;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #801b80;"><span style="color: #801b80;"> QScopedPointer</span><span style="color: #000000;"><</span><span style="color: #801b80;">QQuickView</span><span style="color: #000000;">> </span><span style="color: #000000;">view(</span><span style="color: #801b80;">Sailfish</span><span style="color: #000000;">::</span><span style="font-family: Courier; font-size: 12px;"><span style="color: #ff2600;"><strong>createView())</strong></span></span><span style="color: #000000;">;</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Courier; font-size: 12px;"><span style="color: #ff2600;"><strong> view->rootContext()->setContextProperty("platform", platformId)</strong></span></span>;</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span><span style="color: #801b80;">Sailfish</span>::setView(view.data(), <span style="color: #018000;">"main.qml"</span>);</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span><span style="color: #801b80;">Sailfish</span>::showView(view.data());</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #c0c0c0; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span><span style="color: #808000;">return </span>app->exec();</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;">}</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">Compare this to standard main function as generated for a default new Sailfish project below:</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #011480;">Q_DECL_EXPORT </span><span style="color: #808000;">int </span>main(<span style="color: #808000;">int </span>argc, <span style="color: #808000;">char </span>*argv[])</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;">{</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span><span style="color: #801b80;">QScopedPointer</span><<span style="color: #801b80;">QGuiApplication</span>> app(<span style="color: #801b80;">Sailfish</span>::createApplication(argc, argv));</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #801b80;"><span style="color: #c0c0c0;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #801b80;"><span style="color: #801b80;"> QScopedPointer</span><span style="color: #000000;"><</span><span style="color: #801b80;">QQuickView</span><span style="color: #000000;">></span><span style="color: #000000;">view(</span><span style="color: #801b80;">Sailfish</span><span style="color: #000000;">::</span><span style="font-family: Courier; font-size: 12px;"><span style="color: #ff2600;"><strong>createView("main.qml"));</strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #c0c0c0; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span><span style="color: #801b80;">Sailfish</span>::showView(view.data());</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier; color: #c0c0c0; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="color: #c0c0c0;"> </span><span style="color: #808000;">return</span>app->exec();</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;">}</p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">In my solution, the <span style="font-size: 12px; font-family: Courier;"><strong>createview</strong></span> function is called without specifying the main.qml, we do this two lines later with the <span style="font-size: 12px; font-family: Courier;"><strong>setView</strong></span> function. In between we can then do the <span style="font-size: 12px; font-family: Courier;"><strong>setContextProperty</strong></span>.</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;"><strong>Note for this to work properly, a bug-fix has to be applied to the sailfish application.cpp file, Thanks to Lucien XU for this. <a href="https://lists.sailfishos.org/pipermail/devel/2013-August/000529.html">You can find his post here</a>.</strong></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong>Example Code Posted to GitHub</strong></span></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"> </p>
<p style="margin: 0px; font-size: 12px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">I have created a throwaway demo <span style="font-size: 12px;"><strong>setContextPropertyDemo</strong></span> that illustrates this technique. <a href="https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/setContextPropertyDemo">You can find the code here.</a></span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-24560325982396521102013-08-05T20:01:00.001+02:002013-08-05T20:01:24.268+02:00Alpha 2: Installing an Import Library on the Emulator<p>In a previous post I covered the code migration of my import library AbstractUI from Qt4 to Qt5.</p>
<p>However the greatest problem proved to be not in the code, but rather where to install my newly migrated library. Read on to find out the solution.</p><br /><a name='more'></a><br /><p>Having completed the migration of my import library AbstractUI to Qt5, I was keen to continue with the migration of LandedSettings, which uses this library. This would also test if the migration of the library was successful.</p>
<p>For the first Alpha, the install location for libraries on the Emulator was:</p>
<p><span style="font-family: 'Courier New', Courier, monospace;">/usr/lib/<span style="font-family: 'Courier New'; font-size: 12px;"><strong>qt4</strong></span>/imports/o</span></p>
<p><span style="font-size: 12px;">So it seemed logical to me that with Qt5 the new install location would be:</span></p>
<p><span style="font-family: 'Courier New', Courier, monospace;">/usr/lib/<span style="font-family: 'Courier New'; font-size: 12px;"><strong>qt5</strong></span>/imports/</span></p>
<p><span style="font-size: 12px;">I have a helper script using rsync to deploy my abstractui files, <a href="http://flyingsheeponsailfish.blogspot.ch/2013/05/deploying-files-to-sailfish-emulator_26.html">as described here</a>, so I quickly modified this to deploy my library to the directory above.</span></p>
<p><span style="font-size: 12px;">Next I opened my LandedSettings project, and hit the build and run button, and was bitterly disappointed because it could not find AbstractUI.</span></p>
<p style="margin: 0px;"><span style="font-size: 12px;"><a href="file:///opt/sdk/landedsettingsQt5_21/usr/share/landedsettingsQt5_21/main.qml:2:1"><span style="color: #0000aa;">file:///opt/sdk/landedsettingsQt5_21/usr/share/landedsettingsQt5_21/main.qml:2:1</span></a><span style="color: #aa0000;">: module "org.flyingsheep.abstractui" is not installed</span></span></p>
<p style="margin: 0px;"><span style="font-size: 12px;"><span style="color: #aa0000;"><br /></span></span></p>
<p style="margin: 0px;"><span style="font-size: 12px;">Had I somehow copied the files to the wrong place? A quick SSH confirmed that my files were on the Emulator exactly where I was expecting. So what was wrong?</span></p>
<p><span style="font-size: 12px;">Then it occurred to me to look where Sailfish install their files. Taking SilicaFlickable as an example, I did the following on the Emulator</span></p>
<p><span style="font-family: Courier; font-size: 12px;">[root@SailfishEmul ~]# find / -name SilicaFlickable.qml</span></p>
<p><span style="font-size: 12px;">which gave:</span></p>
<p><span style="font-family: Courier; font-size: 12px;">/usr/lib/qt5/<strong><span style="color: #ff7e79;">qml</span></strong>/Sailfish/Silica/SilicaFlickable.qml</span></p>
<p><span style="font-size: 12px;">Bingo! The subdirectory is <span style="font-family: Courier; font-size: 12px;">qml</span>, NOT <span style="font-family: Courier; font-size: 12px;">imports</span>!</span></p>
<p style="text-align: center;"><span style="font-size: 18px;"><span style="color: #ff7e79;"><strong><br /></strong></span></span></p>
<p style="text-align: center;"><span style="font-size: 18px;"><span style="color: #ff7e79;"><span style="font-family: Helvetica; font-size: 18px;">The correct location to install import libraries on the Emulator is</span><strong>: </strong></span></span><span style="color: #ff7e79; font-family: Courier; font-size: 18px;">/usr/lib/qt5/</span><strong style="color: #ff7e79; font-family: Courier; font-size: 18px;"><span style="font-size: 22px;">qml</span>/</strong></p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span><br /></span></span></p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span>I adapted <a href="http://flyingsheeponsailfish.blogspot.ch/2013/05/deploying-files-to-sailfish-emulator_26.html">my rsync script,</a> and this time QtCreator found AbstractUI, and I could focus on completing the migration of LandedSettings. More on that soon.</span></span></p>
<p><span style="font-family: Helvetica; font-size: 12px;">Interestingly the MERSDK is no so picky. QtCreator will find libraries installed in both the directories below:</span></p>
<p><span style="font-family: 'Courier New', Courier, monospace;">/Users/<your user>/SailfishOSAlpha5/mersdk/targets/SailfishOS-i486-x86/usr/lib/qt5/imports</span></p>
<p><span style="font-family: 'Courier New', Courier, monospace;">/Users/<span style="font-family: 'Courier New', Courier, monospace;"><your user></span>/SailfishOSAlpha5/mersdk/targets/SailfishOS-i486-x86/usr/lib/qt5/qml</span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-74079164801641606972013-08-05T14:30:00.001+02:002013-08-05T22:17:00.421+02:00Alpha 2: Migrating LocalStorage from Qt4 to Qt5<p style="margin: 0px; font-size: 12px;">This morning I successfully migrated the LocalStorage part of my app LandedSettings from the Sailfish Alpha 1 (Qt4) style to the new Sailfish Alpha 2 (Qt5) style.</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">In LandedSettings all the Database access functionality is encapsulated in 3 javascript files. In order to focus the migration on the LocalStorage only, I created a new throwaway project QT5TestLS, copied the 3 JavaScript files to the new project, and added just enough code to the project to setup and populate the Database.</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"><strong><br /></strong></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"><strong><a href="https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/QT5TestLS">The Full code of QT5TestLS can be found on GitHub</a>.</strong></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">Below is a summary of the things I had to change:</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p><br /><a name='more'></a><br /><p><strong style="font-size: 12px;">1) LocalStorage is not installed by default on the Emulator: You must install via zypper</strong></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">Connect via SSH to the Emulator:</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">Verify first if installed:</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;">zypper se Storage</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">If not present, then</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;">zypper in qt5-qtdeclarative-import-localstorageplugin </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><strong>2) LocalStorage is no longer part of the Qml Global object, you have to import it to qml / JavaScript files using it:</strong></span></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; color: #018000;"><span style="font-family: Helvetica; color: #000000;">in Qml</span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; color: #018000;">import QtQuick.LocalStorage 2.0</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; color: #018000;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; color: #018000;"><span style="font-family: Helvetica; color: #000000;">in JavaScript</span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; color: #018000;"><span style="color: #000000;">.</span>import QtQuick.LocalStorage 2.0 as LS</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">Note the period before the import in javascript</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">In the Alpha 1 / Qt4 no import was required.</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><strong>3) As a result of 2) above, all local storage function calls need to qualified by the namespace "LocalStorage".</strong></span></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><span style="font-family: Helvetica;">in Qml</span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><span style="color: #808000;">return </span>LocalStorage.openDatabaseSync(<span style="color: #018000;">"Landed21"</span>,<span style="color: #018000;">"15.0"</span>,<span style="color: #018000;">"StorageDatabase"</span>,100000);</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><span style="font-family: Helvetica;">In JavaScript</span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><span style="color: #808000;">return </span>LS.LocalStorage.openDatabaseSync(<span style="color: #018000;">"Landed21"</span>,<span style="color: #018000;">"15.0"</span>,<span style="color: #018000;">"StorageDatabase"</span>,100000);</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; color: #c0c0c0; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">Note that in JavaScript LocalStorage functions must be qualified both by the import alias (in this example "LS" ), and the namespace "LocalStorage".</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><strong>4) JavaScript files can import other JavaScript files (rather than using Qt.include) function.</strong></span></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">For example I have a settingsDB.js java file, which contains the "getDatabase" method.</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">In my debugDB.js script I can import this file as follows</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; color: #018000;"><span style="color: #000000;">.import </span>"settingsDB.js" <span style="color: #000000;">as </span><span style="color: #000000;">SDB</span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">This gives me access to the functions within settingsDB.js (e.g. the getDatabase). These are accessed qualified by the alias. e.g</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><span style="color: #808000;">var</span><span style="color: #2985c7;"><em>db</em></span>=<span style="color: #0055af;"><em>SDB</em></span>.getDatabase();</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">Note that in debugDB.js I do not need an explicit import of QtQuickLocalStorage. That seems to be inherited by importing settingsDB.js, which has such an import statement.</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">The old style <span style="font-family: Courier; color: #018000;">Qt.include("settingsDB.js")</span> is still available, but behaves slightly differently.</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; min-height: 14px;"><span style="font-family: Helvetica; font-size: 14px;"><strong><span style="color: #ffd479;">Further Reference </span></strong></span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; min-height: 14px;"><span style="font-family: Helvetica; font-size: 14px;"><strong><span style="color: #ffd479;"><br /></span></strong></span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;">See:</span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><span style="font-family: Helvetica; font-size: 12px;"><br /></span></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><a href="https://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-localstorage2-qtquick-localstorage-2.html">https://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-localstorage2-qtquick-localstorage-2.html</a></p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier;"><a href="https://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-imports.html">https://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-imports.html</a></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><a href="https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/QT5TestLS"><strong>The Full code of QT5TestLS can be found on GitHub</strong></a></span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-25904212965753114152013-08-03T18:43:00.001+02:002013-08-05T17:32:12.660+02:00Alpha 2: Migrating an Import Library<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff2600;"><em>Note: As my experience and understanding of migrating to Qt5 / Sailfish Alpha 2 increases, I will update this post if required.</em></span></span></p>
<p>Having installed the second Sailfish Alpha (which I will refer to as Alpha 2), and checked that the default "Hello Sailors" project runs on the Emulator, I jumped in feet first to try and get LandedSettings running using Qt5.</p>
<p>Almost at once I ran into a problem, one that should have been obvious from the start: LandedSettings depends on an import library AbstractUI, and of course this must be migrated first.</p>
<p>As abstractui is intended to abstract out the differences between Harmattan and Sailfish, and Sailfish is now on a higher Qt level than Harmattan this does raise the question whether this approach is still valid. But I prefer to defer that question to slightly later For the moment I want to get LandedSetttings up and running on the new Alpha, thus I need to get AbstractUI ported.</p>
<p>The irony of a tool that was intended to ease porting needing porting itself does not escape me.</p>
<p>Therefore I decided to make a throwaway demo import library native to Qt5, and a throwaway QML project to import it. I could then compare the throwaway library to AbstractUI, and identify what needs changing.</p>
<p>The first pleasant surprise is that there is now a project template for Libraries. I chose "New Project / Libraries / Qt Quick 2 Extension Plugin". In the first alpha this template was not available. if I remember correctly i actually created the project in the Qt Project SDK as a a Qt Quick 1 Extension Plugin, and adapted it for Sailfish to the point that I got it working.</p>
<p>Having tested that the throwaway was importable and installable (more on this in a follow-up post) it was time to start porting abstractui.</p>
<p>As the original Sailfish flavour of the abstractui library was not created in the Sailfish SDK (but now could be), I decided to start from fresh, creating a new project in the Saillfish QtCreator, and would then merge in the bits of code required from the old version of the library.</p>
<p> </p><br /><a name='more'></a><br /><p><strong style="color: #ffd479; font-size: 20px;">The Differences</strong></p>
<p><span style="font-family: Helvetica; font-size: 14px;"><strong><span style="color: #ffd479;">1) The Project pro Files.</span></strong></span></p>
<p><span style="font-family: Helvetica; font-size: 12px;"><strong>Alpha 1 pro file</strong></span></p>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #008000;">#</span><span style="color: #008000;">Sailfish OS </span><span style="color: #008000;">version </span><span style="color: #008000;">of </span><span style="color: #008000;">the </span><span style="color: #008000;">abstractui </span><span style="color: #008000;">user interface</span><span style="color: #008000;">components </span><span style="color: #008000;">abstraction </span><span style="color: #008000;">layer</span></pre>
<pre style="margin: 0px;"><span style="color: #800080;">TEMPLATE</span>=lib</pre>
<pre style="margin: 0px;"><span style="color: #800080;">TARGET</span>=abstractui</pre>
<pre style="margin: 0px;"><span style="color: #800080;">TARGET</span>=$$qtLibraryTarget($$<span style="color: #800080;">TARGET</span>)</pre>
<pre style="margin: 0px;"><span style="color: #800080;">QT</span>+=declarative</pre>
<pre style="margin: 0px;"><span style="color: #800080;">CONFIG</span>+=qtplugin</pre>
<pre style="margin: 0px;"><span style="color: #008000;">#</span><span style="color: #008000;">DEPLOYMENT_PATH</span><span style="color: #008000;">=</span><span style="color: #008000;">/opt/sdk/share/$$TARGET</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">SOURCES</span>+=\</pre>
<pre style="margin: 0px;">plugin.cpp</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">HEADERS</span>+=\</pre>
<pre style="margin: 0px;">auimdialogstatus.h\</pre>
<pre style="margin: 0px;">auimpagestatus.h\</pre>
<pre style="margin: 0px;">auimpageorientation.h\</pre>
<pre style="margin: 0px;">plugin.h</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">OTHER_FILES</span>+=$$PWD/auiqmls/*.qml\</pre>
<pre style="margin: 0px;">auiqmls/AUILabel.qml\</pre>
<pre style="margin: 0px;">auiqmls/AUICheckBox.qml\</pre>
<pre style="margin: 0px;">auiqmls/AUIPageWithMenu.qml\</pre>
<pre style="margin: 0px;">auiqmls/AUIPageHeader.qml\</pre>
<pre style="margin: 0px;">auiqmls/AUIBackgroundRectangle.qml\</pre>
<pre style="margin: 0px;">auiqmls/AUIHighlightRectangle.qml\</pre>
<pre style="margin: 0px;">auiqmls/AUIContextMenu.qml</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">OTHER_FILES</span>+=rpm/abstractui.yaml\</pre>
<pre style="margin: 0px;">rpm/abstractui.spec</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">TARGETPATH=/opt/sdk/bin</pre>
<pre style="margin: 0px;">target.path=$$TARGETPATH</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">DEPLOYMENT_PATH=/opt/sdk/share/$$<span style="color: #800080;">TARGET</span></pre>
<pre style="margin: 0px;">qml.path=$$DEPLOYMENT_PATH</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">DEFINES</span>+=DEPLOYMENT_PATH=\"\\\"\"$${DEPLOYMENT_PATH}/\"\\\"\"</pre>
<pre style="margin: 0px;"><br /><!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><strong>Alpha 2 pro file</strong></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #008000;">#</span><span style="color: #008000;">SailfishOS </span><span style="color: #008000;">version </span><span style="color: #008000;">of </span><span style="color: #008000;">the </span><span style="color: #008000;">abstractui </span><span style="color: #008000;">user </span><span style="color: #008000;">interface </span><span style="color: #008000;">components </span><span style="color: #008000;">abstraction </span><span style="color: #008000;">layer</span></pre>
<pre style="margin: 0px;"><span style="color: #800080;">TEMPLATE</span>=lib</pre>
<pre style="margin: 0px;"><span style="color: #800080;">TARGET</span>=abstractui</pre>
<pre style="margin: 0px;"><span style="color: #800080;">QT</span>+=qmlquick</pre>
<pre style="margin: 0px;"><span style="color: #800080;">CONFIG</span>+=qtplugin</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">TARGET</span>=$$qtLibraryTarget($$<span style="color: #800080;">TARGET</span>)</pre>
<pre style="margin: 0px;">uri=org.flyingsheep.abstractui</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">SOURCES</span>+=\</pre>
<pre style="margin: 0px;">plugin.cpp</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">HEADERS</span>+=\</pre>
<pre style="margin: 0px;">auimdialogstatus.h\</pre>
<pre style="margin: 0px;">auimpagestatus.h\</pre>
<pre style="margin: 0px;">auimpageorientation.h\</pre>
<pre style="margin: 0px;">plugin.h</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">OTHER_FILES</span>+=$$PWD/auiqmls/*.qml</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">!equals(<span style="color: #800080;">_PRO_FILE_PWD_</span>,$$OUT_PWD){</pre>
<pre style="margin: 0px;">copy_qmldir.target=$$OUT_PWD/qmldir</pre>
<pre style="margin: 0px;">copy_qmldir.depends=$$<span style="color: #800080;">_PRO_FILE_PWD_</span>/qmldir</pre>
<pre style="margin: 0px;">copy_qmldir.commands=$(COPY_FILE)\"$$<span style="color: #808000;">replace</span>(copy_qmldir.depends,/,$$QMAKE_DIR_SEP)\"\"$$<span style="color: #808000;">replace</span>(copy_qmldir.target,/,$$QMAKE_DIR_SEP)\"</pre>
<pre style="margin: 0px;">QMAKE_EXTRA_TARGETS+=copy_qmldir</pre>
<pre style="margin: 0px;">PRE_TARGETDEPS+=$$copy_qmldir.target</pre>
<pre style="margin: 0px;">}</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">qmldir.files=qmldir</pre>
<pre style="margin: 0px;">unix{</pre>
<pre style="margin: 0px;">installPath=$$[QT_INSTALL_QML]/$$<span style="color: #808000;">replace</span>(uri,\\.,/)</pre>
<pre style="margin: 0px;">qmldir.path=$$installPath</pre>
<pre style="margin: 0px;">target.path=$$installPath</pre>
<pre style="margin: 0px;"><span style="color: #800080;">INSTALLS</span>+=targetqmldir</pre>
<pre style="margin: 0px;">}</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">The most significant change is easy to overlook:</span></pre>
<pre style="margin: 0px;"><span style="color: #800080;"><br /></span></pre>
<pre style="margin: 0px;"><span style="color: #800080;">QT</span>+=declarative</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">Is now:</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #800080;">QT</span>+=qmlquick</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">This reflects the fact that QtDeclarative is replaced by QmlQuick in Qt5. According to <a href="https://qt-project.org/doc/qt-5.1/qtdoc/qtquick-porting-qt5.html">this porting page</a> (see bottom of the page), QtDeclarative is still available in Qt5, but lets make the move to QmlQuick now.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">The bottom half of the file is dedicated to installation configuration. I will look at this closely later.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong>The plugin.h Files</strong></span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong><br /></strong></span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span><strong><strong style="font-size: 12px;">Alpha 1 plugin.h file</strong></strong></span></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #000080;">#ifndef </span>ABSTRACTUI_PLUGIN_H</pre>
<pre style="margin: 0px;"><span style="color: #000080;">#define </span><span style="color: #000080;">ABSTRACTUI_PLUGIN_H</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;"><QDeclarativeExtensionPlugin></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;">class </span><span style="color: #800080;">AbstractuiPlugin</span>: <span style="color: #808000;">public</span><span style="color: #800080;">QDeclarativeExtensionPlugin</span></pre>
<pre style="margin: 0px;">{</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;"> Q_OBJECT</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#if</span><span style="color: #000080;">QT_VERSION</span>>=<span style="color: #000080;">0x050000</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;"> Q_PLUGIN_METADATA</span>(IID<span style="color: #008000;">"org.qt-project.Qt.QQmlExtensionInterface"</span>)</pre>
<pre style="margin: 0px;"><span style="color: #000080;">#endif</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;">public</span>:</pre>
<pre style="margin: 0px;"><span style="color: #808000;"> void </span><span style="font-style: italic;">registerTypes</span>(<span style="color: #808000;">const</span><span style="color: #808000;">char</span>*uri);</pre>
<pre style="margin: 0px;">};</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;">#endif </span><span style="color: #008000;">// </span><span style="color: #008000;">ABSTRACTUI_PLUGIN_H</span></pre>
<pre style="margin: 0px;"><!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span><strong><strong style="font-size: 12px;"><br /></strong></strong></span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span><strong><strong style="font-size: 12px;">Alpha 2 plugin.h file</strong></strong></span></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #000080;">#ifndef </span>ABSTRACTUI_PLUGIN_H</pre>
<pre style="margin: 0px;"><span style="color: #000080;">#define </span><span style="color: #000080;">ABSTRACTUI_PLUGIN_H</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;"><QQmlExtensionPlugin></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;">class </span><span style="color: #800080;">AbstractuiPlugin</span>: <span style="color: #808000;">public </span><span style="color: #800080;">QQmlExtensionPlugin</span></pre>
<pre style="margin: 0px;">{</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;"> Q_OBJECT</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;"> Q_PLUGIN_METADATA</span>(IID<span style="color: #008000;">"org.qt-project.Qt.QQmlExtensionInterface"</span>)</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;">public</span>:</pre>
<pre style="margin: 0px;"><span style="color: #808000;"> void </span><span style="font-style: italic;">registerTypes</span>(<span style="color: #808000;">const</span><span style="color: #808000;">char</span>*uri);</pre>
<pre style="margin: 0px;">};</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;">#endif </span><span style="color: #008000;">// </span><span style="color: #008000;">ABSTRACTUI_PLUGIN_H</span></pre>
<pre style="margin: 0px;"><!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">Here again the changes reflect the fact that QtDeclarative is replaced by QmlQuick in Qt5.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong>The plugin.cpp Files</strong></span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong><br /></strong></span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span><strong><strong style="font-size: 12px;">Alpha 1 plugin.cpp file</strong></strong></span></span></pre>
<div><span style="font-family: Helvetica; font-size: 14px;"><span><strong><strong style="font-size: 12px;"><br /></strong></strong></span></span></div>
<div>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #008000;">//SailfishOS </span><span style="color: #008000;">"flavour" </span><span style="color: #008000;">of </span><span style="color: #008000;">user </span><span style="color: #008000;">interface </span><span style="color: #008000;">components </span><span style="color: #008000;">abstraction </span><span style="color: #008000;">layer</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;">"plugin.h"</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;">"auimpagestatus.h"</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;">"auimdialogstatus.h"</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;">"auimpageorientation.h"</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;"><qdeclarative.h></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;">void </span><span style="color: #800080;">AbstractuiPlugin</span>::<span style="font-style: italic;">registerTypes</span>(<span style="color: #808000;">const </span><span style="color: #808000;">char </span>*uri)</pre>
<pre style="margin: 0px;">{</pre>
<pre style="margin: 0px;"><span style="color: #000080;"> Q_ASSERT</span>(uri==<span style="color: #800080;">QLatin1String</span>(<span style="color: #008000;">"org.flyingsheep.abstractui"</span>));</pre>
<pre style="margin: 0px;"> qmlRegisterUncreatableType<AUIMPageStatus>(uri,<span style="color: #000080;">1</span>,<span style="color: #000080;">0</span>,<span style="color: #008000;">"AUIPageStatus"</span>,<span style="color: #008000;">""</span>);</pre>
<pre style="margin: 0px;"> qmlRegisterUncreatableType<AUIMDialogStatus>(uri,<span style="color: #000080;">1</span>,<span style="color: #000080;">0</span>,<span style="color: #008000;">"AUIDialogStatus"</span>,<span style="color: #008000;">""</span>);</pre>
<pre style="margin: 0px;"> qmlRegisterUncreatableType<AUIMPageOrientation>(uri,<span style="color: #000080;">1</span>,<span style="color: #000080;">0</span>,<span style="color: #008000;">"AUIPageOrientation"</span>,<span style="color: #008000;">""</span>);</pre>
<pre style="margin: 0px;">}</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;">Q_EXPORT_PLUGIN2</span>(abstractuiplugin,AbstractuiPlugin)<!--EndFragment--></pre>
</div>
<div><span style="font-family: Helvetica; font-size: 14px;"><span><strong><strong style="font-size: 12px;"><br /></strong></strong></span></span></div>
<div>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><strong><strong style="font-size: 12px;">Alpha 2 plugin.cpp file</strong></strong></span></pre>
</div>
<div><span style="font-family: Helvetica; font-size: 14px;"><span><strong><strong style="font-size: 12px;"><br /></strong></strong></span></span></div>
<div>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #008000;">//SailfishOS </span><span style="color: #008000;">"flavour" </span><span style="color: #008000;">of </span><span style="color: #008000;">user </span><span style="color: #008000;">interface </span><span style="color: #008000;">components </span><span style="color: #008000;">abstraction </span><span style="color: #008000;">layer</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;">"plugin.h"</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;">"auimpagestatus.h"</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;">"auimdialogstatus.h"</span></pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;">"auimpageorientation.h"</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #000080;">#include</span><span style="color: #008000;"><qqml.h></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;">void </span><span style="color: #800080;">AbstractuiPlugin</span>::<span style="font-style: italic;">registerTypes</span>(<span style="color: #808000;">const </span><span style="color: #808000;">char </span>*uri)</pre>
<pre style="margin: 0px;">{</pre>
<pre style="margin: 0px;"><span style="color: #000080;"> Q_ASSERT</span>(uri==<span style="color: #800080;">QLatin1String</span>(<span style="color: #008000;">"org.flyingsheep.abstractui"</span>));</pre>
<pre style="margin: 0px;"> qmlRegisterUncreatableType<AUIMPageStatus>(uri,<span style="color: #000080;">1</span>,<span style="color: #000080;">0</span>,<span style="color: #008000;">"AUIPageStatus"</span>,<span style="color: #008000;">""</span>);</pre>
<pre style="margin: 0px;"> qmlRegisterUncreatableType<AUIMDialogStatus>(uri,<span style="color: #000080;">1</span>,<span style="color: #000080;">0</span>,<span style="color: #008000;">"AUIDialogStatus"</span>,<span style="color: #008000;">""</span>);</pre>
<pre style="margin: 0px;"> qmlRegisterUncreatableType<AUIMPageOrientation>(uri,<span style="color: #000080;">1</span>,<span style="color: #000080;">0</span>,<span style="color: #008000;">"AUIPageOrientation"</span>,<span style="color: #008000;">""</span>);</pre>
<pre style="margin: 0px;">}</pre>
<pre style="margin: 0px;"><br /><!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">Here the only difference is that the Q_EXPORT_PLUGIN2 macro is no longer required.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><a href="https://qt-project.org/doc/qt-5.1/qtdoc/qtquick-porting-qt5.html">https://qt-project.org/doc/qt-5.1/qtdoc/qtquick-porting-qt5.html</a> states: </span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">"</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><span style="color: #363534; font-family: 'Open Sans', sans-serif; font-size: 13px; line-height: 20px; text-align: left;">plugins no longer require the Q_EXPORT_PLUGIN2() macro. Instead, they should use the </span><a style="margin: 0px; padding: 0px; font-family: 'Open Sans', sans-serif; color: #00732f; text-decoration: none; font-size: 13px; line-height: 20px; text-align: left;" href="https://qt-project.org/doc/qt-5.1/qtcore/qtplugin.html#Q_PLUGIN_METADATA">Q_PLUGIN_METADATA</a><span style="color: #363534; font-family: 'Open Sans', sans-serif; font-size: 13px; line-height: 20px; text-align: left;">() macro within the plugin class declaration.</span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">"</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">I will look into what this means at a later date, and update this post.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong>The *.qml Files</strong></span></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">These now import </span>QtQuick 2.0 <span style="font-family: Helvetica;">rather than the </span>QtQuick 1.0<span style="font-family: Helvetica;"> of the first SDK. When I get to testing the library I will see if this has any knock on implications for the qml code, and update this post accordingly.</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 14px;"><span style="color: #ffd479;"><strong>The qmldir File </strong></span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">According to <a href="http://qt-project.org/doc/qt-5.0/qtqml/qtqml-modules-qmldir.html">http://qt-project.org/doc/qt-5.0/qtqml/qtqml-modules-qmldir.html</a> the qmldir should start with a "module </span><span style="font-family: Helvetica;">identifier directive".</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">So the first line in the AbstractUI qmldir is now:</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">module org.flyingsheep.abstractui</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">This prevents warnings like:</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"> </pre>
<p style="margin: 0px;"><!--StartFragment--><span style="font-family: Monaco; font-size: 12px; color: #aa0000;">Module 'Sailfish.Silica' does not contain a module identifier directive - it cannot be protected from external registrations.</span></p>
<pre style="margin: 0px;"> </pre>
<p style="margin: 0px; font-family: Monaco; font-size: 12pt; color: #aa0000;"> </p>
<p style="margin: 0px; font-family: Monaco; font-size: 12pt; color: #aa0000;"><span style="font-family: Helvetica; font-size: 12px;">(In this case, thrown by Sailfish.Silica, which is currently missing a module identifier directive.)</span></p>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ffd479;"><strong>Next Steps</strong></span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ffd479;"><strong><br /></strong></span></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">Having made these changes, my library now builds, and I have an libabstractui.so and a qmldir file.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">The next step will be to install the library and then import it to LandedSettings. I will post on that soon ….</span></pre>
<span style="font-family: Helvetica; font-size: 14px;"><span><strong><strong style="font-size: 12px;"><br /></strong></strong></span></span></div>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><!--EndFragment--></pre>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-58306336696272536342013-08-03T14:15:00.001+02:002013-08-03T14:15:21.443+02:00Update after the Sailfish Qt5 Alpha<p>Hi all</p>
<p>This is just a quick update to say what I am up to, and the changes I hope to make to this blog over the next few days and weeks.</p>
<p>The announcement of the second Sailfish Alpha: this one Qt5 is a tipping point. Plus the fact that the Sailfish guys were kind enough to link this blog from their official website has put a cat amongst the pigeons!</p>
<p>Due to the differences between Qt4 and Qt5 some of the exiting articles will no longer be relevant. Most however will be, but with small changes. So I am doing the following:</p>
<p>1) I have marked most posts indicating that they will be revised for the new Alpha soon.</p>
<p>2) Started updating posts for Qt5.</p>
<p>3) I have started porting my app LandedSettings so that it runs with the new Alpha. Whilst doing so I will gradually review existing posts and update these with differences. As LandedSettings currently uses the AbstractUI library this is a good "complicated" example to start with.</p>
<p>4) Where I encounter major differences (headaches) I will post new articles highlighting these!</p>
<p>5) I am pondering just how viable an abstraction library supporting Harmattan (Qt4.7.4) and Sailfish (Qt 5) remains, . I am convinced that the technique is highly relevant for different platforms on Qt 5, but less so for platforms on different Qt Versions. Once I am past the pondering stage I will post in detail on this topic.</p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-78116780276120826882013-08-02T13:40:00.001+02:002013-08-02T13:40:21.922+02:00Sailfish Qt5 Alpha Available!<p>Hi All</p>
<p>As of last night the SailfishOs Qt5 Alpha is now available for download.</p>
<p>The biggest and most obvious change is that the "old" alpha used Qt 4.8.3, the "new" alpha uses Qt 5.</p>
<p>Equally interesting, X11 has been replaced by Wayland.</p>
<p>Whereas Qt 4.7.4 (Harmattan) and Qt 4.8.3 (Sailfish Silica) were close enough as to make very little difference, Qt5 brings some big changes. It remains to be seen as to how this makes supporting an app with a common code base for Harmattan and Sailfish more difficult (or even impossible….)</p>
<p>Sailfish have added a webpage on porting from Harmattan. It can be found <a href="https://sailfishos.org/wiki/Porting/Harmattan">here</a>.</p>
<p>In the meantime I have installed the Qt5 Alpha on OSX and Lubuntu 64 bit, and been able to run and deploy the default "Hello Sailor" app on both. Windows is downloading in the background as I type this.</p>
<p>Note that before you install the new SDK, you should first deinstall the old SDK using the SDKMaintenance tool. As I am by nature suspicious I simply renamed the original install directory and the hidden .scratchbox2 directory, so that I could easily restore these if required.</p>
<p>My next step is to try running Landed and LandedSettings.. I hope to bring news over the next few days of how this works.</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-2984020845617251472013-06-27T20:49:00.001+02:002013-06-27T20:49:49.106+02:00QML: Faking an SQLResultSet Object with JavaScript<p>A few days ago while hunting down an elusive bug in the way the Silica <span style="font-family: Helvetica; font-size: 12px;"><strong>ContextMenu</strong></span> component work I decided to produce a radically stripped down version of LandedSettings. The idea was to prove that the strange behaviour was still present in a pure Sailfish project, and make things much more readable by removing anything from the project not directly related to the issue.</p>
<p>Now LandedSettings is ultimately a front end to an SQLite database. But in my simplified project I only needed data from one table, basically a list which is returned from the Javascript handling SQLite as a JavaScript rs object.</p>
<p>I was keen to remove all the code concerned with database setup and access, yet did not want to change the code deep in my app that processes the resultset. </p>
<p>So would it be possible to produce a JavaScript object equivalent to that returned from SQLite? This object would return the same data (a list of 6 items), and would have to have the same structure as its SQLite equivalent.</p>
<p>In effect, could I replace the whole database access code with a simple javascript method returning a javascript object?</p>
<p>As we will see, not only is it possible, but it is actually very simple, elegant and easy to achieve. (But as is often the case, working out how to do this was not so easy …)</p><br /><a name='more'></a><br /><p>First I had to find out exactly what is the "rs" object returned from an SQLite select, and how it is structured. After a bit of googling I found this documentation: <a href="http://www.w3.org/TR/webdatabase/#sqlresultset">http://www.w3.org/TR/webdatabase/#sqlresultset</a></p>
<p>It turns out that 'rs' is officially called an <span style="font-family: Helvetica; font-size: 12px;"><strong>SQLResultSet</strong></span>. This object has 2 properties and a child object '<span style="font-family: Helvetica; font-size: 12px;"><strong>rows</strong></span>'.</p>
<p>For a SQLResultSet returned from a select the 2 properties <span style="font-family: Helvetica; font-size: 12px;"><strong>insertId</strong></span> and <span style="font-family: Helvetica; font-size: 12px;"><strong>rowsAffected</strong></span> are not interesting, so while we will add these to our object we will set them to zero.</p>
<p>But the child object '<span style="font-family: Helvetica; font-size: 12px;"><strong>rows</strong></span>' is interesting. This is an object of type "<span style="font-family: Helvetica; font-size: 12px;"><strong>SQLResultSetRowList</strong></span>' and has 2 members that should be familiar to us.</p>
<p>The first is a property <span style="font-family: Helvetica; font-size: 12px;"><strong>length</strong></span>. This will return the number of rows in the result set. We are used to accessing this as <span style="font-family: Helvetica; font-size: 12px;"><strong>rs.rows.length</strong></span>.</p>
<p>The second is the method <span style="font-family: Helvetica; font-size: 12px;"><strong>item()</strong></span>. This is an accessor method used to 'get' one row. e.g. <span style="font-family: Helvetica; font-size: 12px;"><strong>rs.rows.item(0).name</strong></span> would give us the name field of the first item in the result set.</p>
<p>So now we understand the desired end structure, how do we express this in JavaScript?</p>
<p>There are several ways / formats to declare an object in JavaScript, but the one that worked for me and seemed to be most Qt / QML friendly is as described here.<a href="http://javascript.info/tutorial/objects">http://javascript.info/tutorial/objects</a></p>
<p>Then I set about building up and testing the required objects, properties and methods step by step.</p>
<p>First I made a simple JavaScript Array object to store the rows. Each row has 2 fields id and name.</p>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">var </span><span style="font-style: italic; color: #2985c7;">qmlrs </span>= [];</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;">qmlrs</span>.push({id:1, name:<span style="color: #008000;">'South</span><span style="color: #008000;">Africa'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;">qmlrs</span>.push({id:1, name:<span style="color: #008000;">'Greece'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;">qmlrs</span>.push({id:1, name:<span style="color: #008000;">'Schweiz'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;">qmlrs</span>.push({id:4, name:<span style="color: #008000;">'France'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;">qmlrs</span>.push({id:5, name:<span style="color: #008000;">'Italy'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;">qmlrs</span>.push({id:6, name:<span style="color: #008000;">'Austria'</span>});</pre>
<p>Next i built a <span style="font-family: Helvetica; font-size: 12px;"><strong>SQLResultSetRowList</strong></span></p>
<pre style="margin: 0px;"><!--StartFragment-->var rows = {</pre>
<pre style="margin: 0px;"><span style="color: #008000;"> //rows </span><span style="color: #008000;">is </span><span style="color: #008000;">a </span><span style="color: #008000;">SQLResultSetRowList</span><span style="color: #008000;">object</span></pre>
<pre style="margin: 0px;"> length: <span style="font-style: italic; color: #2985c7;">qmlrs</span>.length,</pre>
<pre style="margin: 0px;"> item: <span style="color: #808000;">function</span>(index) {</pre>
<pre style="margin: 0px;"><span style="color: #808000;"> return </span><span style="font-style: italic; color: #2985c7;">qmlrs</span>[<span style="font-style: italic; color: #2985c7;">index</span>];</pre>
<pre style="margin: 0px;"> }</pre>
<pre style="margin: 0px;">}</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">Note that each property / method is separated by a comma, not a semicolon.</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;">Then I created the <span style="font-size: 13px;"><strong>SQLResultset</strong></span> around this.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">var </span><span style="font-style: italic; color: #2985c7;">rs </span>= {</pre>
<pre style="margin: 0px;"><span style="color: #008000;"> //rs </span><span style="color: #008000;">is </span><span style="color: #008000;">a </span><span style="color: #008000;">SQLResultSet</span><span style="color: #008000;">object</span></pre>
<pre style="margin: 0px;"> insertId: 0,</pre>
<pre style="margin: 0px;"> rowsAffected: 0,</pre>
<pre style="margin: 0px;"> rows: {</pre>
<pre style="margin: 0px;"><span style="color: #008000;"> //rows </span><span style="color: #008000;">is </span><span style="color: #008000;">a </span><span style="color: #008000;">SQLResultSetRowList</span><span style="color: #008000;">object</span></pre>
<pre style="margin: 0px;"> length: <span style="font-style: italic; color: #2985c7;">qmlrs</span>.length,</pre>
<pre style="margin: 0px;"> item: <span style="color: #808000;">function</span>(index) {</pre>
<pre style="margin: 0px;"><span style="color: #808000;"> return </span><span style="font-style: italic; color: #2985c7;">qmlrs</span>[<span style="font-style: italic; color: #2985c7;">index</span>];</pre>
<pre style="margin: 0px;"> }</pre>
<pre style="margin: 0px;"> }</pre>
<pre style="margin: 0px;">}<!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica; font-size: 13px;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">Here the child object rows is now expressed as 'rows: ' rather than the original 'vars rows ='.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">Then all I needed to do was wrap this in a function. Here I used the same name as the function in the original SQLite accessor script.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">function </span><span style="font-style: italic; color: #2985c7;">getTemplateGroups</span>() {</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;"> var </span><span style="font-style: italic; color: #2985c7;">qmlrs </span>= [];</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;"> qmlrs</span>.push({id:1, name:<span style="color: #008000;">'South</span><span style="color: #008000;">Africa'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;"> qmlrs</span>.push({id:1, name:<span style="color: #008000;">'Greece'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;"> qmlrs</span>.push({id:1, name:<span style="color: #008000;">'Schweiz'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;"> qmlrs</span>.push({id:4, name:<span style="color: #008000;">'France'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;"> qmlrs</span>.push({id:5, name:<span style="color: #008000;">'Italy'</span>});</pre>
<pre style="margin: 0px;"><span style="font-style: italic; color: #2985c7;"> qmlrs</span>.push({id:6, name:<span style="color: #008000;">'Austria'</span>});</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;"><br /></span></pre>
<pre style="margin: 0px;"><span style="color: #808000;"> var </span><span style="font-style: italic; color: #2985c7;">rs </span>= {</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #008000;"> //rs </span><span style="color: #008000;">is </span><span style="color: #008000;">a </span><span style="color: #008000;">SQLResultSet</span><span style="color: #008000;">object</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> insertId: 0,</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> rowsAffected: 0,</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> rows: {</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #008000;"> //rows </span><span style="color: #008000;">is </span><span style="color: #008000;">a </span><span style="color: #008000;">SQLResultSetRowList</span><span style="color: #008000;">object</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> length: <span style="font-style: italic; color: #2985c7;">qmlrs</span>.length,</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> item: <span style="color: #808000;">function</span>(index) {</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="color: #808000;"> return </span><span style="font-style: italic; color: #2985c7;">qmlrs</span>[<span style="font-style: italic; color: #2985c7;">index</span>];</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> }</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> }</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"> }</pre>
<pre style="margin: 0px;"><span style="color: #808000;"> return </span><span style="font-style: italic; color: #2985c7;">rs</span>;</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">}<!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">With this technique I could simulate an SQL select. Of course it is no good for persisting changes to data, but that was not necessary for my stripped down project.</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><!--EndFragment--></pre>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com1tag:blogger.com,1999:blog-1638189258536559624.post-36149614090426522802013-06-23T17:04:00.001+02:002013-06-23T17:04:11.436+02:00Playing around with the guts of Sailfish Silica Components<p>Have you ever felt the need to dig around in the guts of the Sailfish Silica provided QML components to work out how things are done? This article explains how you can do this.</p>
<p>Recently I decided to change the way my LandedSettings app allows the user to create, edit and delete entries in the settings database.</p>
<p>Under the existing solution, when the user double-clicked an item in a view (and I have four views), the view delegate would push an appropriate configuration page. This page was festooned with new, edit and delete buttons. Each of these would push a further page allowing that action to be carried out.</p>
<p>I was never entirely happy with this solution. It always struck me as more than a little clumsy and very "desktop", but as LandedSettings was a secondary app supporting the main app Landed I stuck with it.</p>
<p>Then I started porting to Sailfish Silica. Using the Sailfish ComponentsGallery as a reference (click on the propeller on the home screen) I found that under Silica, when a view entry is pressed and held, a context menu drops down.</p>
<p>This seemed to be a much better solution to offer new, copy, edit and delete options, so I set about changing LandedSettings to use this type of context menu.</p><br /><a name='more'></a><br /><p>After a little bit of hacking, I got the ContextMenu to open, but not quite as I expected. This strange behaviour is reported here:</p>
<p><a href="https://lists.sailfishos.org/pipermail/devel/2013-June/000431.html">https://lists.sailfishos.org/pipermail/devel/2013-June/000431.html</a></p>
<p>So how do I track down and cure this behaviour?</p>
<p>Well the first step is to find the guilty qml file. In QtCreator a right-click / "Follow Symbol Under Cursor" takes us to the file</p>
<p>In this case it's ContextMenu.qml, and can be found in /Users/<your home drive>/SailfishOS/mersdk/targets/SailfishOS-i486-x86/usr/lib/qt4/imports/Sailfish/Silica/</p>
<p>Now I could have edited this file direct, then copied it to the Emulator via SSH / SCP. But I did not want to change the original</p>
<p>Instead, I decided to create a clone LandedContextMenu in my project. I could then change the clone to my heart's desire, and deploy it just as I deploy any other .qml file in my project.</p>
<p>To get the clone to work, I had to make a few more changes:</p>
<p>a) in addition to copying ContextMenu to my project, I also had to copy Util.js and HighlightBar.qml, both of which are used by ContextMenu.qml, and can be found in the private subdirectory.</p>
<p>b) change the import in LandedContextMenu to</p>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #808000;">import </span><span style="color: #008000;">"Util.js" </span>as <span style="font-style: italic; color: #0055af;">Util</span></pre>
<pre style="margin: 0px;"><span style="color: #808000;">import </span>Sailfish.Silica.private 1.0</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">The Sailfish.Silica.private import is required to get the ScreenChangeNotifier component working. This exposed by a c++ plugin, and not as a .qml file.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">Having done this I could now change things within LandedContextMenu, and see how this affected LandedSettings.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">My desk-checking of ContextMenu.qml had suggested that the problem might be caused by a PropertyChanges element that operates on the contentY property of a Flickable.</span></pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;"><!--StartFragment--><span style="color: #800080;">PropertyChanges</span>{</pre>
<pre style="margin: 0px;"><span style="color: #800000;">target</span>: <span style="font-style: italic;">_flickable</span></pre>
<pre style="margin: 0px;"><span style="color: #800000;">contentY</span>:<span style="font-style: italic; color: #0055af;">Math</span>.max(<span style="font-style: italic;">contextMenu</span>.mapToItem(<span style="font-style: italic;">_flickable</span>.contentItem, 0, <span style="font-style: italic;">contextMenu</span>.childrenRect.height).y-<span style="font-style: italic;">_flickable</span>.height, <span style="font-style: italic;">_flickable</span>.contentY)</pre>
<pre style="margin: 0px;"><span style="color: #800000;">interactive</span>: false</pre>
<pre style="margin: 0px;"><span style="color: #800000;">explicit</span>: true</pre>
<pre style="margin: 0px;">}<!--EndFragment--></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;">So my next task is to understand this, and then decide if I can find a workaround, or maybe even keep a modified version of the clone in my project.</span></pre>
<pre style="margin: 0px;"><span style="font-family: Helvetica;"><br /></span></pre>
<pre style="margin: 0px;"><!--EndFragment--></pre>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-29631300177826133602013-06-20T08:07:00.001+02:002013-06-20T08:07:15.131+02:00Connecting to the Harmattan QEMU: Learning from Sailfish!<p>A few days ago I wanted to compare some differences in behavior between the Sailfish Emulator, and the old Harmattan Equivalent QEMU.</p>
<p>These are two very different beasts, with the QEMU being so slow and unresponsive as to be just barely usable, while the Sailfish Emulator is a much snappier affair. But that is not the point of this post.</p>
<p>On starting up on the QEMU I realized that I had not installed my AbstractUI library on QEMU, and even more surprisingly that I had never connected to the thing via SSH for a peak inside.</p>
<p>A quick google found this link:</p>
<p style="margin: 0px; font-size: 12px;"><a href="http://harmattan-dev.nokia.com/docs/library/html/guide/html/Developer_Library_Alternative_development_environments_Platform_SDK_user_guide_Using_QEMU_in_Scratchbox.html">http://harmattan-dev.nokia.com/docs/library/html/guide/html/Developer_Library_Alternative_development_environments_Platform_SDK_user_guide_Using_QEMU_in_Scratchbox.html</a></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;">So we can connect like this:</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"><span style="font-family: Courier; font-size: 12px;">ssh -p6666 root@localhost</span></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">no password required!</p><br /><a name='more'></a><br /><p><span style="font-size: 20px; font-family: Helvetica;"><span style="color: #ff9300;"><strong>Installing AbstractUI with an Rsync Script</strong></span></span></p>
<p>After a bit of poking around, I decide that AbstractUI should be installed in: </p>
<p style="margin: 0px; font-size: 12px;">/usr/lib/qt4/imports</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">But can I use rsync (and a script like I made for the Sailfish Emulator)?</p>
<p>A quick test of rsync on QEMU proves disappointing: <span style="font-family: Helvetica; font-size: 12px;"><strong>rsync</strong></span> is not installed, and <span style="font-family: Helvetica; font-size: 12px;"><strong>apt-get install rsync</strong></span> finds nothing.</p>
<p>So after some more googling, I came across this:</p>
<p style="margin: 0px; font-size: 12px;"><a href="http://www.who.is.free.fr/wiki/doku.php?id=harmattan">http://www.who.is.free.fr/wiki/doku.php?id=harmattan</a></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p>Unfortunately the link to the .deb package did not work: This would have been my preferred option.</p>
<p>But the second option worked: Adding a repository to apt, and then doing <span style="font-family: Helvetica; font-size: 12px;"><strong>apt-get instal rsync</strong></span> again.</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff2600;"><strong>Please bear in mind that you do this at your own risk, and only try this if you have some idea of what your are doing. If you goldfish has kittens, your mother-in-law gets the hiccups (or the other way around) as a result of this, don't come running to me!</strong></span></span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# killall pkgmgrd && killall pkgmgrd</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">killall: pkgmgrd: no process killed</span></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"><span style="font-family: Courier; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# distro="harmattan"</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# target="MeeGo_1.2_Harmattan_Maemo.org_MeeGo_1.2_Harmattan_standard"</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# repo="home-rzr-${distro}-${target}"</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# baseurl="http://rzr.online.fr/r/"</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# url="http://repo.pub.meego.com/home:/rzr:/${distro}/${target}/"</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# url="${baseurl}${url}"</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# echo "deb ${url} ./" | tee "/etc/apt/sources.list.d/${repo}.list"</span></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"><span style="font-family: Courier; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">RX71-47-2_QEMU_MR0:~# apt-get install rsync</span></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p>Note that in the original instructions in the link above the author installed further bits and bobs. I chose not to do this - at -least until I work out what these are. For the moment I am only interested in getting rsync.</p>
<p>Having run the above, another test rsync gives much more positive results.</p>
<p>Without further ado, we can then modify our sync script for QEMU:</p>
<p><span style="font-family: Courier; font-size: 12px;"># This script syncs abstractui files from the localhost to the QEMU Harmattan Emulator</span><br /><span style="font-family: Courier; font-size: 12px;"># and then sets owners and rights</span><br /><span style="font-family: Courier; font-size: 12px;"># Note: It syncs the entire org directory structure.</span><br /><span style="font-family: Courier; font-size: 12px;"># Make this script executable with chmod 755 syncAUI2QEMU.sh</span><br /><span style="font-family: Courier; font-size: 12px;"># call it with ./syncAUI2QEMU.sh</span><br /><span style="font-family: Courier; font-size: 12px;">rsync -avz -e "ssh -p 6666" org root@localhost:/usr/lib/qt4/imports/ --exclude .DS_Store \</span><br /><span style="font-family: Courier; font-size: 12px;">&& \</span><br /><span style="font-family: Courier; font-size: 12px;">ssh -p 6666 root@localhost "cd /usr/lib/qt4/imports/ && \chown -R root:root org && \</span><br /><span style="font-family: Courier; font-size: 12px;">cd org/flyingsheep/abstractui && \</span><br /><span style="font-family: Courier; font-size: 12px;">chmod 755 *.so && \</span><br /><span style="font-family: Courier; font-size: 12px;">chmod 644 *.qml && \</span><br /><span style="font-family: Courier; font-size: 12px;">chmod 644 qmldir && \</span><br /><span style="font-family: Courier; font-size: 12px;">ls -ahl && \</span><br /><span style="font-family: Courier; font-size: 12px;">exit \</span><br /><span style="font-family: Courier; font-size: 12px;">; bash"</span></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-73831593334399088982013-06-13T23:08:00.001+02:002013-06-13T23:08:34.889+02:00Menu Abstraction with AbstractUI Part 2<p>Hi all</p>
<p>In a post some days ago I pointed out that menu handling is substantially different between Harmattan and Sailfish Silica. I may even have mentioned jumping through flaming hoops ...</p>
<p>Well the solution I now have is not perfect. I would still categorize it as a workaround, but it is one that I can live with as it fits my needs, and I am aware of the weaknesses.</p>
<p>From a user's point of view (and we should never forget our users) the differences in Menu Handling are these:</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff9300;"><strong>1) Launching</strong></span></span></p>
<p>A Harmattan menu is launched from the Toolbar which sits at the bottom of the screen occupying valuable screen real-estate.</p>
<p>The Silica Menu is launched by swiping the screen (up in the case of a PushUpMenu, down in the case of a PullDownMenu). While no screen real-estate is consumed by a ToolBar, the menu is indicated by a MenuIndicator. The trouble is that the new user will naturally try and open the menu by the indicator: that's the intuitive thing to do: but it is the part of the screen that cannot be used to open the menu: if you drag there you will slide the whole app away!</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><strong><span style="color: #ff9300;">2) Behaviour on Opening</span></strong></span></p>
<p>When the Harmattan Menu opens, it slides over other content on the page, without any programmer intervention, and as the menu is non-transparent, there is no "interference" between menu items and components now under the open menu.</p>
<p>The Silica Menu, at least in the demo new project, causes other page content (page childs) to slide away with the menu as it opens</p>
<p>So how do these affect us as programmers? Read on:</p>
<p> </p><br /><a name='more'></a><br /><p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Thoughts on Menu Launching</strong></span></span></p>
<p>The confusing idiom of dragging anything but the menu indicator is something the Sailfish Jolla guys will need to do some thinking about, but I see a problem where a page already hosts flickable items. As an example, my LandedSettings app has four ListViews on the MainPage (or in Silica speak FirstPage). These have variable content read in from an SQLite settings DB, and the content displayed in one ListView depends on the content in a parent ListView.It is quite possible that he total height of all four ListViews is greater than the available screen height, so in the original Harmattan implementation, flicking the screen up or down would flick the stack of ListViews. The Menu could still be opened, because it was launched from the ToolBar - which was like a kind of "reserved area" at the bottom of the screen.</p>
<p>Now with Silica I have a conflict. Following the Silica idiom, flicking the screen should open a menu: yet I still need to be able to handle screen content taller than the visible screen!</p>
<p>At the moment the workaround is to reserve a small area at the bottom of the screen just above the MenuIndicator. When this area is flicked, the menu opens. When the rest of the screen if flicked, the stack of ListViews scroll. Defacto I have an invisible Toolbar.</p>
<p>But it remains a workaround. Possibly I will totally abandon the Menu for LandedSettings: the current entries are for testing purposes only; or maybe I need to find a much better idiom then the 4 fully expanded ListViews. Some out-of-the-box thinking is required!</p>
<p>Perhaps the pertinent point is that the Silica menu opening idiom is forcing me to think about the whole screen design, and may result in a completely different approach to that which worked naturally with Harmattan. Time will prove if the end result is better or a kludge!</p>
<p><span style="font-family: Helvetica; font-size: 20px;"><span style="color: #ff9300;"><strong>Thoughts on Menu Opening</strong></span></span></p>
<p>From a technical point-of-view the greatest problem I have so far is getting other page childs to slide away when the menu opens. I must confess that I have not really invested much time in this yet, and may have got overly distracted in polishing the workarounds.</p>
<p>To recap: the Silica Menu, at the moment a PushUpMenu, is embedded with the declaration of the AUIPageWithMenu control. The programmer will import this control, and add an instance to his project. let's call it MyPage. MyPage will in turn have various child components, Buttons, Rectangles, Labels etc. Following the Silica idiom all these childs of MyPage should slide up when the embedded PushUpMenu opens.</p>
<p>But despite reparenting these childs I have not got that working yet.</p>
<p>So for the moment I have a 2 part workaound</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff9300;"><strong>1) Change the Menu Z axis property bound to the Menu's active property.</strong></span></span></p>
<p>When the menu is opened, Z should be high, so as to be painted (and thus slide) above all other components. At the moment I set it to an arbitrary 9999 as this is a workaround, but were this to be the final solution i would probably have to have logic to find the highest current Z, and make the open menu Z higher.</p>
<p>When the menu is closed the Z property of the menu should be low. This is important, as if the menu is closed, but has a high Z property, the Flickable no longer works, and the menu cannot be opened! The menu "steals" mouse input even though is is closed if it has a higher Z then other items!</p>
<p>With this workaround in place, the Menu should now slide over the childs of MyPage, but this leads us to the next problem and its workaround:</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><span style="color: #ff9300;"><strong>2) Change the Opacity of other childs of the Page</strong></span></span></p>
<p>The menu now slides over other content, but given that everything Silica is glassy, and therefore transparent, the menu becomes hard to read if we have other text or distracting items underneath it.</p>
<p>My workaround is to fade these "other items" by reducing their opacity property. They remain visible, but less prominent than the Menu. The technique used is interesting enough that I will post a separate article on it, together with an open question.</p>
<p>So for the moment my Sailfish implantation of menu handling does not yet slide other content away: instead the menu (should) slide over other content, and fade other page content while open.</p>
<p>Watch this space for more news, the battle is not yet decided!</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-24761430793262333512013-06-13T21:00:00.001+02:002013-06-13T21:55:35.679+02:00Connecting to a Nokia N9 with a RSA Key File: Learning from Sailfish!<p>I recently had to reflash my Nokia N9 because Bluetooth would no longer start. The reflashing itself is a story for another time (and maybe another blog post), but the process of restoring apps and stuff after the reflash made me think about how I interact with the N9 as a developer.</p>
<p>Until now when I have needed to move files onto the N9 I have connected via SSH using the password prompted in the N9's SDK Connectivity App. While this works well it is a bit cumbersome.</p>
<p>Then I reflected on how we interact with the Sailfish SDK and Emulator. Here we authenticate via RSA key files. No password needed. Much nicer, yet equally secure.</p>
<p>So this raised the question: can we apply the same technique to the N9? Can we connect to the N9 with a RSA key file?</p>
<p>After a little bit of googling and experimentation, the answer is a resounding yes; and it proves to be very easy.</p>
<p>I found the basic idea here: <a style="font-size: 12px;" href="http://talk.maemo.org/showthread.php?t=41547">http://talk.maemo.org/showthread.php?t=41547</a>. So thanks to Greygoo the author. My post takes a slightly simpler approach, and is specific to the N9.</p><br /><a name='more'></a><br /><p> </p>
<p>Easy it may be: but please bear in mind that if you get this wrong, you may lose SSH access to your phone. Please take care, think with me; and you follow these instructions at your own responsibility.</p>
<p>Firstly we need to generate a key pair on our development host. In this case I will be using Apple-pip my MacBookAir. This will give us a public key and a private key. The private key will remain securely on Apple-pip (the client in the connection), and the public key will be put on to the connection server - the N9.</p>
<p>So on Apple-Pip: let's move the .ssh directory, then list what's already there</p>
<p><span style="font-family: Courier; font-size: 12px;">cd ~/.ssh</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">ls -ahl</span></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">Now we will generate a key pair called n9_rsa, with an empty passphrase.</p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">ssh-keygen -t rsa</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">Generating public/private rsa key pair.</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">Enter file in which to save the key (~/.ssh/id_rsa): n9_rsa</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">Enter passphrase (empty for no passphrase): </span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">Enter same passphrase again: </span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">Your identification has been saved in n9_rsa.</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">Your public key has been saved in n9_rsa.pub.</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">The key fingerprint is:</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">f1:8e:51:ab:d8:0c:fb:2f:ee:9c:fd:d5:02:25:69:d6 xxxxxxx@Apple-Pip.local</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">The key's randomart image is:</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">+--[ RSA 2048]----+</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| |</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| o |</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| . . = E |</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| + + o |</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| . S o . |</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| * = . . |</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| o = . o .|</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| o.o . . |</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">| o*oo.. |</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">+-----------------+</span></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">Now if we ls again we should find 2 additional files, </p>
<p style="margin: 0px; font-size: 12px;">* private key n9_rsa</p>
<p style="margin: 0px; font-size: 12px;">* and the public key n9_rsa.pub</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;">Now we need to transfer the public key to the N9 </p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">scp ~/.ssh/n9_rsa.pub developer@192.168.2.15:/home/developer/</span></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">Then we connect to the N9 as we always have done, with password:</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;">ssh developer@192.168.2.15</span></p>
<p style="margin: 0px; font-size: 12px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 12px;">Once connected, move to the .ssh directory.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;"><span style="color: #011993;">cd .ssh</span></span></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">Now we want to concatenate the contents of the public key to the authorized_keys file</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;"><span style="color: #011993;">cat ../n9_rsa.pub >> authorized_keys</span></span></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">Then we cleanup by removing the public key file from the N9.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;"><span style="color: #011993;">cd ..</span></span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;"><span style="color: #011993;"><br /></span></span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Courier; font-size: 12px;"><span style="color: #011993;">rm n9_rsa.pub</span></span></p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p>Exit, and try reconnecting from your development host as follows:</p>
<p><span style="font-size: 12px; font-family: Courier;">ssh -i ~/.ssh/n9_rsa developer@192.168.2.15</span></p>
<p> </p>
<p><span style="font-size: 12px;"><br /></span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-51737434667687396462013-06-09T18:46:00.001+02:002013-08-02T19:28:28.032+02:00Where is my SQLite DB on the Sailfish Emulator ?<p><em style="color: #ff2600; font-family: Arial; font-size: 14px;">Note: This post will be updated for the Qt5 Alpha shortly!</em></p>
<p>By default, SQLite Database files are stored here on the Emulator:</p>
<p>/home/nemo/.local/share/data/QML/OfflineStorage/Databases/</p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-7263105838528603932013-06-09T17:03:00.001+02:002013-06-09T17:03:09.271+02:00Landed Project Source Posted to Github<p>I have hinted in previous posts at my core app Landed, which started over a year ago on Harmattan, and is now up and running on Sailfish as well. Getting Landed running on both platforms was the motivation for creating the AbstractUI abstraction library.</p>
<p>For sometime I have been mulling over the idea of publishing the source of Landed, but it was never quite ready enough: there was always something else to correct, improve or add, and the migration to Sailfish (and abstract) proved to be a distraction.</p>
<p>It was not until I realized that this is likely to always be the case: there will always be something to improve or tweak, or a cleaner way of doing things, that to quote the Duke of Wellington I decided to "Publish and be Dammed!".</p>
<p>So both Landed, and its sidekick LandedSettings are now posted to: <a href="https://github.com/sailfishapps/landed">https://github.com/sailfishapps/landed</a></p>
<p>See the <a href="https://github.com/sailfishapps/landed/blob/master/README.md">https://github.com/sailfishapps/landed/blob/master/README.md</a> file for an explanation of what Landed does, requirements, how to setup etc.</p>
<p>I make no apologies for the fact that Landed and LandedSettings are at the time of this post not finished. Most of the functionality works, but some does not. The abstract still throws lots of errors to the output, but am I working on the that.</p>
<p>Now for some food (cold fillet steak from last night), and some ale, then back to programming ….</p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-71282350577916091592013-06-01T10:30:00.001+02:002013-06-09T17:09:27.087+02:00Menu Abstraction with AbstractUI<p>I have been doing more work migrating my core apps to Sailfish using AbstractUI, extending this library as I find problems.</p>
<p>One of major stumbling blocks so far is Menu handling. Not only do Harmattan and Silica Menus look and behave a little bit differently (not really a problem), they also interact differently with other associated components (Page, MenuLayout etc.).</p>
<p>This means that the Harmattan and Sailfish versions of these abstraction controls have to differ substantially, yet still provide a common interface which can be used from one code base to target both platforms.</p>
<p>I will go into the differences and the flaming hoops I jumped through to address them in a second post later this weekend. For now I want to point out 4 demo menu handling projects that I have posted to <a href="https://github.com/sailfishapps/AbstractUI-for-Sailfish-Silica/tree/master/Demos/MenuAbsraction">Github</a> last night to demonstrate menu handling, with and without AbstractUI.</p>
<p>Each of these projects offers a menu with two options. One increments a counter on the page, the other decrements it. Each is based on a stripped down version of the "new project" created by the Harmattan and Sailfish QtCreators.</p>
<p>The <a href="https://github.com/sailfishapps/AbstractUI-for-Sailfish-Silica/tree/master/Demos/MenuAbsraction/HarmattanMenuDemo">HarmattanMenuDemo</a> shows native Harmattan menu handling: A ToolBar at the bottom of the screen, with a ToolIcon, which when pressed opens or closes the menu.</p>
<p>The <a href="https://github.com/sailfishapps/AbstractUI-for-Sailfish-Silica/tree/master/Demos/MenuAbsraction/SilicaMenuDemo">SilicaMenuDemo</a> is the Silica equivalent, with a native Silica PulldownMenu which is accessed by dragging down on anywhere on the screen other than the glowy MenuIndicator at the top. (This is a bit counter intuitive at first).</p>
<p>The <a href="https://github.com/sailfishapps/AbstractUI-for-Sailfish-Silica/tree/master/Demos/MenuAbsraction/HarmattanAbstractMenuDemo">HarmattanAbstractMenuDemo</a> is a copy of the HarmattanMenuDemo, but with the native controls abstracted out via the Harmattan flavour of AbstractUI.</p>
<p>The <a href="https://github.com/sailfishapps/AbstractUI-for-Sailfish-Silica/tree/master/Demos/MenuAbsraction/SilicaAbstractMenuDemo">SilicaAbstractMenuDemo</a> is the Silica equivalent, using the Silica flavour of AbstractUI.</p>
<p>There are some minor differences between the native and abstracted handling / look and feel, but I should be able to iron those out later.</p>
<p>For these demos I started with separate Harmattan and Silica projects a) to show the implementation(s) as natively as possible, and b) because I could not get a new Sailfish project to start up on Harmattan (the reverse should work), and I did not want to get side tracked into that issue…</p>
<p>In a later post I will dive deeper into the implementation.</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><strong>Update: 2013.06.01 14:03</strong></span></p>
<p><span style="font-family: Helvetica; font-size: 12px;">The Sailfish native implementation has all Page child items in a Flickable control sized to the Page, so </span><span style="font-family: Helvetica;">all items move down when the menu opens</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Consolas; min-height: 14px;"><span style="font-family: Helvetica; font-size: 12px;"> </span></p>
<p style="margin: 0px; font-size: 12px; font-family: Consolas;"><span style="font-family: Helvetica; font-size: 12px;">My current AUI implementation does not do this, </span><span style="font-family: Helvetica;">so while the menu opens, other page controls stay in place, and the menu may open behind them, rendering it not very useful!</span></p>
<p style="margin: 0px; font-size: 12px; font-family: Consolas;"><span style="font-family: Helvetica;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Consolas;"><span style="font-family: Helvetica; font-size: 12px;"><strong>Update: 2013.06.09 17:05</strong></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Consolas;"><span style="font-family: Helvetica;"><br /></span></p>
<p style="margin: 0px; font-size: 12px; font-family: Consolas;"><span style="font-family: Helvetica;">The Sailfish flavour of AUIPageWithMenu, now changes the z: axis of the menu to high when the menu is active (i.e. open) and low when not active (closed). Also when the menu opens, the opacity of all page childs is reduced (fading these out), so while they are still visible behind the menu, the menu is readable.</span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-63146599922151161282013-05-26T12:23:00.001+02:002013-08-05T22:44:19.198+02:00Deploying Files to the Sailfish Emulator using the Unix rsync Command: Part 2<p><em style="color: #ff2600; font-family: Arial; font-size: 14px;">Note: As of Alpha 2: The correct install location on the Emulator for import libraries is: <span style="font-size: 14px;"><span style="text-align: center; color: #ff7e79; font-family: Courier;">/usr/lib/qt5/</span><strong style="text-align: center; color: #ff7e79; font-family: Courier; font-size: 18px;">qml/</strong></span></em></p>
<p>In <a href="http://flyingsheeponsailfish.blogspot.ch/2013/05/deploying-files-to-sailfish-emulator.html">my last post</a> I showed how <strong>rsync</strong> can be used to sync files to the Emulator excluding unwanted files. We also required an additional set of commands to correctly set the owner and privileges.</p>
<p>Since then I have been working on the Sailfish flavour of AbstractUI, and testing this with my 2 core apps. This means frequent changes to the AbstractUI qmls, and the frequent need to synchronize to the Emulator.</p>
<p>Getting tired of rerunning the same 2 commands; I decided to make life even easier by creating a script <span style="font-family: Helvetica; font-size: 12px;"><strong>synchAUI2Emulator.sh</strong></span>:.</p>
<p style="margin: 0px; font-family: Courier; font-size: 14px; background-color: #eeeeee;"># This script syncs abstractui files from the localhost to the Sailfish Emulator<br /># and then sets owners and rights</p>
<p style="margin: 0px; font-family: Courier; font-size: 14px; background-color: #eeeeee;"># make this script executable with chmod 755 syncAUI2Emulator.sh<br /># call it with ./syncAUI2Emulator.sh</p>
<p style="margin: 0px; font-family: Courier; font-size: 14px; background-color: #eeeeee;">rsync -avz -e "ssh -p 2223 -i $HOME/.ssh/mer-qt-creator-rsa" org root@localhost:<span style="color: #ff2600;">/usr/lib/qt5/qml</span>/ --exclude .DS_Store \<br />&& \<br />ssh -p 2223 -i ~/.ssh/mer-qt-creator-rsa root@localhost "cd <span style="color: #ff2600;">/usr/lib/qt5/qml/</span> && \</p>
<p style="margin: 0px; font-family: Courier; font-size: 14px; background-color: #eeeeee;">chown -R root:root org && \<br />cd org/flyingsheep/abstractui && \<br />chmod 755 *.so && \<br />chmod 644 *.qml && \<br />chmod 644 qmldir && \<br />ls -ahl && \<br />exit \<br />; bash"</p>
<p>The script lives in my AbstractUI project, at the same level as the <strong>org</strong> directory which contains everything I need to synchronise.</p>
<p>Now just one call synchronizes all changes: the output shows the files that have been synchronized, and the privileges of all files on the destination.</p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0tag:blogger.com,1999:blog-1638189258536559624.post-86855440038120388082013-05-25T20:23:00.001+02:002013-08-05T22:42:32.529+02:00Deploying Files to the Sailfish Emulator using the Unix rsync Command<p style="margin: 0px; font-size: 20px; min-height: 20px; color: #ffd479;"><strong>Introduction</strong></p>
<p style="margin: 0px; font-size: 20px; min-height: 20px; color: #ffd479;"><strong><br /></strong></p>
<p style="margin: 0px; font-size: 20px; min-height: 20px; color: #ffd479;"><em style="color: #ff2600; font-family: Arial; font-size: 14px;">Note: Now <em style="color: #ff2600; font-family: Arial; font-size: 14px;">adapted for Alpha 2 / Qt5. S</em>ee <a style="text-decoration: none; color: #888888;" href="http://flyingsheeponsailfish.blogspot.ch/2013/05/deploying-files-to-sailfish-emulator_26.html">Part 2 of this post</a> for this technique as a script. </em></p>
<p style="font-size: 12px; margin: 0px; min-height: 8px;"> </p>
<p style="margin: 0px; font-size: 12px;">In a previous post I showed how files could be deployed to various Harmattan and Sailfish devices.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">For emulators and real devices we used the unix <span style="font-family: Helvetica; font-size: 12px;"><strong>scp</strong></span> secure copy command.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">Which worked. . .</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">. . . and would have worked well if Steve Jobs had not thrown a nasty little spanner in the works.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">My primary development Qt Host is OSX, primarily because a MacBookAir has just the right combination of portability and power that allows me develop in dead time on the train on the way to work, or like now sitting in an armchair, with Apple-Pip on my lap, a pint of ale on the floor next to my armchair, and my <a href="http://www.linn.co.uk/all-products/network-music-players">Linn</a> system streaming sweet sweet music.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">But I am not a mac-head. I point out things that are wrong with OSX, and one of those things is .DS_Store files.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">OSX automatically litters its file system with these hidden files. These serve some internal cabalistic purpose as sanely documented <a href="http://en.wikipedia.org/wiki/.DS_Store">here</a>. Bill Gates's equivalents are <a href="http://en.wikipedia.org/wiki/Windows_thumbnail_cache">Thumbs.db</a> files, which are just as pesky, but at least have a vaguely amusing name.</p>
<p style="margin: 0px; font-size: 12px;"> </p>
<p style="margin: 0px; font-size: 12px;">While these files are harmless in themselves, they cause extra headaches when interacting with version control systems, or when replicating betwee<span style="font-family: Arial;">n heterogeneous systems.</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Arial;"><br /></span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Arial;">The reference above to my Linn was not entirely spurious. For a few years I have been enjoying music steaming at CD quality and above, all stored in FLAC format on 2 NAS systems. Ever so often I sync the NASes with a backup on Butschgi my Mac Pro Tower. I use disparate sources (CDs ripped on Windows using <span style="font-family: Courier; font-size: 12px;"><a href="http://www.dbpoweramp.com/dmc.htm">dbPowerAmp</a>),</span> hi-res Albums (legally) downloaded on what ever machine i happen to be on, so after a bit of copying around and syncing between systems I like to count the number of files on each stem; but I always have the problems of those hidden .DS_Store and Thumbs.db files distorting the results .</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Arial;"><br /></span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Arial;">But getting back to the Sailfish Emulator. Here we again have heterogeneous systems: our host, and the Emulator; and want to copy files from the host to the Emulator without any pesky .DS_Store files polluting our innocent Emulator.</span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Arial;"><br /></span></p>
<p style="margin: 0px; font-size: 12px;"><span style="font-family: Arial;">The answer, as previously indicated is the unix command <span style="font-size: 12px;"><strong>rsync</strong></span>.</span></p>
<p style="margin: 0px; font-size: 12px;"> </p><br /><a name='more'></a><br /><p style="margin: 0px; font-size: 20px; min-height: 20px; color: #ffd479;"><strong>Using rsync</strong></p>
<p style="font-size: 12px; margin: 0px; min-height: 8px;"> </p>
<p style="font-size: 12px; margin: 0px;">First we need to install it on the Sailfish Emulator.</p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">ssh -p 2223 -i ~/.ssh/mer-qt-creator-rsa root@localhost</p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px;">Let's just check if it is not already installed, but I guess if you have read this far for anything than academic interest, it will not be.</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px; font-family: Courier; background-color: #3399cc;">rsync --version</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;">output:</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #3399cc;">-bash: rsync: command not found</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">So lets find rsync, and then install it;</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #3399cc;">zypper se rsync</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px; font-family: Courier; background-color: #3399cc;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #3399cc;">zypper in rsync</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">To verify that it is now installed:</p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #3399cc;">rsync --version</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;">Back on our host let's test the equivalent of the <span><strong>scp</strong></span> command we have used thus far: </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">rsync -avz -e "ssh -p 2223 -i $HOME/.ssh/mer-qt-creator-rsa" flyingsheep root@localhost:/usr/lib/qt4/imports/org/</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">output:</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">building file list ... done</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/.DS_Store</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/.DS_Store</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIButton.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIButtonColumn.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIButtonRow.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIButtonStyle.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUICheckBox.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUICheckBoxStyle.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIDialog.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUILabel.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIMenu.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIMenuItem.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIMenuLayout.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIPage.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIPageStackWindow.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIQueryDialog.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIRadioButton.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUISheet.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUITabButton.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUITabGroup.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIToolBarLayout.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIToolButton.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIToolIcon.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/libabstractui.so</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/plugins.qmltypes</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/qmldir</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px; font-family: Courier; background-color: #eeeeee;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">sent 3543 bytes received 4402 bytes 15890.00 bytes/sec</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">total size is 431766 speedup is 54.34</p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px;">Note that the home directory on the localhost is expressed as $HOME, rather than with the tilda (that spanish squiggly thing) as used with scp. This seems to be a rsync quirk (depending on the shell) which does not allow the tilda to be resolved to the home dir. But $HOME works, is more readable (and on an OSX CH_DE keyboard I can never find the tilda anyway).</p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px;">Now lets add the <span><strong>--exclude</strong></span> option as follows:</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">rsync -avz -e "ssh -p 2223 -i $HOME/.ssh/mer-qt-creator-rsa" flyingsheep root@localhost:/usr/lib/qt5/qml/org/ --exclude .DS_Store</p>
<p style="font-size: 12px; margin: 0px;"><span style="font-family: Courier;"><br /></span></p>
<p style="font-size: 12px; margin: 0px;"><span>output:</span></p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">building file list ... done</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIButton.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIButtonColumn.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIButtonRow.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIButtonStyle.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUICheckBox.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUICheckBoxStyle.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIDialog.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUILabel.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIMenu.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIMenuItem.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIMenuLayout.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIPage.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIPageStackWindow.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIQueryDialog.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIRadioButton.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUISheet.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUITabButton.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUITabGroup.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIToolBarLayout.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIToolButton.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/AUIToolIcon.qml</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/libabstractui.so</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/plugins.qmltypes</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">flyingsheep/abstractui/qmldir</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px; font-family: Courier; background-color: #eeeeee;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">sent 142471 bytes received 560 bytes 286062.00 bytes/sec</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">total size is 419470 speedup is 2.93</p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;">Note, as rsync only synchronizes changes, you may get less output this time, I purposely deleted the remote flyingsheep directory between the first and second rsync calls</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">After this we still need to set the correct unix file permissions for the files we have copied. Unfortunately also rsync (at least in my case) sets the owner and group of the files to <span><strong>501</strong></span> and <span><strong>games,</strong><span> rather than the </span></span><span><strong>root</strong></span><span><strong>root</strong></span><span> I would expect.</span></p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px;"><span style="background-color: transparent;">rsync does have a <span style="font-family: Courier;">--chmod</span> option, but as we need to set different options for different file types I prefer the solution below:</span></p>
<p style="font-size: 12px; margin: 0px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">ssh -p 2223 -i ~/.ssh/mer-qt-creator-rsa root@localhost \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">"cd /usr/lib/qt5/qml/org/ && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">chown -R root:root flyingsheep && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">cd flyingsheep/abstractui && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">chmod 755 *.so && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">chmod 644 *.qml && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">chmod 644 qmldir && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">ls -ahl && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">exit \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">; bash"</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">Here we ssh into the Emulator, and create a bash shell within which we</p>
<ul>
<li>change directory to /usr/lib/qt4/imports/org/,</li>
<li>set the owner and group of the directory flyingsheep recursively to root and root,</li>
<li>change directory to /usr/lib/qt4/imports/org/flyingsheep/abstractui/,</li>
<li>apply the required file permissions,</li>
<li>list our files (so we can verify if the above commands worked,</li>
<li>and then exits ssh, back to the local shell.</li>
</ul>
<p style="font-size: 12px; margin: 0px;">As we are using the double ampersand && to stitch unix commands together, each command will only execute if the previous was successful. i.e. if there is a problem the ssh session remains open; it wil only exit and return to the host if everything works without error.</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px;">See <span style="font-family: Arial; text-align: left;"><a href="http://www.ibm.com/developerworks/aix/library/au-badunixhabits.html">UNIX tips: Learn 10 good UNIX usage habits</a> </span>for more on the && and other unix shell good practices.</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;">I probably could combine this command with the rsync command above, but I think the result would be unreadable. A better approach would be a shell script wrapping both.</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="margin: 0px; font-size: 20px; min-height: 20px; color: #ffd479;"><strong>Conclusion</strong></p>
<p style="font-size: 12px; margin: 0px; min-height: 8px;"> </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"><span>So using </span></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">rsync -avz -e "ssh -p 2223 -i $HOME/.ssh/mer-qt-creator-rsa" flyingsheep root@localhost:/usr/lib/qt5/qml/org/ --exclude .DS_Store</p>
<p style="font-size: 12px; margin: 0px;"><span style="font-family: Courier;"><br /></span></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"><span>and </span></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">ssh -p 2223 -i ~/.ssh/mer-qt-creator-rsa root@localhost \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">"cd /usr/lib/qt5/qml/org/ && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">chown -R root:root flyingsheep && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">cd flyingsheep/abstractui && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">chmod 755 *.so && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">chmod 644 *.qml && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">chmod 644 qmldir && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">ls -ahl && \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">exit \</p>
<p style="font-size: 12px; margin: 0px; font-family: Courier; background-color: #eeeeee;">; bash"</p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"> </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;">we can copy files to our remote device, excluding .DS_Store files. </p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"><span><br /></span></p>
<p style="font-size: 12px; margin: 0px; min-height: 14px;"><span><em style="color: #ff2600; font-family: Arial; font-size: 14px;"><em>S</em>ee <a style="text-decoration: none; color: #888888;" href="http://flyingsheeponsailfish.blogspot.ch/2013/05/deploying-files-to-sailfish-emulator_26.html">Part 2 of this post</a> for this technique as a script. </em></span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com32tag:blogger.com,1999:blog-1638189258536559624.post-33764690549748207552013-05-21T22:38:00.001+02:002013-11-06T17:12:24.411+01:00Adding Additional Qt Packages to Sailfish SDK and Emulator<p><em style="color: #ff2600; font-family: Arial; font-size: 14px;">Note: 06 Nov 20 13: This post refers to Qt4 packages, thought the techniques are still relevant for the Qt5 Alpha: Please also see the newer post:</em></p>
<p><em style="color: #ff2600; font-family: Arial; font-size: 14px;"><a href="http://flyingsheeponsailfish.blogspot.com/2013/11/deploying-additional-packages-to.html">http://flyingsheeponsailfish.blogspot.com/2013/11/deploying-additional-packages-to.html</a></em></p>
<p>Having posted the code of <span style="font-family: Helvetica; font-size: 12px;"><strong>AbstractUI </strong></span> to GitHub yesterday, I plan to post the code to <span style="font-family: Helvetica; font-size: 12px;"><strong>Landed</strong></span> and <span style="font-family: Helvetica; font-size: 12px;"><strong>LandedSettings</strong></span>: my two core apps that use <span style="font-family: Helvetica; font-size: 12px;"><strong>AbstractUI</strong></span>.</p>
<p>However before we do that we need to address one of the first problems that you may encounter when migrating from Harmattan to Sailfish.</p>
<p>Your app may start up on the Sailfish Emulator, but parts of it don't do anything:</p>
<p>The cause?</p>
<p>"Missing" Qt packages on the Sailfish Alpha: Some of the packages installed as standard on Harmattan and that your app relies on, are not installed as standard on the Sailfish Alpha.</p>
<p>Luckily in many cases we can fix that: We simply install the packages to Sailfish.</p>
<p>Many things come in two halves. One example is the new Jolla smart phone just announced: Another is installing packages to Sailfish. We need to install on both the SDK and the Emulator.</p>
<p>In the case of Landed and its sidekick LandedSettings I had to install the packages.</p>
<ul>
<li>qt-components-devel: this gives me access to the com.nokia.meego component Harmattan component set which I will use temporarily to get my apps runnable on Sailfish.</li>
<li>qt-mobility-devel: gives me access to the Qt Mobility API for things like Camera and GPS functionality.</li>
<li>sqlite-devel: for database access.</li>
</ul>
<p>Your first step has to be to ascertain which packages are missing, and what they are called. A little bit of googling may help here (or alternatively, searching using <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> on the Emulator).</p>
<h3><span style="color: #ff9300;">Installing to the SDK</span></h3>
<p>Then our next port-of-call is the Sailfish SDK Control Center. If you have not yet stumbled over this, it is accessed by the Sailfish Icon between the Projects and Analyze icons on the icon bar on the lefthand edge of QtCreator.</p>
<p>On the Targets tab, click the "Manage" button. This should give you a long list of packages to install or deinstall. The rest is easy: find your desired package and click install.</p>
<h3><span style="color: #ff9300;">Installing to the Emulator</span></h3>
<p>This is initially marginally less easy, as we have to do this on the command line via SSH. We will be using the package management tool <span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span>:</p>
<p><span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> is pretty cool, as it sorts out dependencies, and will install other packages that your target package depends on.</p>
<p><a href="http://en.opensuse.org/File:Zypper-cheat-sheet-1.pdf">http://en.opensuse.org/File:Zypper-cheat-sheet-1.pdf</a></p>
<p><a href="http://en.opensuse.org/File:Zypper-cheat-sheet-1.pdf">http://en.opensuse.org/File:Zypper-cheat-sheet-2.pdf</a></p>
<p>Connect to the Emulator as described <a href="http://flyingsheeponsailfish.blogspot.com/2013/05/connecting-to-sailfishos-sdk-and.html">in this post</a>.</p>
<p>As an example, to install the package sqlite-devel, including other packages this depends on:</p>
<p><span style="font-family: Courier; font-size: 12px;">[root@SailfishEmul ~]# zypper in sqlite-devel</span></p>
<p><span style="font-family: Courier; font-size: 12px;">Loading repository data...</span><br /><span style="font-family: Courier; font-size: 12px;">Reading installed packages...</span><br /><span style="font-family: Courier; font-size: 12px;">Resolving package dependencies...</span></p>
<p><span style="font-family: Courier; font-size: 12px;">The following NEW packages are going to be installed:</span><br /><span style="font-family: Courier; font-size: 12px;"> pkgconfig sqlite-devel</span></p>
<p><span style="font-family: Courier; font-size: 12px;">2 new packages to install.</span><br /><span style="font-family: Courier; font-size: 12px;">Overall download size: 322.5 KiB. After the operation, additional 936.9 KiB will be used.</span><br /><span style="font-family: Courier; font-size: 12px;">Continue? [y/n/?] (y): y</span><br /><span style="font-family: Courier; font-size: 12px;">Retrieving package pkgconfig-0.27.1-1.4.i486 (1/2), 220.3 KiB (574.5 KiB unpacked)</span><br /><span style="font-family: Courier; font-size: 12px;">Retrieving: pkgconfig-0.27.1-1.4.i486.rpm ........................................................[done (33.1 KiB/s)]</span><br /><span style="font-family: Courier; font-size: 12px;">Retrieving package sqlite-devel-3.7.15.2-1.3.i486 (2/2), 102.2 KiB (362.4 KiB unpacked)</span><br /><span style="font-family: Courier; font-size: 12px;">Retrieving: sqlite-devel-3.7.15.2-1.3.i486.rpm ....................................................[done (5.6 KiB/s)]</span><br /><span style="font-family: Courier; font-size: 12px;">Installing: pkgconfig-0.27.1-1.4 <span style="font-family: Courier; font-size: 12px;">.<span style="font-family: Courier; font-size: 12px;">.</span><span style="font-family: Courier; font-size: 12px;">.</span><span style="font-family: Courier; font-size: 12px;">.</span><span style="font-family: Courier; font-size: 12px;">.</span></span><span style="font-family: Courier; font-size: 12px;">.</span><span style="font-family: Courier; font-size: 12px;">.</span>.......................................................................[done]</span><br /><span style="font-family: Courier; font-size: 12px;">Installing: sqlite-devel-3.7.15.2-1.3 .........................................................................[done<span style="font-family: Courier; font-size: 12px;">]</span></span></p>
<p style="text-align: left;"><span style="font-family: Helvetica; font-size: 12px;"><strong>zypper</strong></span> also supports search, which is great if you don' t know the exact name of a package: You can find packages using the <span style="font-family: Helvetica; font-size: 12px;"><strong>se</strong></span> command. e.g. to find packages with "mobility" in the name:</p>
<p><span style="font-family: Courier; font-size: 12px;">[root@SailfishEmul ~]# zypper se 'mobility'</span><br /><span style="font-family: Courier; font-size: 12px;">Loading repository data...</span><br /><span style="font-family: Courier; font-size: 12px;">Reading installed packages...</span></p>
<p><span style="font-family: Courier; font-size: 12px;">S | Name | Summary | Type </span><br /><span style="font-family: Courier; font-size: 12px;">--+-------------------------------------------+-------------------------------------------------------------+-----------</span><br /><span style="font-family: Courier; font-size: 12px;"> | qt-mobility-debuginfo | Debug information for package qt-mobility | package </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt-mobility-debugsource | Debug sources for package qt-mobility | package </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt-mobility-devel | APIs for mobile device functionality - development files | package </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt-mobility-examples | Qt Mobility examples | package </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt-mobility-haptics-ffmemless | Plugin which provides haptic feedback via ffmemless ioctl | srcpackage</span><br /><span style="font-family: Courier; font-size: 12px;">i | qt-mobility-haptics-ffmemless | Plugin which provides haptic feedback via ffmemless ioctl | package </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt-mobility-haptics-ffmemless-debuginfo | Debug information for package qt-mobility-haptics-ffmemless | package </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt-mobility-haptics-ffmemless-debugsource | Debug sources for package qt-mobility-haptics-ffmemless | package </span><br /><span style="font-family: Courier; font-size: 12px;">i | qt-mobility-l10n | APIs for mobile device functionality - localization files | package </span><br /><span style="font-family: Courier; font-size: 12px;"> | qt5-qtdeclarative-import-mobility-sensors | QtQml mobility sensors import | package</span></p>
<p> </p>
<p style="text-align: left;"><span style="font-family: Didot;"><span><br /></span></span></p>FlyingSheephttp://www.blogger.com/profile/02914540176521592283noreply@blogger.com0