Saturday, 8 December 2012

Simple Setup SDL on Blackberry OS 10 on a Mac



Yes, I'm started to play with BlackBerry OS 10.
Trust me, when I said BBOS10 is an incredible os, with a lot of potential and the main developer tools are also great: I have only positive words for Webworks and Cascades. If you are a developer you should check the developer.blackberry.com website.

Games, Games, Games!
This is a little guide on how to setup SDL to develop with BBOS10 and a Mac.
This guide is intended for a real bb10 device... but you can simply change some step and make the whole works with the simulator.
Let's go with the steps:
  1. Download BBOS10 Native Development Kit and install it (and the simulator if you don't have a device)
  2. Download the sample/template SDL project that you can find attached, in a answer, on this link http://supportforums.blackberry.com/t5/Native-Development/Problems-getting-SDL-to-work/td-p/1569839 : this  .zip file contains also the 2 library SDL and TouchOverlay (a library for integrate touch on SDL 4 Blackberry). Extract the sample somewhere on your disk.
  3. Go on  www.github.com/blackberry/sdl and git clone the project.
  4. Launch the BlackBerry Native SDK (point 1), than go on File->Import->Existing project into workspace and in the new window select the root directory of the uncompressed sample at point 2. Press Finish.
  5. Now you have to correct some broken link in the project. Right click on the SDLHelloWorld project and press Properties. 
  6. In the new window you have to check and correct the following parameters:
check the includes path.. remove the eventually QNX_Target symbol and put an absolute path

add the "m" library to the list

Correct also the library path

Build and Run the project and you should see something like this:


If you would like an updated compiled version of SDL and TouchOverlay check this post: http://www.joshuagranick.com/blog/2012/07/05/nme-adding-the-blackberry-cpp-native-target-in-48-hours/ (very useful) and expecially this link.
Happy coding!

Wednesday, 24 October 2012

How much can you trust your Android Phone?


Introduction
Android sales has been huge, in the last years.
Surely, one of the key success factors of this platform is the possibility to have a smartphone with thousand of apps available with a starting price of 99$.

A big problem
Its huge user base, makes android a fertile ground in which computer thieves, put their efforts to gain access to:
  • user accounts
  • private data
  • credit card numbers
Let's take the webkit engine: it is used from the browser and from some apps for rendering of webpages.
it is one of the most attacked module on the platform, maybe, because it is easier to find a known bug and obtain access to personal data.
If you have a problem on that components, a lot of apps become a security problem, unless you can update the smartphone.


A platform with no bugs doesn't exist and never exist but, anyone who makes you pay for a phone should guarantee  to have a system repairable and upgradable.


Google can guarantee this, but not Android .. why?

Generally, for my experience the only phones that receive system update, are Nexus phones, made by manufactures for Google.

If you have an Android phone .. you should have Jelly Bean now, lastest version of Android.
That's how it should work...
Is there a system update? and your phone must receive it as soon as possible.

Other phone manufacturers, does not update their software.
After you have bought their phone, they ignore you, they leave you with an insecure system that   compromised with a simple link received from a social network, or scanning a qrcode(link) or by NFC(link).

Most of the problems found on a module like webkit are commons to IOS, because also iphones uses Webkit, but on the Iphone the in-security is limited to people who doesn't want to make a system update.

The problem on IOS are solved in some days. 

The solutions
Here they are some solutions:
  • buy a new phone every year to have new software update.....
  • buy a nexus phone (new will be available soon)
  • use a custom rom: you can flash your phone with a rom made by someone like cyanogenmod  (how can I trust them? I don't know.. but it is opensource and better than a stock buggy rom)
  • don't buy an android phone
Keep your apps updated and pay attention to what you install too
This is an article about a security problem on Google Drive and DropBox of some days ago: http://blog.watchfire.com/wfblog/2012/10/old-habits-die-hard.html
If Google and Dropbox have security problems, you can immagine how many other apps can have security problem... so  think before "yes install / accept accept accept/ don't care / yes do what you want with my phone".
And this is another recent article about how apps are generally insecure when handle HTTPS connection (for example when you want to watch your bank account from your phone in a public wifi).

If you have not seen this yet.. watch this android bug and... think that the only android platform not affected.. is jelly bean.

Wednesday, 12 September 2012

If you are better than facebook engineer..than go ahead with HTML5

Yesterday, M. Zuckerberg talked about HTML5 as a mistake for the facebook iphone and android app.

Exactly:
When I’m introspective about the last few years I think the biggest mistake that we made, as a company, is betting too much on HTML5 as opposed to native… because it just wasn’t there. And it’s not that HTML5 is bad. I’m actually, on long-term, really excited about it. One of the things that’s interesting is we actually have more people on a daily basis using mobile Web Facebook than we have using our iOS or Android apps combined. So mobile Web is a big thing for us.
Quote from http://blog.tobie.me/post/31366970040/when-im-introspective-about-the-last-few-years-i

(maybe people use Web Facebook instead of native version because the previous version was buggy. Changes are hard to made)


I totally agree about HTML5... but I also think that for any app out there, use HTML5 as a one solution for all the mobile platform out there, and as the main platform to build app is a mistake.
I don't have a good opinion of HTML5 on mobile, for many reason:
  • it is a growing and evolving tecnology with a not defined standard: there are 2 standards now..
  • you lose the link to the hardware and also control, if you need it.
  • I don't believe personally to solution/framework that can works everywhere.. You need compromise; compromise means poor integration & bad performance and so a bad user experience.
  • Not all the mobile browsers are the same: on android platform, you can find different browser installed, with different rendering engine. Yes you can choose to support only some browser.. but don't you choose HTML5 because it can runs everywhere?
  • Javascript performance may differ a lot from a platform to another: means slow speed on some device.
  • The time spent improving App/OS integration..cost.
  • No store exist yet... and if it exists.. needs a lot of app that are not native (if not why a user should point to the html5 store?)
  • it is early: maybe in the future will be the best choice. We don't really know if it will be the best and when.. we know is not now.
It also have good points:
  • HTML is a good solution for content rendering: if you need to show rich text, with images as an example.
  • Easy to prototype an app.
and I also don't think to be better than all those nerds engineer at facebook.. so...

Platforms matter
As a personal experience IOS and Android have done a lot in terms of HTML5 integration..and they are continuing to do it but it is not enough, at least for now...for an example in these platform you can't access:
- camera and than shoot photos (for example no QrCode sorry)
- PIM
- Media
- .. many others things
I don't have any experience on Windows Phone platform.. so I can't say more about that.

Damn, I want to make an HTML5 app
You have some choices:
  • if you don't need hardware integration, your app display contents grabbed from a web service.. you can accept UI compromise..performance...and you will package your app inside a WebKit window of a native app.. ok go ahead with your HTML5 app
  • choose a platform with HTML5 capabilities: Firefox Mobile OS and BlackBerry OS 10.
I have saw enough things of Firefox Mobile OS to say it is not ready, not interesting and it is in a evolving state.. and more important.. may have a 0% market impact when you will see a firefox phone.
It's simple early for Firefox Mobile OS. Someone said Tizen? Same story there.

BlackBerry is pushing a lot their new platform BBOS10, but first of all, they are believing in you, as a developer: pushing a lot of support on forums and social network.

They can't make mistakes (who really can?) for the new platform release (2013) and they have a real HTML5 support on BBOS10! Read More here
There is a growing community.. so if you choose to develop for HTML5, it is time to choose BBOS10.

Tuesday, 11 September 2012

Playing with OAuth 2.0: how does it works?

Recently I have started to play with a new mobile platform.
Tipically the things that I do when I have a new platform to learn are:
- read general documentation of the platform
- try to realize an application from scratch with the new platform

Just because the project that I have in mind use OAuth I had the necessity to understand how it works.
Many portal and website  nowadays use this protocol for users authentication.

The idea is based on soundcloud and its api…
If you search on the site you will find a lot of documentation, also library, for  the most famous mobile platform (android and ios) but not a general way on how OAuth should works and how you, as developer, should handle it.
Results from a search on the web show me detailed complicated explanation or specific platform dependent explanations ( for the specific api or platform)

Talk auth2.0
With auth2.0 applications the security of your accounts improves.
A client with OAuth never ask for your username and password, instead, it ask authorization from the server where your account is.
The server (typically a famous service like Facebook,twitter, gmail…) than ask you to login(if you are not already logged) and ask if you would like to authorize the application.
If the user authorize the application the server send back to the application a token, something like a string of numbers and letters.
The application than will store the token locally and use that token for next api request to the service.
Someone can hack the application and get the saved token (it can expire and be invalidated also by the users) but it doesn't have access to your account… so your account still remain safe!

An image is better than thousands words...


simple uhm?
you connect to the credential page asking to the user to login (if it is not already logged) and than authorize the application.
the server than send back a message with a code.
with that code you can ask for a token...and with the token you can finally make api requests.

In the next post, I will show a specific implementation…based on soundcloud api!

Tuesday, 4 September 2012

Tethering indicator... on github!

Ok!
First Alpha of Tethering Indicator is out!

 The client application on mac... as you can see the connection of the phone was 2G :/


It is not perfect.. and a little buggy.. but it works... need improvements and the main ingredient of all good application... TIME!

So for now I will stop to develop it , but I have commited the code on github .. so anyone that wants to try it ... can test it, improve it and change it :)
I'm not so good with osx development (I'm a bit new) so I hope that someone will change and fix the code... so I can learn something too :)

I'm not leaving the project, I've just want to develop something different for the next month
I will publish update everytime I can!
GITHUB TETHERING INDICATOR

Other post about tetheringindicator here

Tuesday, 21 August 2012

Tethering Indicator: start simple grow complex

I'm back from holidays... but during it, I did something on my tethering indicator project.
It was thinked as a simple application.. and now it is no-more a pure simple activity that talks with bluetooth..but something more complex.

The apps on the phone, is composed by 2 part:
- a service that make available data through bluetooth and show a notification whenever it is started.
- an activity that talks to the previous service for control and send command like: start/stop service.
It was not easy to understand how to make the activity bind and unbind correctly from the service, also when the activity die,  but after some test and research I did it.

This is a simplified diagram of the actual architecture :
I didn't released the code now, but I will do very soon, at least for the android server, when it will be enough good.
For now the program on the phone works.

Thursday, 2 August 2012

A Bluetooth Server on Android: part 2, the code

From the previous post
Summary for a bluetooth server:
- Turn the bluetooth chip on
- Be visible to others
- Create a Service
- Listen for incoming connection

The methoed for realize the previous steps are in these methoeds extracted by the code of TetheringIndicator.

Wednesday, 1 August 2012

A Bluetooth Server on Android: part 1

This is the first of 2 posts on "How to make your Android Phone, listen for remote request with bluetooth".
Bluetooth is a mature tecnology used everywhere.
For my experience, it is not an easy tecnology to manage, if you want to simply share something you have to follow many steps.
If you are a developer and you want to simply create a connection and pass data between 2 devices (whatever the devices are), you have to create a lot of code and first of all, learn how this tecnology works.
As a reference platform in this post I will use Android; things can change from a platform to another but the key concept are the same.

Who are you? Be visible!


Bluetooth have differents modes:
  • visible: any other device around that start a bluetooth search, Inquiry, will find the device.
  • not visible: you can see other device around you, but none can see you in a search and establish a connection.
  • off: the chip is off.

So the first things you have to do, in a bluetooth server are:
  1. get a reference to your internal bluetooth chip
  2. set the chip on
  3. set chip in visible mode
The 2nd and 3rd step require the permission of the user.
On Android, whenever you try to make your bluetooth phone on or visible, a system dialog message, automatically advise the user of the action.

The 3rd step is available only for a limited amout of time (you can specify how many seconds)... I think this is just for security and autonomy reason.

What do you offer? A service
Be visible is not enough to establish a connection with another device.
You have to specify the services that you are offering.


A service is a way to declare what you are capable to offer in term of data, for another device.
It is what you expose to others.
Every phone have some default service created for sharing content like calendar, phonebook etc...
A service is identified by a name and a UUID: http://en.wikipedia.org/wiki/Universally_unique_identifier.

How do we talk? With a profile
A profile is a low level bluetooth protocol that explain which type of message and communication you are trying to establish.
Bluetooth is used in different way so you have different profile specific for a task: there is A2DP for bluetooth audio communication (used by bluetooth earphone), Obex for file transfers, L2Cap for exchange information, RfComm is a sort of serial communication over bluetooth and others profiles.
When you have to make 2 device talk eachother with your own protocol, the options are usually use L2Cap or RfComm and built your protocol on top of them.
I have decided to use RfComm.

Summary for a bluetooth server:
- Turn the bluetooth chip on
- Be visible to others
- Create a Service
- Listen for incoming connection

Next:
The android code will be explained and available in the next post on the blog.

Monday, 30 July 2012

A new project: a Tethering Indicator

Scenario
I usually take a train in the weekend and travel for 150 km with my Macbook or Tablet connected to my Android phone in tethering mode by bluetooth or wifi.
While I travel by the train, my phone is usually inside my bag and I only have in front of me the Macbook...  I check only sometimes the phone but it is mainly inside my bag.
During my travel the phone connection change a lot and pass in one of this state: no connection, only phone network, 2G or 3G.
What I'm searching to create is an app on the phone that talk with my macbook and regularly send information of the network state of the phone.


How should it work?
These are the step that I have in mind:
  • I launch the apps on the phone and start the bluetooth server
  • I launch the application on the mac
  • I establish from the mac the connection with the phone
  • On the Mac menubar, an Icon display the state of the phone's connection.
This is the basic idea.. but I have some new improvements in mind.




What have I done till now?
The first version of the mac client is in "under construction" state..  The application is capable to connect to the phone but I don't know, for now, how to put and change an icon on the menu bar for the various phone connection state... Need to go deep about it.

Android side is in progres: it is capable to create a bluetooth server and send informations to the connected client back...
Something on the android client will be visible tomorrow soon.

Other platform?
Of Course!
stay tuned.


Thursday, 19 July 2012

Make Osx talks with a Bluetooth GPS

This GPS:
Everything started one week ago when I had a new project in mind.
In this project (I will talk about it in a future post) I have to make my android phone talk with my macbook through bluetooth.
What I need to do:

- expose an RfComm Service on Android device
- search the device from the mac (inquiry)
- establish a connection between the phone and my mac through bluetooth
- pass data between phone and mac

Use a gps bluetooth is enough for a simulation of these operations.


The problems
Documentation.
Yes, this is the first problem.
The second one is .. I've never developed something for OsX but I have did something with IOS (it helps).
Since the arrive of Bluetooth 4.0 LE, Apple make some changes to the bluetooth library.
For what I've seen from the Apple documentation, they did a lot of improvements to make the new library easy to use.
Only new apple product support BT4.0LE... if you have to talk with previous BT device.. you need to use old library.
My Mac and my btgps are old.. so no BT4.
I didn't find any documentation on how to use the old library.. so you have to surf the web searching for the answers.
 

The code
The code is here(the important stuff, you need to customize it) is on gist.github.com and this is how it works:
  • after application is started it search bt devices and get the names of all the visible bluetooth device (this is called inquiry). In this step I search for the BT Device with the name "HBTGPS" and I save the reference locally. 
  • the second step is searching for the available services on the device.  (it is called SDP: service discovery protocol). Every Bluetooth device can have one ore more services to expose.
  • the third step is: check if RfComm service is present on the device and get the channel on which RfComm is available. A service is bound to a channel.
  • Last step, with the channel and the reference of the bluetooth device I can open the connection and start getting data from the device. Here there are some protocol methoeds call after every change.
This is the output of the program:
2012-07-19 01:19:05.427 FMOSXAPP[406:903] ok, go on
2012-07-19 01:19:05.452 FMOSXAPP[406:903] Let's start inquiry devices around me
2012-07-19 01:19:05.621 FMOSXAPP[406:903] found this device 00-0a-1a-17-88-d6
2012-07-19 01:19:18.335 FMOSXAPP[406:903] updating names for: 1
2012-07-19 01:19:18.435 FMOSXAPP[406:903] That's my boy! HBTGPS
2012-07-19 01:19:18.437 FMOSXAPP[406:903] I gottcha!
2012-07-19 01:19:18.443 FMOSXAPP[406:903] Service: SPP slave
2012-07-19 01:19:18.444 FMOSXAPP[406:903] ChannelID FOUND 1 1
2012-07-19 01:19:18.444 FMOSXAPP[406:903] Found rfcomm channel on device.. 1
2012-07-19 01:19:20.332 FMOSXAPP[406:903] channel complete
2012-07-19 01:19:20.469 FMOSXAPP[406:903] received: ,000,*71
$GPGSV,2,2,08,04,00,000,,04,00,000,,31,00,000,,07,00,000,*71
$GPRMC,000027.0,V,1438.70599,N,01215.00413,E,,,010100,,,N*70
$GPGGA,000038.0,4128.70599,N,01215.00423,E,0,00,,-00027,M,,,,*1F
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,2,1,01,09,00,000,,25,00,000,,08,00,000,,27,00,000,*71
$GPGSV,2,2,03,06,00,000,,03,
2012-07-19 01:19:20.476



(I've changed a little bit the data from the gps.. just for privacy :P)

Tuesday, 17 July 2012

My Favourites Application's list from UbuntuAppShowdown

At this link, you can find all the application that passed the qualification for Ubuntu App Showdown contest.
I was so curious about this list so I have watched the applications listed.. and this is the list of the applications that IMHO needs attention:
  • Cookety: an application for recipies. I really like the design. Easy, clear, simple. I would like to see it connected with a cloud for hosting,share,save recepies between users.
  • Fogger: pay attention to this app. It hides a website logic inside a unity integrated application.  I like it for many aspects: but the idea to transform unity as a "platform" for website.. is really interesting and new.
  • GWOffice: a desktop client for google drive. It seems a good quality app and I think it is really hard to create something like this... so +1 for this.
  • NitroShare: Cool project. Do you want to share a file with another computer on the LAN? Just drag&drop the file on an Icon on the desktop and it is shared.
  • PostMan: help you to manage photos to send on cloud services like ubuntuone or flickr... So cool UI. Easy to send an image on the cloud, just as sending a letter :)
 
PostMan

And this is a list of applications that I found nice(as realization or idea) but for me not able to win:
  • StackLens a unity lens for stack overflow: stack overflow integrated in unity .. good for developers!
  • PicTag: help people to geotag photos. I would like to see it integrated in an application like shotwell instead of a separeted application.
  • XKCD browser: nice to have.. to launch sometimes during an hard working day.
  • Snare: A minimalistic drum machine. I like the style of this application.. clean! Nice UI for this kind of application
  • SmartShine Photo: I don't know how good it is.. but I like the idea. It corrects photos, based on an algorithm.
  • Nulloy Music Player: yes it is just a music player.. but that's why I like it.. Modern players are full of unuseful feature. Just put an mp3 on the player's list and press play. Good.
  • Interest Calculation: It can be useful for people who manage this kind of calculation everyday.
  • Houston ( I hope is not.. "we got a problem" :D ) An UI for manage servers on the cloud. Good Idea, need a lot of work on it.. But it is a nice start.
  • Facebook App: Do we need a facebook app? I don't know.. but it seems (from sshots) a good designed application.
  • Format Junkie: a frontend for easy convert file formats. Good, Ubuntu needs something like this. I'm not enthusiast of the UI but it is just my opinion :)
  • Lightread: an rss client. Good UI designed. If you use a lot RSS, you probably like it. I thinks it needs ubuntu one sincronization.
My judge is based on the description from Software Center of every application, I didn't try these application yet.. and I judged it basing on my first impact watching the description, screenshot and videos(when present).
It is all IMHO :)

Tuesday, 10 July 2012

Mobile OS: need apps...milions of apps!

Everyone wanna do Mobile OS..Blackberry, Microsoft and many others...are trying to get some space in this giant enviroment... because it is the new revolution and maybe mobile (tablet and smartphones) will replace desktop platform in the future.

For many people, a smartphones or a tablet is enough.
People are starting to prefer to use their phone to access internet: because their phone are faster enough and they have dedicated apps.. designed to be easy.
They provide a better user experience.
People can use their phones, without asking to their geeky friends for any trouble, they reach their scope because phones are easy also to reset.
Desktop PC are powerful but noisy, slow, exposed (virus and many problem) = stress & pain for a simple man.
Smartphones is always with you and it can help you in everyday activities, PC only when available.

The main usage of a desktop pc today is open a browser and go to internet..smartphones are enough for many websites and they can accomplish very well this task...and when they are lucky enough there is always an app for a specific task.
We are part of a revolution that will change how we will get information from the net.

The giants
Mobile world is becoming simple everyday.. IOS and Android are the largest platform out there... with so many downloadable apps.
Microsoft is desperately trying to get in.
Desktop platforms are converging to hybrid solution:
  • Apple: new release of OSX contains part of IOS and I thinks one day we will see a unique platform with the best approach of both (with an Apple processor on it). They are driving people slowly to these changes and they are careful. This is the approach that I prefer.
  • Google: they haven't got a real operating system for desktop.. they have chrome os.. but it is a sort of an experiment..Android for desktop is not an acceptable solution. I thinks docking stations for connecting monitor to a smartphones are great things but.. how many do you see out there? Google is just waiting... They have the power to start something from scratch tomorrow and fight with others in any moment.. (see google voice vs siri). They wait and see.
  • Microsoft: Windows 8 is one of the biggest challenge of MSFT. It's a strict parent of windowsphone. If they are right, they can really change mobile enviroment again. What I think? I thinks Metro is a good UI, at least different from IOS, but it is a mobile UI and not good for a Desktop experience (many wasted space and poor aesthetics...).  I don't really like on a tablet, and I really hate on a desktop.. I thinks we will see windows 7 for a long long time.. It is too soon.. but they have enough money for try..I thinks windows 8 is just there to prepare people to windows 9 learning the mistakes from win8, like MSFT did with xbox 1 for xbox 360 (I hope also Nokia will have the power to follow this..change.. or they will die.).
And the others
  • Symbian: adieu.
  • Blackberry: a fact, they can't make mistakes or they are out. For me the biggest mistakes of blackberry was to open to teenager market and forget business people. BB should focus on business services and business tasks and make something new. A BB phone today is a toy like any other smartphones out there. BB years ago was a tool for work, that is why business man liked it.
  • Opensource world: maemo... meego... Tizen... now some  new Firefox OS. It is just crazy to make a new OS and thinks HTML5 will save the world. I don't believe in these revolutions why? read on.
All you need is apps (papaparapa)
Unless IOS and Android.. what platforms need are apps!
Microsoft is trying to become an interesting ($$$) platform for developers.. but the numbers of IOS and Android are pretty different from windows phone.
MSFT is doing the right thing.. pushing people to write apps for them... but it is not an easy task.
I thinks a mobile developer focus more attention for IOS and Android platform now, than he looks the others  platform.

HTML5 apps will not save anyone... because as a developer you have to pay in performance and platform integration (and testing), and HTML5 is just a new technology. So the gain is not enough.
Anyone needs apps and developer who write apps.. so I don't really now how Tizen, Firefox OS and co... can fight with the market numbers of IOS, Android and Windowsphone.
And apart from the hardware of a phone, people don't care about the os, people care about apps!
We wait and see...

Monday, 9 July 2012

Last improvements

I did some improvements in the last 3 days :)
This is how the application UI is now:


I removed the 3 buttons on the bottom and I added a toolbar with the 3 buttons: add, remove, reload.
I've also introduced some unity integration in the app:
  • progress/loading in the launcher
  • quicklists for reload action

Unity integration is easy to do.. but, you have to deal with some problem with .desktop files like this one.
I had also this problem with quickly.
All of these problems are defeatable... but they make headaches.
You've just to ask to the community: there is always someone who can help you if you ask the right question.

I'm very tired after these 3 weeks of programming after-work and I thinks that if there is no problem with submitting, my application is ready as is.
UbuntuAppShowdown is a really nice experience.
My application is not perfect, buy I'm a bit proud of the result... it's not easy to work on this kind of application everyday, scheduling the work to do.
And I've also learned a lot of new things!
Need to sleep now, if you found a bug on protoborsa, please write me!

Thursday, 5 July 2012

The community is the key


Linux and all the software around it, it is one of the most challenging and complex enviroment out there.


You know, what is it really hard? Keep all the things working and coordinated.. because you have to deal with many and many problem that proprietary software don't have.
 
It is an enviroment, not ready for all, at least for now, because it needs time... but a route is traced and the key of this enviroment, it is the community around it.

You have feedbacks; there is always someone that watch your work, someone that gives you ideas, for improve your application, and I f*cking love this.


Yesterday, I said that I had finally put the ppa on launchpad... but it was not working correctly.. today I have finally upload a working version.
You can find a version here.

Meanwhile someone (Daniel Holbach) watched the code of my application submission on ubuntu software center, and he found a bug on my licence.. many thanks.


This is such a kind of collaborative env, very hard to find elsewhere.


Protoborsa, new update!

Some minutes ago I uploaded a new version whit these changes:

  * fixed Licence file.:
  * improved company search on add stock.
  * fixed first loading of settings.
  * little changed on thread code for future improvements.

but this version, got a bug (damn!)...the first run fail to copy of a settings file to your homedir/.protoborsa/ directory..
You can manually create this directory and copy the /opt/extras.ubuntu.com/protoborsa/share/protoborsa/db/stocksymbols.db inside it.. or wait for the new version (protoborsa_12.07.5ubuntu5)... that is on the way, and will be downloadable soon.

I would like to improve my application for:
  • better handling of loading chart with thread support and animation while loading
  • toolbar instead of the bottom buttons: this is just for a better UI integration with Unity.
  • try to add unity quicklists
  • add progress while downloading data, on unity icon.
That's all!

Wednesday, 4 July 2012

First Version is out...!

Finally my application for ubuntuappshowdown is out..
After 2 nights of tests..

It's not perfect.. when you are far from a milestones, all it seems perfect..when you are near to reach the milestones, bugs comes from everywhere!

The application is on a ppa here: https://launchpad.net/~dega1999/+archive/protoborsa/

The Name:

So first of all.. my application is called now.. protoborsa.. why this name? because this was the name of the application when I started to hack this project...
I thought that it was simple to change the name of a quickly project in another moment.. but there is no way (let me know if I am wrong please!) to refactor a project and change the name..
So at the end I left this because refactoring for rename is a problematic task. And it is better to don't talk about version... it's  12.07.5 the last uploaded.. LOL.


Quickly submitubuntu is not enough for now
quickly is a young project and so this competition is a good way to test it for bugs.

It's not just (mention from showdown page):
  • Set up a PPA on Launchpad
  • Run the following command to package and upload your app: quickly submitubuntu
 because you need also to:
Other stuff
I spent a lot of time trying to make a good svg icons for the application (the one present in media with the same name of application):  pay attention to make it a 64x64pixel svg (you can create it with inkscape)... not the image.. the entire document...

After that, in order to join the competition you have to upload on Ubuntu Software Center:
  • Create some screenshot of your application
  • Remember to "IMPORTANT! While submitting your app, fill in the App Showdown Participation Details and upload it in the ‘Your application‘ field in MyApps"
  • Create 4 icons: 16x16, 32x32, 64x64, 128x128. You can use a command like this "convert youricon.png -resize 128x128! youricon_128x128.png"
and follow all the steps..

Testing..

I haven't tryed to download from the ppa and install the application from there and verify if it is all ok or not (application is on /opt and it works...)
I will do tomorrow..
if someone read this and wants to try..
Let me know if it works or not, thanks you.

Next.
I think I will spend my resting time to:
  • testing
  • correct bugs
  • improve unity integration



Monday, 2 July 2012

Changes, Changes and... Changes!

The code relatives to chart is finally ok..
Now the program is capable to:
  • plot a chart with the data ordered by date
  • put the correct label on the chart ticks
  • put an explicative label on the axis
  • calculate a good y-range for displaying the chart (see this option of pycha)
  • for every click on one of the symbol on the stocks list, it display the last month of data on the chart.
  • I added a reload button... if you want you can trash all your dowloaded data and download it again.
About pycha: this is the complete list of options and if you want to specify ticks labels, you need to give pycha something like this:


[

{'v': 0, 'label': 'day1'},
{'v': 1, 'label': 'day2'},
{'v': 2, 'label': 'day3'}

]


It is a list of dictionary.
so record 0 will have day 1 on the first tick.. and so on...


Tomorrow I will spend my after-work time, trying to put it on the ppa and making it ready for the ubuntuappshowdown!

Last screenshot here:



After that, I will spend my resting time for:
  • finish about page.
  • unity integration.
  • make it possible to change data displayed on chart
  • caching data (I want to reduce queries to yahoo whenever is possible).

I need also some graphics.. for icons at least.

Saturday, 30 June 2012

Talking with Thread

With another search on the web.. I have found the answer I was searching on yesterday: Queue with thread.

How? you can read here a good guide.
So anytime the code need to fetch data from the web, there is a good thread who can manage it.

I would like to see a urllib2 library completely asynchronous.. but for now.. you need threads.

Other things I did..a lot of bugfixing and a little bit of code cleaning.

I have also found another bug while displaying data on the chart.
Next step, will be chart improvements... and than..

first alpha will be out!

Friday, 29 June 2012

Baby, did a bad, bad thing

Yesterday I wasted a little bit of time searching to find a bug: I had to delete a selected element from the list of registered stocks in the main screen, and also from the internal db.
Everytime I searched to delete one element from the list, the deletion of that element from internal db doesn't work... instead it was deleting another element.
The code was something like that:
  1. get the iterator and model , for the selected element of the treeview.
  2. remove the element from the model giving the iterator.
  3. the iterator became invalid...(yes it is deleted!) so I did the same thing of step 1.
  4. remove the element form the db getting the key from the iterator.
The bug was simple but it takes some time.. at point 4, the selection to the treeview changed to the previous element in the list!
So the code changed like this:
  1. get the iterator and model , for the selected element of the treeview.
  2. remove the element form the db getting the key from the iterator.
  3. remove the element from the model giving the iterator.

Now add and delete of stocks works.

The other problem is with pygtk and thread.. As I mentioned before.. everytime the application try to connect to the web the interface freeze until this operation is complete.
This happened because retrieving data from the net, it is a blocking operation, and block the main thread where the GTK engine runs.. so the application freeze.

I read so many pages about which is the best way to implements a Thread.. and I hope to be near to a solution.. but not yet!

Thursday, 28 June 2012

Add functionality & autocomplete

I have added a textentry on the top of the dialog for add a new stock quote.
This textentry helps to find through the list of available company, with an autocomplete algorithm... while you type, the list change.
The Add, now it works!

In the main screen when you select one of the registered stock quote, the chart updates, but I have some problem displaying the chart..
I need to examine more later on this, I have a pycha error with some company and I have to understand if it is a problem with the loaded data or a pycha problem.



Latency
Every network operation is blocking the main thread.. so the UI freeze until the dowload of data from the yahoo finance complete: when you add a new stock, at startup and when chart updates.
A disaster! :D

This is a common UI problem and the solution, here, it is to use a secondary thread that manage the connection.
I have to search for which is the common solution on pygtk.. maybe there is a good way to do this, or a pattern to follow.

Wednesday, 27 June 2012

It is growing day by day!

I think the final name of the app will be UStockQuotes!

This is a screenshot of the last evolution of my app:


As you can see there is a list of stock quotes now.
This is the list of the stocks interested by the user.
At the moment the data is stored inside a database, the application fetch the list from the database and than fetch the updated data from yahoo service.

When you select one of the row of the table, the chart update itself retrieving the data.
 
So this is roadmap, just for the first part:
- add/remove stock quote.
- handle no-selected quote, no-stored-data (leaving a banner for example or a message), yahoo errors: means no plot.
- change chart period.
- change stock quote order in table.
- data caching mechanism for fast response and less requests.
- loading screen.
- better unity integration.
- ppa & preparation for contest.


Nice to have:
- Fullscreen mode.
- Fullscreen with stock quote data-rotation.

Tuesday, 26 June 2012

Main Screen Mockup

 I did some test with Yahoo Finance Api.. trying to understand, which data, it is possible to retrieve fast from their service and which is slowly, also because it is huge.
What I would like to achieve in this application is  a fast, responsive interface, designed to mitigate the delay during data retrieval.
A good organized application can help to reduce this problem and make users happy to use the application.

After this step, I did a mockup, with pencil, of the main screen of my application:
Let me show you how it should work... using the 3 bullet on the mockup
  • bullet 1: this is the zone where chart of a selected company is displayed. At the first launch will display the chart of the first present company or, a message if none company is registered. As you can see, there is also on the top right a combo box. This combo box contains some prefixed , period: 1 week, 1 day, 1 month, 1 year ecc. Changing the combobox will update the chart accordingly to the selected period. I don't know if I will use a combo box, but it's just for the idea.  I would like also to change the period, simply scrolling in or scrolling out on the chart.
  • bullet 2: The list of your selected stock quote companies. At the launch of the application this table should be populated asynchronously .. putting every line , one by one, after every download of the information from a company, and making user informed of the in progress operation. Clicking on one of this row will update the chart.
  • bullet 3: a toolbar for handling: add of a new company in the table, remove of an existing company, fullscreenmode. Fullscreen will be a mode to use all the screen for displaying the data of only one selected company with a chart that will take 90% of the screen. It needs a new mockup only for this.

I will try to reduce call to yahoo service whenever is possible with a local caching mechanism like save the data displayed on the table, save the data displayed on a chart for a company... So if I know that the data is locally present, I will not fetch it from Yahoo, otherwise I will fetch, display and save it locally.

Other Features..
Yes, it is not just finished here but, my time is limited so I need to proceed step by step and reach some milestones before proceed with other feature..
I prefer to create a working program with less feature but robust than an application with many feature and bugs.

Monday, 25 June 2012

About Dialogs and Gtk.TreeView

Just finished working on this: open a new dialog with a simple treeview inside and other widgets.
This dialog will be used for searching inside the stock quote table(see the previous post)

First problem first
Adding a new dialog to your project it is easier than you think.. if you know that you should use Quickly (and if your project is quickly based)!

Quickly team make easy to add a new dialog to your project.. just follow this answer.
I wasted an hour searching for an answer on how to manage it with glade3 and finally I found that post.
I like this solution... it is easy to add a new dialog and it manage files for you.. just quickly.

After a dialog finish his task, it return a response code; a list of response code is here.

Second problem.. Treeview, pygtk and Glade
This is a complicated task... information on the net are poor or refers to old version.. but you can do a lot with glade3.
You need to create a TreeView and the associated ListStore.
On the treeview you should define:
  • column list with information
  • the renderer for every column you need like Text, Image or other widget available
On the liststore you have to define:
  •  the column to use with the type for every column (for text gchararray is enough)
  • eventually, any static information you need in the list when the treeview start.
ListStore need to be connected with Treestore and also you need to map every cellrenderer to an attribute on the liststore! For this last point, there is a "Text" property in the tab General of a CellRenderer element.
If you don't map the attribute and you have elements on the liststore, you will probably see 0 lenght string on the treeview.

What now?
Now, I have enough informations to stop hacking and start designing the app.
Also I will try to include the feautres that someone asked on reddit :).
Need to sleep now, it is a working day tomorrow and it's too late!

Saturday, 23 June 2012

It's Symbol not Keyword

Thanks to this reply from Stephen Lepage I discover that the correct word for searching company in stock quotes data is Symbol and not Keyword!
So GOOG, AAPL and RHT are the symbols for Google, Apple and Red Hat!

If you want to check data from yahoo finance, you have to pass this data inside the request.

Where can you find all the symbols or, at least, a good number of it?
After a little search I found this post on stackoverflow (the saint of all developers) where the first answer said:
you can also get nice tidy csv files from nasdaq.com here: http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nasdaq&render=download (replace exchange=nasdaq with exchange=nyse for nyse symbols).
Those links took to a downloadable .csv file that contains the Symbol, Naming and other information of all the companies form Nasdaq and Nyse.

So the next step for my application is to make this data easy to query...yes.. query.. so.. I made a python script that:
  • read data from csv.
  • read only the necessary information.
  • save the new data to a sqlite3 db.




And this is a search on the table:


This table will be used in the application for lookup operation of symbols.
The db, will not be used only for this operation but for other stuff.

The application is also on reddit now: http://www.reddit.com/r/ubuntuappshowdown/comments/vge3x/app_submission_a_stock_quote_app/

Friday, 22 June 2012

Data downloading... complete!

Ok here it is again.
Today, I'm happier than yesterday.. just because the things went as expected and I can go to sleep earlier...

This is how it looks the new experiment:

That chart display google stock quote (on a predefined period) integrated with pycha library and gtk3!

What I learnt
If you want to:
  • draw on a GTK3 drawing area, you need to register to "draw" event.The "expose" event doesn't exist anymore.
  • update a drawing area widget, you must call queue_draw on that widget
  • get the dimension and position of a widget, you can call the methoed "get_allocation()" on that widget. This methoed give back a Rectangle object with this properties: x,y,width,height.
  • plot with pycha, you have to create a context from the drawing area widget and from the context a surface, than pass the surface to pycha. More info on this point soon.
Yahoo Finance and Stock Quote Data
The stock quote data is obtained from Yahoo Finance, thanks to a web services present on their portal.
Thanks to Corey Goldberg with his library ystockquote obtain these data is a pretty easy task.
I have only to understand how much deep I can go with this script and if it is enough for what I'm looking for...
I also don't know where I can find the right keyword for stock quote companies: Google is GOOG , Apple is AAPL but I don't know where to find a list of these keywords.. or better a webservices to query.

After this research.. I need to pass to design & a bit of mockups!
 




Thursday, 21 June 2012

Lack of documentation

Yesterday I spent a lot of time trying to plot a Chart in a Gtk Drawing Area, using quickly, Glade3, pygtk and pycha.

Some criticism about these tools:
  • "hackish" style... you fix some problem thanks god to people like this: http://somethingididnotknow.wordpress.com/2012/01/27/retrieve-the-window-object-from-widgets-with-pygobject-gtk3.
  • general lack of documentation. what you find around the web is usually deprecated and it doesn't work when you try it
  • the gtk documentation is mainly in C, not in python, and sometimes have a C function called pippo() doesn't mean it exists the equivalent python function pippo()..but something like pyPippo()....
  • when you need a library for a simple task, like plotting on a screen, you can find a lot of solutions, but find the one that just works , it is hard. Many library examples just doesn't work.. you have to find the solution. Read this http://detrasproject.wordpress.com/2011/04/04/show-graphs-using-pygtk/ Also if you don't want plot chart, read the post to understand what I mean. It's not coding.. it's hacking.
  • Trying to plot a line chart inside a drawing area...it has been a bad experience.. and the result not satisfying for now... it looks good but there are a lot of bug to fix.
a prototype.

Quickly, pygtk, glade etc are great tool.. but Ubuntu need documentation, keeping it updated with examples and easy to find tutorial on "how to solve a simple task" or a page with the most important and working library for solve a task.
The hackish approach is not for all, we are in 2012.

This is not an attack to ubuntu community or in general to opensource.
Instead it is an important point, where community should think and improve.

I will post later the recipe for plot a pycha inside a GTK window made with Glade.

Wednesday, 20 June 2012

Planning and some code

For many reasons, the only way I had to find a place for ubuntu 12.04 was some space on Virtualbox.
Ubuntu on Virtualbox is quite fast to don't regret a real machine.

I have seen some parts of the video recorded from UbuntuDevelopers on this youtube channel: http://www.youtube.com/user/ubuntudevelopers
If you are new to pygtk, glade and quickly I suggest to follow those videos.

Planning
From now on, I have around 15 days to produce something good for the competition..
The 15 days will be splitted like this:
  • 3 days experimenting, searching and understand new library in python: fetch webservices,  plot graphs (at least lines) and tools pygtk/glade, quickly.
  • 4 days for design
  • 4 days for programming
  • 1 day for testing
  • 1 day for submission
  • 2 days extra time.. I know those days will be used in some way.

1st Problem
Yes, 1st problem: I desperately need to find a way to plot "cool" graphs with python.

I searched a bit and what I've found is not satisfying me enough.

I don't have the time to create a new library for plot graphs like I want..

Maybe, at the beginning I will use matplotlib (see this tutorial http://www.thetechrepo.com/main-articles/465-how-to-create-a-graph-in-python ) and I will try to improve how graphs looks on the screen only if I will have the time to do it..
I hope matplotlib is able to draw directly on a Gtk Drawing Area... I don't want to save on disk the image than load an image on the Gtk Drawing Area..... it is a sad approach.

Tuesday, 19 June 2012

A Stock Quotes App for Ubuntu

I will do a simple stock quotes application with Quickly for Ubuntu 12.04 but first of all..

Why did I choose to make a stock quotes app for Ubuntu?
Everything started some day ago, while I was playing with the new beta of IOS 6, I found the IOS default app for trace stock quotes information:

It was the first time that I ran that app.

I like the way it works:
  • built to be easy
  • fast manipulation of information: add/remove stocks quote
  • fast searching for stock quotes
  • interface without noise
  • smooth animation and graphics
I've never been interested in stock quotes, markets, etc.. but when you find an application like this and you feel how it is designed...you are captured by how it guides you.

After that I see there is an Ubuntu competition and I have thinked to make something similar for Ubuntu.
I am an Ubuntu user since 4.10 and I would like to give some of my contribute back to the community (I did in other way in the past but I never did a program for the community).
I see there are other stock quote application but I don't like it.. and I have some idea on how to create something different... I would like to create a "wow" effect app.. maybe
I will use quickly (as suggest in the competition) and I will use this blog to document my progress.
I hope the future informations posted on this blog will be useful for others.

Sunday, 17 June 2012

First!

Who Am I? 
Hello everyone,  I'm a 28 years old  developer, from Genova (gmaps) a nice italian city near the sea.
One of the typical plate here is Trofie al pesto (that's why pesto in the name).
When I was a child, I usually break toys trying to change it, transform it or simply trying to make it works again... in a simple word hacks  (yes, this complete the name of this blog).

My fist computer was a fantastic sinclair zx spectrum 48k, my love with computer and technology started with that cute gummy keyboad at the age of 6.
From that moment, obviusly, things changed a lot..and as any good kid I spent a lot of time learning from computer!

In many years I have learnt many languages and technologies like: C, C++, python, java, php , bash , ios, android, j2me, gtk programming, javascript, html, css, linux, xml, xslt, sqlite , oracle, cloenzilla , windows, osx and many others stuff..
Everytime I found some tech-thing that catch enough my attention I start to study it...
And of course I do a lot of experiments with tech-toys like this  http://extenderconcept.wikidot.com/
My computers are only mac and linux workstation, it is easier for me to be productive with those OS.

 
Why did I start this blog?
So.. this is more important for you reader..
I decided to start this blog because:
  • This contest : http://developer.ubuntu.com/showdown great idea Canonical! I use it as an excuse to start this blog, so I have a trace to follow for my future posts about my application idea ( more info soon )
  • I'm italian..my english is not so good and I hope to improve it writing here.
  • I hope that the stuff I will produce will be useful for others and to receive feedback. I love to improve my knowledge.
  • I like to share ideas with others: be a linux user from 10 years means something about sharing.