fetchMeetings( iClock->datetime(), iClock->datetime().addDays( 7 ), room );
}
-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() )
- ); */
- iCommunication->fetchMeetingDetails( *aMeeting );
-}
-
bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting )
{
qDebug() << "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
{
qDebug() << "Engine::ErrorHandler, aCode: " << aCode;
// inform UI about the problem
- if( aCode >= 100 && aCode <= 150 )
+ if( aCode >= 100 && aCode <= 150 ) { //communication errors
+ //we don't want these to close operation changing
qDebug() << "CommunicationManager signaled an error:" << aCode;
- // iWindowManager->closeProgressBar();
- // iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
+ }
+
+ iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
}
void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
iCommunication->fetchMeetings( aFrom, aUntil, *aIn );
}
+void Engine::fetchMeetingDetails(Meeting *aMeeting)
+{
+ qDebug() << "[Engine::fetchMeetingDetails] <TODO : METHOD NOT IMPLEMENTED>";
+// Meeting tempMeeting = aMeeting;
+// iCommunication->fetchMeetingDetails( tempMeeting );
+}
+
+void Engine::cancelFetchMeetingDetails()
+{
+ 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" );
+ 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::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus )
+void Engine::changeDeviceMode( bool aChange )
{
- qDebug() << "Engine::passwordEntered( PasswordDialog::PasswordStatus )";
-// iWindowManager->closePasswordDialog();
-
- switch ( aPasswordStatus )
+ if ( aChange )
{
- case PasswordDialog::Correct :
- {
- connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( progressBarCancelled() ) );
- iDevice->changeMode( true );
- break;
- }
- case PasswordDialog::Incorrect :
- {
-// iWindowManager->error( tr( "Incorrect password." ) );
- iDevice->changeMode( false );
- break;
- }
- default : //case PasswordDialog::Canceled
- {
- iDevice->changeMode( false );
- }
+ connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) );
+ iAutoRefresh->stop(); // Stop the meeting update
}
+ iDevice->changeMode( aChange );
}
-void Engine::progressBarCancelled()
+void Engine::changeModeFailed()
{
qDebug() << "Engine::progressBarCancelled()";
iDevice->changeMode( false );
+ iAutoRefresh->start(); //we start the metting updating
}
void Engine::initUserInterface()
}
}
-void Engine::fetchMeetingDetailsCancelled()
-{
- iCommunication->cancelFetchMeetingDetails();
-// iWindowManager->closeProgressBar();
-}
-
void Engine::stopIdleTimeCounter()
{
if ( iIdleTimeCounter != 0 )
* room storage and calling the roomStatusInfoNeeded() separately on each of them.
*/
void checkStatusOfAllRooms();
- //! Slot. Fetches meeting details from the server.
+ //! Slot for receiving the failure event of operation mode changing.
/*!
- * Slot. Fetches meeting details from the server.
- * \param aMeeting The meeting.
+ * Slot. Receives the failure event of operation mode changing.
*/
- 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 cancel event of the progress bar.
- /*!
- * Slot. Receives the cancel event of the progress bar.
- */
- void progressBarCancelled();
+ void changeModeFailed();
//! Slot for receiving the cancel event of the progress bar.
/*!
* Receives the cancel event of the progress bar when meeting details requested.
*/
- void fetchMeetingDetailsCancelled();
+ void fetchMeetingDetails( Meeting *aMeeting );
+ void cancelFetchMeetingDetails();
void handleViewEvent();
void previousViewRestored();
void stopIdleTimeCounter();
void startIdleTimeCounter();
+
+ void changeDeviceMode( bool aChange );
private:
// Make the UIManager as friendly class so it can connect to private slots.
#include "WeeklyViewWidget.h"
#include "SettingsView.h"
#include "RoomStatusIndicatorWidget.h"
-#include "PasswordDialog.h"
#include "MeetingInfoDialog.h"
#include "ProgressBar.h"
#include "CommunicationManager.h"
if ( iEngine == 0 ) return;
if ( iWindowManager == 0 ) return;
+ qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
+
createWeeklyView();
createSettingsView();
createRoomStatusIndicator();
createPasswordDialog();
createProgressBar();
createMeetingInfoDialog();
+
+ qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
}
UIManager::~UIManager()
{
iWeeklyView = new WeeklyViewWidget( QDateTime::currentDateTime(), iEngine->iConfiguration );
- // Connect signals
+ // 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 ) ) );
}
void UIManager::createSettingsView()
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") );
- connect( iProgressBar, SIGNAL( cancelled() ), this, SLOT( progressBarCancelled() ) );
- connect( iProgressBar, SIGNAL( cancelled() ), iEngine, SLOT( progressBarCancelled() ) );
+ // 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 & ) ), iProgressBar, SLOT( update( const QString & ) ) );
+ connect( aDeviceManager, SIGNAL( changingMode( const QString & ) ), this, SLOT( updateProgressBarText( const QString & ) ) );
}
void UIManager::connectCommunicationManager( CommunicationManager *aCommunicationManager )
{
- // To communication manager
- connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), aCommunicationManager, SLOT( fetchMeetingDetails( Meeting * ) ) );
-
- // From communication manager
- connect( aCommunicationManager, SIGNAL( meetingsFetched( const QList<Meeting *> ) ), this, SLOT( meetingsFetched( const QList<Meeting *> ) ) );
connect( aCommunicationManager, SIGNAL( meetingDetailsFetched( Meeting & ) ), this, SLOT( meetingDetailsFetched( Meeting & ) ) );
}
}
+void UIManager::showMeetingProgressBar( Meeting *aMeeting )
+{
+ if ( iProgressBar != 0 )
+ {
+ iProgressBar->update( tr("Fetching meeting info...") );
+ iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ) );
+ }
+}
+
void UIManager::meetingDetailsFetched(Meeting &aDetailedMeeting)
{
if ( iMeetingInfo != 0 )
{
+ if ( iProgressBar != 0 )
+ {
+ iProgressBar->close(); // Close it in case it's visible
+ }
iMeetingInfo->setMeeting( &aDetailedMeeting );
iWindowManager->showDialog( static_cast<QDialog *>( iMeetingInfo ) );
}
void UIManager::progressBarCancelled()
{
- // TODO : Close progress bar
+ if ( iProgressBar != 0 )
+ {
+ iProgressBar->close();
+ }
}
void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
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 ) );
+ }
+ // ... 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 );
+ }
+}
#include "Meeting.h"
#include "DeviceManager.h"
+#include "PasswordDialog.h"
class Engine;
class WindowManager;
class WeeklyViewWidget;
class SettingsView;
class RoomStatusIndicatorWidget;
-class PasswordDialog;
class ProgressBar;
class MeetingInfoDialog;
class CommunicationManager;
void currentRoomChanged( Room *aRoom );
void progressBarCancelled();
void updateTime( QDateTime aDateTime );
+ void passwordEntered( PasswordDialog::PasswordStatus aStatus );
+ void showMeetingProgressBar( Meeting *aMeeting );
+ void updateProgressBarText( const QString &aText );
private:
#include <QUrl>
+#include <time.h>
#include "MessagingUtils.h"
#include "Meeting.h"
return MsgErrSomeError;
}
int err = MsgErrNoError;
+
+ time_t rawtime;
+ tm *localTime;
+
+ 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.
+
+#ifdef MU_DEBUG
+ qDebug( "ReqMsgGetUserAvailability::setTimeZone - offset in minutes=%d", offsetMinutes );
+#endif
+
//TODO: timezone and daylight times to application configuration
- setNodeValue( QString( "Bias" ), QString::number( -120 ), QDomNode::ElementNode, QString( "TimeZone" ) );
+ 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" ) );
#define ACTION_URL "http://schemas.microsoft.com/exchange/services/2006/messages/"
//Set MessagingUtils Debug on/off
-//#define MU_DEBUG
-#undef MU_DEBUG
+#define MU_DEBUG
+//#undef MU_DEBUG
class Meeting;
class Room;
}
iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage );
connect( iModeToggler, SIGNAL( finished() ), this, SLOT( modeChanged() ) );
- connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode ) ), this, SLOT( errorSender( DeviceManager::ErrorCode ) ) );
+ connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode, const QString & ) ),
+ this, SLOT( errorSender( DeviceManager::ErrorCode, const QString & ) ) );
connect( iModeToggler, SIGNAL( changingMode( const QString & ) ), this, SIGNAL( changingMode( const QString & ) ) );
connect( iModeToggler, SIGNAL( toggleErrorSending( bool ) ), this, SLOT( toggleErrorSending( bool ) ) );
iModeToggler->start();
void DeviceManager::toggleErrorSending( bool aToggle )
{
+ qDebug() << "DeviceManager::toggleErrorSending( bool )";
iSendErrorMessages = aToggle;
}
void DeviceManager::modeChanged()
{
+ qDebug() << "DeviceManager::modeChanged()";
if( iModeToggler != 0 ) {
if ( iModeToggler->success() ) //mode changing went well
iConfigurator->restartDevice();
else
- emit changingModeFailed();
+ emit changeModeFailed();
delete iModeToggler;
iModeToggler = 0;
}
#include <QObject>
#include <QStringList>
+#include <QMetaType>
class AlarmSender;
class HWKeyListener;
/*!
* Enumeration of errors
*/
+
enum ErrorCode
{
FileCreationFailed, /*!< File couldn't be created. */
/*!
* Signal. Emitted if the operation mode change fails.
*/
- void changingModeFailed();
+ void changeModeFailed();
private slots:
//! Slot. Handles "full screen"-hardware key presses.
};
+Q_DECLARE_METATYPE( DeviceManager::ErrorCode )
+
#endif /*DEVICEMANAGER_H_*/
iSuccess( true )
{
qDebug() << "OperationModeToggler::OperationModeToggler( ... )";
+
+ qRegisterMetaType<DeviceManager::ErrorCode>("DeviceManager::ErrorCode");
+
+ connect( iAlarmSender, SIGNAL( alarmSendingFailed( DeviceManager::ErrorCode, const QString& ) ),
+ this, SIGNAL( error( DeviceManager::ErrorCode, const QString& ) ) );
+ connect( iConfigurator, SIGNAL( configuringError( DeviceManager::ErrorCode ) ),
+ this, SLOT( createError( DeviceManager::ErrorCode ) ) );
+ connect( iDataStorage, SIGNAL( dataStorageInitFailed( DeviceManager::ErrorCode ) ),
+ this, SLOT( createError( DeviceManager::ErrorCode ) ) );
}
OperationModeToggler::~OperationModeToggler()
{
case DeviceManager::EmptyMode:
// error occured. Mode cannot be changed
- emit error( DeviceManager::ModeNotFetched );
+ createError( DeviceManager::ModeNotFetched );
iSuccess = false;
return;
case DeviceManager::StandAloneMode:
emit changingMode( "Storing information about the new operation mode." );
sleep( 2 );
if( !storeOperationMode( DeviceManager::KioskMode, iDataStorage ) ) {
- emit error( DeviceManager::ModeNotStored );
+ createError( DeviceManager::ModeNotStored );
iSuccess = false;
}
}
emit changingMode( "Storing information about the new operation mode." );
sleep( 2 );
if( !storeOperationMode( DeviceManager::StandAloneModeInProgress, iDataStorage ) ) {
- emit error( DeviceManager::ModeNotStored );
+ createError( DeviceManager::ModeNotStored );
iSuccess = false;
}
}
bool OperationModeToggler::success()
{
+ qDebug() << "OperationModeToggler::success()";
return iSuccess;
}
return false;
return true;
}
+
+void OperationModeToggler::createError( DeviceManager::ErrorCode aCode )
+{
+ qDebug() << "OperationModeToggler::createError( DeviceManager::ErrorCode )";
+ QString empty = "";
+ emit error( aCode, empty );
+}
+
static bool storeOperationMode( DeviceManager::OperationMode aMode, DeviceDataStorage *aDataStorage );
signals:
- //! Signal. Emitted if an error occurs during operation mode fetching or reading.
+ //! Signal. Emitted if an error happens.
/*!
- * Signal. Emitted if an error occurs during operation mode fetching or reading. Note that other
- * possible errors are sent by the other instances e.g. alarm sender sents it's own errors.
- * \param aCode The error code.
+ * Signal. Emitted if an error happens.
+ * \param aCode An error code defined by DeviceManager.
+ * \param aAddInfo Possible additional information.
*/
- void error( DeviceManager::ErrorCode aCode );
+ void error( DeviceManager::ErrorCode aCode, const QString &aAddInfo );
//! Signal. Emitted if an error occurs during operation mode changing.
/*!
* Signal. Emitted if an error occurs during operation mode changing. If an error occurs, the operation
* \param aMessage Explains the sub-change
*/
void changingMode( const QString &aMessage );
+
+private slots:
+ //! Slot. Emits an error signal.
+ /*!
+ * Slot. Emits an error signal.
+ * \param aCode The error code.
+ */
+ void createError( DeviceManager::ErrorCode aCode );
private:
DeviceManager::OperationMode iMode;
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;
// Handle component connections
connect( iOkButton, SIGNAL( clicked() ), this, SLOT( handleOkClicked() ) );
- connect( iCancelButton, SIGNAL( clicked() ), this, SLOT( cancelClicked() ) );
}
SettingsView::~SettingsView()
delete iOkButton;
iOkButton = 0;
}
- if ( iCancelButton != 0 )
- {
- delete iCancelButton;
- iCancelButton = 0;
- }
if ( iSettingsTab != 0 )
{
delete iSettingsTab;
// Emit the signal to notify that ok is pressed and data is saved.
emit okClicked();
-
-// close();
-}
-
-void SettingsView::cancelClicked()
-{
- qDebug() << "[SettingsView::cancelClicked] <Invoked>";
- close();
}
void SettingsView::viewResized(const QSize &size)
private slots:
//! Slot to handle the Ok button pressing.
void handleOkClicked();
- //! Slot to handle the cancel button pressing.
- void cancelClicked();
private:
//! Initialize "Settings" tab.
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.
\r
iRoomsCombo = new MeetingRoomCombo( iConfiguration->rooms(), this );\r
iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() );\r
- connect( iRoomsCombo, SIGNAL( currentRoomChange( Room * ) ), this, SIGNAL( currentRoomChange( Room * ) ) );\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
#include <QEvent>
#include <QDialog>
#include "ViewBase.h"
+#include "PopUpMessageBox.h"
#include <QtDebug>
{
qDebug() << "WindowManager::showErrorPopup";
-// PopUpMessageBox::error( 0, aErrorMessage );
+ showDialog( static_cast<QDialog *>( PopUpMessageBox::error( 0, aErrorMessage ) ) );
}
void WindowManager::setFullscreen()