Re: Browsing and opening URLs from within a C application

2007-08-24 Thread Antonio Gomes
 I've tested this code on the emulator on my development system (but not
 on the N800 itself). It is failing even to connect after the
 con_ic_connection_connect call (it times out without the appropriate
 callback handler ever receiving the connection-event). If I remove all
 of the conic connection logic, the gnome_vfs_open_uri call fails with
 a Host not found error.

We can test it on sbox, it has to be on device, I believe.


-- 
--Antonio Gomes
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Browsing and opening URLs from within a C application

2007-08-23 Thread David Hazel
I'm trying to do two things that I would expect to be very simple on a
device as internet-enabled as the Nokia N800, but it's proving almost
impossible to find any documentation that tells me how to go about doing
either of these things.

Firstly, I need to be able to open a URL and read (programmatically, in
C) the HTML text that is returned by it. I'm currently trying to do this
with code similar to the following (which is trying to retrieve the
required text in the variable actText; url contains the URL that I want
to open):

gchar *actText   = malloc(big enough buffer for text);
GnomeVFSURI *uri = gnome_vfs_uri_new(url);
GnomeVFSHandle *gfh = NULL;
...
ConIcConnection *inConn = con_ic_connection_new();
g_signal_connect(G_OBJECT(inConn), connection-event,
G_CALLBACK(inConnCallback), NULL);

if (con_ic_connection_connect(inConn, CON_IC_CONNECT_FLAG_NONE))
{
/* wait for connection-event to be flagged by callback function */
if (connected)
{
GnomeVFSResult gres = gnome_vfs_open_uri(gfh, uri,
GNOME_VFS_OPEN_READ);
if (gres == GNOME_VFS_OK)
{
GnomeVFSFileSize count = 0;
gres = gnome_vfs_read(gfh, actText, buffSize, count);
if (gres != GNOME_VFS_OK)
{
/* deal with error */
}
gres = gnome_vfs_close(gfh);

}
else
{
/* deal with error */
}

con_ic_connection_disconnect (inConn);
}
}


I've tested this code on the emulator on my development system (but not
on the N800 itself). It is failing even to connect after the
con_ic_connection_connect call (it times out without the appropriate
callback handler ever receiving the connection-event). If I remove all
of the conic connection logic, the gnome_vfs_open_uri call fails with
a Host not found error.

The questions are:
(a) am I using the right calls above to enable me to open the URL? and
(b) if not, what should I be doing? Should I be using something other
than the con_ic and gnome_vfs functions?


Secondly, I would like to be able to embed a browser within my
application, so as to provide the user with a means of viewing local
HTML content. I came across a vague reference somewhere to Mozilla which
seemed to imply this could somehow be embedded within an application,
but I couldn't find anything that told me how. (In fact, I even noted
down libgtkembedmoz.so in connection with this, but couldn't find any
references to the header files that might tell me the functions to use
for it.) Any ideas? Is it possible to embed a browser within an
application (by which I mean add a widget to my application window that
can load and render HTML documents)?


In hopeful anticipation,
David Hazel


___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: Browsing and opening URLs from within a C application

2007-08-23 Thread Kemal Hadimli
For libconic: Try comparing it with the maemoscrobbler's conic code from here:
https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/src/scrobblerd/scrobblerd.c?root=maemoscrobblerrev=7view=markup

Hope it helps.


On 8/24/07, David Hazel [EMAIL PROTECTED] wrote:
 I'm trying to do two things that I would expect to be very simple on a
 device as internet-enabled as the Nokia N800, but it's proving almost
 impossible to find any documentation that tells me how to go about doing
 either of these things.

 Firstly, I need to be able to open a URL and read (programmatically, in
 C) the HTML text that is returned by it. I'm currently trying to do this
 with code similar to the following (which is trying to retrieve the
 required text in the variable actText; url contains the URL that I want
 to open):

 gchar *actText   = malloc(big enough buffer for text);
 GnomeVFSURI *uri = gnome_vfs_uri_new(url);
 GnomeVFSHandle *gfh = NULL;
 ...
 ConIcConnection *inConn = con_ic_connection_new();
 g_signal_connect(G_OBJECT(inConn), connection-event,
 G_CALLBACK(inConnCallback), NULL);

 if (con_ic_connection_connect(inConn, CON_IC_CONNECT_FLAG_NONE))
 {
 /* wait for connection-event to be flagged by callback function */
 if (connected)
 {
 GnomeVFSResult gres = gnome_vfs_open_uri(gfh, uri,
 GNOME_VFS_OPEN_READ);
 if (gres == GNOME_VFS_OK)
 {
 GnomeVFSFileSize count = 0;
 gres = gnome_vfs_read(gfh, actText, buffSize, count);
 if (gres != GNOME_VFS_OK)
 {
 /* deal with error */
 }
 gres = gnome_vfs_close(gfh);

 }
 else
 {
 /* deal with error */
 }

 con_ic_connection_disconnect (inConn);
 }
 }


 I've tested this code on the emulator on my development system (but not
 on the N800 itself). It is failing even to connect after the
 con_ic_connection_connect call (it times out without the appropriate
 callback handler ever receiving the connection-event). If I remove all
 of the conic connection logic, the gnome_vfs_open_uri call fails with
 a Host not found error.

 The questions are:
 (a) am I using the right calls above to enable me to open the URL? and
 (b) if not, what should I be doing? Should I be using something other
 than the con_ic and gnome_vfs functions?


 Secondly, I would like to be able to embed a browser within my
 application, so as to provide the user with a means of viewing local
 HTML content. I came across a vague reference somewhere to Mozilla which
 seemed to imply this could somehow be embedded within an application,
 but I couldn't find anything that told me how. (In fact, I even noted
 down libgtkembedmoz.so in connection with this, but couldn't find any
 references to the header files that might tell me the functions to use
 for it.) Any ideas? Is it possible to embed a browser within an
 application (by which I mean add a widget to my application window that
 can load and render HTML documents)?


 In hopeful anticipation,
 David Hazel


 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers



-- 
Kemal
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers