Skip to content

Commit

Permalink
[buteo-syncml] Align with libwbxml 0.11.6 API. Contributes to JB#46819
Browse files Browse the repository at this point in the history
Upgrading from libwbxml 0.10.8 to 0.11.6, the API changed slightly and
this commit updates the code to align with these changes to libwbxml.
Most notably, wbxml_conv_wbxml2xml_withlen() has been deprecated, and so
has been replaced with a call to wbxml_conv_wbxml2xml_run().
  • Loading branch information
llewelld committed Feb 11, 2020
1 parent 2e5199f commit 6d05ea5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion rpm/buteo-syncml-qt5.spec
Expand Up @@ -12,7 +12,7 @@ BuildRequires: pkgconfig(Qt5XmlPatterns)
BuildRequires: pkgconfig(Qt5Xml)
BuildRequires: pkgconfig(Qt5Sql)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(libwbxml2)
BuildRequires: pkgconfig(libwbxml2) >= 0.11.6
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(openobex)
BuildRequires: pkgconfig(buteosyncfw5) >= 0.6.24
Expand Down
5 changes: 3 additions & 2 deletions src/src.pro
Expand Up @@ -16,7 +16,8 @@ CONFIG += dll \
create_prl \
link_pkgconfig

PKGCONFIG = buteosyncfw5
PKGCONFIG = buteosyncfw5 \
libwbxml2

INCLUDEPATH += . \
syncelements \
Expand Down Expand Up @@ -114,7 +115,7 @@ HEADERS += SyncItem.h \
OTHER_FILES += config/meego-syncml-conf.xsd \
config/meego-syncml-conf.xml

LIBS += -lsqlite3 -lwbxml2 -lopenobex
LIBS += -lsqlite3 -lopenobex

QTDIR = /usr/lib/qt5

Expand Down
30 changes: 20 additions & 10 deletions src/transport/LibWbXML2Encoder.cpp
Expand Up @@ -35,6 +35,7 @@

#include "SyncMLMessage.h"
#include "datatypes.h"
#include <wbxml/wbxml_encoder.h>

#include "LogMacros.h"

Expand Down Expand Up @@ -174,19 +175,28 @@ bool LibWbXML2Encoder::decodeFromWbXML( const QByteArray& aWbXMLDocument, QByteA

LOG_DEBUG("Converting WbXML to XML");

WBXMLGenXMLParams params;
params.lang = WBXML_LANG_UNKNOWN;
WBXMLError error = WBXML_OK;
WBXMLConvWBXML2XML *conv = NULL;

error = wbxml_conv_wbxml2xml_create( &conv );
if (error != WBXML_OK) {
LOG_DEBUG("WbXML to XML conversion failed: " << (const char* )wbxml_errors_string( error ) );
return false;
}

wbxml_conv_wbxml2xml_set_language( conv, WBXML_LANG_UNKNOWN );

if( aPrettyPrint ) {
params.gen_type = WBXML_GEN_XML_INDENT;
params.indent = 3;
wbxml_conv_wbxml2xml_set_gen_type( conv, WBXML_GEN_XML_INDENT );
wbxml_conv_wbxml2xml_set_indent( conv, 3 );
}
else {
params.gen_type = WBXML_GEN_XML_COMPACT;
params.indent = 0;
wbxml_conv_wbxml2xml_set_gen_type( conv, WBXML_GEN_XML_COMPACT );
wbxml_conv_wbxml2xml_set_indent( conv, 0 );
}

params.keep_ignorable_ws = TRUE;
wbxml_conv_wbxml2xml_enable_preserve_whitespaces( conv );
wbxml_conv_wbxml2xml_set_charset( conv, WBXML_CHARSET_UNKNOWN );

const WB_UTINY* wbxml = reinterpret_cast<const WB_UTINY*>( aWbXMLDocument.constData() );
WB_ULONG wbxml_len = aWbXMLDocument.size();
Expand All @@ -196,9 +206,9 @@ bool LibWbXML2Encoder::decodeFromWbXML( const QByteArray& aWbXMLDocument, QByteA

LOG_DEBUG( "WbXML buffer size: " << wbxml_len );

WBXMLError error = wbxml_conv_wbxml2xml_withlen( const_cast<WB_UTINY*>( wbxml ), wbxml_len,
&xml, &xml_len,
&params );
error = wbxml_conv_wbxml2xml_run( conv, const_cast<WB_UTINY*>( wbxml ), wbxml_len,
&xml, &xml_len);
wbxml_conv_wbxml2xml_destroy(conv);

QByteArray data;

Expand Down
6 changes: 5 additions & 1 deletion src/transport/LibWbXML2Encoder.h
Expand Up @@ -39,10 +39,14 @@
// libwbxml2-0 includes wbxml_config.h in wbxml.h.
#define WBXML_SUPPORT_SYNCML

#include <wbxml.h>
#include <wbxml/wbxml.h>

#include "SyncAgentConsts.h"

// Defined opaquely to match the full definitions in <wbxml/wbxml_tree.h>
typedef struct WBXMLTree_s WBXMLTree;
typedef struct WBXMLTreeNode_s WBXMLTreeNode;

namespace DataSync {

class SyncMLCmdObject;
Expand Down
3 changes: 2 additions & 1 deletion tests_meego/tests_common.pri
Expand Up @@ -14,7 +14,8 @@ CONFIG += link_prl link_pkgconfig
# So if remember to compile them when debugging
LIBS += -L$${OUT_PWD}/$${tests_subdir_r}/../src/

PKGCONFIG += buteosyncfw5
PKGCONFIG += buteosyncfw5 \
libwbxml2
LIBS += -lbuteosyncml5

# This is needed to avoid adding the /usr/lib link directory before the
Expand Down
1 change: 1 addition & 0 deletions tests_meego/tests_meego.pro
@@ -1,6 +1,7 @@
include(tests_common.pri)
TEMPLATE = subdirs
CONFIG += ordered
PKGCONFIG = libwbxml2
SUBDIRS = \
TestUtils.pro \
generaltests.pro \
Expand Down

0 comments on commit 6d05ea5

Please sign in to comment.