summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
Diffstat (limited to 'frontends')
-rw-r--r--frontends/amiga/gui.c273
-rwxr-xr-xfrontends/amiga/launch.c22
-rw-r--r--frontends/amiga/memory.h8
-rwxr-xr-xfrontends/amiga/object.c24
-rw-r--r--frontends/amiga/tree.c4
-rw-r--r--frontends/beos/cookies.cpp1
-rw-r--r--frontends/riscos/gui.c1
7 files changed, 185 insertions, 148 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 76785051f..2c7bc82f6 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -217,7 +217,6 @@ static bool cli_force = false;
#define USERS_DIR "PROGDIR:Users"
static char *users_dir = NULL;
-static char *current_user = NULL;
static char *current_user_dir;
static char *current_user_faviconcache;
@@ -285,6 +284,7 @@ STRPTR ami_locale_langs(int *codeset)
acceptlangs = ASPrintf("%s", remapped);
}
}
+ if(remapped != NULL) free(remapped);
}
else
{
@@ -354,8 +354,7 @@ static bool ami_gui_check_resource(char *fullpath, const char *file)
netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
lock = Lock(fullpath, ACCESS_READ);
- if(lock)
- {
+ if(lock) {
UnLock(lock);
found = true;
}
@@ -371,7 +370,7 @@ bool ami_locate_resource(char *fullpath, const char *file)
struct Locale *locale;
int i;
bool found = false;
- char *remapped;
+ char *remapped = NULL;
size_t fullpath_len = 1024;
/* Check NetSurf user data area first */
@@ -397,11 +396,12 @@ bool ami_locate_resource(char *fullpath, const char *file)
strcpy(fullpath, "PROGDIR:Resources/");
if(locale->loc_PrefLanguages[i]) {
- ami_gui_map_filename(&remapped, "PROGDIR:Resources",
- locale->loc_PrefLanguages[i], "LangNames");
- netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
-
- found = ami_gui_check_resource(fullpath, file);
+ if(ami_gui_map_filename(&remapped, "PROGDIR:Resources",
+ locale->loc_PrefLanguages[i], "LangNames") == true) {
+ netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
+ found = ami_gui_check_resource(fullpath, file);
+ free(remapped);
+ }
} else {
continue;
}
@@ -429,7 +429,17 @@ bool ami_locate_resource(char *fullpath, const char *file)
return found;
}
-static bool ami_open_resources(void)
+static void ami_gui_resources_free(void)
+{
+ ami_schedule_free();
+ ami_object_fini();
+
+ FreeSysObject(ASOT_PORT, appport);
+ FreeSysObject(ASOT_PORT, sport);
+ FreeSysObject(ASOT_PORT, schedulermsgport);
+}
+
+static bool ami_gui_resources_open(void)
{
urlStringClass = MakeStringClass();
@@ -445,6 +455,13 @@ static bool ami_open_resources(void)
ASO_NoTrack, FALSE,
TAG_DONE))) return false;
+ if(ami_schedule_create(schedulermsgport) != NSERROR_OK) {
+ ami_misc_fatal_error("Failed to initialise scheduler");
+ return false;
+ }
+
+ ami_object_init();
+
return true;
}
@@ -905,11 +922,12 @@ static struct RDArgs *ami_gui_commandline(int *restrict argc, char ** argv,
return NULL;
}
-static void ami_gui_read_tooltypes(struct WBArg *wbarg)
+static char *ami_gui_read_tooltypes(struct WBArg *wbarg)
{
struct DiskObject *dobj;
STRPTR *toolarray;
char *s;
+ char *current_user = NULL;
if((*wbarg->wa_Name) && (dobj = GetDiskObject(wbarg->wa_Name))) {
toolarray = (STRPTR *)dobj->do_ToolTypes;
@@ -919,13 +937,16 @@ static void ami_gui_read_tooltypes(struct WBArg *wbarg)
FreeDiskObject(dobj);
}
+ return current_user;
}
-static void ami_gui_read_all_tooltypes(int argc, char **argv)
+static STRPTR ami_gui_read_all_tooltypes(int argc, char **argv)
{
struct WBStartup *WBenchMsg;
struct WBArg *wbarg;
char i = 0;
+ char *current_user = NULL;
+ char *cur_user = NULL;
if(argc == 0) { /* Started from WB */
WBenchMsg = (struct WBStartup *)argv;
@@ -934,11 +955,17 @@ static void ami_gui_read_all_tooltypes(int argc, char **argv)
if((wbarg->wa_Lock) && (*wbarg->wa_Name))
olddir = SetCurrentDir(wbarg->wa_Lock);
- ami_gui_read_tooltypes(wbarg);
+ cur_user = ami_gui_read_tooltypes(wbarg);
+ if(cur_user != NULL) {
+ if(current_user != NULL) FreeVec(current_user);
+ current_user = cur_user;
+ }
if(olddir !=-1) SetCurrentDir(olddir);
}
}
+
+ return current_user;
}
void ami_gui_set_default_gg(void)
@@ -1311,8 +1338,9 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
break;
default:
if((chars = MapRawKey(ie,buffer,20,NULL)) > 0) {
- utf8_from_local_encoding(buffer, chars, &utf8);
+ if(utf8_from_local_encoding(buffer, chars, &utf8) != NSERROR_OK) return 0;
nskey = utf8_to_ucs4(utf8, utf8_char_byte_length(utf8));
+ free(utf8);
if(ie->ie_Qualifier & IEQUALIFIER_RCOMMAND) {
switch(nskey) {
@@ -2914,6 +2942,9 @@ void ami_quit_netsurf(void)
struct nsObject *nnode;
struct gui_window_2 *gwin;
+ /* Disable the multiple tabs open warning */
+ nsoption_set_bool(tab_close_warn, false);
+
if(!IsMinListEmpty(window_list)) {
node = (struct nsObject *)GetHead((struct List *)window_list);
@@ -2973,7 +3004,6 @@ void ami_quit_netsurf_delayed(void)
free(utf8gadgets);
#endif
if(res == -1) { /* Requester timed out */
- nsoption_set_bool(tab_close_warn, false);
ami_quit_netsurf();
}
}
@@ -3061,6 +3091,13 @@ static void gui_quit(void)
FreeStringClass(urlStringClass);
FreeObjList(window_list);
+
+ ami_clipboard_free();
+ ami_gui_resources_free();
+
+ LOG("Closing screen");
+ ami_gui_close_screen(scrn, locked_screen, FALSE);
+ if(nsscreentitle) FreeVec(nsscreentitle);
}
char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
@@ -4527,8 +4564,7 @@ static void gui_window_destroy(struct gui_window *g)
if((g->shared->tabs == 1) && (nsoption_bool(tab_always_show) == false))
ami_toggletabbar(g->shared, false);
- ami_utf8_free(g->tabtitle);
-
+ if(g->tabtitle) free(g->tabtitle);
free(g);
return;
}
@@ -4574,6 +4610,7 @@ static void gui_window_destroy(struct gui_window *g)
Remove(g->tab_node);
FreeClickTabNode(g->tab_node);
}
+ if(g->tabtitle) free(g->tabtitle);
free(g); // g->shared should be freed by DelObject()
if(IsMinListEmpty(window_list))
@@ -4595,8 +4632,7 @@ static void gui_window_set_title(struct gui_window *g, const char *restrict titl
utf8title = ami_utf8_easy((char *)title);
- if(g->tab_node) // && (g->shared->tabs > 1))
- {
+ if(g->tab_node) {
node = g->tab_node;
if((g->tabtitle == NULL) || (strcmp(utf8title, g->tabtitle)))
@@ -4606,7 +4642,7 @@ static void gui_window_set_title(struct gui_window *g, const char *restrict titl
CLICKTAB_Labels, ~0,
TAG_DONE);
- if(g->tabtitle) ami_utf8_free(g->tabtitle);
+ if(g->tabtitle) free(g->tabtitle);
g->tabtitle = strdup(utf8title);
SetClickTabNodeAttrs(node, TNA_Text, g->tabtitle,
@@ -5452,6 +5488,84 @@ uint32 ami_gui_get_app_id(void)
return ami_appid;
}
+/* Get current user directory for user-specific NetSurf data
+ * Returns NULL on error
+ */
+static char *ami_gui_get_user_dir(STRPTR current_user)
+{
+ BPTR lock = 0;
+ char temp[1024];
+ int32 user = 0;
+
+ if(current_user == NULL) {
+ user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
+ current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
+ }
+ LOG("User: %s", current_user);
+
+ if(users_dir == NULL) {
+ users_dir = ASPrintf("%s", USERS_DIR);
+ if(users_dir == NULL) {
+ ami_misc_fatal_error("Failed to allocate memory");
+ FreeVec(current_user);
+ return NULL;
+ }
+ }
+
+ if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
+#ifdef __amigaos4__
+ struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
+ if(infodata == NULL) {
+ ami_misc_fatal_error("Failed to allocate memory");
+ FreeVec(current_user);
+ return NULL;
+ }
+ GetDiskInfoTags(GDI_StringNameInput, users_dir,
+ GDI_InfoData, infodata,
+ TAG_DONE);
+ if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
+ FreeDosObject(DOS_INFODATA, infodata);
+ ami_misc_fatal_error("User directory MUST be on a writeable volume");
+ FreeVec(current_user);
+ return NULL;
+ }
+ FreeDosObject(DOS_INFODATA, infodata);
+#else
+#warning FIXME for OS3 and older OS4
+#endif
+ } else {
+//TODO: check volume write status using old API
+ }
+
+ int len = strlen(current_user);
+ len += strlen(users_dir);
+ len += 2; /* for poss path sep and NULL term */
+
+ current_user_dir = malloc(len);
+ if(current_user_dir == NULL) {
+ ami_misc_fatal_error("Failed to allocate memory");
+ FreeVec(current_user);
+ return NULL;
+ }
+
+ strlcpy(current_user_dir, users_dir, len);
+ AddPart(current_user_dir, current_user, len);
+ FreeVec(users_dir);
+ FreeVec(current_user);
+
+ LOG("User dir: %s", current_user_dir);
+
+ if((lock = CreateDirTree(current_user_dir)))
+ UnLock(lock);
+
+ ami_nsoption_set_location(current_user_dir);
+
+ current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
+ if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
+
+ return current_user_dir;
+}
+
static struct gui_window_table amiga_window_table = {
.create = gui_window_create,
.destroy = gui_window_destroy,
@@ -5515,8 +5629,8 @@ int main(int argc, char** argv)
char script[1024];
char temp[1024];
STRPTR current_user_cache = NULL;
+ STRPTR current_user = NULL;
BPTR lock = 0;
- int32 user = 0;
nserror ret;
int nargc = 0;
char *nargv = NULL;
@@ -5563,99 +5677,24 @@ int main(int argc, char** argv)
struct Interupt *memhandler = ami_memory_init();
#endif
- ami_object_init();
-
- if (ami_open_resources() == false) { /* alloc message ports */
+ if (ami_gui_resources_open() == false) { /* alloc msgports, objects and other miscelleny */
ami_misc_fatal_error("Unable to allocate resources");
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
}
- if(ami_schedule_create(schedulermsgport) != NSERROR_OK) {
- ami_misc_fatal_error("Failed to initialise scheduler");
- ami_gui_splash_close(splash_window);
- ami_libs_close();
- return RETURN_FAIL;
- }
-
- ami_gui_read_all_tooltypes(argc, argv);
+ current_user = ami_gui_read_all_tooltypes(argc, argv);
struct RDArgs *args = ami_gui_commandline(&argc, argv, &nargc, &nargv);
- if(current_user == NULL) {
- user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
- current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
- }
- LOG("User: %s", current_user);
-
- if(users_dir == NULL) {
- users_dir = ASPrintf("%s", USERS_DIR);
- if(users_dir == NULL) {
- ami_misc_fatal_error("Failed to allocate memory");
- ami_schedule_free();
- ami_gui_splash_close(splash_window);
- ami_libs_close();
- return RETURN_FAIL;
- }
- }
-
- if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
-#ifdef __amigaos4__
- struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
- if(infodata == NULL) {
- ami_misc_fatal_error("Failed to allocate memory");
- ami_schedule_free();
- ami_gui_splash_close(splash_window);
- ami_libs_close();
- return RETURN_FAIL;
- }
- GetDiskInfoTags(GDI_StringNameInput, users_dir,
- GDI_InfoData, infodata,
- TAG_DONE);
- if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
- FreeDosObject(DOS_INFODATA, infodata);
- ami_misc_fatal_error("User directory MUST be on a writeable volume");
- ami_schedule_free();
- ami_gui_splash_close(splash_window);
- ami_libs_close();
- return RETURN_FAIL;
- }
- FreeDosObject(DOS_INFODATA, infodata);
-#else
-#warning FIXME for OS3 and older OS4
-#endif
- } else {
-//TODO: check volume write status using old API
- }
-
- int len = strlen(current_user);
- len += strlen(users_dir);
- len += 2; /* for poss path sep and NULL term */
-
- current_user_dir = malloc(len);
+ current_user_dir = ami_gui_get_user_dir(current_user);
if(current_user_dir == NULL) {
- ami_misc_fatal_error("Failed to allocate memory");
- ami_schedule_free();
+ ami_gui_resources_free();
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
}
- strlcpy(current_user_dir, users_dir, len);
- AddPart(current_user_dir, current_user, len);
- FreeVec(users_dir);
- LOG("User dir: %s", current_user_dir);
-
- if((lock = CreateDirTree(current_user_dir)))
- UnLock(lock);
-
- ami_nsoption_set_location(current_user_dir);
- current_user_cache = ASPrintf("%s/Cache", current_user_dir);
- current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
-
- if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
- if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
-
ami_mime_init("PROGDIR:Resources/mimetypes");
sprintf(temp, "%s/mimetypes.user", current_user_dir);
ami_mime_init(temp);
@@ -5673,7 +5712,7 @@ int main(int argc, char** argv)
ret = nsoption_init(ami_set_options, &nsoptions, &nsoptions_default);
if (ret != NSERROR_OK) {
ami_misc_fatal_error("Options failed to initialise");
- ami_schedule_free();
+ ami_gui_resources_free();
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
@@ -5686,7 +5725,9 @@ int main(int argc, char** argv)
if (ami_locate_resource(messages, "Messages") == false) {
ami_misc_fatal_error("Cannot open Messages file");
- ami_schedule_free();
+ ami_nsoption_free();
+ nsoption_finalise(nsoptions, nsoptions_default);
+ ami_gui_resources_free();
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
@@ -5694,16 +5735,23 @@ int main(int argc, char** argv)
ret = messages_add_from_file(messages);
+ current_user_cache = ASPrintf("%s/Cache", current_user_dir);
+ if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
+
ret = netsurf_init(current_user_cache);
+
+ if(current_user_cache != NULL) FreeVec(current_user_cache);
+
if (ret != NSERROR_OK) {
ami_misc_fatal_error("NetSurf failed to initialise");
- ami_schedule_free();
+ ami_nsoption_free();
+ nsoption_finalise(nsoptions, nsoptions_default);
+ ami_gui_resources_free();
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
}
- if(current_user_cache != NULL) FreeVec(current_user_cache);
ret = amiga_icon_init();
search_web_init(nsoption_charp(search_engines_file));
@@ -5748,30 +5796,17 @@ int main(int argc, char** argv)
netsurf_exit();
+ nsoption_finalise(nsoptions, nsoptions_default);
ami_nsoption_free();
free(current_user_dir);
FreeVec(current_user_faviconcache);
- FreeVec(current_user);
-
- ami_clipboard_free();
- ami_schedule_free();
-
- FreeSysObject(ASOT_PORT, appport);
- FreeSysObject(ASOT_PORT, sport);
- FreeSysObject(ASOT_PORT, schedulermsgport);
-
- ami_object_fini();
- ami_bitmap_fini();
#ifndef __amigaos4__
/* OS3 low memory handler */
ami_memory_fini(memhandler);
#endif
- LOG("Closing screen");
- ami_gui_close_screen(scrn, locked_screen, FALSE);
- if(nsscreentitle) FreeVec(nsscreentitle);
-
+ ami_bitmap_fini();
ami_libs_close();
return RETURN_OK;
diff --git a/frontends/amiga/launch.c b/frontends/amiga/launch.c
index 31800ef7a..10c32aeed 100755
--- a/frontends/amiga/launch.c
+++ b/frontends/amiga/launch.c
@@ -74,19 +74,19 @@ static void ami_openurl_free_list(struct MinList *list)
struct ami_protocol *node;
struct ami_protocol *nnode;
- if(IsMinListEmpty(list)) return;
- node = (struct ami_protocol *)GetHead((struct List *)list);
-
- do
- {
- nnode=(struct ami_protocol *)GetSucc((struct Node *)node);
+ if(IsMinListEmpty(list) == NULL) {
+ node = (struct ami_protocol *)GetHead((struct List *)list);
- Remove((struct Node *)node);
- if (node->protocol) lwc_string_unref(node->protocol);
- free(node);
- node = NULL;
- }while((node=nnode));
+ do
+ {
+ nnode=(struct ami_protocol *)GetSucc((struct Node *)node);
+ Remove((struct Node *)node);
+ if (node->protocol) lwc_string_unref(node->protocol);
+ free(node);
+ node = NULL;
+ }while((node=nnode));
+ }
free(list);
}
diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h
index 7abf0a387..a9a882e46 100644
--- a/frontends/amiga/memory.h
+++ b/frontends/amiga/memory.h
@@ -51,10 +51,10 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value);
#define ami_memory_itempool_alloc(p,s) ItemPoolAlloc(p)
#define ami_memory_itempool_free(p,i,s) ItemPoolFree(p,i)
#else
-#define ami_memory_itempool_create(s) CreatePool(MEMF_ANY, 20 * s, s)
-#define ami_memory_itempool_delete(p) DeletePool(p)
-#define ami_memory_itempool_alloc(p,s) AllocPooled(p, s)
-#define ami_memory_itempool_free(p,i,s) FreePooled(p,i,s)
+#define ami_memory_itempool_create(s) ((APTR)1)
+#define ami_memory_itempool_delete(p) ((void)0)
+#define ami_memory_itempool_alloc(p,s) malloc(s)
+#define ami_memory_itempool_free(p,i,s) free(i)
#endif
/* clib2 slab allocator */
diff --git a/frontends/amiga/object.c b/frontends/amiga/object.c
index 2ebca7593..37fc724bf 100755
--- a/frontends/amiga/object.c
+++ b/frontends/amiga/object.c
@@ -119,18 +119,18 @@ void FreeObjList(struct MinList *objlist)
struct nsObject *node;
struct nsObject *nnode;
- if(IsMinListEmpty((struct MinList *)objlist)) return;
- node = (struct nsObject *)GetHead((struct List *)objlist);
-
- do {
- nnode=(struct nsObject *)GetSucc((struct Node *)node);
- if(node->Type == AMINS_RECT) {
- DelObjectNoFree(node);
- } else {
- DelObject(node);
- }
- } while((node=nnode));
-
+ if(IsMinListEmpty((struct MinList *)objlist) == FALSE) {
+ node = (struct nsObject *)GetHead((struct List *)objlist);
+
+ do {
+ nnode = (struct nsObject *)GetSucc((struct Node *)node);
+ if(node->Type == AMINS_RECT) {
+ DelObjectNoFree(node);
+ } else {
+ DelObject(node);
+ }
+ } while((node = nnode));
+ }
free(objlist);
}
diff --git a/frontends/amiga/tree.c b/frontends/amiga/tree.c
index 90497092d..79753a7d3 100644
--- a/frontends/amiga/tree.c
+++ b/frontends/amiga/tree.c
@@ -234,6 +234,7 @@ static void ami_tree_redraw_req_dr(void *p)
if(ami_gui_get_space_box(twin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
amiga_warn_user("NoMemory", "");
+ free(atrr_data);
return;
}
@@ -282,6 +283,8 @@ static void ami_tree_redraw_req(void *p)
.plot = &amiplot
};
+ free(atrr_data);
+
if(!twin->win) return;
ami_update_pointer(twin->win, GUI_POINTER_WAIT);
@@ -341,7 +344,6 @@ static void ami_tree_redraw_req(void *p)
}
}
- free(atrr_data);
ami_gui_free_space_box(bbox);
ami_update_pointer(twin->win, GUI_POINTER_DEFAULT);
ami_clearclipreg(glob);
diff --git a/frontends/beos/cookies.cpp b/frontends/beos/cookies.cpp
index 66cf8bbef..91a9beb4c 100644
--- a/frontends/beos/cookies.cpp
+++ b/frontends/beos/cookies.cpp
@@ -27,7 +27,6 @@ extern "C" {
#include "netsurf/cookie_db.h"
#include "netsurf/keypress.h"
#include "desktop/cookie_manager.h"
-#include "desktop/tree.h"
}
#include "beos/cookies.h"
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index a534bceff..3ac9d4aa9 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -2513,6 +2513,7 @@ int main(int argc, char** argv)
}
netsurf_exit();
+ nsoption_finalise(nsoptions, nsoptions_default);
return 0;
}