Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / libkopete / kopetechatsessionmanager.h
blob952efdcc6c5e56a086f79e6397a2cce9455bde47
1 /*
2 kopetechatsessionmanager.h - Creates chat sessions
4 Copyright (c) 2002-2003 by Duncan Mac-Vicar Prett <duncan@kde.org>
6 Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
8 *************************************************************************
9 * *
10 * This library is free software; you can redistribute it and/or *
11 * modify it under the terms of the GNU Lesser General Public *
12 * License as published by the Free Software Foundation; either *
13 * version 2 of the License, or (at your option) any later version. *
14 * *
15 *************************************************************************
18 #ifndef KOPETECHATSESSIONMANAGER_H
19 #define KOPETECHATSESSIONMANAGER_H
21 #include <QtCore/QObject>
22 #include <QtCore/QList>
24 #include "kopetechatsession.h"
25 #include "kopetemessage.h"
27 #include "kopete_export.h"
29 class KopeteView;
31 namespace Kopete
34 class Contact;
35 class Protocol;
36 class MessageEvent;
38 typedef QList<Contact*> ContactPtrList;
39 typedef QList<Message> MessageList;
41 /**
42 * @author Duncan Mac-Vicar Prett <duncan@kde.org>
44 * Kopete::ChatSessionManager is responsible for creating and tracking Kopete::ChatSession
45 * instances for each chat.
47 class KOPETE_EXPORT ChatSessionManager : public QObject
49 Q_OBJECT
51 public:
52 static ChatSessionManager* self();
54 ~ChatSessionManager();
56 /**
57 * Create a new chat session. Provided is the initial list of contacts in
58 * the session. If a session with exactly these contacts already exists,
59 * it will be reused. Otherwise a new session is created.
60 * @param user The local user in the session.
61 * @param chatContacts The list of contacts taking part in the chat.
62 * @param protocol The protocol that the chat is using.
63 * @return A pointer to a new or reused Kopete::ChatSession.
65 Kopete::ChatSession* create( const Kopete::Contact *user,
66 Kopete::ContactPtrList chatContacts, Kopete::Protocol *protocol, Kopete::ChatSession::Form form = Kopete::ChatSession::Small );
68 /**
69 * Find a chat session, if one exists, that matches the given list of contacts.
70 * @param user The local user in the session.
71 * @param chatContacts The list of contacts taking part in the chat.
72 * @param protocol The protocol that the chat is using.
73 * @return A pointer to an existing Kopete::ChatSession, or 0L if none was found.
75 Kopete::ChatSession* findChatSession( const Kopete::Contact *user,
76 Kopete::ContactPtrList chatContacts, Kopete::Protocol *protocol);
78 /**
79 * Registers a Kopete::ChatSession (or subclass thereof) with the Kopete::ChatSessionManager
81 void registerChatSession(Kopete::ChatSession *);
83 /**
84 * Get a list of all open sessions.
86 QList<ChatSession*> sessions();
88 /**
89 * @internal
90 * called by the kmm itself when it gets deleted
92 void removeSession( Kopete::ChatSession *session );
94 /**
95 * create a new view for the manager.
96 * only the manager should call this function
98 KopeteView *createView( Kopete::ChatSession * , const QString &requestedPlugin = QString() );
101 * Post a new event. this will emit the @ref newEvent signal
103 void postNewEvent(Kopete::MessageEvent*);
106 * Returns the current active Kopete view
108 KopeteView *activeView();
110 signals:
112 * This signal is emitted whenever a message
113 * is about to be displayed by the KopeteChatWindow.
114 * Please remember that both messages sent and
115 * messages received will emit this signal!
116 * Plugins may connect to this signal to change
117 * the message contents before it's going to be displayed.
119 void aboutToDisplay( Kopete::Message& message );
122 * Plugins may connect to this signal
123 * to manipulate the contents of the
124 * message that is being sent.
126 void aboutToSend( Kopete::Message& message );
129 * Plugins may connect to this signal
130 * to manipulate the contents of the
131 * message that is being received.
133 * This signal is emitted before @ref aboutToDisplay()
135 void aboutToReceive( Kopete::Message& message );
138 * A new view has been created
140 void viewCreated( KopeteView * );
143 * A view as been activated(manually only?).
145 void viewActivated( KopeteView *view );
148 * A view is about to close.
150 void viewClosing( KopeteView *view );
153 * a new KMM has been created
155 void chatSessionCreated( Kopete::ChatSession *);
158 * the message is ready to be displayed
160 void display( Kopete::Message& message, Kopete::ChatSession * );
163 * A new event has been posted.
165 void newEvent(Kopete::MessageEvent *);
168 * The global shortcut for sending message has been used
170 void readMessage();
172 public slots:
173 void slotReadMessage();
175 private:
176 ChatSessionManager( QObject* parent = 0 );
178 class Private;
179 Private * const d;
181 static ChatSessionManager *s_self;
187 #endif // KOPETECHATSESSIONMANAGER_H
189 // vim: set noet ts=4 sts=4 sw=4: