Skip to content

Commit

Permalink
Bumped GalleryComm2 protocol version to 2.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Luc Paour committed Nov 4, 2002
1 parent 55887e3 commit def9417
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 28 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -2,6 +2,7 @@

* Added support for the "new-album" command to GalleryComm2.
* Corrected a small path problem in ImageUtils.
* Bumped GalleryComm2 protocol version to 2.1.

2002-10-28 Pierre-Luc Paour <gallery@paour.com> (1.0-b11)

Expand Down
12 changes: 12 additions & 0 deletions com/gallery/GalleryRemote/GalleryComm2.java
Expand Up @@ -83,6 +83,11 @@ public class GalleryComm2 extends GalleryComm implements GalleryComm2Consts,
*/
protected int serverMinorVersion = 0;

/**
* The capabilities for 2.1
*/
private static int[] capabilities1;


/* -------------------------------------------------------------------------
* STATIC INITIALIZATON
Expand Down Expand Up @@ -122,6 +127,8 @@ public GalleryComm2( Gallery g ) {
* protocol is, we'll be able to add more capabilities, such as
* CAPA_NEW_ALBUM (since 2.1) */
capabilities = new int[] { CAPA_UPLOAD_FILES, CAPA_FETCH_ALBUMS, CAPA_UPLOAD_CAPTION,
CAPA_FETCH_HIERARCHICAL, CAPA_ALBUM_INFO };
capabilities1 = new int[] { CAPA_UPLOAD_FILES, CAPA_FETCH_ALBUMS, CAPA_UPLOAD_CAPTION,
CAPA_FETCH_HIERARCHICAL, CAPA_ALBUM_INFO, CAPA_NEW_ALBUM };
Arrays.sort(capabilities);
}
Expand Down Expand Up @@ -346,6 +353,11 @@ private boolean login() {
serverMinorVersion = Integer.parseInt( serverVersion.substring( i+1 ) );

Log.log(Log.TRACE, MODULE, "Server minor version: " + serverMinorVersion);

if (serverMinorVersion >= 1) {
// we have more than the 2.0 capabilities, we have 2.1 capabilities.
capabilities = capabilities1;
}
} catch (Exception e) {
Log.log( Log.ERROR, MODULE, "Malformed server_version: " + p.getProperty( "server_version" ) );
Log.logException(Log.ERROR, MODULE, e);
Expand Down
2 changes: 1 addition & 1 deletion com/gallery/GalleryRemote/GalleryComm2Consts.java
Expand Up @@ -38,7 +38,7 @@ public interface GalleryComm2Consts {
/**
* Protocol version string.
*/
public static final String PROTOCOL_VERSION = "2.0";
public static final String PROTOCOL_VERSION = "2.1";

/**
* Remote scriptname that provides version 2 of the protocol on the server.
Expand Down
19 changes: 17 additions & 2 deletions com/gallery/GalleryRemote/NewAlbumDialog.java
Expand Up @@ -43,6 +43,7 @@ public class NewAlbumDialog extends javax.swing.JDialog

Gallery gallery = null;
Album defaultAlbum = null;
Album rootAlbum = null;

GridBagLayout gridBagLayout1 = new GridBagLayout();
JLabel jLabel2 = new JLabel();
Expand Down Expand Up @@ -96,7 +97,12 @@ private void jbInit()
this.setModal( true );
this.setTitle( "New Album" );

album = new JComboBox(new Vector(gallery.getAlbumList()));
Vector albums = new Vector(gallery.getAlbumList());
rootAlbum = new Album();
rootAlbum.setGallery(gallery);
rootAlbum.setTitle("Gallery main page");
albums.add(0, rootAlbum);
album = new JComboBox(albums);
album.setFont( new java.awt.Font( "SansSerif", 0, 11 ) );
album.setSelectedItem(defaultAlbum);
cancel.setText( "Cancel" );
Expand Down Expand Up @@ -169,8 +175,17 @@ public void actionPerformed( ActionEvent e ) {
a.setName(name.getText());
a.setTitle(title.getText());
a.setCaption(description.getText());
a.setParentAlbum((Album) album.getSelectedItem());

Album selectedAlbum = (Album) album.getSelectedItem();
if (selectedAlbum == rootAlbum) {
a.setParentAlbum(null);
} else {
a.setParentAlbum(selectedAlbum);
}

gallery.newAlbum(a, (StatusUpdate) this.getOwner());

setVisible(false);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions com/gallery/GalleryRemote/model/Gallery.java
Expand Up @@ -130,7 +130,7 @@ public void setUrl( URL url ) {
*@param username The new username value
*/
public void setUsername( String username ) {
Log.log(Log.TRACE, MODULE, "setusername: " + username);
//Log.log(Log.TRACE, MODULE, "setusername: " + username);
if ( username != null && username.length() > 0
&& ! username.equals( this.username ) ) {

Expand All @@ -147,7 +147,7 @@ public void setUsername( String username ) {
*@param password The new password value
*/
public void setPassword( String password ) {
Log.log(Log.TRACE, MODULE, "setpassword: " + password);
//Log.log(Log.TRACE, MODULE, "setpassword: " + password);
if ( password != null && password.length() > 0
&& ! password.equals( this.password ) ) {

Expand Down
6 changes: 3 additions & 3 deletions defaults.properties
Expand Up @@ -5,7 +5,7 @@
# You can override these values in your remote.properties file

#
# --- Protocol version (experimental, temporary ---
# --- Protocol version (experimental, temporary) ---
#

# soon, GR will be able to dynamically sense which version
Expand Down Expand Up @@ -100,6 +100,6 @@ updateUrlBeta=http://gallery.sourceforge.net/gallery_remote_version_check_beta.p
#
# --- Do not edit below this line ---
#
version=1.0b10
releaseDate=2002/10/19
version=1.0b11
releaseDate=2002/11/04
aboutText=Gallery Remote\n \n \nA part of the Gallery Open-Source Project\nhttp://gallery.sourceforge.net\n \n \nMaintained by Pierre-Luc Paour\n \nInitial version by Chris Smith\n \n \nContributors:\n \nDolan Halbrook\nTim Miller
47 changes: 27 additions & 20 deletions gal_remote_proto-2.html
@@ -1,7 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Gallery Remote Protocol version 2</title>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Gallery Remote Protocol version 2</title>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
h1 { font-family: sans-serif; font-size: 17pt; font-weight: bold; }
Expand All @@ -20,15 +18,15 @@
td { border-style: solid; border-width: 1px; border-color: black; margin: 5px; }

img { border-width: 0px; }
</style>
</head>
</style></head>

<body>

<h1>Gallery Remote Protocol version 2</h1>

<p><cite>Tim Miller</cite> &lt;<a href="mailto:tim_miller at users.sourceforge.net">tim_miller
<p><cite>Tim Miller</cite> &lt;<a href="mailto:tim_miller%20at%20users.sourceforge.net">tim_miller
at users dot sourceforge dot net</a>&gt;<br>
<cite>Pierre-Luc Paour</cite> &lt;<a href="mailto:paour at users.sourceforge.net">paour
<cite>Pierre-Luc Paour</cite> &lt;<a href="mailto:paour%20at%20users.sourceforge.net">paour
at users dot sourceforge dot net</a>&gt;</p>

<h2><a name="toc">Contents</a></h2>
Expand Down Expand Up @@ -92,9 +90,14 @@ <h2><a name="overview">2. Overview</a></h2>

<h2><a name="interaction">3. Client-Server Interaction</a></h2>

<p>All client-server interaction follows the standard HTTP model. The client initiates all interactions with a <em><a href="#requests">request</a></em>. The server always responds with one <em><a href="#responses">response</a></em>. The data format of each request is HTTP form-data key/value pairs. The data format of each response is plain text key/value pairs.</p>
<p>All client-server interaction follows the standard HTTP model. The client initiates all interactions with a <em><a href="#requests">request</a></em>. The server always responds with one <em><a href="#responses">response</a></em>.
The data format of each request is HTTP form-data key/value pairs. The
data format of each response is plain text key/value pairs.</p>

<p>Each request specifies a <em><a href="#commands">command</a></em> value (and possibly some corresponding parameters) which determines the content of the response. Command-specific responses are defined in the context of each <em>command</em> below).</p>
<p>Each request specifies a <em><a href="#commands">command</a></em> value
(and possibly some corresponding parameters) which determines the content
of the response. Command-specific responses are defined in the context of
each <em>command</em> below).</p>

<hr>

Expand All @@ -120,19 +123,21 @@ <h2><a name="requests">4. Requests</a></h2>
version number. Different major versions of the protocol use different <samp>gallery_remote</samp><em>maj</em><samp>.php</samp>
files. Each such file may provide support for various minor versions.</p>

<p>Each command is described in the <a href="#commands">Commands</a> section below. After a brief description of the command, template form data appears and the contents of the server's response is described.</p>
<p>Each command is described in the <a href="#commands">Commands</a> section
below. After a brief description of the command, template form data appears
and the contents of the server's response is described.</p>

<hr>

<h2><a name="responses">5. Responses</a></h2>

<p>After the client POSTs a request, the server sends a <em>response</em> to the client. The format of the response is a key/value format compatible with the Java "<a href="http://java.sun.com/j2se/1.4.1/docs/api/java/util/Properties.html">Properties</a>" stream format.<p>
<p>After the client POSTs a request, the server sends a <em>response</em> to the client. The format of the response is a key/value format compatible with the Java "<a href="http://java.sun.com/j2se/1.4.1/docs/api/java/util/Properties.html">Properties</a>" stream format.</p><p>

<p>In a nutshell: lines beginning with a <samp>#</samp> character are ignored. The text before the first <samp>=</samp> character is the <em>key</em>. The remainder of the text after the <samp>=</samp> until the end-of-line character(s) is the <em>value</em>.</p>
</p><p>In a nutshell: lines beginning with a <samp>#</samp> character are ignored. The text before the first <samp>=</samp> character is the <em>key</em>. The remainder of the text after the <samp>=</samp> until the end-of-line character(s) is the <em>value</em>.</p>

<p>Each response must begin with the text <samp>#__GR2PROTO__</samp>.

<p>Each response must contain at least the keys: <samp>status</samp> and <samp>status_text</samp>.</p>
</p><p>Each response must contain at least the keys: <samp>status</samp> and <samp>status_text</samp>.</p>

<p>The value associated with the <samp>status</samp> key is an integer status code
(the codes are defined in <a href="#appendix_a">Appendix A</a>. For example, if the
Expand All @@ -158,7 +163,7 @@ <h3><a name="login"><samp>login</samp></a> command</h3>
<li>
<h4>Context</h4>
<p>A request with the <samp>login</samp> command may be made at any time
&mdash; there are no prerequisites.</p>
&#8212; there are no prerequisites.</p>
</li>
<li>
<h4>Form Data</h4>
Expand Down Expand Up @@ -321,7 +326,7 @@ <h4>Results</h4>
</ul>
</li>
<li>
<h3><a name="new-album" id="new-album"><samp>new-album</samp></a> command [since 2.0]</h3>
<h3><a name="new-album" id="new-album"><samp>new-album</samp></a> command [since 2.1]</h3>
<p>
This command creates a new album on the server.
</p>
Expand All @@ -337,7 +342,7 @@ <h4>Context</h4>
<h4>Form Data</h4>
<p>
<samp>cmd=album-properties<br>
protocol_version=2.0<br>
protocol_version=2.1<br>
set_albumName=</samp><em>parent-album-name</em> or empty to create at top level<br>
<samp>newAlbumName=</samp><em>album-name</em><br>
<samp>newAlbumTitle=</samp><em>album-title</em><br>
Expand Down Expand Up @@ -384,7 +389,9 @@ <h2><a name="appendix_a">Appendix A: Response Status Codes</a></h2>
</tr>
</thead>
<tbody>
<tr><td>GR_STAT_SUCCESS</td><td>0</td><td>The command the client sent in the request completed successfully. The data (if any) in the response should be considered valid.</td></tr>
<tr><td>GR_STAT_SUCCESS</td><td>0</td><td>The command the client sent in
the request completed successfully. The data (if any) in the response should
be considered valid.</td></tr>

<tr><td>GR_STAT_PROTO_MAJ_VER_INVAL</td><td>101</td><td>The protocol major version the client is using is not supported.</td></tr>
<tr><td>GR_STAT_PROTO_MIN_VER_INVAL</td><td>102</td><td>The protocol minor version the client is using is not supported.</td></tr>
Expand All @@ -407,5 +414,5 @@ <h2><a name="appendix_a">Appendix A: Response Status Codes</a></h2>
<hr>
<p><samp class="weasel">$Id$</samp></p>

</body>
</html>
<br>
</body></html>

0 comments on commit def9417

Please sign in to comment.