drmfile_p.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_P_H
  9. #define DRMFILE_P_H
  10. #include <qglobal.h>
  11. #include <caf/content.h>
  12. using namespace ContentAccess;
  13. class DRMFile;
  14. /*!
  15. \class DRMFilePrivate
  16. \brief Content Access Framework (CAF) wrapper implementation
  17. */
  18. class DRMFilePrivate
  19. {
  20. public:
  21. /*!
  22. Constructor
  23. */
  24. explicit DRMFilePrivate();
  25. /*!
  26. Destructor
  27. */
  28. virtual ~DRMFilePrivate();
  29. public:
  30. /*!
  31. Opens either DRM encrypted file package or non-protected file
  32. NOTE: Access to unprotected content is unrestricted by CAF thus regular files can
  33. be opened and read successfully
  34. */
  35. int open(const QString & fileName);
  36. /*!
  37. Reads the whole data or requested length into allocated memory buffer.
  38. 'data' - reference to pointer on allocated memory buffer.
  39. It is client's responcibility to release allocated memory
  40. 'length' - requested data length to read, if it is equal to '0' it will read the whole file
  41. 'index' - data item index in the container
  42. */
  43. int read(uchar*& data, int length = 0, int index = 0);
  44. /*!
  45. Closes file or DRM file package
  46. */
  47. void close();
  48. /*!
  49. Returns opened file or DRM file package size
  50. */
  51. int size(int index = 0);
  52. inline int count()
  53. {
  54. return (CAF_data.Count());
  55. }
  56. /*!
  57. Allocates memory for data item name or NULL if error happens
  58. 'index' - data item index in the DRM container
  59. Special cases for the EContentID field
  60. KNullDesC16() - ""
  61. A zero length EContentID is used to refer to the entire file.
  62. If a file is opened this way, no embedded items are visible in the DRM container
  63. */
  64. const ushort* getStringAttr(int index, int& len, TStringAttribute attr = EContentID) const;
  65. private:
  66. /*!
  67. Function helper to 'open' method
  68. */
  69. void openL(const TDesC& fileName);
  70. private:
  71. CContent *CAF_file; // content container
  72. RPointerArray<CData> CAF_data; // content container data array
  73. TBool intentExecuted; //'in-progress' flag
  74. };
  75. #endif // DRMFILE_P_H