19 #include "socialnetworkattributes.h"
21 #include "akonadi/config-akonadi.h"
25 #include <qjson/serializer.h>
26 #include <qjson/parser.h>
28 class Akonadi::SocialNetworkAttributesPrivate
31 QVariantMap attributes;
34 Akonadi::SocialNetworkAttributes::SocialNetworkAttributes()
35 : d( new SocialNetworkAttributesPrivate() )
39 Akonadi::SocialNetworkAttributes::SocialNetworkAttributes(
const QString &userName,
40 const QString &networkName,
43 : d( new SocialNetworkAttributesPrivate() )
45 d->attributes[QLatin1String(
"userName" )] =
userName;
46 d->attributes[QLatin1String(
"networkName" )] = networkName;
47 d->attributes[QLatin1String(
"canPublish" )] = canPublish;
48 d->attributes[QLatin1String(
"maxPostLength" )] = maxPostLength;
51 Akonadi::SocialNetworkAttributes::~SocialNetworkAttributes()
56 void Akonadi::SocialNetworkAttributes::deserialize(
const QByteArray &data )
59 d->attributes = parser.parse(data).toMap();
62 QByteArray Akonadi::SocialNetworkAttributes::serialized()
const
64 QJson::Serializer serializer;
65 #if !defined( USE_QJSON_0_8 )
66 return serializer.serialize( d->attributes );
68 return serializer.serialize( d->attributes, 0 );
75 new SocialNetworkAttributes(
76 d->attributes[QLatin1String(
"userName" )].toString(),
77 d->attributes[QLatin1String(
"networkName" )].toString(),
78 d->attributes[QLatin1String(
"canPublish" )].toBool(),
79 d->attributes[QLatin1String(
"maxPostLength" )].toUInt() );
82 QByteArray Akonadi::SocialNetworkAttributes::type()
const
84 return QByteArray(
"socialattributes" );
87 QString Akonadi::SocialNetworkAttributes::userName()
const
89 return d->attributes[QLatin1String(
"userName" )].toString();
92 QString Akonadi::SocialNetworkAttributes::networkName()
const
94 return d->attributes[QLatin1String(
"networkName" )].toString();
97 bool Akonadi::SocialNetworkAttributes::canPublish()
const
99 return d->attributes[QLatin1String(
"canPublish" )].toBool();
102 uint Akonadi::SocialNetworkAttributes::maxPostLength()
const
104 return d->attributes[QLatin1String(
"maxPostLength" )].toUInt();
Provides interface for custom attributes for Entity.