mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Add possibility to send logs using enable_log_collect in linphonerc [app] section
This commit is contained in:
parent
a65ffb057e
commit
1c08ea1791
7 changed files with 87 additions and 5 deletions
|
|
@ -1337,6 +1337,10 @@ static BOOL libStarted = FALSE;
|
|||
,configDb
|
||||
,self /* user_data */);
|
||||
|
||||
|
||||
linphone_core_set_log_collection_path([[LinphoneManager cacheDirectory] UTF8String]);
|
||||
linphone_core_enable_log_collection([self lpConfigBoolForKey:@"enable_log_collect"]);
|
||||
|
||||
/* set the CA file no matter what, since the remote provisioning could be hitting an HTTPS server */
|
||||
const char* lRootCa = [[LinphoneManager bundleFile:@"rootca.pem"] cStringUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
linphone_core_set_root_ca(theLinphoneCore, lRootCa);
|
||||
|
|
@ -1864,6 +1868,18 @@ static void audioRouteChangeListenerCallback (
|
|||
return [documentsPath stringByAppendingPathComponent:file];
|
||||
}
|
||||
|
||||
+ (NSString*)cacheDirectory {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
NSString *cachePath = [paths objectAtIndex:0];
|
||||
BOOL isDir = NO;
|
||||
NSError *error;
|
||||
// cache directory must be created if not existing
|
||||
if (! [[NSFileManager defaultManager] fileExistsAtPath:cachePath isDirectory:&isDir] && isDir == NO) {
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:&error];
|
||||
}
|
||||
return cachePath;
|
||||
}
|
||||
|
||||
+ (int)unreadMessageCount {
|
||||
int count = 0;
|
||||
if( [LinphoneManager isLcReady] ){
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#import "IASKAppSettingsViewController.h"
|
||||
#import "LinphoneCoreSettingsStore.h"
|
||||
|
||||
@interface SettingsViewController: UIViewController<IASKSettingsDelegate, UICompositeViewDelegate, UIAlertViewDelegate> {
|
||||
@interface SettingsViewController: UIViewController<IASKSettingsDelegate, UICompositeViewDelegate, UIAlertViewDelegate, MFMailComposeViewControllerDelegate> {
|
||||
@private
|
||||
LinphoneCoreSettingsStore* settingsStore;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -640,6 +640,10 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[hiddenKeys addObject:@"clear_cache_button"];
|
||||
[hiddenKeys addObject:@"battery_alert_button"];
|
||||
#endif
|
||||
|
||||
if (! [[LinphoneManager instance] lpConfigBoolForKey:@"enable_log_collect"]) {
|
||||
[hiddenKeys addObject:@"send_logs_button"];
|
||||
}
|
||||
|
||||
[hiddenKeys addObject:@"playback_gain_preference"];
|
||||
[hiddenKeys addObject:@"microphone_gain_preference"];
|
||||
|
|
@ -752,7 +756,32 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[alert release];
|
||||
} else if([key isEqual:@"about_button"]) {
|
||||
[[PhoneMainView instance] changeCurrentView:[AboutViewController compositeViewDescription] push:TRUE];
|
||||
}
|
||||
} else if ([key isEqual:@"send_logs_button"]) {
|
||||
char * filepath = linphone_core_compress_log_collection([LinphoneManager getLc]);
|
||||
if (filepath == NULL) {
|
||||
[LinphoneLogger log:LinphoneLoggerError format:@"Cannot sent logs: file is NULL"];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *filename = [[NSString stringWithUTF8String:filepath] componentsSeparatedByString:@"/"].lastObject;
|
||||
NSString *mimeType;
|
||||
if ([filename hasSuffix:@".jpg"]) {
|
||||
mimeType = @"image/jpeg";
|
||||
} else if ([filename hasSuffix:@".png"]) {
|
||||
mimeType = @"image/png";
|
||||
} else if ([filename hasSuffix:@".pdf"]) {
|
||||
mimeType = @"application/pdf";
|
||||
} else if ([filename hasSuffix:@".txt"]) {
|
||||
mimeType = @"text/plain";
|
||||
} else if ([filename hasSuffix:@".gz"]) {
|
||||
mimeType = @"application/gzip";
|
||||
} else {
|
||||
[LinphoneLogger log:LinphoneLoggerError format:@"Unknown extension type: %@, cancelling email", filename];
|
||||
return;
|
||||
}
|
||||
[self emailAttachment:[NSData dataWithContentsOfFile:[NSString stringWithUTF8String:filepath]] mimeType:mimeType name:filename];
|
||||
ms_free(filepath);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UIAlertView delegate
|
||||
|
|
@ -766,5 +795,33 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - Mail composer for send log
|
||||
- (void)emailAttachment: (NSData*)attachment mimeType:(NSString*)type name:(NSString*)attachmentName
|
||||
{
|
||||
if (attachmentName == nil || type == nil || attachmentName == nil) {
|
||||
[LinphoneLogger log:LinphoneLoggerError format:@"Trying to email attachment but mandatory field is missing"];
|
||||
return;
|
||||
}
|
||||
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
|
||||
picker.mailComposeDelegate = self;
|
||||
|
||||
[picker setSubject:NSLocalizedString(@"Linphone Logs",nil)];
|
||||
[picker setToRecipients:[NSArray arrayWithObjects:@"linphone-iphone@belledonne-communications.com", nil]];
|
||||
[picker setMessageBody:NSLocalizedString(@"Linphone logs", nil) isHTML:NO];
|
||||
[picker addAttachmentData:attachment mimeType:type fileName:attachmentName];
|
||||
|
||||
[self presentViewController:picker animated:true completion:nil];
|
||||
[picker release];
|
||||
}
|
||||
|
||||
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
|
||||
{
|
||||
if (error != nil) {
|
||||
[LinphoneLogger log:LinphoneLoggerWarning format:@"Error while sending mail: %@", error];
|
||||
} else {
|
||||
[LinphoneLogger log:LinphoneLoggerLog format:@"Mail completed with status: %d", result];
|
||||
}
|
||||
[self dismissViewControllerAnimated:true completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ start_at_boot_preference=1
|
|||
backgroundmode_preference=1
|
||||
autoanswer_notif_preference=1
|
||||
voiceproc_preference=1
|
||||
enable_log_collect=0
|
||||
|
||||
[default_values]
|
||||
reg_expires=600
|
||||
|
|
@ -260,7 +260,7 @@
|
|||
<key>Key</key>
|
||||
<string>release_button</string>
|
||||
<key>Title</key>
|
||||
<string>Release</string>
|
||||
<string>Exit</string>
|
||||
<key>Type</key>
|
||||
<string>IASKButtonSpecifier</string>
|
||||
</dict>
|
||||
|
|
@ -280,6 +280,14 @@
|
|||
<key>Type</key>
|
||||
<string>IASKButtonSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Key</key>
|
||||
<string>send_logs_button</string>
|
||||
<key>Title</key>
|
||||
<string>Send debug logs</string>
|
||||
<key>Type</key>
|
||||
<string>IASKButtonSpecifier</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>StringsTable</key>
|
||||
<string>Root</string>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit eee5149dde1ab04249e8d3d83676fa15d0ef78b6
|
||||
Subproject commit afa02ac712906b36fdc21526ecf87659e31fade2
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 2479a567a5a49a7a63406b3b1bf3f7a536a03d54
|
||||
Subproject commit 78acd91a54a0cca244df68475cdc158f03608322
|
||||
Loading…
Add table
Reference in a new issue