/** This file is a part of rexy's matrix client Copyright (C) 2019 rexy712 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ #include "matrix/syncer.hpp" #include "raii/static_string.hpp" #include "raii/rjp_ptr.hpp" #include "raii/util.hpp" namespace matrix{ syncer::syncer(const std::shared_ptr& ses): connection(ses){} sync::response syncer::sync(size_t timeout){ raii::string reply = _get_curl(m_ses->urls.sync(m_ses->homeserver, m_ses->access_token, m_next_batch, raii::itostr(timeout))); if(!reply) return {nullptr}; raii::rjp_ptr root(rjp_parse(reply)); if(!root) return reply; RJP_search_res res = rjp_search_member(root.get(), "next_batch", 0); if(!res.value) return reply; m_next_batch = res.value; return sync::response(root.release()); } }