/*
 *  Copyright (C)  2000-2001 Marc Wandschneider <mw@kiltdown.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation.
 *
 *  For more information look at the file COPYRIGHT in this package
 *
 */
#ifndef _IACCOUNT_H_

#include <iaccounthost.h>

#include <kmaillist.h>
#include <ifolder.h>


class QPopupMenu;
class QPixmap;
class QWidget;
class ISubsystem;

/**
 * This file defines the interface that classes can implement to allow them
 * to interact with the folder view.  This is so that the maximum numbers of
 * protocols and exchanges can be supported.
 *
 * CONSIDER: marcw, 10.2.2000 -- i've currently designed this so that there 
 * cannot be duplicate named folders in a given account.  Is this killer bad?
 */

/**
 * Possible values for the passwordDialogResponse
 */
enum PasswordDialogResponse {

    NoResponse = -1,
    UserAbort = 0,
    NewNameAndPassword,
    ErrorOccurred
};

enum AccountPixmapSize {

    SmallPixmap = 0,
    LargePixmap = 1
};


/**
 * This is the interface that subsystems implement to hook into the folder 
 * view.
 */ 
class IAccount {

  public:
    /**
     * Tells the account to delete the currently 'selected' items in the
     * given folder.  The folder will be the currently focused folder -- we
     * just pass it in to them to save them from having to do so.
     */
    virtual ERRCODE deleteSelectedInFolder(IFolder *) = 0;

    /**
     * This is a little odd -- this function can be called from the function 
     * that is performing the download.  This is done by sending a message of
     * type DispatchEvent to the main widget in the application using 
     * QThread::postEvent().    The parameter data is then passed to this
     * method and should be cleaned up by this method.  I will write a more 
     * detailed document describing this a bit later.
     */
    virtual ERRCODE downloadProgress(void *) = 0;

    /**
     * Shows the editor window to let the user create a new message or
     * whatever in this account.
     */
    virtual ERRCODE editNew() = 0;

    /**
     * Returns the name of the default folder in this account.
     */
    virtual ERRCODE getDefaultFolder(const char **) = 0;

    /**
     * Returns the display name for this account.  CALLER frees the returned
     * string.
     */
    virtual ERRCODE getDisplayName(const char **) = 0;

    /**
     * this function is a request for the function and the parameters to pass
     * to said function to start downloading the 'goo' in this account. this
     * will be called in a different thread, so accounts need to be careful to
     * be thread safe while downloading messages !!!!
     * NOTE: THE CALLED FUNCTION (*pfn) IS RESPONSIBLE FOR CLEANING UP ANY
     * ALLOCATIONS MADE FOR THE PARAMETERS.
     */
    virtual ERRCODE getDownloadInfo(ERRCODE (**pfn)(IAccount *, void *), void **pparams) = 0;

    /**
     * Indicates whether folders in this account can be compacted ...
     */
    virtual bool getCanCompactFolders() = 0;

    /**
     * Returns the number of folders that will be in this account.
     */
    virtual ERRCODE getFolderCount(int *) = 0;

    /**
     * Returns the list of folders.  CALLER must free returned array using
     * localFree()
     */
    virtual ERRCODE getFolderList(IFolder ***) = 0;

    /**
     * Returns the context menu for the given folder.
     */
    virtual ERRCODE getFolderPopup(IFolder *, QPopupMenu * &popup) = 0;

    /**
     * Returns the subsystem that we're working in.
     */
    virtual ERRCODE getHostSubsystem(ISubsystem * &) = 0;

    /**
     * Returns the pixmap associated with this account for the given size.
     */
    virtual ERRCODE getPixmap(AccountPixmapSize, QPixmap *&) = 0;

    /**
     * Are we a mail account?
     */
    virtual bool isMailAccount() = 0;

    /**
     * open a new 'editor' window with the given address as the intended 
     * recipient for this.  initially used for "mailto:" support, i hope this
     * will work for things like news: urls, etc ...
     */
    virtual ERRCODE mailto(const char *) = 0;

    /**
     * creates a new "Folder" entity in the given account.  It's up to the 
     * account to decide what to do here.
     */
    virtual ERRCODE newFolder() = 0;

    /**
     * The account asked to show the password dialog.  Here we give them the
     * reply/results of said dialog.
     */
    virtual void passwordDialogResponse(PasswordDialogResponse resp,
                                        const char * name,
                                        const char * passwd,
                                        bool remember) = 0;

    /**
     * Rename the account with the new name.
     */
    virtual void renameAccount(const char *) = 0;

    /**
     * tells the account to show its account properties with the given parent
     * as the dialog parent.
     */
    virtual void showAccountProperties(QWidget *parent) = 0;

    /**
     * Initializes the new account.
     */
    virtual ERRCODE setAccountHost(IAccountHost *) = 0;

    /**
     * Called when we're about to terminate.  Provides an opportunity to clean
     * anything up.
     */
    virtual void terminateAccount() = 0;
};





#define _IACCOUNT_H_
#endif // _IACCOUNT_H_




syntax highlighted by Code2HTML, v. 0.9.1