forked from mirrors/linphone-iphone
move important files to Application Library
This commit is contained in:
parent
5f94b2295f
commit
ddb81ab171
5 changed files with 58 additions and 18 deletions
|
|
@ -1030,10 +1030,7 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog
|
|||
|
||||
- (NSURL *)getICloudFileUrl:(NSString *)name {
|
||||
if (@available(iOS 11.0, *)) {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSString *documentsPath = [paths objectAtIndex:0];
|
||||
NSURL *url = [NSURL fileURLWithPath:documentsPath];
|
||||
return [url URLByAppendingPathComponent:name];
|
||||
return [NSURL fileURLWithPath:[LinphoneManager documentFile:name]];
|
||||
}
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
|
|
|
|||
|
|
@ -321,9 +321,9 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
LOGW(@"Exception while destroying linphone core: %@", e);
|
||||
} @finally {
|
||||
if ([NSFileManager.defaultManager
|
||||
isDeletableFileAtPath:[LinphoneManager documentFile:@"linphonerc"]] == YES) {
|
||||
isDeletableFileAtPath:[LinphoneManager dataFile:@"linphonerc"]] == YES) {
|
||||
[NSFileManager.defaultManager
|
||||
removeItemAtPath:[LinphoneManager documentFile:@"linphonerc"]
|
||||
removeItemAtPath:[LinphoneManager dataFile:@"linphonerc"]
|
||||
error:nil];
|
||||
}
|
||||
#ifdef DEBUG
|
||||
|
|
|
|||
|
|
@ -160,7 +160,8 @@ typedef struct _LinphoneManagerSounds {
|
|||
+ (BOOL)copyFile:(NSString*)src destination:(NSString*)dst override:(BOOL)override;
|
||||
+ (PHFetchResult *)getPHAssets:(NSString *)key;
|
||||
+ (NSString*)bundleFile:(NSString*)file;
|
||||
+ (NSString*)documentFile:(NSString*)file;
|
||||
+ (NSString *)documentFile:(NSString *)file;
|
||||
+ (NSString*)dataFile:(NSString*)file;
|
||||
+ (NSString*)cacheDirectory;
|
||||
|
||||
- (void)acceptCall:(LinphoneCall *)call evenWithVideo:(BOOL)video;
|
||||
|
|
|
|||
|
|
@ -342,6 +342,29 @@ struct codec_name_pref_table codec_pref_table[] = {{"speex", 8000, "speex_8k_pre
|
|||
[self lpConfigSetBool:YES forKey:@"migration_xmlrpc"];
|
||||
}
|
||||
[self lpConfigSetBool:NO forKey:@"store_friends" inSection:@"misc"]; //so far, storing friends in files is not needed. may change in the future.
|
||||
|
||||
// migration of important file, move these files to app library.
|
||||
if ([LinphoneManager copyFile:[LinphoneManager documentFile:@"linphonerc"] destination:[LinphoneManager dataFile:@"linphonerc"] override:TRUE]) {
|
||||
[NSFileManager.defaultManager
|
||||
removeItemAtPath:[LinphoneManager documentFile:@"linphonerc"]
|
||||
error:nil];
|
||||
}
|
||||
if ([LinphoneManager copyFile:[LinphoneManager documentFile:@"linphone_chats.db"] destination:[LinphoneManager dataFile:@"linphone_chats.db"] override:TRUE]) {
|
||||
[NSFileManager.defaultManager
|
||||
removeItemAtPath:[LinphoneManager documentFile:@"linphone_chats.db"]
|
||||
error:nil];
|
||||
}
|
||||
if ([LinphoneManager copyFile:[LinphoneManager documentFile:@"zrtp_secrets"] destination:[LinphoneManager dataFile:@"zrtp_secrets"] override:TRUE]) {
|
||||
[NSFileManager.defaultManager
|
||||
removeItemAtPath:[LinphoneManager documentFile:@"zrtp_secrets"]
|
||||
error:nil];
|
||||
}
|
||||
if ([LinphoneManager copyFile:[LinphoneManager documentFile:@"zrtp_secrets.bkp"] destination:[LinphoneManager dataFile:@"zrtp_secrets.bkp"] override:TRUE]) {
|
||||
[NSFileManager.defaultManager
|
||||
removeItemAtPath:[LinphoneManager documentFile:@"zrtp_secrets.bkp"]
|
||||
error:nil];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int check_should_migrate_images(void *data, int argc, char **argv, char **cnames) {
|
||||
|
|
@ -1814,8 +1837,8 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
linphone_core_enable_keep_alive(theLinphoneCore, true);
|
||||
|
||||
// get default config from bundle
|
||||
NSString *zrtpSecretsFileName = [LinphoneManager documentFile:@"zrtp_secrets"];
|
||||
NSString *chatDBFileName = [LinphoneManager documentFile:kLinphoneInternalChatDBFilename];
|
||||
NSString *zrtpSecretsFileName = [LinphoneManager dataFile:@"zrtp_secrets"];
|
||||
NSString *chatDBFileName = [LinphoneManager dataFile:kLinphoneInternalChatDBFilename];
|
||||
|
||||
NSString *device = [[NSMutableString alloc]
|
||||
initWithString:[NSString
|
||||
|
|
@ -2483,8 +2506,8 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
// rename .linphonerc to linphonerc to ease debugging: when downloading
|
||||
// containers from MacOSX, Finder do not display hidden files leading
|
||||
// to useless painful operations to display the .linphonerc file
|
||||
NSString *src = [LinphoneManager documentFile:@".linphonerc"];
|
||||
NSString *dst = [LinphoneManager documentFile:@"linphonerc"];
|
||||
NSString *src = [LinphoneManager dataFile:@".linphonerc"];
|
||||
NSString *dst = [LinphoneManager dataFile:@"linphonerc"];
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSError *fileError = nil;
|
||||
if ([fileManager fileExistsAtPath:src]) {
|
||||
|
|
@ -2505,7 +2528,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
if (IPAD && [[NSFileManager defaultManager] fileExistsAtPath:srcIpad]) {
|
||||
src = srcIpad;
|
||||
}
|
||||
NSString *dst = [LinphoneManager documentFile:@"linphonerc"];
|
||||
NSString *dst = [LinphoneManager dataFile:@"linphonerc"];
|
||||
[LinphoneManager copyFile:src destination:dst override:FALSE];
|
||||
}
|
||||
|
||||
|
|
@ -2515,7 +2538,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
if (IPAD && [[NSFileManager defaultManager] fileExistsAtPath:factoryIpad]) {
|
||||
factory = factoryIpad;
|
||||
}
|
||||
NSString *confiFileName = [LinphoneManager documentFile:@"linphonerc"];
|
||||
NSString *confiFileName = [LinphoneManager dataFile:@"linphonerc"];
|
||||
_configDb = lp_config_new_with_factory([confiFileName UTF8String], [factory UTF8String]);
|
||||
}
|
||||
#pragma mark - Audio route Functions
|
||||
|
|
@ -2861,9 +2884,28 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
|
||||
+ (NSString *)documentFile:(NSString *)file {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSString *documentsPath = [paths objectAtIndex:0];
|
||||
return [documentsPath stringByAppendingPathComponent:file];
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSString *documentsPath = [paths objectAtIndex:0];
|
||||
return [documentsPath stringByAppendingPathComponent:file];
|
||||
}
|
||||
|
||||
+ (NSString *)dataFile:(NSString *)file {
|
||||
// TODO : migrate with function dataFile of submodule
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
NSString *writablePath = [paths objectAtIndex:0];
|
||||
NSString *fullPath = [writablePath stringByAppendingString:@"/linphone/"];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
|
||||
NSError *error;
|
||||
LOGI(@"Data path %@ does not exist, creating it.",fullPath);
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:fullPath
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:&error]) {
|
||||
LOGE(@"Create data path directory error: %@",error.description);
|
||||
}
|
||||
}
|
||||
|
||||
return [fullPath stringByAppendingPathComponent:file];
|
||||
}
|
||||
|
||||
+ (NSString *)cacheDirectory {
|
||||
|
|
|
|||
|
|
@ -997,11 +997,11 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
|
|||
if ([LinphoneManager.instance lpConfigBoolForKey:@"send_logs_include_linphonerc_and_chathistory"]) {
|
||||
// retrieve linphone rc
|
||||
[attachments
|
||||
addObject:@[ [LinphoneManager documentFile:@"linphonerc"], @"text/plain", @"linphone-configuration.rc" ]];
|
||||
addObject:@[ [LinphoneManager dataFile:@"linphonerc"], @"text/plain", @"linphone-configuration.rc" ]];
|
||||
|
||||
// retrieve historydb
|
||||
[attachments addObject:@[
|
||||
[LinphoneManager documentFile:@"linphone_chats.db"],
|
||||
[LinphoneManager dataFile:@"linphone_chats.db"],
|
||||
@"application/x-sqlite3",
|
||||
@"linphone-chats-history.db"
|
||||
]];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue