| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtContacts module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 2.1 or version 3 as published by the Free |
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| 22 | ** following information to ensure the GNU Lesser General Public License |
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 25 | ** |
| 26 | ** As a special exception, The Qt Company gives you certain additional |
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception |
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| 29 | ** |
| 30 | ** $QT_END_LICENSE$ |
| 31 | ** |
| 32 | ****************************************************************************/ |
| 33 | |
| 34 | #ifndef QDECLARATIVECONTACTONLINEACCOUNT_H |
| 35 | #define QDECLARATIVECONTACTONLINEACCOUNT_H |
| 36 | |
| 37 | #include <QtContacts/qcontactonlineaccount.h> |
| 38 | |
| 39 | #include "qdeclarativecontactdetail_p.h" |
| 40 | |
| 41 | QTCONTACTS_USE_NAMESPACE |
| 42 | |
| 43 | QT_BEGIN_NAMESPACE |
| 44 | |
| 45 | class QDeclarativeContactOnlineAccount : public QDeclarativeContactDetail |
| 46 | { |
| 47 | Q_OBJECT |
| 48 | Q_PROPERTY(QString accountUri READ accountUri WRITE setAccountUri NOTIFY valueChanged) |
| 49 | Q_PROPERTY(QString serviceProvider READ serviceProvider WRITE setServiceProvider NOTIFY valueChanged) |
| 50 | Q_PROPERTY(QStringList capabilities READ capabilities WRITE setCapabilities NOTIFY valueChanged) |
| 51 | Q_PROPERTY(QList<int> subTypes READ subTypes WRITE setSubTypes NOTIFY valueChanged) |
| 52 | Q_PROPERTY(OnlineAccountProtocol protocol READ protocol WRITE setProtocol NOTIFY valueChanged) |
| 53 | Q_ENUMS(FieldType) |
| 54 | Q_ENUMS(OnlineAccountSubType) |
| 55 | Q_ENUMS(OnlineAccountProtocol) |
| 56 | |
| 57 | Q_CLASSINFO("DefaultProperty" , "accountUri" ) |
| 58 | public: |
| 59 | enum FieldType { |
| 60 | AccountUri = QContactOnlineAccount::FieldAccountUri, |
| 61 | ServiceProvider = QContactOnlineAccount::FieldServiceProvider, |
| 62 | Protocol = QContactOnlineAccount::FieldProtocol, |
| 63 | Capabilities = QContactOnlineAccount::FieldCapabilities, |
| 64 | SubTypes = QContactOnlineAccount::FieldSubTypes |
| 65 | }; |
| 66 | |
| 67 | enum OnlineAccountSubType { |
| 68 | Sip = QContactOnlineAccount::SubTypeSip, |
| 69 | SipVoip = QContactOnlineAccount::SubTypeSipVoip, |
| 70 | Impp = QContactOnlineAccount::SubTypeImpp, |
| 71 | VideoShare= QContactOnlineAccount::SubTypeVideoShare |
| 72 | }; |
| 73 | |
| 74 | enum OnlineAccountProtocol { |
| 75 | Unknown = QContactOnlineAccount::ProtocolUnknown, |
| 76 | Aim = QContactOnlineAccount::ProtocolAim, |
| 77 | Icq = QContactOnlineAccount::ProtocolIcq, |
| 78 | Irc = QContactOnlineAccount::ProtocolIrc, |
| 79 | Jabber = QContactOnlineAccount::ProtocolJabber, |
| 80 | Msn = QContactOnlineAccount::ProtocolMsn, |
| 81 | Qq = QContactOnlineAccount::ProtocolQq, |
| 82 | Skype = QContactOnlineAccount::ProtocolSkype, |
| 83 | Yahoo = QContactOnlineAccount::ProtocolYahoo |
| 84 | }; |
| 85 | |
| 86 | QDeclarativeContactOnlineAccount(QObject* parent = Q_NULLPTR) |
| 87 | :QDeclarativeContactDetail(parent) |
| 88 | { |
| 89 | setDetail(QContactOnlineAccount()); |
| 90 | connect(asender: this, SIGNAL(valueChanged()), SIGNAL(detailChanged())); |
| 91 | } |
| 92 | |
| 93 | DetailType detailType() const |
| 94 | { |
| 95 | return QDeclarativeContactDetail::OnlineAccount; |
| 96 | } |
| 97 | |
| 98 | void setAccountUri(const QString& v) |
| 99 | { |
| 100 | if (!readOnly() && v != accountUri()) { |
| 101 | detail().setValue(field: QContactOnlineAccount::FieldAccountUri, value: v); |
| 102 | emit valueChanged(); |
| 103 | } |
| 104 | } |
| 105 | QString accountUri() const {return detail().value(field: QContactOnlineAccount::FieldAccountUri).toString();} |
| 106 | |
| 107 | void setServiceProvider(const QString& v) |
| 108 | { |
| 109 | if (!readOnly() && v != serviceProvider()) { |
| 110 | detail().setValue(field: QContactOnlineAccount::FieldServiceProvider, value: v); |
| 111 | emit valueChanged(); |
| 112 | } |
| 113 | } |
| 114 | QString serviceProvider() const {return detail().value(field: QContactOnlineAccount::FieldServiceProvider).toString();} |
| 115 | |
| 116 | void setCapabilities(const QStringList& v) |
| 117 | { |
| 118 | if (!readOnly() && v.toSet() != capabilities().toSet()) { |
| 119 | detail().setValue(field: QContactOnlineAccount::FieldCapabilities, value: v); |
| 120 | emit valueChanged(); |
| 121 | } |
| 122 | } |
| 123 | QStringList capabilities() const {return detail().value<QStringList>(field: QContactOnlineAccount::FieldCapabilities);} |
| 124 | |
| 125 | void setSubTypes(const QList<int>& subTypes) |
| 126 | { |
| 127 | QList<int> oldList = detail().value< QList<int> >(field: QContactOnlineAccount::FieldSubTypes); |
| 128 | |
| 129 | if (!readOnly() && subTypes.toSet() != oldList.toSet()) { |
| 130 | detail().setValue(field: QContactOnlineAccount::FieldSubTypes, value: QVariant::fromValue(value: subTypes)); |
| 131 | emit valueChanged(); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | QList<int> subTypes() const |
| 136 | { |
| 137 | return detail().value< QList<int> >(field: QContactOnlineAccount::FieldSubTypes); |
| 138 | } |
| 139 | |
| 140 | void setProtocol(OnlineAccountProtocol v) { |
| 141 | if (!readOnly() && v != protocol()) { |
| 142 | detail().setValue(field: QContactOnlineAccount::FieldProtocol, value: static_cast<int>(v)); |
| 143 | emit valueChanged(); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | OnlineAccountProtocol protocol() const |
| 148 | { |
| 149 | return static_cast<OnlineAccountProtocol>(detail().value<int>(field: QContactOnlineAccount::FieldProtocol)); |
| 150 | } |
| 151 | |
| 152 | signals: |
| 153 | void valueChanged(); |
| 154 | }; |
| 155 | |
| 156 | QT_END_NAMESPACE |
| 157 | |
| 158 | QML_DECLARE_TYPE(QDeclarativeContactOnlineAccount) |
| 159 | |
| 160 | #endif // QDECLARATIVECONTACTONLINEACCOUNT_H |
| 161 | |