/core/externals/update-engine/Core/KSExistenceChecker.h

http://macfuse.googlecode.com/ · C Header · 91 lines · 28 code · 21 blank · 42 comment · 0 complexity · 02f17453410969b8503b23f0be935968 MD5 · raw file

  1. // Copyright 2008 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. // An abstract class that encapsulates the ability to check for the existence
  16. // of something. Concrete subclasses may provide the ability to check existence
  17. // by stating a path, asking LaunchServices whether an application with a
  18. // specific bundle ID exists, or running a Spotlight query.
  19. @interface KSExistenceChecker : NSObject <NSCoding>
  20. // Returns an existence checker whose -exists method always returns NO. Useful
  21. // for testing.
  22. + (id)falseChecker;
  23. // Returns an existence checker whose -exists method always returns
  24. // YES. This is useful for in-application users who don't really need
  25. // an existence check, such as an updater helper tool inside of an
  26. // application bundle. Since the tool exists and is running, the
  27. // application obviously exists too.
  28. + (id)trueChecker;
  29. // Subclasses must override this method. It should return YES if the represented
  30. // object exists, NO otherwise.
  31. - (BOOL)exists;
  32. @end
  33. //
  34. // Concrete subclasses
  35. //
  36. // Existence checker for checking the existence of a path.
  37. @interface KSPathExistenceChecker : KSExistenceChecker {
  38. @private
  39. NSString *path_;
  40. }
  41. // Returns an existence checker that will check the existence of |path|.
  42. + (id)checkerWithPath:(NSString *)path;
  43. - (id)initWithPath:(NSString *)path;
  44. // Returns the existence checker's path.
  45. - (NSString *)path;
  46. @end
  47. // Existence checker for querying LaunchServices about the existence of an
  48. // application with the specified bundle ID.
  49. @interface KSLaunchServicesExistenceChecker : KSExistenceChecker {
  50. @private
  51. NSString *bundleID_;
  52. }
  53. // Returns an existence checker that will check for the existence of |bid| in
  54. // the LaunchServices database.
  55. + (id)checkerWithBundleID:(NSString *)bid;
  56. - (id)initWithBundleID:(NSString *)bid;
  57. @end
  58. // Existence checker that queries Spotlight. If Spotlight returns any results,
  59. // the existence check will be YES, if Spotlight doesn't find anything, the
  60. // existence check will be NO. It does not matter /what/ is found, just that
  61. // something is found.
  62. @interface KSSpotlightExistenceChecker : KSExistenceChecker {
  63. @private
  64. NSString *query_;
  65. }
  66. // Returns an existence checker that will use Spotlight to see if |query|
  67. // returns any results.
  68. + (id)checkerWithQuery:(NSString *)query;
  69. - (id)initWithQuery:(NSString *)query;
  70. @end