X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2FIO%2FCommunication%2FCommunicationManager.cpp;h=2f340a076ad7b936be14a62149c2ce6f228ea25a;hb=8e4cea2a85073fb73a1dc58fb4adabb6269f4ac9;hp=c941c7d61f0e7b6a9ccf74adf7d05953cef31fbb;hpb=33edea90bd097065e8c6b63cabc6b4b22c6a5d2c;p=qtmeetings diff --git a/src/IO/Communication/CommunicationManager.cpp b/src/IO/Communication/CommunicationManager.cpp index c941c7d..2f340a0 100644 --- a/src/IO/Communication/CommunicationManager.cpp +++ b/src/IO/Communication/CommunicationManager.cpp @@ -39,15 +39,31 @@ CommunicationManager::~CommunicationManager() 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() );