diff --git a/sflphone-common/src/config/yamlemitter.cpp b/sflphone-common/src/config/yamlemitter.cpp index 3b6ba5c0c35d50e2e6d6b8a0071239f9d380a424..0f07f777538417112d7c1f6723238ef5f559e3cd 100644 --- a/sflphone-common/src/config/yamlemitter.cpp +++ b/sflphone-common/src/config/yamlemitter.cpp @@ -47,7 +47,8 @@ YamlEmitter::~YamlEmitter() void YamlEmitter::open() { - fd = fopen (filename.c_str(), "wb"); + + fd = fopen (filename.c_str(), "w"); if (!fd) throw YamlEmitterException ("Could not open file descriptor"); @@ -55,12 +56,13 @@ void YamlEmitter::open() if (!yaml_emitter_initialize (&emitter)) throw YamlEmitterException ("Could not initialize emitter"); - // Use unicode format + // Allows unescaped unicode characters yaml_emitter_set_unicode (&emitter, 1); yaml_emitter_set_output_file (&emitter, fd); - yaml_document_initialize (&document, NULL, NULL, NULL, 0, 0); + if (!yaml_document_initialize (&document, NULL, NULL, NULL, 0, 0)) + throw YamlEmitterException ("Could not initialize yaml document while saving configuration"); // Init the main configuration mapping if ( (topLevelMapping = yaml_document_add_mapping (&document, NULL, YAML_BLOCK_MAPPING_STYLE)) == 0) @@ -74,13 +76,13 @@ void YamlEmitter::close() if (!fd) throw YamlEmitterException ("File descriptor not valid"); - fclose (fd); - /* - if(!fclose(fd)) - throw YamlEmitterException("Error closing file descriptor"); - */ - yaml_document_delete (&document); + if (fclose (fd)) + throw YamlEmitterException ("Error closing file descriptor"); + + + _debug ("Config: Configuration file closed successfully"); + } void YamlEmitter::read() {} @@ -92,7 +94,9 @@ void YamlEmitter::write() void YamlEmitter::serializeData() { - yaml_emitter_dump (&emitter, &document); + // Document object is destroyed once its content is emitted + if (!yaml_emitter_dump (&emitter, &document)) + throw YamlEmitterException ("Error while emitting configuration yaml document"); } diff --git a/sflphone-common/src/config/yamlparser.cpp b/sflphone-common/src/config/yamlparser.cpp index b4d8c5de47ac3afd76f36f778bbffa970b7ff614..90b46c8470c39bdab5774ddd84578b4b647dc5aa 100644 --- a/sflphone-common/src/config/yamlparser.cpp +++ b/sflphone-common/src/config/yamlparser.cpp @@ -79,9 +79,9 @@ void YamlParser::close() if (!fd) throw YamlParserException ("File descriptor not valid"); - fclose (fd); - // if(!fclose(fd)) - // throw YamlParserException("Error closing file descriptor"); + // fclose (fd); + if (fclose (fd)) + throw YamlParserException ("Error closing file descriptor"); } diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 5f48c1ae0df67966d56a954394dae106545c5a19..8bbc44abbce67a2dde7a19e3952ec0d170913136 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -166,6 +166,8 @@ void ManagerImpl::init () // Init the instant messaging module _imModule->init(); + + } void ManagerImpl::terminate ()