Reply
Thread Tools
Posts: 7 | Thanked: 0 times | Joined on Oct 2009
#1
Hai All,

I read abt libconic api and i don't understand how it is usuful to access the intenet.

i understand that if an application want to use the internet(to select the IAP) we must use the libconic api.

Then only we can get info from the webpage using curl http.

My Openion is correct or wrong?

libconic is the only monitor to internet connections?

is ConIcConnection pointer is used in curl http?

thanks and regards
kamesh.smartdude.
 
Posts: 219 | Thanked: 94 times | Joined on Nov 2009 @ Helsinki, Finland
#2
I'm not an expert of the Maemo APIs (haven't used any lol), but to my knowledge libconic provides a way to handle your connections even if user is switching between e.g. 3G, GSM and WLAN.
 
Posts: 2,102 | Thanked: 1,309 times | Joined on Sep 2006
#3
yes, libconic is used to handle connections (setup, switch, shutdown). It has nothing to do with curl. For curl you do something like this:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&resultchunk);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writebuffer);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);

Obviously you'll want some error checking in there too
 

The Following User Says Thank You to lardman For This Useful Post:
Posts: 2,102 | Thanked: 1,309 times | Joined on Sep 2006
#4
// Following fn from liq*, thanks Gary/lcuk
static size_t curl_writebuffer(void *ptr, size_t size, size_t nmemb, void *data)
{
struct curl_memorybuffer *mem = (struct curl_memorybuffer *) data;
int realsize = size * nmemb;

printf("In memory write callback, size=%d\n", realsize);

mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
if (mem->memory){
memcpy(&(mem->memory[mem->size]), ptr, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
}
return realsize;
}
 

The Following User Says Thank You to lardman For This Useful Post:
Posts: 7 | Thanked: 0 times | Joined on Oct 2009
#5
Originally Posted by lardman View Post
yes, libconic is used to handle connections (setup, switch, shutdown). It has nothing to do with curl. For curl you do something like this:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&resultchunk);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writebuffer);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);

Obviously you'll want some error checking in there too
In maemo to use curl is it necessary to start the connection using libconIC api ?

Is There Any reference document or any examples to access internet using both libconIC and curl?
 
Posts: 2 | Thanked: 0 times | Joined on Oct 2009
#6
In maemo to use curl is it necessary to start the connection using libconIC api ?
No, not on the n800 at least. You can start your connection manually using the maemo UI. Once a connection has been established, your application should be able to use curl to send HTTP requests.

Is There Any reference document or any examples to access internet using both libconIC and curl?
I'm not sure but there are some libcurl examples here

http://curl.haxx.se/libcurl/c/example.html

And some Maemo4 linconIC examples here

http://maemo.org/maemo_release_docum...00000000000000

Perhaps the easiest thing to do would be to start the connection manually using the maemo UI for the time being and to concentrate on getting libcurl to work in your application. Once this is working you can integrate libiconic

Code:
mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
Is there not a memory leak here, if realloc fails?
 
Reply


 
Forum Jump


All times are GMT. The time now is 05:57.