Changeset 1540


Ignore:
Timestamp:
11/02/20 15:47:20 (4 years ago)
Author:
bnemhaus
Message:

Removed reliance of System.getProperty("user.name") by introducing some functions and a variable to Browser to be used instead. All previous occurrences of System.getProperty("user.name") now use these functions.

At the time, introduced new piping into various functions related to the creation and management of profile frames that distinguished between a profile name and a user name. This allows functions to be more specific about what is being used. For example, when modifying the users profile frames (in the profiles directory) that users profile name can be used instead of naming the variable 'username'. This distinction is important because while username's can end with numbers, profile names cannot and therefore get an 'A' on the end.

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/null.banks

    r1527 r1540  
    44bnemhausPXOPCQ3.wav൝᳿1.0᳿0
    55bnemhausFNSAEQ2.wav൝᳿1.0᳿0
     6#$frameplayer#master$वbnemhausSNDGGN1.wav൝᳿1.0᳿0
    67bnemhausDGRPEQ1.wav൝᳿1.0᳿0
    78bnemhausKKWPJL7.wav൝᳿1.0᳿0
     
    2425bnemhausBIKKPW1.wav൝᳿1.0᳿0
    2526bnemhausEXIBIN2.wav൝᳿1.0᳿0
     27bnemhausRPIORU1.wav൝᳿1.0᳿0
    2628bnemhausGKCCXP2.wav൝᳿1.0᳿0
    2729bnemhausEXYLOP1.wav൝᳿1.0᳿0
     
    4345bnemhausWVAWJO1.wav൝᳿1.0᳿0
    4446bnemhausHAQABB1.wav൝᳿1.0᳿0
     47bnemhausSNDGGN1.wav൝᳿1.0᳿0
    4548bnemhausHSOCEV2.wav൝᳿1.0᳿0
    4649bnemhausTJNARP1.wav൝᳿1.0᳿0
     
    5356bnemhausGQLOPS1.wav൝᳿1.0᳿0
    5457bnemhausUJHQEQ1.wav൝᳿1.0᳿0
    55 #$frameplayer#master$᳿1.0᳿0
     58#$frameplayer#master$᳿0.13᳿0
    5659bryceFYJNMX1.wav൝᳿1.0᳿0
    5760bnemhausNAMWRO3.wav൝᳿1.0᳿0
  • trunk/src/org/expeditee/auth/Actions.java

    r1506 r1540  
    4848import org.expeditee.encryption.CryptographyConstants;
    4949import org.expeditee.gio.gesture.StandardGestureActions;
     50import org.expeditee.gui.Browser;
    5051import org.expeditee.gui.DisplayController;
    5152import org.expeditee.gui.Frame;
     
    9697                String backup = UserSettings.UserName.get();
    9798                System.setProperty("user.name", userbackup);
     99                Browser.setExpediteeUserName(userbackup);
    98100                UserSettings.UserName.set(userbackup);
    99101                userbackup = backup;
  • trunk/src/org/expeditee/auth/AuthenticatorBrowser.java

    r1504 r1540  
    8484        public static boolean isAuthenticated() {
    8585                //return isAuthenticationRequired() && !UserSettings.UserName.get().equals(AuthenticatorBrowser.USER_NOBODY);
    86                 return isAuthenticationRequired() && !System.getProperty("user.name").equals(AuthenticatorBrowser.USER_NOBODY);
     86                return isAuthenticationRequired() && !Browser.getExpediteeUserName().equals(AuthenticatorBrowser.USER_NOBODY);
    8787        }
    8888       
  • trunk/src/org/expeditee/auth/account/Authenticate.java

    r1504 r1540  
    5353                }
    5454               
    55                 System.setProperty("user.name", username);
     55                Browser.setExpediteeUserName(username);
    5656                UserSettings.UserName.set(username);
    5757                if (!username.equals(AuthenticatorBrowser.ADMINACCOUNT)) {
  • trunk/src/org/expeditee/auth/account/Create.java

    r1505 r1540  
    3131import org.expeditee.core.Colour;
    3232import org.expeditee.encryption.CryptographyConstants;
     33import org.expeditee.gui.Browser;
    3334import org.expeditee.gui.DisplayController;
    3435import org.expeditee.gui.Frame;
     
    8687                // Update in memory settings
    8788                ProfileManager.ensureDefaultProfile();
    88                 System.setProperty("user.name", username);
     89                Browser.setExpediteeUserName(username);
    8990                UserSettings.UserName.set(username);
    9091                //UserSettings.ProfileName.set(username);
    91                 UserSettings.ProfileName.set(FrameIO.ConvertToValidFramesetName(username));
     92                final String profileName = FrameIO.ConvertToValidFramesetName(username);
     93                UserSettings.ProfileName.set(profileName);
    9294                UserSettings.setupDefaultFolders();
    9395                               
    9496                Frame profile;
    9597                try {
    96                         profile = createNewProfile(username, email, personalKey, privateKey, publicKey);
     98                        profile = createNewProfile(username, profileName, email, personalKey, privateKey, publicKey);
    9799                } catch (InvalidFramesetNameException | ExistingFramesetException e) {
    98100                        return CreateResult.ErrorNewProfile;
     
    201203        }
    202204
    203         private static Frame createNewProfile(String username, String email, String personalKey, String privateKey,
     205        private static Frame createNewProfile(String username, String profileName, String email, String personalKey, String privateKey,
    204206                        String publicKey) throws InvalidFramesetNameException, ExistingFramesetException {
    205207                // Establish the initial settings for the created user.
     
    241243               
    242244                // Create users profile
    243                 Frame profile = FrameIO.CreateNewProfile(username, initialSettings, notifiers);
     245                Frame profile = FrameIO.CreateNewProfile(username, profileName, initialSettings, notifiers);
    244246                int lastNumber = FrameIO.getLastNumber(profile.getFramesetName());
    245247                for (int i = 1; i <= lastNumber; i++) {
  • trunk/src/org/expeditee/auth/tags/AuthenticationTag.java

    r1368 r1540  
    99
    1010public enum AuthenticationTag {
    11         Username ("txtUsername", System.getProperty("user.name")),
     11        Username ("txtUsername", System.getProperty("user.name")), // Should use Browser.getExpediteeUserName()
    1212        Password ("txtPassword", System.getProperty("user.password")),
    1313        PasswordAgain ("txtPasswordAgain", System.getProperty("user.password.again")),
  • trunk/src/org/expeditee/gio/swing/SwingGraphicsManager.java

    r1432 r1540  
    197197
    198198                if (on) {
     199                        if (hasAntialiasing) {
     200                                //return;
     201                        }
    199202                        surface.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     203                        hasAntialiasing = true;
    200204                } else {
     205                        if (hasAntialiasing) {
     206                                //return;
     207                        }
    201208                        surface.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    202209                }
    203210        }
     211       
     212        private static boolean hasAntialiasing = false;
    204213
    205214        @Override
  • trunk/src/org/expeditee/gui/Browser.java

    r1526 r1540  
    169169        public static void main(String[] args) {
    170170                if (AuthenticatorBrowser.isAuthenticationRequired()) {
    171                         String starting_user_name = System.getProperty("user.name");
     171                        String starting_user_name = getExpediteeUserName();
    172172                        System.setProperty("startinguser.name", starting_user_name);
    173                         System.setProperty("user.name", AuthenticatorBrowser.USER_NOBODY);
     173                        setExpediteeUserName(AuthenticatorBrowser.USER_NOBODY);
    174174                }
    175175               
     
    276276
    277277                if (!AuthenticatorBrowser.isAuthenticationRequired() && UserSettings.PublicAndPrivateResources) {
    278                         String userName = System.getProperty("user.name"); //UserSettings.ProfileName.get();
     278                        String userName = getExpediteeUserName(); //UserSettings.ProfileName.get();
    279279                        if (!FrameIO.personalResourcesExist(userName)) {
    280280                                FrameIO.setupPersonalResources(userName);
     
    537537                });
    538538        }
    539 
     539               
     540        private static String expediteeUserName = System.getProperty("user.name");
     541       
     542        public static String getExpediteeUserName() {
     543//              String expediteeUserNameLocal = FrameIO.ConvertToValidFramesetName(expediteeUserName);
     544//              return expediteeUserNameLocal;
     545                return expediteeUserName;
     546        }
     547       
     548        public static void setExpediteeUserName(String username) {
     549                expediteeUserName = username;
     550        }
     551       
     552        public static String getExpediteeUserProfileName() {
     553                String expediteeUserNameLocal = FrameIO.ConvertToValidFramesetName(expediteeUserName);
     554                return expediteeUserNameLocal;
     555        }
     556       
    540557        /**
    541558         * @return The user's profile frame.
    542559         */
    543         public static Frame loadInitialProfiles()
    544         {
     560        public static Frame loadInitialProfiles() {
    545561                String defaultProfileName = UserSettings.DEFAULT_PROFILE_NAME;
    546                 String userName = System.getProperty("user.name");
    547 
    548                 Frame defaultProfile = loadProfile(defaultProfileName);
    549                 Frame userProfile = loadProfile(userName);
     562                String userName = getExpediteeUserName();
     563                String userProfileName = getExpediteeUserProfileName();
     564
     565                Frame defaultProfile = loadProfile(defaultProfileName, defaultProfileName);
     566                Frame userProfile = loadProfile(userName, userProfileName);
    550567               
    551568                MessageBay.warningMessages(FrameUtils.ParseProfile(defaultProfile));
     
    571588        }
    572589
    573         protected static Frame loadProfile(String userName)     {
    574                 Frame profile = FrameIO.LoadProfile(userName);
     590        protected static Frame loadProfile(String username, String profileName) {
     591                Frame profile = FrameIO.LoadProfile(profileName);
    575592               
    576593                if (profile == null) {
    577594                        try {
    578                                 profile = FrameIO.CreateNewProfile(userName, null, null);
     595                                profile = FrameIO.CreateNewProfile(username, profileName, null, null);
    579596                        } catch (Exception e) {
    580597                                // TODO tell the user that there was a problem creating the
  • trunk/src/org/expeditee/gui/FrameIO.java

    r1532 r1540  
    11001100               
    11011101                if (toSave == null || !toSave.hasChanged() || toSave.isSaved()) {
     1102                        System.err.println("FrameIO::SaveFrame::Nothing to save, backing out.");
    11021103                        return "";
     1104                }
     1105               
     1106                if (toSave.getName().toLowerCase().equals("abc146a1")) {
     1107                        System.out.println("here");
    11031108                }
    11041109
     
    12001205                        boolean fileModifyConflict = fileLastModify > frameLastModify && !isBayFrameset;
    12011206                        boolean versionConflict = savedVersion > toSave.getVersion() && !isBayFrameset;
     1207                       
     1208                        System.err.println("FrameIO::SaveFrame::Checking for conflicts for frame:" + toSave.getName());
    12021209                       
    12031210                        if ((fileModifyConflict || versionConflict) && savedVersion > 0) {
     
    14051412        }
    14061413
    1407         public static Frame LoadProfile(String userName)
     1414        public static Frame LoadProfile(String profileName)
    14081415        {
    14091416                final String profilesLoc = System.getProperty("profiles.loc");
    14101417                if (profilesLoc != null) {
    1411                         return LoadFrame(userName + "1", profilesLoc);
     1418                        return LoadFrame(profileName + "1", profilesLoc);
    14121419                } else {
    1413                         return LoadFrame(userName + "1");
    1414                 }
    1415         }
    1416 
    1417         public static Frame CreateNewProfile(String username, Map<String, Setting> initialSettings, Map<String, Consumer<Frame>> toNotifyOnSet) throws InvalidFramesetNameException, ExistingFramesetException {
     1420                        return LoadFrame(profileName + "1");
     1421                }
     1422        }
     1423
     1424        public static Frame CreateNewProfile(String userName, String profileName, Map<String, Setting> initialSettings, Map<String, Consumer<Frame>> toNotifyOnSet) throws InvalidFramesetNameException, ExistingFramesetException { //TODO: Investigate these throws, they never seem to be thrown up this far.
    14181425//              Frame profile = CreateFrameset(username, PROFILE_PATH, true);
    14191426//              if (profile != null) {
     
    14251432//              }
    14261433//              return profile;
    1427                 if (username.equals(UserSettings.DEFAULT_PROFILE_NAME)) {
    1428                         ProfileManager.ensureDefaultProfile();
    1429                         return FrameIO.LoadFrame(UserSettings.DEFAULT_PROFILE_NAME + "1");
     1434                if (profileName.equals(UserSettings.DEFAULT_PROFILE_NAME)) {
     1435                        System.err.println("FrameIO::CreateNewProfile::DEPRECATED::CreateNewProfile should no longer be called to create a default profile.  Use FrameIO::CreateNewDefaultProfile instead.");
     1436                        return CreateNewDefaultProfile();
    14301437                } else {
    1431                         return ProfileManager.createProfile(username, initialSettings, toNotifyOnSet);
    1432                 }
     1438                        return ProfileManager.createProfile(userName, profileName, initialSettings, toNotifyOnSet);
     1439                }
     1440        }
     1441       
     1442        public static Frame CreateNewDefaultProfile() throws InvalidFramesetNameException, ExistingFramesetException  { //TODO: Investigate these throws, they never seem to be thrown up this far.
     1443                ProfileManager.ensureDefaultProfile();
     1444                return FrameIO.LoadFrame(UserSettings.DEFAULT_PROFILE_NAME + "1");
    14331445        }
    14341446
  • trunk/src/org/expeditee/gui/MessageBay.java

    r1510 r1540  
    481481                }
    482482               
    483                 _authorisedUser = new Text("Username: " + System.getProperty("user.name"));
     483                _authorisedUser = new Text("Username: " + Browser.getExpediteeUserName());
    484484                _authorisedUser.setFont(new Font(Text.MONOSPACED_FONT));
    485485                _authorisedUser.setY(95);
  • trunk/src/org/expeditee/gui/management/ProfileManager.java

    r1532 r1540  
    3131        private static final String[] startPages = { "exploratorysearch", "webbrowser" };
    3232        public static final String USER_NAME_FLAG = "${" + "USER.NAME" + "}";
    33 
    34         public static Frame createProfile(String profileFor, Map<String, Setting> specifiedSettings,
     33        public static final String PROFILE_NAME_FLAG = "${" + "PROFILE.NAME" + "}";
     34
     35        public static Frame createProfile(String username, String profileName, Map<String, Setting> specifiedSettings,
    3536                        Map<String, Consumer<Frame>> notifyWhenGenerated) {
    3637                ensureDefaultProfile();
    3738                Frame profileOne = null;
    38                 profileFor = FrameIO.ConvertToValidFramesetName(profileFor);
     39                //String profileName = FrameIO.ConvertToValidFramesetName(username); // TODO: Delete this line before SVN commit
    3940               
    4041                try {
    41                         Frame profile = FrameIO.CreateFrameset(profileFor, FrameIO.PROFILE_PATH, true, null);
     42                        Frame profile = FrameIO.CreateFrameset(profileName, FrameIO.PROFILE_PATH, true, null);
    4243                        profileOne = profile;
    43                         profile.setTitle(profileFor + "'s Profile");
     44                        profile.setTitle(username + "'s Profile");
    4445                        Frame defaultFrame = FrameIO.LoadFrame(DEFAULT + "1");
    4546                        MessageBay.suppressMessages(true);
    46                         UserSettings.UserName.set(profileFor);
    47                         UserSettings.ProfileName.set(FrameIO.ConvertToValidFramesetName(profileFor));
     47                        UserSettings.UserName.set(username);
     48                        UserSettings.ProfileName.set(profileName);
    4849                       
    4950                        int lastNumber = FrameIO.getLastNumber(defaultFrame.getFramesetName());
     
    8384                                        if (item instanceof Text) {
    8485                                                String content = item.getText();
    85                                                 item.setText(ResourceUtil.substitute(content, ProfileManager.USER_NAME_FLAG, profileFor));
     86                                                String contentWithUserSub = ResourceUtil.substitute(content, ProfileManager.USER_NAME_FLAG, username);
     87                                                String contentWithUserAndProfileSub = ResourceUtil.substitute(contentWithUserSub, ProfileManager.PROFILE_NAME_FLAG, FrameIO.ConvertToValidFramesetName(profileName));
     88                                                item.setText(contentWithUserAndProfileSub);
    8689                                        }
    8790                                }
  • trunk/src/org/expeditee/items/Dot.java

    r1514 r1540  
    234234                        } else if (_highlightMode == HighlightMode.Connected) {
    235235                                g.drawRectangle(bounds.getTopLeft(), bounds.getSize(), 0.0f, null, highlightColor, HIGHLIGHT_STROKE, null);
     236                                System.err.println("Dot::paint:Painting Dot with colour: " + highlightColor);
    236237                        } else if (_highlightMode == HighlightMode.Normal) {
    237238                                g.drawOval(bounds.getCentre(), bounds.getSize(), 0.0f, fill, highlightColor, DOT_STROKE);
Note: See TracChangeset for help on using the changeset viewer.