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

akonadi/kmime

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
  • kmime
messagethreadingattribute.cpp
1 /*
2  Copyright (c) 2008 Volker Krause <vkrause@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "messagethreadingattribute.h"
21 
22 using namespace Akonadi;
23 
24 class Akonadi::MessageThreadingAttribute::Private
25 {
26 public:
27  QList<Item::Id> perfectParents;
28  QList<Item::Id> unperfectParents;
29  QList<Item::Id> subjectParents;
30 };
31 
32 MessageThreadingAttribute::MessageThreadingAttribute()
33  : d(new Private)
34 {
35 }
36 
37 MessageThreadingAttribute::MessageThreadingAttribute(const MessageThreadingAttribute &other)
38  : Attribute(other)
39  , d(new Private(*(other.d)))
40 {
41 }
42 
43 MessageThreadingAttribute::~ MessageThreadingAttribute()
44 {
45  delete d;
46 }
47 
48 QByteArray MessageThreadingAttribute::type() const
49 {
50  static const QByteArray sType( "MESSAGETHREADING" );
51  return sType;
52 }
53 
54 MessageThreadingAttribute *MessageThreadingAttribute::clone() const
55 {
56  return new MessageThreadingAttribute(*this);
57 }
58 
59 QByteArray MessageThreadingAttribute::serialized() const
60 {
61  QByteArray rv;
62  foreach (const Item::Id id, d->perfectParents) {
63  rv += QByteArray::number(id) + ',';
64  }
65  if (!d->perfectParents.isEmpty()) {
66  rv[rv.size() - 1] = ';';
67  } else {
68  rv += ';';
69  }
70  foreach (const Item::Id id, d->unperfectParents) {
71  rv += QByteArray::number(id) + ',';
72  }
73  if (!d->unperfectParents.isEmpty()) {
74  rv[rv.size() - 1] = ';';
75  } else {
76  rv += ';';
77  }
78  foreach (const Item::Id id, d->subjectParents) {
79  rv += QByteArray::number(id) + ',';
80  }
81  if (!d->perfectParents.isEmpty()) {
82  rv.chop(1);
83  }
84 
85  return rv;
86 }
87 
88 static void parseIdList(const QByteArray &data, QList<Item::Id> &result)
89 {
90  bool ok = false;
91  foreach (const QByteArray &s, data.split(',')) {
92  Item::Id id = s.toLongLong(&ok);
93  if (!ok) {
94  continue;
95  }
96  result << id;
97  }
98 }
99 
100 void MessageThreadingAttribute::deserialize(const QByteArray &data)
101 {
102  d->perfectParents.clear();
103  d->unperfectParents.clear();
104  d->subjectParents.clear();
105 
106  QList<QByteArray> lists = data.split(';');
107  if (lists.size() != 3) {
108  return;
109  }
110 
111  parseIdList(lists[0], d->perfectParents);
112  parseIdList(lists[1], d->unperfectParents);
113  parseIdList(lists[2], d->subjectParents);
114 }
115 
116 QList< Item::Id > MessageThreadingAttribute::perfectParents() const
117 {
118  return d->perfectParents;
119 }
120 
121 void MessageThreadingAttribute::setPerfectParents(const QList< Item::Id > &parents)
122 {
123  d->perfectParents = parents;
124 }
125 
126 QList< Item::Id > MessageThreadingAttribute::unperfectParents() const
127 {
128  return d->unperfectParents;
129 }
130 
131 void MessageThreadingAttribute::setUnperfectParents(const QList< Item::Id > &parents)
132 {
133  d->unperfectParents = parents;
134 }
135 
136 QList< Item::Id > MessageThreadingAttribute::subjectParents() const
137 {
138  return d->subjectParents;
139 }
140 
141 void MessageThreadingAttribute::setSubjectParents(const QList< Item::Id > &parents)
142 {
143  d->subjectParents = parents;
144 }
Akonadi::MessageThreadingAttribute::setUnperfectParents
void setUnperfectParents(const QList< Item::Id > &parents)
Sets the list of non-perfect parent message ids.
Definition: messagethreadingattribute.cpp:131
Akonadi::MessageThreadingAttribute::subjectParents
QList< Item::Id > subjectParents() const
Returns the list of possible parent message ids based on analyzing the subject.
Definition: messagethreadingattribute.cpp:136
QByteArray::split
QList< QByteArray > split(char sep) const
QByteArray
QByteArray::chop
void chop(int n)
QList::size
int size() const
Akonadi::MessageThreadingAttribute
Message threading information.
Definition: messagethreadingattribute.h:34
Akonadi::MessageThreadingAttribute::~MessageThreadingAttribute
~MessageThreadingAttribute()
Destructor.
Definition: messagethreadingattribute.cpp:43
Akonadi::MessageThreadingAttribute::setPerfectParents
void setPerfectParents(const QList< Item::Id > &parents)
Sets the list of perfect parent message ids.
Definition: messagethreadingattribute.cpp:121
Akonadi::MessageThreadingAttribute::perfectParents
QList< Item::Id > perfectParents() const
Returns the list of perfect parent message ids.
Definition: messagethreadingattribute.cpp:116
QByteArray::number
QByteArray number(int n, int base)
Akonadi::MessageThreadingAttribute::unperfectParents
QList< Item::Id > unperfectParents() const
Returns the list of non-perfect parent message ids.
Definition: messagethreadingattribute.cpp:126
QList< Item::Id >
QByteArray::toLongLong
qlonglong toLongLong(bool *ok, int base) const
Akonadi::MessageThreadingAttribute::MessageThreadingAttribute
MessageThreadingAttribute()
Creates an empty threading attribute.
Definition: messagethreadingattribute.cpp:32
Akonadi::MessageThreadingAttribute::setSubjectParents
void setSubjectParents(const QList< Item::Id > &parents)
Sets the list of possible parent message ids based on analyzing the subject.
Definition: messagethreadingattribute.cpp:141
QByteArray::size
int size() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:24 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi/kmime

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

kdepimlibs API Reference

Skip menu "kdepimlibs 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

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