diff -r 5de72ea7a065 -r 579cc610882e alarmui/alarmalertwidget/alarmalertinterface/src/alarmalertwidget.cpp --- a/alarmui/alarmalertwidget/alarmalertinterface/src/alarmalertwidget.cpp Wed Jun 23 18:11:28 2010 +0300 +++ b/alarmui/alarmalertwidget/alarmalertinterface/src/alarmalertwidget.cpp Tue Jul 06 14:14:56 2010 +0300 @@ -11,21 +11,22 @@ * * Contributors: * -* Description: +* Description: * */ // alarmalertwidget.cpp // System includes -#include -#include -#include +#include // User includes #include "alarmalertwidget.h" #include "alarmalert.h" #include "alarmalertobserver.h" +// Constants. +const TInt KMaxlength=30; + // --------------------------------------------------------- // AlarmAlertWidget::AlarmAlertWidget // rest of the details are commented in the header @@ -34,11 +35,6 @@ AlarmAlertWidget::AlarmAlertWidget(AlarmAlertObserver *observer) : mObserver(observer) { - // Create a session with the device dialog server - mDeviceDialog = new HbDeviceDialog(HbDeviceDialog::NoFlags, this); - - // Connect to signals to receive events sent by the dialog - connect(mDeviceDialog, SIGNAL(dataReceived(QVariantMap)), this, SLOT(triggerAction(QVariantMap))); } // --------------------------------------------------------- @@ -48,10 +44,47 @@ // AlarmAlertWidget::~AlarmAlertWidget() { - // Cleanup - if (mDeviceDialog) { - delete mDeviceDialog; - } + // Cleanup + + if (mAlarmSubject) { + delete mAlarmSubject; + } + + if (mLocation) { + delete mLocation; + } + + if (mAlarmTime) { + delete mAlarmTime; + } + + if (mAlarmDate) { + delete mAlarmDate; + } + + if (mAlarmAlertType) { + delete mAlarmAlertType; + } + + if (mCanSnooze) { + delete mCanSnooze; + } + + if (mIsSilent) { + delete mIsSilent; + } + + if (mIsTimedAlarm) { + delete mIsTimedAlarm; + } + + if (mVariantMap) { + delete mVariantMap; + } + + if (mDeviceDialog) { + delete mDeviceDialog; + } } // --------------------------------------------------------- @@ -61,40 +94,77 @@ // bool AlarmAlertWidget::showAlarmDialog(SAlarmInfo *alarmInfo) { - // Get the subject of the alarm (description for clock alarms - // and subject for calendar alarms) - mSubject = QString::fromUtf16(alarmInfo->iSubject->Ptr(), - alarmInfo->iSubject->Length()); + // Get the alarm date and time + TBuf timeString; + TBuf dateString; + + TBuf timeFormat(_L("%-B%:0%J%:1%T%:3%+B")); + TBuf dateFormat; + TLocale locale; + switch (locale.DateFormat()) { + case EDateEuropean: + dateFormat.Copy(_L("%F%/0%D%/1%M%/2%Y%/3")); + break; + case EDateAmerican: + dateFormat.Copy(_L("%F%/0%M%/1%D%/2%Y%/3")); + break; + case EDateJapanese: + dateFormat.Copy(_L("%F%/0%Y%/1%M%/2%D%/3")); + break; + default: + // Nothing yet. + break; + } + - // Get the location (for calendar alarms) - mLocation = QString::fromUtf16(alarmInfo->iLocation->Ptr(), - alarmInfo->iLocation->Length()); + alarmInfo->iTime.FormatL(timeString, timeFormat); + alarmInfo->iTime.FormatL(dateString, dateFormat); + + // Create a session with the device dialog server + mDeviceDialog = CHbDeviceDialogSymbian::NewL(); - // Get the alarm date and time - // TODO: Check QDateTime to TTime compatibility - mAlarmTime.setTime(QTime(alarmInfo->iTime.DateTime().Hour(), - alarmInfo->iTime.DateTime().Minute(), - alarmInfo->iTime.DateTime().Second())); - mAlarmTime.setDate(QDate(alarmInfo->iDate.DateTime().Year(), - alarmInfo->iDate.DateTime().Month(), - alarmInfo->iDate.DateTime().Day())); + + // Package the different parameters to send + mVariantMap = CHbSymbianVariantMap::NewL(); + + // Get the subject of the alarm (description for clock alarms + // and subject for calendar alarms) + mAlarmSubject = CHbSymbianVariant::NewL( + alarmInfo->iSubject, CHbSymbianVariant::EDes ); + mVariantMap->Add(alarmSubjectSymbian, mAlarmSubject); + + // Get the location (for calendar alarms) + mLocation = CHbSymbianVariant::NewL( + alarmInfo->iLocation, CHbSymbianVariant::EDes); + mVariantMap->Add(alarmLocationSymbian, mLocation); + + mAlarmTime = CHbSymbianVariant::NewL( + &timeString, CHbSymbianVariant::EDes); + mVariantMap->Add(alarmTimeSymbian, mAlarmTime); - mCanSnooze = alarmInfo->iCanSnooze; - mIsSilent = alarmInfo->iIsSilent; - mAlarmAlertType = alarmInfo->iAlarmAlertType; - mIsTimedAlarm = alarmInfo->iIsTimed; + mAlarmDate = CHbSymbianVariant::NewL( + &dateString, CHbSymbianVariant::EDes); + mVariantMap->Add(alarmDateSymbian, mAlarmDate); + + mIsSilent = CHbSymbianVariant::NewL( + &alarmInfo->iIsSilent, CHbSymbianVariant::EBool); + mVariantMap->Add(alarmRingingTypeSymbian, mIsSilent); + + mCanSnooze = CHbSymbianVariant::NewL( + &alarmInfo->iCanSnooze, CHbSymbianVariant::EBool); + mVariantMap->Add(alarmCanSnoozeSymbain, mCanSnooze); + + mAlarmAlertType = CHbSymbianVariant::NewL( + &alarmInfo->iAlarmAlertType, CHbSymbianVariant::EInt); + mVariantMap->Add(alarmTypeSymbian, mAlarmAlertType); + + mIsTimedAlarm = CHbSymbianVariant::NewL( + &alarmInfo->iIsTimed, CHbSymbianVariant::EBool); + mVariantMap->Add(alarmIsTimedSymbian, mIsTimedAlarm); + + // Package the different parameters to send + return mDeviceDialog->Show(ALARM_ALERT_PLUGIN_SYMBIAN, *mVariantMap, this); - // Package the different parameters to send - QVariantMap params; - params.insert(alarmSubject, mSubject); - params.insert(alarmLocation, mLocation); - params.insert(alarmDateTime, mAlarmTime); - params.insert(alarmRingingType, mIsSilent); - params.insert(alarmCanSnooze, mCanSnooze); - params.insert(alarmType, mAlarmAlertType); - params.insert(alarmIsTimed, mIsTimedAlarm); - - return mDeviceDialog->show(ALARM_ALERT_PLUGIN, params); } // --------------------------------------------------------- @@ -102,10 +172,10 @@ // rest of the details are commented in the header // --------------------------------------------------------- // -bool AlarmAlertWidget::dismissAlarmDialog() +void AlarmAlertWidget::dismissAlarmDialog() { // Dismiss the dialog - return mDeviceDialog->cancel(); + mDeviceDialog->Cancel(); } // --------------------------------------------------------- @@ -113,13 +183,37 @@ // rest of the details are commented in the header // --------------------------------------------------------- // -bool AlarmAlertWidget::updateAlarmDialog(SAlarmInfo* alarmInfo) +bool AlarmAlertWidget::updateAlarmDialog(SAlarmInfo* /*alarmInfo*/) { - Q_UNUSED(alarmInfo); // Update the dialog with any new information // TODO: Pass the updated information sent by the observer - QVariantMap params; - return mDeviceDialog->update(params); + /*CHbSymbianVariantMap params; + mDeviceDialog->Update(params);*/ + return false; +} + +// --------------------------------------------------------- +// AlarmAlertWidget::DataReceived +// rest of the details are commented in the header +// --------------------------------------------------------- +// +void AlarmAlertWidget::DataReceived(CHbSymbianVariantMap& aData) +{ + if (!aData.Keys().MdcaCount()) { + return; + } + + triggerAction(aData.Get(alarmCommandSymbian)); +} + +// --------------------------------------------------------- +// AlarmAlertWidget::DeviceDialogClosed +// rest of the details are commented in the header +// --------------------------------------------------------- +// +void AlarmAlertWidget::DeviceDialogClosed(TInt /*aCompletionCode*/) +{ + } // --------------------------------------------------------- @@ -127,33 +221,28 @@ // rest of the details are commented in the header // --------------------------------------------------------- // -void AlarmAlertWidget::triggerAction(QVariantMap params) +void AlarmAlertWidget::triggerAction(const CHbSymbianVariant* source) { - // Check what is the command being sent by the dialog - // Based on that, update the command to be sent - QVariantMap::const_iterator iter = params.find(alarmCommand); - if (iter != params.constEnd()) { - AlarmCommand command(AlarmCmdLast); - if (iter.value().toInt() == Stop) { - command = AlarmStop; - } - else if (iter.value().toInt() == Snooze) { - command = AlarmSnooze; - } - else if (iter.value().toInt() == Silence) { - command = AlarmSilence; - } else if (iter.value().toInt() == Shown) { - command = AlarmShown; - mObserver->alertDisplayed(command); - return; - } else { - command = AlarmCmdLast; - } - if (command != AlarmCmdLast) { - // Notify the observer with the command - mObserver->alertCompleted(command); - } - - } + AlarmCommand command(AlarmCmdLast); + + if (*source->Value() == Stop) { + command = AlarmStop; + } else if (*source->Value() == Snooze) { + command = AlarmSnooze; + } else if (*source->Value() == Silence) { + command = AlarmSilence; + } else if (*source->Value() == Shown) { + command = AlarmShown; + mObserver->alertDisplayed(command); + return; + } else { + command = AlarmCmdLast; + } + + if (command != AlarmCmdLast) { + // Notify the observer with the command + mObserver->alertCompleted(command); + } } + // End of file --Don't remove this.