/*
 * Copyright (C) 2009 - 2010 Funambol, Inc.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by
 * the Free Software Foundation with the addition of the following permission
 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program; if not, see http://www.gnu.org/licenses or write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA.
 *
 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by Funambol" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by Funambol".
 */

/* $Id$ */

#pragma once

#include "Errors.h"
#include "commontypes.h"
#include "daemon/IComponent.h"

namespace Funambol
{
    class Item;
}

namespace NS_DM_Client
{
	enum TNDSProperty
	{
		e_TNDS_ACL,
		e_TNDS_format,
		e_TNDS_name,
		e_TNDS_size,
		e_TNDS_title,
		e_TNDS_tstamp,
		e_TNDS_type,
		e_TNDS_verNo,
		e_TNDS_value
	};

	class IMOTreeManager: public IComponent
	{
	public:
        typedef std::vector<URI> ChildrenPaths;
		typedef std::vector<TNDSProperty> RequiredProperties;

		virtual bool Exist(const URI& uri, const char* serverId = 0) = 0;
		virtual StatusCode Get(const URI& uri, Funambol::Item& item, const char* serverId = 0) = 0;
		virtual StatusCode GetValue(const URI& uri, String& value, const char* serverId = 0) = 0; // works for leaves only
		virtual StatusCode GetPropertyValue(const URI& uri, const String& property_name, String& value, const char* serverId = 0) = 0; // works for leaves only
		virtual StatusCode GetChildren(const URI& uri, ChildrenPaths& children, const char* serverId = 0) = 0; // for interior node only
		virtual StatusCode GetAttributeStructData(const URI& uri, Funambol::ArrayList& items, const char* serverId = 0) = 0;
		virtual StatusCode GetAttributeTNDS(const URI& uri, const RequiredProperties& requiredProp, Funambol::StringBuffer*& xml, const char* serverId = 0) = 0;

		virtual StatusCode Add(const URI& uri, const Funambol::Item& item, const char* serverId = 0, bool isUpdateRequired = true) = 0;
		virtual StatusCode Delete(const URI& uri, const char* serverId = 0) = 0;
		virtual StatusCode Replace(const URI& uri, const Funambol::Item& item, const char* serverId = 0, bool isUpdateRequired = true) = 0;

		virtual StatusCode ReplacePropertyValue(const URI& uri, const String& property_name, const String& new_value, const char* serverId = 0) = 0;

		virtual StatusCode Copy(const URI& source, const URI& dest, const char* serverId = 0) = 0; // works for leaves only

        virtual StatusCode ExecPermitted(const URI& path, const char* serverId = 0) = 0;

        virtual StatusCode SetPropertyValue(const URI& uri, const String& property_name, const String& value) = 0;

	    virtual StatusCode StartTransaction() = 0;
	    virtual StatusCode Rollback() = 0;
	    virtual StatusCode Commit() = 0;
	};
}
