This is a straight conversion, and does not make any attempt to be more asynchronous, as I don't know the protocol between them, but I expect there are ways to reduce the blocking.
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/247/
/*
* purple
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <https://www.gnu.org/licenses/>.