delete iMeetings.takeFirst();
}
-void CommunicationManager::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room &aIn )
+void CommunicationManager::fetchMeetings( const int aWeek, const int aYear, const Room &aIn )
{
//prevent making multiple simultaneous user availibility requests
+ //TODO: Would be nice to queue these requests instead of just aborting
const RequestData* rd = findRequest( GetUserAvailability );
if( rd )
return;
+
+ // Set from to beginning, 00:00 of the requested week
+ QDateTime from = QDateTime::currentDateTime();
+ from = from.addYears( aYear - from.date().year() );
+ from = from.addDays( -1*(from.date().dayOfWeek()-1) );
+ from = from.addDays( (aWeek - from.date().weekNumber())*7 );
+ QTime midnight = from.time();
+ midnight.setHMS( 0,0,0 );
+ from.setTime( midnight );
+ qDebug() << "CommunicationManager::fetchMeetings from: " << from.toString();
+
+ QDateTime until = from.addDays(7);
+ qDebug() << "CommunicationManager::fetchMeetings until: " << until.toString();
+
+
ReqMsgGetUserAvailability msg;
msg.setTimeZone();
- msg.setTimeWindow( aFrom, aUntil );
+ msg.setTimeWindow( from, until );
msg.addUser( aIn.address() );
int id = iFetchingCommunication->request( msg.getContentTypeForHeader(), msg.getMessage() );
void CommunicationManager::cancelFetchMeetingDetails()
{
- const RequestData *rd = NULL;
- for( rd = findRequest( GetCalendarItem );rd != NULL; )
- {
- int id = rd->requestId;
+ const RequestData *rd = findRequest( GetCalendarItem );
+ if( rd != NULL ) {
+ int id = rd->requestId;
iCancelledRequests.append( id );
- rd = findRequest( GetCalendarItem );
}
}