/* Copyright (C) 2007 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(giommconfig.h)

#include <glibmm/object.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)
_PINCLUDE(gio/gio.h)

namespace Gio
{

_WRAP_ENUM(AskPasswordFlags, GAskPasswordFlags, NO_GTYPE, decl_prefix GIOMM_API)
_WRAP_ENUM(PasswordSave, GPasswordSave, decl_prefix GIOMM_API)
_WRAP_ENUM(MountOperationResult, GMountOperationResult, NO_GTYPE, decl_prefix GIOMM_API)

/** Authentication methods for mountable locations.
 *
 * MountOperation provides a mechanism for authenticating mountable operations, such as loop mounting files, hard drive partitions or server locations.
 *
 * Mounting operations are handed a MountOperation that they can use if they require any privileges or authentication for their volumes to be mounted (e.g.
 * a hard disk partition or an encrypted filesystem), or if they are implementing a remote server protocol which requires user credentials such as FTP or
 * WebDAV.
 *
 * Developers should instantiate a subclass of this that implements all the various callbacks to show the required dialogs.
 *
 * @newin{2,16}
 */
class GIOMM_API MountOperation : public Glib::Object
{
  _CLASS_GOBJECT(MountOperation, GMountOperation, G_MOUNT_OPERATION, Glib::Object, GObject, , , GIOMM_API)

protected:
  _CTOR_DEFAULT

public:
  _WRAP_CREATE()

  _WRAP_METHOD(Glib::ustring get_username() const,
               g_mount_operation_get_username)
  _WRAP_METHOD(void set_username(const Glib::ustring& username),
               g_mount_operation_set_username)
  _WRAP_METHOD(Glib::ustring get_password() const,
               g_mount_operation_get_password)
  _WRAP_METHOD(void set_password(const Glib::ustring& password),
               g_mount_operation_set_password)
  _WRAP_METHOD(bool get_anonymous() const,
               g_mount_operation_get_anonymous)
  _WRAP_METHOD(void set_anonymous(bool anonymous = true),
               g_mount_operation_set_anonymous)
  _WRAP_METHOD(Glib::ustring get_domain() const,
               g_mount_operation_get_domain)
  _WRAP_METHOD(void set_domain(const Glib::ustring& domain),
               g_mount_operation_set_domain)
  _WRAP_METHOD(PasswordSave get_password_save() const,
               g_mount_operation_get_password_save)
  _WRAP_METHOD(void set_password_save(PasswordSave save),
               g_mount_operation_set_password_save)
  _WRAP_METHOD(int get_choice() const, g_mount_operation_get_choice)
  _WRAP_METHOD(void set_choice(int choice), g_mount_operation_set_choice)
  _WRAP_METHOD(void reply(MountOperationResult result), g_mount_operation_reply)


#m4 _CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING)
  _WRAP_SIGNAL(void ask_password(const Glib::ustring& message, const Glib::ustring& default_user, const Glib::ustring& default_domain, AskPasswordFlags flags), ask_password)

  //TODO: We really need some test to make sure that our use of ArrayHandler is correct. murrayc.
#m4 _EQUAL(const gchar**,const char**)
#m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const gchar**',`const_cast<const gchar**>(Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data())')
#m4 _CONVERSION(`const gchar**',`const std::vector<Glib::ustring>&',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, Glib::OWNERSHIP_NONE)')
  _WRAP_SIGNAL(void ask_question(const Glib::ustring& message, const std::vector<Glib::ustring>& choices), ask_question)

  _WRAP_SIGNAL(void reply(MountOperationResult result), reply)
  _WRAP_SIGNAL(void aborted(), aborted)

  //TODO: The array of char* is not very pleasant to wrap:
  //_WRAP_SIGNAL( void show_processes(const Glib::ustring& message, GArray* processes, const gchar *choices[]);

  _WRAP_SIGNAL(void show_unmount_progress(const Glib::ustring& message, gint64 time_left, gint64 bytes_left), "show_unmount_progress")

  _WRAP_PROPERTY("username", Glib::ustring)
  _WRAP_PROPERTY("password", Glib::ustring)
  _WRAP_PROPERTY("anonymous", bool)
  _WRAP_PROPERTY("domain", Glib::ustring)
  _WRAP_PROPERTY("password-save", PasswordSave)
  _WRAP_PROPERTY("choice", int)
};

} // namespace Gio
