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

var DataImportService = Class.create( {
	initialize: function() {
		
	},
  
  	getStatus: function(successCallback, errorCallback)	{
		return new Mojo.Service.Request(DataImportService.identifier, {
			method: 'getStatus',
			parameters: {'subscribe':true},
			onSuccess: successCallback,
			onFailure: errorCallback
		});
	},
	
	deleteData: function (successCallback, errorCallback) {
		return new Mojo.Service.Request(DataImportService.identifier, {
			method: 'deleteData',
			parameters: {"sendResponse": true},
			onSuccess: successCallback,
			onFailure: errorCallback
		});
	},
	
	importData: function(syncChoice, accountId, successCallback, errorCallback, sceneController) {
		Mojo.log("Import Data ---------");
		return sceneController.serviceRequest(DataImportService.identifier, {
			method: 'importData',
			parameters: {"syncChoice": syncChoice, "accountId": accountId},
			onSuccess: successCallback,
			onFailure: errorCallback
		});
	},
	
	getAllAccountsOfUser: function (successCallback, errorCallback, sceneController) {
		var serviceTypes = ["CONTACTS", "CALENDAR", "TASKS"];
		return new Mojo.Service.Request(DataImportService.accountIdentifier, {
			method: 'getAllAccountsForService',
			parameters: {"services": serviceTypes, "includeReadOnlyDataAccounts": false, 
						"includeHidden": false, "includeOnlyUserCreatable": true, "subscribe": true},
			onSuccess: successCallback,
			onFailure: errorCallback
		});
	},
	
	getLocalAccount: function (successCallback, errorCallback) {
		return new Mojo.Service.Request(DataImportService.identifier, {
			method: 'getLocalAccount',
			parameters: {},
			onSuccess: successCallback,
			onFailure: errorCallback
		});
	},
	
	getDataTransferReport: function (successCallback, errorCallback) {
		return new Mojo.Service.Request(DataImportService.identifier, {
			method: 'getDataTransferReport',
			parameters: {},
			onSuccess: successCallback,
			onFailure: errorCallback
		});
	},
	
	launchHelp: function(){
		var helpParams = {
			 target: 'http://help.palm.com/data_transfer/index.html'
		};
		 
		return new Mojo.Service.Request('palm://com.palm.applicationManager', {
			method: 'open',
			parameters: {
				id: 'com.palm.app.help',
				params: helpParams
			}
		});
	},
	
	getTransferredPIMTypes: function (successCallback, errorCallback) {
		return new Mojo.Service.Request(DataImportService.identifier, {
			method: 'getTransferredPIMTypes',
			parameters: {},
			onSuccess: successCallback,
			onFailure: errorCallback
		});
	}
	
});

DataImportService.identifier = 'palm://com.palm.dataimport';
DataImportService.accountIdentifier = 'palm://com.palm.accounts';