Commit 3a3745d7 authored by jehan's avatar jehan

Automatically load cpim grammar from Linphone framework on IOS

parent 2cd079c9
......@@ -219,8 +219,8 @@ if(ENABLE_STATIC)
)
endif()
if(ENABLE_SHARED)
add_library(linphone SHARED ${LINPHONE_HEADER_FILES} ${LINPHONE_PRIVATE_HEADER_FILES}
${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX} ${LINPHONE_SOURCE_FILES_OBJC}
add_library(linphone SHARED "../share/cpim_grammar" ${LINPHONE_HEADER_FILES} ${LINPHONE_PRIVATE_HEADER_FILES}
${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX} ${LINPHONE_SOURCE_FILES_OBJC}
$<TARGET_OBJECTS:linphone-cxx-objects>
)
if(IOS)
......@@ -235,6 +235,7 @@ if(ENABLE_SHARED)
MACOSX_FRAMEWORK_IDENTIFIER org.linphone.linphone
MACOSX_FRAMEWORK_INFO_PLIST Info.plist.in
PUBLIC_HEADER "${LINPHONE_HEADER_FILES}"
RESOURCE "../share/cpim_grammar"
)
endif()
if(BELCARD_FOUND)
......
......@@ -29,6 +29,10 @@
#include "object/object-p.h"
#include "cpim-parser.h"
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <CoreFoundation/CoreFoundation.h>
#endif
#define CPIM_GRAMMAR "cpim_grammar"
......@@ -223,8 +227,18 @@ public:
Cpim::Parser::Parser () : Singleton(*new ParserPrivate) {
L_D();
d->grammar = belr::GrammarLoader::get().load(CPIM_GRAMMAR);
#if TARGET_OS_IPHONE
CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("org.linphone.linphone") );
CFURLRef grammar_url = CFBundleCopyResourceURL(bundle, CFSTR(CPIM_GRAMMAR), NULL, NULL);
CFStringRef grammar_path = CFURLCopyFileSystemPath(grammar_url, kCFURLPOSIXPathStyle);
CFStringEncoding encoding_method = CFStringGetSystemEncoding();
const char *path = CFStringGetCStringPtr(grammar_path, encoding_method);
CFRelease(grammar_url);
CFRelease(grammar_path);
#else
const char *path = CPIM_GRAMMAR;
#endif
d->grammar = belr::GrammarLoader::get().load(path);
if (!d->grammar)
lFatal() << "Unable to load CPIM grammar.";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment