nfcsettings_symbian_p.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
  3. * All rights reserved.
  4. * This component and the accompanying materials are made available
  5. * under the terms of "Eclipse Public License v1.0"
  6. * which accompanies this distribution, and is available
  7. * at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. *
  9. * Initial Contributors:
  10. * Nokia Corporation - initial contribution.
  11. *
  12. * Contributors:
  13. *
  14. * Description: Part of Qt NFC Setting sample application.
  15. */
  16. /*!
  17. * \file
  18. * \brief Declaration of the Symbian NfcSettingsPrivate class.
  19. *
  20. * This file contains the declaration of the NfcSettingsPrivate class for
  21. * Symbian platforms.
  22. */
  23. #ifndef NFCSETTINGS_SYMBIAN_P_H
  24. #define NFCSETTINGS_SYMBIAN_P_H
  25. #include <e32base.h>
  26. #include <qglobal.h>
  27. #include "nfcsettings.h"
  28. class CRepository;
  29. /*!
  30. * \brief The Symbian private implementation class for the NFC mode setting.
  31. *
  32. * This implementation class is used on Symbian platforms. The accessor methods
  33. * nfcMode() and nfcError() of this class are fully implemented and report
  34. * whether NFC is supported by the device and if so, what the current value of
  35. * the NFC mode setting is.
  36. *
  37. * On Symbian platforms the NFC mode setting is stored in the Central
  38. * Repository. NfcSettingsPrivate monitors changes to the NFC mode setting by
  39. * requesting to be notified whenever the value of the relevant Central
  40. * Repository key is modified. Changes to the setting are communicated to
  41. * clients of the public API class corresponding to this private implementation
  42. * by emitting its NfcSettings::nfcModeChanged() signal.
  43. *
  44. * \note This class is part of the private implementation design pattern, and as
  45. * such it is an internal implementation detail of the NfcSettings class. The
  46. * class NfcSettingsPrivate is documented here for completeness' sake, but must
  47. * not be used directly - all code using the NFC settings API should use the
  48. * public class NfcSettings instead.
  49. *
  50. * \see NfcSettings
  51. */
  52. class NfcSettingsPrivate : public CActive
  53. {
  54. public:
  55. /*!
  56. * \brief C++ constructor.
  57. *
  58. * Constructs a new NfcSettingsPrivate instance. This class is
  59. * automatically instantiated by the public class NfcSettings as a part of
  60. * its own construction. No other instances of this class should be created.
  61. *
  62. * \param q Pointer to the public class instance that owns this private
  63. * instance. Ownership of the instance is not transferred.
  64. */
  65. explicit NfcSettingsPrivate( NfcSettings *q );
  66. /*!
  67. * \brief C++ destructor.
  68. *
  69. * Releases any resources allocated by this NfcSettingsPrivate instance.
  70. */
  71. virtual ~NfcSettingsPrivate();
  72. /*!
  73. * \brief Returns the current level of NFC feature support provided by the
  74. * device.
  75. *
  76. * Called by the public class when NfcSettings::nfcFeature() is called.
  77. *
  78. * \return The current level of NFC feature support of the device.
  79. * \see NfcSettings::NfcFeature, NfcSettings::nfcMode()
  80. */
  81. NfcSettings::NfcFeature nfcFeature() const;
  82. /*!
  83. * \brief Returns the current value of the NFC mode setting.
  84. *
  85. * Called by the public class when NfcSettings::nfcMode() is called.
  86. *
  87. * \return The current NFC mode setting value. If any errors have occurred,
  88. * this function always return NfcSettings::NfcModeUnknown.
  89. * \see NfcSettings::NfcMode, NfcSettings::nfcMode(),
  90. * NfcSettings::nfcModeChanged()
  91. */
  92. NfcSettings::NfcMode nfcMode() const;
  93. /*!
  94. * \brief Returns the error reason for the latest error that has occurred.
  95. *
  96. * Called by the public class when NfcSettings::nfcError() is called.
  97. *
  98. * \return The latest NFC error reason.
  99. * \see NfcSettings::NfcError, NfcSettings::nfcError(),
  100. * NfcSettings::nfcErrorOccurred()
  101. */
  102. NfcSettings::NfcError nfcError() const;
  103. /*!
  104. * \brief Resets this NfcSettings instance back to its initial state by
  105. * attempting to redetermine the availability of NFC hardware and retrieving
  106. * the NFC mode value.
  107. *
  108. * This function re-initializes this NfcSettings instance by verifying the
  109. * presence of NFC hardware and the Central Repository containing the mode
  110. * setting. If the Symbian Feature Manager reports that the device supports
  111. * NFC, the Central Repository containing the mode setting is opened and a
  112. * subscription is made to get notifications of changes to the mode setting.
  113. * The initial value of the mode setting is also retrieved.
  114. *
  115. * If the initialization cannot be successfully completed, the error is
  116. * reported to clients of the public class by emitting the
  117. * NfcSettings::nfcErrorOccurred() signal.
  118. */
  119. void reset();
  120. protected:
  121. /*!
  122. * \brief From the base class <code>CActive</code>, cancels any pending
  123. * Central Repository notification requests.
  124. *
  125. * This function is called when <code>CActive::Cancel()</code> is called if
  126. * this active object is currently active. DoCancel() must not be called
  127. * manually.
  128. */
  129. virtual void DoCancel();
  130. /*!
  131. * \brief From the base class <code>CActive</code>, handles completed
  132. * Central Repository notification requests.
  133. *
  134. * This function gets called whenever a Central Repository notification
  135. * request is completed, i.e. when the value of the NFC mode setting changes.
  136. * The new value of the setting is retrieved and the public class is
  137. * notified by emitting its NfcSettings::nfcModeChanged() signal.
  138. *
  139. * Prior to notifying the public class, a new notification request is made,
  140. * and NfcSettingsPrivate continues to wait for further mode setting
  141. * changes.
  142. */
  143. virtual void RunL();
  144. /*!
  145. * \brief From the base class <code>CActive</code>, handles Symbian leaves
  146. * that occur in RunL().
  147. *
  148. * This function is called if some code in RunL() causes a Symbian leave.
  149. * This happens if the Central Repository notification request is completed,
  150. * but the request status object indicates an error.
  151. *
  152. * All leaves are handled by notifying the clients of the public class by
  153. * emitting its NfcSettings::nfcErrorOccurred() signal with the NFC error
  154. * NfcSettings::NfcErrorModeChangeNotification and the platform specific
  155. * error code \a aError.
  156. *
  157. * \param aError The leave code generated by a leave that occurred in RunL().
  158. * \return Always return <code>KErrNone</code> to indicate that the leave
  159. * was successfully handled.
  160. */
  161. virtual TInt RunError( TInt aError );
  162. private:
  163. /*!
  164. * \brief Verifies the presence of NFC hardware and the Central Repository
  165. * containing the mode setting.
  166. *
  167. * If the Symbian Feature Manager reports that the device supports NFC,
  168. * the Central Repository containing the mode setting is opened and a
  169. * subscription is made to get notifications of changes to the mode setting.
  170. *
  171. * If the initialization cannot be successfully completed, either an
  172. * NfcSettings::NfcErrorFeatureSupportQuery or
  173. * NfcSettings::NfcErrorSoftwareVersionQuery error is reported to the public
  174. * class.
  175. */
  176. void InitializeNfcFeatureSupport();
  177. /*!
  178. * \brief Requests the Central Repository to notify this class of changes
  179. * made to the NFC mode setting.
  180. *
  181. * If the notification request cannot be successfully completed, the error
  182. * NfcSettings::NfcErrorModeChangeNotificationRequest is reported to the
  183. * public class.
  184. */
  185. void NotifyRequest();
  186. /*!
  187. * \brief Reads the current value of the NFC mode setting from the Central
  188. * Repository.
  189. *
  190. * The Symbian specific NFC mode setting value is mapped to a value of the
  191. * NfcSettings::NfcMode enumeration and stored. The stored value can
  192. * subsequently be obtained by calling nfcMode().
  193. *
  194. * If the value cannot be successfully read, the error
  195. * NfcSettings::NfcErrorModeRetrieval is reported to the public class.
  196. */
  197. void RetrieveSetting();
  198. /*!
  199. * \brief Reports an error in the internal operation of this class to its
  200. * public counterpart.
  201. *
  202. * This is a utility function that stores the NFC error code and notifies
  203. * the public class of the error. The nfcError() function always returns
  204. * the error code of the latest error reported via a call to ReportError().
  205. *
  206. * \param aNfcError The general reason for the error being reported. The
  207. * value of this parameter indicates the stage at which the error took
  208. * place.
  209. * \param aError The Symbian error code relating to the error being
  210. * reported.
  211. */
  212. void ReportError( NfcSettings::NfcError aNfcError, TInt aError );
  213. /*!
  214. * \brief Tests whether the device can be updated to support NFC functionality.
  215. *
  216. * This function tests if the device has NFC hardware, and if so, whether
  217. * the installed firmware version is recent enough to provide support for
  218. * the hardware.
  219. *
  220. * \return ETrue if the device has NFC hardware, but requires a firmware
  221. * update to use it. EFalse otherwise (i.e. the there is no NFC hardware
  222. * or the firmware already supports NFC).
  223. */
  224. TBool ProductSupportsNfcViaFirmwareUpdate();
  225. private:
  226. Q_DISABLE_COPY( NfcSettingsPrivate )
  227. /*! \brief Pointer to the public class instance, not owned. */
  228. NfcSettings *q_ptr;
  229. /*! \brief The level of NFC feature support provided by the device. */
  230. NfcSettings::NfcFeature iNfcFeature;
  231. /*! \brief The current effective NFC mode setting value. */
  232. NfcSettings::NfcMode iNfcMode;
  233. /*! \brief The most recent NFC mode related error reason. */
  234. NfcSettings::NfcError iNfcError;
  235. /*! \brief The Central Repository instance used to read the NFC mode setting value, owned. */
  236. CRepository* iRepository;
  237. };
  238. #endif // NFCSETTINGS_SYMBIAN_P_H