Skip to content

Commit

Permalink
2006-02-10 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b11)
Browse files Browse the repository at this point in the history
	* Fixed EXIF handling broken in b10
	* Allows forcing the encoding when connecting to a G1 server.
	  Add forceProtocolEncoding.n=encoding in the GR preferences,
	  where n is associated with your Gallery URL and encoding
	  is the standard name of the encoding.
  • Loading branch information
Pierre-Luc Paour committed Feb 10, 2006
1 parent 6c88927 commit c4820c5
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 81 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
2006-02-10 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b11)

* Fixed EXIF handling broken in b10
* Allows forcing the encoding when connecting to a G1 server.
Add forceProtocolEncoding.n=encoding in the GR preferences,
where n is associated with your Gallery URL and encoding
is the standard name of the encoding.

2006-01-16 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b10)

* Also look for image caption in TAG_USER_COMMENT
Expand Down
146 changes: 78 additions & 68 deletions HTTPClient/HTTPConnection.java
Expand Up @@ -324,6 +324,8 @@ public class HTTPConnection implements GlobalConstants, HTTPClientModuleConstant
/** JSSE's socket factory */
private Object sslFactory = null;

private String forceCharset = null;


static
{
Expand Down Expand Up @@ -3863,95 +3865,103 @@ public String toString()
(getPort() != URI.defaultPort(getProtocol()) ? ":" + getPort() : "");
}

public String getForceCharset() {
return forceCharset;
}

private class EstablishConnection extends Thread
{
String actual_host;
int actual_port;
IOException exception;
Socket sock;
SocksClient Socks_client;
boolean close;
public void setForceCharset(String forceCharset) {
this.forceCharset = forceCharset;
}


EstablishConnection(String host, int port, SocksClient socks)
private class EstablishConnection extends Thread
{
super("EstablishConnection (" + host + ":" + port + ")");
try { setDaemon(true); }
catch (SecurityException se) { } // Oh well...
String actual_host;
int actual_port;
IOException exception;
Socket sock;
SocksClient Socks_client;
boolean close;

actual_host = host;
actual_port = port;
Socks_client = socks;

exception = null;
sock = null;
close = false;
}
EstablishConnection(String host, int port, SocksClient socks)
{
super("EstablishConnection (" + host + ":" + port + ")");
try { setDaemon(true); }
catch (SecurityException se) { } // Oh well...

actual_host = host;
actual_port = port;
Socks_client = socks;

public void run()
{
try
{
if (Socks_client != null)
sock = Socks_client.getSocket(actual_host, actual_port);
else
exception = null;
sock = null;
close = false;
}


public void run()
{
// try all A records
InetAddress[] addr_list = InetAddress.getAllByName(actual_host);
for (int idx=0; idx<addr_list.length; idx++)
{
try
try
{
if (Socks_client != null)
sock = Socks_client.getSocket(actual_host, actual_port);
else
{
if (LocalAddr == null)
sock = new Socket(addr_list[idx], actual_port);
else
sock = new Socket(addr_list[idx], actual_port,
LocalAddr, LocalPort);
break; // success
}
catch (SocketException se)
// try all A records
InetAddress[] addr_list = InetAddress.getAllByName(actual_host);
for (int idx=0; idx<addr_list.length; idx++)
{
if (idx == addr_list.length-1 || close)
throw se; // we tried them all
try
{
if (LocalAddr == null)
sock = new Socket(addr_list[idx], actual_port);
else
sock = new Socket(addr_list[idx], actual_port,
LocalAddr, LocalPort);
break; // success
}
catch (SocketException se)
{
if (idx == addr_list.length-1 || close)
throw se; // we tried them all
}
}
}
}
}
}
catch (IOException ioe)
{
exception = ioe;
}

if (close && sock != null)
{
try
{ sock.close(); }
catch (IOException ioe)
{ }
sock = null;
}
}
{
exception = ioe;
}

if (close && sock != null)
{
try
{ sock.close(); }
catch (IOException ioe)
{ }
sock = null;
}
}

IOException getException()
{
return exception;
}

IOException getException()
{
return exception;
}

Socket getSocket()
{
return sock;
}

Socket getSocket()
{
return sock;
}

void forget()
{
close = true;

void forget()
{
close = true;
}
}
}


/**
Expand Down
6 changes: 4 additions & 2 deletions HTTPClient/HTTPResponse.java
Expand Up @@ -538,7 +538,10 @@ public synchronized String getText()
if (ct == null || !ct.toLowerCase().startsWith("text/"))
throw new IOException("Content-Type `" + ct + "' is not a text type");

String charset = Util.getParameter("charset", ct);
String charset = request.getConnection().getForceCharset();

if (charset == null)
Util.getParameter("charset", ct);
if (charset == null)
charset = "ISO-8859-1";

Expand Down Expand Up @@ -880,7 +883,6 @@ private synchronized void getTrailers() throws IOException, ModuleException
* Reads the response data received. Does not return until either
* Content-Length bytes have been read or EOF is reached.
*
* @inp the input stream from which to read the data
* @exception IOException if any read on the input stream fails
*/
private void readResponseData(InputStream inp)
Expand Down
8 changes: 3 additions & 5 deletions com/gallery/GalleryRemote/GRAppletMini.java
Expand Up @@ -358,15 +358,13 @@ public void valueChanged(ListSelectionEvent e) {
}

public void g2Feedback(String method, Object[] params) {
//if (gallery.galleryVersion == 2) {
if (gallery.galleryVersion == 2) {
try {
Log.log(Log.LEVEL_TRACE, MODULE, "Invoking Javascript method '" + method + "' with " + params);
call.invoke(window, new Object[] {method, params});
} catch (IllegalAccessException e) {
Log.logException(Log.LEVEL_ERROR, MODULE, e);
} catch (InvocationTargetException e) {
} catch (Throwable e) {
Log.logException(Log.LEVEL_ERROR, MODULE, e);
}
//}
}
}
}
6 changes: 5 additions & 1 deletion com/gallery/GalleryRemote/GalleryComm2.java
Expand Up @@ -1322,7 +1322,7 @@ GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, b
}

/**
* POSTSs a request to the Gallery server with the given form data. If data is
* POSTs 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, GalleryComm2.GalleryTask task, boolean alreadyRetried) throws GR2Exception, ModuleException, IOException {
Expand All @@ -1342,6 +1342,10 @@ GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, b
mConnection.setDefaultHeaders(new NVPair[] { new NVPair("User-Agent", userAgent) });
}

if (g.getForceProtocolEncoding() != null) {
mConnection.setForceCharset(g.getForceProtocolEncoding());
}

// Valiant thinks this will solve the sometines-reported problem with
// uploading large numbers of files.
NVPair[] def_hdrs = { new NVPair("Connection", "close") };
Expand Down
10 changes: 10 additions & 0 deletions com/gallery/GalleryRemote/model/Gallery.java
Expand Up @@ -69,6 +69,7 @@ public class Gallery extends DefaultTreeModel implements Serializable, Preferenc
transient public boolean cookieLogin = false;
transient public int galleryVersion = 1;
transient public int forceGalleryVersion = 0;
transient public String forceProtocolEncoding = null;
transient public int resizeJpegQuality = -1;

public static String types[] = new String[]{STANDALONE, POSTNUKE, PHPNUKE, GEEKLOG};
Expand Down Expand Up @@ -675,6 +676,7 @@ public static Gallery readFromProperties(GalleryProperties p, int prefsIndex, St
g.setAlias(p.getProperty(ALIAS + prefsIndex));

g.forceGalleryVersion = p.getIntProperty(FORCE_GALLERY_VERSION + prefsIndex, 0);
g.forceProtocolEncoding = p.getProperty(FORCE_PROTOCOL_ENCODING + prefsIndex);
g.resizeJpegQuality = p.getIntProperty(RESIZE_JPEG_QUALITY + prefsIndex, -1);

g.setPrefsIndex(prefsIndex);
Expand Down Expand Up @@ -921,6 +923,14 @@ public int getResizeJpegQuality() {
return resizeJpegQuality;
}

public String getForceProtocolEncoding() {
return forceProtocolEncoding;
}

public void setForceProtocolEncoding(String forceProtocolEncoding) {
this.forceProtocolEncoding = forceProtocolEncoding;
}

class TreeEnumeration implements Enumeration {
protected TreeNode root;
protected Enumeration children;
Expand Down
1 change: 1 addition & 0 deletions com/gallery/GalleryRemote/prefs/PreferenceNames.java
Expand Up @@ -50,6 +50,7 @@ public interface PreferenceNames {
public static final String GL_LOGIN_URL = "glLoginUrl.";
public static final String ALIAS = "alias.";
public static final String FORCE_GALLERY_VERSION = "forceGalleryVersion.";
public static final String FORCE_PROTOCOL_ENCODING = "forceProtocolEncoding.";
public static final String RESIZE_JPEG_QUALITY = "resizeJpegQuality.";

// Proxy panel
Expand Down
6 changes: 3 additions & 3 deletions com/gallery/GalleryRemote/util/ExifImageUtils.java
Expand Up @@ -74,21 +74,21 @@ public static Date getCreationDate(Directory exifDirectory, Directory iptcDirect
}

public static String getCaption(Directory exifDirectory, Directory iptcDirectory, String filename) {
String caption = exifDirectory.getString(ExifDirectory.TAG_IMAGE_DESCRIPTION).trim();
String caption = exifDirectory.getString(ExifDirectory.TAG_IMAGE_DESCRIPTION);

if (caption != null && caption.length() != 0) {
Log.log(Log.LEVEL_TRACE, MODULE, "Picture " + filename + " TAG_IMAGE_DESCRIPTION: " + caption);
return caption.trim();
}

caption = exifDirectory.getString(ExifDirectory.TAG_USER_COMMENT).trim();
caption = exifDirectory.getString(ExifDirectory.TAG_USER_COMMENT);

if (caption != null && caption.length() !=0) {
Log.log(Log.LEVEL_TRACE, MODULE, "Picture " + filename + " TAG_USER_COMMENT: " + caption);
return caption.trim();
}

caption = iptcDirectory.getString(IptcDirectory.TAG_CAPTION).trim();
caption = iptcDirectory.getString(IptcDirectory.TAG_CAPTION);

if (caption != null && caption.length() !=0) {
Log.log(Log.LEVEL_TRACE, MODULE, "Picture " + filename + " IPTC DESCRIPTION: " + caption);
Expand Down
1 change: 1 addition & 0 deletions com/gallery/GalleryRemote/util/ImageUtils.java
Expand Up @@ -1055,6 +1055,7 @@ public static ExifData getExifData(String filename) {
return (ExifData) m.invoke(null, new Object[]{filename});
} catch (Throwable e) {
Log.log(Log.LEVEL_ERROR, MODULE, "Exif library is not installed.");
//Log.logException(Log.LEVEL_ERROR, MODULE, e);
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions defaults.properties
Expand Up @@ -308,6 +308,6 @@ updateUrlBeta=http://gallery.sourceforge.net/gallery_remote_version_check_beta.p
#
# --- Do not edit below this line ---
#
version=1.5.1-b10
releaseDate=2006/01/16
version=1.5.1-b11
releaseDate=2006/02/10
aboutText=Gallery Remote\n \n \nA part of the Gallery Open-Source Project\nhttp://gallery.sourceforge.net\n \n \nMaintained by:\n \nPierre-Luc Paour\n \n \nInitial version by Chris Smith\n \n \nContributors:\n \nTim Miller\nDolan Halbrook\nMarkus Cozowicz\nScott Gartner\nAmedeo Paglione\nChris Schwerdt\nSeth Ladd\n \n \nArtwork by Ross A. Reyman\n \n \nBundled software:\n \nImageMagick\nJava look and feel Graphics Repository icons\njpegtran, Guido Vollbeding's version\nMetadataExtractor

0 comments on commit c4820c5

Please sign in to comment.