drmfile.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 Allocates memory buffer and reads the whole file content into
  52. * that. Allocated buffer is returned to client via reference pointer 'data'
  53. * parameter. Client is responcible for allocated memory release
  54. *
  55. * Will return a negative error code or the read data length.
  56. *
  57. * @param data
  58. */
  59. int read(uchar*& data);
  60. /**
  61. * @brief Close the file.
  62. *
  63. */
  64. void close();
  65. /**
  66. * @brief Returns a 32b value size of the amount of available (uncompressed) data.
  67. *
  68. */
  69. int size();
  70. #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  71. /**
  72. * @brief Returns a 64b value size of the amount of available (uncompressed) data.
  73. * Only supported starting with Symbian^3
  74. */
  75. qint64 size64();
  76. #endif
  77. /**
  78. * @brief Returns true if the error code returned by the *open* method is a DRM
  79. * specific error
  80. *
  81. * @param error
  82. */
  83. static bool isDRMError(int error);
  84. protected:
  85. /**
  86. * @variable Private implementation of the API
  87. */
  88. DRMFilePrivate* const d_ptr;
  89. };
  90. #endif // DRMFILE_H