• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
  • socialutils
socialnetworkattributes.cpp
1/*
2 Copyright (C) 2012 Martin Klapetek <martin.klapetek@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#include "socialnetworkattributes.h"
20
21#include "akonadi/config-akonadi.h"
22
23#include <QString>
24
25#include <qjson/serializer.h>
26#include <qjson/parser.h>
27
28class Akonadi::SocialNetworkAttributesPrivate
29{
30 public:
31 QVariantMap attributes;
32};
33
34Akonadi::SocialNetworkAttributes::SocialNetworkAttributes()
35 : d( new SocialNetworkAttributesPrivate() )
36{
37}
38
39Akonadi::SocialNetworkAttributes::SocialNetworkAttributes( const QString &userName,
40 const QString &networkName,
41 bool canPublish,
42 uint maxPostLength )
43 : d( new SocialNetworkAttributesPrivate() )
44{
45 d->attributes[QLatin1String( "userName" )] = userName;
46 d->attributes[QLatin1String( "networkName" )] = networkName;
47 d->attributes[QLatin1String( "canPublish" )] = canPublish;
48 d->attributes[QLatin1String( "maxPostLength" )] = maxPostLength;
49}
50
51Akonadi::SocialNetworkAttributes::~SocialNetworkAttributes()
52{
53 delete d;
54}
55
56void Akonadi::SocialNetworkAttributes::deserialize( const QByteArray &data )
57{
58 QJson::Parser parser;
59 d->attributes = parser.parse(data).toMap();
60}
61
62QByteArray Akonadi::SocialNetworkAttributes::serialized() const
63{
64 QJson::Serializer serializer;
65#if !defined( USE_QJSON_0_8 )
66 return serializer.serialize( d->attributes );
67#else
68 return serializer.serialize( d->attributes, 0 );
69#endif
70}
71
72Akonadi::Attribute *Akonadi::SocialNetworkAttributes::clone() const
73{
74 return
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() );
80}
81
82QByteArray Akonadi::SocialNetworkAttributes::type() const
83{
84 static const QByteArray sType( "socialattributes" );
85 return sType;
86}
87
88QString Akonadi::SocialNetworkAttributes::userName() const
89{
90 return d->attributes[QLatin1String( "userName" )].toString();
91}
92
93QString Akonadi::SocialNetworkAttributes::networkName() const
94{
95 return d->attributes[QLatin1String( "networkName" )].toString();
96}
97
98bool Akonadi::SocialNetworkAttributes::canPublish() const
99{
100 return d->attributes[QLatin1String( "canPublish" )].toBool();
101}
102
103uint Akonadi::SocialNetworkAttributes::maxPostLength() const
104{
105 return d->attributes[QLatin1String( "maxPostLength" )].toUInt();
106}
Akonadi::Attribute
Provides interface for custom attributes for Entity.
Definition attribute.h:139
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal