0 Comments

In my recent post I have shown, how to track web requests issued against remote server I don’t have a control over. Curious reader could ask at this point – but what have I broken this time? And the answer is as usual – personally did nothing wrong, I was just doing my job. I had to port some HTTP related code from using Windows Runtime-specific HttpClient (i.e. Windows.Web.Http.HttpClient) to also work outside the sandbox on a regular .NET 4.5 desktop version and start using System.Net.Http.HttpClient instead.

Then I noticed that everything worked fine except multipart form-data submissions using POST method that were behaving unexpectedly bad (timeouting or returning an error immediately). There was nothing unusual mentioned on MSDN, so I started to compare sent requests using both implementation. It turned-out of course, the problem lied deeper in the framework in a value serialized as a *boundary* part of the Content-Type field. HttpClient from the System.Net.Http somehow was adding extra quotes around it, while the one from Windows.Web.Http didn’t. Even though server should accept both values (according to RFC2046 section 5.1.1), it actually didn’t and was waiting for correct *boundary*.

Simple fix by manually overwriting the guilty header can look like that:

var request = new HttpRequestMessage(HttpMethod.Post, url);
var boundary = "--" + Guid.NewGuid().ToString("D");
request.Content = new MultipartFormDataContent(boundary);

// fill content
// ...

// update the Content-Type header to be accepted by the server:
request.Content.Headers.Remove("Content-Type");
request.Content.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary);

// send request:
var result = await _client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token);
result.EnsureSuccessStatusCode();

 

World saved. Job done!

0 Comments

With the recent announcement of Visual Studio 2015 RC you, as a developer, are now able to write applications targeting iOS, Android and of course all kinds of Windows platforms, web and cloud. I am also pretty solid, you will be happy to hear, you can make your applications run on BlackBerry devices (including PlayBook!) as well. I just recently updated integration of the BlackBerry Native Development plugin with latest version of Visual Studio, so you can stick to your favorite IDE and continue coding without lowering your productivity. Grab it directly from Visual Studio Gallery, to be always up-to-date, when new releases are published in the future.

Notice that this plugin supports wide range of Visual Studio versions, from 2010 till the most recent ones now.

 

The current state includes features like:

  1. dedicated "New Project" and "New Project Item"

    New Project wizard preview

    New Project Item wizard preview

  2. automatic MSBuild update (without any manual plumbing) on new version releases

    MSBuild notification

  3. GDB integration

    GDB preview

  4. IntelliSense support

    Runtime IntelliSense preview

  5. Qt 4.8.3 for PlayBook support via dedicated set of NuGet packages
  6. QML basic colorizing support

    Runtime QML colorizing preview

  7. device browsing support

    Device browser preview

  8. dedicated settings to tune all aspects of project build and deployment

    Project settings preview

    Global settings preview

  9. support for C++0x and C++11 features (limited to OpenGL applications)
  10. and much more!
    This package provides Native SDK, Qt and Cascades support inside Visual Studio for PlayBook and BlackBerry 10 devices. It encapsulates whole development cycle - from developer registration, via coding, deployment, debugging, until the final release to AppWorld marketplace.

 

There are for sure some bugs or things you could wish to be improved. So don’t hesitate and let me know about it. You can always contact me directly, twitter @CodeTitans or submit a feature request on project’s website. Please only take into account, this project is **not** sponsored by any company (BlackBerry nor Microsoft in particular) and I do it only in my spare time, when not working for food!

0 Comments

Although the PlayBook tablet was totally abandoned by BlackBerry long time ago and there are other problems around the company I still wish them well. That’s why I continuously support the BlackBerry Native Development plugin for Visual Studio. Recent additions were about Visual Studio 2015 RC and most notably PlayBook and Qt-4.8.3 support. I hope it will inspire you and myself to write some applications on it.

Thankfully lack of support from BlackBerry is the best thing they could do to PlayBook. It’s OS software is not bloated with useless features and even if you count it to be 4-years-old tablet with only 1GHz clock and 1GB of RAM applications run fast and fluid. Most notably it’s now so damn cheap to buy, if you plan to do some IoT, that it compares with Raspberry Pi 2 and has SD and screen already attached.

The problem however is lack of a common UI framework that could work out-of-the-box. Until now. BlackBerry tried to support few approaches to enable developers. One was Adobe Air, but somehow I am not so keen to port anything to ActionScript. Another one was Android Runtime to let do some Java programming. This was better, but the best option to me appeared their involvement in Qt framework (and more here). This allows going down to the bare C/C++ coding for maximum efficiency etc. Officially the last version dedicated to PlayBook was Qt-4.8.3. Unfortunately it was never published and never integrated with any IDE. They probably moved all forces to support upcoming BB10 platform at that time.

If you look closely on PlayBook NDK 2.1 you will find some Qt libraries in it, but they don’t tend to work (maybe because the lack of platform-specific libblackberry.so included?). There is even officially published guide, how to build it from sources on Linux machine. I however learnt more from improved versions created by community around how to integrate it with Momentics (more here) and build and tried it several times on my own. As a result I even prepared my own guide, how to build it on Windows. But please, being serious, who wants to do that before writing application? Answer is obvious – no one. There should be no barrier like that and if you count them all, you will know, why BlackBerry failed in the Mobile World War. I always say – small things to matter.

TL;DR

What I really did? I enabled basic Qt types of project via BlackBerry Native Development plugin inside Visual Studio. There are 2 simple steps (assuming you have the plugin configured and NDK 2.1 installed), but I will work on improving it and making down to 1:

1. Create new project in Visual Studio 2013: File –> New –> Project… –> BlackBerry Projects –> Qt –> PlayBook Qt4 Core Application

QtProject

2. make sure following NuGet packages are installed:

* codetitans-playbook-qt4-core – that injects base libraries into the project (and bar-descriptor.xml) and setups headers for successful compilation

* codetitans-playbook-qt4-qml – it will enable QML development inside the application (QtQuick) and actually let you compile samples from Qt website.

Are there any issues?

Sure they are:

  • First and the biggest is that all .moc files have to be created manually (tools for Windows available here). I am working on another NuGet package that will fix it, but it’s not finished yet.
  • Compilation might generate lots of warnings like: “warning : the mangling of 'va_list' has changed in GCC 4.4”. This can be disabled by adding this switch “-Wno-psabi” for the compiler (Project properties –> C/C++ –> Command Line –> Additional Options).
  • The final .bar file deployed for device can be quite big (~20MB at startup) as all required Qt libraries need to be included.
    There is a workaround to put them once to the user’s home folder, when doing development and skip placing them in a .bar file for that time, but haven’t verified it yet.

Post scriptum

This whole project started mostly as a result of my IoT midnight plays and lack of real file manager for PlayBook. Thankfully I found very old project from Kevin Boone named kfile. He also created an introduction, how to make Qt apps on PlayBook and was so kind to share sources. I test the NuGet packages and Visual Studio plugin against this code and plan to publish it in AppWorld shortly.

0 Comments

I wish to say many thanks to Lou Gazzola and Dave Burgess for their help in making the Visual Studio plugin for BlackBerry named Gold 3.0 to be completed and released publicly. There was a dedicated interview with me, published on BlackBerry Dev Blog, which can be found here, which makes me proud a lot. Also I am really grateful for granting me the latest BlackBerry Passport mobile and inspire for further plugin and own apps development.

Hope to see you guys in the future with upcoming new features!

passport

Best!