-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/unstable' into rename-files
- Loading branch information
Showing
330 changed files
with
10,433 additions
and
2,073 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import "pkg:/source/utils/misc.brs" | ||
|
||
sub init() | ||
|
||
' If hideclick setting is checked, exit without setting any variables | ||
if m.global.session.user.settings["ui.design.hideclock"] | ||
return | ||
end if | ||
|
||
m.clockTime = m.top.findNode("clockTime") | ||
|
||
m.currentTimeTimer = m.top.findNode("currentTimeTimer") | ||
m.dateTimeObject = CreateObject("roDateTime") | ||
|
||
m.currentTimeTimer.observeField("fire", "onCurrentTimeTimerFire") | ||
m.currentTimeTimer.control = "start" | ||
|
||
' Default to 12 hour clock | ||
m.format = "short-h12" | ||
|
||
' If user has selected a 24 hour clock, update date display format | ||
if LCase(m.global.device.clockFormat) = "24h" | ||
m.format = "short-h24" | ||
end if | ||
end sub | ||
|
||
|
||
' onCurrentTimeTimerFire: Code that runs every time the currentTimeTimer fires | ||
' | ||
sub onCurrentTimeTimerFire() | ||
' Refresh time variable | ||
m.dateTimeObject.Mark() | ||
|
||
' Convert to local time zone | ||
m.dateTimeObject.ToLocalTime() | ||
|
||
' Format time as requested | ||
m.clockTime.text = m.dateTimeObject.asTimeStringLoc(m.format) | ||
end sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<component name="Clock" extends="Group"> | ||
<children> | ||
<Label id="clockTime" font="font:SmallSystemFont" horizAlign="right" vertAlign="center" height="64" width="200" /> | ||
<Timer id="currentTimeTimer" repeat="true" duration="1" /> | ||
</children> | ||
<interface> | ||
</interface> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import "pkg:/source/api/baserequest.brs" | ||
import "pkg:/source/utils/misc.brs" | ||
|
||
sub init() | ||
m.top.functionName = "postItems" | ||
end sub | ||
|
||
' Main function for PostTask. | ||
' Posts either an array of data | ||
' or a string of data to an API endpoint. | ||
' Saves the response information | ||
sub postItems() | ||
if m.top.apiUrl = "" | ||
print "ERROR in PostTask. Invalid API URL provided" | ||
return | ||
end if | ||
if m.top.arrayData.count() > 0 and m.top.stringData = "" | ||
print "PostTask Started - Posting array to " + m.top.apiUrl | ||
req = APIRequest(m.top.apiUrl) | ||
req.SetRequest("POST") | ||
httpResponse = asyncPost(req, FormatJson(m.top.arrayData)) | ||
m.top.responseCode = httpResponse | ||
print "PostTask Finished. " + m.top.apiUrl + " Response = " + httpResponse.toStr() | ||
else if m.top.arrayData.count() = 0 and m.top.stringData <> "" | ||
print "PostTask Started - Posting string(" + m.top.stringData + ") to " + m.top.apiUrl | ||
req = APIRequest(m.top.apiUrl) | ||
req.SetRequest("POST") | ||
httpResponse = asyncPost(req, m.top.stringData) | ||
m.top.responseCode = httpResponse | ||
print "PostTask Finished. " + m.top.apiUrl + " Response = " + httpResponse.toStr() | ||
else | ||
print "ERROR processing data for PostTask" | ||
end if | ||
end sub | ||
|
||
' Post data and wait for response code | ||
function asyncPost(req, data = "" as string) as integer | ||
' response code 0 means there was an error | ||
respCode = 0 | ||
|
||
req.setMessagePort(CreateObject("roMessagePort")) | ||
req.AddHeader("Content-Type", "application/json") | ||
req.AsyncPostFromString(data) | ||
' wait up to m.top.timeoutSeconds for a response | ||
' NOTE: wait() uses milliseconds - multiply by 1000 to convert | ||
resp = wait(m.top.timeoutSeconds * 1000, req.GetMessagePort()) | ||
|
||
respString = resp.GetString() | ||
if isValidAndNotEmpty(respString) | ||
m.top.responseBody = ParseJson(respString) | ||
print "m.top.responseBody=", m.top.responseBody | ||
end if | ||
|
||
respCode = resp.GetResponseCode() | ||
if respCode < 0 | ||
' there was an unexpected error | ||
m.top.failureReason = resp.GetFailureReason() | ||
else if respCode >= 200 and respCode < 300 | ||
' save response headers if they're available | ||
m.top.responseHeaders = resp.GetResponseHeaders() | ||
end if | ||
|
||
return respCode | ||
end function | ||
|
||
' Revert PostTask to default state | ||
sub empty() | ||
' These should match the defaults set in PostTask.xml | ||
m.top.apiUrl = "" | ||
m.top.timeoutSeconds = 30 | ||
|
||
m.top.arrayData = {} | ||
m.top.stringData = "" | ||
|
||
m.top.responseCode = invalid | ||
m.top.responseBody = {} | ||
m.top.responseHeaders = {} | ||
m.top.failureReason = "" | ||
end sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<component name="PostTask" extends="Task"> | ||
<interface> | ||
<field id="apiUrl" type="string" /> | ||
<field id="timeoutSeconds" type="integer" value="30" /> | ||
|
||
<field id="arrayData" type="assocarray" value="{}" /> | ||
<field id="stringData" type="string" value="" /> | ||
|
||
<field id="responseCode" type="integer" /> | ||
<field id="responseBody" type="assocarray" value="{}" /> | ||
<field id="responseHeaders" type="assocarray" value="{}" /> | ||
<field id="failureReason" type="string" value="" /> | ||
|
||
<function name="empty" /> | ||
</interface> | ||
</component> |
Oops, something went wrong.