Sunday, 16 February 2014

New Sailfish Demos Posted to Github

Hi All

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.

That notwithstanding, I have created a number of mini-demos to illustrate interesting things I came across while porting to Sailfish.

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.


Sunday, 5 January 2014

Connecting to a Jolla via SSH over USB from OSX

Out of the box it is not possible to connect to your new Jolla via SSH over USB from OSX.

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.

But with a bit of tweaking it is possible to get an SSH over USB connection going.


Connecting to a Jolla with a RSA Key File for password-less SSH Access

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.

Surprise surprise, exactly the same is possible with a real Jolla device. No more typing in long passwords!

Black Courier shows commands typed on your development host.

Blue Courier shows commands typed on your Jolla (via SSH).

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.


Sunday, 22 December 2013

Deploying Additional Packages to the Sailfish Emulator and SDK updated

As new versions of the Sailfish SDK are released, so installing stuff changes a little.

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.

http://flyingsheeponsailfish.blogspot.ch/2013/11/deploying-additional-packages-to.html

As I used QtLocation and QtPositioning in the examples, I am also posting a link to this tutorial

https://github.com/b0bben/SailfishOS_MapTutorial

This tutorial gives more in-depth advice on the use of QtLocation and QtPositioning, in addition to how to install.

Saturday, 2 November 2013

Deploying Additional Packages to the Sailfish Emulator and SDK

Latest update is 24 Dec 2013 11:40 UK time.

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.

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.

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

We will look at zypper, PkCon, ScratchBox2, yaml and spectacle. We will find out how to install "by hand*, and automatically on building and running.


Friday, 25 October 2013

Alpha 2: After the update of 22 Oct 2013

Hi All

As announced by Jarko here there is a refresh of the Sailfish Alpha available now.

This post lists some immediate differences I have noticed, and some changes I had to make to get "things" working again.

As / If I discover other stuff, I will update this post


Saturday, 12 October 2013

Alpha 2: Migrating Landed

Note this article is work-in-profess, reflecting work that is work-in-progress, and will be updated / corrected as the migration moves forwards . . .

Last update is: 06 Nove 2013

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 Landed to the Sailfish Alpha 2.

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?). Landed is now fully functional, and thus another stab at porting to the Sailfish Alpha 2 makes sense.

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 Landed 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.

The demo is called MigratePhoneContactsDemo. I will soon post the Harmattan code, and the ported Sailfish equivalent code to Github, and add links here.

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.


Thursday, 26 September 2013

A Status Update

The eagle-eyed will have noticed that I have not updated this blog for several weeks. For this I apologise.

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.

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.


Tuesday, 6 August 2013

Alpha 2: Passing simple C++ properties from main.cpp to the QML Side with Qt5

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 a setContextProperty call.

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).

In Qt4 I was able to pass such properties via a call to setContextProperty, offered by a bit of Nokia code called the QmlApplicationViewer. 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.


Monday, 5 August 2013

Alpha 2: Installing an Import Library on the Emulator

In a previous post I covered the code migration of my import library AbstractUI from Qt4 to Qt5.

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.


Alpha 2: Migrating LocalStorage from Qt4 to Qt5

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.

 

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.


The Full code of  QT5TestLS can be found on GitHub.

 

 

Below is a summary of the things I had to change:

 


Saturday, 3 August 2013

Alpha 2: Migrating an Import Library

Note: As my experience and understanding of migrating to Qt5 / Sailfish Alpha 2 increases, I will update this post if required.

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.

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.

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.

The irony of a tool that was intended to ease porting needing porting itself does not escape me.

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.

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.

Having tested that the throwaway was importable and installable (more on this in a follow-up post) it was time to start porting abstractui.

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.

 


Update after the Sailfish Qt5 Alpha

Hi all

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.

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!

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:

1) I have marked most posts indicating that they will be revised for the new Alpha soon.

2) Started updating posts for Qt5.

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.

4) Where I encounter major differences (headaches) I will post new articles highlighting these!

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.

Friday, 2 August 2013

Sailfish Qt5 Alpha Available!

Hi All

As of last night the SailfishOs Qt5 Alpha is now available for download.

The biggest and most obvious change is that the "old" alpha used Qt 4.8.3, the "new" alpha uses Qt 5.

Equally interesting, X11 has been replaced by Wayland.

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….)

Sailfish have added a webpage on porting from Harmattan. It can be found here.

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.

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.

My next step is to try running Landed and LandedSettings.. I hope to bring news over the next few days of how this works.

 

 

 

 

 

Thursday, 27 June 2013

QML: Faking an SQLResultSet Object with JavaScript

A few days ago while hunting down an elusive bug in the way the Silica ContextMenu 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.

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.

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. 

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.

In effect, could I replace the whole database access code with a simple javascript method returning a javascript object?

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 …)


Sunday, 23 June 2013

Playing around with the guts of Sailfish Silica Components

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.

Recently I decided to change the way my LandedSettings app allows the user to create, edit and delete entries in the settings database.

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.

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.

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.

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.


Thursday, 20 June 2013

Connecting to the Harmattan QEMU: Learning from Sailfish!

A few days ago I wanted to compare some differences in behavior between the Sailfish Emulator, and the old Harmattan Equivalent QEMU.

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.

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.

A quick google found this link:

http://harmattan-dev.nokia.com/docs/library/html/guide/html/Developer_Library_Alternative_development_environments_Platform_SDK_user_guide_Using_QEMU_in_Scratchbox.html

 

So we can connect like this:

 

ssh -p6666 root@localhost

 

no password required!


Thursday, 13 June 2013

Menu Abstraction with AbstractUI Part 2

Hi all

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 ...

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.

From a user's point of view (and we should never forget our users) the differences in Menu Handling are these:

1) Launching

A Harmattan menu is launched from the Toolbar which sits at the bottom of the screen occupying valuable screen real-estate.

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!

2) Behaviour on Opening

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.

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

So how do these affect us as programmers? Read on:

 


Connecting to a Nokia N9 with a RSA Key File: Learning from Sailfish!

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.

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.

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.

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?

After a little bit of googling and experimentation, the answer is a resounding yes; and it proves to be very easy.

I found the basic idea here: http://talk.maemo.org/showthread.php?t=41547. So thanks to Greygoo the author. My post takes a slightly simpler approach, and is specific to the N9.


Sunday, 9 June 2013

Where is my SQLite DB on the Sailfish Emulator ?

Note: This post will be updated for the Qt5 Alpha shortly!

By default, SQLite Database files are stored here on the Emulator:

/home/nemo/.local/share/data/QML/OfflineStorage/Databases/