Skip to content

Commit

Permalink
If username and/or password are not set, GalleryComm2 asks for them. …
Browse files Browse the repository at this point in the history
…This is necessary for when passwords are not saved.
  • Loading branch information
Pierre-Luc Paour committed Jun 26, 2003
1 parent 0f10f53 commit 7675256
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions com/gallery/GalleryRemote/GalleryComm2.java
Expand Up @@ -23,7 +23,6 @@

import java.io.IOException;
import java.io.StringBufferInputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.SocketException;
import java.util.*;
Expand All @@ -40,6 +39,8 @@
import com.gallery.GalleryRemote.util.HTMLEscaper;
import com.gallery.GalleryRemote.prefs.PreferenceNames;

import javax.swing.*;

/**
* The GalleryComm2 class implements the client side of the Gallery remote
* protocol <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/gallery/gallery/gallery_remote.php?rev=HEAD&content-type=text/vnd.viewcvs-text">
Expand Down Expand Up @@ -350,11 +351,40 @@ private boolean login() {
}

// setup protocol parameters
String username = g.getUsername();
String password = g.getPassword();

if (username == null) {
username = (String)JOptionPane.showInputDialog(
(JFrame) su,
"Username:",
"Username",
JOptionPane.PLAIN_MESSAGE,
null,
null,
null);

g.setUsername(username);
}

if (password == null) {
password = (String)JOptionPane.showInputDialog(
(JFrame) su,
"Password:",
"Password",
JOptionPane.PLAIN_MESSAGE,
null,
null,
null);

g.setPassword(password);
}

NVPair form_data[] = {
new NVPair("cmd", "login"),
new NVPair("protocol_version", PROTOCOL_VERSION),
new NVPair("uname", g.getUsername()),
new NVPair("password", g.getPassword())
new NVPair("uname", username),
new NVPair("password", password)
};
Log.log(Log.TRACE, MODULE, "login parameters: " + Arrays.asList(form_data));

Expand Down Expand Up @@ -453,7 +483,7 @@ void runTask() {
boolean uploadPicture(Picture p) {
try {
boolean escapeCaptions = GalleryRemote.getInstance().properties.getBooleanProperty(HTML_ESCAPE_CAPTIONS);

// can't set null as an NVPair value
String caption = p.getCaption();
caption = (caption == null) ? "" : caption;
Expand Down

0 comments on commit 7675256

Please sign in to comment.