KIMAP2

searchjob.h
1 /*
2  Copyright (c) 2009 Andras Mantia <[email protected]>
3  Copyright (c) 2014 Christian Mollekopf <[email protected]>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #ifndef KIMAP2_SEARCHJOB_H
22 #define KIMAP2_SEARCHJOB_H
23 
24 #include "kimap2_export.h"
25 
26 #include "job.h"
27 #include <QSharedPointer>
28 
29 class QDate;
30 
31 namespace KIMAP2
32 {
33 
34 class ImapSet;
35 
36 class Session;
37 struct Message;
38 class SearchJobPrivate;
39 
40 /**
41  * A query term.
42  * Refer to the IMAP RFC for the meaning of the individual terms.
43  * @since 4.13
44  */
45 class KIMAP2_EXPORT Term
46 {
47 public:
48  enum Relation {
49  And,
50  Or
51  };
52 
53  enum SearchKey {
54  All,
55  Bcc,
56  Body,
57  Cc,
58  From,
59  Subject,
60  Text,
61  To,
62  Keyword
63  };
64 
65  enum BooleanSearchKey {
66  New,
67  Old,
68  Recent,
69  Seen,
70  Draft,
71  Deleted,
72  Flagged,
73  Answered
74  };
75 
76  enum DateSearchKey {
77  Before,
78  On,
79  Since,
80  SentBefore,
81  SentOn,
82  SentSince
83  };
84  enum NumberSearchKey {
85  Larger,
86  Smaller
87  };
88  enum SequenceSearchKey {
89  Uid,
90  SequenceNumber
91  };
92 
93  Term();
94  ~Term() = default; // silence clazy rule of three warning
95  Term(Relation relation, const QVector<Term> &subterms);
96  Term(SearchKey key, const QString &value);
97  Term(BooleanSearchKey key);
98  Term(DateSearchKey key, const QDate &date);
99  Term(NumberSearchKey key, int value);
100  Term(SequenceSearchKey key, const KIMAP2::ImapSet &);
101  Term(const QString &header, const QString &value);
102 
103  Term(const Term &other);
104 
105  Term &operator=(const Term &other);
106  bool operator==(const Term &other) const;
107 
108  bool isNull() const;
109 
110  Term &setFuzzy(bool fuzzy);
111  Term &setNegated(bool negated);
112 
113  QByteArray serialize() const;
114 
115 private:
116  class Private;
118 };
119 
120 class KIMAP2_EXPORT SearchJob : public Job
121 {
122  Q_OBJECT
123  Q_DECLARE_PRIVATE(SearchJob)
124 
125  friend class SessionPrivate;
126 
127 public:
128  enum SearchLogic {
129  And = 0,
130  Or,
131  Not
132  };
133 
134  enum SearchCriteria {
135  All = 0,
136  Answered,
137  BCC,
138  Before,
139  Body,
140  CC,
141  Deleted,
142  Draft,
143  Flagged,
144  From,
145  Header,
146  Keyword,
147  Larger,
148  New,
149  Old,
150  On,
151  Recent,
152  Seen,
153  SentBefore,
154  SentOn,
155  SentSince,
156  Since,
157  Smaller,
158  Subject,
159  Text,
160  To,
161  Uid,
162  Unanswered,
163  Undeleted,
164  Undraft,
165  Unflagged,
166  Unkeyword,
167  Unseen
168  };
169 
170  explicit SearchJob(Session *session);
171  virtual ~SearchJob();
172 
173  void setUidBased(bool uidBased);
174  bool isUidBased() const;
175 
176  void setCharset(const QByteArray &charSet);
177  QByteArray charset() const;
178 
179  /**
180  * Get the search result, as a list of sequence numbers or UIDs, based on the isUidBased status
181  * @return the found items
182  * @since 4.6
183  */
184  QVector<qint64> results() const;
185 
186  /**
187  * Sets the search term.
188  * @param term The search term.
189  * @since 4.13
190  */
191  void setTerm(const Term &);
192 
193 protected:
194  void doStart() Q_DECL_OVERRIDE;
195  void handleResponse(const Message &response) Q_DECL_OVERRIDE;
196 };
197 
198 }
199 
200 #endif
Subject
Represents a set of natural numbers (1->∞) in a as compact as possible form.
Definition: imapset.h:141
A query term.
Definition: searchjob.h:45
Definition: acl.cpp:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Nov 29 2021 23:00:39 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.