Logo Search packages:      
Sourcecode: kmess version File versions

chatwindow.h

/***************************************************************************
                          chatwindow.h  -  description
                             -------------------
    begin                : Wed Jan 15 22:41:32 CST 2003
    copyright            : (C) 2003 by Mike K. Bennett
    email                : mkb137b@hotmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CHATWINDOW_H
#define CHATWINDOW_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qdatetime.h>
#include <qptrlist.h>
#include <qtimer.h>

#include <kapp.h>

#include "chatwindowinterface.h"

// Forward declarations
class ChatInformation;
class ChatView;
class ChatMessage;
class ContactBase;
class ContactAction;
class ContactSidebar;
class CurrentAccount;
class EmoticonSidebar;
class KMessTest;
class MsnSwitchboardConnection;
class QDir;
class QLabel;
class WebSidebar;

/* ChatWindow is the main window for a chat with one or more contacts */
class ChatWindow : public ChatWindowInterface
{
  Q_OBJECT 

  friend class KMessTest;

  public:
    // The construtor
                       ChatWindow(QWidget* parent=0, const char *name=0);
    // The destructor 
                      ~ChatWindow();
    // Initialize the object
    bool               initialize();
    // Return the switchboard connection used by the chat window.
    MsnSwitchboardConnection * getSwitchboardConnection() const;
    // Return whether or nor the contact is in this chat.
    bool               isContactInChat( const QString &handle );
    // Return whether or not this is an exclusive chat with the given contact
    bool               isExclusiveChatWithContact( const QString& handle );
    // Start a chat
    void               startChat( const ChatInformation &chatInfo );
    // Initialize a chat window, pretending the contact is in the chat
    void               startOfflineChat( const QString &handle );
    // Show a status message temporary in the status dialog
    void               showStatusMessage( const QString &message, int duration = 5000 );
    // Show a wink received by a contact
    void               showWink( const QString &handle, const QString &filename, const QString &animationName );
    // Update the messages which contain custom emoticons
    void               updateCustomEmoticon( const QString &handle, const QString &code );

  public slots:
    // A message was received from a contact.
    void               receivedMessage(const ChatMessage &message);

  protected:
    // Restore the window properties (called by KMainWindow)
    virtual void       readProperties(KConfig *config);
    // Save the window properties (called by KMainWindow)
    virtual void       saveProperties(KConfig *config);

  protected slots:
    // put the marked text/object into the clipboard and remove
    //      it from the document
    void               editCut();
    // put the marked text/object into the clipboard
    void               editCopy();
    // Bring up a dialog to change the message font color.
    void               editFontColor();
    // Bring up a dialog to change the message font color.
    void               editFont();
    // paste the clipboard into the document
    void               editPaste();
    // "Show status bar" was toggled.
    void               showStatusBar();
    // Send a nudge
    void               slotSendNudge();
    // Send a file to a contact.
    void               slotStartFileTransfer();
    //Voice conversation
    void               startConversation();
    // Start GnomeMeeting with a contact.
    void               startMeeting();
    // Change the status bar message.
    void               statusMessage(QString message);
    // Called when the "use emoticons" action is called.
    void               toggleEmoticons(bool useEmoticons);
    // Called when the "show sidebar" action is called.
    void               toggleSidebar();

  private: // Private methods
    // Check if the user enabled an auto-reply, and send it
    void               checkAutoReply();
    // Toggle the sidebar based on account preferences
    void               checkSidebarPreferences();
    // Choose the contact to start an invitation with.
    const QString &    chooseContact(); 
    // Create the contact actions
    void               createContactActions();
    // Return the contact action with the given handle
    ContactAction*     getContactActionByHandle(const QString& handle);
    // Set up the main chat view
    bool               initializeChatView();
    // Set up the contact sidebar
    bool               initializeContactSidebar();
    // Set up the current account
    bool               initializeCurrentAccount();
    // Initialize the emoticon chooser
    bool               initializeEmoticonSidebar();
    // Set up the switchboard connection
    bool               initializeSwitchboardConnection();
    // Set up the contact sidebar
    bool               initializeWebSidebar();
    // The application is exiting
    bool               queryExit();
    // The chat window is closing
    bool               queryClose();
    // Save the chat if necessary
    void               saveChatAutomatically();
    // Shake the window, for nudge/buzzer effect.
    void               shakeWindow();
    // Start blinking the caption
    void               startBlink();

  private slots: // Private slots
    // Make the caption blink if the window still doesn't have focus
    void               blinkCaption();
    // A contact joined the chat
    void               contactJoined(QString handle, QString friendlyName);
    // A contact left the chat
    void               contactLeft(QString handle);
    // A contact is typing
    void               contactTyping(QString handle, QString friendlyName);
    // The emoticon button was pressed.
    void               emoticonButtonPressed();
    // Forward the application command to the ChatMaster
    void               forwardAppCommand(QString cookie, QString contact, QString command);
    // Forward the request for a new chat connection
    void               forwardRequestChat(QString handle);
    // Invite a contact to the chat
    void               inviteContact(QString handle);
    // Notify the user of a received nudge
    void               slotReceivedNudge(const QString &handle);
    // Save the chat according to the user's request
    void               saveChat();
    // Clear the status label text
    void               slotClearStatus();
    // The user sent a new message
    void               userSentMessage();

  private: // Private attributes
    // A timer used to make the caption blink on new messages.
    QTimer             blinkTimer_;
    // Whether to blink to upper (true) or lower (false) case
    bool               blinkToUpper_;
    // The stored window caption
    QString            caption_;
    // The chat view widget
    ChatView          *chatView_;
    // The contact actions in the invite menu
    QPtrList<ContactAction> contactActions_;
    // The contact sidebar, which goes in the qtoolbox widget
    ContactSidebar    *contactSidebar_;
    // A pointer to the instance of the current account
    CurrentAccount    *currentAccount_;
    // The emoticon sidebar
    EmoticonSidebar   *emoticonSidebar_;
    // The first contact who joined the chat
    QString            firstContact_;
    // Whether or not the incoming message is the first incoming message
    bool               firstMessage_;
    // Whether or not the object was initialized
    bool               initialized_;
    // The last time the window was shaked
    QTime              lastShake_;
    // The object that connects to the switchboard server.
    MsnSwitchboardConnection *msnSwitchboardConnection_;
    // The sidebar widths
    int                sidebarWidth_;
    // The date/time the chat started
    QDate              startDate_;
    QTime              startTime_;
    // The status label
    QLabel            *statusLabel_;
    // A timer to time the duration that a status message is shown
    QTimer             statusTimer_;
    // Whether the sidebar should only be temporary visible
    bool               temporarySidebar_;
    // The web sidebar, which goes in the qtoolbox widget
    WebSidebar        *webSidebar_;
// 
  signals: // Public signals
    // Signal that there's an application command
    void               appCommand(QString cookie, QString contact, QString method);
    // Signal that the window is about to close.
    void               closing(QObject *object);
    // Signal that a new chat has started
    void               newChat(const ContactBase *contact, QString message, ChatWindow *chatWindow);
    // Signal that the ChatMaster should request a new switchboard connection
    void               requestChat(QString handle);
    // Signal that the ChatMaster should start a filetransfer.
    void               requestFileTransfer(const QString &handle, const QString &filename);
    // Signal that the ChatMaster should start a newmeeting session.
    void               requestNetMeeting(const QString &handle);
};

#endif

Generated by  Doxygen 1.6.0   Back to index