Commit a10ee82f authored by Erwan Croze's avatar Erwan Croze 👋🏻

Loading Cpim grammar instead of build this

parent b4710039
......@@ -315,6 +315,7 @@ if(WIN32)
endif()
set(PACKAGE_LOCALE_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_DATADIR}/locale")
set(PACKAGE_DATA_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_DATADIR}")
set(PACKAGE_GRAMMAR_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_DATADIR}/belr/grammars")
set(PACKAGE_SOUND_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_DATADIR}/sounds/linphone")
set(PACKAGE_RING_DIR "${PACKAGE_SOUND_DIR}/rings")
set(PACKAGE_FREEDESKTOP_DIR "${PACKAGE_DATA_DIR}/applications")
......
......@@ -35,6 +35,7 @@
#define PACKAGE_LOCALE_DIR "${PACKAGE_LOCALE_DIR}"
#define PACKAGE_DATA_DIR "${PACKAGE_DATA_DIR}"
#define PACKAGE_GRAMMAR_DIR "${PACKAGE_GRAMMAR_DIR}"
#define PACKAGE_SOUND_DIR "${PACKAGE_SOUND_DIR}"
#define PACKAGE_RING_DIR "${PACKAGE_RING_DIR}"
......
......@@ -42,6 +42,16 @@ if(ENABLE_ROOTCA_DOWNLOAD)
)
endif()
set(GRAMMAR_FILES
cpim_grammar
vcard_grammar
)
install(FILES ${GRAMMAR_FILES}
DESTINATION ${PACKAGE_GRAMMAR_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
set(SOUND_FILES
hello16000.wav
hello8000.wav
......
......@@ -60,7 +60,6 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
chat/cpim/header/cpim-header-p.h
chat/cpim/header/cpim-header.h
chat/cpim/message/cpim-message.h
chat/cpim/parser/cpim-grammar.h
chat/cpim/parser/cpim-parser.h
chat/modifier/chat-message-modifier.h
chat/modifier/cpim-chat-message-modifier.h
......@@ -189,7 +188,6 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
chat/cpim/header/cpim-generic-header.cpp
chat/cpim/header/cpim-header.cpp
chat/cpim/message/cpim-message.cpp
chat/cpim/parser/cpim-grammar.cpp
chat/cpim/parser/cpim-parser.cpp
chat/modifier/cpim-chat-message-modifier.cpp
chat/modifier/encryption-chat-message-modifier.cpp
......
/*
* cpim-grammar.h
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _L_CPIM_GRAMMAR_H_
#define _L_CPIM_GRAMMAR_H_
#include "linphone/utils/general.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
namespace Cpim {
const char *getGrammar ();
}
LINPHONE_END_NAMESPACE
#endif // ifndef _L_CPIM_GRAMMAR_H_
......@@ -24,7 +24,6 @@
#include "linphone/utils/utils.h"
#include "cpim-grammar.h"
#include "content/content-type.h"
#include "logger/logger.h"
#include "object/object-p.h"
......@@ -37,6 +36,8 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
#define CPIM_GRAMMAR "cpim_grammar"
namespace Cpim {
class Node {
public:
......@@ -223,11 +224,9 @@ public:
Cpim::Parser::Parser () : Singleton(*new ParserPrivate) {
L_D();
belr::ABNFGrammarBuilder builder;
d->grammar = builder.createFromAbnf(getGrammar(), make_shared<belr::CoreRules>());
d->grammar = belr::GrammarLoader::get().load(CPIM_GRAMMAR);
if (!d->grammar)
lFatal() << "Unable to build CPIM grammar.";
lFatal() << "Unable to load CPIM grammar.";
}
// -----------------------------------------------------------------------------
......
/*
* cpim-grammar.cpp
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "cpim-grammar.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
static const char *grammar =
// See: https://tools.ietf.org/html/rfc3862
R"==GRAMMAR==(
Message = Headers CRLF Headers CRLF [Headers CRLF]
Headers = *Header
......@@ -93,10 +65,7 @@ UTF8-multi = %xC0-DF %x80-BF
/ %xFC-FD %x80-BF %x80-BF %x80-BF %x80-BF %x80-BF
URI = absoluteURI
)==GRAMMAR=="
// See: https://tools.ietf.org/html/rfc2396 & https://tools.ietf.org/html/rfc2732
R"==GRAMMAR==(
absoluteURI = scheme ":" ( hier-part / opaque-part )
relativeURI = ( net-path / abs-path / rel-path ) [ "?" query ]
......@@ -153,17 +122,11 @@ mark = "-" / "_" / "." / "!" / "~" / "*" / "'" / "(" / ")"
escaped = "%" HEXDIG HEXDIG
alphanum = ALPHA / DIGIT
)==GRAMMAR=="
// See: https://tools.ietf.org/html/rfc3066
R"==GRAMMAR==(
Language-Tag = Primary-subtag *( "-" Subtag )
Primary-subtag = 1*8ALPHA
Subtag = 1*8(ALPHA / DIGIT)
)==GRAMMAR=="
// See: https://tools.ietf.org/html/rfc3339
R"==GRAMMAR==(
date-fullyear = 4DIGIT
date-month = 2DIGIT
date-mday = 2DIGIT
......@@ -182,10 +145,3 @@ full-date = date-fullyear "-" date-month "-" date-mday
full-time = partial-time time-offset
date-time = full-date "T" full-time
)==GRAMMAR==";
const char *Cpim::getGrammar () {
return grammar;
}
LINPHONE_END_NAMESPACE
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