drmfile.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
  3. * All rights reserved.
  4. *
  5. * For the applicable distribution terms see the license.txt -file, included in
  6. * the distribution.
  7. */
  8. #ifndef DRMFILE_H
  9. #define DRMFILE_H
  10. #include <QObject>
  11. class DRMFilePrivate;
  12. /**
  13. * @class DRMFile class
  14. *
  15. * @brief Utility API intended to demonstrate and facilitate access to DRM protected
  16. * content.
  17. *
  18. * The API has two private implementations, one Symbian specific - using the
  19. * Content Access Framework (CAF) API - and an empty one which enables the API
  20. * to be used (more like compiled) in the simulator
  21. */
  22. class DRMFile : public QObject
  23. {
  24. Q_OBJECT
  25. Q_DECLARE_PRIVATE(DRMFile)
  26. public:
  27. /**
  28. * @brief Constructor
  29. *
  30. * @param parent
  31. */
  32. explicit DRMFile(QObject *parent = 0);
  33. /**
  34. * @brief Destructor
  35. *
  36. */
  37. virtual ~DRMFile();
  38. public:
  39. /**
  40. * @brief Read only open method for the specified file
  41. *
  42. * const QString & name - fully cualified file name and path.
  43. *
  44. * Will return a negative error code if the file opening fails. The error
  45. * code should be checked with *isDRMError* in order to understand
  46. *
  47. * @param name
  48. */
  49. int open(const QString & name);
  50. /**
  51. * @brief Read max of *length* bytes into the provided *data* buffer
  52. *
  53. * Will return a negative error code or the length of the read data.
  54. *
  55. * if length is not given or equal to '0' it will allocate memory buffer to contain the whole data
  56. * client must release allocated memory passed by reference pointer 'data'
  57. *
  58. * @param data
  59. * @param length
  60. */
  61. int read(uchar*& data, int length = 0);
  62. /**
  63. * @brief Close the file.
  64. *
  65. */
  66. void close();
  67. /**
  68. * @brief Returns a 32b value size of the amount of available (uncompressed) data.
  69. *
  70. */
  71. int size();
  72. #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  73. /**
  74. * @brief Returns a 64b value size of the amount of available (uncompressed) data.
  75. * Only supported starting with Symbian^3
  76. */
  77. qint64 size64();
  78. #endif
  79. /**
  80. * @brief Returns true if the error code returned by the *open* method is a DRM
  81. * specific error
  82. *
  83. * @param error
  84. */
  85. static bool isDRMError(int error);
  86. protected:
  87. /**
  88. * @variable Private implementation of the API
  89. */
  90. DRMFilePrivate* const d_ptr;
  91. };
  92. #endif // DRMFILE_H