PDA

View Full Version : Developing an internet application.


Krumpir
2010-06-02, 00:26
Hello, im trying to develop an app for maemo 5 that will check some web pages for updates at regular intervals and alert the users in case it is needed. For this purpose i've downloaded the karmic desktop virtual image.

I am new to this and i don't quite know how to access the internet on maemo. The first thing i found while researching the subject was the libconic api which can be used to acquire a connection to the internet.

When i include <conic/conic.h> into my project it wont compile saying it cant find Conicevent.h and several other header files referenced from conic.h i have verified that the files exist on disk so i must be missing an include folders or library folders entry somewhere but i cant figure out where to put it (perhaps somewhere in makefile.am but as i sad im a newb ;)).

Furthermore i would like to ask for some pointers on how it would be best to download a web page (would the standard unix system calls like socket, gethostbyname , connect etc. work? i understand there is also a library named curl which i could use).

Finally i'm interested in testing the application. When running example apps in the Xephyr window i've noticed there are also some internet applications in there (youtube, facebook ...) and they dont seem to be connected (are these only simulations of real apps?). The question is once i do get the code right will i be able to actually get data from the internet and display it in a UI inside Xephyr to see if my app is working (all inside the VM).

I apologize in advance if im asking the obvious and thank you for your patience if you're still reading :)

nicola.mfb
2010-06-02, 01:19
A good way may be to use Qt and qt-mobility framework.
With the bearer api you may request a connection, with other Qt classes you can download webpages without taking care of all the mentioned low-level stuff.

And finally, give a try to Qt SDK beta, configure the profile for your n900, select it and with a simple "control-r" you'll see the app automagically cross-compiled and launched directly on the device!

Niko

Joorin
2010-06-02, 05:15
The N900 runs, in most senses, an ordinary Linux. Using socket, gethostbyname, connect and other standard calls work well.

Krumpir
2010-06-02, 08:37
The N900 runs, in most senses, an ordinary Linux. Using socket, gethostbyname, connect and other standard calls work well.
Thanks for the replies, is it neccessary to use the libconic api at all then? And if someone knows where to add the conic include and/or lib folders i would very much appreciate it i will also look into the qt sdk stuff.

gri
2010-06-02, 09:30
Thanks for the replies, is it neccessary to use the libconic api at all then? And if someone knows where to add the conic include and/or lib folders i would very much appreciate it i will also look into the qt sdk stuff.

conic is like QtMobility bearer management. It's there to determine if your phone is connected and how. So if it says "you're not connected", your connect() calls may time out as the user gets asked first if he wants to connect to some network.

You should use pkg-config for the headers and libs.

When using qmake, add this to your .pro file:
CONFIG += link_pkgconfig
PKGCONFIG += conic

When not using qmake:
"pkg-config --cflags conic" puts out the header includes
"pkg-config --lflags conic" puts out the linker settings

danielwilms
2010-06-02, 09:52
conic is like QtMobility bearer management.

But if you are anyway using Qt, it might be worth to have a look at the QtMobility documentation (http://doc.qt.nokia.com/qtmobility-1.0/index.html) for bearer management (http://doc.qt.nokia.com/qtmobility-1.0/bearer-management.html).


Daniel

Krumpir
2010-06-02, 19:17
Thank you for the suggestions. I already have a good part of the UI done in C using hildon so switching to qt now just for the network access seems to much (i have no experience with qt either). I have managed to compile my app though by adding conic into configure.ac and makefile.am (mentioning pkg_config helped ;)). The main example code i am using is the one here (http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Using_Connectivity_Components/Maemo_Connectivity#Requesting_for_Connection).

So im requesting a connection and then catching the response using a callback function. The mentioned code seems to work but the response is the following:
helloworldinc[7618]: GLIB DEBUG default - And we are disconnected. Let's see what went wrong...
helloworldinc[7618]: GLIB DEBUG default - Libconic thinks there was nothing wrong.

So the connection cant be acquired eventhough i can acess the internet normally from the shell in the virtual machine. I have also tried directly connecting from code (without checking if there is a connection available first) but the following call:
status = getaddrinfo("www.google.com", NULL, &hints, &servinfo);
returns a Name or service unknown error code.

Also while trying to use the curl library the curl_easy_perform function returns a a CURLE_COULDNT_RESOLVE_HOST code.

It appears my app cant resolve host adresses even though the VM is connected (pinging things from the console works perfectly). Any input on what might fix the problem would be much apprecciated.

danielwilms
2010-06-02, 19:54
but the following call:
status = getaddrinfo("www.google.com", NULL, &hints, &servinfo);
returns a Name or service unknown error code.


This might be a Scratchbox issue. Please have a look at the FAQ (http://wiki.maemo.org/Developer_frequently_asked_questions#Why_can_I_rea ch_an_IP-address_but_no_domain_inside_Scratchbox.3F), maybe that helps.

Daniel

Krumpir
2010-06-03, 22:35
This might be a Scratchbox issue. Please have a look at the FAQ (http://wiki.maemo.org/Developer_frequently_asked_questions#Why_can_I_rea ch_an_IP-address_but_no_domain_inside_Scratchbox.3F), maybe that helps.

Daniel

Thank you for this suggestion i really thought it would do the trick. However even after these steps and modifying, all the resolv.conf files i could find, to match the one in /etc, im still getting the error.

The strange thing though is that i can access the internet even from the scratchbox prompt, and i can even do a system("wget www.google.com"); from code (that isnt very elegant but it seems to work).