summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-19 03:07:47 +0000
committereea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-19 03:07:47 +0000
commitd8797ca8274e1c5d0364af395e86e40e8f187531 (patch)
tree39835b1cc903c0d6cc53aa55c0cc7cad71ca92c9
parentd3b4f184eeea603e79aded58bd0722257df2431c (diff)
downloadATCD-d8797ca8274e1c5d0364af395e86e40e8f187531.tar.gz
This adds the authorization to the PUT command. Now the frames for
saving and loading URLs are different. Once the password is entered, it has to make its way all the way to BlobWriter in JACE -- that's why so many files had to be changed.
-rw-r--r--java/ImageProcessing/framework/BaseButton.java11
-rw-r--r--java/ImageProcessing/framework/FilePanel.java7
-rw-r--r--java/ImageProcessing/framework/GIFHandler.java9
-rw-r--r--java/ImageProcessing/framework/ImageApp.java12
-rw-r--r--java/ImageProcessing/framework/ImageSender.java20
-rwxr-xr-x[-rw-r--r--]java/ImageProcessing/framework/LoadURLFrame.java (renamed from java/ImageProcessing/framework/URLFrame.java)61
-rw-r--r--java/ImageProcessing/framework/Makefile3
-rwxr-xr-xjava/ImageProcessing/framework/SaveURLFrame.java133
8 files changed, 212 insertions, 44 deletions
diff --git a/java/ImageProcessing/framework/BaseButton.java b/java/ImageProcessing/framework/BaseButton.java
index 0694d8fbf51..794670b2f3f 100644
--- a/java/ImageProcessing/framework/BaseButton.java
+++ b/java/ImageProcessing/framework/BaseButton.java
@@ -37,7 +37,7 @@ class URLDialogButton extends BaseButton
public URLDialogButton (String title, String desc, ImageApp parent)
{
super (title, desc, parent);
- this.openURLFrame_ = new URLFrame ("Open URL", this.parent_, true);
+ this.openURLFrame_ = new LoadURLFrame ("Open URL <2>", this.parent_);
}
public boolean action (Event e, Object arg)
@@ -45,15 +45,18 @@ class URLDialogButton extends BaseButton
this.openURLFrame_.show ();
return true;
}
- private URLFrame openURLFrame_;
+ private LoadURLFrame openURLFrame_;
}
+// ******************
+// Should continue to remember the password
+// ******************
class SaveButton extends BaseButton
{
public SaveButton (String title, String desc, ImageApp parent)
{
super (title, desc, parent);
- this.openURLFrame_ = new URLFrame ("Save Image", this.parent_, false);
+ this.openURLFrame_ = new SaveURLFrame ("Save Image <2>", this.parent_);
}
public boolean action (Event e, Object arg)
@@ -61,7 +64,7 @@ class SaveButton extends BaseButton
this.openURLFrame_.show ();
return true;
}
- private URLFrame openURLFrame_;
+ private SaveURLFrame openURLFrame_;
}
class ReloadButton extends BaseButton
diff --git a/java/ImageProcessing/framework/FilePanel.java b/java/ImageProcessing/framework/FilePanel.java
index ac5589d7862..f8ffc7dbca8 100644
--- a/java/ImageProcessing/framework/FilePanel.java
+++ b/java/ImageProcessing/framework/FilePanel.java
@@ -52,6 +52,13 @@ class ResetPanel extends Panel
// First create all the buttons
this.reloadButton_ = new ReloadButton ("Reload Filters", "Reload all filters", this.parent_);
+
+ // **********************
+ // Disable this until it works
+ // **********************
+ this.reloadButton_.disable();
+
+
this.resetButton_ = new ResetButton ("Reset", "Reset the image", this.parent_);
diff --git a/java/ImageProcessing/framework/GIFHandler.java b/java/ImageProcessing/framework/GIFHandler.java
index 18b9ad9d52f..336ed25141a 100644
--- a/java/ImageProcessing/framework/GIFHandler.java
+++ b/java/ImageProcessing/framework/GIFHandler.java
@@ -13,6 +13,15 @@ public class GIFHandler extends BlobWriter
super (null, length, 0, filename);
this.image_ = image;
}
+
+ /******************************
+ * Used for HTTP 1.1 PUT authorization
+ *****************************/
+ public GIFHandler (String filename, Image image, int length, String authentication)
+ {
+ super (null, length, 0, filename, authentication);
+ this.image_ = image;
+ }
protected int sendRequest ()
{
diff --git a/java/ImageProcessing/framework/ImageApp.java b/java/ImageProcessing/framework/ImageApp.java
index 4886059a2ec..1c6f3a85912 100644
--- a/java/ImageProcessing/framework/ImageApp.java
+++ b/java/ImageProcessing/framework/ImageApp.java
@@ -144,11 +144,17 @@ public class ImageApp extends Applet
return 0;
}
+ // maintain compatibility
public void saveFile (String url)
+ {
+ this.saveFile (url, null);
+ }
+
+ public void saveFile (String url, String authentication)
{
ImageSender imageSender = new ImageSender (this);
imageSender.open (this.imageCanvas_.getImage (), url);
- int bytesSent = imageSender.send ();
+ int bytesSent = imageSender.send (authentication);
if (bytesSent == -1)
DialogManager.popDialog (DialogType.NOT_SUPPORTED,
"Server does not support uploading or URL not found");
@@ -167,8 +173,10 @@ public class ImageApp extends Applet
// Check if the filename has been previously specified and
// if not then check if the user has specified the name of the
// config file
- if (this.configFile_ == null)
+ if (this.configFile_ == null) {
this.configFile_ = getParameter ("configFile");
+ System.out.println ("Configuration File (1): " + this.configFile_);
+ }
if (this.configFile_ == null)
this.configFile_ = "http://www.cs.wustl.edu/~pjain/java/ACE_wrappers/java/ImageProcessing/framework/filter.conf";
diff --git a/java/ImageProcessing/framework/ImageSender.java b/java/ImageProcessing/framework/ImageSender.java
index 708e39f9fae..c1659267537 100644
--- a/java/ImageProcessing/framework/ImageSender.java
+++ b/java/ImageProcessing/framework/ImageSender.java
@@ -14,6 +14,9 @@ public class ImageSender
this.parent_ = parent;
}
+ // ******************
+ // Currently bombs if it's not in an http or / format
+ //
public void open (Image image, String url)
{
this.image_ = image;
@@ -46,7 +49,17 @@ public class ImageSender
}
}
+ // Maintain compatibility
public int send ()
+ {
+ return send(null);
+ }
+
+ /*******************************************
+ * The authenication string allows the PUT command to work if the server
+ * accepts the basic HTTP 1.1 encryption scheme
+ *******************************************/
+ public int send (String authentication)
{
ImageByteCounter byteCounter = new ImageByteCounter ("", this.image_, this.parent_);
// StatusIndicator indicator = new StatusIndicator ("");
@@ -70,7 +83,12 @@ public class ImageSender
}
*/
- GIFHandler gifHandler = new GIFHandler (this.filename_, this.image_, length);
+ GIFHandler gifHandler;
+ if (authentication == null)
+ gifHandler = new GIFHandler (this.filename_, this.image_, length);
+ else
+ gifHandler = new GIFHandler (this.filename_, this.image_, length, authentication);
+
try
{
// Connect to the server and send the image
diff --git a/java/ImageProcessing/framework/URLFrame.java b/java/ImageProcessing/framework/LoadURLFrame.java
index bc1d25f6fa4..610d9eaafa8 100644..100755
--- a/java/ImageProcessing/framework/URLFrame.java
+++ b/java/ImageProcessing/framework/LoadURLFrame.java
@@ -5,16 +5,34 @@ import java.awt.image.*;
import java.net.*;
import java.io.*;
-class URLFrame extends Frame
+/******************************************************
+ * Future idea:
+ *
+ * Create a smart button class with an invoke method that's
+ * to be called when the button is pressed.
+ *
+ * Subclasses override the invoke method to define
+ * specific behavior.
+ *
+ * That would allow things like load and save frames
+ * to be almost exactly the same -- one could inherit
+ * from the other and override addButtons, etc
+ *****************************************************/
+
+class LoadURLFrame extends Frame
{
- public URLFrame (String title, ImageApp parent, boolean open)
+ public LoadURLFrame (String title, ImageApp parent)
{
super (title);
- // Cache information -- whether we are a load window or a save window
- this.open_ = open;
this.parent_ = parent;
this.resize (500,130);
+
+ this.addButtons();
+ }
+
+ private void addButtons()
+ {
this.setLayout (new BorderLayout ());
Panel textPanel = new Panel ();
@@ -25,11 +43,8 @@ class URLFrame extends Frame
Panel buttonPanel = new Panel ();
buttonPanel.setLayout (new FlowLayout (FlowLayout.CENTER));
- if (this.open_)
- buttonPanel.add (this.openButton_);
- else
- buttonPanel.add (this.saveButton_);
-
+ buttonPanel.add (this.openButton_);
+
buttonPanel.add (this.clearButton_);
buttonPanel.add (this.cancelButton_);
@@ -53,10 +68,6 @@ class URLFrame extends Frame
{
this.getURL ();
}
- if (e.target == this.saveButton_)
- {
- this.saveFile ();
- }
else if (e.target == this.clearButton_)
{
this.openURLText_.setText (new String ());
@@ -75,10 +86,7 @@ class URLFrame extends Frame
{
if (key == 10)
{
- if (this.open_)
- this.getURL ();
- else
- this.saveFile ();
+ this.getURL ();
return true;
}
else
@@ -120,24 +128,9 @@ class URLFrame extends Frame
}
}
- private void saveFile ()
- {
- String url = this.openURLText_.getText ();
- this.hide ();
- this.dispose ();
-
- // The following is only for debugging
- if (url.startsWith ("#"))
- url = "http://merengue.cs:5432/" + url.substring (1);
-
- this.parent_.saveFile (url);
- }
-
-
// Create the Open URL Frame and also the buttons which appear in
// it
private Button openButton_ = new Button ("Open");
- private Button saveButton_ = new Button ("Save");
private Button clearButton_ = new Button ("Clear");
private Button cancelButton_ = new Button ("Cancel");
@@ -146,8 +139,4 @@ class URLFrame extends Frame
private FileBrowser fileBrowser_ = null;
private ImageApp parent_;
- // Flag indicating if this is a load window or a save window
- private boolean open_ = true;
-
}
-
diff --git a/java/ImageProcessing/framework/Makefile b/java/ImageProcessing/framework/Makefile
index 6db3aff01d3..1187b8a88d7 100644
--- a/java/ImageProcessing/framework/Makefile
+++ b/java/ImageProcessing/framework/Makefile
@@ -19,7 +19,8 @@ realclean: clean
files = ImageProcessor.java \
DialogType.java \
- URLFrame.java \
+ LoadURLFrame.java \
+ SaveURLFrame.java \
DialogManager.java \
ImageCanvas.java \
ImageApp.java \
diff --git a/java/ImageProcessing/framework/SaveURLFrame.java b/java/ImageProcessing/framework/SaveURLFrame.java
new file mode 100755
index 00000000000..c3b6adf3490
--- /dev/null
+++ b/java/ImageProcessing/framework/SaveURLFrame.java
@@ -0,0 +1,133 @@
+package imaging.framework;
+
+import java.awt.*;
+import java.awt.image.*;
+import java.net.*;
+import java.io.*;
+
+/******************************************************
+ * Future idea:
+ *
+ * Create a smart button class with an invoke method that's
+ * to be called when the button is pressed.
+ *
+ * Subclasses override the invoke method to define
+ * specific behavior.
+ *
+ * That would allow things like load and save frames
+ * to be almost exactly the same -- one could inherit
+ * from the other and override addButtons, etc
+ *****************************************************/
+
+
+class SaveURLFrame extends Frame
+{
+ public SaveURLFrame (String title, ImageApp parent)
+ {
+ super (title);
+
+ this.parent_ = parent;
+ this.resize (500,200);
+
+ this.addButtons();
+ }
+
+ private void addButtons()
+ {
+ this.setLayout (new BorderLayout ());
+
+ Panel textPanels = new Panel();
+ textPanels.setLayout(new BorderLayout());
+
+ Panel URLPanel = new Panel ();
+ URLPanel.setLayout (new BorderLayout ());
+ URLPanel.add ("North", new Label ("Image Location:"));
+ URLPanel.add ("Center", this.openURLText_);
+
+ // Password panel
+ Panel pwPanel = new Panel();
+ pwPanel.setLayout (new BorderLayout ());
+ pwPanel.add ("North", new Label ("Authentication:"));
+ pwPanel.add ("Center", this.passwordText_);
+
+ textPanels.add("North", URLPanel);
+ textPanels.add("South", pwPanel);
+
+ Panel buttonPanel = new Panel ();
+ buttonPanel.setLayout (new FlowLayout (FlowLayout.CENTER));
+
+ buttonPanel.add (this.saveButton_);
+ buttonPanel.add (this.clearButton_);
+ buttonPanel.add (this.cancelButton_);
+
+ this.add ("North", textPanels);
+ this.add ("South", buttonPanel);
+ }
+
+ // Handle all action events
+ public boolean action (Event e, Object arg)
+ {
+ if (e.target instanceof Button)
+ {
+ if (e.target == this.saveButton_)
+ {
+ this.saveFile ();
+ }
+ else if (e.target == this.clearButton_)
+ {
+ this.openURLText_.setText (new String ());
+ this.openURLText_.requestFocus ();
+ }
+ else if (e.target == this.cancelButton_)
+ this.dispose ();
+ validate ();
+ return true;
+ }
+ else
+ return false;
+ }
+
+ public boolean keyDown (Event e, int key)
+ {
+ if (key == 10)
+ {
+ this.saveFile ();
+ return true;
+ }
+ else
+ return false;
+ }
+
+ private void saveFile ()
+ {
+ String url = this.openURLText_.getText ();
+ String password = this.passwordText_.getText();
+ this.hide ();
+ this.dispose ();
+
+ // The following is only for debugging
+ if (url.startsWith ("#"))
+ url = "http://merengue.cs:5432/" + url.substring (1);
+
+ if ((password != null) && (password.length() > 0))
+ this.parent_.saveFile (url, password);
+ else
+ this.parent_.saveFile (url);
+ }
+
+
+ // Create the Open URL Frame and also the buttons which appear in
+ // it
+ private Button saveButton_ = new Button ("Save");
+ private Button clearButton_ = new Button ("Clear");
+ private Button cancelButton_ = new Button ("Cancel");
+
+ private TextField openURLText_ = new TextField (40);
+ private TextField passwordText_ = new TextField (40);
+
+ private ImageApp parent_;
+
+ // Flag indicating if this is a load window or a save window
+ private boolean open_ = true;
+
+}