|
36 | 36 |
|
37 | 37 | // Log levels: off, error, warn, info, verbose
|
38 | 38 | #if DEBUG
|
39 |
| - static const int xmppLogLevel = XMPP_LOG_LEVEL_VERBOSE | XMPP_LOG_FLAG_TRACE; |
| 39 | + static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN; |
40 | 40 | #else
|
41 | 41 | static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
|
42 | 42 | #endif
|
@@ -106,13 +106,57 @@ - (void)commonInit
|
106 | 106 | pausedMessageDeletion = [[NSMutableSet alloc] init];
|
107 | 107 | }
|
108 | 108 |
|
| 109 | +/** |
| 110 | + * Documentation from the superclass (XMPPCoreDataStorage): |
| 111 | + * |
| 112 | + * Override me, if needed, to provide customized behavior. |
| 113 | + * |
| 114 | + * This method is queried to get the name of the ManagedObjectModel within the app bundle. |
| 115 | + * It should return the name of the appropriate file (*.xdatamodel / *.mom / *.momd) sans file extension. |
| 116 | + * |
| 117 | + * The default implementation returns the name of the subclass, stripping any suffix of "CoreDataStorage". |
| 118 | + * E.g., if your subclass was named "XMPPExtensionCoreDataStorage", then this method would return "XMPPExtension". |
| 119 | + * |
| 120 | + * Note that a file extension should NOT be included. |
| 121 | +**/ |
109 | 122 | - (NSString *)managedObjectModelName
|
110 | 123 | {
|
111 |
| - // This method overrides [XMPPCoreDataStorage managedObjectModelName]. |
| 124 | + // Optional hook |
| 125 | + // |
| 126 | + // The default implementation would return "XMPPPRoomHybridStorage". |
| 127 | + // We prefer a slightly shorter version. |
112 | 128 |
|
113 | 129 | return @"XMPPRoomHybrid";
|
114 | 130 | }
|
115 | 131 |
|
| 132 | +/** |
| 133 | + * Documentation from the superclass (XMPPCoreDataStorage): |
| 134 | + * |
| 135 | + * Override me, if needed, to provide customized behavior. |
| 136 | + * |
| 137 | + * For example, if you are using the database for non-persistent data and the model changes, you may want |
| 138 | + * to delete the database file if it already exists on disk and a core data migration is not worthwhile. |
| 139 | + * |
| 140 | + * If this instance was created via initWithDatabaseFilename, then the storePath parameter will be non-nil. |
| 141 | + * If this instance was created via initWithInMemoryStore, then the storePath parameter will be nil. |
| 142 | + * |
| 143 | + * The default implementation simply writes to the XMPP error log. |
| 144 | +**/ |
| 145 | +- (void)didNotAddPersistentStoreWithPath:(NSString *)storePath error:(NSError *)error |
| 146 | +{ |
| 147 | + // Optional hook |
| 148 | + // |
| 149 | + // If we ever have problems opening the database file, |
| 150 | + // it's likely because the model changed or the file became corrupt. |
| 151 | + // |
| 152 | + // In this case we don't have to worry about migrating the data, because it's all stored on servers. |
| 153 | + // So we're just going to delete the sqlite file from disk, and create a new one. |
| 154 | + |
| 155 | + [[NSFileManager defaultManager] removeItemAtPath:storePath error:NULL]; |
| 156 | + |
| 157 | + [self addPersistentStoreWithPath:storePath error:NULL]; |
| 158 | +} |
| 159 | + |
116 | 160 | - (void)dealloc
|
117 | 161 | {
|
118 | 162 | [self destroyDeleteTimer];
|
|
0 commit comments