1 #ifndef COMMUNICATIONMANAGER_H_
2 #define COMMUNICATIONMANAGER_H_
7 #include "Communication.h"
9 #include "MessagingUtils.h"
11 class ConnectionSettings;
14 //! Responsible for Exchange server communication and request encoding and response parsing.
16 * CommunicationManager holds two connections to the Exchange server:
17 * Fetching and modifying connection. Fetching connetion is read only connection
18 * which has static authentication information defined in the application configuration.
19 * The modifying connection's authentication information varies, according to the user interface.
21 * NOTE! Currently Modifying connection is NOT implemented.
23 class CommunicationManager : public QObject
28 enum CommunicationType
30 FetchingCommunication,
31 ModifyingCommunication
37 * \param aConnection Reference to the fetching ConnectionSettings.
39 CommunicationManager( const ConnectionSettings &aConnection );
40 virtual ~CommunicationManager();
41 //! Starts fetching meetings. Meetings are returned by the meetingsFetched signal.
43 * Calls the MS Exchange GetUserAvailability WebService method.
44 * \param aFrom QDateTime to start searching from.
45 * \param aUntil QDateTime to search meetings until.
46 * \param aIn Meeting room meetings are searched.
48 void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room &aIn );
49 //! Starts fetching a meeting details. Details are returned by the meetingDetailsFetched signal.
51 * \param aMeeting A meeting the detailed information is wanted.
53 void fetchMeetingDetails( Meeting &aMeeting );
54 /* Not supported member functions which are using the modifying communication
55 void setModifyCredentials( const QString &aUsername, const QString &aPassword ) {};
56 void createMeeting( const Meeting &aMeeting ) {};
57 void updateMeeting( const Meeting &aMeeting ) {};
58 void deleteMeeting( const Meeting &aMeeting ) {};
62 //! Emitted when an error happens. Error could be QHttp or SOAP related.
64 * \param aCode An error code defined by CommunicationManager.
65 * \param aType FetchingCommunication or ModifyingCommunication.
67 void error( int aCode, CommunicationManager::CommunicationType aType );
68 //! Emitted when a http request is ongoing. Reports the bytes read from the server.
70 * \param aDone Bytes read from the server.
71 * \param aTotal Bytes total of the response.
72 * \param aType FetchingCommunication or ModifyingCommunication.
74 void readProgress( int aDone, int aTotal, CommunicationManager::CommunicationType aType );
75 //! Emitted when meetings are fetched.
77 * \param aMeetings Meetings found according to the search criteria.
79 void meetingsFetched( const QList<Meeting*> &aMeetings );
80 //! Emitted when meeting details are fetched.
82 * \param aDetailedMeeting Meeting which contains detailed information.
84 void meetingDetailsFetched( Meeting &aDetailedMeeting );
87 //! Connected to Communication::requestFinished.
88 void requestFinished( int aRequestId, int aError );
89 //! Connected to Communication::readProgress.
90 void readProgress( int aRequestId, int aDone, int aTotal );
93 //! Gets the secondary id number of a meeting.
95 * Calls the MS Exchange ConvertId WebService method. Converts primary id
96 * number to secondary id number.
97 * \param aMeeting A meeting which contains primaryId number.
99 void getSecondaryIdForMeeting( Meeting &aMeeting );
100 //! Gets the details of a meeting.
102 * Calls the MS Exchange GetCalendarItem WebService method.
103 * \param aMeeting A meeting the detailed information is wanted.
105 void getMeetingDetails( Meeting &aMeeting );
108 * Lists the WebService methods known by the CommunicationManager.
112 GetUserAvailability = 1,
116 //! Internal data structure which contains data about requests made to Exchange server.
120 RequestData( RequestType aType, int aRequestId ) :
121 type( aType ), requestId( aRequestId ), room( NULL ), meeting( NULL ) {};
124 if( type == GetUserAvailability )
127 //! Holds one of the enum RequestType value
129 //! Request ID number returned by the Communication::request
131 //! Pointer to a Room related to this request. NULL by default. Owned.
133 //! Pointer to a Meeting related to this request. Not owned.
136 //! Adds a request to the iRequestInfos list.
138 * \param aType One of the enum RequestType value.
139 * \param aRequestId Request ID number returned by the Communication::request
141 void addRequest( RequestType aType, int aRequestId );
142 //! Takes RequestData off from the iRequestInfos list.
144 * Returns a pointer to RequestData data structure. Removes RequestData from
145 * the iRequestInfos list.
146 * \param aRequestId Request ID number returned by the Communication::request
148 RequestData* takeRequest( int aRequestId );
149 //! Finds a RequestData from the iRequestInfos list.
151 * Returns a pointer to RequestData, NULL if not found.
152 * \param aRequestType Request type
154 const RequestData* findRequest( RequestType aRequestType ) const;
157 //! Instance of Connection settings of the fetching communication
158 ConnectionSettings *iConnectionSettings;
159 //! Instance of the fetching communication
160 Communication* iFetchingCommunication;
161 //! Instance of the modifying communication
162 Communication* iModifyingCommunication;
163 //! Temporary list which holds the lastest meetings fetched
164 QList<Meeting*> iMeetings;
165 //! Additional information about requests made to the Exchange server
166 QList<RequestData*> iRequestInfos;
169 #endif /*COMMUNICATIONMANAGER_H_*/