1 /*
2  * Copyright (C) 2008-2021 The QXmpp developers
3  *
4  * Author:
5  *  Manjeet Dahiya
6  *
7  * Source:
8  *  https://github.com/qxmpp-project/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 #ifndef QXMPPVCARDMANAGER_H
25 #define QXMPPVCARDMANAGER_H
26 
27 #include "QXmppClientExtension.h"
28 
29 class QXmppVCardIq;
30 class QXmppVCardManagerPrivate;
31 
32 ///
33 /// \brief The QXmppVCardManager class gets/sets XMPP vCards. It is an
34 /// implementation of \xep{0054}: vcard-temp.
35 ///
36 /// \note Its object should not be created using its constructor. Instead
37 /// \c QXmppClient::findExtension<QXmppVCardManager>() should be used to get
38 /// the instantiated object of this class.
39 ///
40 /// <B>Getting vCards of entries in Roster:</B><BR>
41 /// It doesn't store vCards of the JIDs in the roster of connected user. Instead
42 /// client has to request for a particular vCard using requestVCard(). And connect to
43 /// the signal vCardReceived() to get the requested vCard.
44 ///
45 /// <B>Getting vCard of the connected client:</B><BR>
46 /// For getting the vCard of the connected user itself. Client can call requestClientVCard()
47 /// and on the signal clientVCardReceived() it can get its vCard using clientVCard().
48 ///
49 /// <B>Setting vCard of the client:</B><BR>
50 /// Using setClientVCard() client can set its vCard.
51 ///
52 /// \note Client can't set/change vCards of roster entries.
53 ///
54 /// \ingroup Managers
55 ///
56 class QXMPP_EXPORT QXmppVCardManager : public QXmppClientExtension
57 {
58     Q_OBJECT
59 
60 public:
61     QXmppVCardManager();
62     ~QXmppVCardManager() override;
63 
64     QString requestVCard(const QString& bareJid = QString());
65 
66     const QXmppVCardIq& clientVCard() const;
67     void setClientVCard(const QXmppVCardIq&);
68 
69     QString requestClientVCard();
70     bool isClientVCardReceived() const;
71 
72     /// \cond
73     QStringList discoveryFeatures() const override;
74     bool handleStanza(const QDomElement& element) override;
75     /// \endcond
76 
77 Q_SIGNALS:
78     /// This signal is emitted when the requested vCard is received
79     /// after calling the requestVCard() function.
80     void vCardReceived(const QXmppVCardIq&);
81 
82     /// This signal is emitted when the client's vCard is received
83     /// after calling the requestClientVCard() function.
84     void clientVCardReceived();
85 
86 private:
87     QXmppVCardManagerPrivate* d;
88 };
89 
90 #endif  // QXMPPVCARDMANAGER_H
91