Permalink
Browse files

Merge branch 'master' of github.com:liato/android-bankdroid

  • Loading branch information...
2 parents 8e70928 + aafdc65 commit 6e8cfdc2ca98347287c9f577ae5dfb360e33caea @liato committed Jul 8, 2012
Showing with 10 additions and 6 deletions.
  1. +10 −6 src/com/liato/bankdroid/banking/banks/Vasttrafik.java
@@ -48,7 +48,7 @@
private static final int BANKTYPE_ID = IBankTypes.VASTTRAFIK;
private Pattern reViewState = Pattern.compile("__VIEWSTATE\"\\s+value=\"([^\"]+)\"");
- private Pattern reAccounts = Pattern.compile("<div class=\"myCardsItemContainer\" data-cardnumber=\"\\d+\">.*?<h3 class=\"cardName grid_12 clearMargin\">(.*?)</h3>.*?<span class=\"cardNumber\">(\\d+)</span>.*?<div class=\"clearfix cardCharges\">(.*?)<div class=\"clearfix paddingBottom grid_12 cardOptions\">", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
+ private Pattern reAccounts = Pattern.compile("<div class=\"myCardsItemContainer\" data-cardnumber=\"(.*?)\">.*?<h3 class=\"cardName grid_12 clearMargin\">(.*?)</h3>.*?<div class=\"clearfix cardCharges\">(.*?)<div class=\"clearfix paddingBottom grid_12 cardOptions(.*?)\">", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
private Pattern reBalance = Pattern.compile("<span class=\"chargeType boldType\">(.*?): (.*?)</span>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
private String response = null;
@@ -66,7 +66,6 @@ public Vasttrafik(String username, String password, Context context) throws Bank
this.update(username, password);
}
-
@Override
protected LoginPackage preLogin() throws BankException,
ClientProtocolException, IOException {
@@ -89,11 +88,12 @@ protected LoginPackage preLogin() throws BankException,
return new LoginPackage(urlopen, postData, response, "https://www.vasttrafik.se/mina-sidor/logga-in/?ReturnUrl=/mina-sidor-inloggad/mina-kort/");
}
+ @Override
public Urllib login() throws LoginException, BankException {
try {
LoginPackage lp = preLogin();
response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
- if (!response.contains("Inloggad som:")) {
+ if (!response.contains("<span class=\"loggedInAs\">")) {
throw new LoginException(res.getText(R.string.invalid_username_password).toString());
}
}
@@ -123,11 +123,15 @@ public void update() throws BankException, LoginException, BankChoiceException {
/*
* Capture groups:
* GROUP EXAMPLE DATA
- * 1: Name Nytt
- * 2: Card number 1111111111
+ * 1: Card number 1111111111
+ * 2: Name Nytt
* 3: Balance information
*/
+ if ("".equals(matcher.group(1))) {
+ continue;
+ }
+
matcher_b = reBalance.matcher(matcher.group(3));
if (matcher_b.find()) {
/*
@@ -139,7 +143,7 @@ public void update() throws BankException, LoginException, BankChoiceException {
String balanceString = matcher_b.group(2).replaceAll("\\<a[^>]*>","").replaceAll("\\<[^>]*>","").trim();
- accounts.add(new Account(Html.fromHtml(matcher.group(1)).toString().trim() , Helpers.parseBalance(balanceString), matcher.group(2)));
+ accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim() , Helpers.parseBalance(balanceString), matcher.group(1)));
balance = balance.add(Helpers.parseBalance(balanceString));
}
}

0 comments on commit 6e8cfdc

Please sign in to comment.