Skip to content

Commit

Permalink
Fix login bug (Windows), Fix logout bug (Android, Windows), Update ve…
Browse files Browse the repository at this point in the history
…rsion to 2.1.6.
  • Loading branch information
hearsilent committed Sep 25, 2015
1 parent bc6520c commit 0d5bd63
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "tw.edu.kuas.wifiautologin"
minSdkVersion 9
targetSdkVersion 22
versionCode 215
versionName "2.1.5"
versionCode 216
versionName "2.1.6"
}
buildTypes {
debug {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ private static void checkLogoutLocation(final Context context, final GeneralCall
if (!location.equals("")) {
if (location.contains("login_online")) {
logout(context, callback, Constant.JIANGONG_WIFI_SERVER);
} else if (location.contains("auth_entry")) {
} else if (location.contains("login.php")) {
tracker.send(
new HitBuilders.EventBuilder().setCategory("onFailure").setAction("Logout")
.setLabel("Already logged out").build());
Expand Down Expand Up @@ -498,6 +498,7 @@ private static void retryLogin(Context context, final LinkedHashMap<String, Stri
mNotificationManager.notify(Constant.NOTIFICATION_LOGIN_ID, mBuilder.build());
} else {
errorTimes = 0;
mNotificationManager.cancel(Constant.NOTIFICATION_LOGIN_ID);
}

errorTimes++;
Expand Down
29 changes: 23 additions & 6 deletions Windows/KUAS WiFi/LoginFrm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ Public Class LoginFrm
disableViews()

Try
Dim response As HttpWebResponse = HttpWebResponseUtility.CreateGetHttpResponse("http://" + JIANGONG_WIFI_SERVER, 7000, Nothing, Nothing)
Dim response As HttpWebResponse = HttpWebResponseUtility.CreateGetHttpResponse("https://www.example.com/", 7000, Nothing, Nothing)
Dim reader As StreamReader = New StreamReader(response.GetResponseStream, System.Text.Encoding.GetEncoding("UTF-8"))
Dim respHTML As String = reader.ReadToEnd()
checkLoginLocation(response.Headers.[Get]("Location"))
If (response.StatusCode = 200) Then
MsgBox("您已經登入或是有可用網路了。", MsgBoxStyle.Information, "高應無線通")
enableViews()
Else
checkLoginLocation(response.Headers.[Get]("Location"))
End If
response.Close()
Catch ex As Exception
MsgBox("請求 Wi-Fi 伺服器的連線逾時。", MsgBoxStyle.Critical, "高應無線通")
Expand Down Expand Up @@ -96,17 +101,26 @@ Public Class LoginFrm
MsgBox("請求 Wi-Fi 伺服器的連線逾時。", MsgBoxStyle.Critical, "高應無線通")
enableViews()
Else
If (_location.Contains("auth_entry")) Then
If (_location.Contains("login.php")) Then
If match.Success Then
login(match.Value)
Else
MsgBox("發生錯誤!", MsgBoxStyle.Critical, "高應無線通")
enableViews()
End If
Else
If (_location.Contains("login_online") Or _location.Contains("login.php")) Then
If (_location.Contains("login_online")) Then
MsgBox("您已經登入或是有可用網路了。", MsgBoxStyle.Information, "高應無線通")
enableViews()
Else
If (match.Success And match.Value.Equals(JIANGONG_WIFI_SERVER)) Then
login(YANCHAO_WIFI_SERVER)
ElseIf (match.Success And match.Value.Equals(YANCHAO_WIFI_SERVER)) Then
login(JIANGONG_WIFI_SERVER)
Else
MsgBox("發生錯誤!", MsgBoxStyle.Critical, "高應無線通")
enableViews()
End If
End If
End If
End If
Expand All @@ -117,10 +131,11 @@ Public Class LoginFrm
MsgBox("請求 Wi-Fi 伺服器的連線逾時。", MsgBoxStyle.Critical, "高應無線通")
enableViews()
Else
If (_location.Contains("login_online") Or _location.Contains("login.php")) Then
If (_location.Contains("login_online")) Then
logout(JIANGONG_WIFI_SERVER)
ElseIf (_location.Contains("auth_entry")) Then
ElseIf (_location.Contains("login.php")) Then
MsgBox("您已經登出或是尚未登入WiFi。", MsgBoxStyle.Critical, "高應無線通")
enableViews()
Else
logout(YANCHAO_WIFI_SERVER)
End If
Expand Down Expand Up @@ -282,6 +297,8 @@ Namespace SilentWebModule
''' <param name="cookies">隨同HTTP請求發送的Cookie信息,如果不需要身分驗證可以為空</param>
''' <returns></returns>
Public Shared Function CreateGetHttpResponse(url As String, timeout As System.Nullable(Of Integer), userAgent As String, cookies As CookieContainer) As HttpWebResponse
System.Net.ServicePointManager.Expect100Continue = False '防止417

If String.IsNullOrEmpty(url) Then
Throw New ArgumentNullException("url")
End If
Expand Down
4 changes: 2 additions & 2 deletions Windows/KUAS WiFi/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' 指定為預設值:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.0.9.24")>
<Assembly: AssemblyFileVersion("1.0.9.24")>
<Assembly: AssemblyVersion("2.1.6.0")>
<Assembly: AssemblyFileVersion("2.1.6.0")>

0 comments on commit 0d5bd63

Please sign in to comment.