VLCDialogProvider.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 error the dialog title
  33. * \param message 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 title login dialog title
  41. * \param message an explaining message
  42. * \param username a default username within context
  43. * \param askingForStorage 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 title the dialog title
  54. * \param message an explaining message text
  55. * \param questionType a question type
  56. * \param cancelString cancel button text
  57. * \param action1String action 1 text
  58. * \param action2String 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 title the dialog title
  71. * \param message an explaining message
  72. * \param isIndeterminate indicator whether progress indeterminate
  73. * \param position initial progress position
  74. * \param cancelString 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 message updated message
  86. * \param position 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 library the VLCLibrary instance
  101. * \param customUI 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. * \return the object set
  111. */
  112. @property (weak, readwrite, nonatomic, nullable) id<VLCCustomDialogRendererProtocol> customRenderer;
  113. /**
  114. * if you requested custom UI mode for dialogs, use this method respond to a login dialog
  115. * \param username or NULL if cancelled
  116. * \param password or NULL if cancelled
  117. * \param dialogReference reference to the dialog you respond to
  118. * \param store shall VLC store the login securely?
  119. * \note This method does not have any effect if you don't use custom UI mode */
  120. - (void)postUsername:(NSString * _Nonnull)username
  121. andPassword:(NSString * _Nonnull)password
  122. forDialogReference:(NSValue * _Nonnull)dialogReference
  123. store:(BOOL)store;
  124. /**
  125. * if you requested custom UI mode for dialogs, use this method respond to a question dialog
  126. * \param buttonNumber the button number the user pressed, use 3 if s/he cancelled, otherwise respectively 1 or 2 depending on the selected action
  127. * \param dialogReference reference to the dialog you respond to
  128. * \note This method does not have any effect if you don't use custom UI mode */
  129. - (void)postAction:(int)buttonNumber
  130. forDialogReference:(NSValue * _Nonnull)dialogReference;
  131. /**
  132. * if you requested custom UI mode for dialogs, use this method to cancel a progress dialog
  133. * \param dialogReference reference to the dialog you want to cancel
  134. * \note This method does not have any effect if you don't use custom UI mode */
  135. - (void)dismissDialogWithReference:(NSValue * _Nonnull)dialogReference;
  136. @end