1 /***************************************************************************
2 Copyright 2006 David Nolden <david.nolden.kdevelop@art-master.de>
3 ***************************************************************************/
5 /***************************************************************************
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. *
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"
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
41 KDevTeamworkClient( KDevTeamwork
* teamwork
);
43 void invalidateTeamwork() {
44 disconnectAllServers();
45 closeAllIncomingSessions();
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*/ ) {
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
);
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();
97 //AllKDevTeamworkMessages, KDevTeamworkMessages
99 KDevTeamwork
* m_teamwork
;
105 // kate: space-indent on; indent-width 2; tab-width 2; replace-tabs on