From f7ebec7142321c0d97789015d8185c5b0cacda0c Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 22 Nov 2015 00:06:10 +0000 Subject: [PATCH] Added Amiga ToolTypes parser. Initially this allows setting the location of the Users directory, and the current user's name. --- amiga/dist/NetSurf.guide | 11 +++ amiga/gui.c | 74 ++++++++++++++++++-- amiga/os3support.h | 1 + amiga/resources/Themes/AISS/NetSurf.info | Bin 23720 -> 23778 bytes amiga/resources/Themes/Default/NetSurf.info | Bin 14760 -> 14818 bytes 5 files changed, 82 insertions(+), 4 deletions(-) diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide index 7265c6cc9..4c1d34862 100755 --- a/amiga/dist/NetSurf.guide +++ b/amiga/dist/NetSurf.guide @@ -117,6 +117,17 @@ FORCE = Force new instance of NetSurf to open (has some limitations, use for de NSOPTS = Catches everything else and passes it to the NetSurf core command line parser @endnode +@node tooltypes "ToolTypes" +Supported tooltypes are: + +@{b}USERSDIR@{ub} +Location of the Users directory. This should contain the "Users" part of the path, NetSurf will append the username. Defaults to PROGDIR:Users. +The user directories contain user-specific preferences and cache data. Always locate them on fast, non-volatile, writeable media. + +@{b}USER@{ub} +Current user. Defaults to the value of the USER env-var, or Default. +@endnode + @node options "Options file" The options file is stored in @{"Users/Default/Choices" link Users/Default/Choices/Main} by default. Most of the settings can be changed from within NetSurf by selecting Edit preferences from the Settings menu. diff --git a/amiga/gui.c b/amiga/gui.c index f9dcec8cf..a3cd57bcc 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -188,7 +189,9 @@ static struct Hook newprefs_hook; static STRPTR temp_homepage_url = NULL; static bool cli_force = false; -static char *current_user; +#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; @@ -855,6 +858,42 @@ static void ami_gui_commandline(int *argc, char **argv) } } +static void ami_gui_read_tooltypes(struct WBArg *wbarg) +{ + struct DiskObject *dobj; + STRPTR *toolarray; + char *s; + + if((*wbarg->wa_Name) && (dobj = GetDiskObject(wbarg->wa_Name))) { + toolarray = (STRPTR *)dobj->do_ToolTypes; + + if((s = (char *)FindToolType(toolarray,"USERSDIR"))) users_dir = ASPrintf("%s", s); + if((s = (char *)FindToolType(toolarray,"USER"))) current_user = ASPrintf("%s", s); + + FreeDiskObject(dobj); + } +} + +static void ami_gui_read_all_tooltypes(int argc, char **argv) +{ + struct WBStartup *WBenchMsg; + struct WBArg *wbarg; + char i; + LONG olddir = -1; + + if(argc == 0) { /* Started from WB */ + WBenchMsg = (struct WBStartup *)argv; + for(i = 0, wbarg = WBenchMsg->sm_ArgList; i < WBenchMsg->sm_NumArgs; i++,wbarg++) { + olddir =-1; + if((wbarg->wa_Lock) && (*wbarg->wa_Name)) + olddir = SetCurrentDir(wbarg->wa_Lock); + + ami_gui_read_tooltypes(wbarg); + + if(olddir !=-1) SetCurrentDir(olddir); + } + } +} static void gui_init2(int argc, char** argv) { @@ -965,6 +1004,7 @@ static void gui_init2(int argc, char** argv) temp_homepage_url = NULL; } } + /* this should be where we read tooltypes, but it's too late for that now */ } } @@ -5427,10 +5467,36 @@ int main(int argc, char** argv) return RETURN_FAIL; } - user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY); - current_user = ASPrintf("%s", (user == -1) ? "Default" : temp); + ami_gui_read_all_tooltypes(argc, argv); + + 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); - current_user_dir = ASPrintf("PROGDIR:Users/%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"); + return RETURN_FAIL; + } + } + + int len = strlen(current_user); + len += strlen(users_dir); + len += 2; /* for poss path sep and NULL term */ + + current_user_dir = AllocVecTags(len, NULL); + if(current_user_dir == NULL) { + ami_misc_fatal_error("Failed to allocate memory"); + 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); diff --git a/amiga/os3support.h b/amiga/os3support.h index 45a917a46..dddedb7ff 100644 --- a/amiga/os3support.h +++ b/amiga/os3support.h @@ -144,6 +144,7 @@ #define FOpen(A,B,C) Open(A,B) #define FClose(A) Close(A) #define CreateDirTree(D) CreateDir(D) /*\todo This isn't quite right */ +#define SetCurrentDir(L) CurrentDir(L) #define DevNameFromLock(A,B,C,D) NameFromLock(A,B,C) /* Exec */ diff --git a/amiga/resources/Themes/AISS/NetSurf.info b/amiga/resources/Themes/AISS/NetSurf.info index b46db4ad4e311bd657221a3d8c32391a5ae37a72..70275756e9d26227de0691f7934ddd9516057e5d 100644 GIT binary patch delta 160 zcmZ3nlkw3`#tCBX;o(vX!o$TFFaRSnLxfppLWHw!LIY3|gyDb*%5q?EVBm=G6kzy2 z*^tR$LS@EZzW=17QUC{~yeDU~pjIh-Ue~@PD!) Zlf%Zj=lPkVSs6Cx3n&Y0KBFLJ0|3Pw7i<6k diff --git a/amiga/resources/Themes/Default/NetSurf.info b/amiga/resources/Themes/Default/NetSurf.info index 8d90882231d9353ed48ee4a71fb6e1c864668c49..0e60172531fdb94b6d18df535ed94deb4003140c 100644 GIT binary patch delta 166 zcmZ2c{HS<>n0sWx{RNQ;mliMp!G9nC(F_a?3=E9S48f8w10ufq6aaZ35d>g@G7}ga z7?>jUo-!~`W@OHq{F{kq@@+PrjrV(5nWJTIZO&&?X0rq;6#!x>jnH7%pkNozAlrZ- le|I2l6