Skip to content

Commit

Permalink
modified isReachable to return a NetworkStatus code rather than true …
Browse files Browse the repository at this point in the history
…false for platform conformity
  • Loading branch information
Ryan Willoughby committed Jun 17, 2010
1 parent 802a83e commit 00bb61f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions framework/www/phonegap.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallba
delay += interval;

//if we have a new position, call success and cancel the timer
if (typeof(dis.lastPosition) == 'object' && dis.lastPosition.timestamp > referenceTime) {
if (dis.lastPosition && typeof(dis.lastPosition) == 'object' && dis.lastPosition.timestamp > referenceTime) {
successCallback(dis.lastPosition);
clearInterval(timer);
} else if (delay >= timeout) { //else if timeout has occured then call error and cancel the timer
Expand Down Expand Up @@ -658,7 +658,15 @@ Network.prototype.isReachable = function(hostName, successCallback, options) {
this.request = new Mojo.Service.Request('palm://com.palm.connectionmanager', {
method: 'getstatus',
parameters: {},
onSuccess: function(result) { successCallback(result.isInternetConnectionAvailable); },
onSuccess: function(result) {
var status = NetworkStatus.NOT_REACHABLE;
if (result.isInternetConnectionAvailable == true)
{
// don't know whether its via wifi or carrier ... so return the worst case
status = NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK;
}
successCallback(status);
},
onFailure: function() {}
});

Expand Down
10 changes: 9 additions & 1 deletion js/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ Network.prototype.isReachable = function(hostName, successCallback, options) {
this.request = new Mojo.Service.Request('palm://com.palm.connectionmanager', {
method: 'getstatus',
parameters: {},
onSuccess: function(result) { successCallback(result.isInternetConnectionAvailable); },
onSuccess: function(result) {
var status = NetworkStatus.NOT_REACHABLE;
if (result.isInternetConnectionAvailable == true)
{
// don't know whether its via wifi or carrier ... so return the worst case
status = NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK;
}
successCallback(status);
},
onFailure: function() {}
});

Expand Down

0 comments on commit 00bb61f

Please sign in to comment.