Commit 82c18443 authored by Elliot Lee's avatar Elliot Lee

Add HTML component to build. Make process die when all objects have been



* configure.in, components/Makefile.am: Add HTML component to build.
* components/help/hyperbola-main.c, components/history/ntl-history-view.c: Make process die when
  all objects have been destroyed.
* components/history/ntl-history-view.c: Bug fixes.
* components/html/*.[ch]: Copy glibwww over, write new NautilusViewClient for HTML browsing.
* src/ntl-uri-map.c: Cleanup, and use ntl_web_browser as default HTML display engine.
* src/ntl-view.c: Try to handle Bonobo views for data display.
parent 27cef034
1999-12-20 Elliot Lee <sopwith@redhat.com>
* configure.in, components/Makefile.am: Add HTML component to build.
* components/help/hyperbola-main.c, components/history/ntl-history-view.c: Make process die when
all objects have been destroyed.
* components/history/ntl-history-view.c: Bug fixes.
* components/html/*.[ch]: Copy glibwww over, write new NautilusViewClient for HTML browsing.
* src/ntl-uri-map.c: Cleanup, and use ntl_web_browser as default HTML display engine.
* src/ntl-view.c: Try to handle Bonobo views for data display.
1999-12-20 John Sullivan <sullivan@eazel.com>
* src/nautilus-bookmark.h,c: new files
* src/nautilus-bookmarklist.h,c: new files
......
SUBDIRS=history help
SUBDIRS=history help html
......@@ -5,12 +5,32 @@
/* In hyperbola-nav-tree.c */
extern GnomeObject *hyperbola_navigation_tree_new(void);
static int object_count = 0;
static void
do_destroy(GtkObject *obj)
{
object_count--;
if(object_count <= 0)
gtk_main_quit();
}
static GnomeObject *
make_obj(GnomeGenericFactory *Factory, const char *goad_id, void *closure)
{
GnomeObject *retval = NULL;
if(!strcmp(goad_id, "hyperbola_navigation_tree"))
return hyperbola_navigation_tree_new();
return NULL;
retval = hyperbola_navigation_tree_new();
if(retval)
{
object_count++;
gtk_signal_connect(GTK_OBJECT(retval), "destroy", do_destroy, NULL);
}
return retval;
}
int main(int argc, char *argv[])
......@@ -26,7 +46,9 @@ int main(int argc, char *argv[])
factory = gnome_generic_factory_new_multi("hyperbola_factory", make_obj, NULL);
bonobo_main();
do {
bonobo_main();
} while(object_count > 0);
return 0;
}
......@@ -26,7 +26,7 @@ hyperbola_navigation_history_notify_location_change (NautilusViewClient *view,
if(hview->last_row >= 0)
{
char *uri;
int i;
int i, j;
/* If we are moving 'forward' in history, must either just
select a new row that is farther ahead in history, or delete
......@@ -34,15 +34,18 @@ hyperbola_navigation_history_notify_location_change (NautilusViewClient *view,
for(i = -1; i <= 1; i++)
{
if((hview->last_row + i) < 0)
continue;
gtk_clist_get_text(clist, hview->last_row + i, 0, &uri);
if(!strcmp(uri, loci->requested_uri))
{
new_rownum = hview->last_row + i;
hview->last_row = new_rownum = hview->last_row + i;
goto skip_prepend;
}
}
for(i = 0; i < hview->last_row; i++)
for(j = 0; j < hview->last_row; j++)
gtk_clist_remove(clist, 0);
}
......@@ -92,6 +95,15 @@ hyperbola_navigation_history_select_row(GtkCList *clist, gint row, gint column,
gtk_clist_thaw(clist);
}
static int object_count = 0;
static void
do_destroy(GtkObject *obj)
{
object_count--;
if(object_count <= 0)
gtk_main_quit();
}
static GnomeObject * make_obj(GnomeGenericFactory *Factory, const char *goad_id, gpointer closure)
{
......@@ -105,6 +117,8 @@ static GnomeObject * make_obj(GnomeGenericFactory *Factory, const char *goad_id,
hview = g_new0(HistoryView, 1);
hview->last_row = -1;
client = gtk_widget_new(nautilus_meta_view_client_get_type(), NULL);
gtk_signal_connect(GTK_OBJECT(client), "destroy", do_destroy, NULL);
object_count++;
ctl = nautilus_view_client_get_gnome_object(NAUTILUS_VIEW_CLIENT(client));
......@@ -150,7 +164,9 @@ int main(int argc, char *argv[])
factory = gnome_generic_factory_new_multi("ntl_history_view_factory", make_obj, NULL);
bonobo_main();
do {
bonobo_main();
} while(object_count > 0);
return 0;
}
......@@ -26,7 +26,7 @@ hyperbola_navigation_history_notify_location_change (NautilusViewClient *view,
if(hview->last_row >= 0)
{
char *uri;
int i;
int i, j;
/* If we are moving 'forward' in history, must either just
select a new row that is farther ahead in history, or delete
......@@ -34,15 +34,18 @@ hyperbola_navigation_history_notify_location_change (NautilusViewClient *view,
for(i = -1; i <= 1; i++)
{
if((hview->last_row + i) < 0)
continue;
gtk_clist_get_text(clist, hview->last_row + i, 0, &uri);
if(!strcmp(uri, loci->requested_uri))
{
new_rownum = hview->last_row + i;
hview->last_row = new_rownum = hview->last_row + i;
goto skip_prepend;
}
}
for(i = 0; i < hview->last_row; i++)
for(j = 0; j < hview->last_row; j++)
gtk_clist_remove(clist, 0);
}
......@@ -92,6 +95,15 @@ hyperbola_navigation_history_select_row(GtkCList *clist, gint row, gint column,
gtk_clist_thaw(clist);
}
static int object_count = 0;
static void
do_destroy(GtkObject *obj)
{
object_count--;
if(object_count <= 0)
gtk_main_quit();
}
static GnomeObject * make_obj(GnomeGenericFactory *Factory, const char *goad_id, gpointer closure)
{
......@@ -105,6 +117,8 @@ static GnomeObject * make_obj(GnomeGenericFactory *Factory, const char *goad_id,
hview = g_new0(HistoryView, 1);
hview->last_row = -1;
client = gtk_widget_new(nautilus_meta_view_client_get_type(), NULL);
gtk_signal_connect(GTK_OBJECT(client), "destroy", do_destroy, NULL);
object_count++;
ctl = nautilus_view_client_get_gnome_object(NAUTILUS_VIEW_CLIENT(client));
......@@ -150,7 +164,9 @@ int main(int argc, char *argv[])
factory = gnome_generic_factory_new_multi("ntl_history_view_factory", make_obj, NULL);
bonobo_main();
do {
bonobo_main();
} while(object_count > 0);
return 0;
}
......@@ -6,34 +6,34 @@ CPPFLAGS = \
-DG_LOG_DOMAIN=\"Nautilus-HTML\"
INCLUDES = \
-I$(top_srcdir)/intl \
-I$(top_builddir)/intl \
-I$(top_srcdir)/src/lib \
-I$(top_builddir)/src/lib \
$(DMALLOC_INCLUDES) \
$(GNOME_INCLUDEDIR)
-I$(top_srcdir) \
-I$(top_builddir) \
$(GNOMEUI_CFLAGS) \
`libwww-config --cflags`
gnorbadir = $(sysconfdir)/CORBA/servers
gnorba_DATA = \
ntl-html-component.gnorba
ntl-web-browser.goad
bin_PROGRAMS = \
ntl-html-component
ntl-web-browser
ntl_html_component_SOURCES = \
main.c
ntl_web_browser_SOURCES = \
ntl-web-browser.c \
glibwww-init.c \
glibwww-trans.c \
glibwww-callbacks.c \
glibwww.h \
gnome-dialogs.c
ntl_html_component_LDADD = \
ntl_web_browser_LDFLAGS = \
$(top_builddir)/libnautilus/libnautilus.la \
-lgtkhtml -lgdk_pixbuf \
$(BONOBO_LIBS) \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(GNOME_VFS_LIBS) \
$(GNORBA_LIBS) \
$(GNOME_XML_LIB) \
$(INTLLIBS)
EXTRA_DIST = ntl-html-component.gnorba
-lgtkhtml -lgdk_pixbuf \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS) \
$(VFS_LIBS) \
$(GNORBA_LIBS) \
`libwww-config --libs`
EXTRA_DIST = ntl-web-browser.goad
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#include "glibwww.h"
#include <HTEvent.h>
#include <HTTimer.h>
#define WWW_HIGH_PRIORITY (G_PRIORITY_HIGH_IDLE + 50)
#define WWW_LOW_PRIORITY G_PRIORITY_LOW
#define WWW_SCALE_PRIORITY(p) ((WWW_HIGH_PRIORITY - WWW_LOW_PRIORITY) * p \
/ HT_PRIORITY_MAX + WWW_LOW_PRIORITY)
#define READ_CONDITION (G_IO_IN | G_IO_HUP | G_IO_ERR)
#define WRITE_CONDITION (G_IO_OUT | G_IO_ERR)
#define EXCEPTION_CONDITION (G_IO_PRI)
typedef struct _SockEventInfo SockEventInfo;
struct _SockEventInfo {
SOCKET s;
HTEventType type;
HTEvent *event;
guint io_tag;
guint timer_tag;
};
typedef struct _SockInfo SockInfo;
struct _SockInfo {
SOCKET s;
GIOChannel *io;
SockEventInfo ev[HTEvent_TYPES];
};
static GHashTable *sockhash = NULL;
static SockInfo *
get_sock_info(SOCKET s, gboolean create)
{
SockInfo *info;
if (!sockhash)
sockhash = g_hash_table_new(g_direct_hash, g_direct_equal);
info = g_hash_table_lookup(sockhash, GINT_TO_POINTER(s));
if (!info && create) {
info = g_new0(SockInfo, 1);
info->s = s;
info->io = g_io_channel_unix_new(s);
info->ev[0].s = info->ev[1].s = info->ev[2].s = s;
info->ev[0].type = HTEvent_READ;
info->ev[1].type = HTEvent_WRITE;
info->ev[2].type = HTEvent_OOB;
g_hash_table_insert(sockhash, GINT_TO_POINTER(s), info);
}
return info;
}
static gboolean glibwww_timeout_func (gpointer data);
static gboolean glibwww_io_func(GIOChannel *source, GIOCondition condition,
gpointer data);
static int
glibwww_event_register (SOCKET s, HTEventType type, HTEvent *event)
{
SockInfo *info;
gint priority = G_PRIORITY_DEFAULT;
GIOCondition condition;
if (s == INVSOC || HTEvent_INDEX(type) >= HTEvent_TYPES)
return 0;
info = get_sock_info(s, TRUE);
info->ev[HTEvent_INDEX(type)].event = event;
switch (HTEvent_INDEX(type)) {
case HTEvent_INDEX(HTEvent_READ):
condition = READ_CONDITION; break;
case HTEvent_INDEX(HTEvent_WRITE):
condition = WRITE_CONDITION; break;
case HTEvent_INDEX(HTEvent_OOB):
condition = EXCEPTION_CONDITION; break;
default:
condition = 0; /* this should never occur */
}
if (event->priority != HT_PRIORITY_OFF)
priority = WWW_SCALE_PRIORITY(event->priority);
info->ev[HTEvent_INDEX(type)].io_tag =
g_io_add_watch_full(info->io, priority, condition, glibwww_io_func,
&info->ev[HTEvent_INDEX(type)], NULL);
if (event->millis >= 0)
info->ev[HTEvent_INDEX(type)].timer_tag =
g_timeout_add_full(priority, event->millis, glibwww_timeout_func,
&info->ev[HTEvent_INDEX(type)], NULL);
return HT_OK;
}
static int
glibwww_event_unregister (SOCKET s, HTEventType type)
{
SockInfo *info = get_sock_info(s, FALSE);
if (info) {
if (info->ev[HTEvent_INDEX(type)].io_tag)
g_source_remove(info->ev[HTEvent_INDEX(type)].io_tag);
if (info->ev[HTEvent_INDEX(type)].timer_tag)
g_source_remove(info->ev[HTEvent_INDEX(type)].timer_tag);
info->ev[HTEvent_INDEX(type)].event = NULL;
info->ev[HTEvent_INDEX(type)].io_tag = 0;
info->ev[HTEvent_INDEX(type)].timer_tag = 0;
/* clean up sock hash if needed */
/*if (info->ev[0].io_tag == 0 &&
info->ev[1].io_tag == 0 &&
info->ev[2].io_tag == 0) {
g_message("Freeing sock:%d", s);
g_hash_table_remove(sockhash, GINT_TO_POINTER(s));
g_io_channel_unref(info->io);
g_free(info);
}*/
return HT_OK;
}
return HT_ERROR;
}
static gboolean
glibwww_timeout_func (gpointer data)
{
SockEventInfo *info = (SockEventInfo *)data;
HTEvent *event = info->event;
if (event)
(* event->cbf) (info->s, event->param, HTEvent_TIMEOUT);
return info->timer_tag != 0; /* XXXX a hack */
}
static gboolean
glibwww_io_func(GIOChannel *source, GIOCondition condition, gpointer data)
{
SockEventInfo *info = (SockEventInfo *)data;
HTEvent *event = info->event;
if (info->timer_tag)
g_source_remove(info->timer_tag);
if (event && event->millis >= 0) {
gint priority = G_PRIORITY_DEFAULT;
if (event->priority != HT_PRIORITY_OFF)
priority = WWW_SCALE_PRIORITY(event->priority);
info->timer_tag =
g_timeout_add_full(priority, info->event->millis, glibwww_timeout_func,
info, NULL);
}
if (event)
(* event->cbf) (info->s, event->param, info->type);
return info->io_tag != 0; /* XXXX a hack */
}
static GHashTable *timers = NULL;
static gboolean
glibwww_dispatch_timer(gpointer data)
{
HTTimer *timer = (HTTimer *)data;
HTTimer_dispatch(timer);
return FALSE;
}
static BOOL
glibwww_timer_register(HTTimer *timer)
{
guint tag;
if (!timers)
timers = g_hash_table_new(g_direct_hash, g_direct_equal);
tag = g_timeout_add(HTTimer_expiresRelative(timer),
glibwww_dispatch_timer, timer);
g_hash_table_insert(timers, timer, GUINT_TO_POINTER(tag));
return YES;
}
static BOOL
glibwww_timer_unregister(HTTimer *timer) {
guint tag;
if (!timers)
return NO;
tag = GPOINTER_TO_UINT(g_hash_table_lookup(timers, timer));
if (tag) {
g_source_remove(tag);
g_hash_table_remove(timers, timer);
return YES;
}
return NO;
}
void
glibwww_register_callbacks(void)
{
HTEvent_setRegisterCallback(glibwww_event_register);
HTEvent_setUnregisterCallback(glibwww_event_unregister);
HTTimer_registerSetTimerCallback(glibwww_timer_register);
HTTimer_registerDeleteTimerCallback(glibwww_timer_unregister);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#include <WWWCore.h>
#include <WWWStream.h>
#include <WWWTrans.h>
#include <WWWHTTP.h>
#include <WWWMIME.h>
#include <WWWFTP.h>
#include <WWWFile.h>
#include <WWWGophe.h>
#include <WWWZip.h>
/* clean up the cpp namespace -- libwww is particularly dirty */
#undef PACKAGE
#undef VERSION
#undef _
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib.h>
#include "glibwww.h"
#ifndef FTP_PORT
#define FTP_PORT 21
#endif
#ifndef HTTP_PORT
#define HTTP_PORT 80
#endif
/*#include "WWWMIME.h"*/
static void HTMIMEInit (void);
static void glibwww_parse_proxy_env (void);
static int HTProxyFilter (HTRequest *request, void *param, int status);
static int HTRedirectFilter (HTRequest *request, HTResponse *response,
void *param, int status);
static int HTCredentialsFilter (HTRequest *request, void *param, int status);
static int HTAuthFilter (HTRequest *request, HTResponse *response,
void *param, int status);
static int HTAuthInfoFilter (HTRequest *request, HTResponse *response,
void *param, int status);
static gboolean exitfunc = FALSE;
void
glibwww_init(const gchar *appName, const gchar *appVersion)
{
if (!HTLib_isInitialized())
HTLibInit(appName, appVersion);
/*HTAlertInit();
HTAlert_setInteractive(NO);*/
HTTransport_add("tcp", HT_TP_SINGLE,HTReader_new,HTWriter_new);
HTTransport_add("buffered_tcp",HT_TP_SINGLE,HTReader_new,HTBufferWriter_new);
HTTransport_add("local", HT_TP_SINGLE,HTReader_new,HTWriter_new);
HTProtocol_add("ftp", "tcp", FTP_PORT, NO, HTLoadFTP, NULL);
HTProtocol_add("http", "buffered_tcp", HTTP_PORT, NO, HTLoadHTTP, NULL);
HTProtocol_add("file", "local", 0, NO, HTLoadFile, NULL);
HTNet_setMaxSocket(6);
HTNet_addBefore(HTCredentialsFilter, "http://*", NULL, HT_FILTER_LATE);
HTNet_addBefore(HTProxyFilter, NULL, NULL, HT_FILTER_LATE);
HTNet_addAfter(HTAuthFilter, "http://*", NULL, HT_NO_ACCESS,
HT_FILTER_MIDDLE);
HTNet_addAfter(HTAuthFilter, "http://*", NULL, HT_REAUTH,
HT_FILTER_MIDDLE);
HTNet_addAfter(HTRedirectFilter, "http://*", NULL, HT_PERM_REDIRECT,
HT_FILTER_MIDDLE);
HTNet_addAfter(HTRedirectFilter, "http://*", NULL, HT_FOUND,
HT_FILTER_MIDDLE);
HTNet_addAfter(HTRedirectFilter, "http://*", NULL, HT_SEE_OTHER,
HT_FILTER_MIDDLE);
HTNet_addAfter(HTRedirectFilter, "http://*", NULL, HT_TEMP_REDIRECT,
HT_FILTER_MIDDLE);
HTNet_addAfter(HTAuthInfoFilter, "http://*", NULL, HT_ALL,
HT_FILTER_MIDDLE);
HTAA_newModule ("basic", HTBasic_generate, HTBasic_parse, NULL,
HTBasic_delete);
glibwww_parse_proxy_env();
/* set proxy from our config files ... */
/* glibwww_add_proxy("http", ...); */
/* glibwww_add_proxy("ftp", ...); */
HTMIME_setSaveStream (HTSaveLocally);
HTFormat_addConversion("message/rfc822", "*/*", HTMIMEConvert,
1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-foot", "*/*", HTMIMEFooter,
1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-head", "*/*", HTMIMEHeader,
1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-cont", "*/*", HTMIMEContinue,
1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-upgrade", "*/*", HTMIMEUpgrade,
1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-partial", "*/*", HTMIMEPartial,
1.0, 0.0, 0.0);
HTFormat_addConversion("text/x-http", "*/*", HTTPStatus_new,
1.0, 0.0, 0.0);
HTFormat_addCoding("*", HTIdentityCoding, HTIdentityCoding, 0.3);
HTFormat_addTransferCoding("deflate", NULL, HTZLib_inflate, 1.0);
HTFormat_addTransferCoding("chunked", HTChunkedEncoder,HTChunkedDecoder,1.0);
HTMIMEInit();
HTFileInit();
HTHost_setEventTimeout(30000);
HTFTP_setTransferMode(FTP_BINARY_TRANSFER_MODE);
glibwww_register_callbacks();
if (!exitfunc)
g_atexit(glibwww_cleanup);
exitfunc = TRUE;
/*WWWTRACE = SHOW_MEM_TRACE;*/
}
void glibwww_cleanup(void) {
if (HTLib_isInitialized()) {
HTFormat_deleteAll();
HTLibTerminate();
}
}
struct ProxyEntry {
gchar *protocol;
gchar *proxy;
};
static GList *proxies = NULL;
static GList *noproxy = NULL;
void
glibwww_add_proxy(const gchar *protocol, const gchar *proxy)
{