Commit 7d118981 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Use getInstance from BelCardParser

parent 12657d5a
...@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
struct _LinphoneVcardContext { struct _LinphoneVcardContext {
belcard::BelCardParser *parser; shared_ptr<belcard::BelCardParser> parser;
void *user_data; void *user_data;
}; };
...@@ -46,14 +46,14 @@ extern "C" { ...@@ -46,14 +46,14 @@ extern "C" {
LinphoneVcardContext* linphone_vcard_context_new(void) { LinphoneVcardContext* linphone_vcard_context_new(void) {
LinphoneVcardContext* context = ms_new0(LinphoneVcardContext, 1); LinphoneVcardContext* context = ms_new0(LinphoneVcardContext, 1);
context->parser = new belcard::BelCardParser(); context->parser = belcard::BelCardParser::getInstance();
context->user_data = NULL; context->user_data = NULL;
return context; return context;
} }
void linphone_vcard_context_destroy(LinphoneVcardContext *context) { void linphone_vcard_context_destroy(LinphoneVcardContext *context) {
if (context) { if (context) {
if (context->parser) delete context->parser; context->parser = nullptr;
ms_free(context); ms_free(context);
} }
} }
...@@ -92,7 +92,7 @@ bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardConte ...@@ -92,7 +92,7 @@ bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardConte
bctbx_list_t *result = NULL; bctbx_list_t *result = NULL;
if (context && filename) { if (context && filename) {
if (!context->parser) { if (!context->parser) {
context->parser = new belcard::BelCardParser(); context->parser = belcard::BelCardParser::getInstance();
} }
shared_ptr<belcard::BelCardList> belCards = context->parser->parseFile(filename); shared_ptr<belcard::BelCardList> belCards = context->parser->parseFile(filename);
if (belCards) { if (belCards) {
...@@ -110,7 +110,7 @@ bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardCon ...@@ -110,7 +110,7 @@ bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardCon
bctbx_list_t *result = NULL; bctbx_list_t *result = NULL;
if (context && buffer) { if (context && buffer) {
if (!context->parser) { if (!context->parser) {
context->parser = new belcard::BelCardParser(); context->parser = belcard::BelCardParser::getInstance();
} }
shared_ptr<belcard::BelCardList> belCards = context->parser->parse(buffer); shared_ptr<belcard::BelCardList> belCards = context->parser->parse(buffer);
if (belCards) { if (belCards) {
...@@ -128,7 +128,7 @@ LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext ...@@ -128,7 +128,7 @@ LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext
LinphoneVcard *vCard = NULL; LinphoneVcard *vCard = NULL;
if (context && buffer) { if (context && buffer) {
if (!context->parser) { if (!context->parser) {
context->parser = new belcard::BelCardParser(); context->parser = belcard::BelCardParser::getInstance();
} }
shared_ptr<belcard::BelCard> belCard = context->parser->parseOne(buffer); shared_ptr<belcard::BelCard> belCard = context->parser->parseOne(buffer);
if (belCard) { if (belCard) {
......
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