Kgapi

contact.h
1 /*
2  * This file is part of LibKGAPI library
3  *
4  * SPDX-FileCopyrightText: 2013 Daniel Vrátil <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7  */
8 
9 #ifndef LIBKGAPI2_CONTACT_H
10 #define LIBKGAPI2_CONTACT_H
11 
12 #include "object.h"
13 #include "types.h"
14 #include "kgapicontacts_export.h"
15 
16 #include <KContacts/Addressee>
17 #include <QDateTime>
18 
19 namespace KGAPI2
20 {
21 
22 /**
23  * @brief Represents a single contact
24  *
25  * @author Daniel Vrátil <[email protected]>
26  * @since 0.1
27  */
28 class KGAPICONTACTS_EXPORT Contact : public KGAPI2::Object,
30 {
31  public:
32 
33  /**
34  * @brief Instant Messaging Protocols
35  */
36  enum IMProtocol {
37  Jabber,
38  ICQ,
39  GoogleTalk,
40  QQ,
41  Skype,
42  Yahoo,
43  MSN,
44  AIM,
45  Other
46  };
47 
48  /**
49  * @brief Constructor
50  */
51  Contact();
52 
53  /**
54  * @brief Copy constructor
55  */
56  explicit Contact(const KContacts::Addressee &other);
57 
58  /**
59  * @brief Copy constructor
60  */
61  Contact(const Contact &other);
62 
63 
64  /**
65  * @brief Destructor
66  */
67  ~Contact();
68 
69  bool operator==(const Contact &other) const;
70 
71  /**
72  * @brief Marks contact as deleted
73  *
74  * @param deleted
75  */
76  void setDeleted(bool deleted);
77 
78  /**
79  * @brief Returns whether contact is deleted
80  */
81  bool deleted() const;
82 
83  /**
84  * Sets URL of contact photo.
85  *
86  * @param photoUrl
87  */
88  void setPhotoUrl(const QString &photoUrl);
89 
90  /**
91  * Sets URL of contact photo.
92  * @overload setPhotoUrl(QString)
93  */
94  void setPhotoUrl(const QUrl &photoUrl);
95 
96  /**
97  * @brief Returns URL of contact photo.
98  */
99  QUrl photoUrl() const;
100 
101  /**
102  * @brief Sets date and time when the contact was created.
103  *
104  * @param created
105  */
106  void setCreated(const QDateTime &created);
107 
108  /**
109  * @brief Returns date and time when the contact was created.
110  */
111  QDateTime created() const;
112 
113  /**
114  * @brief Sets date and time or last modification
115  *
116  * @param updated
117  */
118  void setUpdated(const QDateTime &updated);
119 
120  /**
121  * @brief Returns date and time of last modification
122  */
123  QDateTime updated() const;
124 
125  /**
126  * @brief Set list of groups the contact is member of.
127  *
128  * @param groups
129  */
130  void setGroups(const QStringList &groups);
131 
132  /**
133  * @brief Adds a group the contact is member of
134  *
135  * @param group
136  */
137  void addGroup(const QString &group);
138 
139  /**
140  * @brief Remove contact from a group.
141  *
142  * Use this method to remove contact from groups, instead
143  * of setGroups(QStringList()). To clear group membership
144  * use clearGroups()
145  *
146  * @param group
147  */
148  void removeGroup(const QString &group);
149 
150  /**
151  * @brief Removes contact from all groups it's member of.
152  */
153  void clearGroups();
154 
155  /**
156  * @brief Returns list of groups the contact is member of.
157  */
158  QStringList groups() const;
159 
160  /**
161  * @brief Returns whether contact has been removed from the @p group or not.
162  *
163  * @param group
164  */
165  bool groupIsDeleted(const QString &group) const;
166 
167  /**
168  * @brief Converts IMProtocol to Google Scheme URL.
169  *
170  * @param protocol
171  */
172  static QString IMProtocolToScheme(const IMProtocol protocol);
173 
174  /**
175  * @brief Converts Google Scheme URL to string with protocol name.
176  *
177  * @param scheme
178  */
179  static QString IMSchemeToProtocolName(const QString &scheme);
180 
181  /**
182  * @brief Converts string with protocol name to Google Scheme URL.
183  *
184  * @param protocolName
185  */
186  static QString IMProtocolNameToScheme(const QString &protocolName);
187 
188  /**
189  * @brief Converts Google Scheme URL to IMProtocol.
190  *
191  * @param scheme
192  */
193  static IMProtocol IMSchemeToProtocol(const QString &scheme);
194 
195  /**
196  * @brief Converts phone number type to Google Scheme URL.
197  *
198  * @param type
199  */
200  static QString phoneTypeToScheme(const KContacts::PhoneNumber::Type type);
201 
202  /**
203  * @brief Converts Google Scheme URL to phone number type.
204  *
205  * @param scheme
206  */
207  static KContacts::PhoneNumber::Type phoneSchemeToType(const QString &scheme);
208 
209  /**
210  * @brief Converts address type to Google Scheme URL.
211  *
212  * @param type
213  * @param primary
214  */
215  static QString addressTypeToScheme(const KContacts::Address::Type type, bool *primary = nullptr);
216 
217  /**
218  * @brief Converts Google Scheme UrL to address type.
219  *
220  * @param scheme
221  * @param primary
222  */
223  static KContacts::Address::Type addressSchemeToType(const QString &scheme, bool primary = false);
224 
225  /**
226  * @brief Contacts Google scheme URL to email type.
227  */
228  static QString emailSchemeToProtocolName(const QString &scheme);
229 
230  private:
231  class Private;
232  Private * const d;
233 
234 };
235 
236 } // namespace KGAPI2
237 
238 #endif /* LIBKGAPI2_CONTACT_H */
Base class for all objects.
Definition: object.h:31
IMProtocol
Instant Messaging Protocols.
Definition: contact.h:36
Represents a single contact.
Definition: contact.h:28
A job to fetch a single map tile described by a StaticMapUrl.
Definition: blog.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Mar 3 2021 00:10:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.