I added virtual features() method and changed open contact window methods. Now there is method openContactWindow() for existing contact and method openAddContactWindow() for adding new contact. Trojita should check if contact is already addressbook by contactExist() and then decide if will show button for adding new contact or open existing. Also check if addressbook is readonly, so button for adding new contact will be disabled.
#ifndef ADDRESSBOOK_INTERFACE
#define ADDRESSBOOK_INTERFACE
#include <QList>
#include <QObject>
#include <QPair>
#include <QString>
#include <QStringList>
#include <QtPlugin>
class AddressbookInterface : public QObject {
Q_OBJECT
public:
enum Feature {
ReadOnly
};
/**
* @short Return implementation features
**/
virtual qint64 features() const = 0;
/**
* @short Return true if contact exists in addressbook
**/
virtual bool contactExist(const QString &email) const = 0;
public slots:
/**
* @short Request a list of pairs (name, email) matching contacts and emit
signal @see completionAvailable when finish
* @p input is input string
* @p ignores is list of strings which are NOT included in result
* @p max is the demanded maximum reply length, negative value means
"uncapped"
**/
virtual void requestCompletion(const QString &input, const QStringList
&ignores = QStringList(), int max = -1) = 0;
/**
* @short Request a list of display names matching the given e-mail address
and emit signal @see
prettyNamesForAddressAvailable when finish
* @p email is e-mail address
**/
virtual void requestPrettyNamesForAddress(const QString &email) = 0;
/**
* @short Open window for addressbook manager
**/
virtual void openAddressbookWindow() = 0;
/**
* @short Open window for contact specified by email address
* contact should exist in addressbook, caller can check this by calling
contactExist() method
**/
virtual void openContactWindow(const QString &email) = 0;
/**
* @short Open window for adding new contact, fill display name and email
**/
virtual void openAddContactWindow(const QString &email, const QString
&displayName) = 0;
signals:
/**
* @short Emitted when @see requestCompletion finish
**/
void completionAvailable(const QString &input, const QList < QPair
<QString, QString> > &completion);
/**
* @short Emitted when @see requestPrettyNamesForAddress finish
**/
void prettyNamesForAddressAvailable(const QString &email, const QStringList
&displayNames);
protected:
AddressbookInterface(QObject *parent) : QObject(parent) {}
};
class AddressbookFactoryInterface {
public:
/**
* @short Return name of plugin
**/
virtual QString name() const = 0;
/**
* @short Return description of plugin
**/
virtual QString description() const = 0;
/**
* @short Return true if this plugin is valid and can be used (e.g this
addressbook is installed and usable)
**/
virtual bool isValid() const = 0;
/**
* @short Return new AddressbookInterface instance implemented by plugin
**/
virtual AddressbookInterface *create(QObject *parent) = 0;
};
Q_DECLARE_INTERFACE(AddressbookFactoryInterface, "AddressbookFactoryInterface");
#endif //ADDRESSBOOK_INTERFACE
--
Pali Rohár
[email protected]
signature.asc
Description: This is a digitally signed message part.
