Log.log(Log.LEVEL_TRACE, MODULE, "Trying protocol 2.5 for " + url);  String urlPath2_5 = urlPath + ((urlPath.endsWith("/")) ? GalleryComm2_5.SCRIPT_NAME : "/" + GalleryComm2_5.SCRIPT_NAME); if (tryComm(su, mConnection, urlPath2_5)) { Log.log(Log.LEVEL_TRACE, MODULE, "Server has protocol 2.5"); return new GalleryComm2_5(g); }
	public static GalleryComm getCommInstance(StatusUpdate su, URL url, Gallery g) {		try {			GalleryProperties p = GalleryRemote._().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.LEVEL_TRACE, MODULE, "Setting proxy to " + hostname + ":" + port);				HTTPConnection.setProxyServer(hostname, port);				if (username != null && username.length() > 0) {					String password = p.getBase64Property(PROXY_PASSWORD);					Log.log(Log.LEVEL_TRACE, MODULE, "Setting proxy auth to " + username + ":" + password);					AuthorizationInfo.addBasicAuthorization(hostname, port, "",							username, password);				}			} else {				HTTPConnection.setProxyServer(null, 0);			}			// create a connection			HTTPConnection mConnection = new HTTPConnection(url);			if (g.getType() == Gallery.TYPE_STANDALONE) {				// assemble the URL				String urlPath = url.getFile();				Log.log(Log.LEVEL_TRACE, MODULE, "Trying protocol 2 for " + url);				// Test GalleryComm2				String urlPath2 = urlPath + ((urlPath.endsWith("/")) ? GalleryComm2.SCRIPT_NAME : "/" + GalleryComm2.SCRIPT_NAME);				if (tryComm(su, mConnection, urlPath2)) {					Log.log(Log.LEVEL_TRACE, MODULE, "Server has protocol 2");					return new GalleryComm2(g);				}				Log.log(Log.LEVEL_TRACE, MODULE, "Trying protocol 1 for " + url);				// Test GalleryComm1				// BUT: only if first try was not status code 401 = authorization failure				String scriptName = "gallery_remote.php";				String urlPath1 = urlPath + ((urlPath.endsWith("/")) ? scriptName : "/" + scriptName);				if (lastRespCode != 401 && tryComm(su, mConnection, urlPath1)) {					Log.log(Log.LEVEL_TRACE, MODULE, "Server has protocol 1");					// todo: Alert, we don't support protocol 1 any more.				}			} else {				// if Gallery is embedded, only support protocol 2				return new GalleryComm2(g);			}		} catch (HTTPClient.ProtocolNotSuppException e) {			Log.logException(Log.LEVEL_ERROR, MODULE, e);		}		return null;	}