1 /** \file TocChatWidget.h
2 * \brief Declaration of TocChatWidget class
4 * Tieto Open Communicator - Client for the Telepathy communications framework.
5 * Copyright (c) 2010, Tieto Corporation
8 * Redistribution and use in source and binary forms, with or without modification,
9 * are permitted provided that the following conditions are met:
11 * Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * Neither the name of the Tieto Corporation nor the names of its contributors
17 * may be used to endorse or promote products derived from this software without
18 * specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef TOCCHATWIDGET_H
33 #define TOCCHATWIDGET_H
39 class Ui_TocChatWidgetClass;
43 /** \brief TocChatWidget class
45 * Widget used as a conversation window. Enables sending of messages
46 * and notifies about presence changes of the contact by textual information
47 * and conversion window border color.
49 class TocChatWidget : public QWidget
58 TocChatWidget( const QString& uid, const QString& name, Presence presence, QWidget * parent = 0, const Message& message = Message() );
65 /** \brief Used to read uid property
67 * @return ID of the Contact for which the chat was created
69 QString uid() const { return _uid; }
71 /** \brief Used to read name property
73 * @return Name of the Contact for which the chat was created
75 QString name() const { return _name; }
77 /** \brief Used to set name property
79 * @param New name of the Contact
81 void onDisplayedNameChange(const QString& newName) { _name = newName; }
83 /** \brief Used to handle contact's presence change
85 * This method is used when status of the Contact has changed.
86 * It gives textual and graphical notification to the user.
88 * @param presence New contact's presence
89 * @param description New contact's presence description
91 void onContactPresenceUpdate(Presence presence, const QString& description);
93 /** \brief Used to update contact's presence
95 * This is used when the chat window was closed and did not
96 * recieved Contact Presence Updates, so it can show the current status properly.
98 void updateContactPresence(Presence presence);
100 /** \brief Used to handle incoming message
102 * @param message Message to be displayed in chat
104 void appendMessage(const Message& message);
108 /** \brief Used to filter incoming events
110 * This method is used to filter keyboards event.
111 * If Enter key is pressed, typed message is send (as pressing Send button).
112 * If Enter key is pressed with Shift key modifier new line in entered.
114 * @param *object Pointer to the object on which an event appears.
115 * @param *event Pointer to the event.
117 * @return If the event is a key event Enter without Shift modifier
118 * method returns true, otherwise false.
121 bool eventFilter(QObject *object, QEvent *event);
123 /** \brief Reimplemented from QWidget
126 virtual void showEvent(QShowEvent* event);
130 /** \brief Emited when new message is ready to be sent
132 * This signal is emited when user want's to send a prepared message.
134 * @param uid Contact's ID
135 * @param message Message to be sent
137 void newMessageReady(const QString& uid, Message message);
139 /** \brief Emited Smile button clicked.
141 * This signal is emited when user clicks on Smile button in Chat view,
142 * to choose emoticon.
145 void smileButtonClicked();
149 /** \brief Send message slot
151 * Invoked when message from chatWidget needs to be sent.
152 * It composes a message, emits a signal and wipes out a text from messageTextEdit.
155 void pressedSendButton();
156 /** \brief Shows emoticons dialog window.
159 void showEmoticonsDialog();
164 /** \brief Returns a human readable string for the given error type
166 * @param error Error id
167 * @return Human readable error description
169 QString errorString(MessageDeliveryError error);
171 /** \brief Appends new message to the chat dialog edit with parsed emoticons
174 /** \brief Inserts emoticons.
176 * Checks user message text for emoticons aliases and replace them with
177 * corresponding inage.
179 * @param message Message from user message text edit box.
182 void insertEmoticons(const QString& message);
186 QString _uid; /// User ID.
187 QString _name; /// User name.
189 Ui_TocChatWidgetClass* ui; /// Pointer to the TocChatWidgetClass form.
194 #endif // TOCCHATWIDGET_H