Changeset 1244


Ignore:
Timestamp:
03/17/19 22:29:23 (5 years ago)
Author:
davidb
Message:

After change to have resources-public and resources-private, some changes needed to support running Expeditee for a single user; other main change is to allow FrameDirs to specify relative directory paths, to help with when Expeditee is run on the cloud -- similar work still needs to occurr for ImageDir and AudioDir; some other minor changes also made.

Location:
trunk
Files:
1 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/META-INF/MANIFEST.MF

    r1103 r1244  
    150150 org.expeditee.assets.icons,
    151151 org.expeditee.assets.images,
    152  org.expeditee.assets.resources.dict,
    153  org.expeditee.assets.resources.documentation.calculatetest,
    154  org.expeditee.assets.resources.documentation.demo,
    155  org.expeditee.assets.resources.documentation.documentation,
    156  org.expeditee.assets.resources.documentation.expediteetest,
    157  org.expeditee.assets.resources.documentation.framesetthatdoesntexist,
    158  org.expeditee.assets.resources.documentation.simpledoc,
    159  org.expeditee.assets.resources.documentation.simpletest,
    160  org.expeditee.assets.resources.documentation.simpletestsuite,
    161  org.expeditee.assets.resources.documentation.tutorials,
    162  org.expeditee.assets.resources.fonts.Amaranth,
    163  org.expeditee.assets.resources.fonts.DejaVu,
    164  org.expeditee.assets.resources.fonts.FontAwesome,
    165  org.expeditee.assets.resources.fonts.Metamorphous,
    166  org.expeditee.assets.resources.fonts.RobotoCondensed,
    167  org.expeditee.assets.resources.framesets.exploratorysearch,
    168  org.expeditee.assets.resources.framesets.javascript,
    169  org.expeditee.assets.resources.framesets.overlayset,
    170  org.expeditee.assets.resources.framesets.platonicforms,
    171  org.expeditee.assets.resources.framesets.pong,
    172  org.expeditee.assets.resources.framesets.webbrowser,
    173  org.expeditee.assets.resources.images,
    174152 org.expeditee.assets.scripts.browserreadablemode,
    175153 org.expeditee.assets.style,
  • trunk/src/org/apollo/ApolloSystem.java

    r1242 r1244  
    1818import org.apollo.gui.FramePlaybackBarRenderer;
    1919import org.apollo.gui.FrameRenderPasses;
     20import org.apollo.io.AudioPathManager;
    2021import org.apollo.io.SampledAudioFileImporter;
    2122import org.apollo.util.ApolloSystemLog;
     
    260261                Browser.main(args);
    261262               
    262                 // Initialize apollo
    263                 EcosystemManager.getMiscManager().runOnGIOThread(new BlockingRunnable() {
    264                         public void execute() {
    265                                 ApolloSystem.initialize();
    266                         }
    267                 });
     263                if (!Boolean.getBoolean("auth")) {
     264                        // If not running with authentication/login, then proceed with initializing Apollo
     265                        EcosystemManager.getMiscManager().runOnGIOThread(new BlockingRunnable() {
     266                                public void execute() {
     267                                        ApolloSystem.initialize();
     268                                }
     269                        });
     270                }
    268271        }
    269272       
  • trunk/src/org/apollo/agents/MelodySearch.java

    r1102 r1244  
    452452                String fullPath = null;
    453453                if (path == null) {
    454                         for (String possiblePath : FolderSettings.FrameDirs.get()) {
     454                        for (String possiblePath : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    455455                                fullPath = FrameIO.getFrameFullPathName(possiblePath, frameName);
    456456                                if (fullPath != null)
  • trunk/src/org/apollo/audio/structure/AudioStructureModel.java

    r1142 r1244  
    289289
    290290                        String fullPath = null;
    291                         for (int i = 0; i < FolderSettings.FrameDirs.get().size(); i++) { // RISKY CODE - IN EXPEDITEE SPACE FROM RANDOM TRHEAD
    292                                 String possiblePath = FolderSettings.FrameDirs.get().get(i);
     291                        List<String> possiblePaths = FolderSettings.FrameDirs.getAbsoluteDirs();
     292                       
     293                        for (int i = 0; i < possiblePaths.size(); i++) { // RISKY CODE - IN EXPEDITEE SPACE FROM RANDOM TRHEAD
     294                                String possiblePath = possiblePaths.get(i);
    293295                                fullPath = FrameIO.getFrameFullPathName(possiblePath, rootFrameName);
    294296                                if (fullPath != null)
  • trunk/src/org/apollo/io/AudioPathManager.java

    r1023 r1244  
    1212import org.apollo.util.ApolloSystemLog;
    1313import org.apollo.util.RegExpFileFilter;
    14 
     14import org.expeditee.gui.Browser;
    1515import org.expeditee.gui.FrameIO;
     16import org.expeditee.settings.UserSettings;
    1617
    1718/**
     
    2829
    2930        /** Suffixed with the native file separator */
    30         public static String AUDIO_HOME_DIRECTORY = "audio" + File.separatorChar;
     31        public static String AUDIO_HOME_DIRECTORY = null;
    3132       
    3233        /** Stores all virtual names created by this repository. */
     
    3940        private static Random rand = new Random(System.currentTimeMillis());
    4041
    41         /**
    42          * Class initializer.
    43          * Ensures that the home directory(ies) exist and preps the counter
    44          */
    45         static {
    46                 String expeditee_home = System.getProperty("expeditee.home");
    47 
    48                 /*
    49                 if (expeditee_home != null) {
    50                     AUDIO_HOME_DIRECTORY = expeditee_home + File.separator + AUDIO_HOME_DIRECTORY;                 
    51                     }*/
    52                 AUDIO_HOME_DIRECTORY = FrameIO.PARENT_FOLDER + AUDIO_HOME_DIRECTORY;
    53                 //System.err.println("*** audio_home_dir = " + AUDIO_HOME_DIRECTORY);
     42        // **** DB
     43        // Some work to be done here => remove dependency in code on 'AUDIO_HOME_DIRECTORY'
     44        // and change it to use audio dir list from UserSettings
     45        public static void changeParentAndSubFolders(String newFolder) {
     46               
     47                if (Boolean.getBoolean("auth") && System.getProperty("user.name").equals(Browser.USER_NOBODY)) {
     48                        System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Nothing to do for user '" + Browser.USER_NOBODY + "'");
     49                        return;
     50                }
     51               
     52                if (UserSettings.PublicAndPrivateResources) {
     53                        //String resourcesPublicPath = FrameIO.PARENT_FOLDER + "resources-public" + File.separator;
     54                        String userName = UserSettings.UserName.get();
     55                        //String resourcesPrivateIndividualPath = FrameIO.PARENT_FOLDER + "resources-" + userName + File.separator;
     56                        if (Boolean.getBoolean("auth")) {
     57                                System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Setting 'audio' folder to resources-" + userName);
     58                        }
     59                        //AUDIO_HOME_DIRECTORY = resourcesPrivateIndividualPath + "audio" + File.separatorChar;
     60                        AUDIO_HOME_DIRECTORY = FrameIO.AUDIO_PRIVATE_PATH;
     61                }
     62                else {
     63                        AUDIO_HOME_DIRECTORY = FrameIO.PARENT_FOLDER + "audio" + File.separatorChar;;
     64                }
     65        }
     66       
     67        public static void activateAndScanAudioDir()
     68        {
     69                changeParentAndSubFolders(FrameIO.PARENT_FOLDER);
    5470               
    5571                // Ensure audio directory exists
     
    6278
    6379                // Load counter
    64                 loadCounter(dir);
    65         }
    66 
     80                loadCounter(AUDIO_HOME_DIRECTORY);
     81        }
     82       
     83       
    6784        /**
    6885         * Loads the counter
    6986         * @param dir The dir where the audio files live.
    7087         */
    71         private static void loadCounter(File dir) {
    72                 String[] files = getAudioFileNames(dir);
     88        private static void loadCounter(String audio_dir_str) {
     89                File audio_dir = new File(audio_dir_str);
     90               
     91                String[] files = getAudioFileNames(audio_dir);
    7392                if (files == null) { // Due to IO exception
    7493                        ApolloSystemLog.printError("Failed to read audio directory");
     
    89108                                }
    90109                               
    91                                 if (start >= 0 && end == -1) end = f.length();
     110                                if (start >= 0 && end == -1) {
     111                                        end = f.length();
     112                                }
    92113       
    93114                                if (start > 0 && end >= start) { // not start >= 0 since missing preable
  • trunk/src/org/apollo/util/AudioPurger.java

    r1102 r1244  
    3333                Set<String> referencedAudio = new HashSet<String>();
    3434               
    35                 for (String path : FolderSettings.FrameDirs.get()) {
     35                for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    3636                       
    3737                        File frameDir = new File(path);
  • trunk/src/org/expeditee/actions/Spelling.java

    r919 r1244  
    4646                }
    4747                if (path == null) {
    48                         for (String possiblePath : FolderSettings.FrameDirs.get()) {
    49                                 fullPath = FrameIO
    50                                                 .getFrameFullPathName(possiblePath, frameName);
     48                        for (String possiblePath : FolderSettings.FrameDirs.getAbsoluteDirs()) {
     49                                fullPath = FrameIO.getFrameFullPathName(possiblePath, frameName);
    5150                                if (fullPath != null)
    5251                                        break;
  • trunk/src/org/expeditee/agents/SearchTree.java

    r919 r1244  
    8888
    8989                String fullPath = null;
    90                 for (String possiblePath : FolderSettings.FrameDirs.get()) {
     90                for (String possiblePath : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    9191                        fullPath = FrameIO.getFrameFullPathName(possiblePath, frameName);
    9292                        if (fullPath != null)
  • trunk/src/org/expeditee/agents/SearchTreeNoResults.java

    r919 r1244  
    7171               
    7272                String fullPath = null;
    73                 for (String possiblePath : FolderSettings.FrameDirs.get()) {
     73                for (String possiblePath : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    7474                        fullPath = FrameIO.getFrameFullPathName(possiblePath, frameName);
    7575                        if (fullPath != null)
  • trunk/src/org/expeditee/auth/Actions.java

    r1243 r1244  
    3939import javax.crypto.spec.SecretKeySpec;
    4040
     41import org.apollo.ApolloSystem;
     42import org.apollo.io.AudioPathManager;
    4143import org.expeditee.agents.ExistingFramesetException;
    4244import org.expeditee.agents.InvalidFramesetNameException;
     
    4547import org.expeditee.auth.tags.AuthenticationTag;
    4648import org.expeditee.auth.tags.Constants;
     49import org.expeditee.core.BlockingRunnable;
    4750import org.expeditee.core.Colour;
     51import org.expeditee.gio.EcosystemManager;
    4852import org.expeditee.gui.DisplayController;
    4953import org.expeditee.gui.Frame;
     
    374378               
    375379                // Update in memory settings
     380                System.setProperty("user.name", username);
    376381                UserSettings.UserName.set(username);
    377382                UserSettings.ProfileName.set(username);
     
    388393                initialSettings.put("org.expeditee.gui.folders.FolderSettings.FrameDirs", FolderSettings.FrameDirs);
    389394                initialSettings.put("org.expeditee.gui.folders.FolderSettings.ImageDirs", FolderSettings.ImageDirs);
    390                                                
     395                initialSettings.put("org.expeditee.gui.folders.FolderSettings.AudioDirs", FolderSettings.AudioDirs);
     396               
    391397                // Create users profile
    392398                Frame profile = FrameIO.CreateNewProfile(username, initialSettings);
     
    447453               
    448454                // Copy private resources to personal area
    449                 Path personalResources = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-" + username);
    450                 personalResources.toFile().mkdir();             
    451                 File[] globalResourcesToCopy = Paths.get(FrameIO.RESOURCES_PRIVATE).toFile().listFiles();
    452                 for (File toCopy: globalResourcesToCopy) {
    453                         Path p = Paths.get(toCopy.getAbsolutePath());
    454                         if (!p.getFileName().toString().equals(".res") && !p.getFileName().toString().equals("about")) {
    455                                 copyFileTree(p.toAbsolutePath(), personalResources.resolve(p.getFileName()));
    456                         }
    457                 }
     455                Path personalResources = FrameIO.setupPersonalResources(username);
     456               
    458457                File contactsDir = new File(personalResources.resolve("contacts").toAbsolutePath().toString());
    459458                contactsDir.mkdir();
    460459               
     460                System.err.println("**** Hardwired call in Apollo's AuthioPathManager");
     461                AudioPathManager.activateAndScanAudioDir(); // ****
     462               
    461463                System.out.println(message + "Done.");
    462464        }
    463465       
    464         private static void copyFileTree(Path source, Path target) throws IOException {
    465                 Files.copy(source, target);
    466                 if (source.toFile().isDirectory()) {
    467                         File[] files = source.toFile().listFiles();
    468                         for (File file: files) {
    469                                 Path asPath = Paths.get(file.getAbsolutePath());
    470                                 copyFileTree(asPath, target.resolve(asPath.getFileName()));
    471                         }
    472                 }
    473         }
     466       
    474467
    475468        /*
     
    486479                        return;
    487480                }
     481               
     482                // **** DB
     483                // Have not been able to test the following as auth + login not currently working
     484                // 'out of the box'
     485               
     486                // initialize Apollo
     487                //EcosystemManager.getMiscManager().runOnGIOThread(new BlockingRunnable() {
     488                        //public void execute() {
     489                                ApolloSystem.initialize();
     490                        //}
     491                //});
     492
    488493               
    489494                // Load in and cache the profile frame using the personal key fetched from keystore.
  • trunk/src/org/expeditee/auth/Authenticator.java

    r1243 r1244  
    180180        }
    181181       
    182         final SecretKey getSecretKey(final String label, final String password) throws NoSuchAlgorithmException, KeyStoreException {           
    183                 final KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(password.toCharArray());
    184                 KeyStore.SecretKeyEntry entry = null;
     182        final SecretKey getSecretKey(final String label, final String password) throws NoSuchAlgorithmException, KeyStoreException {   
     183               
     184                char[] password_ca = password.toCharArray();
     185                final KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(password_ca);
     186               
     187                SecretKey secret_key;
    185188                try {
    186                         entry = (SecretKeyEntry) keyStore.getEntry(label, entryPassword);
     189                        SecretKeyEntry entry = (SecretKeyEntry) keyStore.getEntry(label, entryPassword);
     190                        secret_key = entry.getSecretKey();
     191                       
    187192                } catch (final UnrecoverableEntryException e) {
    188                         entry = null;
    189                 }
    190                 if (entry == null) { return null; }
    191                 else { return entry.getSecretKey(); }
     193                        secret_key = null;
     194                }
     195               
     196                return secret_key;
    192197        }
    193198       
  • trunk/src/org/expeditee/gui/Browser.java

    r1242 r1244  
    2222import java.io.IOException;
    2323import java.net.Authenticator;
     24import java.nio.file.Path;
    2425import java.security.KeyStoreException;
    2526import java.security.NoSuchAlgorithmException;
     
    148149        public static boolean _hasExited = false;
    149150
     151        public static String USER_NOBODY = "nobody";
     152       
    150153        /** A flag which is set once the application is exiting. */
    151154        protected boolean _isExiting = false;
     
    154157       
    155158        private static String _startFrame = null;
     159
    156160
    157161        /**
     
    162166        public static void main(String[] args)
    163167        {
     168                if (Boolean.getBoolean("auth")) {
     169                        String starting_user_name = System.getProperty("user.name");
     170                        System.setProperty("startinguser.name", starting_user_name);
     171                        System.setProperty("user.name", USER_NOBODY);
     172                }
     173               
    164174                // Parse the starting frame command-line argument
    165175                if(args.length > 0) {
     
    261271                Frame userProfile = loadProfiles();
    262272
     273                if (!Boolean.getBoolean("auth")) {
     274                        String userName = UserSettings.ProfileName.get();
     275                        FrameIO.setupPersonalResources(userName);
     276                }
    263277                // Listen for save status to display during and after runtime
    264278                EntitySaveManager.getInstance().addSaveStateChangedEventListener(this);
  • trunk/src/org/expeditee/gui/DisplayController.java

    r1216 r1244  
    6868                RIGHT
    6969        }
    70 
     70       
     71        // To help title calculations on frame
     72        public static final int MINIMUM_FRAME_WIDTH = 512;
     73       
    7174        /** Convenience definition of TwinFramesSide.LEFT. */
    7275        public static final TwinFramesSide LEFT = TwinFramesSide.LEFT;
  • trunk/src/org/expeditee/gui/FrameIO.java

    r1242 r1244  
    3333import java.io.Writer;
    3434import java.nio.channels.FileChannel;
     35import java.nio.file.Files;
     36import java.nio.file.Path;
    3537import java.nio.file.Paths;
    3638import java.sql.Time;
     
    4345import java.util.stream.Collectors;
    4446
     47import org.apollo.gui.IChangeParentAndSubFolders;
     48import org.apollo.io.AudioPathManager;
    4549import org.expeditee.actions.Actions;
    4650import org.expeditee.agents.ExistingFramesetException;
     
    8185 *
    8286 */
     87
     88
    8389public class FrameIO {
    8490
    8591        private static final char FRAME_NAME_LAST_CHAR = 'A';
    86 
    87         public static void changeParentFolder(String newFolder) {
    88                 // Partial Paths.
    89                 PARENT_FOLDER = newFolder;
    90                 String resourcesPublicPath = PARENT_FOLDER + "resources-public" + File.separator;
    91                 String resourcesPrivateIndividualPath = PARENT_FOLDER + "resources-" + UserSettings.UserName.get() + File.separator;
    92                
    93                 // Standard paths.
    94                 PUBLIC_PATH = PARENT_FOLDER + "public" + File.separator;
    95                 MESSAGES_PATH = PARENT_FOLDER + "messages" + File.separator;
    96                 TRASH_PATH = PARENT_FOLDER + "trash" + File.separator;
    97                 HELP_PATH = PARENT_FOLDER + "documentation" + File.separator;
    98                 PROFILE_PATH = PARENT_FOLDER + "profiles" + File.separator;
    99                 EXPORTS_DIR = PARENT_FOLDER + "exports" + File.separator;
    100                 STATISTICS_DIR = PARENT_FOLDER + "statistics" + File.separator;
    101                 LOGS_DIR = PARENT_FOLDER + "logs" + File.separator;
    102                                
    103                 // New regime paths.
    104                 if (UserSettings.multiUserMode) {
    105                         SHARED_FRAMESETS_PATH = resourcesPrivateIndividualPath + "framesets-shared" + File.separator;
    106                         RESOURCES_PRIVATE = PARENT_FOLDER + "resources-private" + File.separator;
    107                         RESOURCES_PATH = resourcesPublicPath + "documentation" + File.separator;
    108                         FRAME_PRIVATE_PATH = resourcesPrivateIndividualPath + "framesets" + File.separator;
    109                         IMAGES_PRIVATE_PATH = resourcesPrivateIndividualPath + "images" + File.separator;
    110                         CONTACTS_PATH = resourcesPrivateIndividualPath + "contacts" + File.separator;
    111                 } else {
    112                         // If we are using the old regime then these paths should not be used.
    113                         SHARED_FRAMESETS_PATH = null;
    114                         RESOURCES_PRIVATE = null;               
    115                         RESOURCES_PATH = null;
    116                         FRAME_PRIVATE_PATH = null;
    117                         IMAGES_PRIVATE_PATH = null;
    118                         CONTACTS_PATH = null;
    119                 }
    120                
    121                 // Conditional paths
    122                 if (UserSettings.multiUserMode) {
    123                         FONT_PATH = resourcesPublicPath + "fonts" + File.separator;
    124                         DICT_PATH = resourcesPublicPath + "dict" + File.separator;
    125                         IMAGES_PATH = resourcesPublicPath + "images" + File.separator;
    126                         FRAME_PATH = resourcesPublicPath + "framesets" + File.separator;
    127                 } else {
    128                         FONT_PATH = PARENT_FOLDER + "fonts" + File.separator;
    129                         DICT_PATH = PARENT_FOLDER + "dict" + File.separator;
    130                         IMAGES_PATH = PARENT_FOLDER + "images" + File.separator;
    131                         FRAME_PATH = PARENT_FOLDER + "framesets" + File.separator;
    132                 }
    133         }
    13492
    13593        // The parent path that all others are relative to.  Also referred to as Expeditee Home.
     
    142100        public static String MESSAGES_PATH;
    143101        public static String IMAGES_PATH;
     102        public static String AUDIO_PATH;
    144103        public static String PUBLIC_PATH;
    145104        public static String TRASH_PATH;
     
    159118        public static String FRAME_PRIVATE_PATH;
    160119        public static String IMAGES_PRIVATE_PATH;
     120        public static String AUDIO_PRIVATE_PATH;
    161121       
    162122        // Paths used only by old regime.
     
    175135       
    176136        private static final String INF_FILENAME = "frame.inf";
     137       
     138        public static void changeParentAndSubFolders(String newFolder) {
     139                // Partial Paths.
     140                PARENT_FOLDER = newFolder;
     141                       
     142                String resourcesPublicPath = PARENT_FOLDER + "resources-public" + File.separator;
     143
     144                // Standard paths.
     145                PUBLIC_PATH = PARENT_FOLDER + "public" + File.separator;
     146                MESSAGES_PATH = PARENT_FOLDER + "messages" + File.separator;
     147                TRASH_PATH = PARENT_FOLDER + "trash" + File.separator;
     148                HELP_PATH = PARENT_FOLDER + "documentation" + File.separator;
     149                PROFILE_PATH = PARENT_FOLDER + "profiles" + File.separator;
     150                EXPORTS_DIR = PARENT_FOLDER + "exports" + File.separator;
     151                STATISTICS_DIR = PARENT_FOLDER + "statistics" + File.separator;
     152                LOGS_DIR = PARENT_FOLDER + "logs" + File.separator;
     153                               
     154               
     155                // Conditional paths
     156                if (UserSettings.PublicAndPrivateResources) {
     157                        // Work with a system of public and private folders
     158                       
     159                        FONT_PATH = resourcesPublicPath + "fonts" + File.separator;
     160                        DICT_PATH = resourcesPublicPath + "dict" + File.separator;
     161                        IMAGES_PATH = resourcesPublicPath + "images" + File.separator;
     162                        AUDIO_PATH = resourcesPublicPath + "audio" + File.separator;
     163                        FRAME_PATH = resourcesPublicPath + "framesets" + File.separator;
     164                }
     165                else {
     166                        FONT_PATH = PARENT_FOLDER + "fonts" + File.separator;
     167                        DICT_PATH = PARENT_FOLDER + "dict" + File.separator;
     168                        IMAGES_PATH = PARENT_FOLDER + "images" + File.separator;
     169                        AUDIO_PATH = PARENT_FOLDER + "audio" + File.separator;
     170                        FRAME_PATH = PARENT_FOLDER + "framesets" + File.separator;
     171                }
     172               
     173                if (!UserSettings.PublicAndPrivateResources || System.getProperty("user.name").equals(Browser.USER_NOBODY)) {
     174                       
     175                        if (System.getProperty("user.name").equals(Browser.USER_NOBODY)) {
     176                                System.err.println("**** FrameIO::changeParentAndSubFolders(): Not setting subfolders for user '"+Browser.USER_NOBODY+"'");
     177                        }
     178                       
     179                        // If we are using the old regime, or user.name set to Browser.USER_NOBODY
     180                        // => then these paths should not be used.
     181                        RESOURCES_PATH = null;
     182                        SHARED_FRAMESETS_PATH = null;
     183                        RESOURCES_PRIVATE = null;               
     184                        FRAME_PRIVATE_PATH = null;
     185                        IMAGES_PRIVATE_PATH = null;
     186                        AUDIO_PRIVATE_PATH = null;
     187                        CONTACTS_PATH = null;
     188                }
     189                else {
     190                        String resourcesPrivateIndividualPath = PARENT_FOLDER + "resources-" + UserSettings.UserName.get() + File.separator;
     191                       
     192                        RESOURCES_PATH = resourcesPublicPath + "documentation" + File.separator;
     193                        SHARED_FRAMESETS_PATH = resourcesPrivateIndividualPath + "framesets-shared" + File.separator;
     194                       
     195                        RESOURCES_PRIVATE = PARENT_FOLDER + "resources-private" + File.separator;
     196                        FRAME_PRIVATE_PATH = resourcesPrivateIndividualPath + "framesets" + File.separator;
     197                        IMAGES_PRIVATE_PATH = resourcesPrivateIndividualPath + "images" + File.separator;
     198                        AUDIO_PRIVATE_PATH = resourcesPrivateIndividualPath + "audio" + File.separator;
     199                        CONTACTS_PATH = resourcesPrivateIndividualPath + "contacts" + File.separator;
     200                }
     201                       
     202               
     203                System.err.println("**** FrameIO::changeParentAndSubFolder(): Calling AudioPathManger.changeParentAndSubFolder()");
     204                AudioPathManager.changeParentAndSubFolders(newFolder);
     205        }
    177206       
    178207        // All methods are static, this should not be instantiated
     
    341370                        loaded = LoadKnownPath(knownPath, framename);
    342371                } else {
    343                         List<String> directoriesToSearch = FolderSettings.FrameDirs.get();
     372                        List<String> directoriesToSearch = FolderSettings.FrameDirs.getAbsoluteDirs();
    344373                       
    345374                        if (Authenticator.Authenticated) {
     
    378407                StringBuffer list = new StringBuffer();
    379408
    380                 for (String path : FolderSettings.FrameDirs.get()) {
     409                for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    381410                        File files = new File(path);
    382411                        if (!files.exists()) {
     
    466495                }
    467496
    468                 for (String path : FolderSettings.FrameDirs.get()) {
     497                for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    469498                        if (getFrameFullPathName(path, frameName) != null) {
    470499                                return true;
     
    478507                String fullPath = null;
    479508                if (path == null) {
    480                         for (String possiblePath : FolderSettings.FrameDirs.get()) {
     509                        for (String possiblePath : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    481510                                fullPath = getFrameFullPathName(possiblePath, frameName);
    482511                                if (fullPath != null) {
     
    879908                if (!DisplayController.isTwinFramesOn() && !Justification.center.equals(((Text)titleItem).getJustification())) {
    880909                        if ((titleItem.getX() + 1) < template.getNameItem().getX()) {
    881                                 while (titleItem.getSize() > Text.MINIMUM_FONT_SIZE
    882                                                 && titleItem.getBoundsWidth() + titleItem.getX() > template
    883                                                                 .getNameItem().getX()) {
     910                                int title_item_xr = titleItem.getX() + titleItem.getBoundsWidth(); // should really be '... -1'
     911                                int frame_name_xl = template.getNameItem().getX();
     912                                if (frame_name_xl < DisplayController.MINIMUM_FRAME_WIDTH) {
     913                                        frame_name_xl = DisplayController.MINIMUM_FRAME_WIDTH;
     914                                }
     915                               
     916                                while ((titleItem.getSize() > Text.MINIMUM_FONT_SIZE) && title_item_xr > frame_name_xl) {
    884917                                        titleItem.setSize(titleItem.getSize() - 1);
     918                                        System.err.println("**** shrunk titleItem: " + titleItem + " to font size: " + titleItem.getSize());
    885919                                }
    886920                        } else {
     
    15441578        public static Boolean canAccessFrameset(String framesetName) {
    15451579                framesetName = framesetName.toLowerCase();
    1546                 for (String path : FolderSettings.FrameDirs.get()) {
     1580                for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    15471581                        if ((new File(path + framesetName)).exists()) {
    15481582                                return true;
     
    16851719
    16861720                // Search all the available directories for the directory
    1687                 for (String path : FolderSettings.FrameDirs.get()) {
     1721                for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    16881722                        String source = path + framesetName.toLowerCase() + File.separator;
    16891723                        File framesetDirectory = new File(source);
     
    17301764                // search through all the directories to find the frameset we are
    17311765                // copying
    1732                 for (String path : FolderSettings.FrameDirs.get()) {
     1766                for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    17331767                        String source = path + framesetToCopy.toLowerCase()
    17341768                                        + File.separator;
     
    18901924                toSave.setActiveTime(activeTime);
    18911925        }
     1926       
     1927        public static Path setupPersonalResources(String username)
     1928        {
     1929                Path personalResources = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-" + username);
     1930                personalResources.toFile().mkdir();             
     1931                File[] globalResourcesToCopy = Paths.get(FrameIO.RESOURCES_PRIVATE).toFile().listFiles();
     1932               
     1933                try {
     1934                        for (File toCopy: globalResourcesToCopy) {
     1935                                Path p = Paths.get(toCopy.getAbsolutePath());
     1936                                if (!p.getFileName().toString().equals(".res") && !p.getFileName().toString().equals("about")) {
     1937                                        copyFileTree(p.toAbsolutePath(), personalResources.resolve(p.getFileName()));
     1938                                }
     1939                        }
     1940                }
     1941                catch (IOException e) {
     1942                        e.printStackTrace();
     1943                        personalResources = null;
     1944                }
     1945               
     1946                return personalResources;
     1947        }
     1948       
     1949        private static void copyFileTree(Path source, Path target) throws IOException {
     1950                Files.copy(source, target);
     1951                if (source.toFile().isDirectory()) {
     1952                        File[] files = source.toFile().listFiles();
     1953                        for (File file: files) {
     1954                                Path asPath = Paths.get(file.getAbsolutePath());
     1955                                copyFileTree(asPath, target.resolve(asPath.getFileName()));
     1956                        }
     1957                }
     1958        }
    18921959}
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r1242 r1244  
    10901090                                Logger.Log(e);
    10911091                                e.printStackTrace();
    1092                                 MessageBay.warningMessage("Exception occured when loading " + i.getClass().getSimpleName() + "(ID: "
    1093                                                 + i.getID() + ") " + e.getMessage() != null ? e.getMessage() : "");
     1092                                System.err.println("**** Have temporarily supressed MessageBay call, as resulted in infinite recursion");
     1093                                //MessageBay.warningMessage("Exception occured when loading " + i.getClass().getSimpleName() + "(ID: "
     1094                                //              + i.getID() + ") " + e.getMessage() != null ? e.getMessage() : "");
    10941095                        }
    10951096                }
     
    18201821         */
    18211822        public static void extractResources(boolean force) {
    1822                 // Extract private resources
    1823                 Path resourcesPrivate = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-private");
    1824                 extractResources("org/expeditee/assets/resources-private", resourcesPrivate, force);
    18251823               
    1826                 // Extract public resources
    1827                 Path resourcesPublic = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-public");
    1828                 extractResources("org/expeditee/assets/resources-public", resourcesPublic, force);
     1824                if (UserSettings.PublicAndPrivateResources) {
     1825                        // Extract private resources
     1826                        Path resourcesPrivate = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-private");
     1827                        extractResources("org/expeditee/assets/resources-private", resourcesPrivate, force);
     1828                       
     1829                        // Extract public resources
     1830                        Path resourcesPublic = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-public");
     1831                        extractResources("org/expeditee/assets/resources-public", resourcesPublic, force);
     1832                }
    18291833        }
    18301834       
  • trunk/src/org/expeditee/items/Item.java

    r1212 r1244  
    23012301                int newWidth = i - getX() - Item.MARGIN_LEFT;
    23022302                if (newWidth < 0) newWidth = 0;
     2303               
    23032304                if (!fixWidth) {
    23042305                        newWidth *= -1;
  • trunk/src/org/expeditee/items/Text.java

    r1210 r1244  
    226226                                                }
    227227
    228                                                 System.out.print("'" + font_family + "'");
     228                                                //System.out.print("'" + font_family + "'");
     229                                               
    229230                                        } else {
    230231                                                System.err.println("Error: Failed to add custom True-Type Font file: " + fontFile);
     
    22792280                Frame modelFrame = getParentOrCurrentFrame();
    22802281                if (modelFrame != null) {
    2281                         setRightMargin(modelFrame.getNameItem().getX() - MARGIN_LEFT, true);
     2282                        int model_frame_name_x = modelFrame.getNameItem().getX();
     2283                        if (model_frame_name_x < DisplayController.MINIMUM_FRAME_WIDTH) {
     2284                                System.err.println("resetTitlePostion(): value to be used as right margin from position of frameName < 512");
     2285                                System.err.println("Overriding to ensure reasonable width for title");
     2286                                model_frame_name_x = DisplayController.MINIMUM_FRAME_WIDTH;
     2287                        }
     2288                       
     2289                        setRightMargin(model_frame_name_x - MARGIN_LEFT, true);
    22822290                } else {
    22832291                        System.out.print("Error: text.resetTitlePosition, getParent or currentFrame returned null");
  • trunk/src/org/expeditee/settings/Settings.java

    r1242 r1244  
    241241                                        continue;
    242242                                }
    243                                 System.out.println("Generating " + name);
     243                                System.out.println("@Settings: Generating " + name);
    244244                                generateSettingsTree(k, frames.addText(name.substring(0, 1).toUpperCase() + name.substring(1), null, null, null, false));
    245245                        }
  • trunk/src/org/expeditee/settings/UserSettings.java

    r1242 r1244  
    2727import java.util.List;
    2828
     29import org.apollo.io.AudioPathManager;
    2930import org.expeditee.agents.SearchGreenstone;
    3031import org.expeditee.agents.mail.MailSession;
     
    5354        public static String DEFAULT_PROFILE_NAME = "default";
    5455         
    55         public static Boolean multiUserMode;
     56        public static Boolean PublicAndPrivateResources;
    5657       
    5758        public static final IntegerSetting Gravity = new IntegerSetting("Distance the cursor has to be from a text item to select the text item", "Gravity", 3);
     
    7071                }
    7172                String first = FrameUtils.getLink(text, UserSettings.HomeFrame.get());
    72                 // do not use non-existant frames as the first frame
     73                // do not use non-existent frames as the first frame
    7374                if (FrameIO.isValidFrameName(first)) {
    7475                        _value = first;
     
    203204        static {
    204205                // Are we in the new regime or the old regime?
    205                 File resFile = Paths.get(getDesiredExpediteeHome()).resolve(".res").toFile();
    206                 File resourcesPrivateFile = Paths.get(getDesiredExpediteeHome() + "resources-private" + File.separator).toFile();
     206                File resFile = Paths.get(getExpediteeHome()).resolve(".res").toFile();
     207                File resourcesPrivateFile = Paths.get(getExpediteeHome() + "resources-private" + File.separator).toFile();
    207208                if (resourcesPrivateFile.exists()) {
    208                         // If resources-private exists than this is a good sign we have new regime available.
    209                         multiUserMode = Boolean.TRUE;
    210                 } else if (resFile.exists()) {
     209                        // If resources-private exists then this is a good sign we have new regime available.
     210                        PublicAndPrivateResources = Boolean.TRUE;
     211                }
     212                else if (resFile.exists()) {
    211213                        // If we do not, but do have the .res file then this is a good sign we are in old regime.
    212                         multiUserMode = Boolean.FALSE;
    213                 } else {
     214                        PublicAndPrivateResources = Boolean.FALSE;
     215                }
     216                else {
    214217                        // If we have neither then we are unpacking and therefore will have new regime available once unpacked.
    215                         multiUserMode = Boolean.TRUE;
     218                        PublicAndPrivateResources = Boolean.TRUE;
    216219                }
    217220               
     
    219222        }
    220223               
    221         public static void setupDefaultFolders() {             
    222                 FrameIO.changeParentFolder(getDesiredExpediteeHome());
    223          
     224        public static void setupDefaultFolders() {
     225                String expeditee_home = getExpediteeHome();
     226
     227                FrameIO.changeParentAndSubFolders(expeditee_home);
     228
    224229                FolderSettings.FrameDirs.get().clear();
    225230                FolderSettings.ImageDirs.get().clear();
     231                FolderSettings.AudioDirs.get().clear();
    226232                appendDefaultFolders();
    227         }
    228 
    229         private static String getDesiredExpediteeHome() {
    230                 String homeProperty = System.getProperty("expeditee.home");
    231                 String expeditee_home = homeProperty == null ? getSaveLocation() : homeProperty + File.separator;
     233               
     234        }
     235
     236        private static String getExpediteeHome() {
     237                String home_property = System.getProperty("expeditee.home");
     238                String expeditee_home = (home_property != null) ? home_property + File.separator : getSaveLocation();
    232239                return expeditee_home;
    233240        }
    234241
    235242        public static void appendDefaultFolders() {
    236                 if (multiUserMode) {
     243                if (PublicAndPrivateResources) {
    237244                        // The comments here explain how things have changed with the new regime.
    238245                        // FrameDirs
     
    244251                        // 6. MESSAGES_PATH                                     Still points to same place.  Should these be per user and encrypted?
    245252                        // 7. PUBLIC_PATH                                       Still points to same place.  Kept for compatibility.
    246                         FolderSettings.FrameDirs.get().add(FrameIO.PROFILE_PATH);
    247                         FolderSettings.FrameDirs.get().add(FrameIO.FRAME_PRIVATE_PATH);
    248                         FolderSettings.FrameDirs.get().add(FrameIO.SHARED_FRAMESETS_PATH);
    249                         FolderSettings.FrameDirs.get().add(FrameIO.FRAME_PATH);
    250                         FolderSettings.FrameDirs.get().add(FrameIO.RESOURCES_PATH);
    251                         FolderSettings.FrameDirs.get().add(FrameIO.MESSAGES_PATH);
    252                         FolderSettings.FrameDirs.get().add(FrameIO.PUBLIC_PATH);
     253                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PROFILE_PATH);
     254                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PRIVATE_PATH);
     255                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.SHARED_FRAMESETS_PATH);
     256                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PATH);
     257                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.RESOURCES_PATH);
     258                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MESSAGES_PATH);
     259                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PUBLIC_PATH);
    253260                        FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
    254261                                               
     
    259266                        FolderSettings.ImageDirs.get().add(FrameIO.IMAGES_PATH);
    260267                        FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
     268                       
     269                        FolderSettings.AudioDirs.get().add(FrameIO.AUDIO_PRIVATE_PATH);
     270                        FolderSettings.AudioDirs.get().add(FrameIO.AUDIO_PATH);
     271                        FolderSettings.AudioDirs.setDefault(FolderSettings.AudioDirs.get());
     272                       
    261273                } else {
    262                         FolderSettings.FrameDirs.get().add(FrameIO.FRAME_PATH);
    263                         FolderSettings.FrameDirs.get().add(FrameIO.PUBLIC_PATH);
    264                         FolderSettings.FrameDirs.get().add(FrameIO.PROFILE_PATH);
    265                         FolderSettings.FrameDirs.get().add(FrameIO.HELP_PATH);
    266                         FolderSettings.FrameDirs.get().add(FrameIO.MESSAGES_PATH);
     274                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PATH);
     275                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PUBLIC_PATH);
     276                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PROFILE_PATH);
     277                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_PATH);
     278                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MESSAGES_PATH);
    267279                        FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
     280
    268281                        FolderSettings.ImageDirs.get().add(FrameIO.IMAGES_PATH);
    269282                        FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
     283                       
     284                        FolderSettings.AudioDirs.get().add(FrameIO.AUDIO_PATH);
     285                        FolderSettings.AudioDirs.setDefault(FolderSettings.AudioDirs.get());
    270286                }
    271287        }
  • trunk/src/org/expeditee/settings/folders/FolderSettings.java

    r1242 r1244  
    1919package org.expeditee.settings.folders;
    2020
     21import java.io.File;
     22import java.util.ArrayList;
     23import java.util.List;
     24
    2125import org.expeditee.gui.AttributeValuePair;
    2226import org.expeditee.gui.FrameIO;
    2327import org.expeditee.gui.FrameUtils;
    2428import org.expeditee.items.Text;
     29import org.expeditee.setting.DirectoryListSetting;
    2530import org.expeditee.setting.ListSetting;
    2631import org.expeditee.setting.Setting;
     
    2833public class FolderSettings {
    2934
    30         public static final ListSetting<String> FrameDirs = new ListSetting<String>("Directories to look in for frames", "FrameDirs") {
    31                 @Override
    32                 public boolean setSetting(Text text) {
    33                         _value.addAll(FrameUtils.getDirs(text));
    34                         return true;
    35                 }
    36         };
     35        public static final DirectoryListSetting FrameDirs = new DirectoryListSetting("Directories to look in for frames", "FrameDirs");
     36       
    3737        public static final Setting FramesetDir = new Setting("Adds a directory to look in for frames", "FramesetDir") {
    3838                @Override
     
    9090        };
    9191       
     92       
     93        public static ListSetting<String> AudioDirs = new ListSetting<String>("Directories to look in for audio", "AudioDirs") {
     94                @Override
     95                public boolean setSetting(Text text) {
     96                        _value.addAll(FrameUtils.getDirs(text));
     97                        return true;
     98                }
     99        };
     100        public static final Setting AudioDir = new Setting("Adds a directory to look in for audio", "AudioDir") {
     101                @Override
     102                public boolean setSetting(Text text) {
     103                if(text.getText().indexOf(':') == -1) {
     104                        return false;
     105                }
     106                AttributeValuePair avp = new AttributeValuePair(text.getText());
     107                if(avp.getValue().trim().length() != 0) {
     108                        String dir = FrameUtils.getDir(avp.getValue());
     109                        if(dir != null) {
     110                                FolderSettings.AudioDirs.get().add(0, dir);
     111                                return true;
     112                        }
     113                }
     114                return false;
     115                }
     116               
     117                @Override
     118                public Text generateRepresentation(String label, String frameset) {
     119                        Text t = new Text(label);
     120                        return t;
     121                }
     122        };
     123       
     124       
    92125        public static final Setting LogDir = new Setting("Set the directory to save logs", "LogDir") {
    93126                @Override
  • trunk/src/org/expeditee/settings/templates/TemplateSettings.java

    r1242 r1244  
    138138                        Text t = new Text("TitleTemplate");
    139139                        t.setSize(30);
     140                        t.setWidth(895);
    140141                t.setFontStyle("Bold");
    141142                t.setFamily("SansSerif");
  • trunk/src/org/expeditee/stats/DocumentStatsFast.java

    r919 r1244  
    7575
    7676                String fullPath = null;
    77                 for (String possiblePath : FolderSettings.FrameDirs.get()) {
     77                for (String possiblePath : FolderSettings.FrameDirs.getAbsoluteDirs()) {
    7878                        fullPath = FrameIO.getFrameFullPathName(possiblePath, _name);
    7979                        if (fullPath != null)
  • trunk/src/org/expeditee/stats/StatsLogger.java

    r919 r1244  
    6161
    6262                _filename = Formatter.getDateTime() + ".stat";
     63                _filename = _filename.replace(":","_");
    6364        }
    6465
Note: See TracChangeset for help on using the changeset viewer.