Merge branch 'jasa'
authorJan Lapinkataja <jan.lapinkataja@ixonos.com>
Thu, 28 May 2009 06:57:35 +0000 (09:57 +0300)
committerJan Lapinkataja <jan.lapinkataja@ixonos.com>
Thu, 28 May 2009 06:57:35 +0000 (09:57 +0300)
27 files changed:
QtMeetings.conf
QtMeetings.pro
src/BusinessLogic/Engine.cpp
src/BusinessLogic/Engine.h
src/BusinessLogic/UIManager.cpp [new file with mode: 0644]
src/BusinessLogic/UIManager.h [new file with mode: 0644]
src/Domain/Configuration/Configuration.cpp
src/Domain/Configuration/Configuration.h
src/Domain/Configuration/DateTimeSettings.cpp [new file with mode: 0644]
src/Domain/Configuration/DateTimeSettings.h [new file with mode: 0644]
src/IO/Communication/MessagingUtils.cpp
src/UserInterface/Components/MeetingRoomCombo.cpp
src/UserInterface/Components/MeetingRoomCombo.h
src/UserInterface/Components/TimeDisplayWidget.cpp
src/UserInterface/Components/TimeDisplayWidget.h
src/UserInterface/Views/MeetingInfoDialog.cpp
src/UserInterface/Views/MeetingInfoDialog.h
src/UserInterface/Views/RoomStatusIndicatorWidget.cpp
src/UserInterface/Views/RoomStatusIndicatorWidget.h
src/UserInterface/Views/SettingsView.cpp
src/UserInterface/Views/SettingsView.h
src/UserInterface/Views/ViewBase.cpp [new file with mode: 0644]
src/UserInterface/Views/ViewBase.h [new file with mode: 0644]
src/UserInterface/Views/WeeklyViewWidget.cpp
src/UserInterface/Views/WeeklyViewWidget.h
src/UserInterface/WindowManager.cpp
src/UserInterface/WindowManager.h

index 7066087..04cb472 100644 (file)
                        <name>Hercules</name>
                        <address>meetingroom.hercules@ixonos.com</address>
                </room>
-       </rooms>
+    </rooms>
+
+    <daylight_saving_time>
+               <!-- Sunday = 0, Monday = 1, Tuesday = 2 etc.. -->
+               <DayOfWeek>0</DayOfWeek>
+               <!-- date/time format is dd.MM.yyyy hh:mm:ss  -->
+               <StandardTimeChangeMoment>05.10.2009 03:00:00</StandardTimeChangeMoment>
+               <DaylightSaveTimeChangeMoment>01.04.2010 03:00:00</DaylightSaveTimeChangeMoment>
+    </daylight_saving_time>
+       
 
        <!-- language code must be in ISO 3166-1 alpha-2 standard -->
        <language code="EN" />
index c57d210..b4c6c65 100644 (file)
@@ -13,13 +13,15 @@ INCLUDEPATH += src/Domain/ \
     src/UserInterface/Components/ \
     src/UserInterface/Utils/ \
     src/UserInterface/Views/
-HEADERS += src/IO/DeviceControl/OperationModeToggler.h \
+HEADERS += src/BusinessLogic/UIManager.h \
+    src/IO/DeviceControl/OperationModeToggler.h \
     src/UserInterface/Utils/ProgressBar.h \
     src/Domain/Room.h \
     src/Domain/Meeting.h \
     src/Domain/Configuration/ConnectionSettings.h \
     src/Domain/Configuration/StartupSettings.h \
     src/Domain/Configuration/DisplaySettings.h \
+    src/Domain/Configuration/DateTimeSettings.h \
     src/Domain/Configuration/Configuration.h \
     src/IO/Communication/MessagingUtils.h \
     src/IO/Communication/Communication.h \
@@ -44,14 +46,17 @@ HEADERS += src/IO/DeviceControl/OperationModeToggler.h \
     src/UserInterface/Views/WeeklyViewWidget.h \
     src/UserInterface/Views/MeetingInfoDialog.h \
     src/UserInterface/Views/SettingsView.h \
-    src/UserInterface/WindowManager.h
-SOURCES += src/IO/DeviceControl/OperationModeToggler.cpp \
+    src/UserInterface/WindowManager.h \
+    src/UserInterface/Views/ViewBase.h
+SOURCES += src/BusinessLogic/UIManager.cpp \
+    src/IO/DeviceControl/OperationModeToggler.cpp \
     src/UserInterface/Utils/ProgressBar.cpp \
     src/Domain/Room.cpp \
     src/Domain/Meeting.cpp \
     src/Domain/Configuration/ConnectionSettings.cpp \
     src/Domain/Configuration/StartupSettings.cpp \
     src/Domain/Configuration/DisplaySettings.cpp \
+    src/Domain/Configuration/DateTimeSettings.cpp \
     src/Domain/Configuration/Configuration.cpp \
     src/IO/Communication/MessagingUtils.cpp \
     src/IO/Communication/Communication.cpp \
@@ -77,6 +82,7 @@ SOURCES += src/IO/DeviceControl/OperationModeToggler.cpp \
     src/UserInterface/Views/MeetingInfoDialog.cpp \
     src/UserInterface/Views/SettingsView.cpp \
     src/UserInterface/WindowManager.cpp \
+    src/UserInterface/Views/ViewBase.cpp \
     src/main.cpp
 RESOURCES += resources/BusinessLogic.qrc \
     resources/UserInterface.qrc
index 0aad994..009dbdd 100644 (file)
@@ -5,10 +5,10 @@
 #include "Configuration.h"
 #include "DisplaySettings.h"
 #include "CommunicationManager.h"
-#include "DeviceManager.h"
+// #include "DeviceManager.h"
 #include "Clock.h"
 #include "ErrorMapper.h"
-#include "WeeklyViewWidget.h"
+#include "UIManager.h"
 
 #include <QApplication>
 #include <QTimer>
 QTime Engine::endOfTheDay = QTime( 23, 59, 0, 0); // end of the day is 11:59pm
 const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
 
-Engine::Engine() :
-       iClock( 0), iConfiguration(Configuration::instance() ), iCommunication( 0)
-{
-       qDebug() << "Engine::Engine()";
-       // if reading of configuration fails, signal that initialization failed
-       if (iConfiguration == 0)
-       {
-               QTimer::singleShot( 0, this, SLOT( closeApplication() ));
-               return;
+// Macro to help deleting objects. This could be global.
+#define QT_DELETE(X) \
+       if ( X != 0 ) \
+       { \
+               delete X; \
+               X = 0; \
        }
 
-       //initialize window manager
-       iWindowManager = new WindowManager( iConfiguration );
-       connect(iWindowManager, SIGNAL( roomStatusInfoNeeded( Room * ) ), this, SLOT( roomStatusInfoNeeded( Room * ) ));
-       connect(iWindowManager, SIGNAL( observedEventDetected() ), this, SLOT( observedEventDetected() ));
-       connect(iWindowManager, SIGNAL( meetingActivated( Meeting * ) ), this, SLOT( fetchMeetingDetails( Meeting * ) ));
-       connect(iWindowManager, SIGNAL( currentRoomChanged( Room * ) ), this, SLOT( currentRoomChanged( Room * ) ));
-       connect(iWindowManager, SIGNAL( shownWeekChanged( QDate ) ), this, SLOT( shownWeekChanged( QDate ) ));
-       connect(iWindowManager, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ));
-
-       // initialize communication
-       iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) );
-       connect(iCommunication, SIGNAL( error( int, CommunicationManager::CommunicationType ) ), this, SLOT( errorHandler( int ) ));
-       connect(iCommunication, SIGNAL( meetingsFetched( const QList<Meeting*>& ) ), this, SLOT( meetingsFetched( const QList<Meeting*>& ) ));
-       connect(iCommunication, SIGNAL( meetingDetailsFetched( Meeting& ) ), this, SLOT( meetingDetailsFetched( Meeting& ) ));
 
+Engine::Engine() :
+               iClock( 0 ), iConfiguration( 0 ), iCommunication( 0 ),
+               iWindowManager( 0 ), iUIManager( 0 )
+{
+       qDebug() << "Engine::Engine()";
+       
+       initConfiguration();
+       initDevice();
+       initCommunication();
+       initUserInterface();
+       
        //initialize idle time counter
        iIdleTimeCounter = new QTimer();
        iIdleTimeCounter->setSingleShot( true);
        iIdleTimeCounter->setInterval(IDLE_TIME_MULTIPLIER * iConfiguration->displaySettings()->screensaver() );
        iIdleTimeCounter->start();
-       connect(iIdleTimeCounter, SIGNAL( timeout() ), iWindowManager, SLOT( showRoomStatus() ));
 
        // create application clock
        iClock = new Clock;
-       connect(iClock, SIGNAL( tick( QDateTime ) ), this, SLOT( checkStatusOfAllRooms() ));
-       connect(iClock, SIGNAL( tick( QDateTime ) ), iWindowManager, SLOT( distributeDateTimeInfo( QDateTime ) ));
+       connect( iClock, SIGNAL( tick( QDateTime ) ), this, SLOT( checkStatusOfAllRooms() ) );
+       // connect( iClock, SIGNAL( tick( QDateTime ) ), iWindowManager, SLOT( distributeDateTimeInfo( QDateTime ) ) );
 
+       // Create auto refresh timer
        iAutoRefresh = new QTimer;
        iAutoRefresh->setInterval(iConfiguration->connectionSettings()->refreshInterval() * 1000);
        iAutoRefresh->start();
-       connect(iAutoRefresh, SIGNAL( timeout() ), iAutoRefresh, SLOT( start() ));
-       connect(iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ));
-
-       // create device manager
-       iDevice = new DeviceManager( iConfiguration->startupSettings() );
-       connect(iDevice, SIGNAL( error( int, const QString& ) ), this, SLOT( errorHandler( int, const QString& ) ));
-       connect(iDevice, SIGNAL( changeModeOrdered( DeviceManager::OperationMode ) ), this, SLOT( changeModeOrdered( DeviceManager::OperationMode ) ));
-       iDevice->initDeviceManager();
-
-       if (iDevice->currentOperationMode() == DeviceManager::KioskMode)
-               iWindowManager->fullScreen();
+       connect( iAutoRefresh, SIGNAL( timeout() ), iAutoRefresh, SLOT( start() ) );
+       // connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) );
+       
+       if( iDevice->currentOperationMode() == DeviceManager::KioskMode )
+       {
+               iWindowManager->setFullscreen();
+       }
 
-       QTimer::singleShot( 0, this, SLOT( fetchMeetings() ));
+       connectSignals();
+       
+       // QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) );
 
        // TODO: continue implementation
 }
@@ -81,15 +73,18 @@ Engine::~Engine()
        qDebug() << "Engine::~Engine()";
        while ( !iMeetings.isEmpty() )
                delete iMeetings.takeFirst();
-       iIdleTimeCounter->stop();
-       delete iIdleTimeCounter;
-       iIdleTimeCounter = 0;
-       delete iWindowManager;
-       iWindowManager = 0;
-       delete iClock;
-       iClock = 0;
-       delete iDevice;
-       iDevice = 0;
+       
+       if ( iIdleTimeCounter != 0 )
+       {
+               iIdleTimeCounter->stop();
+               delete iIdleTimeCounter;
+               iIdleTimeCounter = 0;
+       }
+       QT_DELETE( iClock );
+       QT_DELETE( iDevice );
+
+       QT_DELETE( iUIManager );
+       QT_DELETE( iWindowManager );
 }
 
 void Engine::closeApplication()
@@ -99,23 +94,6 @@ void Engine::closeApplication()
        QTimer::singleShot( 1000, QApplication::instance(), SLOT( quit() ));
 }
 
-void Engine::observedEventDetected()
-{
-       qDebug() << "Engine::observedEventDetected()";
-       if ( !iIdleTimeCounter->isActive() )
-       {
-               iWindowManager->weeklyView()->showCurrentWeek();
-       }
-       iWindowManager->showWeeklyView();
-       // prepare to restart idle counter
-       if (iIdleTimeCounter->isActive() )
-       {
-               iIdleTimeCounter->stop();
-       }
-       // (re)start idle counter
-       iIdleTimeCounter->start();
-}
-
 Room* Engine::defaultRoom()
 {
        qDebug() << "Engine::defaultRoom()";
@@ -124,7 +102,7 @@ Room* Engine::defaultRoom()
 
 void Engine::checkStatusOfAllRooms()
 {
-       qDebug() << "Engine::checkStatusOfAllRooms()";
+//     qDebug() << "Engine::checkStatusOfAllRooms()";
        // iterate trough on the rooms
        for (int i = 0; i < iConfiguration->rooms().count(); i++)
        {
@@ -135,8 +113,8 @@ void Engine::checkStatusOfAllRooms()
 
 int Engine::indexOfMeetingAt(Room *aRoom, QDateTime aAt)
 {
-       qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
-       for (int i = 0; i < iMeetings.count(); i++)
+//     qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
+       for ( int i = 0; i < iMeetings.count(); i++ )
        {
                // exchange server ensures that there is only one meeting in a room at a specified time
                if (aRoom->equals(iMeetings.at( i )->room() ) && iMeetings.at( i )->startsAt() <= aAt && iMeetings.at( i )->endsAt() >= aAt)
@@ -149,7 +127,7 @@ int Engine::indexOfMeetingAt(Room *aRoom, QDateTime aAt)
 
 int Engine::indexOfMeetingAfter(Room *aRoom, QDateTime aAfter)
 {
-       qDebug() << "Engine::indexOfMeetingAfter( Room *, QDateTime )";
+//     qDebug() << "Engine::indexOfMeetingAfter( Room *, QDateTime )";
        // seeks for the next meeting on the SAME DAY
        int min = -1;
        for (int i = 0; i < iMeetings.count(); i++)
@@ -169,8 +147,8 @@ int Engine::indexOfMeetingAfter(Room *aRoom, QDateTime aAfter)
 
 void Engine::roomStatusInfoNeeded(Room *aRoom)
 {
-       qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
-       if (aRoom == 0)
+//     qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
+       if ( aRoom == 0 )
        {
                return;
        }
@@ -186,24 +164,31 @@ void Engine::roomStatusInfoNeeded(Room *aRoom)
        ( ( indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay );
 
        //currently works only for deafult room
-       if (aRoom->equals( *(defaultRoom() )) )
-               iWindowManager->roomStatusChanged(aRoom, status, until);
+//     if( aRoom->equals( *(defaultRoom() ) ) )
+//             iWindowManager->roomStatusChanged( aRoom, status, until );
 }
 
+/*
 void Engine::fetchMeetings()
 {
-       qDebug() << "Engine::fetchMeetings for " << iWindowManager->weeklyView()->currentRoom();
+       qDebug() << "Engine::fetchMeetings for " << iCurrentRoom;
        QDateTime from( iWindowManager->weeklyView()->beginnigOfShownWeek() );
        QDateTime to( from.addDays( 7 ) );
-       fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+       // fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+       // Signal is connected to the currentRoomChanged slot which keeps the iCurrentRoom up to date
+       fetchMeetings( from, to, iCurrentRoom );
 }
+*/
 
 void Engine::fetchMeetingDetails( Meeting *aMeeting )
 {
        qDebug() << "Engine::fetchMeetingDetails( Meeting* )";
-       iWindowManager->showProgressBar( tr( "Please Wait" ), true );
-       iWindowManager->updateProgressBar( tr( "Fetching Meeting Details..." ) );
-       connect(iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( fetchMeetingDetailsCancelled() ));
+/*     iWindowManager->showProgressBar(tr("Please Wait"), true);
+       iWindowManager->updateProgressBar(tr("Fetching Meeting Details...") );
+       connect(iWindowManager, 
+       SIGNAL( progressBarCancelled() ), this, 
+       SLOT( fetchMeetingDetailsCancelled() ));
+       iCommunication->fetchMeetingDetails( *aMeeting); */
        iCommunication->fetchMeetingDetails( *aMeeting );
 }
 
@@ -221,95 +206,168 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
                iMeetings.append( m );
        }
 
-       iWindowManager->refreshMeetings( iMeetings );
        // refresh room status info
        roomStatusInfoNeeded( defaultRoom() );
 }
 
-void Engine::meetingDetailsFetched( Meeting &aDetailedMeeting )
-{
-       qDebug() << "Engine::meetingDetailsFetched( Meeting & )";
-       iWindowManager->closeProgressBar();
-       iWindowManager->showMeetingInfo( &aDetailedMeeting );
-}
-
 void Engine::errorHandler( int aCode, const QString &aAddInfo )
-{
-       qDebug() << "Engine::ErrorHandler, aCode: " << aCode;
-       // inform UI about the problem
-       if( aCode >= 100 && aCode <= 150 ) { //communication errors
-               //we don't want these to close operation changing
-               qDebug() << "CommunicationManager signaled an error:" << aCode;
-               iWindowManager->closeProgressBar();
+{      
+       if ( iWindowManager != 0 )
+       {
+               iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
        }
-       iWindowManager->error( ErrorMapper::codeToString(aCode, aAddInfo ) );
 }
 
-void Engine::currentRoomChanged( Room *aCurrentRoom )
+void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
 {
-       qDebug() << "Engine::currentRoomChanged to " << aCurrentRoom->name();
-       QDateTime from(iWindowManager->weeklyView()->beginnigOfShownWeek() );
-       QDateTime to( from.addDays( 7 ) );
-       fetchMeetings( from, to, aCurrentRoom );
+       qDebug()
+                       << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
+       iCommunication->fetchMeetings(aFrom, aUntil, *aIn);
 }
 
-void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
+void Engine::cancelFetchMeetingDetails()
 {
-       qDebug() << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
-       iCommunication->fetchMeetings( aFrom, aUntil, *aIn );
+       iCommunication->cancelFetchMeetingDetails();
 }
 
 void Engine::shownWeekChanged( QDate aFrom )
 {
-       qDebug() << "Engine::shownWeekChanged( QDate )";
+       qDebug() << "[Engine::shownWeekChanged] <Invoked>";
        QDateTime from( aFrom );
        QDateTime to( aFrom.addDays( 7 ), QTime( 23, 59 ) );
-       qDebug() << "Engine::shownWeekChanged " << aFrom.toString( "d.m. h:mm" ) << " to " << to.toString( "d.m. h:mm" );
-       fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+       qDebug() << "[Engine::shownWeekChanged] <From " << aFrom.toString( "d.m. h:mm" ) << " to " << to.toString( "d.m. h:mm" ) << ">";
+       iCommunication->fetchMeetings( from, to, *defaultRoom() );
+//     fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+}
+
+void Engine::changeDeviceMode( bool aChange )
+{
+       if ( aChange )
+       {
+               connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) );
+               iAutoRefresh->stop(); // Stop the meeting update
+       }
+       iDevice->changeMode( aChange );
+}
+
+void Engine::changeModeFailed()
+{
+       qDebug() << "Engine::progressBarCancelled()";
+       iDevice->changeMode( false );
+       iAutoRefresh->start(); //we start the metting updating
 }
 
-void Engine::changeModeOrdered( DeviceManager::OperationMode aMode )
+void Engine::initUserInterface()
 {
-       qDebug() << "Engine::changeModeOrdered( DeviceManager::OperationMode )";
-       QString message = tr( "You are about to change operation mode to %1." ).arg( iDevice->operationModeToString(aMode ) );
+       qDebug() << "[Engine::initUserInterface] <Invoked>";
+       
+       // Initialize the window manager and connect what ever signals can be connected
+       iWindowManager = new WindowManager;
+       // Create the UIManager which internally handles most of the UI actions
+       iUIManager = new UIManager( this, iWindowManager );
+       
+       connect( iWindowManager, SIGNAL( eventDetected() ), this, SLOT( handleViewEvent() ) );
+       connect( iWindowManager, SIGNAL( previousViewRestored() ), iUIManager, SLOT( previousViewRestored() ) );
+       connect( iWindowManager, SIGNAL( dialogActivated() ), this, SLOT( dialogActivated() ) );
+       connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
+       
+       // Show the UI
+       iWindowManager->setWindowState( Qt::WindowMaximized );
+       iWindowManager->show();
+       iUIManager->showMainView();
+       
+       qDebug() << "[Engine::initUserInterface] <Finished>";
+}
 
-       iWindowManager->showPasswordDialog( iConfiguration->adminPassword(), message );
+void Engine::handleViewEvent()
+{
+       if ( iIdleTimeCounter != 0 )
+       {
+               // Restart the idle time counter when view event is received
+               iIdleTimeCounter->stop();
+               iIdleTimeCounter->start();
+       }
 }
 
-void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus )
+void Engine::initConfiguration()
 {
-       qDebug() << "Engine::passwordEntered( PasswordDialog::PasswordStatus )";
-       iWindowManager->closePasswordDialog();
-
-       switch ( aPasswordStatus ) {
-               case PasswordDialog::Correct:
-                       iAutoRefresh->stop(); //we stop the metting updating
-                       iWindowManager->showProgressBar( "Changing current operation mode." );
-                       connect(iDevice, SIGNAL( changingMode( const QString & ) ), iWindowManager, SLOT( updateProgressBar( const QString & ) ));
-                       connect( iDevice, SIGNAL( changingMode( const QString & ) ),
-                                       iWindowManager, SLOT( updateProgressBar( const QString & ) ) );
-                       connect( iDevice, SIGNAL( changeModeFailed() ), this, SLOT( changeModeFailed() ) );
-                       iDevice->changeMode( true);
-                       break;
-               case PasswordDialog::Incorrect:
-                       iWindowManager->error( tr( "Incorrect password." ) );
-                       iDevice->changeMode( false );
-                       break;
-               default: //case PasswordDialog::Canceled
-                       iDevice->changeMode( false );
+       iConfiguration = Configuration::instance();
+       if ( iConfiguration == 0 )
+       {
+               QTimer::singleShot( 0, this, SLOT( closeApplication() ) );
        }
+       iCurrentRoom = iConfiguration->defaultRoom();
 }
 
-void Engine::changeModeFailed()
+void Engine::connectSignals()
 {
-       qDebug() << "Engine::changeModeFailed()";
-       iWindowManager->closeProgressBar();
-       iAutoRefresh->start(); //we start the metting updating
+       // Connect engine objects signals to UIManager
+       connect( iClock, SIGNAL( tick( QDateTime ) ), iUIManager, SLOT( updateTime( QDateTime ) ) );
+       connect( iIdleTimeCounter, SIGNAL( timeout() ) , iUIManager, SLOT( roomStatusIndicatorRequested() ) );
+       
+       iUIManager->connectDeviceManager( iDevice );
+       iUIManager->connectCommunicationManager( iCommunication );
 }
 
-void Engine::fetchMeetingDetailsCancelled()
+void Engine::initCommunication()
 {
-       iCommunication->cancelFetchMeetingDetails();
-       iWindowManager->closeProgressBar();
+       // initialize communication
+       iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) );
+       connect( iCommunication, SIGNAL( error( int, CommunicationManager::CommunicationType  ) ),
+                       this, SLOT( errorHandler( int ) ) );
+       connect( iCommunication, SIGNAL( meetingsFetched( const QList<Meeting*>& ) ),
+                       this, SLOT( meetingsFetched( const QList<Meeting*>& ) ) );
 }
 
+void Engine::initDevice()
+{
+       // create device manager
+       iDevice = new DeviceManager( iConfiguration->startupSettings() );
+       connect( iDevice, SIGNAL( error( int, const QString& ) ), this, SLOT( errorHandler( int, const QString& ) ) );  
+       iDevice->initDeviceManager();
+}
+
+void Engine::dialogActivated()
+{
+       if ( iIdleTimeCounter != 0 )
+       {
+               iIdleTimeCounter->stop();
+       }
+}
+
+void Engine::dialogDeactivated()
+{
+       if ( iIdleTimeCounter != 0 )
+       {
+               iIdleTimeCounter->start();
+       }
+}
+
+void Engine::previousViewRestored()
+{
+       if ( iIdleTimeCounter != 0 )
+       {
+               iIdleTimeCounter->start();
+       }
+}
+
+void Engine::stopIdleTimeCounter()
+{
+       if ( iIdleTimeCounter != 0 )
+       {
+               iIdleTimeCounter->stop();
+       }
+}
+
+void Engine::startIdleTimeCounter()
+{
+       if ( iIdleTimeCounter != 0 )
+       {
+               iIdleTimeCounter->start();
+       }
+}
+
+void Engine::currentRoomChanged(Room *aRoom)
+{
+       iCurrentRoom = aRoom;
+}
\ No newline at end of file
index 14d2740..99992dd 100644 (file)
@@ -5,13 +5,15 @@
 #include <QDateTime>
 #include "Room.h"
 #include "WindowManager.h"
+#include "DeviceManager.h"
+#include "PasswordDialog.h"
 
 class QTimer;
 class Clock;
 class Configuration;
 class CommunicationManager;
 class Meeting;
-class DeviceManager;
+class UIManager;
 
 //! BusinessLogic class. Contains all the business logic of the application.
 /*!
@@ -39,8 +41,6 @@ public:
 
 signals:
 
-       void meetingDetailsFetched( Meeting *aDetailedMeeting );        
-
 private slots:
        //! Slot. Closes the application.
        /*!
@@ -53,17 +53,6 @@ private slots:
         * \param aRoom The room which availability information is needed.
         */
        void roomStatusInfoNeeded( Room *aRoom );
-       //! Slot. Indicates that some user event has happened.
-       /*!
-        * Slot. Indicates that some user event has happened.
-        */
-       void observedEventDetected();
-       //! Slot. Asks the communication to fetch new meeting data.
-       /*!
-        * Slot. Asks the communication to fetch new meeting data.
-        * \param aCurrentRoom The current room.
-        */
-       void currentRoomChanged( Room *aCurrentRoom );
        //! Slot. Asks the communication to fetch new meeting data.
        /*!
         * Slot. Asks the communication to fetch new meeting data.
@@ -83,7 +72,7 @@ private slots:
         * Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
         * room from current and +/- 2 weeks are fetched.
         */
-       void fetchMeetings();
+//     void fetchMeetings();
        //! Slot. Saves fetched meetings to the current instance's local storage.
        /*!
         * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
@@ -92,34 +81,12 @@ private slots:
         * \param aMeetings The list of freshly fetched meetings.
         */
        void meetingsFetched( const QList<Meeting*>& );
-       
-       void meetingDetailsFetched( Meeting &aDetailedMeeting );
-       
        //! Slot. Checks the availability of all the rooms.
        /*!
         * Slot. Checks the availability of all the rooms by iterating through the current object's local
         * room storage and calling the roomStatusInfoNeeded() separately on each of them.
         */
        void checkStatusOfAllRooms();
-       //! Slot for popping up the confirmation dialog to change the current operation mode
-       /*!
-        * Slot. Asks Window manager to pop up a confirmation dialog.
-        * \param aMode The operation mode to be changed to
-        */
-       void changeModeOrdered( DeviceManager::OperationMode aMode );
-       //! Slot. Fetches meeting details from the server.
-       /*!
-        * Slot. Fetches meeting details from the server.
-        * \param aMeeting The meeting.
-        */
-       void fetchMeetingDetails( Meeting *aMeeting );
-       //! Slot for receiving the status of the entered password
-       /*!
-        * Slot. Receives the status of the entered password and makes the DeviceManager to change the
-        * operation mode if the password is correct.
-        * \param aPasswordStatus The status of the password.
-        */
-       void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
        //! Slot for receiving the failure event of operation mode changing.
        /*!
         * Slot. Receives the failure event of operation mode changing.
@@ -129,9 +96,38 @@ private slots:
        /*!
         *  Receives the cancel event of the progress bar when meeting details requested.
         */
-       void fetchMeetingDetailsCancelled();
+       void fetchMeetingDetails( Meeting *aMeeting );
+       void cancelFetchMeetingDetails();
+       
+       void handleViewEvent();
+       void previousViewRestored();
+       
+       //! Slot for dialog activation signal.
+       /*!
+        * This slot is used to inform that dialog is activated. It stops
+        * the idle time counter so screensaver is not activated while the
+        * dialog is displayed.
+        */
+       void dialogActivated();
+       //! Slot for dialog deactivation signal.
+       /*!
+        * This slot is used to inform that dialog is deactivated. It restarts
+        * the idle time counter so that the screensaver is being activated again
+        * as needed.
+        */
+       void dialogDeactivated();
+       
+       void stopIdleTimeCounter();
+       void startIdleTimeCounter();
 
+       void changeDeviceMode( bool aChange );
+       
+       void currentRoomChanged( Room *aRoom );
+       
 private:
+       // Make the UIManager as friendly class so it can connect to private slots.
+       friend class UIManager;
+       
        //! Provides the index of the Meeting instance which is at the specified time.
        /*!
         * Provides the index of the Meeting instance which is at the specified time. If there are
@@ -158,20 +154,58 @@ private:
         * \param aIn The room which meetings need to be fetched.
         */
        void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
+       //! Initialize configuration package.
+       /*!
+        * This method initializes configuration classes and
+        * connects signals from and to the engine.
+        */
+       void initConfiguration();
+       //! Initialize device package.
+       /*!
+        * This method initializes device manager and
+        * connects signals from and to the engine.
+        */
+       void initDevice();
+       //! Initialize communication package.
+       /*!
+        * This method initializes the communication manager and
+        * connects signals from and to the engine.
+        */
+       void initCommunication();
+       //! Initialize user interface package.
+       /*!
+        * This method initializes the user interface and
+        * connects signals from and to the engine. This method
+        * makes the window manager visible and shows weekly
+        * view as the first view.
+        */
+       void initUserInterface();
+       //! Connects signal between objects.
+       /*!
+        * Signals that could not be connected while initializing different
+        * packages are connected here.
+        */
+       void connectSignals();
        
+       bool isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting);
+
 private:
        static QTime endOfTheDay;
 
        WindowManager *iWindowManager;
+       
        QTimer *iIdleTimeCounter;
        Clock *iClock;
        Configuration *iConfiguration;
        CommunicationManager *iCommunication;
        DeviceManager *iDevice;
+       UIManager *iUIManager;
 
        QTimer *iAutoRefresh;
 
        QList<Meeting*> iMeetings;
+       
+       Room *iCurrentRoom;
 };
 
 #endif /*ENGINE_H_*/
diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp
new file mode 100644 (file)
index 0000000..d6d16b3
--- /dev/null
@@ -0,0 +1,300 @@
+#include "UIManager.h"
+
+#include <QDateTime>
+#include <QTime>
+
+#include "Engine.h"
+#include "WindowManager.h"
+#include "ViewBase.h"
+#include "WeeklyViewWidget.h"
+#include "SettingsView.h"
+#include "RoomStatusIndicatorWidget.h"
+#include "MeetingInfoDialog.h"
+#include "ProgressBar.h"
+#include "CommunicationManager.h"
+#include "Configuration.h"
+#include "DisplaySettings.h"
+
+#include <QtDebug>
+
+#define QT_DELETE(X) \
+       if ( X != 0 ) \
+       { \
+               delete X; \
+               X = 0; \
+       }
+
+UIManager::UIManager( Engine *aEngine, WindowManager *aWindowManager ) :
+       iEngine( aEngine ),
+       iWindowManager( aWindowManager ),
+       iWeeklyView( 0 ),
+       iSettingsView( 0 ),
+       iRoomStatusIndicator( 0 ),
+       iPasswordDialog( 0 ),
+       iProgressBar( 0 ),
+       iMeetingInfo( 0 )
+{
+       if ( iEngine == 0 ) return;
+       if ( iWindowManager == 0 ) return;
+       
+       qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
+       
+       createWeeklyView();
+       createSettingsView();
+       createRoomStatusIndicator();
+       createPasswordDialog();
+       createProgressBar();
+       createMeetingInfoDialog();
+       
+       qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
+}
+
+UIManager::~UIManager()
+{
+       iEngine = 0;
+       iWindowManager = 0;
+       
+       QT_DELETE( iMeetingInfo );
+       QT_DELETE( iProgressBar );
+       QT_DELETE( iPasswordDialog );
+       QT_DELETE( iRoomStatusIndicator );
+       QT_DELETE( iSettingsView );
+       QT_DELETE( iWeeklyView );
+}
+
+void UIManager::showMainView()
+{
+       iWindowManager->showView( iWeeklyView );
+}
+
+void UIManager::showProgressBar( QString aText )
+{
+       if ( iProgressBar != 0 )
+       {
+               iProgressBar->update( aText );
+               iWindowManager->showDialog( iProgressBar );
+       }
+}
+
+// ===============================================
+//             INITIALIZE THE UIMANAGER
+void UIManager::createWeeklyView()
+{
+       iWeeklyView = new WeeklyViewWidget( QDateTime::currentDateTime(), iEngine->iConfiguration );
+       
+       // Connect signals to UIManager
+       connect( iWeeklyView, SIGNAL( settingsButtonClicked() ), this, SLOT( settingsViewRequest() ) );
+       connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), this, SLOT( currentRoomChanged( Room * ) ) );
+       connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), this, SLOT( showMeetingProgressBar( Meeting * ) ) );
+       // Connect signals to engine
+       connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), iEngine, SLOT( fetchMeetingDetails( Meeting * ) ) );
+       connect( iWeeklyView, SIGNAL( shownWeekChanged( QDate ) ), iEngine, SLOT( shownWeekChanged( QDate ) ) );
+       connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iEngine, SLOT( currentRoomChanged( Room * ) ) );
+}
+
+void UIManager::createSettingsView()
+{
+       iSettingsView = new SettingsView;
+       
+       // Connect signals
+       connect( iSettingsView, SIGNAL( okClicked() ), this, SLOT( settingsOkClicked() ) );
+}
+
+void UIManager::createRoomStatusIndicator()
+{
+       iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->dateFormat() );
+}
+
+void UIManager::createPasswordDialog()
+{
+       iPasswordDialog = new PasswordDialog( iEngine->iConfiguration->adminPassword(), tr("UIManager::createPasswordDialog"), tr("UIManager::createPasswordDialog") );
+       
+       connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) );
+}
+
+void UIManager::createProgressBar()
+{
+       iProgressBar = new ProgressBar( tr("CHANGE THIS"), true );
+       
+       // Connect to UIManager
+       connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) );
+       // Connect to Engine
+       connect( iProgressBar, SIGNAL( cancel() ), iEngine, SLOT( cancelFetchMeetingDetails() ) );
+}
+
+void UIManager::createMeetingInfoDialog()
+{
+       iMeetingInfo = new MeetingInfoDialog();
+}
+
+void UIManager::connectDeviceManager( DeviceManager *aDeviceManager )
+{
+       connect( aDeviceManager, SIGNAL( changeModeOrdered( DeviceManager::OperationMode ) ),
+                       this, SLOT( changeModeOrdered( DeviceManager::OperationMode ) ) );
+       
+       connect( aDeviceManager, SIGNAL( changingMode( const QString & ) ), this, SLOT( updateProgressBarText( const QString & ) ) );
+       connect( aDeviceManager, SIGNAL( changeModeFailed() ), this, SLOT( hideProgressBar() ) );
+}
+
+void UIManager::connectCommunicationManager( CommunicationManager *aCommunicationManager )
+{
+       connect( aCommunicationManager, SIGNAL( meetingDetailsFetched( Meeting & ) ), this, SLOT( meetingDetailsFetched( Meeting & ) ) );
+       connect( aCommunicationManager, SIGNAL( meetingsFetched( const QList<Meeting *> & ) ), this, SLOT( meetingsFetched( const QList<Meeting *> & ) ) );
+}
+
+// ============================================
+//             UIMANAGER SLOTS
+void UIManager::settingsViewRequest()
+{
+       // Show the settings view and stop the idle timer
+       if ( iSettingsView != 0 )
+       {
+               iWindowManager->showView( static_cast<ViewBase *>( iSettingsView ) );
+               iEngine->stopIdleTimeCounter();
+       }
+}
+
+void UIManager::settingsOkClicked()
+{
+       // Show the weekly view and restart the idle timer
+       if ( iWeeklyView != 0 )
+       {
+               iWindowManager->showView( static_cast<ViewBase *>( iWeeklyView ) );
+               iEngine->startIdleTimeCounter();
+       }
+}
+
+void UIManager::meetingsFetched( const QList<Meeting*> &aMeetings )
+{
+       qDebug() << "[UIManager::meetingsFetched] <Change the weekly views method to slot so we don't need this>";
+       if ( iWeeklyView != 0 )
+       {
+               iWeeklyView->refreshMeetings( aMeetings );
+       }
+}
+
+void UIManager::showMeetingProgressBar( Meeting *aMeeting )
+{
+       if ( iProgressBar != 0 )
+       {
+               iProgressBar->update( tr("Fetching meeting info...") );
+               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false, false );
+               iEngine->stopIdleTimeCounter();
+       }
+}
+
+void UIManager::meetingDetailsFetched(Meeting &aDetailedMeeting)
+{
+       qDebug() << "[UIManager::meetingDetailsFetched] <Invoked>";
+       if ( iMeetingInfo != 0 )
+       {
+               if ( iProgressBar != 0 && iProgressBar->isVisible() )
+               {
+                       iProgressBar->close(); // Close it in case it's visible
+               }
+               MeetingInfoDialog *tmp = new MeetingInfoDialog( &aDetailedMeeting );
+               iWindowManager->showDialog( static_cast<QDialog *>( tmp ) );
+// TODO : We should use the member variable and implement correctly the setMeeting() method !!!
+//             iMeetingInfo->setMeeting( &aDetailedMeeting );
+//             iWindowManager->showDialog( static_cast<QDialog *>( iMeetingInfo ) );
+       }
+}
+
+void UIManager::roomStatusIndicatorRequested()
+{
+       if ( iRoomStatusIndicator != 0 )
+       {
+               iWindowManager->showView( static_cast<ViewBase *>( iRoomStatusIndicator ) );
+               iEngine->stopIdleTimeCounter();
+       }
+}
+
+void UIManager::previousViewRestored()
+{
+       iEngine->startIdleTimeCounter();
+}
+
+void UIManager::progressBarCancelled()
+{
+       if ( iProgressBar != 0 )
+       {
+               iProgressBar->close();
+               iEngine->startIdleTimeCounter();
+       }
+}
+
+void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
+{
+       qDebug() << "[UIManager::changeModeOrdered] <Invoked>";
+       
+       QString message = tr( "You are about to change operation mode to %1." )
+                               .arg( iEngine->iDevice->operationModeToString( aMode ) );
+
+       if ( iPasswordDialog != 0 )
+       {
+               // TODO : Set the new text for password dialog
+               iWindowManager->showDialog( static_cast<QDialog *>( iPasswordDialog ) );
+       }
+}
+
+void UIManager::currentRoomChanged(Room *aRoom)
+{
+       if ( iWeeklyView != 0 )
+       {
+               QDateTime from = QDateTime( iWeeklyView->beginnigOfShownWeek() );
+               QDateTime to = QDateTime( from.addDays( 8 ) );
+               iEngine->fetchMeetings( from, to, aRoom );
+       }
+}
+
+void UIManager::updateTime(QDateTime aDateTime)
+{
+       if ( iWeeklyView != 0 )
+       {
+               iWeeklyView->setCurrentDateTime( aDateTime );
+       }
+}
+
+void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
+{
+       switch( aStatus )
+       {
+               case PasswordDialog::Correct:
+                       // Show the progress bar..
+                       if ( iProgressBar != 0 )
+                       {
+                               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false );
+                       }
+                       // ... and initiate the mode changing
+                       iEngine->changeDeviceMode( true );
+                       break;
+               case PasswordDialog::Incorrect:
+                       iWindowManager->error( tr("Incorrect Password") );
+               case PasswordDialog::Canceled:
+                       iEngine->changeDeviceMode( false );
+                       break;
+       }
+       
+       // Close the dialog after we have handled the status
+       if ( iPasswordDialog != 0 )
+       {
+               iPasswordDialog->close();
+       }
+}
+
+void UIManager::updateProgressBarText(const QString &aText)
+{
+       if ( iProgressBar != 0 )
+       {
+               iProgressBar->update( aText );
+       }
+}
+
+void UIManager::hideProgressBar()
+{
+       qDebug() << "[UIManager::hideProgressBar] <Invoked>";
+       if ( iProgressBar != 0 && iProgressBar->isVisible() )
+       {
+               iProgressBar->close();
+       }
+}
diff --git a/src/BusinessLogic/UIManager.h b/src/BusinessLogic/UIManager.h
new file mode 100644 (file)
index 0000000..de123b6
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef UIMANAGER_H_
+#define UIMANAGER_H_
+
+#include <QObject>
+#include <QList>
+
+#include "Meeting.h"
+#include "DeviceManager.h"
+#include "PasswordDialog.h"
+
+class Engine;
+class WindowManager;
+class WeeklyViewWidget;
+class SettingsView;
+class RoomStatusIndicatorWidget;
+class ProgressBar;
+class MeetingInfoDialog;
+class CommunicationManager;
+class QDateTime;
+
+class UIManager : public QObject
+{
+       Q_OBJECT
+       
+public:
+       UIManager( Engine *aEngine, WindowManager *aWindowManager );
+       virtual ~UIManager();
+       
+       void connectDeviceManager( DeviceManager *aDeviceManager );
+       void connectCommunicationManager( CommunicationManager *aCommunicationManager );
+       void showMainView();
+       void showProgressBar( QString aText );
+
+signals:
+       
+public slots:
+
+       void settingsViewRequest();
+       void settingsOkClicked();
+       void roomStatusIndicatorRequested();
+       void previousViewRestored();
+       void changeModeOrdered( DeviceManager::OperationMode aMode );
+       
+private slots:
+
+       void meetingsFetched( const QList<Meeting*> &aMeetings );
+       void meetingDetailsFetched( Meeting &aDetailedMeeting );
+       void currentRoomChanged( Room *aRoom );
+       void progressBarCancelled();
+       void updateTime( QDateTime aDateTime );
+       void passwordEntered( PasswordDialog::PasswordStatus aStatus );
+       void showMeetingProgressBar( Meeting *aMeeting );
+       void updateProgressBarText( const QString &aText );
+       void hideProgressBar();
+
+private:
+       
+       void createWeeklyView();
+       void createSettingsView();
+       void createRoomStatusIndicator();
+       void createPasswordDialog();
+       void createProgressBar();
+       void createMeetingInfoDialog();
+       
+private:
+       Engine *iEngine;
+       WindowManager *iWindowManager;
+       
+       WeeklyViewWidget *iWeeklyView;
+       SettingsView *iSettingsView;
+       RoomStatusIndicatorWidget *iRoomStatusIndicator;
+       PasswordDialog *iPasswordDialog;
+       ProgressBar *iProgressBar;
+       MeetingInfoDialog *iMeetingInfo;
+};
+
+#endif /*UIMANAGER_H_*/
index 56a4472..0076e23 100644 (file)
@@ -2,6 +2,7 @@
 #include "ConnectionSettings.h"
 #include "StartupSettings.h"
 #include "DisplaySettings.h"
+#include "DateTimeSettings.h"
 #include "Room.h"
 #include <QDomDocument>
 #include <QDomElement>
@@ -17,7 +18,8 @@ QString Configuration::sConfigurationPath = "/etc/QtMeetings.conf";
 Configuration::Configuration() :
                iConnectionSettings( 0 ),
                iStartupSettings( 0 ),
-               iDisplaySettings( 0 )
+               iDisplaySettings( 0 ),
+               iDateTimeSettings( 0 )
 {
 }
 
@@ -26,6 +28,7 @@ Configuration::~Configuration()
        delete iConnectionSettings;
        delete iStartupSettings;
        delete iDisplaySettings;
+       delete iDateTimeSettings;
        while ( !iRooms.isEmpty() )
        {
                delete iRooms.takeFirst();
@@ -60,6 +63,11 @@ DisplaySettings * Configuration::displaySettings()
        return iDisplaySettings;
 }
 
+DateTimeSettings * Configuration::dateTimeSettings()
+{
+       return iDateTimeSettings;
+}
+
 Room* Configuration::defaultRoom()
 {
        // default room is stored as the first element of the list
@@ -127,6 +135,10 @@ void Configuration::save()
                {
                        saveDisplaySettings( node );
                }
+               else if (tagName == QString( "daylight_saving_time" ) )
+               {
+                       saveDateTimeSettings( node );
+               }
        }
 
        //! Empty the file from previous content and write again with new one
@@ -281,6 +293,31 @@ void Configuration::saveDisplaySettings( const QDomNode &aXML )
        }
 }
 
+void Configuration::saveDateTimeSettings( const QDomNode &aXML )
+{
+       for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() )
+       {
+               QDomElement e = node.toElement();
+               QString tagName = e.tagName().toLower();
+
+               if ( tagName == QString( "dayofweek" ) )
+               {
+                       QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->switchDay() );
+                       e.replaceChild( t, e.firstChild() );
+               }
+               else if( tagName == QString( "StandardTimeChangeMoment" ) )
+               {
+                       QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->STDDateTime().toString("ddMMyyyyhhmmss"));
+                       e.replaceChild( t, e.firstChild() );
+               }
+               else if( tagName == QString( "DaylightSaveTimeChangeMoment" ) )
+               {
+                       QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->DSTDateTime().toString("ddMMyyyyhhmmss"));
+                       e.replaceChild( t, e.firstChild() );
+               }
+       }
+}
+
 void Configuration::saveAdminPassword( const QDomNode &aXML )
 {
        QDomElement e = aXML.toElement();
@@ -340,6 +377,10 @@ Configuration* Configuration::readFromXML( const QString &aPath )
                {
                        conf->iDisplaySettings = Configuration::readDisplaySettings( node );
                }
+               else if ( tagName == QString( "daylight_saving_time" ) )
+               {
+                       conf->iDateTimeSettings = Configuration::readDateTimeSettings(node);
+               }
        }
 
        return conf;
@@ -560,6 +601,44 @@ DisplaySettings * Configuration::readDisplaySettings( const QDomNode &aXML )
        return new DisplaySettings( dateformat, timeformat, daysInSchedule, dayStartsAt, dayEndsAt, screensaver );
 }
 
+DateTimeSettings * Configuration::readDateTimeSettings( const QDomNode &aXML )
+{
+       // Set defaults..
+       QDateTime standardTimeChangeMoment = QDateTime::fromString("05.10.2009 04:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss");
+       QDateTime daylightSaveTimeChangeMoment = QDateTime::fromString("01.04.2010 03:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss");
+       DateTimeSettings::weekDay dayOfWeek = DateTimeSettings::Sunday;
+       
+       for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() )
+       {
+               QDomElement e = node.toElement();
+               QString tagName = e.tagName().toLower();
+
+               if ( tagName == QString( "dayofweek" ) )
+               {
+                       qDebug() << "Configuration::readDateTimeSettings: " +e.text();
+                       
+                       bool success = false;
+                       unsigned int weekDayTmp = e.text().toUInt( &success );
+                       if( success && weekDayTmp >= 0 && weekDayTmp < 7)
+                       {
+                               dayOfWeek = (DateTimeSettings::weekDay)weekDayTmp;
+                       }
+               }
+               else if( tagName == QString( "standardtimechangemoment" ) )
+               {
+                       standardTimeChangeMoment = QDateTime::fromString(e.text(), "dd'.'MM'.'yyyy' 'hh:mm:ss");
+                       qDebug() << "Configuration::readDateTimeSettings: " +standardTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss");
+               }
+               else if( tagName == QString( "daylightsavetimechangemoment" ) )
+               {
+                       daylightSaveTimeChangeMoment = QDateTime::fromString(e.text(), "dd'.'MM'.'yyyy' 'hh:mm:ss");
+                       qDebug() << "Configuration::readDateTimeSettings: " +daylightSaveTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss");
+               }
+       }
+       
+       return new DateTimeSettings(standardTimeChangeMoment, daylightSaveTimeChangeMoment, dayOfWeek);
+}
+
 QByteArray Configuration::readAdminPassword( const QDomNode &aXML )
 {
        QDomElement e = aXML.toElement();
index c08002d..5cd7e6d 100644 (file)
@@ -11,6 +11,7 @@ class StartupSettings;
 class DisplaySettings;
 class Room;
 class QDomNode;
+class DateTimeSettings;
 
 //! Domain class. Store application wide configuration values.
 /*!
@@ -20,7 +21,7 @@ class QDomNode;
  */
 class Configuration : public QObject
 {
-       Q_OBJECT
+Q_OBJECT
 
 private:
        //! Constructor.
@@ -76,6 +77,12 @@ public:
         * \return Pointer to DisplaySettings instance.
         */
        DisplaySettings* displaySettings();
+       //! Gets date/time settings.
+       /*!
+        * Gets the date/time settings.
+        * \return Pointer to DateTimeSettings instance.
+        */
+       DateTimeSettings* dateTimeSettings();
        //! Gets the administrator's password.
        /*!
         * Gets the administrator's password
@@ -87,8 +94,8 @@ public:
         * Sets  room list.
         * \param aRooms List of rooms
         */
-       void setRooms( const QList<Room*> aRooms );
-       
+       void setRooms(const QList<Room*> aRooms);
+
 public slots:
 
        //! Saves setting values to file.
@@ -104,85 +111,100 @@ private:
         * \param aPath path and name of configuration file
         * \return Configuration object.
         */
-       static Configuration* readFromXML( const QString &aPath );
+       static Configuration* readFromXML(const QString &aPath);
        //! Static. Reads settings of connection from and XML node.
        /*!
         * Static. Reads settings of connection from an XML node.
         * \param aXml QDomNode containing connection parameters.
         * \return Pointer to ConnectionSettings object.
         */
-       static ConnectionSettings* readConnectionSettings( const QDomNode &aXML );
+       static ConnectionSettings* readConnectionSettings(const QDomNode &aXML);
        //! Static. Reads rooms from an XML node.
        /*!
         * Static. Reads rooms from an XML node.
         * \param aXml QDomNode containing meeting room parameters
         * \return List of meetingrooms.
         */
-       static QList<Room*> readRooms( const QDomNode &aXML );
+       static QList<Room*> readRooms(const QDomNode &aXML);
        //! Static. Reads language code from an XML node.
        /*!
         * Static. Reads rooms from an XML node.
         * \param aXml QDomNode containing language code
         * \return Language code.
         */
-       static QString readLanguageCode( const QDomNode &aXML );
+       static QString readLanguageCode(const QDomNode &aXML);
        //! Static. Reads settings of startup from an XML node.
        /*!
         * Static. Reads settings of startup from an XML node.
         * \param aXml QDomNode containing startup parameters
         * \return Pointer to the read StartupSettings object.
         */
-       static StartupSettings* readStartupSettings( const QDomNode &aXML );
+       static StartupSettings* readStartupSettings(const QDomNode &aXML);
        /*!
         * Static function to load and store display settings from xml node.
         * \param aXml QDomNode containing display parameters
         * \return Pointer to the read DisplaySettings object.
         */
-       static DisplaySettings* readDisplaySettings( const QDomNode &aXML );
+       static DisplaySettings* readDisplaySettings(const QDomNode &aXML);
+       //! Static. Reads the date/time settings from an XML node.
+       /*!
+        * Static. Reads the date/time settings from an XML node.
+        * \param aXml QDomNode containing the date/time settings
+        * \return The date/time settings.
+        */
+       static DateTimeSettings* readDateTimeSettings(const QDomNode &aXML);
+
        //! Static. Reads adminstrator's password from an XML node.
        /*!
         * Static. Reads adminstrator's password from an XML node.
         * \param aXml QDomNode containing admin password
         * \return Admin password.
         */
-       static QByteArray readAdminPassword( const QDomNode &aXML );
+       static QByteArray readAdminPassword(const QDomNode &aXML);
 
        //! Saves connection data to the document.
        /*!
         * Reads data from iConnectionSettings and saves it to the aXML document.
         * \param aXml QDomNode containing connection parameters.
         */
-       void saveConnectionSettings( const QDomNode &aXML );
+       void saveConnectionSettings(const QDomNode &aXML);
        //! Saves meeting rooms to the document.
        /*!
         * Reads data from iRooms list and saves it to the aXML document.
         * \param aXml QDomNode containing meeting room parameters
         */
-       void saveRooms( const QDomNode &aXML );
+       void saveRooms(const QDomNode &aXML);
        //! Saves the language code.
        /*!
         * Reads data from iLanguageCode and saves it to the aXML document.
         * \param aXml QDomNode containing language code
         */
-       void saveLanguageCode( const QDomNode &aXML );
+       void saveLanguageCode(const QDomNode &aXML);
        //! Saves startup setting data to the document.
        /*!
         * Reads data from iStartupSettings and saves it to the aXML document.
         * \param aXml QDomNode containing startup parameters
         */
-       void saveStartupSettings( const QDomNode &aXML );
+       void saveStartupSettings(const QDomNode &aXML);
        //! Saves display setting data to the document.
        /*!
         * Reads data from iDisplaySettings and saves it to the aXML document.
         * \param aXml QDomNode containing display parameters
         */
-       void saveDisplaySettings( const QDomNode &aXML );
+       void saveDisplaySettings(const QDomNode &aXML);
+       //! Saves date/time setting data to the document.
+       /*!
+        * Reads data from iDateTimeSettings and saves it to the aXML document.
+        * \param aXml QDomNode containing the date/time settings
+        */
+       void saveDateTimeSettings(const QDomNode &aXML);
+
        //! Saves admin password to the document.
        /*!
         * Reads data from iAdminPassword and saves it to the aXML document.
         * \param aXml QDomNode containing admin password
         */
-       void saveAdminPassword( const QDomNode &aXML );
+       void saveAdminPassword(const QDomNode &aXML);
 
        //! Hash password with md5 method.
        /*!
@@ -190,7 +212,7 @@ private:
         * \param aPassword password to be encoded
         * \return Encoded password.
         */
-       QString hashPassword( const QString aPassword );
+       QString hashPassword(const QString aPassword);
 
 private:
        //! Path and name of configuration file
@@ -205,6 +227,8 @@ private:
        StartupSettings *iStartupSettings;
        //! Stores display settings.
        DisplaySettings *iDisplaySettings;
+       //! Stores date/time settings.
+       DateTimeSettings *iDateTimeSettings;
        //! List of meeting rooms.
        QList<Room*> iRooms;
        //! Stores administrator password.
diff --git a/src/Domain/Configuration/DateTimeSettings.cpp b/src/Domain/Configuration/DateTimeSettings.cpp
new file mode 100644 (file)
index 0000000..83c6767
--- /dev/null
@@ -0,0 +1,129 @@
+#include "DateTimeSettings.h"
+#include <QtDebug>
+
+const QString DateTimeSettings::weekDays[DAYS_IN_A_WEEK]=
+{ 
+       "Sunday", 
+       "Monday", 
+       "Tuesday", 
+       "Wednesday", 
+       "Thursday", 
+       "Friday",
+       "Saturday" 
+};
+
+DateTimeSettings::DateTimeSettings(const QDateTime &aStandardTimeChange, const QDateTime &aDaylightTimeChange, weekDay aDayOfWeek)
+{
+       this->iDaylightSaveTimeChangeMoment = aDaylightTimeChange;
+       this->iStandardTimeChangeMoment = aStandardTimeChange;
+       this->iDayOfWeek = aDayOfWeek;
+}
+
+DateTimeSettings::DateTimeSettings(const DateTimeSettings &aOther)
+{
+       this->iDaylightSaveTimeChangeMoment = aOther.iDaylightSaveTimeChangeMoment;
+       this->iStandardTimeChangeMoment = aOther.iStandardTimeChangeMoment;
+       this->iDayOfWeek = aOther.iDayOfWeek;
+}
+
+DateTimeSettings::~DateTimeSettings()
+{
+
+}
+
+QDateTime DateTimeSettings::STDDateTime()
+{
+       return (this->iStandardTimeChangeMoment);
+}
+
+QDateTime DateTimeSettings::DSTDateTime()
+{
+       return (this->iDaylightSaveTimeChangeMoment);
+}
+
+QString DateTimeSettings::STDTime()
+{
+       QTime time = this->iStandardTimeChangeMoment.time();
+
+       qDebug() << "DateTimeSettings::standardTimeChange_Time: "
+                       +time.toString("hh:mm:ss");
+
+       return (time.toString("hh:mm:ss"));
+}
+
+QString DateTimeSettings::STDMonth()
+{
+       QDate date = this->iStandardTimeChangeMoment.date();
+
+       qDebug() << "DateTimeSettings::standardTimeChange_Month: "
+                       +date.toString("MM");
+
+       return (date.toString("M"));
+}
+
+QString DateTimeSettings::STDDay()
+{
+       QDate date = this->iStandardTimeChangeMoment.date();
+
+       qDebug() << "DateTimeSettings::standardTimeChange_Day: "
+                       +date.toString("dd");
+
+       return (date.toString("d"));
+}
+
+QString DateTimeSettings::DSTTime()
+{
+       QTime time = this->iDaylightSaveTimeChangeMoment.time();
+
+       qDebug() << "DateTimeSettings::daylightSaveTimeChange_Time: "
+                       +time.toString("hh:mm:ss");
+
+       return (time.toString("hh:mm:ss"));
+}
+
+QString DateTimeSettings::DSTMonth()
+{
+       QDate date = this->iDaylightSaveTimeChangeMoment.date();
+
+       qDebug() << "DateTimeSettings::daylightSaveTimeChange_Month: "
+                       +date.toString("MM");
+
+       return (date.toString("M"));
+}
+
+QString DateTimeSettings::DSTDay()
+{
+       QDate date = this->iDaylightSaveTimeChangeMoment.date();
+
+       qDebug() << "DateTimeSettings::daylightSaveTimeChange_Day: "
+                       +date.toString("dd");
+
+       return (date.toString("d"));
+}
+
+void DateTimeSettings::setDSTDateTime(const QDateTime &aDaylightSaveTimeChange)
+{
+       this->iDaylightSaveTimeChangeMoment = aDaylightSaveTimeChange;
+       qDebug() << "DateTimeSettings::setDaylightSaveTimeChange: "
+                               +this->iDaylightSaveTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss");
+}
+
+void DateTimeSettings::setSTDDateTime(const QDateTime &aStandardTimeChange)
+{
+       this->iStandardTimeChangeMoment = aStandardTimeChange;
+       qDebug() << "DateTimeSettings::setStandardTimeChange: "
+                                       +this->iStandardTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss");
+}
+
+void DateTimeSettings::setSwitchDay(weekDay aDay)
+{
+       this->iDayOfWeek = aDay;
+       qDebug() << "DateTimeSettings::setDayOfWeek: "
+                                               +DateTimeSettings::weekDays[this->iDayOfWeek];
+}
+
+QString DateTimeSettings::switchDay()
+{
+       qDebug() << "DateTimeSettings::dayOfWeek: " +DateTimeSettings::weekDays[this->iDayOfWeek];
+       return(DateTimeSettings::weekDays[this->iDayOfWeek]);
+}
diff --git a/src/Domain/Configuration/DateTimeSettings.h b/src/Domain/Configuration/DateTimeSettings.h
new file mode 100644 (file)
index 0000000..6c79e7d
--- /dev/null
@@ -0,0 +1,118 @@
+#ifndef DATETIMESETTINGS_H_
+#define DATETIMESETTINGS_H_
+
+#include <QDateTime>
+#include <QString>
+
+#define DAYS_IN_A_WEEK 7
+
+class DateTimeSettings
+{
+public:
+
+       /*!
+        * An enumeration for the weekdays to be used.
+        */
+       typedef enum 
+       {
+               Sunday = 0,
+               Monday,
+               Tuesday,
+               Wednesday,
+               Thursday,
+               Friday,
+               Saturday
+       } weekDay;
+
+       /*!
+        * Overloaded.
+        * \param aStandardTimeChange The date and time when the standard time is to be used. The year part and the milliseconds are omitted.
+        * \param aDaylightTimeChange The date and time when the daylight time is to be used. The year part and the milliseconds are omitted.
+        * \param aDayOfWeek The day of the week when the time is to be used.
+        */
+       DateTimeSettings(const QDateTime &aStandardTimeChange, const QDateTime &aDaylightTimeChange, weekDay aDayOfWeek);
+
+       //! Copy constructor.
+       /*!
+        * Overloaded. Constructor to initialize a DateTimeSettings instance.
+        * \param aOther DateTimeSettings class to be copied.
+        */
+       DateTimeSettings(const DateTimeSettings &aOther);
+       //! Destructor
+       virtual ~DateTimeSettings();
+
+       /*!
+        * \return The Date/time when the standard time is to be switched into use
+        */
+       QDateTime STDDateTime();
+
+       /*!
+        * \return The Date/time when the daylight saving time is to be switched into use
+        */
+       QDateTime DSTDateTime();
+
+       /*!
+        * \return The time as a string (hh:mm:ss) of the moment the standard time is to be switched into use
+        */
+       QString STDTime();
+
+       /*!
+        * \return The month as a string (MM) of the moment the standard time is to be switched into use
+        */
+       QString STDMonth();
+
+       /*!
+        * \return The day as a string (dd) of the moment the standard time is to be switched into use
+        */
+       QString STDDay();
+
+       /*!
+        * \return The time as a string (hh:mm:ss) of the moment the daylight saving time is to be switched into use
+        */
+       QString DSTTime();
+
+       /*!
+        * \return The month as a string (MM) of the moment the daylight saving time is to be switched into use
+        */
+       QString DSTMonth();
+
+       /*!
+        * \return The day as a string (dd) of the moment the daylight saving time is to be switched into use
+        */
+       QString DSTDay();
+
+       /*!
+        * Sets the time/date of the moment the daylight saving time is to be switched into use
+        */
+       void setDSTDateTime(const QDateTime &aDaylightSaveTimeChange);
+
+       /*!
+        * Sets the time/date of the moment the standard time is to be switched into use
+        */
+       void setSTDDateTime(const QDateTime &aStandardTimeChange);
+
+       /*!
+        * Sets the appropriate day of the week the time switch is carried out.
+        * \see DateTimeSettings::weekDay
+        */
+       void setSwitchDay(DateTimeSettings::weekDay aDay);
+
+       /*!
+        * \return The appropriate day of the week the time switch is carried out.
+        */
+       QString switchDay();
+
+private:
+       QDateTime iStandardTimeChangeMoment;
+       QDateTime iDaylightSaveTimeChangeMoment;
+       weekDay iDayOfWeek;
+
+       /*!
+        * Contains the weekday strings that are passed to the exchange server when
+        * defining the timezone variables
+        */
+       static const QString weekDays[DAYS_IN_A_WEEK];
+};
+
+
+#endif /*DATETIMESETTINGS_H_*/
index d12b73a..dfa0ee7 100644 (file)
@@ -4,58 +4,60 @@
 #include "MessagingUtils.h"
 #include "Meeting.h"
 #include "Configuration.h"
+#include "DateTimeSettings.h"
 
 /*
  * BaseMessage class functions
-*/
+ */
 BaseMessage::BaseMessage()
 {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::BaseMessage" );
+       qDebug("BaseMessage::BaseMessage");
 #endif
        iMessage = new QDomDocument();
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::BaseMessage end" );
+       qDebug("BaseMessage::BaseMessage end");
 #endif
 }
 
 BaseMessage::~BaseMessage()
 {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::~BaseMessage" );
+       qDebug("BaseMessage::~BaseMessage");
 #endif
-       if( iMessage )
-               {
+       if (iMessage)
+       {
                delete iMessage;
                iMessage = 0;
-               }
+       }
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::~BaseMessage end" );
+       qDebug("BaseMessage::~BaseMessage end");
 #endif
 }
 
-QList<QDomNode> BaseMessage::getNodesByName( const QString& aNodeName, const QString& aParentName, QDomNode* aRootNode )
+QList<QDomNode> BaseMessage::getNodesByName(const QString& aNodeName, const QString& aParentName, QDomNode* aRootNode)
 {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::getNodesByName" );
+       qDebug("BaseMessage::getNodesByName");
 #endif
-       
+
        //TODO: Add implementation for attribute search
-       
+
        QDomNodeList list;
        QList<QDomNode> specList;
-       
-       list = ( aRootNode ) ? aRootNode->toElement().elementsByTagName( aNodeName ) : iMessage->elementsByTagName( aNodeName );
 
-       for( int i=0; i<list.count(); i++ )
+       list
+                       = (aRootNode ) ? aRootNode->toElement().elementsByTagName(aNodeName) : iMessage->elementsByTagName(aNodeName);
+
+       for (int i=0; i<list.count(); i++)
        {
-               if( aParentName != QString::null )
+               if (aParentName != QString::null )
                {
-               if( !list.item( i ).parentNode().isNull() && list.item( i ).parentNode().isElement() && list.item( i ).parentNode().toElement().tagName().compare( aParentName ) == 0 )
+                       if( !list.item( i ).parentNode().isNull() && list.item( i ).parentNode().isElement() && list.item( i ).parentNode().toElement().tagName().compare( aParentName ) == 0 )
                        specList.append( list.item( i ) );
                }
                else
-                       specList.append( list.item( i ) );
+               specList.append( list.item( i ) );
        }
 #ifdef MU_DEBUG
        qDebug( "BaseMessage::getNodesByName end" );
@@ -63,59 +65,54 @@ QList<QDomNode> BaseMessage::getNodesByName( const QString& aNodeName, const QSt
        return specList;
 }
 
-QDomNode BaseMessage::getNodeFromDocument( const QString& aNodeName,
-                                                               QDomNode::NodeType aNodeType,
-                                                               const QString& aParentName,
-                                                               int aIndex,
-                                                               QDomNode* aRootNode )
+QDomNode BaseMessage::getNodeFromDocument(const QString& aNodeName, QDomNode::NodeType aNodeType, const QString& aParentName, int aIndex, QDomNode* aRootNode)
 {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::getNodeFromDocument" );
+       qDebug("BaseMessage::getNodeFromDocument");
 #endif
        QDomNode node;
-       if( aNodeType == QDomNode::ElementNode )
-               node = getElementFromDocument( aNodeName, aParentName, aIndex, aRootNode );
-       else if( aNodeType == QDomNode::AttributeNode )
-               node = getAttributeFromDocument( aNodeName, aParentName, aIndex, aRootNode );
-#ifdef MU_DEBUG
-       qDebug( "BaseMessage::getNodeFromDocument end" );
+       if (aNodeType == QDomNode::ElementNode)
+               node
+                               = getElementFromDocument(aNodeName, aParentName, aIndex, aRootNode);
+       else if (aNodeType == QDomNode::AttributeNode)
+               node
+                               = getAttributeFromDocument(aNodeName, aParentName, aIndex, aRootNode);
+#ifdef MU_DEBUG
+       qDebug("BaseMessage::getNodeFromDocument end");
 #endif
        return node;
 }
 
-QDomNode BaseMessage::getAttributeFromDocument( const QString& aAttributeName,
-                                                               const QString& aParentName,
-                                                               int aIndex,
-                                                               QDomNode* aRootNode )
+QDomNode BaseMessage::getAttributeFromDocument(const QString& aAttributeName, const QString& aParentName, int aIndex, QDomNode* aRootNode)
 {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::getAttributeFromDocument" );
+       qDebug("BaseMessage::getAttributeFromDocument");
 #endif
 
        QDomNode root;
        QDomNode node;
        QDomNode parent;
-       
+
        root = ( !aRootNode ) ? iMessage->documentElement() : *aRootNode;
-       if( root.isNull() )
-               {
+       if (root.isNull() )
+       {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::getAttributeFromDocument : RootNode is NULL." );
+               qDebug("BaseMessage::getAttributeFromDocument : RootNode is NULL.");
 #endif         
                return node;
-               }
+       }
 
-       if( aParentName != QString::null )
+       if (aParentName != QString::null )
        {
                if( root.isElement() )
                {
                        QDomNodeList list = root.toElement().elementsByTagName( aParentName );
-                       if( list.count() > 0 ) parent = list.item( 0 );
+                       if( list.count()> 0 ) parent = list.item( 0 );
                }
        }
-       
+
        QDomNamedNodeMap attrs = parent.attributes();
-       
+
        int count = attrs.count();
        if( count==0 || aIndex >= count || !attrs.contains( aAttributeName ) ) return root;
 
@@ -132,109 +129,104 @@ QDomNode BaseMessage::getAttributeFromDocument( const QString& aAttributeName,
                                list.append( attr );
                        }
                        else
-                               list.append( attr );
+                       list.append( attr );
                }
 
        }
 
-       if( list.count() > 0 )
-               node = list.at( aIndex );
+       if( list.count()> 0 )
+       node = list.at( aIndex );
 
 #ifdef MU_DEBUG
        qDebug( "BaseMessage::getAttributeFromDocument end." );
 #endif 
-       
+
        return node;
 }
 
-QDomNode BaseMessage::getElementFromDocument( const QString& aElementName,
-                                                               const QString& aParentName,
-                                                               int aIndex,
-                                                               QDomNode* aRootNode )
+QDomNode BaseMessage::getElementFromDocument(const QString& aElementName, const QString& aParentName, int aIndex, QDomNode* aRootNode)
 {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::getElementFromDocument" );
+       qDebug("BaseMessage::getElementFromDocument");
 #endif
-               QDomNode node;
-               QDomNodeList elems;
+       QDomNode node;
+       QDomNodeList elems;
 
-               if( !aRootNode )
-               {
-               elems = iMessage->elementsByTagName( aElementName );
-               }
-               else
-               {
-               elems = aRootNode->toElement().elementsByTagName( aElementName );
-               }
+       if ( !aRootNode)
+       {
+               elems = iMessage->elementsByTagName(aElementName);
+       }
+       else
+       {
+               elems = aRootNode->toElement().elementsByTagName(aElementName);
+       }
 
-               int count = elems.count();
-               if( count == 0 || aIndex >= count )
-               { 
+       int count = elems.count();
+       if (count == 0 || aIndex >= count)
+       {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::getElementFromDocument : No Elements found." );
+               qDebug("BaseMessage::getElementFromDocument : No Elements found.");
 #endif                 
-                       return node; //no elements found
-               }
+               return node; //no elements found
+       }
 
-               QList<QDomElement> list;
+       QList<QDomElement> list;
 
-               for( int i=0; i<count; i++ )
+       for (int i=0; i<count; i++)
+       {
+               QDomElement elem = elems.item( i ).toElement();
+               if (elem.tagName().compare(aElementName) == 0 || elem.localName().compare(aElementName) == 0)
                {
-                       QDomElement elem = elems.item( i ).toElement();
-                       if( elem.tagName().compare( aElementName ) == 0 || elem.localName().compare( aElementName ) == 0 )
+                       if (aParentName != QString::null )
                        {
-                               if( aParentName != QString::null )
+                               if( !elem.parentNode().isNull() )
                                {
-                                       if( !elem.parentNode().isNull() )
-                                       {
-                                               if( elem.parentNode().toElement().tagName().compare( aParentName ) == 0 || elem.parentNode().toElement().tagName().compare( aParentName ) == 0 )
-                                                       list.append( elem );
-                                       }
-                               }
-                               else
+                                       if( elem.parentNode().toElement().tagName().compare( aParentName ) == 0 || elem.parentNode().toElement().tagName().compare( aParentName ) == 0 )
                                        list.append( elem );
+                               }
                        }
-
+                       else
+                       list.append( elem );
                }
 
-               if( list.count() > 0 )
-                       node = list.at( aIndex );
+       }
+
+       if( list.count()> 0 )
+       node = list.at( aIndex );
 
 #ifdef MU_DEBUG
        qDebug( "BaseMessage::getElementFromDocument end" );
 #endif         
-               return node;
+       return node;
 }
 
-bool BaseMessage::matchName( const QDomNode& aNode, const QString& aName )
+bool BaseMessage::matchName(const QDomNode& aNode, const QString& aName)
 {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::matchName" );
+       qDebug("BaseMessage::matchName");
 #endif
-       if( aNode.isElement() )
+       if (aNode.isElement() )
        {
-               if( aNode.toElement().tagName().toLower().compare( aName.toLower() ) == 0
-                               || aNode.localName().toLower().compare( aName.toLower() ) == 0 )
+               if (aNode.toElement().tagName().toLower().compare(aName.toLower() ) == 0 || aNode.localName().toLower().compare(aName.toLower() ) == 0)
                {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::matchName end" );
+                       qDebug("BaseMessage::matchName end");
 #endif                 
                        return true;
                }
        }
-       else if( aNode.isAttr() )
+       else if (aNode.isAttr() )
        {
-               if( aNode.toAttr().name().toLower().compare( aName.toLower() ) == 0
-                               || aNode.localName().toLower().compare( aName.toLower() ) == 0 )
+               if (aNode.toAttr().name().toLower().compare(aName.toLower() ) == 0 || aNode.localName().toLower().compare(aName.toLower() ) == 0)
                {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::matchName end" );
+                       qDebug("BaseMessage::matchName end");
 #endif                 
                        return true;
                }
        }
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::matchName : No match." );
+       qDebug("BaseMessage::matchName : No match.");
 #endif 
        return false;
 }
@@ -242,63 +234,64 @@ bool BaseMessage::matchName( const QDomNode& aNode, const QString& aName )
 QByteArray BaseMessage::getMessage()
 {
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::getMessage" );
+       qDebug("BaseMessage::getMessage");
 #endif
        QByteArray msg;
-       if( iMessage )
+       if (iMessage)
        {
-               msg.append( iMessage->toByteArray() );
+               msg.append(iMessage->toByteArray() );
        }
 #ifdef MU_DEBUG
-       qDebug( "BaseMessage::getMessage end" );
+       qDebug("BaseMessage::getMessage end");
 #endif 
        return msg;
 }
 
 /*
  * RequestMessage class functions
-*/
-RequestMessage::RequestMessage( RequestCommandId aCommandId ) : iCurrCmd( aCommandId )
+ */
+RequestMessage::RequestMessage(RequestCommandId aCommandId) :
+       iCurrCmd(aCommandId)
 {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::RequestMessage" );
+       qDebug("RequestMessage::RequestMessage");
 #endif
        createEnvelopeBase();
 
-       if( aCommandId != ReqCmdNoCommand )
+       if (aCommandId != ReqCmdNoCommand)
        {
-               createMessageStructure( aCommandId );
+               createMessageStructure(aCommandId);
        }
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::RequestMessage end" );
+       qDebug("RequestMessage::RequestMessage end");
 #endif
 }
 
-RequestMessage::RequestMessage( const QString& /*aFileName*/ )
+RequestMessage::RequestMessage(const QString& /*aFileName*/)
 {
        //createEnvelopeBase();
        //TODO: read operation structures from a file
 }
 
-int RequestMessage::addNode( const QDomNode& aNode, QDomNode::NodeType aNodeType, const QString& aParentName, int aIndex, QDomNode* aRootNode )
+int RequestMessage::addNode(const QDomNode& aNode, QDomNode::NodeType aNodeType, const QString& aParentName, int aIndex, QDomNode* aRootNode)
 {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::addNode" );
+       qDebug("RequestMessage::addNode");
 #endif
 
-       if( !iMessage )
+       if ( !iMessage)
        {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::addNode : iMessage is NULL." );
+               qDebug("RequestMessage::addNode : iMessage is NULL.");
 #endif 
                return MsgErrSomeError;
        }
 
        int err = MsgErrNoError;
 
-       if( aNodeType == QDomNode::ElementNode && aNode.isElement() )
+       if (aNodeType == QDomNode::ElementNode && aNode.isElement() )
        {
-               if( aParentName == QString::null )
+               if (aParentName == QString::null )
                {
                        if( !aRootNode )
                        iMessage->appendChild( aNode );
@@ -308,7 +301,7 @@ int RequestMessage::addNode( const QDomNode& aNode, QDomNode::NodeType aNodeType
                else
                {
                        QDomNodeList list = ( aRootNode ) ? aRootNode->toElement().elementsByTagName( aParentName ) : iMessage->elementsByTagName( aParentName );
-                               
+
                        if( list.count() == 0 || aIndex >= list.count() ) err = MsgErrSomeError;
                        else
                        {
@@ -322,7 +315,7 @@ int RequestMessage::addNode( const QDomNode& aNode, QDomNode::NodeType aNodeType
                if( aParentName != QString::null )
                {
                        QDomNodeList list = ( aRootNode ) ? aRootNode->toElement().elementsByTagName( aParentName ) : iMessage->elementsByTagName( aParentName );
-                               
+
                        if( list.count() == 0 || aIndex >= list.count() ) err = MsgErrSomeError;
                        else
                        {
@@ -331,10 +324,10 @@ int RequestMessage::addNode( const QDomNode& aNode, QDomNode::NodeType aNodeType
                        }
                }
                else
-                       err = MsgErrSomeError; //Attribute must have a parent specified
+               err = MsgErrSomeError; //Attribute must have a parent specified
        }
        else
-               err = MsgErrSomeError;
+       err = MsgErrSomeError;
 
 #ifdef MU_DEBUG
        qDebug( "RequestMessage::addNode end : err=%d", err );
@@ -342,34 +335,36 @@ int RequestMessage::addNode( const QDomNode& aNode, QDomNode::NodeType aNodeType
        return err;
 }
 
-int RequestMessage::setNodeValue( const QString& aNodeName, const QString& aValue, QDomNode::NodeType aNodeType, const QString& aParentName, int aIndex, QDomNode* aRootNode )
+int RequestMessage::setNodeValue(const QString& aNodeName, const QString& aValue, QDomNode::NodeType aNodeType, const QString& aParentName, int aIndex, QDomNode* aRootNode)
 {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::setNodeValue" );
+       qDebug("RequestMessage::setNodeValue");
 #endif
 
-       QDomNode node = getNodeFromDocument( aNodeName, aNodeType, aParentName, aIndex, aRootNode );
-       if( node.isNull() || !iMessage )
-               {
+       QDomNode
+                       node =
+                                       getNodeFromDocument(aNodeName, aNodeType, aParentName, aIndex, aRootNode);
+       if (node.isNull() || !iMessage)
+       {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::setNodeValue : Node is NULL or iMessage is NULL." );
+               qDebug("RequestMessage::setNodeValue : Node is NULL or iMessage is NULL.");
 #endif         
                return MsgErrSomeError;
-               }
+       }
 
        int err = MsgErrNoError;
 
-       if( node.isElement() )
+       if (node.isElement() )
        {
-               node.appendChild( iMessage->createTextNode( aValue ) );
+               node.appendChild(iMessage->createTextNode(aValue) );
        }
-       else if( node.isAttr() )
-               node.toAttr().setValue( aValue );
+       else if (node.isAttr() )
+               node.toAttr().setValue(aValue);
        else
                err = MsgErrSomeError;
 
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::setNodeValue end : err=%d", err );
+       qDebug("RequestMessage::setNodeValue end : err=%d", err);
 #endif 
        return err;
 }
@@ -377,37 +372,38 @@ int RequestMessage::setNodeValue( const QString& aNodeName, const QString& aValu
 int RequestMessage::createEnvelopeBase()
 {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::createEnvelopeBase" );
+       qDebug("RequestMessage::createEnvelopeBase");
 #endif
-       if( iMessage )
-               {
+       if (iMessage)
+       {
                delete iMessage;
                iMessage = 0;
-               }
+       }
 
        iMessage = new QDomDocument();
 
-       int size = sizeof( reqCmdArrayEnvelopeBase ) / sizeof( MessageBodyElement );
+       int size = sizeof(reqCmdArrayEnvelopeBase ) / sizeof(MessageBodyElement);
        int err = MsgErrNoError;
 
-       QDomNode base = constructArrayToNode( reqCmdArrayEnvelopeBase, size );
+       QDomNode base = constructArrayToNode(reqCmdArrayEnvelopeBase, size);
 
-       if( !base.isNull() )
-               err = addNode( base );
-       else err = MsgErrSomeError;
+       if ( !base.isNull() )
+               err = addNode(base);
+       else
+               err = MsgErrSomeError;
 
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::createEnvelopeBase end : err=%d", err );
+       qDebug("RequestMessage::createEnvelopeBase end : err=%d", err);
 #endif         
        return err;
 }
 
-QString RequestMessage::getContentTypeForHeader( RequestCommandId aCommandId )
+QString RequestMessage::getContentTypeForHeader(RequestCommandId aCommandId)
 {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::getContentTypeForHeader" );
+       qDebug("RequestMessage::getContentTypeForHeader");
 #endif
-       QString contentType( QString::null );
+       QString contentType(QString::null );
 
        RequestCommandId cmd = ( aCommandId == ReqCmdNoCommand ) ? iCurrCmd : aCommandId;
 
@@ -416,45 +412,48 @@ QString RequestMessage::getContentTypeForHeader( RequestCommandId aCommandId )
                QString operation( QString::null );
                switch( cmd )
                {
-               //Used commands
-               case ReqCmdGetUserAvailability : { operation = "GetUserAvailability"; } break;
-               case ReqCmdConvertId : { operation = "ConvertId"; } break;
-               case ReqCmdGetItem : { operation = "GetItem"; } break;
-
-               //Currently unused operations
-
-               /*case ReqCmdAddDelegate : { operation = "AddDelegate"; } break;
-               case ReqCmdCopyFolder : { operation = "CopyFolder"; } break;
-               case ReqCmdCopyItem : { operation = "CopyItem"; } break;
-               case ReqCmdCreateAttachment : { operation = "CreateAttachment"; } break;
-               case ReqCmdCreateFolder : { operation = "CreateFolder"; } break;
-               case ReqCmdCreateItem : { operation = "CreateItem"; } break;
-               case ReqCmdCreateManagedFolder : { operation = "CreateManagedFolder"; } break;
-               case ReqCmdDeleteAttachment : { operation = "DeleteAttachment"; } break;
-               case ReqCmdDeleteFolder : { operation = "DeleteFolder"; } break;
-               case ReqCmdDeleteItem : { operation = "DeleteItem"; } break;
-               case ReqCmdExpandDL : { operation = "ExpandDL"; } break;
-               case ReqCmdFindFolder : { operation = "FindFolder"; } break;
-               case ReqCmdFindItem : { operation = "FindItem"; } break;
-               case ReqCmdGetAttachment : { operation = "GetAttachment"; } break;
-               case ReqCmdGetDelegate : { operation = "GetDelegate"; } break;
-               case ReqCmdGetEvents : { operation = "GetEvents"; } break;
-               case ReqCmdGetFolder : { operation = "GetFolder"; } break;
-               case ReqCmdGetUserOofSettings : { operation = "GetUserOofSettings"; } break;
-               case ReqCmdMoveFolder : { operation = "MoveFolder"; } break;
-               case ReqCmdMoveItem : { operation = "MoveItem"; } break;
-               case ReqCmdRemoveDelegate : { operation = "RemoveDelegate"; } break;
-               case ReqCmdResolveNames : { operation = "ResolveNames"; } break;
-               case ReqCmdSendItem : { operation = "SendItem"; } break;
-               case ReqCmdSetUserOofSettings : { operation = "SetUserOofSettings"; } break;
-               case ReqCmdSubscribe : { operation = "Subscribe"; } break;
-               case ReqCmdSyncFolderHierarchy : { operation = "SyncFolderHierarchy"; } break;
-               case ReqCmdSyncFolderItems : { operation = "SyncFolderItems"; } break;
-               case ReqCmdUnsubscribe : { operation = "Unsubscribe"; } break;
-               case ReqCmdUpdateDelegate : { operation = "UpdateDelegate"; } break;
-               case ReqCmdUpdateFolder : { operation = "UpdateFolder"; } break;
-               case ReqCmdUpdateItem : { operation = "UpdateItem"; } break;*/
-               default: break;
+                       //Used commands
+                       case ReqCmdGetUserAvailability :
+                       {       operation = "GetUserAvailability";}break;
+                       case ReqCmdConvertId :
+                       {       operation = "ConvertId";}break;
+                       case ReqCmdGetItem :
+                       {       operation = "GetItem";}break;
+
+                       //Currently unused operations
+
+                       /*case ReqCmdAddDelegate : { operation = "AddDelegate"; } break;
+                        case ReqCmdCopyFolder : { operation = "CopyFolder"; } break;
+                        case ReqCmdCopyItem : { operation = "CopyItem"; } break;
+                        case ReqCmdCreateAttachment : { operation = "CreateAttachment"; } break;
+                        case ReqCmdCreateFolder : { operation = "CreateFolder"; } break;
+                        case ReqCmdCreateItem : { operation = "CreateItem"; } break;
+                        case ReqCmdCreateManagedFolder : { operation = "CreateManagedFolder"; } break;
+                        case ReqCmdDeleteAttachment : { operation = "DeleteAttachment"; } break;
+                        case ReqCmdDeleteFolder : { operation = "DeleteFolder"; } break;
+                        case ReqCmdDeleteItem : { operation = "DeleteItem"; } break;
+                        case ReqCmdExpandDL : { operation = "ExpandDL"; } break;
+                        case ReqCmdFindFolder : { operation = "FindFolder"; } break;
+                        case ReqCmdFindItem : { operation = "FindItem"; } break;
+                        case ReqCmdGetAttachment : { operation = "GetAttachment"; } break;
+                        case ReqCmdGetDelegate : { operation = "GetDelegate"; } break;
+                        case ReqCmdGetEvents : { operation = "GetEvents"; } break;
+                        case ReqCmdGetFolder : { operation = "GetFolder"; } break;
+                        case ReqCmdGetUserOofSettings : { operation = "GetUserOofSettings"; } break;
+                        case ReqCmdMoveFolder : { operation = "MoveFolder"; } break;
+                        case ReqCmdMoveItem : { operation = "MoveItem"; } break;
+                        case ReqCmdRemoveDelegate : { operation = "RemoveDelegate"; } break;
+                        case ReqCmdResolveNames : { operation = "ResolveNames"; } break;
+                        case ReqCmdSendItem : { operation = "SendItem"; } break;
+                        case ReqCmdSetUserOofSettings : { operation = "SetUserOofSettings"; } break;
+                        case ReqCmdSubscribe : { operation = "Subscribe"; } break;
+                        case ReqCmdSyncFolderHierarchy : { operation = "SyncFolderHierarchy"; } break;
+                        case ReqCmdSyncFolderItems : { operation = "SyncFolderItems"; } break;
+                        case ReqCmdUnsubscribe : { operation = "Unsubscribe"; } break;
+                        case ReqCmdUpdateDelegate : { operation = "UpdateDelegate"; } break;
+                        case ReqCmdUpdateFolder : { operation = "UpdateFolder"; } break;
+                        case ReqCmdUpdateItem : { operation = "UpdateItem"; } break;*/
+                       default: break;
                };
 
                if( operation != QString::null )
@@ -472,18 +471,18 @@ QString RequestMessage::getContentTypeForHeader( RequestCommandId aCommandId )
 
 int RequestMessage::createMessageStructure()
 {
-       return createMessageStructure( iCurrCmd );
+       return createMessageStructure(iCurrCmd);
 }
 
-int RequestMessage::createMessageStructure( RequestCommandId aCommandId )
+int RequestMessage::createMessageStructure(RequestCommandId aCommandId)
 {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::createMessageStructure" );
+       qDebug("RequestMessage::createMessageStructure");
 #endif
-       if( !iMessage )
+       if ( !iMessage)
        {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::createMessageStructure : iMessage is NULL" );
+               qDebug("RequestMessage::createMessageStructure : iMessage is NULL");
 #endif         
                return MsgErrSomeError;
        }
@@ -491,10 +490,10 @@ int RequestMessage::createMessageStructure( RequestCommandId aCommandId )
        //Should always be soap:Envelope or first element in envelopebase array
        QDomNode last = iMessage->documentElement();
 
-       if( !matchName( last, reqCmdArrayEnvelopeBase[0].iElementName ) )
+       if ( !matchName(last, reqCmdArrayEnvelopeBase[0].iElementName) )
        {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::createMessageStructure : Document element is not valid SOAP envelope" );
+               qDebug("RequestMessage::createMessageStructure : Document element is not valid SOAP envelope");
 #endif         
                return MsgErrSomeError;
        }
@@ -502,38 +501,60 @@ int RequestMessage::createMessageStructure( RequestCommandId aCommandId )
        QDomNode cmd;
        int err = MsgErrNoError;
 
-       switch( aCommandId )
+       switch (aCommandId)
        {
-       case ReqCmdGetUserAvailability : { cmd = constructArrayToNode( reqCmdArrayGetUserAvailability, sizeof( reqCmdArrayGetUserAvailability ) / sizeof( MessageBodyElement ) ); } break;
-       case ReqCmdConvertId : { cmd = constructArrayToNode( reqCmdArrayConvertId, sizeof( reqCmdArrayConvertId ) / sizeof( MessageBodyElement ) ); } break;
-       case ReqCmdGetItem : { cmd = constructArrayToNode( reqCmdArrayGetCalendarItem, sizeof( reqCmdArrayGetCalendarItem ) / sizeof( MessageBodyElement ) ); } break;
-       default: break;
+               case ReqCmdGetUserAvailability:
+               {
+                       cmd
+                                       = constructArrayToNode(reqCmdArrayGetUserAvailability, sizeof(reqCmdArrayGetUserAvailability )
+                                                       / sizeof(MessageBodyElement));
+               }
+                       break;
+               case ReqCmdConvertId:
+               {
+                       cmd
+                                       = constructArrayToNode(reqCmdArrayConvertId, sizeof(reqCmdArrayConvertId )
+                                                       / sizeof(MessageBodyElement));
+               }
+                       break;
+               case ReqCmdGetItem:
+               {
+                       cmd
+                                       = constructArrayToNode(reqCmdArrayGetCalendarItem, sizeof(reqCmdArrayGetCalendarItem )
+                                                       / sizeof(MessageBodyElement));
+               }
+                       break;
+               default:
+                       break;
        };
 
-       if( cmd.isNull() ) err = MsgErrSomeError;
-       else{
-               err = addNode( cmd, QDomNode::ElementNode, reqCmdArrayEnvelopeBase[0].iElementName );
+       if (cmd.isNull() )
+               err = MsgErrSomeError;
+       else
+       {
+               err
+                               = addNode(cmd, QDomNode::ElementNode, reqCmdArrayEnvelopeBase[0].iElementName);
        }
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::createMessageStructure end : err=%d", err );
+       qDebug("RequestMessage::createMessageStructure end : err=%d", err);
 #endif 
        return err;
 }
 
-QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray, int aSize )
+QDomNode RequestMessage::constructArrayToNode(const MessageBodyElement* aArray, int aSize)
 {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode" );
+       qDebug("RequestMessage::constructArrayToNode");
 #endif
        QDomElement target; //final node to be returned
 
-       if( !iMessage || aSize == 0 )
-               {
+       if ( !iMessage || aSize == 0)
+       {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode : iMessage is NULL or aSize is 0." );
+               qDebug("RequestMessage::constructArrayToNode : iMessage is NULL or aSize is 0.");
 #endif
                return target;
-               }
+       }
 
        QDomElement last; // last appended node
 
@@ -542,16 +563,16 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
 
        //get the root
        MessageBodyElement root = aArray[idx];
-       if( root.iNodeType != QDomNode::ElementNode || root.iTraversalLevel > 0 )
+       if (root.iNodeType != QDomNode::ElementNode || root.iTraversalLevel > 0)
        {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
+               qDebug("RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults.");
 #endif         
                return target; //Root must be an element and on level 0
        }
        else
        {
-               if( root.iNamespace != QString::null )
+               if (root.iNamespace != QString::null )
                {
                        //QString prefix = root.iNamespace
                        target = iMessage->createElementNS( root.iNamespace, root.iElementName );
@@ -585,7 +606,7 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
                                if( currentLvl == 0 )
                                {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
+                                       qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
 #endif                                                 
                                        return target; //Only root can be at traversal level 0
                                }
@@ -593,17 +614,17 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
                                {
                                        //Sibling to previous
                                        if( !last.parentNode().isNull() )
-                                               last.parentNode().appendChild( elem );
+                                       last.parentNode().appendChild( elem );
                                        else
-                                               {
+                                       {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
+                                               qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
 #endif 
                                                return target; //malformed. if last has no parent, it's a rootnode
-                                               }
+                                       }
                                }
                        }
-                       else if( element.iTraversalLevel > currentLvl )
+                       else if( element.iTraversalLevel> currentLvl )
                        {
                                //check if node is child to previous
                                //else there is something wrong in array representing the structure
@@ -614,7 +635,7 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
                                else
                                {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
+                                       qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
 #endif 
                                        return target;
                                }
@@ -636,7 +657,7 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
                        else
                        {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
+                               qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
 #endif                         
                                //some undefined error
                                return target;
@@ -650,9 +671,9 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
 
                        QDomAttr attr;
                        if( element.iNamespace != QString::null )
-                                attr = iMessage->createAttributeNS( element.iNamespace, element.iElementName );
+                       attr = iMessage->createAttributeNS( element.iNamespace, element.iElementName );
                        else
-                                attr = iMessage->createAttribute( element.iElementName );
+                       attr = iMessage->createAttribute( element.iElementName );
 
                        if( element.iTraversalLevel == currentLvl )
                        {
@@ -661,7 +682,7 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
                        else
                        {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
+                               qDebug( "RequestMessage::constructArrayToNode : Malformed message definition. Check array for faults." );
 #endif                                 
                                //error in template array.
                                //attributes for element must be specified right after element
@@ -672,7 +693,7 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
                else
                {
 #ifdef MU_DEBUG
-       qDebug( "RequestMessage::constructArrayToNode : Node type not supported." );
+                       qDebug( "RequestMessage::constructArrayToNode : Node type not supported." );
 #endif 
                        //node type not supported
                        return target;
@@ -692,71 +713,71 @@ QDomNode RequestMessage::constructArrayToNode( const MessageBodyElement* aArray,
 ResponseMessage::ResponseMessage()
 {
 #ifdef MU_DEBUG
-       qDebug( "ResponseMessage::ResponseMessage" );
+       qDebug("ResponseMessage::ResponseMessage");
 #endif
        iMessage = new QDomDocument();
 #ifdef MU_DEBUG
-       qDebug( "ResponseMessage::ResponseMessage end" );
+       qDebug("ResponseMessage::ResponseMessage end");
 #endif
 }
 
-ResponseMessage::ResponseMessage( const QByteArray& aData )
+ResponseMessage::ResponseMessage(const QByteArray& aData)
 {
 #ifdef MU_DEBUG
-       qDebug( "ResponseMessage::ResponseMessage" );
+       qDebug("ResponseMessage::ResponseMessage");
 #endif
-       iMessage->setContent( aData, true );
+       iMessage->setContent(aData, true);
 #ifdef MU_DEBUG
-       qDebug( "ResponseMessage::ResponseMessage end" );
+       qDebug("ResponseMessage::ResponseMessage end");
 #endif
 }
 
-QString ResponseMessage::getNodeValue( const QString& aNodeName, QDomNode::NodeType aNodeType, const QString& aParentName, int aIndex, QDomNode* aRootNode )
+QString ResponseMessage::getNodeValue(const QString& aNodeName, QDomNode::NodeType aNodeType, const QString& aParentName, int aIndex, QDomNode* aRootNode)
 {
 #ifdef MU_DEBUG
-       qDebug( "ResponseMessage::getNodeValue" );
+       qDebug("ResponseMessage::getNodeValue");
 #endif 
        QString value = QString::null;
        QDomNode node = getNodeFromDocument( aNodeName, aNodeType, aParentName, aIndex, aRootNode );
        if( !node.isNull() )
        {
                if( node.isElement() )
-                       value = node.toElement().text();
+               value = node.toElement().text();
                else if( node.isAttr() )
-                       value = node.toAttr().value();
+               value = node.toAttr().value();
        }
 #ifdef MU_DEBUG
        qDebug( "ResponseMessage::getNodeValue end" );
 #endif 
-       return value;   
+       return value;
 }
 
 bool ResponseMessage::hasErrors()
 {
 #ifdef MU_DEBUG
-       qDebug( "ResponseMessage::hasErrors" );
+       qDebug("ResponseMessage::hasErrors");
 #endif
-       if( !iMessage )
-               {
+       if ( !iMessage)
+       {
 #ifdef MU_DEBUG
-       qDebug( "ResponseMessage::hasErrors : iMessage is NULL." );
+               qDebug("ResponseMessage::hasErrors : iMessage is NULL.");
 #endif
                return true;
-               }
+       }
 
        QDomElement root = iMessage->documentElement();
        bool err = false;
 
-       QString rootname = ( root.prefix() == QString::null ) ? root.tagName() : root.localName();
+       QString rootname = (root.prefix() == QString::null ) ? root.tagName() : root.localName();
        err = ( rootname.compare( QString( "Envelope" ) ) == 0 ) ? false : true;
 
        QDomNodeList list = iMessage->elementsByTagName( QString( "m:ResponseCode" ) );
        for( int i=0; i<list.count(); i++ )
        {
                if( list.item(i).nodeValue().compare( "NoError" ) != 0 )
-                       {
+               {
                        err = true;
-                       }
+               }
        }
 #ifdef MU_DEBUG
        qDebug( "ResponseMessage::hasErrors end : err=%d", err );
@@ -768,90 +789,93 @@ bool ResponseMessage::hasErrors()
  * ReqMsgGetUserAvailability class functions
  */
 
-ReqMsgGetUserAvailability::ReqMsgGetUserAvailability() : RequestMessage( ReqCmdGetUserAvailability )
+ReqMsgGetUserAvailability::ReqMsgGetUserAvailability() :
+       RequestMessage(ReqCmdGetUserAvailability)
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::ReqMsgGetUserAvailability" );
+       qDebug("ReqMsgGetUserAvailability::ReqMsgGetUserAvailability");
 #endif
-       if( iMessage && iCurrCmd == ReqCmdGetUserAvailability )
+       if (iMessage && iCurrCmd == ReqCmdGetUserAvailability)
        {
-               setNodeValue( QString( "MergedFreeBusyIntervalInMinutes" ), QString::number( 60 ) );
-               setNodeValue( QString( "RequestedView" ), QString( "DetailedMerged" ) );
+               setNodeValue(QString("MergedFreeBusyIntervalInMinutes"), QString::number( 60) );
+               setNodeValue(QString("RequestedView"), QString("DetailedMerged") );
        }
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::ReqMsgGetUserAvailability end" );
+       qDebug("ReqMsgGetUserAvailability::ReqMsgGetUserAvailability end");
 #endif 
 }
 
-int ReqMsgGetUserAvailability::addUser( const QString& aAddress, const QString& /*aAttendeeType*/, const QString& aExcludeConflicts )
+int ReqMsgGetUserAvailability::addUser(const QString& aAddress, const QString& /*aAttendeeType*/, const QString& aExcludeConflicts)
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::addUser" );
+       qDebug("ReqMsgGetUserAvailability::addUser");
 #endif
-       if( !iMessage || iCurrCmd != ReqCmdGetUserAvailability )
+       if ( !iMessage || iCurrCmd != ReqCmdGetUserAvailability)
        {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::addUser : iMessage is NULL or current command id is wrong" );
+               qDebug("ReqMsgGetUserAvailability::addUser : iMessage is NULL or current command id is wrong");
 #endif         
                return MsgErrSomeError;
        }
 
        int err = MsgErrNoError;
-       int size = sizeof( reqCmdMailboxElement ) / sizeof( MessageBodyElement );
+       int size = sizeof(reqCmdMailboxElement ) / sizeof(MessageBodyElement);
 
        //Create mailbox data element
-       QDomNode mailbox = constructArrayToNode( reqCmdMailboxElement, size );
-       if( !mailbox.isNull() )
+       QDomNode mailbox = constructArrayToNode(reqCmdMailboxElement, size);
+       if ( !mailbox.isNull() )
        {
                QDomNode email;
 
-               if( mailbox.hasChildNodes() )
+               if (mailbox.hasChildNodes() )
                {
-                       for ( QDomNode subnode = mailbox.firstChild(); !subnode.isNull(); subnode = subnode.nextSibling() )
+                       for (QDomNode subnode = mailbox.firstChild(); !subnode.isNull(); subnode
+                                       = subnode.nextSibling() )
                        {
-                               qDebug( "subnode: %s", subnode.toElement().tagName().toStdString().data() );
-                               if( matchName( subnode, QString( "Email" ) ) )
-                                       {
+                               qDebug("subnode: %s", subnode.toElement().tagName().toStdString().data() );
+                               if (matchName(subnode, QString("Email") ) )
+                               {
                                        email = subnode;
-                                       }
+                               }
                        }
                }
 
-               setNodeValue( QString( "Address" ), aAddress, QDomNode::ElementNode, QString( "Email" ), 0, &email );
-               setNodeValue( QString( "AttendeeType" ), QString( "Required" ), QDomNode::ElementNode, QString( "MailboxData" ), 0, &mailbox );
-               setNodeValue( QString( "ExcludeConflicts" ), aExcludeConflicts, QDomNode::ElementNode, QString( "MailboxData" ), 0, &mailbox );
+               setNodeValue(QString("Address"), aAddress, QDomNode::ElementNode, QString("Email"), 0, &email);
+               setNodeValue(QString("AttendeeType"), QString("Required"), QDomNode::ElementNode, QString("MailboxData"), 0, &mailbox);
+               setNodeValue(QString("ExcludeConflicts"), aExcludeConflicts, QDomNode::ElementNode, QString("MailboxData"), 0, &mailbox);
 
-               err = addNode( mailbox, QDomNode::ElementNode, QString( "MailboxDataArray" ) );
+               err
+                               = addNode(mailbox, QDomNode::ElementNode, QString("MailboxDataArray") );
        }
        else
                err = MsgErrSomeError;
 
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::addUser end : err=%d", err );
+       qDebug("ReqMsgGetUserAvailability::addUser end : err=%d", err);
 #endif 
        return err;
 }
 
-int ReqMsgGetUserAvailability::setTimeWindow( const QDateTime& aStart, const QDateTime& aEnd )
+int ReqMsgGetUserAvailability::setTimeWindow(const QDateTime& aStart, const QDateTime& aEnd)
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::setTimeWindow" );
+       qDebug("ReqMsgGetUserAvailability::setTimeWindow");
 #endif
-       if( !iMessage || iCurrCmd != ReqCmdGetUserAvailability )
+       if ( !iMessage || iCurrCmd != ReqCmdGetUserAvailability)
        {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::setTimeWindow : iMessage is NULL or command id is wrong" );
+               qDebug("ReqMsgGetUserAvailability::setTimeWindow : iMessage is NULL or command id is wrong");
 #endif         
                return MsgErrSomeError;
        }
 
        int err = MsgErrNoError;
 
-       err = setNodeValue( QString( "StartTime" ), aStart.toString( Qt::ISODate ) );
-       err = setNodeValue( QString( "EndTime" ), aEnd.toString( Qt::ISODate ) );
+       err = setNodeValue(QString("StartTime"), aStart.toString(Qt::ISODate) );
+       err = setNodeValue(QString("EndTime"), aEnd.toString(Qt::ISODate) );
 
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::setTimeWindow end : err=%d", err );
+       qDebug("ReqMsgGetUserAvailability::setTimeWindow end : err=%d", err);
 #endif         
        return err;
 }
@@ -859,12 +883,12 @@ int ReqMsgGetUserAvailability::setTimeWindow( const QDateTime& aStart, const QDa
 int ReqMsgGetUserAvailability::setTimeZone()
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::setTimeZone" );
+       qDebug("ReqMsgGetUserAvailability::setTimeZone");
 #endif
-       if( !iMessage || iCurrCmd != ReqCmdGetUserAvailability )
+       if ( !iMessage || iCurrCmd != ReqCmdGetUserAvailability)
        {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::setTimeZone : iMessage is NULL or command id is wrong" );
+               qDebug("ReqMsgGetUserAvailability::setTimeZone : iMessage is NULL or command id is wrong");
 #endif         
                return MsgErrSomeError;
        }
@@ -875,33 +899,34 @@ int ReqMsgGetUserAvailability::setTimeZone()
 
        time(&rawtime);
        localTime = localtime(&rawtime);
-       
+
        int offsetMinutes = localTime->tm_gmtoff / 60;
        if (localTime->tm_isdst)
-               offsetMinutes -= 60;    // If DST is in use then reduce an hour from offset, because
-                                                               // DST will be added to the offset later and it already includes
-                                                               // DST. TODO: This is silly and must be changed if possible.
-                                                               // If you can get UTC offset without DST, use it here.
-       
+               offsetMinutes -= 60; // If DST is in use then reduce an hour from offset, because
+       // DST will be added to the offset later and it already includes
+       // DST. TODO: This is silly and must be changed if possible.
+       // If you can get UTC offset without DST, use it here.
+
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::setTimeZone - offset in minutes=%d", offsetMinutes );
+       qDebug("ReqMsgGetUserAvailability::setTimeZone - offset in minutes=%d", offsetMinutes);
 #endif
-       
-       //TODO: timezone and daylight times to application configuration
-       setNodeValue( QString( "Bias" ), QString::number( -offsetMinutes ), QDomNode::ElementNode, QString( "TimeZone" ) );
-       setNodeValue( QString( "Bias" ), QString::number( 0 ), QDomNode::ElementNode, QString( "StandardTime" ) );
-       setNodeValue( QString( "Time" ), QString( "03:00:00" ), QDomNode::ElementNode, QString( "StandardTime" ) );
-       setNodeValue( QString( "DayOrder" ), QString::number( 5 ), QDomNode::ElementNode, QString( "StandardTime" ) );
-       setNodeValue( QString( "Month" ), QString::number( 10 ), QDomNode::ElementNode, QString( "StandardTime" ) );
-       setNodeValue( QString( "DayOfWeek" ), QString( "Sunday" ), QDomNode::ElementNode, QString( "StandardTime" ) );
-       setNodeValue( QString( "Bias" ), QString::number( -60 ), QDomNode::ElementNode, QString( "DaylightTime" ) );
-       setNodeValue( QString( "Time" ), QString( "03:00:00" ), QDomNode::ElementNode, QString( "DaylightTime" ) );
-       setNodeValue( QString( "DayOrder" ), QString::number( 1 ), QDomNode::ElementNode, QString( "DaylightTime" ) );
-       setNodeValue( QString( "Month" ), QString::number( 4 ), QDomNode::ElementNode, QString( "DaylightTime" ) );
-       setNodeValue( QString( "DayOfWeek" ), QString( "Sunday" ), QDomNode::ElementNode, QString( "DaylightTime" ) );
-
-#ifdef MU_DEBUG
-       qDebug( "ReqMsgGetUserAvailability::setTimeZone end : err=%d", err );
+
+        DateTimeSettings *dateTimeSettings = Configuration::instance()->dateTimeSettings();
+        
+        setNodeValue( QString( "Bias" ), QString::number( -offsetMinutes ), QDomNode::ElementNode, QString( "TimeZone" ) );
+        setNodeValue( QString( "Bias" ), QString::number( 0 ), QDomNode::ElementNode, QString( "StandardTime" ) );
+        setNodeValue( QString( "Time" ), dateTimeSettings->STDTime(), QDomNode::ElementNode, QString( "StandardTime" ) );
+        setNodeValue( QString( "DayOrder" ), dateTimeSettings->STDDay(), QDomNode::ElementNode, QString( "StandardTime" ) );
+        setNodeValue( QString( "Month" ), dateTimeSettings->STDMonth(), QDomNode::ElementNode, QString( "StandardTime" ) );
+        setNodeValue( QString( "DayOfWeek" ), dateTimeSettings->switchDay(), QDomNode::ElementNode, QString( "StandardTime" ) );
+        setNodeValue( QString( "Bias" ), QString::number( -60 ), QDomNode::ElementNode, QString( "DaylightTime" ) );
+        setNodeValue( QString( "Time" ), dateTimeSettings->DSTTime(), QDomNode::ElementNode, QString( "DaylightTime" ) );
+        setNodeValue( QString( "DayOrder" ), dateTimeSettings->DSTDay(), QDomNode::ElementNode, QString( "DaylightTime" ) );
+        setNodeValue( QString( "Month" ), dateTimeSettings->DSTMonth(), QDomNode::ElementNode, QString( "DaylightTime" ) );
+        setNodeValue( QString( "DayOfWeek" ), dateTimeSettings->switchDay(), QDomNode::ElementNode, QString( "DaylightTime" ) );
+
+#ifdef MU_DEBUG
+       qDebug("ReqMsgGetUserAvailability::setTimeZone end : err=%d", err);
 #endif         
        return err;
 }
@@ -909,65 +934,74 @@ int ReqMsgGetUserAvailability::setTimeZone()
 /*
  * ReqMsgConvertMeetingId class functions
  */
-ReqMsgConvertMeetingId::ReqMsgConvertMeetingId( const QString& aItemId, const QString& aMailbox )
+ReqMsgConvertMeetingId::ReqMsgConvertMeetingId(const QString& aItemId, const QString& aMailbox)
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgConvertMeetingId::ReqMsgConvertMeetingId" );
+       qDebug("ReqMsgConvertMeetingId::ReqMsgConvertMeetingId");
 #endif 
        //For this class, we're not going to provide id for base class as parameter,
        //because before content structure initialization, we must add SOAP header to envelope
        iCurrCmd = ReqCmdConvertId;
-       
-       QDomNode header = constructArrayToNode( reqCmdArrayConvertIdHeader, sizeof( reqCmdArrayConvertIdHeader ) / sizeof( MessageBodyElement ) );
-       
-       if( !header.isNull() )
+
+       QDomNode
+                       header =
+                                       constructArrayToNode(reqCmdArrayConvertIdHeader, sizeof(reqCmdArrayConvertIdHeader )
+                                                       / sizeof(MessageBodyElement));
+
+       if ( !header.isNull() )
        {
-               int err = addNode( header, QDomNode::ElementNode, reqCmdArrayEnvelopeBase[0].iElementName );
+               int
+                               err =
+                                               addNode(header, QDomNode::ElementNode, reqCmdArrayEnvelopeBase[0].iElementName);
 
-               if( err == MsgErrNoError )
+               if (err == MsgErrNoError)
                {
-               createMessageStructure( ReqCmdConvertId );
-               
-               if( aItemId != QString::null ) setItemId( aItemId );
-               if( aMailbox != QString::null ) setMailbox( aMailbox );
-               
-               setNodeValue( QString( "Version" ), QString( "Exchange2007_SP1" ), QDomNode::AttributeNode, QString( "RequestServerVersion" ) );
-               setNodeValue( QString( "DestinationFormat" ), QString( "EwsLegacyId" ), QDomNode::AttributeNode, QString( "ConvertId" ) );
-               setNodeValue( QString( "Format" ), QString( "HexEntryId" ), QDomNode::AttributeNode, QString( "AlternateId" ) );
+                       createMessageStructure(ReqCmdConvertId);
+
+                       if (aItemId != QString::null ) setItemId( aItemId );
+                       if( aMailbox != QString::null ) setMailbox( aMailbox );
+
+                       setNodeValue( QString( "Version" ), QString( "Exchange2007_SP1" ), QDomNode::AttributeNode, QString( "RequestServerVersion" ) );
+                       setNodeValue( QString( "DestinationFormat" ), QString( "EwsLegacyId" ), QDomNode::AttributeNode, QString( "ConvertId" ) );
+                       setNodeValue( QString( "Format" ), QString( "HexEntryId" ), QDomNode::AttributeNode, QString( "AlternateId" ) );
                }
        }
        //setNodeValue( QString( "xmlns:t" ), NS_T, QDomNode::AttributeNode, QString( "ConvertId" ) );
-       
+
        //Must be added (for now at least) like this, because Envelope is initialized already, without attributes
        /*QDomAttr attr = iMessage->createAttribute( QString( "xmlns:t" ) );
-       attr.setValue( NS_T );
-       addNode( attr, QDomNode::AttributeNode, QString( "Envelope" ) );
-       */
+        attr.setValue( NS_T );
+        addNode( attr, QDomNode::AttributeNode, QString( "Envelope" ) );
+        */
 #ifdef MU_DEBUG
        qDebug( "ReqMsgConvertMeetingId::ReqMsgConvertMeetingId end" );
 #endif         
 }
 
-int ReqMsgConvertMeetingId::setItemId( const QString& aItemId )
+int ReqMsgConvertMeetingId::setItemId(const QString& aItemId)
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgConvertMeetingId::setItemId" );
+       qDebug("ReqMsgConvertMeetingId::setItemId");
 #endif 
-       int err = setNodeValue( QString( "Id" ), aItemId, QDomNode::AttributeNode, QString( "AlternateId" ) );
+       int
+                       err =
+                                       setNodeValue(QString("Id"), aItemId, QDomNode::AttributeNode, QString("AlternateId") );
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgConvertMeetingId::setItemId end : err=%d", err );
+       qDebug("ReqMsgConvertMeetingId::setItemId end : err=%d", err);
 #endif 
        return err;
 }
 
-int ReqMsgConvertMeetingId::setMailbox( const QString& aMailbox )
+int ReqMsgConvertMeetingId::setMailbox(const QString& aMailbox)
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgConvertMeetingId::setMailbox" );
+       qDebug("ReqMsgConvertMeetingId::setMailbox");
 #endif 
-       int err = setNodeValue( QString( "Mailbox" ), aMailbox, QDomNode::AttributeNode, QString( "AlternateId" ) );
+       int
+                       err =
+                                       setNodeValue(QString("Mailbox"), aMailbox, QDomNode::AttributeNode, QString("AlternateId") );
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgConvertMeetingId::setMailbox end : err=%d", err );
+       qDebug("ReqMsgConvertMeetingId::setMailbox end : err=%d", err);
 #endif
        return err;
 }
@@ -975,31 +1009,34 @@ int ReqMsgConvertMeetingId::setMailbox( const QString& aMailbox )
 /*
  * ReqMsgGetCalendarItem class functions
  */
-ReqMsgGetCalendarItem::ReqMsgGetCalendarItem( const QString& aItemId ) : RequestMessage( ReqCmdGetItem )
+ReqMsgGetCalendarItem::ReqMsgGetCalendarItem(const QString& aItemId) :
+       RequestMessage(ReqCmdGetItem)
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetCalendarItem::ReqMsgGetCalendarItem" );
+       qDebug("ReqMsgGetCalendarItem::ReqMsgGetCalendarItem");
 #endif 
-       if( iMessage && iCurrCmd == ReqCmdGetItem )
+       if (iMessage && iCurrCmd == ReqCmdGetItem)
        {
-               setNodeValue( QString( "BaseShape" ), QString( "AllProperties" ) );
-               
-               if( aItemId != QString::null )
-                       setItemId( aItemId );
+               setNodeValue(QString("BaseShape"), QString("AllProperties") );
+
+               if (aItemId != QString::null )
+               setItemId( aItemId );
        }
 #ifdef MU_DEBUG
        qDebug( "ReqMsgGetCalendarItem::ReqMsgGetCalendarItem end" );
 #endif
 }
 
-int ReqMsgGetCalendarItem::setItemId( const QString& aItemId )
+int ReqMsgGetCalendarItem::setItemId(const QString& aItemId)
 {
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetCalendarItem::setItemId" );
+       qDebug("ReqMsgGetCalendarItem::setItemId");
 #endif 
-       int err = setNodeValue( QString( "Id" ), aItemId, QDomNode::AttributeNode, QString( "ItemId" ), 0 );
+       int
+                       err =
+                                       setNodeValue(QString("Id"), aItemId, QDomNode::AttributeNode, QString("ItemId"), 0);
 #ifdef MU_DEBUG
-       qDebug( "ReqMsgGetCalendarItem::setItemId end : err=%d", err );
+       qDebug("ReqMsgGetCalendarItem::setItemId end : err=%d", err);
 #endif 
        return err;
 }
@@ -1007,137 +1044,141 @@ int ReqMsgGetCalendarItem::setItemId( const QString& aItemId )
 /*
  * ResMsgGetUserAvailability class functions
  */
-ResMsgGetUserAvailability::ResMsgGetUserAvailability( const QByteArray& aData ) : ResponseMessage( aData )
+ResMsgGetUserAvailability::ResMsgGetUserAvailability(const QByteArray& aData) :
+       ResponseMessage(aData)
 {
 #ifdef MU_DEBUG
-       qDebug( "ResMsgGetUserAvailability::ResMsgGetUserAvailability" );
-       qDebug( "ResMsgGetUserAvailability::ResMsgGetUserAvailability end" );
+       qDebug("ResMsgGetUserAvailability::ResMsgGetUserAvailability");
+       qDebug("ResMsgGetUserAvailability::ResMsgGetUserAvailability end");
 #endif
 }
 
-int ResMsgGetUserAvailability::getMeetingsFromResponse( QList<Meeting*>& aMeetings, const Room &aRoom )
+int ResMsgGetUserAvailability::getMeetingsFromResponse(QList<Meeting*>& aMeetings, const Room &aRoom)
 {
 #ifdef MU_DEBUG
-       qDebug( "ResMsgGetUserAvailability::getMeetingsFromResponse" );
+       qDebug("ResMsgGetUserAvailability::getMeetingsFromResponse");
 #endif
-               if( !iMessage )
-                       {
+       if ( !iMessage)
+       {
 #ifdef MU_DEBUG
-       qDebug( "ResMsgGetUserAvailability::getMeetingsFromResponse : iMessage is NULL" );
+               qDebug("ResMsgGetUserAvailability::getMeetingsFromResponse : iMessage is NULL");
 #endif 
-                       return MsgErrSomeError;
-                       }
+               return MsgErrSomeError;
+       }
 
-               //TODO: Clean this function a bit (see getMeetingDetailsFromResponse)
-               
-               int err = MsgErrNoError;
+       //TODO: Clean this function a bit (see getMeetingDetailsFromResponse)
 
-               QDomNodeList list = iMessage->elementsByTagName( QString( "CalendarEvent" ) );
+       int err = MsgErrNoError;
 
-               for( int i=0; i<list.count(); i++ )
+       QDomNodeList list = iMessage->elementsByTagName(QString("CalendarEvent") );
+
+       for (int i=0; i<list.count(); i++)
+       {
+               QDomElement e = list.item( i ).toElement();
+               QString tagName = (e.prefix() == QString::null ) ? e.tagName().toLower() : e.localName().toLower();
+
+               if( !e.isNull() && tagName == "calendarevent" )
                {
-                       QDomElement e = list.item( i ).toElement();
-                       QString tagName = ( e.prefix() == QString::null ) ? e.tagName().toLower() : e.localName().toLower();
 
-                       if( !e.isNull() && tagName == "calendarevent" )
-                       {
+                       QString id, startsAt, endsAt, organizer, subject;
 
-                               QString id, startsAt, endsAt, organizer, subject;
+                       for ( QDomNode subnode = e.firstChild(); !subnode.isNull(); subnode = subnode.nextSibling() )
+                       {
+                               QDomElement e = subnode.toElement();
+                               QString tagName = ( e.prefix() == QString::null ) ? e.tagName().toLower() : e.localName().toLower();
 
-                               for ( QDomNode subnode = e.firstChild(); !subnode.isNull(); subnode = subnode.nextSibling() )
+                               if( tagName == QString( "starttime" ) )
+                               {
+                                       startsAt = e.text();
+                               }
+                               else if( tagName == QString( "endtime" ) )
+                               {
+                                       endsAt = e.text();
+                               }
+                               else if( tagName == QString( "calendareventdetails" ) )
                                {
-                                       QDomElement e = subnode.toElement();
-                                       QString tagName = ( e.prefix() == QString::null ) ? e.tagName().toLower() : e.localName().toLower();
 
-                                       if( tagName == QString( "starttime" ) )
-                                       {
-                                               startsAt = e.text();
-                                       }
-                                       else if( tagName == QString( "endtime" ) )
+                                       for ( QDomNode detailnode = subnode.firstChild(); !detailnode.isNull(); detailnode = detailnode.nextSibling() )
                                        {
-                                               endsAt = e.text();
-                                       }
-                                       else if( tagName == QString( "calendareventdetails" ) )
-                                       {
-
-                                               for ( QDomNode detailnode = subnode.firstChild(); !detailnode.isNull(); detailnode = detailnode.nextSibling() )
-                                               {
 
-                                                       QDomElement e = detailnode.toElement();
-                                                       QString tagName = ( e.prefix() == QString::null ) ? e.tagName().toLower() : e.localName().toLower();
+                                               QDomElement e = detailnode.toElement();
+                                               QString tagName = ( e.prefix() == QString::null ) ? e.tagName().toLower() : e.localName().toLower();
 
-                                                       if( tagName == QString( "id" ) )
-                                                       {                                                       
-                                                               id = e.text();
-                                                       }
+                                               if( tagName == QString( "id" ) )
+                                               {
+                                                       id = e.text();
+                                               }
 
-                                                       if( tagName == QString( "subject" ) )
-                                                       {
-                                                               subject = e.text();
-                                                       }
+                                               if( tagName == QString( "subject" ) )
+                                               {
+                                                       subject = e.text();
                                                }
                                        }
                                }
+                       }
 
-                               QDateTime start = QDateTime::fromString( startsAt, Qt::ISODate );
-                               QDateTime end = QDateTime::fromString( endsAt, Qt::ISODate );
+                       QDateTime start = QDateTime::fromString( startsAt, Qt::ISODate );
+                       QDateTime end = QDateTime::fromString( endsAt, Qt::ISODate );
 
-                               aMeetings.append( new Meeting(
-                                               id,
-                                               aRoom,
-                                               start,
-                                               end,
-                                               subject ) );
+                       aMeetings.append( new Meeting(
+                                       id,
+                                       aRoom,
+                                       start,
+                                       end,
+                                       subject ) );
 
-                       }
                }
+       }
 #ifdef MU_DEBUG
        qDebug( "ResMsgGetUserAvailability::getMeetingsFromResponse end : err=%d", err );
 #endif         
-               return err;
+       return err;
 }
 
 /*
  * ResMsgGetCalendarItem class functions
  */
-int ResMsgGetCalendarItem::getMeetingDetailsFromResponse( Meeting& aMeeting )
+int ResMsgGetCalendarItem::getMeetingDetailsFromResponse(Meeting& aMeeting)
 {
 #ifdef MU_DEBUG
-       qDebug( "ResMsgGetCalendarItem::getMeetingDetailsFromResponse" );
+       qDebug("ResMsgGetCalendarItem::getMeetingDetailsFromResponse");
 #endif
-       if( !iMessage || hasErrors() )
-               {
+       if ( !iMessage || hasErrors() )
+       {
 #ifdef MU_DEBUG
-       qDebug( "ResMsgGetCalendarItem::getMeetingDetailsFromResponse : iMessage is NULL or response has errors." );
+               qDebug("ResMsgGetCalendarItem::getMeetingDetailsFromResponse : iMessage is NULL or response has errors.");
 #endif         
                return MsgErrSomeError;
-               }
+       }
 
        QString name, address, description; //Organizer
 
-       QDomNode box = getElementFromDocument( QString( "Mailbox" ), QString( "Organizer" ), 0 );
+       QDomNode box =
+                       getElementFromDocument(QString("Mailbox"), QString("Organizer"), 0);
 
-       if( !box.isNull() && box.hasChildNodes() )
+       if ( !box.isNull() && box.hasChildNodes() )
        {
-               for ( QDomNode subnode = box.firstChild(); !subnode.isNull(); subnode = subnode.nextSibling() )
+               for (QDomNode subnode = box.firstChild(); !subnode.isNull(); subnode
+                               = subnode.nextSibling() )
                {
-                       if( matchName( subnode, QString( "Name" ) ) )
+                       if (matchName(subnode, QString("Name") ) )
                                name = subnode.toElement().text();
-                       else if( matchName( subnode, QString( "EmailAddress" ) ) )
+                       else if (matchName(subnode, QString("EmailAddress") ) )
                                address = subnode.toElement().text();
                }
        }
-       
-       QDomNode body = getElementFromDocument( QString( "Body" ), QString( "CalendarItem" ), 0 );
 
-       if( body.isElement() )
+       QDomNode body =
+                       getElementFromDocument(QString("Body"), QString("CalendarItem"), 0);
+
+       if (body.isElement() )
                description = body.toElement().text();
-       
-       aMeeting.setOrganizer( name, address );
-       aMeeting.setDescription( description );
+
+       aMeeting.setOrganizer(name, address);
+       aMeeting.setDescription(description);
 
 #ifdef MU_DEBUG
-       qDebug( "ResMsgGetCalendarItem::getMeetingDetailsFromResponse end" );
+       qDebug("ResMsgGetCalendarItem::getMeetingDetailsFromResponse end");
 #endif         
        return MsgErrNoError;
 }
index 4b7a128..fad0493 100644 (file)
@@ -7,7 +7,7 @@
 #include <QtDebug>
 
 MeetingRoomCombo::MeetingRoomCombo( QList<Room*> aRooms, QWidget *aParent ) :
-               ObservedWidget( aParent )
+               QWidget( aParent )
 {
        iRooms = aRooms;
        qSort( iRooms.begin(), iRooms.end(), Room::caseInsensitiveLessThan );
index 5c7120a..01a858e 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef MEETINGROOMCOMBO_H_\r
 #define MEETINGROOMCOMBO_H_\r
 \r
-#include "ObservedWidget.h"\r
 #include <QWidget>\r
 #include <QList>\r
 \r
@@ -13,7 +12,7 @@ class Room;
  * Userinterface class. Displays a list of selectable meeting rooms. Customized QComboBox which hides\r
  * all the not needed functionality of the "base" class.\r
  */\r
-class MeetingRoomCombo : public ObservedWidget\r
+class MeetingRoomCombo : public QWidget\r
 {\r
        Q_OBJECT\r
 \r
index 8267ca0..9fd2fab 100644 (file)
@@ -1,7 +1,7 @@
 #include "TimeDisplayWidget.h"\r
 \r
 TimeDisplayWidget::TimeDisplayWidget( QTime aNow, QWidget *aParent ) :\r
-               ObservedWidget( aParent )\r
+               QWidget( aParent )\r
 \r
 {\r
        iCurrentTime = aNow;\r
index a1bcfd4..5f4e3a4 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef TIMEDISPLAYWIDGET_H_\r
 #define TIMEDISPLAYWIDGET_H_\r
 \r
-#include "ObservedWidget.h"\r
 #include <QWidget>\r
 #include <QColor>\r
 #include <QTime>\r
@@ -11,7 +10,7 @@
  * Abstact. UserInterface class. Offers  basic functionality to display time. Inherited by\r
  * DigitalTimeDisplayWidget.\r
  */\r
-class TimeDisplayWidget : public ObservedWidget\r
+class TimeDisplayWidget : public QWidget\r
 {\r
        Q_OBJECT\r
 \r
index 95e2cce..9a08de9 100644 (file)
@@ -13,6 +13,28 @@ MeetingInfoDialog::MeetingInfoDialog( Meeting *aMeeting, QWidget *aParent ) :
 {
        setWindowTitle( tr( "Details" ) );
 
+       if ( aMeeting != 0 )
+       {
+               createDialogView( aMeeting );
+       }
+
+       setMinimumWidth( MeetingInfoDialog::width );
+       setMinimumHeight( MeetingInfoDialog::height );
+}
+
+MeetingInfoDialog::~MeetingInfoDialog()
+{
+}
+
+void MeetingInfoDialog::setMeeting(Meeting *aMeeting)
+{
+       createDialogView( aMeeting );
+}
+
+void MeetingInfoDialog::createDialogView(Meeting *aMeeting)
+{
+       qDebug() << "[MeetingInfoDialog::createDialogView] <Invoked>";
+       
        QFont normalFont;
        normalFont.setPointSize( 11 );
 
@@ -75,11 +97,6 @@ MeetingInfoDialog::MeetingInfoDialog( Meeting *aMeeting, QWidget *aParent ) :
        layout->addStretch();
        layout->addLayout( buttonLayout );
        setLayout( layout );
-
-       setMinimumWidth( MeetingInfoDialog::width );
-       setMinimumHeight( MeetingInfoDialog::height );
-}
-
-MeetingInfoDialog::~MeetingInfoDialog()
-{
+       
+       qDebug() << "[MeetingInfoDialog::createDialogView] <Finished>";
 }
index a62cb32..86c33d1 100644 (file)
@@ -19,11 +19,14 @@ public:
         * \param aMeeting The Meeting instance which is needed to be presented in detail.\r
         * \param aParent Pointer to the parent widget. Optional.\r
         */\r
-       MeetingInfoDialog( Meeting *aMeeting, QWidget *aParent = 0 );\r
+       MeetingInfoDialog( Meeting *aMeeting = 0, QWidget *aParent = 0 );\r
        //! Destructor.\r
        virtual ~MeetingInfoDialog();\r
+       \r
+       void setMeeting( Meeting * aMeeting );\r
 \r
 private:\r
+       void createDialogView(Meeting *aMeeting);\r
 \r
        static const int width = 200;\r
        static const int height = 400;\r
index 7421a47..c903bc0 100644 (file)
@@ -11,7 +11,7 @@
 QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );\r
 \r
 RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :\r
-               ObservedWidget( aParent ), iTimeFormat( aTimeFormat )\r
+               ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )\r
 {\r
        QFont importantTextFont;\r
        //importantTextFont.setBold( true );\r
index 615051e..c20ce45 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef ROOMSTATUSINDICATORWIDGET_H_\r
 #define ROOMSTATUSINDICATORWIDGET_H_\r
 \r
-#include "ObservedWidget.h"\r
+#include "ViewBase.h"\r
 #include <QTime>\r
 #include <QKeyEvent>\r
 #include <QTabletEvent>\r
@@ -19,7 +19,7 @@ class TimeDisplayWidget;
  * and disappears if there is any. Its function is to behave like a screen saver on one hand, and\r
  * to provide details about the current availability on the other hand.\r
  */\r
-class RoomStatusIndicatorWidget : public ObservedWidget\r
+class RoomStatusIndicatorWidget : public ViewBase\r
 {\r
        Q_OBJECT\r
 \r
@@ -55,6 +55,8 @@ public slots:
         * \param aUntil The new time until the specified status is valid.\r
         */\r
        void statusChanged( const Room::Status aStatus, const QTime aUntil );\r
+       \r
+       void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
 \r
 private:\r
        //! Translates the status into human readable text.\r
index caa5cfe..1021d77 100644 (file)
@@ -24,7 +24,7 @@
 #include <QtDebug>
 
 SettingsView::SettingsView( QWidget *aParent ) :
-               ObservedWidget( aParent )
+               ViewBase( ViewBase::NormalView, aParent )
 {
        qDebug() << "SettingsView::ctor invoked";
        // Prepare the tabbed view
@@ -44,10 +44,7 @@ SettingsView::SettingsView( QWidget *aParent ) :
        QHBoxLayout *buttonLayout = new QHBoxLayout;
        iOkButton = new QPushButton;
        iOkButton->setText( tr( "OK" ) );
-       iCancelButton = new QPushButton;
-       iCancelButton->setText( tr( "Cancel" ) );
        buttonLayout->addWidget( iOkButton );
-       buttonLayout->addWidget( iCancelButton );
 
        // Handle the main layout
        QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -57,8 +54,7 @@ SettingsView::SettingsView( QWidget *aParent ) :
        setLayout( mainLayout );
 
        // Handle component connections
-       connect( iOkButton, SIGNAL( pressed() ), this, SLOT( okClicked() ) );
-       connect( iCancelButton, SIGNAL( pressed() ), this, SLOT( cancelClicked() ) );
+       connect( iOkButton, SIGNAL( clicked() ), this, SLOT( handleOkClicked() ) );
 }
 
 SettingsView::~SettingsView()
@@ -73,11 +69,6 @@ SettingsView::~SettingsView()
                delete iOkButton;
                iOkButton = 0;
        }
-       if ( iCancelButton != 0 )
-       {
-               delete iCancelButton;
-               iCancelButton = 0;
-       }
        if ( iSettingsTab != 0 )
        {
                delete iSettingsTab;
@@ -389,7 +380,7 @@ QWidget *SettingsView::initKioskModeTab()
        return widget;
 }
 
-void SettingsView::okClicked()
+void SettingsView::handleOkClicked()
 {
        qDebug() << "[SettingsView::okClicked] <Invoked>";
 
@@ -409,12 +400,17 @@ void SettingsView::okClicked()
        bool powerSaveEnabled = iPowerSaveEnabled->isChecked();
 
        // TODO : Set the values to configuration and save it
-
-       close();
+       
+       // Emit the signal to notify that ok is pressed and data is saved.
+       emit okClicked();
 }
 
-void SettingsView::cancelClicked()
+void SettingsView::viewResized(const QSize &newSize, const QSize &oldSize)
 {
-       qDebug() << "[SettingsView::cancelClicked] <Invoked>";
-       close();
-}
+       if ( oldSize.height() > newSize.height() )
+       {
+               // Get the button's height and add that to the new size so that
+               // the ok button is hidden under the keyboard.
+               size().rheight() += iOkButton->size().height();
+       }
+}
\ No newline at end of file
index 8b9bbeb..2845a8d 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef SETTINGSVIEW_H_
 #define SETTINGSVIEW_H_
 
-#include "ObservedWidget.h"
+#include "ViewBase.h"
 
 class QTabWidget;
 class QPushButton;
@@ -9,9 +9,10 @@ class QLineEdit;
 class QTimeEdit;
 class QRadioButton;
 class QCheckBox;
+class QSize;
 
 //! User interface class. Shows the settings view and handles configuration changes.
-class SettingsView : public ObservedWidget
+class SettingsView : public ViewBase
 {
        Q_OBJECT
 
@@ -25,12 +26,16 @@ public:
        SettingsView( QWidget *aParent = 0 );
        //! Destructor.
        virtual ~SettingsView();
+       
+signals:
+       void okClicked();
+       
+public slots:
+       void viewResized(const QSize &newSize, const QSize &oldSize);
 
 private slots:
        //! Slot to handle the Ok button pressing.
-       void okClicked();
-       //! Slot to handle the cancel button pressing.
-       void cancelClicked();
+       void handleOkClicked();
 
 private:
        //! Initialize "Settings" tab.
@@ -46,8 +51,6 @@ private:
        QTabWidget *iTabWidget;
        //! OK button to dismiss the settings view with saving the settings.
        QPushButton *iOkButton;
-       //! Cancel button to dismiss the settings view without saving settings.
-       QPushButton *iCancelButton;
        //! Settings tab.
        QWidget *iSettingsTab;
        //! Week View tab.
diff --git a/src/UserInterface/Views/ViewBase.cpp b/src/UserInterface/Views/ViewBase.cpp
new file mode 100644 (file)
index 0000000..24d6461
--- /dev/null
@@ -0,0 +1,77 @@
+#include "ViewBase.h"
+
+#include <QEvent>
+#include <QKeyEvent>
+#include <QTabletEvent>
+#include <QMouseEvent>
+#include <QMouseEvent>
+#include <QMouseEvent>
+#include <QLayout>
+
+#include <QtDebug>
+
+ViewBase::ViewBase( ViewBase::ViewMode aMode, QWidget *aParent ) : QWidget( aParent ), iViewMode( aMode )
+{
+
+}
+
+ViewBase::~ViewBase()
+{
+       
+}
+
+ViewBase::ViewMode ViewBase::viewMode()
+{
+       return iViewMode;
+}
+
+bool ViewBase::event(QEvent *event)
+{
+       switch( event->type() )
+       {
+               // TODO : Add events as needed !!!
+               case QEvent::KeyPress:
+               case QEvent::KeyRelease:
+               case QEvent::TabletMove:
+               case QEvent::TabletPress:
+               case QEvent::MouseMove:
+               case QEvent::MouseButtonPress:
+               case QEvent::MouseButtonDblClick:
+                       emit eventDetected();
+                       break;
+               default:
+                       break;
+       }
+       
+       return QWidget::event( event );
+}
+
+bool ViewBase::eventFilter( QObject *watched, QEvent *event )
+{
+       if ( watched != this ) // We do not filter our own events
+       {
+               switch( event->type() )
+               {
+                       // TODO : Add events as needed !!!!
+                       case QEvent::KeyPress:
+                       case QEvent::KeyRelease:
+                       case QEvent::TabletMove:
+                       case QEvent::TabletPress:
+                       case QEvent::MouseMove:
+                       case QEvent::MouseButtonPress:
+                       case QEvent::MouseButtonDblClick:
+                               emit eventDetected();
+                               break;
+                       default:
+                               break;
+               }
+       }
+       
+       return QWidget::eventFilter( watched, event );
+}
+
+void ViewBase::observeChild(QWidget *aChild)
+{
+       aChild->setMouseTracking( true );
+       aChild->installEventFilter( this );
+}
diff --git a/src/UserInterface/Views/ViewBase.h b/src/UserInterface/Views/ViewBase.h
new file mode 100644 (file)
index 0000000..631a089
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef VIEWBASE_
+#define VIEWBASE_
+
+#include <QWidget>
+
+class QEvent;
+class QSize;
+
+class ViewBase : public QWidget
+{
+       Q_OBJECT
+       
+public:
+       enum ViewMode
+       {
+               NormalView, /*!< Indicates that the view is normal view that isn't hidden by events. */
+               ObservedView /*!< Indicates that the view will be hidden when event occurs. */
+       };
+       
+public:
+       ViewBase( ViewBase::ViewMode aMode, QWidget *aParent = 0 );
+       virtual ~ViewBase();
+       
+       //! Overwritten event handler.
+       /*!
+        * Listens for events and emits eventDetected signal when observed
+        * event is triggered.
+        */
+       virtual bool event(QEvent *event);
+       
+       //! Event filter.
+       /*!
+        * Event filter method that is used to listen for child widgets
+        * events.
+        */
+       virtual bool eventFilter(QObject *watched, QEvent *event);
+       
+       //! Returns view mode.
+       /*!
+        * Returns the views mode which is one of the ViewMode enumerations.
+        */
+       ViewBase::ViewMode viewMode();
+       
+public slots:
+       //! This slot is called when the view is resized.
+       /*!
+        * This slot will be called after the view is resized by the window manager
+        * to fit its client area. This method can be used to refine the view size
+        * after it has been resized, for example when the on screen keyboard is
+        * displayed.
+        */
+       virtual void viewResized(const QSize &newSize, const QSize &oldSize) = 0;
+       
+signals:
+       /*!
+        * This signal indicates that some user initiated event has occured.
+        * Event filter tracks for mouse, pointer and key events.
+        */
+       void eventDetected();
+       
+protected:
+       void observeChild(QWidget *aChild);
+       
+private:
+       ViewMode iViewMode;
+       
+};
+
+#endif /*VIEWBASE_*/
index 21fdc94..673d91e 100644 (file)
@@ -20,7 +20,7 @@
 #include <QtDebug>\r
 \r
 WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *aConfiguration, QWidget *aParent ) :\r
-               ObservedWidget( aParent ), iConfiguration( aConfiguration )\r
+               ViewBase( ViewBase::NormalView, aParent ), iConfiguration( aConfiguration )\r
 {\r
 \r
        // *****************************************\r
@@ -36,23 +36,21 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a
        iSettingsButton = new QPushButton;\r
        iSettingsButton->setIcon( QPixmap( ":button_settings" ) );\r
        iSettingsButton->setFixedWidth( 36 );\r
-       connect( iSettingsButton, SIGNAL( clicked() ), this, SIGNAL( showSettingsView() ) );\r
+       connect( iSettingsButton, SIGNAL( clicked() ), this, SIGNAL( settingsButtonClicked() ) );\r
 \r
        iCurrentDayLabel = ToolBox::createLabel( aCurrentDateTime.toString( iConfiguration->displaySettings()->dateFormat() ), regularTextFont );\r
        iCurrentWeekLabel = ToolBox::createLabel( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ), regularTextFont );\r
 \r
        iRoomsCombo = new MeetingRoomCombo( iConfiguration->rooms(), this );\r
        iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() );\r
-       connect( iRoomsCombo, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
+       connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );\r
 \r
        iTimeDisplay = new DigitalTimeDisplayWidget( aCurrentDateTime.time(), iConfiguration->displaySettings()->timeFormat(), this );\r
        iTimeDisplay->setFrameVisible( false );\r
        iTimeDisplay->setFont( regularTextFont );\r
-       connect( iTimeDisplay, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
 \r
        iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this );\r
        connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );\r
-       connect( iSchedule, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
        connect( iSchedule, SIGNAL( meetingActivated( Meeting* ) ), this, SIGNAL( meetingActivated( Meeting* ) ) );\r
 \r
        iPreviousWeekButton = new QPushButton( this );\r
@@ -91,6 +89,16 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a
        mainLayout->addLayout( tableLayout );\r
        mainLayout->addLayout( bottomLayout );\r
        setLayout( mainLayout );\r
+       \r
+       // Set child observing\r
+       observeChild( iRoomsCombo );\r
+       observeChild( iTimeDisplay );\r
+       observeChild( iCurrentDayLabel );\r
+       observeChild( iCurrentWeekLabel );\r
+       observeChild( iPreviousWeekButton );\r
+       observeChild( iCurrentWeekButton );\r
+       observeChild( iNextWeekButton );\r
+       observeChild( iSettingsButton );\r
 \r
        QPalette palette;\r
        palette.setColor( QPalette::Window, Qt::white );\r
@@ -100,11 +108,11 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a
        // ******************************************\r
        //              Handle all the signal connections\r
        // TODO : this solution if interaction monitoring is not elegant enough\r
-       connect( iPreviousWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
-       connect( iCurrentWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
-       connect( iNextWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
-       connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );\r
-       connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iPreviousWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iCurrentWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iNextWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );\r
        // TODO: connect RoomCombo signals to change meetings data.\r
        connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );\r
        connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( refresh() ) );\r
index f4c4762..055617b 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef WEEKLYVIEWWIDGET_H_\r
 #define WEEKLYVIEWWIDGET_H_\r
 \r
-#include "ObservedWidget.h"\r
+#include "ViewBase.h"\r
 #include <QDateTime>\r
 \r
 class QLabel;\r
@@ -19,7 +19,7 @@ class Room;
  * selected meeting room. User can select meeting room, browse weeks back and forth, and can navigate\r
  * back to the current week.\r
  */\r
-class WeeklyViewWidget : public ObservedWidget\r
+class WeeklyViewWidget : public ViewBase\r
 {\r
        Q_OBJECT\r
 \r
@@ -101,14 +101,14 @@ signals:
        /*!\r
         * Signal is emited when settings button is clicked.\r
         */\r
-       void showSettingsView();\r
+       void settingsButtonClicked();\r
        \r
        //! Signal. Emitted if the shown week has been changed.\r
        /*!\r
         * Signal. Emitted if the shown week has been changed.
         * \param aDate The first date of the shown week.
         */
-       void shownWeekChanged( QDate aDate );
+       void shownWeekChanged( QDate aDate );\r
 \r
 public slots:\r
        //! Sets the date and time\r
@@ -117,6 +117,12 @@ public slots:
         * \param aCurrentDateTime Date and time to be displayd.\r
         */\r
        void setCurrentDateTime( QDateTime aCurrentDateTime );\r
+       //! Handle resizing\r
+       /*!\r
+        * Handle possible resize changes after the view is resized\r
+        * to match the window managers client area.\r
+        */\r
+       void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
 \r
 private:\r
        //! Displays the selectable meeting rooms.\r
index 552bb7c..af006f1 100644 (file)
 #include "WindowManager.h"
 
-#include <QTimer>
-#include "Configuration.h"
-#include "DisplaySettings.h"
-#include "Meeting.h"
-#include "Room.h"
-#include "Clock.h"
-#include "WeeklyViewWidget.h"
-#include "RoomStatusIndicatorWidget.h"
-#include "MeetingInfoDialog.h"
+#include <QEvent>
+#include <QDialog>
+#include "ViewBase.h"
 #include "PopUpMessageBox.h"
-#include "DeviceManager.h"
-#include "SettingsView.h"
-#include "ProgressBar.h"
 
 #include <QtDebug>
 
-WindowManager::WindowManager( Configuration *aConfiguration ) :
-               QObject(),
+WindowManager::WindowManager( QWidget *aParent ) :
+               QWidget( aParent ),
                iApplicationName( tr( "Qt Meetings" ) ),
-               iFullScreen( false ),
-               iConfiguration( aConfiguration ),
-               iWeeklyView( 0 ),
-               iRoomStatusView( 0 ),
-               iMeetingInfo( 0 ),
-               iProgressBar( 0 ),
-               iPasswordDialog( 0 )
+               iCurrentView( 0 )
 {
-       iWeeklyView = new WeeklyViewWidget( QDateTime::currentDateTime(), aConfiguration );
-       iWeeklyView->setWindowTitle( iApplicationName );
-       connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
-       connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), this, SIGNAL( meetingActivated( Meeting * ) ) );
-       connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );
-       connect( iWeeklyView, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );
-       
-       showWeeklyView();
-       
+       this->setWindowTitle( iApplicationName );
 }
 
 WindowManager::~WindowManager()
 {
-       delete iWeeklyView;
-       iWeeklyView = 0;
-       delete iRoomStatusView;
-       iRoomStatusView = 0;
-       delete iMeetingInfo;
-       iMeetingInfo = 0;
-       delete iProgressBar;
-       iProgressBar = 0;
-       delete iPasswordDialog;
-       iPasswordDialog = 0;
+       
 }
 
-void WindowManager::distributeDateTimeInfo( QDateTime aCurrentDateTime )
+void WindowManager::showView( ViewBase *view )
 {
-       if ( iRoomStatusView != 0 && iRoomStatusView->isActiveWindow() )
+       // The views parent must be WindowManager when it is displayed trough this
+       QWidget *parent = static_cast<QWidget *>(view->parent());
+       if ( parent != this )
        {
-               iRoomStatusView->setCurrentTime( aCurrentDateTime.time() );
+               view->setParent( this );
        }
-
-       if ( iWeeklyView != 0 && iWeeklyView->isActiveWindow() )
+       
+       // Store the current view because it is hidden after the new view is shown
+       QWidget *oldView = iCurrentView;
+       
+       // If the new view is observed view we store the current into stack
+       // from which it is restored when the new view receives event we are
+       // listening to.
+       if ( view->viewMode() == ViewBase::ObservedView )
        {
-               iWeeklyView->setCurrentDateTime( aCurrentDateTime );
+               iViewList.push( iCurrentView );
        }
+       
+       // Make the new view visible and handle connections
+       iCurrentView = view;
+       connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
+       connect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), iCurrentView, SLOT( viewResized( const QSize &, const QSize & ) ) );
+       view->resize( this->size() );
+       
+       view->show();
+       
+       // Disconnect old connections and hide the view
+       if ( oldView != 0 )
+       {
+               disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
+               disconnect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), oldView, SLOT( viewResized(const QSize &, const QSize &) ) );
+               oldView->hide();
+       }
+       
 }
 
-void WindowManager::roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime )
+void WindowManager::showDialog(QDialog *aDialog, bool blocking, bool aSendSignal)
 {
-       if ( iRoomStatusView == 0 )
+       // Handle dialog displaying
+       if ( aSendSignal ) emit dialogActivated();
+       if ( blocking )
        {
-               iRoomStatusView = new RoomStatusIndicatorWidget( aRoom, aStatus, aTime, iConfiguration->displaySettings()->timeFormat() );
-               iRoomStatusView->setWindowTitle( iApplicationName );
-               if( iFullScreen )
-                       iRoomStatusView->setWindowState( Qt::WindowFullScreen );
-               connect( iRoomStatusView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
+               aDialog->exec();
        }
        else
        {
-               iRoomStatusView->statusChanged( aStatus, aTime );
-       }
-       if ( !iWeeklyView->isVisible() && !iRoomStatusView->isVisible() )
-       {
-               showRoomStatus();
+               aDialog->show();
        }
+       if ( aSendSignal ) emit dialogDeactivated();
 }
 
-void WindowManager::showRoomStatus()
+void WindowManager::viewEventDetected()
 {
-       qDebug() << "WindowManager::showRoomStatus";
-       iWeeklyView->setDefaultRoom();
-       if ( iRoomStatusView == 0 )
-       {
-               emit roomStatusInfoNeeded( iWeeklyView->currentRoom() );
-       }
-       else
+       
+       if ( iCurrentView != 0 )
        {
-               iRoomStatusView->show();
-               if ( iWeeklyView->isVisible() )
+               if ( iCurrentView->viewMode() == ViewBase::NormalView )
                {
-                       iWeeklyView->hide();
+                       emit eventDetected();
+               }
+               else if ( iCurrentView->viewMode() == ViewBase::ObservedView )
+               {
+                       if ( !iViewList.isEmpty() )
+                       {
+                               ViewBase *previousView = static_cast<ViewBase *>( iViewList.pop() );
+                               this->showView( previousView );
+                               emit previousViewRestored();
+                       }
                }
        }
 
-       // closing/deleting meeting info dialog
-       if ( iMeetingInfo != 0 )
-       {
-               iMeetingInfo->hide();
-       }
 }
 
-void WindowManager::showWeeklyView()
+bool WindowManager::event(QEvent *event)
 {
-       qDebug() << "WindowManager::showWeeklyView";
-       if ( iRoomStatusView != 0 && iRoomStatusView->isVisible() )
+       if ( event->type() == QEvent::Resize )
        {
-               iRoomStatusView->hide();
+               if ( iCurrentView != 0 )
+               {
+                       QSize currentSize = iCurrentView->size();
+                       iCurrentView->setFixedSize( this->size() );
+                       emit viewResized( this->size(), currentSize );
+               }
        }
-
-       iWeeklyView->show();
-}
-
-void WindowManager::fullScreen()
-{
-       if ( iRoomStatusView != 0 )
-               iRoomStatusView->setWindowState( Qt::WindowFullScreen );
-       if ( iWeeklyView != 0 )
-               iWeeklyView->setWindowState( Qt::WindowFullScreen );
-       iFullScreen = true;
-}
-
-void WindowManager::showMeetingInfo( Meeting *aMeeting )
-{
-       iMeetingInfo = new MeetingInfoDialog( aMeeting );
-       // Display modal dialog
-       iMeetingInfo->exec();
-
-       delete iMeetingInfo;
-       iMeetingInfo = 0;
-}
-
-void WindowManager::showSettingsView()
-{
-       // TODO : give the Torspo for the person who was responsible to write this method
-}
-
-WeeklyViewWidget * WindowManager::weeklyView()
-{
-       return iWeeklyView;
-}
-
-void WindowManager::error( const QString &aErrorMessage )
-{
-       qDebug() << "WindowManager::showErrorPopup";
-
-       PopUpMessageBox::error( 0, aErrorMessage );
-}
-
-void WindowManager::showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage )
-{
-       iPasswordDialog = new PasswordDialog( aAdminPassword, aMessage );
-       connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ),
-                       this, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ) );
-       iPasswordDialog->show();
        
-       //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
+       return QWidget::event( event );
 }
 
-void WindowManager::closePasswordDialog()
-{
-       iPasswordDialog->close();
-       delete iPasswordDialog;
-       iPasswordDialog = 0;
-}
-
-void WindowManager::showProgressBar( const QString &aText, bool aCancellable )
+void WindowManager::error( const QString &aErrorMessage )
 {
-       qDebug() << "WindowManager::showProgressBar( const QString & )";
-       if( iProgressBar == 0 ) {
-               iProgressBar = new ProgressBar( aText, aCancellable );
-               iProgressBar->setFixedSize( 600, 125 );
-               iProgressBar->show();
-               if( aCancellable )
-                       connect( iProgressBar, SIGNAL( cancel() ), this, SIGNAL( progressBarCancelled() ) );
-       }
-       
-       //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
-}
+       qDebug() << "WindowManager::error       ";
 
-void WindowManager::closeProgressBar()
-{
-       qDebug() << "WindowManager::closeProgressBar()";
-       if( iProgressBar )
+       PopUpMessageBox *popup = PopUpMessageBox::error( 0, aErrorMessage );
+       if ( popup != 0 )
        {
-               iProgressBar->close();
-               delete iProgressBar;
-               iProgressBar = 0;
+               showDialog( static_cast<QDialog *>( popup ), false );
        }
 }
 
-void WindowManager::updateProgressBar( const QString &aMessage )
-{
-       qDebug() << "WindowManager::updateProgressBar( const QString & )";
-       if( iProgressBar != 0 )
-               iProgressBar->update( aMessage );
-}
-
-void WindowManager::refreshMeetings( const QList<Meeting*> &aMeetings )
+void WindowManager::setFullscreen()
 {
-       qDebug() << "WindowManager::refreshMeetings()";
-       iWeeklyView->refreshMeetings( aMeetings );
+       this->setWindowState( Qt::WindowFullScreen );
+       // Resize event handles the rest.
 }
index 2267525..2f46050 100644 (file)
-#ifndef WINDOWMANAGER_H_
-#define WINDOWMANAGER_H_
-
-#include <QObject>
-#include <QTime>
-#include "Room.h"
-#include "Meeting.h"
-#include "PasswordDialog.h"
-#include "DeviceManager.h"
-
-class QTimer;
-class RoomStatusIndicatorWidget;
-class WeeklyViewWidget;
-class Engine;
-class MeetingInfoDialog;
-class SettingsView;
-class ProgressBar;
-class Configuration;
-
-//! UserInterface class. Behaves as a proxy between the user interface and application's business logic.
-/*!
- * UserInterface class. Controls the whole user interface, starting with displaying the appropriate
- * views. It behaves as a proxy between the user interface and application's business logic, it connects
- * the specified components together and forwards the data to the correct place. It also manages the correct
- * appearance of current views on the screen.
- */
-class WindowManager : public QObject
-{
-       Q_OBJECT
-
-public:
-       //! Constructor.
-       /*!
-        * Constructor of WindowManager.
-        * \param aConfiguration The pointer to configuration.
-        */
-       WindowManager( Configuration *aConfiguration );
-       //! Destructor.
-       virtual ~WindowManager();
-       /*!
-        * Displays an error message
-        * \param aErrorMessage Message to be displayd
-        */
-       void error( const QString &aErrorMessage );
-       //! Updates the rooms status.
-       /*! 
-        * Forwards the signal of changed status to current view.
-        * \param aRoom Room which status is changed.
-        * \param aStatus Current status of room.
-        * \param aTime Time when status is changed.
-        */
-       void roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime );
-       //! Shows the password dialog.
-       /*!
-        * Shows the password dialog.
-        * \param aAdminPassword The correct password.
-        * \param aMessage The message to be shown in the password dialog.
-        */
-       void showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage );
-       //! Closes the password dialog.
-       /*!
-        * Closes the password dialog.
-        */
-       void closePasswordDialog();
-       //! Displays the weekly view.
-       /*!
-        * Displays the weekly view.
-        */
-       void showWeeklyView();
-       //! Displays the meeting info dialog.
-       /*!
-        * Displays the meeting info dialog. 
-        * \param aMeeting Meeting to be displayd
-        */
-       void showMeetingInfo( Meeting *aMeeting );
-       //! Returns the pointer to the weekly view. 
-       /*!
-        * Returns the pointer to the weekly view.
-        */
-       WeeklyViewWidget * weeklyView();
-       //! Switches the views to full screen.
-       /*!
-        * Switches the views to full screen.
-        */
-       void fullScreen();
-       //! Shows the progress bar.
-       /*!
-        * Starts showing the progress bar.
-        * \param aText The text to be shown in progress bar.
-        *  \param aCancellable Is the Cancel button visible. By default not visible.
-        */
-       void showProgressBar( const QString &aText, bool aCancellable = false );
-       //! Closes the progress bar.
-       /*!
-        * Closes the progress bar.
-        */
-       void closeProgressBar();
-       //! Sends the refresh command to weekly view widget.
-       /*!
-        * Sends the refresh command to weekly view widget.
-        * \param aMeetings The list of meetings.
-        */
-       void refreshMeetings( const QList<Meeting*> &aMeetings );
-       
-signals:
-       //! Request current status of the room.
-       /*!
-        * Signal is emitted when there is need to check current status of room aRoom.
-        * \param aRoom Meetingroom which status is requested.
-        */
-       void roomStatusInfoNeeded( Room *aRoom );
-       //! Indicate that some user event has happened.
-       /*!
-        * Signal is emitted if some user event has happened.
-        */
-       void observedEventDetected();
-       //! Meeting activated.
-       /*!
-        * Signal is emitted when a meeting is clicked by the user.
-        * \param aMeeting actived meeting.
-        */
-       void meetingActivated( Meeting *aMeeting );
-       //! Signals if the shown week has been changed.
-       /*!
-        * Signal. Emitted if the shown week has been changed.
-        * \param aDate The first date of the shown week.
-        */
-       void shownWeekChanged( QDate aDate );
-       //! Signals change of the meeting room.
-       /*!
-        * Signal is emitted when meeting room is changed.
-        * \param aRoom Selected meeting room.
-        */
-       void currentRoomChanged( Room *aRoom );
-       //! Signals when the password dialog buttons are clicked.
-       /*!
-        * Signal is emitted when the password dialog buttons are clicked.
-        * \param aPasswordStatus The status of the password.
-        */
-       void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
-       //! Signals when the cancel button in the progress bar is clicked.
-       /*!
-        * Signal is emitted when the cancel button in the progress bar is clicked.
-        */
-       void progressBarCancelled();
-       
-public slots:
-       //! Slot for displaying the screensaver (room status view).
-       /*!
-        * Slot. Displays the screensaver.
-        */
-       void showRoomStatus();
-       //! Slot for updating the time.
-       /*!
-        * Slot. Forwards the signal of changed time to current view.
-        * \param aCurrentDateTime Current date and time.
-        */
-       void distributeDateTimeInfo( QDateTime aCurrentDateTime );
-       
-       void updateProgressBar( const QString &aMessage );
-       
-private slots:
-       //! Displays the settings view
-       void showSettingsView();
-
-private:
-       //! Name of the application.
-       QString iApplicationName;
-       //! Defines whether the views should be shown as full screen 
-       bool iFullScreen;
-       //! Pointer to the configuration.
-       Configuration *iConfiguration;
-       //! Pointer to the weekly view.
-       WeeklyViewWidget *iWeeklyView;
-       //! Pointer to the screensaver (room status view).
-       RoomStatusIndicatorWidget *iRoomStatusView;
-       //! Pointer to the meeting info dialog
-       MeetingInfoDialog *iMeetingInfo;
-       //! Pointer to the settings view
-       SettingsView *iSettingsView;
-       //! Pointer to the progress bar
-       ProgressBar *iProgressBar;
-       //! Pointer to the password dialog.
-       PasswordDialog *iPasswordDialog;
-
-};
-
-#endif /*WINDOWMANAGER_H_*/
+#ifndef WINDOWMANAGER_H_\r
+#define WINDOWMANAGER_H_\r
+\r
+#include <QWidget>\r
+#include <QStack>\r
+\r
+// Forward declarations\r
+class ViewBase;\r
+class QEvent;\r
+class QSize;\r
+class QDialog;\r
+class QString;\r
+\r
+//! UserInterface class. Manages displayed views.\r
+/*!\r
+ * UserInterface class. WindowManager class is responsible for displaying views that inherit the\r
+ * ViewBase class. It also handles dialog showing. Depending on the views type the WindowManager\r
+ * can track the views events and restore previous view if the current on is ObservedView. This\r
+ * is a handy mechanism for screensaver etc.\r
+ */\r
+class WindowManager : public QWidget\r
+{\r
+       Q_OBJECT\r
+\r
+public:\r
+       //! Constructor.\r
+       /*!\r
+        * Constructor of WindowManager.\r
+        */\r
+       WindowManager( QWidget *aParent = 0 );\r
+       //! Destructor.\r
+       virtual ~WindowManager();\r
+       \r
+       virtual bool event(QEvent *event);\r
+\r
+signals:\r
+       //! Request current status of the room.\r
+       /*!\r
+        * Signal is emitted when there is need to check current status of room aRoom.\r
+        * \param aRoom Meetingroom which status is requested.\r
+        */\r
+       void eventDetected();\r
+       \r
+       //! The view size is changed.\r
+       /*!\r
+        * This signal is emitted when the window managers view changes,\r
+        * i.e. it received resized QEvent.\r
+        * \param The new view size.\r
+        */\r
+       void viewResized(const QSize &newSize, const QSize &oldSize);\r
+       \r
+       //! Previous view is restored.\r
+       /*!\r
+        * This signal is emitted when previously stored view is\r
+        * restored. This happens when view with type ViewMode::ObservedView\r
+        * is shown and it receives an event that initiates the view\r
+        * restoring chain.\r
+        */\r
+       void previousViewRestored();\r
+       \r
+       void dialogActivated();\r
+       void dialogDeactivated();\r
+\r
+public slots:\r
+       //! Shows the view.\r
+       /*!\r
+        * Show view that inherits ViewBase class. If the views parent is not\r
+        * the WindowManager it will changed within this method. Depeding on the\r
+        * views type the currently active view might be stored and restored\r
+        * when specific event occurs in the view to be displayed.\r
+        */\r
+       void showView( ViewBase *view );\r
+       \r
+       //! Shows modal dialog.\r
+       /*!\r
+        * Shows modal dialog. Emits dialogActivated() signal prior calling\r
+        * QDialog's exec() method and emits dialogDeactivated signal when\r
+        * the exec() method returns.\r
+        */\r
+       void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true );\r
+       \r
+       //! View event is detected.\r
+       /*!\r
+        * WindowManager connects this slot to ViewBase classes eventDetected()\r
+        * signal and either emits eventDetected() signal if the current views\r
+        * type is ViewMode::NormalView or restores possible previous view\r
+        * if the current views type is ViewMode::ObservedView.\r
+        */\r
+       void viewEventDetected();\r
+       \r
+       void setFullscreen();\r
+       \r
+       void error( const QString &aErrorMessage );\r
+\r
+private:\r
+       //! Name of the application.\r
+       QString iApplicationName;\r
+       \r
+       //! Currently active view.\r
+       ViewBase *iCurrentView;\r
+       \r
+       //! Stack of views previously displayed.\r
+       QStack<ViewBase *> iViewList;\r
+\r
+};\r
+\r
+#endif /*WINDOWMANAGER_H_*/\r