Skip to content

Commit

Permalink
Added code for reporting a log in failure
Browse files Browse the repository at this point in the history
  • Loading branch information
KlasJoensson authored and egonw committed Aug 11, 2012
1 parent e432a13 commit 5c897fe
Showing 1 changed file with 14 additions and 7 deletions.
Expand Up @@ -24,25 +24,30 @@ public OpenToxLogInOutListener(IUserManager userManager) {
}

@Override
public void receiveUserManagerEvent(UserManagerEvent event) {
public boolean receiveUserManagerEvent(UserManagerEvent event) {
System.out.println("Received event: " + event);
boolean eventSucceeded = true;
switch (event) {
case LOGIN:
updateOnLogin();
eventSucceeded = updateOnLogin();
break;
case LOGOUT:
updateOnLogout();
break;
case UPDATE:
update();
eventSucceeded = update();
break;
default:
break;
}

return eventSucceeded;
}

private void updateOnLogin() {
private boolean updateOnLogin() {
System.out.println("Logging in on OpenTox...");
System.out.println("Keyring User is logged in: " + userManager.isLoggedIn());
boolean loginSucceeded = false;
if (userManager.isLoggedIn() && Activator.getToken() == null) {
try {
System.out.println("Logging in on OpenTox: ");
Expand All @@ -53,7 +58,7 @@ private void updateOnLogin() {
String account = otssoAccounts.get(0);
System.out.println(" user: " + userManager.getProperty(account, "username"));
System.out.println(" pwd: " + userManager.getProperty(account, "password"));
Activator.login(
loginSucceeded = Activator.login(
userManager.getProperty(account, "username"),
userManager.getProperty(account, "password")
);
Expand All @@ -62,12 +67,14 @@ private void updateOnLogin() {
// FIXME: should do proper feedback
System.out.println("Error while logging in: " + e.getMessage());
e.printStackTrace();
loginSucceeded = false;
}
}
return loginSucceeded;
}

private void update() {
updateOnLogin();
private boolean update() {
return updateOnLogin();
}

private void updateOnLogout() {
Expand Down

0 comments on commit 5c897fe

Please sign in to comment.