/*
* Copyright (C) 2010 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef LIBKTELEPATHY_KTELEPATHYACCOUNTSWIDGET_H
#define LIBKTELEPATHY_KTELEPATHYACCOUNTSWIDGET_H

#warning KTelepathyAccountsWidget is really ugly, it should not be used exept for testing.

#include <kdemacros.h>

#include <QComboBox>
#include <TelepathyQt4/Constants>

#include "ontologies/personcontact.h"
#include "ontologies/person.h"


//TODO Find a better name
class KTelepathyAccountsWidgetPrivate;
class KDE_EXPORT KTelepathyAccountsWidget : public QComboBox
{
    Q_OBJECT
    Q_DISABLE_COPY(KTelepathyAccountsWidget)
    Q_DECLARE_PRIVATE(KTelepathyAccountsWidget)

    Q_FLAGS(ConnectionPresence)
    Q_ENUMS(DisplayMode)

    Q_PRIVATE_SLOT(d_func(), void __k__displayModeAccounts())
    Q_PRIVATE_SLOT(d_func(), void __k__displayModeContacts())
    Q_PRIVATE_SLOT(d_func(), void __k__displayModeMetaContacts())
    Q_PRIVATE_SLOT(d_func(), void __k__onCurrentIndexChanged(int))

    public:

        enum ConnectionPresence
        {
            ConnectionPresenceUnset           = 1 << Tp::ConnectionPresenceTypeUnset,
            ConnectionPresenceOffline         = 1 << Tp::ConnectionPresenceTypeOffline,
            ConnectionPresenceAvailable       = 1 << Tp::ConnectionPresenceTypeAvailable,
            ConnectionPresenceAway            = 1 << Tp::ConnectionPresenceTypeAway,
            ConnectionPresenceExtendedAway    = 1 << Tp::ConnectionPresenceTypeExtendedAway,
            ConnectionPresenceHidden          = 1 << Tp::ConnectionPresenceTypeHidden,
            ConnectionPresenceBusy            = 1 << Tp::ConnectionPresenceTypeBusy,
            ConnectionPresenceUnknown         = 1 << Tp::ConnectionPresenceTypeUnknown,
            ConnectionPresenceError           = 1 << Tp::ConnectionPresenceTypeError,

            ConnectionPresenceAnyConnected    = ConnectionPresenceAvailable | ConnectionPresenceAway | ConnectionPresenceExtendedAway | ConnectionPresenceHidden | ConnectionPresenceBusy,
            ConnectionPresenceAnyDisconnected = ConnectionPresenceUnset | ConnectionPresenceOffline | ConnectionPresenceUnknown | ConnectionPresenceError,
            ConnectionPresenceAny             = ConnectionPresenceAnyConnected | ConnectionPresenceAnyDisconnected
        };
        Q_DECLARE_FLAGS(ConnectionPresences, ConnectionPresence)

        enum DisplayMode
        {
            DisplayModeAccounts,
            DisplayModeContacts,
            DisplayModeMetaContacts
        };

        KTelepathyAccountsWidget(QWidget* parent = 0);

        KTelepathyAccountsWidget(ConnectionPresences allowedConnectionPresences,
                                 QWidget* parent = 0);

        KTelepathyAccountsWidget(DisplayMode displayMode,
                                 ConnectionPresences allowedConnectionPresences = ConnectionPresenceAny,
                                 QWidget* parent = 0);

        virtual ~KTelepathyAccountsWidget();

        virtual Nepomuk::IMAccount currentAccount();
        virtual Nepomuk::PersonContact currentContact();
        virtual Nepomuk::Person currentMetaContact();
        virtual Nepomuk::Variant currentResource();

        void setConnectionPresences(ConnectionPresences connectionPresences);
        ConnectionPresences connectionPresences();

        void setDisplayMode(DisplayMode displayMode);
        DisplayMode displaymode();

    // TODO later
    //public slots:
        //virtual void update();
    // TODO listen for signals and update entries

    protected:
        KTelepathyAccountsWidgetPrivate* const d_ptr;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(KTelepathyAccountsWidget::ConnectionPresences)

#endif // LIBKTELEPATHY_KTELEPATHYACCOUNTSWIDGET_H
