/***************************************************************************
 *   Copyright (C) 2005 by the G System Team                               *
 *   http://www.g-system.at                                                *
 *                                                                         *
 *   Permission is hereby granted, free of charge, to any person obtaining *
 *   a copy of this software and associated documentation files (the       *
 *   "Software"), to deal in the Software without restriction, including   *
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 *   permit persons to whom the Software is furnished to do so, subject to *
 *   the following conditions:                                             *
 *                                                                         *
 *   The above copyright notice and this permission notice shall be        *
 *   included in all copies or substantial portions of the Software.       *
 *                                                                         *
 *   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 AND NONINFRINGEMENT.*
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 ***************************************************************************/

#ifndef GCOMMUNICATIONWIDGET_H
#define GCOMMUNICATIONWIDGET_H

#include <qwidget.h>

class KTextEdit;
class KLineEdit;
class KListBox;

/**
 * \class GCommunicationWidget GCommunicationWidget.h
 * \brief A widget that handles text messaging between users.
 * @author Raphael Langerhorst
 * 
*/
class GCommunicationWidget : public QWidget
{
  Q_OBJECT
  
  protected:
    
    /**
     * Lists all known servers part of the G Universe with their JID.
     */
    KListBox* InternalServerList;
    
    /**
     * Lists all known servers external to the G Universe with their JID.
     */
    KListBox* ExternalServerList;
    
    /**
     * History of all communication.
     */
    KTextEdit* MessageHistory;
    
    /**
     * The destination for sent messages.
     */
    KLineEdit* MessageDestination;
    
    /**
     * The actual message text to be sent.
     */
    KLineEdit* MessageText;
    
  public:
    
    /**
     * Constructor
     */
    GCommunicationWidget(QWidget* parent = 0, const char* name = 0, WFlags f = 0);
  
    /**
     * Destructor
     */
    virtual ~GCommunicationWidget();
  
  public slots:
    
    
    //BEGIN CONTACT MANAGEMENT
    /**
     * Sets the list of known communication contacts inside
     * the G Universe.
     */
    void replaceInternalContactList(QStringList contacts);
    
    void replaceExternalContactList(QStringList contacts);
    
    void clearInternalContacts();
    
    void clearExternalContacts();
    
    void addInternalContact(QString contact);
    
    void addExternalContact(QString contact);
    
    void removeInternalContact(QString contact);
    
    void removeExternalContact(QString contact);
    
    /**
     * Updates contact states for internal and external lists.
     * @note the very same contact can also switch from !internal to internal
     *       through this slot, it must then be correctly moved in the
     *       different contact lists.
     */
    void updateContactState(QString contact, bool available, bool internal);
    
    //END CONTACT MANAGEMENT
    
    //BEGIN MESSAGE MANAGEMENT
    
  protected slots:
    
    /**
   * Puts a message together from destination and message edit lines.
   * This message is then sent with the sendMessage signal.
   * @todo move into new client interface class.
   * @see sendMessage()
     */
    void prepareMessageForSending();
    
  public slots:
    
    void receiveMessage(QString message, QString from, bool internal);

    //END MESSAGE MANAGEMENT
    
  signals:
    
    void contactSelected(QString contact);
    
    void sendMessage(QString message, QString destination);
};

#endif


syntax highlighted by Code2HTML, v. 0.9.1