[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: Add perfomFolderAction internal method to VLCLibraryController

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Jul 3 10:06:38 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
1c45f417 by Claudio Cambra at 2023-07-03T09:50:11+00:00
macosx: Add perfomFolderAction internal method to VLCLibraryController

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
88e5fb9a by Claudio Cambra at 2023-07-03T09:50:11+00:00
macosx: Eliminate duplication in folder-related methods of VLCLibraryController by using performFolderAction

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


1 changed file:

- modules/gui/macosx/library/VLCLibraryController.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryController.m
=====================================
@@ -30,6 +30,8 @@
 
 #import <vlc_media_library.h>
 
+typedef int (*folder_action_f)(vlc_medialibrary_t*, const char*);
+
 @interface VLCLibraryController()
 {
     vlc_medialibrary_t *_p_libraryInstance;
@@ -120,7 +122,7 @@
 
 #pragma mark - folder management
 
-- (int)addFolderWithFileURL:(NSURL *)fileURL
+- (int)performFolderAction:(folder_action_f)action withFileUrl:(NSURL *)fileURL
 {
     if (!_p_libraryInstance) {
         return VLC_EACCES;
@@ -128,40 +130,28 @@
     if (!fileURL) {
         return VLC_EINVAL;
     }
-    return vlc_ml_add_folder(_p_libraryInstance, [[fileURL absoluteString] UTF8String]);
+
+    return action(_p_libraryInstance, fileURL.absoluteString.UTF8String);
+}
+
+- (int)addFolderWithFileURL:(NSURL *)fileURL
+{
+    return [self performFolderAction:vlc_ml_add_folder withFileUrl:fileURL];
 }
 
 - (int)banFolderWithFileURL:(NSURL *)fileURL
 {
-    if (!_p_libraryInstance) {
-        return VLC_EACCES;
-    }
-    if (!fileURL) {
-        return VLC_EINVAL;
-    }
-    return vlc_ml_ban_folder(_p_libraryInstance, [[fileURL absoluteString] UTF8String]);
+    return [self performFolderAction:vlc_ml_ban_folder withFileUrl:fileURL];
 }
 
 - (int)unbanFolderWithFileURL:(NSURL *)fileURL
 {
-    if (!_p_libraryInstance) {
-        return VLC_EACCES;
-    }
-    if (!fileURL) {
-        return VLC_EINVAL;
-    }
-    return vlc_ml_unban_folder(_p_libraryInstance, [[fileURL absoluteString] UTF8String]);
+    return [self performFolderAction:vlc_ml_unban_folder withFileUrl:fileURL];
 }
 
 - (int)removeFolderWithFileURL:(NSURL *)fileURL
 {
-    if (!_p_libraryInstance) {
-        return VLC_EACCES;
-    }
-    if (!fileURL) {
-        return VLC_EINVAL;
-    }
-    return vlc_ml_remove_folder(_p_libraryInstance, [[fileURL absoluteString] UTF8String]);
+    return [self performFolderAction:vlc_ml_remove_folder withFileUrl:fileURL];
 }
 
 - (int)reloadFolderWithFileURL:(NSURL *)fileURL



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3dac9ffa929a1a517e9b29df22c96f55259156a8...88e5fb9aaecfb7da2c0eace3103a73f8aea63259

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3dac9ffa929a1a517e9b29df22c96f55259156a8...88e5fb9aaecfb7da2c0eace3103a73f8aea63259
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list