lightappprivate.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. ** Description:
  38. ****************************************************************************/
  39. #include <QDateTime>
  40. #include <QMessageBox>
  41. #include "lightappprivate.h"
  42. #include "lightwrapper.h"
  43. /*!
  44. Constructor for the LightAppPrivate class
  45. first stage constructor.
  46. */
  47. LightAppPrivate* LightAppPrivate::NewL(LightWrapper *aLightWrapperPtr)
  48. {
  49. LightAppPrivate* self = new (ELeave) LightAppPrivate(aLightWrapperPtr);
  50. CleanupStack::PushL(self);
  51. self->ConstructL();
  52. CleanupStack::Pop(self);
  53. return self;
  54. }
  55. /*!
  56. Symbian second stage constructor for the LightAppPrivate class.
  57. */
  58. void LightAppPrivate::ConstructL()
  59. {
  60. iLight = CHWRMLight::NewL(this);
  61. }
  62. /*!
  63. Private constructor - initialise the pointer to the public API class
  64. and make this high priority for scheduling.
  65. */
  66. LightAppPrivate::LightAppPrivate(LightWrapper *aLightWrapperPtr):iLightWrapper(aLightWrapperPtr)
  67. {
  68. }
  69. /*!
  70. Initialize function is used to reserve the initial display and set the
  71. light intensity to default.
  72. */
  73. void LightAppPrivate::Initialize()
  74. {
  75. iLight->ReserveLightL(CHWRMLight::EPrimaryDisplay);
  76. iLight->LightOnL(CHWRMLight::EPrimaryDisplay);
  77. }
  78. /*!
  79. Destructor for LightAppPrivate class.
  80. */
  81. LightAppPrivate::~LightAppPrivate()
  82. {
  83. }
  84. /*!
  85. LightStatusChanged function is called whenever there is a change in status
  86. of device display. This function in turn calls the display function of the wrapper.
  87. */
  88. void LightAppPrivate::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus)
  89. {
  90. if(aTarget == CHWRMLight::EPrimaryDisplay)
  91. switch ( aStatus )
  92. {
  93. case CHWRMLight::ELightOn:
  94. iLightWrapper->display("On");
  95. break;
  96. case CHWRMLight::ELightOff:
  97. iLightWrapper->display("Off");
  98. break;
  99. case CHWRMLight::ELightBlink:
  100. iLightWrapper->display("Blink");
  101. break;
  102. case CHWRMLight::ELightStatusUnknown:
  103. iLightWrapper->display("Unknown");
  104. break;
  105. default:
  106. iLightWrapper->display("Unknown");
  107. break;
  108. }
  109. }
  110. /*!
  111. LighMax function sets the display to maximum intensity.
  112. */
  113. void LightAppPrivate::LightMax()
  114. {
  115. iLight->LightOnL(CHWRMLight::EPrimaryDisplay, 8000, KHWRMLightMaxIntensity, ETrue);
  116. }
  117. /*!
  118. LighOff function sets the display to off state.
  119. */
  120. void LightAppPrivate::LightOff()
  121. {
  122. iLight->LightOffL(CHWRMLight::EPrimaryDisplay, 8000);
  123. }
  124. /*!
  125. LighBlink function sets the display to Blinking state.
  126. */
  127. void LightAppPrivate::LightBlink()
  128. {
  129. iLight->LightBlinkL(CHWRMLight::EPrimaryDisplay,8000);
  130. }
  131. /*!
  132. LighOn function sets the display to default on status.
  133. */
  134. void LightAppPrivate::LightOn()
  135. {
  136. iLight->LightOnL(CHWRMLight::EPrimaryDisplay);
  137. }
  138. /*!
  139. LighMin function sets the display to minimum display plus 5.
  140. */
  141. void LightAppPrivate::LightMin()
  142. {
  143. // KHWRMDefaultIntensity is of value 0 which sets the display with no light intensity,
  144. // therefore a value of 5 is added to show a small light intensity on the display.
  145. iLight->LightOnL(CHWRMLight::EPrimaryDisplay, 8000, KHWRMDefaultIntensity + 5, ETrue);
  146. }