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

akonadi/kmime

  • 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  return "MESSAGETHREADING";
51 }
52 
53 MessageThreadingAttribute *MessageThreadingAttribute::clone() const
54 {
55  return new MessageThreadingAttribute(*this);
56 }
57 
58 QByteArray MessageThreadingAttribute::serialized() const
59 {
60  QByteArray rv;
61  foreach (const Item::Id id, d->perfectParents) {
62  rv += QByteArray::number(id) + ',';
63  }
64  if (!d->perfectParents.isEmpty()) {
65  rv[rv.size() - 1] = ';';
66  } else {
67  rv += ';';
68  }
69  foreach (const Item::Id id, d->unperfectParents) {
70  rv += QByteArray::number(id) + ',';
71  }
72  if (!d->unperfectParents.isEmpty()) {
73  rv[rv.size() - 1] = ';';
74  } else {
75  rv += ';';
76  }
77  foreach (const Item::Id id, d->subjectParents) {
78  rv += QByteArray::number(id) + ',';
79  }
80  if (!d->perfectParents.isEmpty()) {
81  rv.chop(1);
82  }
83 
84  return rv;
85 }
86 
87 static void parseIdList(const QByteArray &data, QList<Item::Id> &result)
88 {
89  bool ok = false;
90  foreach (const QByteArray &s, data.split(',')) {
91  Item::Id id = s.toLongLong(&ok);
92  if (!ok) {
93  continue;
94  }
95  result << id;
96  }
97 }
98 
99 void MessageThreadingAttribute::deserialize(const QByteArray &data)
100 {
101  d->perfectParents.clear();
102  d->unperfectParents.clear();
103  d->subjectParents.clear();
104 
105  QList<QByteArray> lists = data.split(';');
106  if (lists.size() != 3) {
107  return;
108  }
109 
110  parseIdList(lists[0], d->perfectParents);
111  parseIdList(lists[1], d->unperfectParents);
112  parseIdList(lists[2], d->subjectParents);
113 }
114 
115 QList< Item::Id > MessageThreadingAttribute::perfectParents() const
116 {
117  return d->perfectParents;
118 }
119 
120 void MessageThreadingAttribute::setPerfectParents(const QList< Item::Id > &parents)
121 {
122  d->perfectParents = parents;
123 }
124 
125 QList< Item::Id > MessageThreadingAttribute::unperfectParents() const
126 {
127  return d->unperfectParents;
128 }
129 
130 void MessageThreadingAttribute::setUnperfectParents(const QList< Item::Id > &parents)
131 {
132  d->unperfectParents = parents;
133 }
134 
135 QList< Item::Id > MessageThreadingAttribute::subjectParents() const
136 {
137  return d->subjectParents;
138 }
139 
140 void MessageThreadingAttribute::setSubjectParents(const QList< Item::Id > &parents)
141 {
142  d->subjectParents = parents;
143 }
Akonadi::MessageThreadingAttribute::setUnperfectParents
void setUnperfectParents(const QList< Item::Id > &parents)
Sets the list of non-perfect parent message ids.
Definition: messagethreadingattribute.cpp:130
Akonadi::MessageThreadingAttribute::subjectParents
QList< Item::Id > subjectParents() const
Returns the list of possible parent message ids based on analyzing the subject.
Definition: messagethreadingattribute.cpp:135
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:120
Akonadi::MessageThreadingAttribute::perfectParents
QList< Item::Id > perfectParents() const
Returns the list of perfect parent message ids.
Definition: messagethreadingattribute.cpp:115
Akonadi::MessageThreadingAttribute::unperfectParents
QList< Item::Id > unperfectParents() const
Returns the list of non-perfect parent message ids.
Definition: messagethreadingattribute.cpp:125
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:140
Akonadi
Definition: addressattribute.h:34
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Thu Nov 13 2014 13:30:13 by doxygen 1.8.8 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 Members
  • File List
  • Related Pages

kdepimlibs-4.14.3 API Reference

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