alarmserver.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation
  6. **
  7. **
  8. ** $QT_BEGIN_LICENSE:BSD$
  9. ** You may use this file under the terms of the BSD license as follows:
  10. **
  11. ** "Redistribution and use in source and binary forms, with or without
  12. ** modification, are permitted provided that the following conditions are
  13. ** met:
  14. ** * Redistributions of source code must retain the above copyright
  15. ** notice, this list of conditions and the following disclaimer.
  16. ** * Redistributions in binary form must reproduce the above copyright
  17. ** notice, this list of conditions and the following disclaimer in
  18. ** the documentation and/or other materials provided with the
  19. ** distribution.
  20. ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
  21. ** the names of its contributors may be used to endorse or promote
  22. ** products derived from this software without specific prior written
  23. ** permission.
  24. **
  25. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #include <QDateTime>
  40. #include <QMessageBox>
  41. #include "alarmserver.h"
  42. // Conditional compilation for the target platform.
  43. #ifdef Q_OS_SYMBIAN
  44. #include "alarmserver_symbian.h" // Symbian definition of private implementation class.
  45. #else
  46. #include "alarmserver_stub.h" // Stub class for all other platforms.
  47. #endif
  48. /*!
  49. * Constructor.
  50. */
  51. AlarmServerEx::AlarmServerEx(QObject *parent) : QObject(parent)
  52. {
  53. #ifdef Q_OS_SYMBIAN
  54. // Symbian private class implementation.
  55. // This code can generate a Symbian Leave.
  56. // If it does, convert it into a throw.
  57. QT_TRAP_THROWING(d_ptr = AlarmServerExPrivate::NewL(this));
  58. #else
  59. // Stub class implementation
  60. d_ptr = new AlarmServerExPrivate(this);
  61. #endif
  62. }
  63. /*!
  64. * Destructor - this public object owns the private implementation.
  65. */
  66. AlarmServerEx::~AlarmServerEx()
  67. {
  68. delete d_ptr;
  69. }
  70. /*!
  71. * Public slot - adds a fixed alarm.
  72. */
  73. void AlarmServerEx::addFixedAlarm()
  74. {
  75. QMessageBox *msg = new QMessageBox;
  76. msg->setText("Added fixed alarm. \n"
  77. "It will expire in 10 seconds");
  78. msg->show();
  79. d_ptr->AddFixedAlarm();
  80. }
  81. /*!
  82. * Public slot - adds a floating alarm.
  83. */
  84. void AlarmServerEx::addFloatingAlarm()
  85. {
  86. QMessageBox *msg = new QMessageBox;
  87. msg->setText("Added floating alarm. \n"
  88. "It will expire in 10 seconds");
  89. msg->show();
  90. d_ptr->AddFloatingAlarm();
  91. }
  92. /*!
  93. * Get current time of the sytem.
  94. */
  95. QString AlarmServerEx::getCurrentTime()
  96. {
  97. QTime time = QTime::currentTime();
  98. return(time.toString());
  99. }
  100. /*!
  101. * Get current date of the system.
  102. */
  103. QString AlarmServerEx::getCurrentDate()
  104. {
  105. QDate date = QDate::currentDate();
  106. return(date.toString());
  107. }
  108. /*!
  109. * Get the alarm details.
  110. */
  111. QString AlarmServerEx::getAlarmDetails(QString alarmId)
  112. {
  113. QString alarmDetails = d_ptr->GetAlarmDetails(alarmId);
  114. return alarmDetails;
  115. }