Skip to content

Commit

Permalink
Added proxy support in the preferences.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Luc Paour committed Jun 12, 2003
1 parent adc1c1f commit 5616a9e
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions com/gallery/GalleryRemote/GalleryComm.java
Expand Up @@ -25,17 +25,12 @@
import java.net.URL;
import java.net.UnknownHostException;

import HTTPClient.Cookie;
import HTTPClient.CookieModule;
import HTTPClient.CookiePolicyHandler;
import HTTPClient.HTTPConnection;
import HTTPClient.HTTPResponse;
import HTTPClient.ModuleException;
import HTTPClient.RoRequest;
import HTTPClient.RoResponse;
import HTTPClient.*;

import com.gallery.GalleryRemote.model.Album;
import com.gallery.GalleryRemote.model.Gallery;
import com.gallery.GalleryRemote.prefs.GalleryProperties;
import com.gallery.GalleryRemote.prefs.PreferenceNames;

/**
* This interface is a temporary mechanism to let us use version
Expand All @@ -46,7 +41,7 @@
*
* @author <a href="mailto:tim_miller@users.sourceforge.net">Tim Miller</a>
*/
public abstract class GalleryComm {
public abstract class GalleryComm implements PreferenceNames {
private static final String MODULE = "GalComm";
int[] capabilities = null;
private static int lastRespCode = 0;
Expand Down Expand Up @@ -142,7 +137,27 @@ public static boolean wasAuthFailure () {

public static GalleryComm getCommInstance(StatusUpdate su, URL url, Gallery g) {
try {
// create a connection
GalleryProperties p = GalleryRemote.getInstance().properties;
// set proxy info
if (p.getBooleanProperty(USE_PROXY)) {
String hostname = p.getProperty(PROXY_HOST);
int port = 80;
try { port = p.getIntProperty(PROXY_PORT); } catch (NumberFormatException e) {}
String username = p.getProperty(PROXY_USERNAME);

Log.log(Log.TRACE, MODULE, "Setting proxy to " + hostname + ":" + port);

HTTPConnection.setProxyServer(hostname, port);

if (username != null && username.length() > 0) {
AuthorizationInfo.addBasicAuthorization(hostname, port, "",
username, p.getBase64Property(PROXY_PASSWORD));
}
} else {
HTTPConnection.setProxyServer(null, 0);
}

// create a connection
HTTPConnection mConnection = new HTTPConnection( url );

if (g.getType() == Gallery.TYPE_STANDALONE) {
Expand Down

0 comments on commit 5616a9e

Please sign in to comment.