Skip to content

Commit

Permalink
2004-07-09 Pierre-Luc Paour <gallery@paour.com> (1.4-b17)
Browse files Browse the repository at this point in the history
	* When the session expires, GR now attempts to login again.
	* Fixed duplicate extra field
	* Added a warning when EXIF data is about to be dumped by Java resize
	* Enabled silent install in the ZeroG installer.
  • Loading branch information
Pierre-Luc Paour committed Jul 9, 2004
1 parent 555c2f3 commit 2a7407a
Show file tree
Hide file tree
Showing 20 changed files with 930 additions and 570 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2004-07-09 Pierre-Luc Paour <gallery@paour.com> (1.4-b17)

* When the session expires, GR now attempts to login again.
* Fixed duplicate extra field
* Added a warning when EXIF data is about to be dumped by Java resize
* Enabled silent install in the ZeroG installer.

2004-06-24 Pierre-Luc Paour <gallery@paour.com> (1.4-b16)

* New Album dialog now prevents user from attempting to create
Expand Down
4 changes: 3 additions & 1 deletion com/gallery/GalleryRemote/GRApplet.java
Expand Up @@ -179,7 +179,9 @@ protected AppletInfo getGRAppletInfo() {
info.gallery.cookieLogin = true;

CookieModule.discardAllCookies();
CookieModule.addCookie(new Cookie(cookieName, cookieValue, cookieDomain, cookiePath, null, false));
Cookie cookie = new Cookie(cookieName, cookieValue, cookieDomain, cookiePath, null, false);
Log.log(Log.LEVEL_TRACE, MODULE, "Adding cookie: " + cookie);
CookieModule.addCookie(cookie);

return info;
}
Expand Down
5 changes: 0 additions & 5 deletions com/gallery/GalleryRemote/GRAppletMini.java
Expand Up @@ -14,8 +14,6 @@
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.border.TitledBorder;
import java.applet.Applet;
import java.io.FilePermission;
import java.io.File;
import java.util.Iterator;
import java.util.Arrays;
Expand All @@ -27,9 +25,6 @@
import java.net.URL;
import java.net.MalformedURLException;

import HTTPClient.CookieModule;
import HTTPClient.Cookie;

/**
* Created by IntelliJ IDEA.
* User: paour
Expand Down
14 changes: 0 additions & 14 deletions com/gallery/GalleryRemote/GRAppletSlideshow.java
@@ -1,32 +1,18 @@
package com.gallery.GalleryRemote;

import com.gallery.GalleryRemote.util.DialogUtil;
import com.gallery.GalleryRemote.util.GRI18n;
import com.gallery.GalleryRemote.util.ImageUtils;
import com.gallery.GalleryRemote.model.Album;
import com.gallery.GalleryRemote.model.Gallery;
import com.gallery.GalleryRemote.model.Picture;
import com.gallery.GalleryRemote.prefs.SlideshowPanel;
import com.gallery.GalleryRemote.prefs.PreferenceNames;

import javax.swing.*;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListDataEvent;
import javax.swing.border.TitledBorder;
import java.applet.Applet;
import java.io.FilePermission;
import java.io.File;
import java.util.Iterator;
import java.util.Arrays;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

import HTTPClient.CookieModule;
import HTTPClient.Cookie;

/**
* Created by IntelliJ IDEA.
Expand Down
1 change: 1 addition & 0 deletions com/gallery/GalleryRemote/GalleryComm.java
Expand Up @@ -135,6 +135,7 @@ public void login(StatusUpdate su) {
}

public void logOut() {
Log.log(Log.LEVEL_INFO, MODULE, "Logging out and clearing cookies");
isLoggedIn = false;
CookieModule.discardAllCookies();
}
Expand Down
49 changes: 35 additions & 14 deletions com/gallery/GalleryRemote/GalleryComm2.java
Expand Up @@ -310,7 +310,7 @@ private boolean login() {

if (g.getType() != Gallery.TYPE_STANDALONE && g.getType() != Gallery.TYPE_APPLET) {
try {
requestResponse(null, null, g.getLoginUrl(scriptName), false, su);
requestResponse(null, null, g.getLoginUrl(scriptName), false, su, this);
} catch (IOException ioe) {
Log.logException(Log.LEVEL_ERROR, MODULE, ioe);
Object[] params2 = {ioe.toString()};
Expand Down Expand Up @@ -377,7 +377,7 @@ private boolean login() {
triedLogin = true;

// load and validate the response
Properties p = requestResponse(form_data, g.getGalleryUrl(scriptName), su);
Properties p = requestResponse(form_data, null, g.getGalleryUrl(scriptName), true, su, this, true);
if (GR_STAT_SUCCESS.equals(p.getProperty("status"))
|| GR_STAT_LOGIN_MISSING.equals(p.getProperty("status"))) {
status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "loggedIn"));
Expand Down Expand Up @@ -579,7 +579,7 @@ boolean uploadPicture(Picture p) {
byte[] data = Codecs.mpFormDataEncode(fudgeFormParameters(opts), fudgeParameters(afile), hdrs);

// load and validate the response
Properties props = requestResponse(hdrs, data, g.getGalleryUrl(scriptName), true, su);
Properties props = requestResponse(hdrs, data, g.getGalleryUrl(scriptName), true, su, this);
if (props.getProperty("status").equals(GR_STAT_SUCCESS)) {
status(su, StatusUpdate.LEVEL_UPLOAD_ONE, GRI18n.getString(MODULE, "upSucc"));
return true;
Expand Down Expand Up @@ -663,7 +663,7 @@ private void list20() throws IOException, ModuleException {
form_data = fudgeFormParameters(form_data);

// load and validate the response
Properties p = requestResponse(form_data, su);
Properties p = requestResponse(form_data, su, this);
if (p.getProperty("status").equals(GR_STAT_SUCCESS)) {
ArrayList mAlbumList = new ArrayList();

Expand Down Expand Up @@ -747,7 +747,7 @@ private void list22() throws IOException, ModuleException {
form_data = fudgeFormParameters(form_data);

// load and validate the response
Properties p = requestResponse(form_data, su);
Properties p = requestResponse(form_data, su, this);
if (p.getProperty("status").equals(GR_STAT_SUCCESS)) {
ArrayList albums = new ArrayList();

Expand Down Expand Up @@ -886,6 +886,10 @@ private void list22() throws IOException, ModuleException {
depth++;
}

if ("no".equals(p.getProperty("can_create_root"))) {
rootAlbum.setCanCreateSubAlbum(false);
}

Log.log(Log.LEVEL_TRACE, MODULE, "Ordered " + orderedAlbums.size() + " albums");

status(su, StatusUpdate.LEVEL_BACKGROUND, GRI18n.getString(MODULE, "ftchdAlbms"));
Expand Down Expand Up @@ -924,7 +928,7 @@ void runTask() {
form_data = fudgeFormParameters(form_data);

// load and validate the response
Properties p = requestResponse(form_data, su);
Properties p = requestResponse(form_data, su, this);
if (p.getProperty("status").equals(GR_STAT_SUCCESS)) {
// parse and store the data
int autoResize = Integer.parseInt(p.getProperty("auto_resize"));
Expand Down Expand Up @@ -999,7 +1003,7 @@ void runTask() {
form_data = fudgeFormParameters(form_data);

// load and validate the response
Properties p = requestResponse(form_data, su);
Properties p = requestResponse(form_data, su, this);
if (p.getProperty("status").equals(GR_STAT_SUCCESS)) {
status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "crateAlbmOk"));
newAlbumName = p.getProperty("album_name");
Expand Down Expand Up @@ -1085,7 +1089,7 @@ private void fetch(Album a, String albumName, ArrayList newPictures)
form_data = fudgeFormParameters(form_data);

// load and validate the response
GalleryProperties p = requestResponse(form_data, su);
GalleryProperties p = requestResponse(form_data, su, this);
if (p.getProperty("status").equals(GR_STAT_SUCCESS)) {
// parse and store the data
int numImages = p.getIntProperty("image_count");
Expand All @@ -1095,6 +1099,7 @@ private void fetch(Album a, String albumName, ArrayList newPictures)
if (baseUrl == null) {
Log.log(Log.LEVEL_TRACE, MODULE, "Gallery root, baseurl is null");
} else {
// verify that baseUrl is a valid URL (don't remove)
URL tmpUrl = new URL(baseUrl);
}
} catch (MalformedURLException e) {
Expand Down Expand Up @@ -1230,7 +1235,7 @@ void runTask() {
form_data = fudgeFormParameters(form_data);

// load and validate the response
GalleryProperties p = requestResponse(form_data, su);
GalleryProperties p = requestResponse(form_data, su, this);
if (p.getProperty("status").equals(GR_STAT_SUCCESS)) {
status(su, StatusUpdate.LEVEL_GENERIC,
GRI18n.getString(MODULE, "moveAlbumDone"));
Expand Down Expand Up @@ -1267,19 +1272,23 @@ boolean isTrue(String s) {
/**
* POSTSs a request to the Gallery server with the given form data.
*/
GalleryProperties requestResponse(NVPair form_data[], StatusUpdate su) throws GR2Exception, ModuleException, IOException {
return requestResponse(form_data, null, g.getGalleryUrl(scriptName), true, su);
GalleryProperties requestResponse(NVPair form_data[], StatusUpdate su, GalleryTask task) throws GR2Exception, ModuleException, IOException {
return requestResponse(form_data, null, g.getGalleryUrl(scriptName), true, su, task);
}

GalleryProperties requestResponse(NVPair form_data[], URL galUrl, StatusUpdate su) throws GR2Exception, ModuleException, IOException {
return requestResponse(form_data, null, galUrl, true, su);
GalleryProperties requestResponse(NVPair form_data[], URL galUrl, StatusUpdate su, GalleryTask task) throws GR2Exception, ModuleException, IOException {
return requestResponse(form_data, null, galUrl, true, su, task);
}

GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, boolean checkResult, StatusUpdate su, GalleryTask task) throws GR2Exception, ModuleException, IOException {
return requestResponse(form_data, data, galUrl, checkResult, su, task, false);
}

/**
* POSTSs a request to the Gallery server with the given form data. If data is
* not null, a multipart MIME post is performed.
*/
GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, boolean checkResult, StatusUpdate su) throws GR2Exception, ModuleException, IOException {
GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, boolean checkResult, StatusUpdate su, GalleryComm2.GalleryTask task, boolean alreadyRetried) throws GR2Exception, ModuleException, IOException {
// assemble the URL
String urlPath = galUrl.getFile();
Log.log(Log.LEVEL_TRACE, MODULE, "Url: " + urlPath);
Expand Down Expand Up @@ -1344,6 +1353,18 @@ GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, b
GalleryProperties p = new GalleryProperties();
p.load(new StringBufferInputStream(response));

// catch session expiration problems
if (!alreadyRetried && !g.cookieLogin && g.getUsername() != null
&& ! "1".equals(p.getProperty("debug_user_already_logged_in"))) {
Log.log(Log.LEVEL_INFO, MODULE, "The session seems to have expired: trying to login and retry...");

if (task.login()) {
return requestResponse(form_data, data, galUrl, checkResult, su, task, true);
} else {
Log.log(Log.LEVEL_INFO, MODULE, "Login attempt unsuccessful");
}
}

//mConnection.stop();

su.stopProgress(StatusUpdate.LEVEL_UPLOAD_ONE, GRI18n.getString(MODULE, "addImgOk"));
Expand Down
38 changes: 14 additions & 24 deletions com/gallery/GalleryRemote/MainFrame.java
Expand Up @@ -178,24 +178,6 @@ public void initMainFrame() {
} else {
//Gallery g = new Gallery(jStatusBar);
Applet applet = GalleryRemote._().getApplet();
/*String url = applet.getParameter("gr_url");
String cookieName = applet.getParameter("gr_cookie_name");
String cookieValue = applet.getParameter("gr_cookie_value");
String cookieDomain = applet.getParameter("gr_cookie_domain");
String cookiePath = applet.getParameter("gr_cookie_path");
if (cookieDomain == null || cookieDomain.length() < 1) {
try {
cookieDomain = new URL(url).getHost();
} catch (Exception e) {
Log.logException(Log.LEVEL_ERROR, MODULE, e);
}
}
g.setType(Gallery.TYPE_STANDALONE);
g.setStUrlString(url);
g.addListDataListener(this);
g.cookieLogin = true;*/

GRApplet.AppletInfo info = ((GRApplet) applet).getGRAppletInfo();

Expand Down Expand Up @@ -1156,19 +1138,27 @@ public void keyPressed(KeyEvent e) {
* we should display to prompt the user
* before we do the dangerous thing.
*
* @return one of CANCEL_OPTION, OK_OPTION (from the JOptionPane
* @param gallery
* @return one of CANCEL_OPTION, OK_OPTION (from the JOptionPane
* class). On CANCEL_OPTION you should stop the current
* process. OK_OPTION means that either we are not dirty)
* or that we just saved for the user.
*/
private int saveOnPermission(String promptMessageID) {
private int saveOnPermission(String promptMessageID, Gallery gallery) {
if (!m_isDirty) {
return (JOptionPane.OK_OPTION);
}

int response = JOptionPane.showConfirmDialog(
String prompt;
if (gallery != null) {
prompt = GRI18n.getString(MODULE, promptMessageID, new Object[] {gallery.toString() });
} else {
prompt = GRI18n.getString(MODULE, promptMessageID);
}

int response = JOptionPane.showConfirmDialog(
this,
GRI18n.getString(MODULE, promptMessageID),
prompt,
lastOpenedFile == null ? GRI18n.getString(MODULE, "noTitleHeader")
: lastOpenedFile.getName(),
JOptionPane.YES_NO_CANCEL_OPTION);
Expand Down Expand Up @@ -1262,7 +1252,7 @@ public void actionPerformed(ActionEvent e) {

// We're currently logged in, but we might be dirty
// so ask the user if it's OK to log out.
int response = saveOnPermission("logoutQuestion");
int response = saveOnPermission("logoutQuestion", getCurrentGallery());

if (JOptionPane.CANCEL_OPTION == response) {
return;
Expand Down Expand Up @@ -1552,7 +1542,7 @@ private void openState(String fileToOpen) {
}

// Before we change galleries, ask them if they want to save.
int response = saveOnPermission("OK_toSaveBeforeClose");
int response = saveOnPermission("OK_toSaveBeforeClose", null);

if (JOptionPane.CANCEL_OPTION == response) {
return;
Expand Down
4 changes: 2 additions & 2 deletions com/gallery/GalleryRemote/PictureInspector.java
Expand Up @@ -212,9 +212,9 @@ private void jbInit() {
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
add(jDeleteButton, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 0, 0), 0, 0));
this.add(jScrollPane1, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
add(jScrollPane1, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
this.add(jScrollPane2, new GridBagConstraints(1, 7, 1, 1, 1.0, 1.0
add(jScrollPane2, new GridBagConstraints(1, 7, 1, 1, 1.0, 1.0
, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0));
jScrollPane1.getViewport().add(jPath, null);
jScrollPane2.getViewport().add(jCaption, null);
Expand Down
4 changes: 2 additions & 2 deletions com/gallery/GalleryRemote/model/Album.java
Expand Up @@ -92,7 +92,7 @@ public class Album extends GalleryItem implements ListModel, Serializable, Prefe
transient private Integer albumDepth;
transient private boolean suppressEvents = false;

public static List extraFieldsNoShow = Arrays.asList(new String[]{GRI18n.getString(MODULE, "upDate"), GRI18n.getString(MODULE, "captDate")});
public static List extraFieldsNoShow = Arrays.asList(new String[]{"Capture date", "Upload date", "Description"});


public Album(Gallery gallery) {
Expand Down Expand Up @@ -627,7 +627,7 @@ public void setExtraFieldsString(String extraFieldsString) {
while (st.hasMoreTokens()) {
String name = st.nextToken();

if (!extraFieldsNoShow.contains(name)) {
if (!extraFieldsNoShow.contains(name) && !extraFields.contains(name)) {
extraFields.add(name);
}
}
Expand Down

0 comments on commit 2a7407a

Please sign in to comment.