[maemo-developers] Browsing and opening URLs from within a C application
From: David Hazel david.hazel at enchaine.comDate: Fri Aug 24 01:41:09 EEST 2007
- Previous message: Does the 770/N800 xserver accept tcp-connections?
- Next message: Browsing and opening URLs from within a C application
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Does the 770/N800 xserver accept tcp-connections?
- Next message: Browsing and opening URLs from within a C application
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]