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

var AudioService = Class.create({ 
	initialize: function() { 
	}
});
    
AudioService.getSystemVolume = function(callback, sceneController) {
    var request = new Mojo.Service.Request(AudioService.system_identifier, {
      method: 'getVolume',
	  onSuccess: callback,
	  onFailure: callback
    });
	return request;
}
  
AudioService.setSystemVolume = function(volume,callback, sceneController) {
    var request = new Mojo.Service.Request(AudioService.system_identifier, {
      method: 'setVolume',
	  parameters: {volume:volume },
	  onSuccess: function(response) {
	  			if(callback)
					callback(response);
	  },
	  onFailure: function(response) {
	  			if(callback)
					callback(response);
	  },			
    });
	return request;
}
  
AudioService.getRingtoneVolume = function(callback, sceneController) {
   var request = new Mojo.Service.Request(AudioService.ringtone_identifier, {
      method: 'getVolume',
	  onSuccess: callback,
	  onFailure: callback
    });
	return request;
}
  
AudioService.setRingtoneVolume = function(volume,callback, sceneController) {
    var request = new Mojo.Service.Request(AudioService.ringtone_identifier, {
      method: 'setVolume',
	  parameters: {volume:volume },
	  onSuccess: function(response) {
	  			if(callback)
					callback(response);
	  },
	  onFailure: function(response) {
	  			if(callback)
					callback(response);
	  }			
    });
	return request;
}

AudioService.subscribeToRingtoneVolume = function(callback) {
   var request = new Mojo.Service.Request(AudioService.ringtone_identifier, {
      method: 'status',
	  parameters: {"subscribe": true},
	  onSuccess: callback,
	  onFailure: callback
    });
	return request;
}

AudioService.getVibrateSettings = function(callback, sceneController) {
   var request = new Mojo.Service.Request(AudioService.vibrate_identifier, {
      method: 'get',
	  onSuccess: callback,
	  onFailure: callback
    });
	return request;
}
  
AudioService.setVibrateSettings = function(whenRingerOn,whenRingerOff,callback, sceneController) {
    var request = new Mojo.Service.Request(AudioService.vibrate_identifier, {
      method: 'set',
	  parameters: {VibrateWhenRingerOn: whenRingerOn,
	  				VibrateWhenRingerOff: whenRingerOff },
	  onSuccess: function(response) {
	  			if(callback)
					callback(response);
	  },
	  onFailure: function(response) {
	  			if(callback)
					callback(response);
	  }			
    });
	return request;
}

AudioService.getSystemSoundStatus = function(callback) {
   var request = new Mojo.Service.Request(AudioService.system_identifier, {
      method: 'status',
	  parameters: {"subscribe": false},
	  onSuccess: callback,
	  onFailure: callback
    });
	return request;
}

AudioService.muteSystemSound = function(mute) {
   var request = new Mojo.Service.Request(AudioService.system_identifier, {
      method: 'setMuted',
	  parameters: {"muted": mute}, 
    });
	return request;
}

AudioService.system_identifier = 'palm://com.palm.audio/system';
AudioService.ringtone_identifier = 'palm://com.palm.audio/ringtone';
AudioService.vibrate_identifier = 'palm://com.palm.audio/vibrate';
