File indexing completed on 2024-05-12 04:45:59
0001 #ifndef ABSTRACTINTERFACE_H 0002 #define ABSTRACTINTERFACE_H 0003 0004 #include <MauiKit3/Core/fmh.h> 0005 0006 /** 0007 * This is an abstract class for handling the contacts, 0008 * it describes tha basic methods needed for Maui Dialer 0009 * to fetch, edit and remove contacts. 0010 * This abstraction is meant to be implemented on 0011 * the android and linux specific interfaces... and any other future platform 0012 */ 0013 0014 class AbstractInterface : public QObject 0015 { 0016 Q_OBJECT 0017 private: 0018 // /* 0019 // * m_contacts might work as a cached list of the contacts 0020 // * when fetching contacts all over again might be expensive 0021 // */ 0022 0023 // FMH::MODEL_LIST m_contacts; 0024 0025 public: 0026 explicit AbstractInterface(QObject *parent = nullptr) 0027 : QObject(parent) 0028 { 0029 } 0030 virtual ~AbstractInterface() 0031 { 0032 } 0033 0034 /** 0035 * getContacts must be done async and 0036 * emit a signal with FMH::MODEL_LIST representing the contacts 0037 */ 0038 virtual void getContacts() 0039 { 0040 } 0041 0042 /** 0043 * getContact returns a contact represented by a FMH::MODEL, 0044 * to do so, it needs a valid id 0045 */ 0046 virtual FMH::MODEL getContact(const QString &id) 0047 { 0048 Q_UNUSED(id) 0049 return FMH::MODEL(); 0050 } 0051 0052 /** 0053 * insertContact takes a contact represented by a FMH::MODEL, 0054 * and returns whether the contact was sucessfully inserted or not. 0055 * To insert a contact to a specific account, use the fields: 0056 * FMH::MODEL_KEY::ACCOUNT = name of the account 0057 * FMH::MODEL_KEY::ACCOUNT_TYPE = type of the account 0058 */ 0059 virtual bool insertContact(const FMH::MODEL &contact) 0060 { 0061 Q_UNUSED(contact) 0062 return false; 0063 } 0064 0065 /** 0066 * updateContact takes the id of the contact to be updated, 0067 * and the up-to-date values represented as a FMH::MODEL, 0068 * and returns whether the contact was sucessfulyl updated or not 0069 */ 0070 virtual bool updateContact(const QString &id, const FMH::MODEL &contact) 0071 { 0072 Q_UNUSED(id) 0073 Q_UNUSED(contact) 0074 return false; 0075 } 0076 0077 /** 0078 * removeContact takes the id of the contact to be removed and return 0079 * whether the contact was sucesfully removed or not 0080 */ 0081 virtual bool removeContact(const QString &id) 0082 { 0083 Q_UNUSED(id) 0084 return false; 0085 } 0086 0087 /** 0088 * getAccounts returns a FMH::MODEL_LIST 0089 * representing the avalible accounts handling the contacts 0090 */ 0091 virtual FMH::MODEL_LIST getAccounts(...) 0092 { 0093 return FMH::MODEL_LIST(); 0094 } 0095 0096 signals: 0097 0098 /** 0099 * contactsReady is emitted when all the contacts are ready, 0100 * this signal is expected to be emitted by the getContacts method, 0101 * which is supossed to work async. 0102 * The contacts data is represented by FMH::MODEL_LIST 0103 */ 0104 void contactsReady(FMH::MODEL_LIST contacts); 0105 }; 0106 0107 #endif // ABSTRACTINTERFACE_H