VLCDialogProvider.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*****************************************************************************
  2. * VLCDialogProvider.h: an implementation of the libvlc dialog API
  3. *****************************************************************************
  4. * Copyright (C) 2016 VideoLabs SAS
  5. * $Id$
  6. *
  7. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  22. *****************************************************************************/
  23. @class VLCLibrary;
  24. typedef NS_ENUM(NSUInteger, VLCDialogQuestionType) {
  25. VLCDialogQuestionNormal,
  26. VLCDialogQuestionWarning,
  27. VLCDialogQuestionCritical,
  28. };
  29. @protocol VLCCustomDialogRendererProtocol <NSObject>
  30. /**
  31. * called when VLC wants to show an error
  32. * \param the dialog title
  33. * \param the error message
  34. */
  35. - (void)showErrorWithTitle:(NSString * _Nonnull)error
  36. message:(NSString * _Nonnull)message;
  37. /**
  38. * called when user logs in to something
  39. * If VLC includes a keychain module for your platform, a user can store stuff
  40. * \param login title
  41. * \param an explaining message
  42. * \param a default username within context
  43. * \param indicator whether storing is even a possibility
  44. * \param reference you need to send the results to
  45. */
  46. - (void)showLoginWithTitle:(NSString * _Nonnull)title
  47. message:(NSString * _Nonnull)message
  48. defaultUsername:(NSString * _Nullable)username
  49. askingForStorage:(BOOL)askingForStorage
  50. withReference:(NSValue * _Nonnull)reference;
  51. /**
  52. * called when VLC needs the user to decide something
  53. * \param the dialog title
  54. * \param an explaining message text
  55. * \param a question type
  56. * \param cancel button text
  57. * \param action 1 text
  58. * \param action 2 text
  59. * \param reference you need to send the action to
  60. */
  61. - (void)showQuestionWithTitle:(NSString * _Nonnull)title
  62. message:(NSString * _Nonnull)message
  63. type:(VLCDialogQuestionType)questionType
  64. cancelString:(NSString * _Nullable)cancelString
  65. action1String:(NSString * _Nullable)action1String
  66. action2String:(NSString * _Nullable)action2String
  67. withReference:(NSValue * _Nonnull)reference;
  68. /**
  69. * called when VLC wants to show some progress
  70. * \param the dialog title
  71. * \param an explaining message
  72. * \param indicator whether progress indeterminate
  73. * \param initial progress position
  74. * \param optional string for cancel button if operation is cancellable
  75. * \param reference VLC will include in updates
  76. */
  77. - (void)showProgressWithTitle:(NSString * _Nonnull)title
  78. message:(NSString * _Nonnull)message
  79. isIndeterminate:(BOOL)isIndeterminate
  80. position:(float)position
  81. cancelString:(NSString * _Nullable)cancelString
  82. withReference:(NSValue * _Nonnull)reference;
  83. /** called when VLC wants to update an existing progress dialog
  84. * \param reference to the existing progress dialog
  85. * \param updated message
  86. * \param current position
  87. */
  88. - (void)updateProgressWithReference:(NSValue * _Nonnull)reference
  89. message:(NSString * _Nullable)message
  90. postion:(float)position;
  91. /** VLC decided to destroy a dialog
  92. * \param reference to the dialog to destroy
  93. */
  94. - (void)cancelDialogWithReference:(NSValue * _Nonnull)reference;
  95. @end
  96. @interface VLCDialogProvider : NSObject
  97. /**
  98. * initializer method to run the dialog provider instance on a specific library instance
  99. *
  100. * \param the library instance
  101. * \param enable custom UI mode
  102. * \note if library param is NULL, [VLCLibrary sharedLibrary] will be used
  103. * \return the dialog provider instance, can be NULL on malloc failures
  104. */
  105. - (instancetype _Nullable)initWithLibrary:(VLCLibrary * _Nullable)library
  106. customUI:(BOOL)customUI;
  107. /**
  108. * initializer method to run the dialog provider instance on a specific library instance
  109. *
  110. * \param an object implementing the custom dialog rendering API
  111. * \return the object set
  112. */
  113. @property (weak, readwrite, nonatomic, nullable) id<VLCCustomDialogRendererProtocol> customRenderer;
  114. /**
  115. * if you requested custom UI mode for dialogs, use this method respond to a login dialog
  116. * \param username or NULL if cancelled
  117. * \param password or NULL if cancelled
  118. * \param reference to the dialog you respond to
  119. * \param shall VLC store the login securely?
  120. * \note This method does not have any effect if you don't use custom UI mode */
  121. - (void)postUsername:(NSString * _Nonnull)username
  122. andPassword:(NSString * _Nonnull)password
  123. forDialogReference:(NSValue * _Nonnull)dialogReference
  124. store:(BOOL)store;
  125. /**
  126. * if you requested custom UI mode for dialogs, use this method respond to a question dialog
  127. * \param the button number the user pressed, use 3 if s/he cancelled, otherwise respectively 1 or 2 depending on the selected action
  128. * \param reference to the dialog you respond to
  129. * \note This method does not have any effect if you don't use custom UI mode */
  130. - (void)postAction:(int)buttonNumber
  131. forDialogReference:(NSValue * _Nonnull)dialogReference;
  132. /**
  133. * if you requested custom UI mode for dialogs, use this method to cancel a progress dialog
  134. * \param reference to the dialog you want to cancel
  135. * \note This method does not have any effect if you don't use custom UI mode */
  136. - (void)dismissDialogWithReference:(NSValue * _Nonnull)dialogReference;
  137. @end