Commit 6ed094a2 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Using binary grammar for identity address

parent 6e786d69
......@@ -27,6 +27,7 @@ install(FILES rootca.pem
set(GRAMMAR_FILES
cpim_grammar
identity_grammar
)
install(FILES ${GRAMMAR_FILES}
......
......@@ -436,6 +436,7 @@ endif()
if(ENABLE_SHARED)
set(LINPHONE_RESOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../share/cpim_grammar"
"${CMAKE_CURRENT_SOURCE_DIR}/../share/identity_grammar"
"${CMAKE_CURRENT_SOURCE_DIR}/../share/rootca.pem"
"${CMAKE_CURRENT_SOURCE_DIR}/../share/ringback.wav"
"${CMAKE_CURRENT_SOURCE_DIR}/../share/Modules"
......
......@@ -36,6 +36,10 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
namespace {
string IdentityGrammar("identity_grammar");
}
// -----------------------------------------------------------------------------
class IdentityAddressParserPrivate : public ObjectPrivate {
......@@ -47,24 +51,7 @@ public:
IdentityAddressParser::IdentityAddressParser () : Singleton(*new IdentityAddressParserPrivate) {
L_D();
const char *identityAddressGrammar =
"address = scheme \":\" [user] \"@\" host [ gruu-parameter ] \r\n"
"scheme = \"sip\" / \"sips\" \r\n"
"user = 1*( alphanum / escaped / \"-\" / \"+\" / \"_\" / \"~\" ) \r\n"
"escaped = \"%\" HEXDIG HEXDIG \r\n"
"host = *( domainlabel \".\" ) toplabel [ \".\" ] \r\n"
"domainlabel = alphanum / (alphanum *( alphanum / ( *(\"-\") alphanum) ) ) \r\n"
"toplabel = ALPHA / (ALPHA *( alphanum / (*(\"-\") alphanum ) ) ) \r\n"
"gruu-parameter = \";gr=\" gruu-value \r\n"
"gruu-value = 1*( alphanum / \"-\" / \"_\" / \":\" ) \r\n"
"alphanum = ALPHA / DIGIT \r\n";
belr::ABNFGrammarBuilder builder;
shared_ptr<belr::Grammar> defaultGrammar = make_shared<belr::Grammar>("");
defaultGrammar->include(make_shared<belr::CoreRules>());
shared_ptr<belr::Grammar> grammar = builder.createFromAbnf(identityAddressGrammar, defaultGrammar);
//shared_ptr<belr::Grammar> grammar = belr::GrammarLoader::get().load(IdentityAddressGrammar);
shared_ptr<belr::Grammar> grammar = belr::GrammarLoader::get().load(IdentityGrammar);
if (!grammar)
lFatal() << "Unable to load Identity Address grammar.";
d->parser = make_shared<belr::Parser<shared_ptr<IdentityAddress>>>(grammar);
......
......@@ -122,6 +122,12 @@ IosPlatformHelpers::IosPlatformHelpers (std::shared_ptr<LinphonePrivate::Core> c
else
ms_error("IosPlatformHelpers did not find cpim grammar resource directory...");
string identityPath = getResourceDirPath(Framework, "identity_grammar");
if (!identityPath.empty())
belr::GrammarLoader::get().addPath(identityPath);
else
ms_error("IosPlatformHelpers did not find identity grammar resource directory...");
#ifdef VCARD_ENABLED
string vcardPath = getResourceDirPath("org.linphone.belcard", "vcard_grammar");
if (!vcardPath.empty())
......
......@@ -279,9 +279,11 @@ public class AndroidPlatformHelper {
String mPauseSoundFile = basePath + "/share/sounds/linphone/rings/dont_wait_too_long.mkv";
String mErrorToneFile = basePath + "/share/sounds/linphone/incoming_chat.wav";
String mGrammarCpimFile = basePath + "/share/belr/grammars/cpim_grammar";
String mGrammarIdentityFile = basePath + "/share/belr/grammars/identity_grammar";
String mGrammarVcardFile = basePath + "/share/belr/grammars/vcard_grammar";
copyEvenIfExists(getResourceIdentifierFromName("cpim_grammar"), mGrammarCpimFile);
copyEvenIfExists(getResourceIdentifierFromName("identity_grammar"), mGrammarIdentityFile);
copyEvenIfExists(getResourceIdentifierFromName("vcard_grammar"), mGrammarVcardFile);
copyEvenIfExists(getResourceIdentifierFromName("rootca"), mLinphoneRootCaFile);
copyIfNotExist(getResourceIdentifierFromName("notes_of_the_optimistic"), mRingSoundFile);
......
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