Skip to content

Commit 61c624e

Browse files
committed
Update files for 0.82 inc multi-services
1 parent 7fbb28e commit 61c624e

File tree

6 files changed

+163
-61
lines changed

6 files changed

+163
-61
lines changed

ABBUsage/@Resources/Scripts/ABB-Clean.vbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
' Description: Backend script for ABBUsage Rainmeter skin by Big Kahuna
2+
' Author: Protogen at whirlpool (skin by Big Kahuna)
3+
' Version: 2.1.0
4+
' Date: 18 Jul 2019
5+
16
Option Explicit
27

38
Const rspName = "ABB"

ABBUsage/@Resources/Scripts/ABB-Usage.vbs

Lines changed: 149 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
' Description: Backend script for ABBUsage Rainmeter skin by Big Kahuna
22
' Author: Protogen at whirlpool (skin by Big Kahuna)
3-
' Version: 3.3.1
4-
' Date: 18 July 2019
3+
' Version: 3.5.0
4+
' Date: 5 Aug 2019
55

66
'-------------------------------------------------------------------------------
77
' Environment, constants, global variables
@@ -37,7 +37,7 @@ If WScript.Arguments.Count = 2 Or WScript.Arguments.Count = 3 Then
3737
objDebugLog.Logname = Replace(objDebugLog.Logname, ".ini", "")
3838
objDebugLog.Logname = Replace(objDebugLog.Logname, "\", "-")
3939

40-
appTitle = appTitle & " [" & WScript.Arguments.Item(0) & "]"
40+
appTitle = appTitle & " [" & WScript.Arguments.Item(0) & "\" & WScript.Arguments.Item(1) & "]"
4141

4242
' Delete old files and update the usage
4343
If WScript.Arguments.Count = 2 Then
@@ -756,7 +756,7 @@ Class HTTPRequest
756756
If Username <> "" And Password <> "" Then
757757
MsgBox "Failed to obtain an authentication cookie from the " & rspName & " portal." & vbCRLF & _
758758
"Possible network error - please check your connection and try again." & vbCRLF & vbCRLF & _
759-
"(If the problem persist enable debug mode)", 16, appTitle
759+
"(If the problem persists, post the issue on whirlpool)", 16, appTitle
760760
End If
761761
WScript.Quit
762762
End If
@@ -771,7 +771,7 @@ Class HTTPRequest
771771
If Username <> "" And Password <> "" Then
772772
MsgBox "Failed to obtain an authentication cookie from the " & rspName & " portal." & vbCRLF & _
773773
"Please check your username and password and try again." & vbCRLF & vbCRLF & _
774-
"(If the problem persist enable debug mode)", 16, appTitle
774+
"(If the problem persists, post the issue on whirlpool)", 16, appTitle
775775
End If
776776
WScript.Quit
777777
End If
@@ -789,10 +789,10 @@ Class HTTPRequest
789789
Private Function PercentEncode(strPlain)
790790
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Function PercentEncode"
791791

792-
Dim strEncoded, pos, currentChar, ansiVal
792+
Dim strEncoded, index, currentChar, ansiVal
793793

794-
For pos = 1 to Len(strPlain)
795-
currentChar = Mid(strPlain, pos, 1)
794+
For index = 1 to Len(strPlain)
795+
currentChar = Mid(strPlain, index, 1)
796796
ansiVal = Asc(currentChar)
797797

798798
' Do not encode numbers, uppercase and lowercase letters
@@ -1003,6 +1003,79 @@ Class Auth
10031003

10041004
End Class
10051005

1006+
'-------------------------------------------------------------------------------
1007+
' Class - UserSelection
1008+
'-------------------------------------------------------------------------------
1009+
1010+
Class UserSelection
1011+
1012+
Private p_desc
1013+
Private p_dict
1014+
1015+
'-------------------------------------------------------------------------------
1016+
' Property - Desc
1017+
'-------------------------------------------------------------------------------
1018+
1019+
Public Property Let Desc(strDesc)
1020+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Let Desc"
1021+
1022+
p_desc = strDesc
1023+
End Property
1024+
1025+
Public Property Get Desc()
1026+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Get Desc"
1027+
1028+
Desc = p_desc
1029+
End Property
1030+
1031+
'-------------------------------------------------------------------------------
1032+
' Property - Dict
1033+
'-------------------------------------------------------------------------------
1034+
1035+
Public Property Let Dict(objDict)
1036+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Let Dict"
1037+
1038+
Set p_dict = objDict
1039+
End Property
1040+
1041+
Public Property Get Dict()
1042+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Get Dict"
1043+
1044+
Set Dict = p_dict
1045+
End Property
1046+
1047+
'-------------------------------------------------------------------------------
1048+
' Function - GetUserSelection
1049+
'-------------------------------------------------------------------------------
1050+
1051+
Public Function GetUserSelection()
1052+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Function GetUserSelection"
1053+
1054+
Dim arrDictKeys, strMessage, index, userResponse
1055+
1056+
arrDictKeys = Me.Dict.Keys
1057+
strMessage = "Please select the " & Me.Desc & " for this skin" & vbCRLF & vbCRLF
1058+
For index = 1 to Me.Dict.Count
1059+
strMessage = strMessage & CStr(index) & " - " & arrDictKeys(index - 1) & vbCRLF
1060+
Next
1061+
strMessage = strMessage & vbCRLF & "Selection (1 - " & Me.Dict.Count & ")?"
1062+
1063+
Do Until 1 <= userResponse And userResponse <= Me.Dict.Count
1064+
userResponse = InputBox(strMessage, appTitle)
1065+
If IsNumeric(userResponse) Then
1066+
userResponse = CInt(userResponse)
1067+
Else
1068+
userResponse = 0
1069+
End If
1070+
Loop
1071+
1072+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "User response = '" & userResponse & "'"
1073+
1074+
GetUserSelection = arrDictKeys(userResponse - 1)
1075+
End Function
1076+
1077+
End Class
1078+
10061079
'-------------------------------------------------------------------------------
10071080
' Class - Options
10081081
'-------------------------------------------------------------------------------
@@ -1083,19 +1156,22 @@ Class Options
10831156
Private Function GetBarStyleSize()
10841157
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Function GetBarStyleSize"
10851158

1086-
Dim objBarStyleSize, userSelection
1087-
Set objBarStyleSize = CreateObject("Scripting.Dictionary")
1159+
Dim objDict, objUserSelection, userSelection
1160+
Set objDict = CreateObject("Scripting.Dictionary")
1161+
Set objUserSelection = New UserSelection
10881162

1089-
objBarStyleSize.Add "Dashed 5px", "image5px"
1090-
objBarStyleSize.Add "Dashed 8px", "image8px"
1091-
objBarStyleSize.Add "Solid 5px", "solid5px"
1092-
objBarStyleSize.Add "Solid 8px", "solid8px"
1163+
objDict.Add "Dashed 5px", "image5px"
1164+
objDict.Add "Dashed 8px", "image8px"
1165+
objDict.Add "Solid 5px", "solid5px"
1166+
objDict.Add "Solid 8px", "solid8px"
10931167

1094-
userSelection = GetUserSelection(objBarStyleSize, "bar style and size")
1168+
objUserSelection.Desc = "bar style and size"
1169+
objUserSelection.Dict = objDict
1170+
userSelection = objUserSelection.GetUserSelection()
10951171

1096-
If debugMode Then objDebugLog.Message "info", TypeName(Me), "User selection = '" & objBarStyleSize(userSelection) & "'"
1172+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "User selection = '" & objDict(userSelection) & "'"
10971173

1098-
GetBarStyleSize = objBarStyleSize(userSelection)
1174+
GetBarStyleSize = objDict(userSelection)
10991175
End Function
11001176

11011177
'-------------------------------------------------------------------------------
@@ -1105,48 +1181,21 @@ Class Options
11051181
Private Function GetFontSize()
11061182
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Function GetFontSize"
11071183

1108-
Dim objFontSize, userSelection
1109-
Set objFontSize = CreateObject("Scripting.Dictionary")
1110-
1111-
objFontSize.Add "Small (8px)", "small"
1112-
objFontSize.Add "Medium (12px)", "medium"
1113-
objFontSize.Add "Large (16px)", "large"
1114-
1115-
userSelection = GetUserSelection(objFontSize, "font size")
1116-
1117-
If debugMode Then objDebugLog.Message "info", TypeName(Me), "User selection = '" & objFontSize(userSelection) & "'"
1118-
1119-
GetFontSize = objFontSize(userSelection)
1120-
End Function
1121-
1122-
'-------------------------------------------------------------------------------
1123-
' Function - GetUserSelection
1124-
'-------------------------------------------------------------------------------
1125-
1126-
Public Function GetUserSelection(objDict, strSelectionName)
1127-
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Function GetUserSelection"
1128-
1129-
Dim arrDictKeys, strMessage, pos, userResponse
1184+
Dim objDict, objUserSelection, userSelection
1185+
Set objDict = CreateObject("Scripting.Dictionary")
1186+
Set objUserSelection = New UserSelection
11301187

1131-
arrDictKeys = objDict.Keys
1132-
strMessage = "Please select the " & strSelectionName & " for this skin" & vbCRLF & vbCRLF
1133-
For pos = 1 to objDict.Count
1134-
strMessage = strMessage & CStr(pos) & " - " & arrDictKeys(pos - 1) & vbCRLF
1135-
Next
1136-
strMessage = strMessage & vbCRLF & "Selection (1 - " & objDict.Count & ")?"
1188+
objDict.Add "Small (8px)", "small"
1189+
objDict.Add "Medium (12px)", "medium"
1190+
objDict.Add "Large (16px)", "large"
11371191

1138-
Do Until 1 <= userResponse And userResponse <= objDict.Count
1139-
userResponse = InputBox(strMessage, appTitle)
1140-
If IsNumeric(userResponse) Then
1141-
userResponse = CInt(userResponse)
1142-
Else
1143-
userResponse = 0
1144-
End If
1145-
Loop
1192+
objUserSelection.Desc = "font size"
1193+
objUserSelection.Dict = objDict
1194+
userSelection = objUserSelection.GetUserSelection()
11461195

1147-
If debugMode Then objDebugLog.Message "info", TypeName(Me), "User response = '" & userResponse & "'"
1196+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "User selection = '" & objDict(userSelection) & "'"
11481197

1149-
GetUserSelection = arrDictKeys(userResponse - 1)
1198+
GetFontSize = objDict(userSelection)
11501199
End Function
11511200

11521201
'-------------------------------------------------------------------------------
@@ -1282,9 +1331,9 @@ Class Service
12821331
End If
12831332

12841333
objAuth.GetAuth()
1285-
objOptions.EnsureOptionsExist()
12861334

12871335
If Not objServiceFile.FileExists() Then CreateService()
1336+
objOptions.EnsureOptionsExist()
12881337
LoadService()
12891338
End Sub
12901339

@@ -1308,15 +1357,15 @@ Class Service
13081357

13091358
objJSON.JSONText = objHTTPRequest.ResponseText
13101359

1311-
Me.ServiceID = objJSON.JSONStruct.services.NBN.[0].service_id
1360+
Me.ServiceID = GetServiceID(objJSON)
13121361

13131362
If IsEmpty(Me.ServiceID) Or Me.ServiceID = "" Then
13141363
If debugMode Then objDebugLog.Message "error", TypeName(Me), "ServiceID is undefined or blank"
13151364
WScript.Quit
13161365
End If
13171366

13181367
maxLen = 16 - Len(Me.ServiceID)
1319-
strMessage = "Your " & rspName & " NBN Service ID is " & Me.ServiceID & vbCRLF & vbCRLF & _
1368+
strMessage = "Your NBN Service ID for this skin is " & Me.ServiceID & vbCRLF & vbCRLF & _
13201369
"Please enter a name for this service" & vbCRLF & _
13211370
"(e.g. 'Home', 'Home2', 'Work', 'Primary')" & vbCRLF & vbCRLF & _
13221371
"Service Name (alphanumeric only; max " & maxLen & " chars)?"
@@ -1342,6 +1391,48 @@ Class Service
13421391
objServiceFile.Contents = serviceFileContents
13431392
End Sub
13441393

1394+
'-------------------------------------------------------------------------------
1395+
' Function - GetServiceID
1396+
'-------------------------------------------------------------------------------
1397+
1398+
Private Function GetServiceID(objJSON)
1399+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Entering Function GetServiceID"
1400+
1401+
Dim serviceCount
1402+
serviceCount = objJSON.JSONStruct.services.NBN.Length
1403+
1404+
If serviceCount <= 0 Then
1405+
If debugMode Then objDebugLog.Message "error", TypeName(Me), "NBN array (customer JSON) is empty or missing"
1406+
MsgBox "Failed to obtain an NBN Service ID from the " & rspName & " portal." & vbCRLF & _
1407+
"Possible " & rspName & " portal change - please try again." & vbCRLF & vbCRLF & _
1408+
"(If the problem persists, post the issue on whirlpool)", 16, appTitle
1409+
WScript.Quit
1410+
ElseIf serviceCount = 1 Then
1411+
GetServiceID = objJSON.JSONStruct.services.NBN.[0].service_id
1412+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Single NBN Service ID found = '" & GetServiceID & "'"
1413+
Exit Function
1414+
End If
1415+
1416+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "Multiple NBN Service IDs found"
1417+
1418+
Dim objDict, index, serviceID, objUserSelection, userSelection
1419+
Set objDict = CreateObject("Scripting.Dictionary")
1420+
Set objUserSelection = New UserSelection
1421+
1422+
For index = 0 to (serviceCount - 1)
1423+
serviceID = Eval("objJSON.JSONStruct.services.NBN.[" & index & "].service_id")
1424+
objDict.Add serviceID, serviceID
1425+
Next
1426+
1427+
objUserSelection.Desc = "NBN Service ID"
1428+
objUserSelection.Dict = objDict
1429+
userSelection = objUserSelection.GetUserSelection()
1430+
1431+
If debugMode Then objDebugLog.Message "info", TypeName(Me), "User selection = '" & objDict(userSelection) & "'"
1432+
1433+
GetServiceID = objDict(userSelection)
1434+
End Function
1435+
13451436
'-------------------------------------------------------------------------------
13461437
' Sub - LoadService
13471438
'-------------------------------------------------------------------------------

ABBUsage/ABB.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;=================================================
22
; Rainmeter configuration file
3-
; Updated June 24, 2019
3+
; Updated August 6th, 2019
44
;=================================================
55

66
;[BEGIN CONFIG FILE]==============================
@@ -16,7 +16,7 @@ Name=Aussie Broadband Usage Meter
1616
Author=Big Kahuna (Skin) Protogen (Scripts)
1717
Information=From Whirlpool Users Big Kahuna/Protogen/hd/jandakot11 Adapted from the Telstra meter made by Kanine.
1818
License=Creative Commons Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 3.0 AU)
19-
Version=0.80
19+
Version=0.82
2020

2121
[Variables]
2222
fontName=Trebuchet MS

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ Unlimited plans don't show the lower data percent used bar and don't show any of
108108
NOTE: Some users have problems with default secure protocols (I've had reports from users running Windows 7, 64 bit) Applying a [Microsoft hotfix has been reported to fix this](https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-a-default-secure-protocols-in#easy)
109109

110110
## Multiple Services for the one account
111-
To use this feature, create a new directory in the ABB usage folder and copy the ABB.ini skin to that folder. Any folder under ABBUsage (the default) will use the SAME ABB logon username/password and the same cookie. In the next release (coming soon) multiple accounts will be detected as part of the setup.
111+
To use this feature, create a new directory in the ABB usage folder and copy the ABB.ini skin to that folder. Any folder under ABBUsage (the default) will use the SAME ABB logon username/password and the same cookie.
112+
In this release multiple accounts are detected as part of the setup and you will be prompted to select the service id from the list of detected service id's.
113+
114+
![Select Service ID](multi-service-prompt.png)
115+
116+
You will then be asked for a friendly name for the service as per a standard configuration.
112117

113118
## Multiple Accounts
114119
Say you are wanting to monitor usage for your work and your home or for a friend - so this would be different accounts. To do this, you will need to duplicate the entire ABBUsage folder (C:\Users\YOUR_USER\Documents\Rainmeter\Skins\ABBUsage to say C:\Users\YOUR_USER\Documents\Rainmeter\Skins\ABBWorkUsage) When you use the manage screen to load that skin from a new folder it will ask for setup credentials for the new account as well as style information.
@@ -118,6 +123,7 @@ The Username and Password are no longer stored as we obtain a cookie and refresh
118123

119124
## Changelog
120125

126+
0.82 - Adds prompts if multiple services are detected
121127
0.81 - Fix for ABB switching to use Cloudflare and new cookie structure
122128

123129
## New in version 0.80 25/06/2019

multi-service-prompt.png

4.72 KB
Loading

0 commit comments

Comments
 (0)