Don't keep compiling/run if something failed.
[kdevelopdvcssupport.git] / plugins / teamwork / kdevteamwork_client.h
blobf668b2f5bb8711c344a9030762e39f815946c573
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_CLIENT_H
15 #define KDEVTEAMWORK_CLIENT_H
18 #include "teamworkfwd.h"
19 #include "lib/network/safesharedptr.h"
20 #include "lib/network/teamworkclient.h"
21 #include "kdevteamwork_messages.h"
22 #include <list>
25 #include <QTimer>
27 ///@TODO: Dispatch the messages in a more flexible way: Allow any client to register with an arbitrary message-type that he wants to get(including all sub-messages). DynamicMessageDispatcher can do this. Use that, and make the way messages are connected more flexible.
29 Q_DECLARE_METATYPE( Teamwork::ServerInformation )
30 Q_DECLARE_METATYPE( Teamwork::UserPointer )
31 Q_DECLARE_METATYPE( ConnectionRequestPointer )
32 Q_DECLARE_METATYPE( SafeSharedPtr<KDevTeamworkTextMessage> )
33 Q_DECLARE_METATYPE( std::list<UserPointer> )
34 Q_DECLARE_METATYPE( SafeSharedPtr<KDevSystemMessage> )
35 Q_DECLARE_METATYPE( CollaborationMessagePointer )
37 ///most of the functions in this class are called from within another thread
38 class KDevTeamworkClient : public QObject, public Teamwork::Client
40 public:
41 KDevTeamworkClient( KDevTeamwork* teamwork );
43 void invalidateTeamwork() {
44 disconnectAllServers();
45 closeAllIncomingSessions();
46 stopRunning();
47 m_teamwork = 0;
50 int receiveMessage( CollaborationMessage* msg );
52 int receiveMessage( PatchesManagerMessage* msg );
54 int receiveMessage( KDevTeamworkTextMessage* msg );
56 int receiveMessage( KDevSystemMessage* msg );
58 int receiveMessage( ConnectionRequest* msg );
60 int receiveMessage( MessageInterface* /*msg*/ ) {
61 return 0;
64 signals:
65 ///All connections made to these signals must be queued, since these signals are emitted from within another thread
66 void guiUserConnected( Teamwork::UserPointer );
67 void guiUserDisconnected( Teamwork::UserPointer );
68 void guiServerConnected( Teamwork::ClientSessionDesc, Teamwork::ServerInformation );
69 void guiServerDisconnected( Teamwork::ClientSessionDesc, Teamwork::ServerInformation );
70 void guiUserList( std::list<UserPointer> );
72 void signalDispatchMessage( PatchesManagerMessagePointer );
73 void signalDispatchMessage( CollaborationMessagePointer );
75 protected:
76 virtual UserPointer createUser( IdentificationMessage* msg );
77 virtual UserPointer createUser( const User* user );
79 ///this is called whenever a new user successfully logged into the server
80 virtual void userConnected( const Teamwork::UserPointer& user );
82 ///called whenever a user leaves the server
83 virtual void userDisconnected( const Teamwork::UserPointer& user );
85 ///this is called whenever a connection is successfully established to a server
86 virtual void connectedToServer( const Teamwork::ClientSessionDesc& session, const Teamwork::ServerInformation& server );
88 ///this is called whenever a server the client disconnects from a connected server in any way
89 virtual void disconnectedFromServer( const Teamwork::ClientSessionDesc& session, const Teamwork::ServerInformation& server );
91 virtual void gotUserList( const std::list<UserPointer>& users );
93 void processMessage( MessageInterface* msg ) throw();
95 private:
97 //AllKDevTeamworkMessages, KDevTeamworkMessages
98 Q_OBJECT
99 KDevTeamwork* m_teamwork;
103 #endif
105 // kate: space-indent on; indent-width 2; tab-width 2; replace-tabs on