/* Copyright 2009 Palm, Inc.  All rights reserved. */

var SystemService = Class.create({ 
	initialize: function() { 
	}
});


SystemService.identifier = 'palm://com.palm.systemservice';
SystemService.time_identifier = 'palm://com.palm.systemservice/time';

SystemService.setTimeFormat = function(format,callback) {
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setPreferences',
			parameters: {"timeFormat":format}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getTimeFormat = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferences',
			parameters: {"keys":["timeFormat"]}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}


SystemService.setUseNetworkTime = function(value,callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setPreferences',
			parameters: {"useNetworkTime":value}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getUseNetworkTime = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferences',
			parameters: {"keys":["useNetworkTime"]}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getUseNetworkTimeZone = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferences',
			parameters: {"keys":["useNetworkTimeZone"]}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}


SystemService.setUseNetworkTimeZone = function(value,callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setPreferences',
			parameters: {"useNetworkTimeZone":value}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getCurrentTimeZone = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferences',
			parameters: {"keys":["timeZone"]}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getTimeZoneValues = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferenceValues',
			parameters: {"key":"timeZone"}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}


SystemService.setTimeZone = function(value,callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setPreferences',
			parameters: {"timeZone":value}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getSystemTime = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.time_identifier, {
			method: 'getSystemTime',
			parameters:{subscribe: true},			
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.setSystemTime = function(value,callback) {
	
	var request = new Mojo.Service.Request(SystemService.time_identifier, {
			method: 'setSystemTime',
			parameters:value,			
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.setWaitForNetworkUpdate = function(key,value) {
	var params = {}
	params[key] = value;
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setPreferences',
			parameters: params
			
		});
	return request;
}

SystemService.getWaitForNetworkUpdate = function(key,callback) {
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferences',
			parameters: {keys:[key],subscribe: true}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}


