Changeset 529


Ignore:
Timestamp:
11/25/13 17:44:20 (10 years ago)
Author:
jts21
Message:

Add Password widget and profile tag for proxy settings

Location:
trunk/src/org/expeditee
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r511 r529  
    4545import org.expeditee.items.widgets.InteractiveWidgetInitialisationFailedException;
    4646import org.expeditee.items.widgets.InteractiveWidgetNotAvailableException;
     47import org.expeditee.items.widgets.Password;
    4748import org.expeditee.items.widgets.WidgetCorner;
    4849import org.expeditee.items.widgets.WidgetEdge;
     
    706707                                } else if (attribute.equals("colorwheel")) {
    707708                                        Item.COLOR_WHEEL = getColorWheel(item);
     709                                } else if (attribute.equals("proxy")) {
     710                                        proxySetup(item);
    708711                                } else if (attribute.equals("fillcolorwheel")) {
    709712                                        Item.FILL_COLOR_WHEEL = getColorWheel(item);
     
    732735
    733736                return errors;
     737        }
     738
     739        /**
     740         * Loads proxy config from a frame
     741         * To be used with authentication code to allow web browsers to work through a proxy
     742         * @author jts21
     743         */
     744        private static void proxySetup(Item item) {
     745                Frame child = item.getChild();
     746                // FrameUtils.Parse(child);
     747                Password passwordWidget = null;
     748                for(Item config : child.getAllItems()) {
     749                        // System.out.println(config.toString());
     750                        if(config instanceof Text) {
     751                                String str = config.getText().trim().toLowerCase();
     752                                if(str.startsWith("http_host:")) {
     753                                        System.out.println(str.substring(10).trim());
     754                                } else if(str.startsWith("http_port:")) {
     755                                        System.out.println(str.substring(10).trim());
     756                                } else if(str.startsWith("https_host:")) {
     757                                        System.out.println(str.substring(11).trim());
     758                                } else if(str.startsWith("https_port:")) {
     759                                        System.out.println(str.substring(11).trim());
     760                                } else if(str.startsWith("proxy_user:")) {
     761                                        System.out.println(str.substring(11).trim());
     762                                } else if(str.startsWith("proxy_pass:")) { // unencrypted password
     763                                        System.out.println(str.substring(11).trim());
     764                                } else if(str.startsWith("@iw:")) {           // widget
     765                                        // check if it's a password widget
     766                                        if(str.substring(4).trim().startsWith("org.expeditee.items.widgets.password")) {
     767                                                if(passwordWidget == null) {
     768                                                        try {
     769                                                                passwordWidget = (Password) InteractiveWidget.createWidget((Text)config);
     770                                                                System.out.println(passwordWidget.getPassword());
     771                                                        } catch (Exception e) {
     772                                                                e.printStackTrace();
     773                                                        }
     774                                                }
     775                                        }
     776                                }
     777                        } else if(config instanceof WidgetCorner || config instanceof WidgetEdge) {
     778                                // System.out.println("BLAH");
     779                                if(passwordWidget == null) {
     780                                        InteractiveWidget iw;
     781                                        if(config instanceof WidgetCorner) {
     782                                                iw = ((WidgetCorner)config).getWidgetSource();
     783                                        } else {
     784                                                iw = ((WidgetEdge)config).getWidgetSource();
     785                                        }
     786                                        if(iw instanceof Password) {
     787                                                passwordWidget = (Password) iw;
     788                                        }
     789                                        System.out.println(passwordWidget.getPassword());
     790                                }
     791                        }
     792                }
    734793        }
    735794
Note: See TracChangeset for help on using the changeset viewer.