VLCDialogProvider.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. /**
  30. * the protocol to use if you decide to run a custom dialog appearance
  31. */
  32. @protocol VLCCustomDialogRendererProtocol <NSObject>
  33. /**
  34. * called when VLC wants to show an error
  35. * \param error the dialog title
  36. * \param message the error message
  37. */
  38. - (void)showErrorWithTitle:(NSString * _Nonnull)error
  39. message:(NSString * _Nonnull)message;
  40. /**
  41. * called when user logs in to something
  42. * If VLC includes a keychain module for your platform, a user can store stuff
  43. * \param title login dialog title
  44. * \param message an explaining message
  45. * \param username a default username within context
  46. * \param askingForStorage indicator whether storing is even a possibility
  47. * \param reference you need to send the results to
  48. */
  49. - (void)showLoginWithTitle:(NSString * _Nonnull)title
  50. message:(NSString * _Nonnull)message
  51. defaultUsername:(NSString * _Nullable)username
  52. askingForStorage:(BOOL)askingForStorage
  53. withReference:(NSValue * _Nonnull)reference;
  54. /**
  55. * called when VLC needs the user to decide something
  56. * \param title the dialog title
  57. * \param message an explaining message text
  58. * \param questionType a question type
  59. * \param cancelString cancel button text
  60. * \param action1String action 1 text
  61. * \param action2String action 2 text
  62. * \param reference you need to send the action to
  63. */
  64. - (void)showQuestionWithTitle:(NSString * _Nonnull)title
  65. message:(NSString * _Nonnull)message
  66. type:(VLCDialogQuestionType)questionType
  67. cancelString:(NSString * _Nullable)cancelString
  68. action1String:(NSString * _Nullable)action1String
  69. action2String:(NSString * _Nullable)action2String
  70. withReference:(NSValue * _Nonnull)reference;
  71. /**
  72. * called when VLC wants to show some progress
  73. * \param title the dialog title
  74. * \param message an explaining message
  75. * \param isIndeterminate indicator whether progress indeterminate
  76. * \param position initial progress position
  77. * \param cancelString optional string for cancel button if operation is cancellable
  78. * \param reference VLC will include in updates
  79. */
  80. - (void)showProgressWithTitle:(NSString * _Nonnull)title
  81. message:(NSString * _Nonnull)message
  82. isIndeterminate:(BOOL)isIndeterminate
  83. position:(float)position
  84. cancelString:(NSString * _Nullable)cancelString
  85. withReference:(NSValue * _Nonnull)reference;
  86. /** called when VLC wants to update an existing progress dialog
  87. * \param reference to the existing progress dialog
  88. * \param message updated message
  89. * \param position current position
  90. */
  91. - (void)updateProgressWithReference:(NSValue * _Nonnull)reference
  92. message:(NSString * _Nullable)message
  93. position:(float)position;
  94. /** VLC decided to destroy a dialog
  95. * \param reference to the dialog to destroy
  96. */
  97. - (void)cancelDialogWithReference:(NSValue * _Nonnull)reference;
  98. @end
  99. /**
  100. * dialog provider base class
  101. * \note For iOS and tvOS, there are useable implementations available which don't require the use of a custom renderer
  102. */
  103. OBJC_VISIBLE
  104. @interface VLCDialogProvider : NSObject
  105. /**
  106. * initializer method to run the dialog provider instance on a specific library instance
  107. *
  108. * \param library the VLCLibrary instance
  109. * \param customUI enable custom UI mode
  110. * \note if library param is NULL, [VLCLibrary sharedLibrary] will be used
  111. * \return the dialog provider instance, can be NULL on malloc failures
  112. */
  113. - (instancetype _Nullable)initWithLibrary:(VLCLibrary * _Nullable)library
  114. customUI:(BOOL)customUI;
  115. /**
  116. * initializer method to run the dialog provider instance on a specific library instance
  117. *
  118. * \return the object set
  119. */
  120. @property (weak, readwrite, nonatomic, nullable) id<VLCCustomDialogRendererProtocol> customRenderer;
  121. /**
  122. * if you requested custom UI mode for dialogs, use this method respond to a login dialog
  123. * \param username or NULL if cancelled
  124. * \param password or NULL if cancelled
  125. * \param dialogReference reference to the dialog you respond to
  126. * \param store shall VLC store the login securely?
  127. * \note This method does not have any effect if you don't use custom UI mode */
  128. - (void)postUsername:(NSString * _Nonnull)username
  129. andPassword:(NSString * _Nonnull)password
  130. forDialogReference:(NSValue * _Nonnull)dialogReference
  131. store:(BOOL)store;
  132. /**
  133. * if you requested custom UI mode for dialogs, use this method respond to a question dialog
  134. * \param buttonNumber the button number the user pressed, use 3 if s/he cancelled, otherwise respectively 1 or 2 depending on the selected action
  135. * \param dialogReference reference to the dialog you respond to
  136. * \note This method does not have any effect if you don't use custom UI mode */
  137. - (void)postAction:(int)buttonNumber
  138. forDialogReference:(NSValue * _Nonnull)dialogReference;
  139. /**
  140. * if you requested custom UI mode for dialogs, use this method to cancel a progress dialog
  141. * \param dialogReference reference to the dialog you want to cancel
  142. * \note This method does not have any effect if you don't use custom UI mode */
  143. - (void)dismissDialogWithReference:(NSValue * _Nonnull)dialogReference;
  144. @end