From 6ed2bd572639a69bb371365cfd0f01ebf89b0466 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 6 Jan 2016 15:11:28 +0100 Subject: [PATCH] tester: fix liblinphone tester [Switch submodule branch] --- Classes/Log.h | 36 +++++++++++++++ Classes/Utils/Log.m | 72 ++++++++++++++++++++++++++++++ Classes/Utils/Utils.h | 19 +------- Classes/Utils/Utils.m | 52 --------------------- LiblinphoneTester/DetailView.m | 2 +- LiblinphoneTester/MasterView.m | 2 +- TestsUI/LinphoneTestCase.m | 1 + linphone.xcodeproj/project.pbxproj | 12 +++-- linphone_Prefix.pch | 1 + submodules/linphone | 2 +- 10 files changed, 122 insertions(+), 77 deletions(-) create mode 100644 Classes/Log.h create mode 100644 Classes/Utils/Log.m diff --git a/Classes/Log.h b/Classes/Log.h new file mode 100644 index 000000000..becc2e538 --- /dev/null +++ b/Classes/Log.h @@ -0,0 +1,36 @@ +/* + * + * Copyright (C) 2012 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import "LinphoneManager.h" + +#define LOGV(level, ...) [LinphoneLogger log:level file:__FILE__ line:__LINE__ format:__VA_ARGS__] +#define LOGD(...) LOGV(ORTP_DEBUG, __VA_ARGS__) +#define LOGI(...) LOGV(ORTP_MESSAGE, __VA_ARGS__) +#define LOGW(...) LOGV(ORTP_WARNING, __VA_ARGS__) +#define LOGE(...) LOGV(ORTP_ERROR, __VA_ARGS__) +#define LOGF(...) LOGV(ORTP_FATAL, __VA_ARGS__) + +#define IPAD (LinphoneManager.runningOnIpad) + +@interface LinphoneLogger : NSObject { +} + ++ (void)log:(OrtpLogLevel)severity file:(const char *)file line:(int)line format:(NSString *)format, ...; +void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); +@end \ No newline at end of file diff --git a/Classes/Utils/Log.m b/Classes/Utils/Log.m new file mode 100644 index 000000000..1c93ba76b --- /dev/null +++ b/Classes/Utils/Log.m @@ -0,0 +1,72 @@ +/* + * + * Copyright (C) 2012 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import "Log.h" + +@implementation LinphoneLogger + ++ (void)log:(OrtpLogLevel)severity file:(const char *)file line:(int)line format:(NSString *)format, ... { + va_list args; + va_start(args, format); + NSString *str = [[NSString alloc] initWithFormat:format arguments:args]; + const char *utf8str = [str cStringUsingEncoding:NSString.defaultCStringEncoding]; + int filesize = 20; + const char *filename = strchr(file, '/') ? strrchr(file, '/') + 1 : file; + if (severity <= ORTP_DEBUG) { + // lol: ortp_debug(XXX) can be disabled at compile time, but ortp_log(ORTP_DEBUG, xxx) will always be valid even + // not in debug build... + ortp_debug("%*s:%3d - %s", filesize, filename + MAX((int)strlen(filename) - filesize, 0), line, utf8str); + } else { + ortp_log(severity, "%*s:%3d - %s", filesize, filename + MAX((int)strlen(filename) - filesize, 0), line, + utf8str); + } + va_end(args); +} + +#pragma mark - Logs Functions callbacks + +void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) { + NSString *format = [[NSString alloc] initWithUTF8String:fmt]; + NSString *formatedString = [[NSString alloc] initWithFormat:format arguments:args]; + char levelC = 'I'; + switch ((OrtpLogLevel)lev) { + case ORTP_FATAL: + levelC = 'F'; + break; + case ORTP_ERROR: + levelC = 'E'; + break; + case ORTP_WARNING: + levelC = 'W'; + break; + case ORTP_MESSAGE: + levelC = 'I'; + break; + case ORTP_TRACE: + case ORTP_DEBUG: + levelC = 'D'; + break; + case ORTP_LOGLEV_END: + return; + } + // since \r are interpreted like \n, avoid double new lines when logging packets + NSLog(@"%c %@", levelC, [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]); +} + +@end diff --git a/Classes/Utils/Utils.h b/Classes/Utils/Utils.h index 0ae4df985..03f1b6843 100644 --- a/Classes/Utils/Utils.h +++ b/Classes/Utils/Utils.h @@ -1,4 +1,4 @@ -/* Utils.h +/* * * Copyright (C) 2012 Belledonne Comunications, Grenoble, France * @@ -19,23 +19,6 @@ #import "LinphoneManager.h" -#define LOGV(level, ...) [LinphoneLogger log:level file:__FILE__ line:__LINE__ format:__VA_ARGS__] -#define LOGD(...) LOGV(ORTP_DEBUG, __VA_ARGS__) -#define LOGI(...) LOGV(ORTP_MESSAGE, __VA_ARGS__) -#define LOGW(...) LOGV(ORTP_WARNING, __VA_ARGS__) -#define LOGE(...) LOGV(ORTP_ERROR, __VA_ARGS__) -#define LOGF(...) LOGV(ORTP_FATAL, __VA_ARGS__) - -#define IPAD (LinphoneManager.runningOnIpad) - -@interface LinphoneLogger : NSObject { - -} - -+ (void)log:(OrtpLogLevel)severity file:(const char *)file line:(int)line format:(NSString *)format, ...; -void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); -@end - @interface LinphoneUtils : NSObject + (BOOL)findAndResignFirstResponder:(UIView*)view; diff --git a/Classes/Utils/Utils.m b/Classes/Utils/Utils.m index 923ad4130..bc3adbe55 100644 --- a/Classes/Utils/Utils.m +++ b/Classes/Utils/Utils.m @@ -28,58 +28,6 @@ #import "FastAddressBook.h" #import "ColorSpaceUtilities.h" -@implementation LinphoneLogger - -+ (void)log:(OrtpLogLevel)severity file:(const char *)file line:(int)line format:(NSString *)format, ... { - va_list args; - va_start(args, format); - NSString *str = [[NSString alloc] initWithFormat:format arguments:args]; - const char *utf8str = [str cStringUsingEncoding:NSString.defaultCStringEncoding]; - int filesize = 20; - const char *filename = strchr(file, '/') ? strrchr(file, '/') + 1 : file; - if (severity <= ORTP_DEBUG) { - // lol: ortp_debug(XXX) can be disabled at compile time, but ortp_log(ORTP_DEBUG, xxx) will always be valid even - // not in debug build... - ortp_debug("%*s:%3d - %s", filesize, filename + MAX((int)strlen(filename) - filesize, 0), line, utf8str); - } else { - ortp_log(severity, "%*s:%3d - %s", filesize, filename + MAX((int)strlen(filename) - filesize, 0), line, - utf8str); - } - va_end(args); -} - -#pragma mark - Logs Functions callbacks - -void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) { - NSString *format = [[NSString alloc] initWithUTF8String:fmt]; - NSString *formatedString = [[NSString alloc] initWithFormat:format arguments:args]; - char levelC = 'I'; - switch ((OrtpLogLevel)lev) { - case ORTP_FATAL: - levelC = 'F'; - break; - case ORTP_ERROR: - levelC = 'E'; - break; - case ORTP_WARNING: - levelC = 'W'; - break; - case ORTP_MESSAGE: - levelC = 'I'; - break; - case ORTP_TRACE: - case ORTP_DEBUG: - levelC = 'D'; - break; - case ORTP_LOGLEV_END: - return; - } - // since \r are interpreted like \n, avoid double new lines when logging packets - NSLog(@"%c %@", levelC, [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]); -} - -@end - @implementation LinphoneUtils + (BOOL)hasSelfAvatar { diff --git a/LiblinphoneTester/DetailView.m b/LiblinphoneTester/DetailView.m index f8da69f6f..e2e0445eb 100644 --- a/LiblinphoneTester/DetailView.m +++ b/LiblinphoneTester/DetailView.m @@ -10,7 +10,7 @@ #import "MasterView.h" #import "LogsView.h" #include "linphone/liblinphone_tester.h" -#import "Utils.h" +#import "Log.h" static NSString *const kAllTestsName = @"Run All tests"; diff --git a/LiblinphoneTester/MasterView.m b/LiblinphoneTester/MasterView.m index 58df6d562..60413188d 100644 --- a/LiblinphoneTester/MasterView.m +++ b/LiblinphoneTester/MasterView.m @@ -12,7 +12,7 @@ #include "linphone/liblinphone_tester.h" #include "mediastreamer2/msutils.h" -#import "Utils.h" +#import "Log.h" @interface MasterView () { NSMutableArray *_objects; diff --git a/TestsUI/LinphoneTestCase.m b/TestsUI/LinphoneTestCase.m index f3753090c..d3d672543 100644 --- a/TestsUI/LinphoneTestCase.m +++ b/TestsUI/LinphoneTestCase.m @@ -11,6 +11,7 @@ #import "LinphoneManager.h" #import "KIF/KIFTypist.h" +#import "Log.h" #import "Utils.h" @implementation LinphoneTestCase diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 11359bd5b..35f545c1b 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -85,8 +85,6 @@ 631348301B6F7B6600C6BDCB /* UIRoundBorderedButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 6313482F1B6F7B6600C6BDCB /* UIRoundBorderedButton.m */; }; 631348321B6FA53300C6BDCB /* rootca.pem in Resources */ = {isa = PBXBuildFile; fileRef = 631348311B6FA53300C6BDCB /* rootca.pem */; }; 6316FA6D1BE12A3E0050E441 /* UIRightImageButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 6316FA6C1BE12A3E0050E441 /* UIRightImageButton.m */; }; - 632DA24D1B43EE9400EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; }; - 632DA24E1B43EEEF00EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; }; 6334DDFA1BBAC97C00631900 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D32B6E2E15A5C0AC0033019F /* libsqlite3.dylib */; }; 6334DDFB1BBAC99400631900 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D32B6E2E15A5C0AC0033019F /* libsqlite3.dylib */; }; 6334DDFC1BBAC99B00631900 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 152F22351B15E889008C0621 /* libxml2.dylib */; }; @@ -549,6 +547,8 @@ 63CFEE0B1B9EDD88007EA5BD /* libmswebrtc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 63EA4C941B50189D00922857 /* libmswebrtc.a */; }; 63CFEE0C1B9EDD88007EA5BD /* libmsx264.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22AA8AFC13D7125500B30535 /* libmsx264.a */; }; 63CFEE131B9EDF65007EA5BD /* libvo-amrwbenc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 63CFEDE31B9EDD36007EA5BD /* libvo-amrwbenc.a */; }; + 63D11C531C3D501200E8FCEE /* Log.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D11C521C3D501200E8FCEE /* Log.m */; }; + 63D11C551C3D50A100E8FCEE /* Log.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D11C521C3D501200E8FCEE /* Log.m */; }; 63E59A3F1ADE70D900646FB3 /* InAppProductsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E59A3E1ADE70D900646FB3 /* InAppProductsManager.m */; }; 63EEE3FF1BBA9AC00087D3AF /* libcunit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F03A9B7E18C0D9C900C4D7FE /* libcunit.a */; }; 63EEE4001BBA9AC00087D3AF /* liblinphonetester.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F0BB8C0F193623F200974404 /* liblinphonetester.a */; }; @@ -1364,6 +1364,8 @@ 63CFEDE21B9EDD36007EA5BD /* libswresample.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswresample.a; path = "liblinphone-sdk/apple-darwin/lib/libswresample.a"; sourceTree = ""; }; 63CFEDE31B9EDD36007EA5BD /* libvo-amrwbenc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libvo-amrwbenc.a"; path = "liblinphone-sdk/apple-darwin/lib/libvo-amrwbenc.a"; sourceTree = ""; }; 63CFEDE41B9EDD36007EA5BD /* libbcg729.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libbcg729.a; path = "liblinphone-sdk/apple-darwin/lib/libbcg729.a"; sourceTree = ""; }; + 63D11C521C3D501200E8FCEE /* Log.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Log.m; path = Utils/Log.m; sourceTree = ""; }; + 63D11C541C3D503A00E8FCEE /* Log.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Log.h; sourceTree = ""; }; 63E59A3D1ADE6ECB00646FB3 /* InAppProductsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InAppProductsManager.h; sourceTree = ""; }; 63E59A3E1ADE70D900646FB3 /* InAppProductsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InAppProductsManager.m; sourceTree = ""; }; 63EA4C941B50189D00922857 /* libmswebrtc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmswebrtc.a; path = "liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins/libmswebrtc.a"; sourceTree = ""; }; @@ -2585,6 +2587,8 @@ C9B3A6FD15B485DB006F52EE /* Utils.h */, D35860D515B549B500513429 /* Utils.m */, D3554EC515CA79A900478841 /* XMLRPC.xcodeproj */, + 63D11C521C3D501200E8FCEE /* Log.m */, + 63D11C541C3D503A00E8FCEE /* Log.h */, ); name = Utils; sourceTree = ""; @@ -3479,6 +3483,7 @@ D3F795D615A582810077328B /* ChatConversationView.m in Sources */, D32B6E2915A5BC440033019F /* ChatConversationTableView.m in Sources */, D3A8BB7015A6C7D500F96BE5 /* UIChatBubbleTextCell.m in Sources */, + 63D11C531C3D501200E8FCEE /* Log.m in Sources */, D3128FE115AABC7E00A2147A /* ContactDetailsView.m in Sources */, D37C639B15AADEF6009D0BAC /* ContactDetailsTableView.m in Sources */, 63E59A3F1ADE70D900646FB3 /* InAppProductsManager.m in Sources */, @@ -3527,7 +3532,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 632DA24E1B43EEEF00EB356A /* Utils.m in Sources */, 63058A3C1B4E822F00EFAE36 /* DTObjectBlockExecutor.m in Sources */, 63058A3F1B4E823000EFAE36 /* NSObject+DTRuntime.m in Sources */, 63058A3E1B4E822F00EFAE36 /* LinphoneTester_Tests.m in Sources */, @@ -3538,9 +3542,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 63D11C551C3D50A100E8FCEE /* Log.m in Sources */, 63058A2D1B4E821E00EFAE36 /* main.m in Sources */, 63058A241B4E821E00EFAE36 /* AppDelegate.m in Sources */, - 632DA24D1B43EE9400EB356A /* Utils.m in Sources */, 63058A2A1B4E821E00EFAE36 /* DetailView.m in Sources */, 63058A2E1B4E821E00EFAE36 /* MasterView.m in Sources */, 63058A2C1B4E821E00EFAE36 /* LogsView.m in Sources */, diff --git a/linphone_Prefix.pch b/linphone_Prefix.pch index a684971e5..247e95804 100644 --- a/linphone_Prefix.pch +++ b/linphone_Prefix.pch @@ -7,4 +7,5 @@ #import #endif +#import "Log.h" #import "Utils.h" diff --git a/submodules/linphone b/submodules/linphone index 0d2723fae..218db02a1 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 0d2723fae84f812c8d8bb7daaee9b91ca57958b5 +Subproject commit 218db02a1ab4590d31032b4cbce25b5c34d508e7