You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.2 KiB

  1. /*
  2. * Copyright 2019 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class FIRInstanceIDAuthKeychain;
  18. @class FIRInstanceIDBackupExcludedPlist;
  19. @class FIRInstanceIDCheckinPreferences;
  20. // These values exposed for testing
  21. extern NSString *const kFIRInstanceIDCheckinKeychainService;
  22. /**
  23. * Checkin preferences backing store.
  24. */
  25. @interface FIRInstanceIDCheckinStore : NSObject
  26. /**
  27. * Designated Initializer. Initialize a checkin store with the given backup excluded
  28. * plist filename.
  29. *
  30. * @param checkinFilename The backup excluded plist filename to persist checkin
  31. * preferences.
  32. *
  33. * @param subDirectoryName Sub-directory in standard directory where we write
  34. * InstanceID plist.
  35. *
  36. * @return Store to persist checkin preferences.
  37. */
  38. - (instancetype)initWithCheckinPlistFileName:(NSString *)checkinFilename
  39. subDirectoryName:(NSString *)subDirectoryName;
  40. /**
  41. * Initialize a checkin store with the given backup excluded plist and keychain.
  42. *
  43. * @param plist The backup excluded plist to persist checkin preferences.
  44. * @param keychain The keychain used to persist checkin auth preferences.
  45. *
  46. * @return Store to persist checkin preferences.
  47. */
  48. - (instancetype)initWithCheckinPlist:(FIRInstanceIDBackupExcludedPlist *)plist
  49. keychain:(FIRInstanceIDAuthKeychain *)keychain;
  50. /**
  51. * Checks whether the backup excluded checkin preferences are present on the disk or not.
  52. *
  53. * @return YES if the backup excluded checkin plist exists on the disks else NO.
  54. */
  55. - (BOOL)hasCheckinPlist;
  56. #pragma mark - Save
  57. /**
  58. * Save the checkin preferences to backing store.
  59. *
  60. * @param preferences Checkin preferences to save.
  61. * @param handler The callback handler which is invoked when the operation is complete,
  62. * with an error if there is any.
  63. */
  64. - (void)saveCheckinPreferences:(FIRInstanceIDCheckinPreferences *)preferences
  65. handler:(void (^)(NSError *error))handler;
  66. #pragma mark - Delete
  67. /**
  68. * Remove the cached checkin preferences.
  69. *
  70. * @param handler The callback handler which is invoked when the operation is complete,
  71. * with an error if there is any.
  72. */
  73. - (void)removeCheckinPreferencesWithHandler:(void (^)(NSError *error))handler;
  74. #pragma mark - Get
  75. /**
  76. * Get the cached device secret. If we cannot access it for some reason we
  77. * return the appropriate error object.
  78. *
  79. * @return The cached checkin preferences if present else nil.
  80. */
  81. - (FIRInstanceIDCheckinPreferences *)cachedCheckinPreferences;
  82. @end