/**********************************************************************
 * LeechCraft - modular cross-platform feature rich internet client.
 * Copyright (C) 2006-2014  Georg Rudoy
 *
 * Boost Software License - Version 1.0 - August 17th, 2003
 *
 * Permission is hereby granted, free of charge, to any person or organization
 * obtaining a copy of the software and accompanying documentation covered by
 * this license (the "Software") to use, reproduce, display, distribute,
 * execute, and transmit the Software, and to prepare derivative works of the
 * Software, and to permit third-parties to whom the Software is furnished to
 * do so, all subject to the following:
 *
 * The copyright notices in the Software and this entire statement, including
 * the above license grant, this restriction and the following disclaimer,
 * must be included in all copies of the Software, in whole or in part, and
 * all derivative works of the Software, unless such copies or derivative
 * works are solely in the form of machine-executable object code generated by
 * a source language processor.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 **********************************************************************/

#pragma once

#include <QList>
#include <QString>
#include <QtPlugin>
#include "devicetypes.h"

class QAbstractItemModel;

/** @brief Interface for classes providing information about removable
 * devices.
 *
 * This interface is to be implemented by plugins that provide
 * information about currently connected USB Mass Storage devices or
 * removable devices in general.
 *
 * The information is provided via the model returned by the
 * GetDevicesModel() method. Each row corresponds to a separate device or
 * its part, like a partition for a flash drive. The model is
 * hierarchical: for example, partitions of a flash drive are children of
 * the row representing the flash drive itself.
 *
 * Each row of the model should contain data for roles defined in the
 * LeechCraft::CommonDevRole enum as well as LeechCraft::USBDeviceRole or
 * LeechCraft::MassStorageRole enums, depending on the device type.
 */
class Q_DECL_EXPORT IRemovableDevManager
{
public:
	virtual ~IRemovableDevManager () {}

	/** @brief Checks whether the plugin can handle the device \em type.
	 *
	 * This function should return whether the device manager plugin
	 * recognizes the given \em type of the devices, like USB mass
	 * storages.
	 *
	 * If a device type is supported, the connected devices of the
	 * corresponding \em type are expected to be found in the model
	 * returned by the GetDevicesModel() method.
	 *
	 * @param[in] type The type of the devices to check.
	 * @return Whether the \em type is recognized and supported by the
	 * plugin.
	 */
	virtual bool SupportsDevType (LeechCraft::DeviceType type) const = 0;

	/** @brief Returns the model describing the devices.
	 *
	 * Each row of the model should contain data for roles defined in the
	 * LeechCraft::CommonDevRole enum as well as LeechCraft::USBDeviceRole or
	 * LeechCraft::MassStorageRole enums, depending on the device type.
	 *
	 * The returned model should be flat - in other words, no hierarchy is
	 * assumed to be present.
	 *
	 * @return The model describing the currently attached removable
	 * devices.
	 */
	virtual QAbstractItemModel* GetDevicesModel () const = 0;

	/** @brief Tries to mount the device with the given \em id.
	 *
	 * This function tried to mount the device identified by \em id, if
	 * applicable. The \em id corresponds to the ID contained in the
	 * CommonDevRole::DevID role.
	 *
	 * @param[in] id The identifier (as in CommonDevRole::DevID) of the
	 * device to mount.
	 *
	 * @sa CommonDevRole::DevID
	 */
	virtual void MountDevice (const QString& id) = 0;
};

Q_DECLARE_INTERFACE (IRemovableDevManager, "org.Deviant.LeechCraft.IRemovableDevManager/1.0")
