Skip to content

Commit

Permalink
Added doWork() listener (regiseterForUpdates/ deregisterForUpdates)
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-Folder committed Nov 9, 2013
1 parent 635538b commit 0e3a990
Show file tree
Hide file tree
Showing 25 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions 2.2.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.2.0/backgroundserviceplugin-2.2.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 2.3.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.3.0/backgroundserviceplugin-2.3.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 2.4.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.4.0/backgroundserviceplugin-2.4.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 2.5.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.5.0/backgroundserviceplugin-2.5.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 2.6.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.6.0/backgroundserviceplugin-2.6.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 2.7.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.7.0/backgroundserviceplugin-2.7.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 2.8.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.8.0/backgroundserviceplugin-2.8.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 2.8.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.8.1/backgroundserviceplugin-2.8.1.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 2.9.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 2.9.0/backgroundserviceplugin-2.9.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions 3.0.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
Binary file modified 3.0.0/backgroundserviceplugin-3.0.0.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions 3.1.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Add the following to AndroidManifest.xml
```
## Change Log ##

* 9th November 2013 - Added ability to listen for doWork() updates using registerForUpdates/ deregisterForUpdates. See individual version README for support info (rolling out version by version. For more info see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/17
* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS
Expand Down
29 changes: 29 additions & 0 deletions 3.1.0/backgroundService-3.1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function CreateBackgroundService(serviceName, require, exports, module) {
* JSONObject Configuration - A JSONObject of the configuration of the service (contents dependant on the service)
* JSONObject LastestResult - A JSONObject of the last result of the service (contents dependant on the service)
* int TimerMilliseconds - Milliseconds used by the background service if Timer enabled
* Boolean RegisteredForUpdates - True if the Service is registered to send updates to the front-end
*/

/**
Expand Down Expand Up @@ -191,6 +192,34 @@ function CreateBackgroundService(serviceName, require, exports, module) {
[this.getServiceName()]);
};

/**
* Registers for doWork() updates
*
* @param successCallback The callback which will be called if the method is successful
* @param failureCallback The callback which will be called if the method encounters an error
*/
BackgroundService.prototype.registerForUpdates = function(successCallback, failureCallback) {
return exec( successCallback,
failureCallback,
'BackgroundServicePlugin',
'registerForUpdates',
[this.getServiceName()]);
};

/**
* Deregisters for doWork() updates
*
* @param successCallback The callback which will be called if the method is successful
* @param failureCallback The callback which will be called if the method encounters an error
*/
BackgroundService.prototype.deregisterForUpdates = function(successCallback, failureCallback) {
return exec( successCallback,
failureCallback,
'BackgroundServicePlugin',
'deregisterForUpdates',
[this.getServiceName()]);
};

var backgroundService = new BackgroundService(serviceName);
module.exports = backgroundService;
};
Binary file modified 3.1.0/backgroundserviceplugin-3.1.0.jar
Binary file not shown.
28 changes: 27 additions & 1 deletion 3.1.0/index-3.1.0.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@
function(e){handleError(e)});
}

function registerForUpdates() {
myService.registerForUpdates( function(r){handleSuccess(r)},
function(e){handleError(e)});
}

function deregisterForUpdates() {
myService.deregisterForUpdates( function(r){handleSuccess(r)},
function(e){handleError(e)});
}

function setConfig() {
var helloToTxt = document.getElementById("helloToTxt");
var helloToString = helloToTxt.value;
Expand All @@ -98,13 +108,15 @@
var serviceBtn = document.getElementById("toggleService");
var timerBtn = document.getElementById("toggleTimer");
var bootBtn = document.getElementById("toggleBoot");
var listenBtn = document.getElementById("toggleListen");
var updateBtn = document.getElementById("updateBtn");
var refreshBtn = document.getElementById("refreshBtn");

var serviceStatus = document.getElementById("serviceStatus");
var timerStatus = document.getElementById("timerStatus");
var bootStatus = document.getElementById("bootStatus");

var listenStatus = document.getElementById("listenStatus");

serviceBtn.disabled = false;
if (data.ServiceRunning) {
serviceStatus.innerHTML = "Running";
Expand Down Expand Up @@ -142,6 +154,15 @@
bootStatus.innerHTML = "Not registered";
bootBtn.onclick = registerForBootStart;
}

listenBtn.disabled = false;
if (data.RegisteredForUpdates) {
listenStatus.innerHTML = "Registered";
listenBtn.onclick = deregisterForUpdates;
} else {
listenStatus.innerHTML = "Not registered";
listenBtn.onclick = registerForUpdates;
}

if (data.Configuration != null)
{
Expand Down Expand Up @@ -185,6 +206,11 @@ <h1>MyService V3.1.0</h1>
<td><div id="bootStatus"></div></td>
<td><input disabled id="toggleBoot" type="button" value="toggle"/></td>
</tr>
<tr>
<th>Listen</th>
<td><div id="listenStatus"></div></td>
<td><input disabled id="toggleListen" type="button" value="toggle"/></td>
</tr>

<tr>
<th colspan=3 align="center">Configuration</th>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Over time I will no longer maintain older versions. These will be listed here.

## Change Log ##

* 9th November 2013 - Added ability to listen for doWork() updates using registerForUpdates/ deregisterForUpdates. See individual version README for support info (rolling out version by version. For more info see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/17
* 20th September 2013 - Added runOnce support (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/14)
* 4th September 2013 - Fixes for NullPointerException (see https://github.com/Red-Folder/Cordova-Plugin-BackgroundService/issues/7)
* 27th August 2013 - Added TimerMilliseconds to returned JSONObject (see Issue 5)
* 12th May 2013 - Updated to handle service being restarted by OS (version 2.2+)
Expand Down

0 comments on commit 0e3a990

Please sign in to comment.