Don't keep compiling/run if something failed.
[kdevelopdvcssupport.git] / plugins / teamwork / kdevteamwork.h
blob7515eee6e2ae79017d46670cb2cbe49c4489895b
1 /***************************************************************************
2 Copyright 2006 David Nolden <david.nolden.kdevelop@art-master.de>
3 ***************************************************************************/
5 /***************************************************************************
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
14 #ifndef KDEVTEAMWORK_H
15 #define KDEVTEAMWORK_H
17 #include <QObject>
18 #include <QMap>
19 #include <QMenu>
20 #include <QDomDocument>
21 #include <memory>
22 #include <kiconloader.h>
23 #include <set>
24 #include <list>
26 #include "teamworkfwd.h"
27 #include "loglevel.h"
28 #include "lib/network/safesharedptr.h"
29 #include "lib/network/messageinterface.h"
30 #include "autoconstructpointer.h"
32 using namespace Teamwork;
33 class KUrl;
35 namespace Ui {
36 class Teamwork;
39 class QModelIndex;
41 class KDevTeamwork : public QObject {
42 static KDevTeamwork* m_self;
43 enum MessageTypes {
44 Message = 0,
45 SourceMessage = 1
48 Q_OBJECT
49 public:
50 typedef SafeSharedPtr<KDevTeamworkClient> TeamworkClientPointer;
51 KDevTeamwork( const KUrl& workspaceDirectory, KDevTeamworkPlugin *plugin, QWidget *parent );
52 virtual ~KDevTeamwork();
54 KDevTeamworkPlugin *plugin() const;
56 static KDevTeamwork* self() ;
58 /**Sets the whole teamwork-part(client plus server) active/inactive. When set inactive, all connetions are closed.
59 on success returns the given activity-state. */
60 bool setActive( bool active );
62 /**enables/disables the server. */
63 bool setServerActive( bool active );
65 void showUserInfo( const UserPointer& user );
67 ///@todo: make this a signal
68 void fillUserMenu( QMenu* menu, const UserPointer& user );
70 ///The main fillMessageMenu is the one in the MessageManager. That also invokes this one.
71 void fillMessageMenu( QMenu* menu, const MessagePointer& msg );
73 ///@todo remove
74 Ui::Teamwork& widgets();
76 QWidget* widget();
78 IconCache& icons();
80 void log( const QString& str, LogLevel level = Info );
82 void err( const QString& str );
84 QIcon iconFromUser( User* user, KIconLoader::Group size = KIconLoader::Small );
86 ///Starts the update-timer for the developer-lists
87 void startUpdateTimer();
89 TeamworkClientPointer& client();
91 PatchesManager* patchesManager();
93 CollaborationManager* collaborationManager();
95 MessageManager* messageManager();
97 void handlePatchesList( PatchesListMessage* msg );
98 void getPatchesList( const UserPointer& user );
100 LoggerPointer logger();
102 ///Inserts the given message into the various GUI-structures. It should be based on AbstractGUIMessage.
103 void addMessageToList( const MessagePointer& smsg );
105 virtual void restorePartialProjectSession( const QDomElement* el );
107 virtual void savePartialProjectSession( QDomElement* el );
109 UserPointer localUser();
111 UserIdentity currentUserIdentity();
113 public slots:
115 /**Prepares the GUI for sending a message to the given user. Second parameter may be zero
116 * @param target The user the message should be sent to
117 * @param answerTo which message this one is a reply to.
118 * */
119 void guiSendMessageTo( const UserPointer& target, const MessagePointer& answerTo = MessagePointer() );
121 ///This can be used by messages in other threads to send a request that their state(currently only icon) has changed
122 void updateMessageInfo( MessagePointer );
124 signals:
125 ///This is called whenever the local client was destroyed or created, the current client is given as parameter(may be null). Whenever this is emitted, all UserPointers become invalid.
126 void updateConnection( TeamworkClientPointer client );
127 ///Called once KDevTeamwork is completely constructed
128 void init();
129 void deInit();
131 private slots:
132 void documentActivated( KDevelop::IDocument* file );
133 void popupContextMenu( const QPoint &pos );
134 void allowIncomingChanged( int state );
135 void enableCollaborationChanged( int state );
136 void connectServer();
138 void uiShowPatches();
139 void uiUserInfo();
141 void uiFilterLog();
143 void connectionRequest( ConnectionRequestPointer request );
145 void developerClicked( const QModelIndex& index );
146 void developerDoubleClicked( const QModelIndex& index );
147 void developerContextMenu( const QPoint& );
149 void serverClicked( const QModelIndex& index );
150 void clientClicked( const QModelIndex& index );
151 void messageClicked( const QModelIndex& index );
153 void serverDoubleClicked( const QModelIndex& index );
154 void clientDoubleClicked( const QModelIndex& index );
155 void messageDoubleClicked( const QModelIndex& index );
157 void receiveMessage( SafeSharedPtr<KDevSystemMessage> msg );
159 void clearLogButton();
160 void saveLogButton();
162 void messageReplyTimeout();
163 void sendMessageButton();
164 void messageTypeIndexChanged( const int index );
166 void slotClearMessageText();
168 void slotClearMessages();
169 void slotMessageHistory();
171 void disconnectFromServer();
172 void disconnectAllServers();
174 void sendAnswerMessage();
175 void sendMessageToUser();
176 void kickClient();
177 void banClient();
178 void kickAllClients();
180 void messageTargetUserChanged();
181 void updateAnswerMenu();
183 void handleTextMessage( SafeSharedPtr<KDevTeamworkTextMessage> msg );
185 void guiUserConnected( Teamwork::UserPointer );
186 void guiUserDisconnected( Teamwork::UserPointer );
187 void guiServerConnected( Teamwork::ClientSessionDesc, Teamwork::ServerInformation );
188 void guiServerDisconnected( Teamwork::ClientSessionDesc, Teamwork::ServerInformation );
189 void guiUserList( std::list<UserPointer> );
190 void guiLog( QString str, int level ) {
191 log( str, ( LogLevel ) level );
194 ///Should be called time by time after the state of users changes. This updates all lists that contain users.
195 void updateTimeout();
197 void messageUpdated( const MessagePointer& msg );
199 void maybeDeveloperContextMenu();
201 void answerMenuToggled( bool state );
202 void answerMenuTriggered( bool );
204 private:
205 void contextMenu( const QPoint& p, const QModelIndex& index );
207 void lockMessageGui( const MessagePointer& msg );
208 void unlockMessageGui();
210 friend class KDevTeamworkLogger;
211 friend class KDevTeamworkClient;
213 void addSentMessageToList( const MessagePointer&, QStandardItemModel* model );
215 void addReceivedMessageToList( const MessagePointer&, QStandardItemModel* model );
217 QAction* sendAnswerAction;
218 QAction* sendMessageToUserAction;
219 QAction* disconnectFromServerAction;
220 QAction* disconnectAllServersAction;
222 QAction* kickClientAction;
223 QAction* banClientAction;
224 QAction* kickAllClientsAction;
225 QAction* m_userInfoAction;
226 QAction* showPatchesAction;
228 UserPointer sendingUser();
230 MessagePointer sendingMessage();
232 void addSentMessageToList( const MessagePointer& );
234 void addReceivedMessageToList( const MessagePointer& );
236 void addDeveloper( const Teamwork::UserPointer& u );
238 void enableActiveGUI( bool active );
240 void enableMessageGUI( bool active );
242 void filterLog( int max = 0 );
244 void registerPatches( PatchesListMessage* msg, QStandardItemModel* model );
246 UserPointer currentMessageTargetUser();
248 QMenu* m_messageFilterMenu;
250 AutoConstructPointer<TeamworkFolderManager> m_folderManager;
252 SafeSharedPtr<KDevTeamworkLogger> m_logger;
254 bool m_destroyed;
255 KDevTeamworkPlugin *m_plugin;
256 QWidget* m_widget;
257 AutoConstructPointer<Ui::Teamwork> m_widgets;
258 bool m_active, m_serverActive;
259 TeamworkClientPointer m_client;
260 QStandardItemModel* m_logModel;
261 QStandardItemModel* m_messagesModel;
262 QStandardItemModel* m_clientsModel;
263 QStandardItemModel* m_serversModel;
264 QStandardItemModel* m_developersModel;
266 ///The next message to send is answer to:
267 MessagePointer m_answerTo;
268 MessagePointer m_waitingForReply; ///This message is blocking the message-gui waiting for a reply
269 QTimer* m_replyWaitingTimeout;
272 friend class MessageUserTab;
274 KDevTeamworkUserPointer currentTabUser();
276 typedef QMap<KDevTeamworkUserPointer, SharedPtr<MessageUserTab> > UserTabMap;
278 UserTabMap m_userTabs;
280 MessagePointer m_actionMessage;
282 QTimer* m_updateTimer;
283 QTimer* m_updateAnswerTimer; ///Timer for updating the list of possible messages the user can reply to
284 AutoConstructPointer<PatchesManager> m_patchesManager;
285 AutoConstructPointer<CollaborationManager> m_collaborationManager;
286 AutoConstructPointer<MessageManager> m_messageManager;
287 AutoConstructPointer<MessageSendManager> m_messageSendManager;
289 std::set<UserPointer, UserPointer::ValueSmallerCompare> m_persistentUsers;
291 LogLevel m_currentLogFilter;
293 AutoConstructPointer<IconCache> m_icons;
294 std::auto_ptr<QPersistentModelIndex> m_contextMenuIndex;
296 enum MessageTypeIndex {
297 NormalMessage,
298 DocumentMessage
302 #endif // KDEVCODEVIEW_H
304 // kate: space-indent on; indent-width 2; tab-width 2; replace-tabs on