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

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 
28 class Akonadi::SocialNetworkAttributesPrivate
29 {
30  public:
31  QVariantMap attributes;
32 };
33 
34 Akonadi::SocialNetworkAttributes::SocialNetworkAttributes()
35  : d( new SocialNetworkAttributesPrivate() )
36 {
37 }
38 
39 Akonadi::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 
51 Akonadi::SocialNetworkAttributes::~SocialNetworkAttributes()
52 {
53  delete d;
54 }
55 
56 void Akonadi::SocialNetworkAttributes::deserialize( const QByteArray &data )
57 {
58  QJson::Parser parser;
59  d->attributes = parser.parse(data).toMap();
60 }
61 
62 QByteArray 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 
72 Akonadi::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 
82 QByteArray Akonadi::SocialNetworkAttributes::type() const
83 {
84  return QByteArray( "socialattributes" );
85 }
86 
87 QString Akonadi::SocialNetworkAttributes::userName() const
88 {
89  return d->attributes[QLatin1String( "userName" )].toString();
90 }
91 
92 QString Akonadi::SocialNetworkAttributes::networkName() const
93 {
94  return d->attributes[QLatin1String( "networkName" )].toString();
95 }
96 
97 bool Akonadi::SocialNetworkAttributes::canPublish() const
98 {
99  return d->attributes[QLatin1String( "canPublish" )].toBool();
100 }
101 
102 uint Akonadi::SocialNetworkAttributes::maxPostLength() const
103 {
104  return d->attributes[QLatin1String( "maxPostLength" )].toUInt();
105 }
Akonadi::SocialFeedItem::userName
QString userName() const
Definition: socialfeeditem.cpp:153
Akonadi::Attribute
Provides interface for custom attributes for Entity.
Definition: attribute.h:138
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:28 by doxygen 1.8.7 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
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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