summaryrefslogtreecommitdiff
path: root/src/xmpp/xmpp_parser.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-03-24 20:31:02 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-03-24 20:31:02 +0100
commitffc820e234ebba39a0f04607f9a0fb044fe31b73 (patch)
tree66ece312b85f89b15e10c9f91444641d8e07c552 /src/xmpp/xmpp_parser.cpp
parente196d2f1f400f5c9634ed42fcbdf5c5fb63a13fb (diff)
downloadbiboumi-ffc820e234ebba39a0f04607f9a0fb044fe31b73.tar.gz
biboumi-ffc820e234ebba39a0f04607f9a0fb044fe31b73.tar.bz2
biboumi-ffc820e234ebba39a0f04607f9a0fb044fe31b73.tar.xz
biboumi-ffc820e234ebba39a0f04607f9a0fb044fe31b73.zip
Reconnected immediately to the XMPP whenever it closes the connection
Diffstat (limited to 'src/xmpp/xmpp_parser.cpp')
-rw-r--r--src/xmpp/xmpp_parser.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/xmpp/xmpp_parser.cpp b/src/xmpp/xmpp_parser.cpp
index 064453e..867648b 100644
--- a/src/xmpp/xmpp_parser.cpp
+++ b/src/xmpp/xmpp_parser.cpp
@@ -31,6 +31,11 @@ XmppParser::XmppParser():
level(0),
current_node(nullptr)
{
+ this->init_xml_parser();
+}
+
+void XmppParser::init_xml_parser()
+{
// Create the expat parser
this->parser = XML_ParserCreateNS("UTF-8", ':');
XML_SetUserData(this->parser, static_cast<void*>(this));
@@ -65,6 +70,16 @@ int XmppParser::parse(const int len, const bool is_final)
return res;
}
+void XmppParser::reset()
+{
+ XML_ParserFree(this->parser);
+ this->init_xml_parser();
+ if (this->current_node)
+ delete this->current_node;
+ this->current_node = nullptr;
+ this->level = 0;
+}
+
void* XmppParser::get_buffer(const size_t size) const
{
return XML_GetBuffer(this->parser, static_cast<int>(size));