drmfile.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include "drmfile.h"
  9. #include "drmfile_p.h"
  10. DRMFile::DRMFile(QObject *parent) :
  11. QObject(parent), d_ptr(new DRMFilePrivate())
  12. {
  13. }
  14. DRMFile::~DRMFile()
  15. {
  16. delete d_ptr;
  17. }
  18. int DRMFile::open(const QString & name)
  19. {
  20. Q_D(DRMFile);
  21. return d_ptr->open(name);
  22. }
  23. int DRMFile::read(uchar*& data, int length, int index)
  24. {
  25. Q_D(DRMFile);
  26. return d_ptr->read(data, length, index);
  27. }
  28. void DRMFile::close()
  29. {
  30. Q_D(DRMFile);
  31. d_ptr->close();
  32. }
  33. int DRMFile::size(int index)
  34. {
  35. Q_D(DRMFile);
  36. return d_ptr->size(index);
  37. }
  38. int DRMFile::count()
  39. {
  40. return d_ptr->count();
  41. }
  42. QString DRMFile::getName(int index)
  43. {
  44. int len = 0;
  45. QString result;
  46. if (const ushort *buf = d_ptr->getStringAttr(index, len)){
  47. result.setUtf16(buf, len); // NOTE: it copies buffer to QString,
  48. // thus it is needed to release allocated memory
  49. delete buf;
  50. }
  51. return result;
  52. }