if (password == null || password.length() == 0) { password = (String)JOptionPane.showInputDialog( (JFrame) su,
if (username != null && (password == null || password.length() == 0)) { password = (String) JOptionPane.showInputDialog( GalleryRemote.getInstance().mainFrame,
		private boolean login() {            Object [] params = {g.toString()};			status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "logIn", params));			if (g.getType() != Gallery.TYPE_STANDALONE) {				try {					requestResponse( null, null, g.getLoginUrl(SCRIPT_NAME), false );				} catch (IOException ioe) {					Log.logException(Log.LEVEL_ERROR, MODULE, ioe);                    Object [] params2 = {ioe.toString() };					error(su, GRI18n.getString(MODULE, "error", params2));				} catch (ModuleException me) {					Log.logException(Log.LEVEL_ERROR, MODULE, me);                    Object [] params2 = {me.getMessage()};					error(su, GRI18n.getString(MODULE, "errReq" , params2));				}			}			// setup protocol parameters			String username = g.getUsername();			String password = g.getPassword();			if (username == null || username.length() == 0) {				username = (String)JOptionPane.showInputDialog(                    (JFrame) su,                    GRI18n.getString(MODULE, "usernameLbl"),                    GRI18n.getString(MODULE, "username"),                    JOptionPane.PLAIN_MESSAGE,                    null,                    null,                    null);				g.setUsername(username);			}			if (password == null || password.length() == 0) {				password = (String)JOptionPane.showInputDialog(                    (JFrame) su,                    GRI18n.getString(MODULE, "passwdLbl"),                    GRI18n.getString(MODULE, "passwd"),                    JOptionPane.PLAIN_MESSAGE,                    null,                    null,                    null);				g.setPassword(password);			}			NVPair form_data[] = {				new NVPair("cmd", "login"),				new NVPair("protocol_version", PROTOCOL_VERSION),				new NVPair("uname", username),				new NVPair("password", password)			};			Log.log(Log.LEVEL_TRACE, MODULE, "login parameters: " + Arrays.asList(form_data));			// make the request			try	{				// load and validate the response				Properties p = requestResponse( form_data, g.getGalleryUrl(SCRIPT_NAME) );				if ( GR_STAT_SUCCESS.equals( p.getProperty( "status" ) ) ) {					status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "loggedIn"));					try {						String serverVersion = p.getProperty( "server_version" );						int i = serverVersion.indexOf( "." );						serverMinorVersion = Integer.parseInt( serverVersion.substring( i+1 ) );						Log.log(Log.LEVEL_TRACE, MODULE, "Server minor version: " + serverMinorVersion);						handleCapabilities();					} catch (Exception e) {						Log.log( Log.LEVEL_ERROR, MODULE, "Malformed server_version: " + p.getProperty( "server_version" ) );						Log.logException(Log.LEVEL_ERROR, MODULE, e);					}					return true;				} else if (GR_STAT_PASSWD_WRONG.equals(p.getProperty("status"))) {					error(su, GRI18n.getString(MODULE, "usrpwdErr"));					return false;				} else {                    Object [] params2 = {p.getProperty( "status_text" ) };					error(su, GRI18n.getString(MODULE, "loginErr", params2));					return false;				}			} catch ( GR2Exception gr2e ) {				Log.logException(Log.LEVEL_ERROR, MODULE, gr2e );                Object [] params2 = {gr2e.getMessage() };				error(su, GRI18n.getString(MODULE, "error", params2));			} catch (IOException ioe) {				Log.logException(Log.LEVEL_ERROR, MODULE, ioe);                Object [] params2 = {ioe.toString() };				error(su, GRI18n.getString(MODULE, "error", params2));			} catch (ModuleException me) {				Log.logException(Log.LEVEL_ERROR, MODULE, me);                Object [] params2 = {me.getMessage() };				error(su, GRI18n.getString(MODULE, "errReq", params2));			}			return false;		}