+++ /dev/null
-/*
- * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef CONTACTS_CONTACT_DATA_H
-#define CONTACTS_CONTACT_DATA_H
-
-#include <memory>
-#include <tizen.h>
-#include <list>
-
-namespace Contacts
-{
- class ContactData;
-
- typedef std::unique_ptr<ContactData> ContactDataPtr;
- typedef std::list<ContactData *> ContactDataList;
-
- class EXPORT_API ContactData
- {
- public:
- /**
- * @brief Determine object type
- */
- enum Type
- {
- TypeSpeeddial, /**< Speeddial number */
- TypeLog, /**< Log number */
- TypePerson, /**< Person */
- TypeContact /**< Contact */
- };
-
- /**
- * @brief Determine object fields
- */
- enum Field
- {
- FieldFirst,
- FieldName = FieldFirst, /**< Name */
- FieldNumber, /**< Number */
- FieldImage, /**< Image path */
- FieldMax /**< Sentinel value */
- };
-
- /**
- * @brief Represents ContactData changes on update event
- */
- enum ChangedInfo
- {
- ChangedNone = 0, /**< Nothing was changed */
- ChangedName = 1 << FieldName, /**< Name has changed */
- ChangedNumber = 1 << FieldNumber, /**< Number has changed */
- ChangedImage = 1 << FieldImage /**< Image path has changed */
- };
-
- /**
- * @brief Change callback
- * @param[in] Changed info
- */
- typedef std::function<void(int)> UpdateCallback;
-
- /**
- * @brief Delete callback
- */
- typedef std::function<void()> DeleteCallback;
-
- /**
- * @brief Create ContactData object
- * @param[in] type ContactData type
- */
- ContactData(Type type);
- ContactData(const ContactData &that) = delete;
- virtual ~ContactData() { }
-
- ContactData &operator=(const ContactData &that) = delete;
-
- /**
- * @return ID
- */
- virtual int getId() const = 0;
-
- /**
- * @return Name
- */
- virtual const char *getName() const = 0;
-
- /**
- * @return Number
- */
- virtual const char *getNumber() const = 0;
-
- /**
- * @return Image path
- */
- virtual const char *getImagePath() const = 0;
-
- /**
- * @return ContactData type
- */
- Type getType() const;
-
- /**
- * @brief Determine if object searchable string contains @a str
- * @return true if it contains, false if not
- */
- virtual bool compare(const char *str) = 0;
-
- /**
- * @brief Set update callback
- * @param[in] callback Update callback
- */
- void setUpdateCallback(UpdateCallback callback);
-
- /**
- * @brief Unset update callback
- */
- void unsetUpdateCallback();
-
- /**
- * @brief Set delete callback
- * @param[in] callback Delete callback
- */
- void setDeleteCallback(DeleteCallback callback);
-
- /**
- * @brief Unset delete callback
- */
- void unsetDeleteCallback();
-
- protected:
- /**
- * @brief ContactData updated callback
- * @param[in] changes Changed info
- */
- void onUpdated(int changes);
-
- /**
- * @brief ContactData deleted callback
- */
- void onDeleted();
-
- private:
- Type m_Type;
- UpdateCallback m_OnUpdated;
- DeleteCallback m_OnDeleted;
- };
-}
-
-#endif /* CONTACTS_CONTACT_DATA_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef CONTACTS_LIST_MODEL_DB_CHANGE_OBSERVER_H
-#define CONTACTS_LIST_MODEL_DB_CHANGE_OBSERVER_H
-
-#include <contacts.h>
-#include <functional>
-#include <list>
-#include <tizen.h>
-#include <unordered_map>
-
-namespace Contacts
-{
- /**
- * @brief Observe changes in contacts DB table
- */
- class EXPORT_API DbChangeObserver
- {
- public:
- /**
- * @brief Represents what DB table is observed by this object
- */
- enum Table
- {
- TableFirst,
- TableContact = TableFirst,
- TableMax
- };
-
- /**
- * @brief Callback function prototype
- * @param[in] id Contact DB record ID
- * @param[in] changeType Inserted/Updated/Deleted change type
- */
- typedef std::function<void(int id, contacts_changed_e changeType)> Callback;
-
- private:
- typedef std::list<Callback> RecordCbs;
-
- public:
- /**
- * @brief Callback handle
- * @remark Used to remove callback
- */
- typedef RecordCbs::const_iterator CallbackHandle;
-
- /**
- * @brief Get observer instance
- * @param[in] table DB table view
- * @return observer object on success or nullptr if wrong parameter passed
- */
- static DbChangeObserver *getInstance(Table table = TableContact);
-
- ~DbChangeObserver();
-
- DbChangeObserver(const DbChangeObserver &that) = delete;
- DbChangeObserver &operator=(const DbChangeObserver &that) = delete;
-
- /**
- * @brief Add callback
- * @param[in] callback DB change callback
- * @return Callback handle
- */
- CallbackHandle addCallback(Callback callback);
-
- /**
- * @brief Remove callback
- * @param[in] handle Handle to delete callback
- */
- void removeCallback(CallbackHandle handle);
-
- /**
- * @brief Add callback
- * @param[in] id Record ID
- * @param[in] callback DB change callback
- * @return Callback handle
- */
- CallbackHandle addCallback(int id, Callback callback);
-
- /**
- * @brief Remove callback
- * @param[in] id Record ID
- * @param[in] handle Callback handle
- */
- void removeCallback(int id, CallbackHandle handle);
-
- private:
- typedef RecordCbs Callbacks;
- typedef std::unordered_map<int, RecordCbs> ChangeCallbacks;
-
- DbChangeObserver(Table table);
- DbChangeObserver(DbChangeObserver &&that) = default;
-
- void subscribe();
- void unsubscribe();
-
- CallbackHandle addCallback(RecordCbs &recordCbs, Callback callback);
-
- void onChanged(const char *viewUri);
- void notifyContactChanges();
- void notify(int id, contacts_changed_e changeType);
-
- static DbChangeObserver m_Observers[TableMax];
-
- Callbacks m_Callbacks;
- ChangeCallbacks m_ChangeCallbacks;
-
- Table m_Table;
- int m_DbVersion;
- bool m_IsSubscribed;
- };
-}
-
-#endif /* CONTACTS_LIST_MODEL_DB_CHANGE_OBSERVER_H */
--- /dev/null
+/*
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef CONTACTS_CONTACT_DATA_H
+#define CONTACTS_CONTACT_DATA_H
+
+#include <memory>
+#include <tizen.h>
+#include <list>
+
+namespace Contacts
+{
+ namespace Model
+ {
+ class ContactData;
+
+ typedef std::unique_ptr<ContactData> ContactDataPtr;
+ typedef std::list<ContactData *> ContactDataList;
+
+ class EXPORT_API ContactData
+ {
+ public:
+ /**
+ * @brief Determine object type
+ */
+ enum Type
+ {
+ TypeSpeeddial, /**< Speeddial number */
+ TypeLog, /**< Log number */
+ TypePerson, /**< Person */
+ TypeContact /**< Contact */
+ };
+
+ /**
+ * @brief Determine object fields
+ */
+ enum Field
+ {
+ FieldFirst,
+ FieldName = FieldFirst, /**< Name */
+ FieldNumber, /**< Number */
+ FieldImage, /**< Image path */
+ FieldMax /**< Sentinel value */
+ };
+
+ /**
+ * @brief Represents ContactData changes on update event
+ */
+ enum ChangedInfo
+ {
+ ChangedNone = 0, /**< Nothing was changed */
+ ChangedName = 1 << FieldName, /**< Name has changed */
+ ChangedNumber = 1 << FieldNumber, /**< Number has changed */
+ ChangedImage = 1 << FieldImage /**< Image path has changed */
+ };
+
+ /**
+ * @brief Change callback
+ * @param[in] Changed info
+ */
+ typedef std::function<void(int)> UpdateCallback;
+
+ /**
+ * @brief Delete callback
+ */
+ typedef std::function<void()> DeleteCallback;
+
+ /**
+ * @brief Create ContactData object
+ * @param[in] type ContactData type
+ */
+ ContactData(Type type);
+ ContactData(const ContactData &that) = delete;
+ virtual ~ContactData() { }
+
+ ContactData &operator=(const ContactData &that) = delete;
+
+ /**
+ * @return ID
+ */
+ virtual int getId() const = 0;
+
+ /**
+ * @return Name
+ */
+ virtual const char *getName() const = 0;
+
+ /**
+ * @return Number
+ */
+ virtual const char *getNumber() const = 0;
+
+ /**
+ * @return Image path
+ */
+ virtual const char *getImagePath() const = 0;
+
+ /**
+ * @return ContactData type
+ */
+ Type getType() const;
+
+ /**
+ * @brief Determine if object searchable string contains @a str
+ * @return true if it contains, false if not
+ */
+ virtual bool compare(const char *str) = 0;
+
+ /**
+ * @brief Set update callback
+ * @param[in] callback Update callback
+ */
+ void setUpdateCallback(UpdateCallback callback);
+
+ /**
+ * @brief Unset update callback
+ */
+ void unsetUpdateCallback();
+
+ /**
+ * @brief Set delete callback
+ * @param[in] callback Delete callback
+ */
+ void setDeleteCallback(DeleteCallback callback);
+
+ /**
+ * @brief Unset delete callback
+ */
+ void unsetDeleteCallback();
+
+ protected:
+ /**
+ * @brief ContactData updated callback
+ * @param[in] changes Changed info
+ */
+ void onUpdated(int changes);
+
+ /**
+ * @brief ContactData deleted callback
+ */
+ void onDeleted();
+
+ private:
+ Type m_Type;
+ UpdateCallback m_OnUpdated;
+ DeleteCallback m_OnDeleted;
+ };
+ }
+}
+
+#endif /* CONTACTS_CONTACT_DATA_H */
#ifndef CONTACTS_CONTACT_DATA_PROVIDER_H
#define CONTACTS_CONTACT_DATA_PROVIDER_H
-#include "Contacts/ContactData.h"
+#include "Contacts/Model/ContactData.h"
#include <functional>
#include <tizen.h>
namespace Contacts
{
- class EXPORT_API ContactDataProvider
+ namespace Model
{
- public:
- /**
- * @brief Insert callback
- * @param[in] Contact data
- */
- typedef std::function<void(ContactData &)> InsertCallback;
+ class EXPORT_API ContactDataProvider
+ {
+ public:
+ /**
+ * @brief Insert callback
+ * @param[in] Contact data
+ */
+ typedef std::function<void(ContactData &)> InsertCallback;
- virtual ~ContactDataProvider() { }
+ virtual ~ContactDataProvider() { }
- /**
- * @return Contact data list
- */
- virtual const ContactDataList &getContactDataList() = 0;
+ /**
+ * @return Contact data list
+ */
+ virtual const ContactDataList &getContactDataList() = 0;
- /**
- * @brief Set insert callback
- * @param[in] callback Create callback
- */
- void setInsertCallback(InsertCallback callback);
+ /**
+ * @brief Set insert callback
+ * @param[in] callback Create callback
+ */
+ void setInsertCallback(InsertCallback callback);
- /**
- * @brief Unset insert callback
- */
- void unsetInsertCallback();
+ /**
+ * @brief Unset insert callback
+ */
+ void unsetInsertCallback();
- protected:
- /**
- * @brief ContactData inserted callback
- * @param[in] contactData Contact data
- */
- void onInserted(ContactData &contactData);
+ protected:
+ /**
+ * @brief ContactData inserted callback
+ * @param[in] contactData Contact data
+ */
+ void onInserted(ContactData &contactData);
- private:
- InsertCallback m_OnInserted;
- };
+ private:
+ InsertCallback m_OnInserted;
+ };
+ }
}
#endif /* CONTACTS_CONTACT_DATA_PROVIDER_H */
--- /dev/null
+/*
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef CONTACTS_LIST_MODEL_CONTACT_RECORD_DATA_H
+#define CONTACTS_LIST_MODEL_CONTACT_RECORD_DATA_H
+
+#include "Contacts/Model/ContactData.h"
+#include "Contacts/Model/DbChangeObserver.h"
+#include <contacts.h>
+
+namespace Contacts
+{
+ namespace Model
+ {
+ class EXPORT_API ContactRecordData : public ContactData
+ {
+ public:
+ /**
+ * @brief Create ContactRecordData object
+ * @param[in] type ContactRecordData type
+ */
+ ContactRecordData(Type type);
+ virtual ~ContactRecordData() override;
+
+ /**
+ * @brief Update contact record handle
+ * @param[in] record Contact record
+ */
+ void updateContactRecord(contacts_record_h record);
+
+ /**
+ * @see ContactData::getId()
+ * @return Contact ID
+ */
+ virtual int getId() const override;
+
+ /**
+ * @see ContactData::getName()
+ * @return Contact name
+ */
+ virtual const char *getName() const override;
+
+ /**
+ * @see ContactData::getNumber()
+ * @return Contact number
+ */
+ virtual const char *getNumber() const override;
+
+ /**
+ * @see ContactData::getImagePath()
+ * @return Contact image path
+ */
+ virtual const char *getImagePath() const override;
+
+ /**
+ * @see ContactData::compare()
+ * @detail Compares by name
+ */
+ virtual bool compare(const char *str) override;
+
+ protected:
+ /**
+ * @return contact record
+ */
+ const contacts_record_h getContactRecord() const;
+
+ /**
+ * @brief Set changed callback
+ * @param[in] callback Change callback
+ */
+ void setChangedCallback(DbChangeObserver::Callback callback);
+
+ /**
+ * @brief Unset changed callback
+ */
+ void unsetChangedCallback();
+
+ /**
+ * @param[in] record Contact record
+ * @return Contact ID
+ */
+ static int getContactId(contacts_record_h record);
+
+ /**
+ * @param[in] record Contact record
+ * @param[in] field Contact field
+ * @return Contact value Name/Number/ImagePath
+ */
+ static const char *getValue(contacts_record_h record, Field field);
+
+ /**
+ * @param[in] oldContact Old contact record
+ * @param[in] newContact New contact record
+ * @return Changes between both contacts
+ */
+ static int getChanges(contacts_record_h oldContact, contacts_record_h newContact);
+
+ private:
+ friend class ContactRecordProvider;
+
+ void onUpdate(contacts_record_h record);
+
+ contacts_record_h m_Record;
+ DbChangeObserver::CallbackHandle m_Handle;
+ };
+ }
+}
+
+#endif /* CONTACTS_LIST_MODEL_CONTACT_RECORD_DATA_H */
#ifndef CONTACTS_LIST_MODEL_CONTACT_RECORD_PROVIDER_H
#define CONTACTS_LIST_MODEL_CONTACT_RECORD_PROVIDER_H
-#include "Contacts/ContactDataProvider.h"
-#include "Contacts/DbChangeObserver.h"
+#include "Contacts/Model/ContactDataProvider.h"
+#include "Contacts/Model/DbChangeObserver.h"
namespace Contacts
{
- namespace List
+ namespace Model
{
- namespace Model
+ class EXPORT_API ContactRecordProvider : public ContactDataProvider
{
- class ContactRecordProvider : public ContactDataProvider
- {
- public:
- ContactRecordProvider();
- virtual ~ContactRecordProvider() override;
+ public:
+ ContactRecordProvider();
+ virtual ~ContactRecordProvider() override;
- /**
- * @see ContactDataProvider::getContactDataList()
- */
- virtual const ContactDataList &getContactDataList() override;
+ /**
+ * @see ContactDataProvider::getContactDataList()
+ */
+ virtual const ContactDataList &getContactDataList() override;
- private:
- void onContactInserted(int id, contacts_changed_e changeType);
- void onContactChanged(ContactDataList::iterator contactIt, int id, contacts_changed_e changeType);
+ private:
+ void onContactInserted(int id, contacts_changed_e changeType);
+ void onContactChanged(ContactDataList::iterator contactIt, int id, contacts_changed_e changeType);
- DbChangeObserver::CallbackHandle m_Handle;
- ContactDataList m_ContactList;
- };
- }
+ DbChangeObserver::CallbackHandle m_Handle;
+ ContactDataList m_ContactList;
+ };
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef CONTACTS_LIST_MODEL_DB_CHANGE_OBSERVER_H
+#define CONTACTS_LIST_MODEL_DB_CHANGE_OBSERVER_H
+
+#include <contacts.h>
+#include <functional>
+#include <list>
+#include <tizen.h>
+#include <unordered_map>
+
+namespace Contacts
+{
+ namespace Model
+ {
+ /**
+ * @brief Observe changes in contacts DB table
+ */
+ class EXPORT_API DbChangeObserver
+ {
+ public:
+ /**
+ * @brief Represents what DB table is observed by this object
+ */
+ enum Table
+ {
+ TableFirst,
+ TableContact = TableFirst,
+ TableMax
+ };
+
+ /**
+ * @brief Callback function prototype
+ * @param[in] id Contact DB record ID
+ * @param[in] changeType Inserted/Updated/Deleted change type
+ */
+ typedef std::function<void(int id, contacts_changed_e changeType)> Callback;
+
+ private:
+ typedef std::list<Callback> RecordCbs;
+
+ public:
+ /**
+ * @brief Callback handle
+ * @remark Used to remove callback
+ */
+ typedef RecordCbs::const_iterator CallbackHandle;
+
+ /**
+ * @brief Get observer instance
+ * @param[in] table DB table view
+ * @return observer object on success or nullptr if wrong parameter passed
+ */
+ static DbChangeObserver *getInstance(Table table = TableContact);
+
+ ~DbChangeObserver();
+
+ DbChangeObserver(const DbChangeObserver &that) = delete;
+ DbChangeObserver &operator=(const DbChangeObserver &that) = delete;
+
+ /**
+ * @brief Add callback
+ * @param[in] callback DB change callback
+ * @return Callback handle
+ */
+ CallbackHandle addCallback(Callback callback);
+
+ /**
+ * @brief Remove callback
+ * @param[in] handle Handle to delete callback
+ */
+ void removeCallback(CallbackHandle handle);
+
+ /**
+ * @brief Add callback
+ * @param[in] id Record ID
+ * @param[in] callback DB change callback
+ * @return Callback handle
+ */
+ CallbackHandle addCallback(int id, Callback callback);
+
+ /**
+ * @brief Remove callback
+ * @param[in] id Record ID
+ * @param[in] handle Callback handle
+ */
+ void removeCallback(int id, CallbackHandle handle);
+
+ private:
+ typedef RecordCbs Callbacks;
+ typedef std::unordered_map<int, RecordCbs> ChangeCallbacks;
+
+ DbChangeObserver(Table table);
+ DbChangeObserver(DbChangeObserver &&that) = default;
+
+ void subscribe();
+ void unsubscribe();
+
+ CallbackHandle addCallback(RecordCbs &recordCbs, Callback callback);
+
+ void onChanged(const char *viewUri);
+ void notifyContactChanges();
+ void notify(int id, contacts_changed_e changeType);
+
+ static DbChangeObserver m_Observers[TableMax];
+
+ Callbacks m_Callbacks;
+ ChangeCallbacks m_ChangeCallbacks;
+
+ Table m_Table;
+ int m_DbVersion;
+ bool m_IsSubscribed;
+ };
+ }
+}
+
+#endif /* CONTACTS_LIST_MODEL_DB_CHANGE_OBSERVER_H */
*
*/
-#include "Contacts/ContactData.h"
+#include "Contacts/Model/ContactData.h"
-using namespace Contacts;
+using namespace Contacts::Model;
ContactData::ContactData(Type type)
: m_Type(type)
*
*/
-#include "Contacts/ContactDataProvider.h"
+#include "Contacts/Model/ContactDataProvider.h"
-using namespace Contacts;
+using namespace Contacts::Model;
void ContactDataProvider::setInsertCallback(InsertCallback callback)
{
*
*/
-#include "Contacts/List/Model/ContactRecordData.h"
+#include "Contacts/Model/ContactRecordData.h"
#include "Contacts/ContactRecordChildIterator.h"
#include <cstring>
-using namespace Contacts::List::Model;
+using namespace Contacts::Model;
ContactRecordData::ContactRecordData(Type type)
: ContactData(type), m_Record(nullptr)
*
*/
-#include "Contacts/List/Model/ContactRecordProvider.h"
-#include "Contacts/List/Model/ContactRecordData.h"
+#include "Contacts/Model/ContactRecordProvider.h"
+#include "Contacts/Model/ContactRecordData.h"
#include "Contacts/Utils.h"
using namespace Contacts;
-using namespace Contacts::List::Model;
+using namespace Contacts::Model;
using namespace std::placeholders;
ContactRecordProvider::ContactRecordProvider()
*
*/
-#include "Contacts/DbChangeObserver.h"
+#include "Contacts/Model/DbChangeObserver.h"
#include "Contacts/Utils.h"
#include "Utils/Callback.h"
#include "Utils/Range.h"
-using namespace Contacts;
+using namespace Contacts::Model;
namespace
{
void onIndexChanged(Evas_Object *index, Elm_Object_Item *indexItem);
void onIndexSelected(Evas_Object *index, Elm_Object_Item *indexItem);
- void onPersonInserted(ContactData &person);
+ void onPersonInserted(Contacts::Model::ContactData &person);
void onPersonUpdated(PersonItem *item, int changes);
void onPersonDeleted(PersonItem *item);
+++ /dev/null
-/*
- * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef CONTACTS_LIST_MODEL_CONTACT_RECORD_DATA_H
-#define CONTACTS_LIST_MODEL_CONTACT_RECORD_DATA_H
-
-#include "Contacts/ContactData.h"
-#include "Contacts/DbChangeObserver.h"
-#include <contacts.h>
-
-namespace Contacts
-{
- namespace List
- {
- namespace Model
- {
- class ContactRecordData : public ContactData
- {
- public:
- /**
- * @brief Create ContactRecordData object
- * @param[in] type ContactRecordData type
- */
- ContactRecordData(Type type);
- virtual ~ContactRecordData() override;
-
- /**
- * @brief Update contact record handle
- * @param[in] record Contact record
- */
- void updateContactRecord(contacts_record_h record);
-
- /**
- * @see ContactData::getId()
- * @return Contact ID
- */
- virtual int getId() const override;
-
- /**
- * @see ContactData::getName()
- * @return Contact name
- */
- virtual const char *getName() const override;
-
- /**
- * @see ContactData::getNumber()
- * @return Contact number
- */
- virtual const char *getNumber() const override;
-
- /**
- * @see ContactData::getImagePath()
- * @return Contact image path
- */
- virtual const char *getImagePath() const override;
-
- /**
- * @see ContactData::compare()
- * @detail Compares by name
- */
- virtual bool compare(const char *str) override;
-
- protected:
- /**
- * @return contact record
- */
- const contacts_record_h getContactRecord() const;
-
- /**
- * @brief Set changed callback
- * @param[in] callback Change callback
- */
- void setChangedCallback(DbChangeObserver::Callback callback);
-
- /**
- * @brief Unset changed callback
- */
- void unsetChangedCallback();
-
- /**
- * @param[in] record Contact record
- * @return Contact ID
- */
- static int getContactId(contacts_record_h record);
-
- /**
- * @param[in] record Contact record
- * @param[in] field Contact field
- * @return Contact value Name/Number/ImagePath
- */
- static const char *getValue(contacts_record_h record, Field field);
-
- /**
- * @param[in] oldContact Old contact record
- * @param[in] newContact New contact record
- * @return Changes between both contacts
- */
- static int getChanges(contacts_record_h oldContact, contacts_record_h newContact);
-
- private:
- friend class ContactRecordProvider;
-
- void onUpdate(contacts_record_h record);
-
- contacts_record_h m_Record;
- DbChangeObserver::CallbackHandle m_Handle;
- };
- }
- }
-}
-
-#endif /* CONTACTS_LIST_MODEL_CONTACT_RECORD_DATA_H */
#ifndef CONTACTS_LIST_MODEL_PERSON_H
#define CONTACTS_LIST_MODEL_PERSON_H
-#include "Contacts/DbChangeObserver.h"
-#include "Contacts/List/Model/ContactRecordData.h"
+#include "Contacts/Model/DbChangeObserver.h"
+#include "Contacts/Model/ContactRecordData.h"
#include "Utils/UniString.h"
#include <contacts.h>
#include <vector>
/**
* @brief Person object
*/
- class Person : public ContactRecordData
+ class Person : public Contacts::Model::ContactRecordData
{
public:
/**
Utils::UniString m_IndexLetter;
mutable Utils::UniString m_SortValue;
- std::vector<DbChangeObserver::CallbackHandle> m_Handles;
+ std::vector<Contacts::Model::DbChangeObserver::CallbackHandle> m_Handles;
};
}
}
#define CONTACTS_LIST_MODEL_PERSON_PROVIDER_H
#include "Contacts/Common/ContactSelectTypes.h"
-#include "Contacts/ContactDataProvider.h"
-#include "Contacts/DbChangeObserver.h"
+#include "Contacts/Model/ContactDataProvider.h"
+#include "Contacts/Model/DbChangeObserver.h"
#include <contacts.h>
/**
* @brief Provides list of person
*/
- class PersonProvider : public ContactDataProvider
+ class PersonProvider : public Contacts::Model::ContactDataProvider
{
public:
/**
* @brief Get person list
* @return List of contact objects
*/
- virtual const ContactDataList &getContactDataList() override;
+ virtual const Contacts::Model::ContactDataList &getContactDataList() override;
private:
contacts_record_h getFilteredRecord(int contactId);
void insertPerson(contacts_record_h record);
- void setChangedCallback(ContactDataList::iterator personIt);
- void updateChangedCallback(ContactDataList::iterator personIt);
+ void setChangedCallback(Contacts::Model::ContactDataList::iterator personIt);
+ void updateChangedCallback(Contacts::Model::ContactDataList::iterator personIt);
void unsetChangedCallback(const Person &person);
void onPersonInserted(int id, contacts_changed_e changeType);
- void onPersonChanged(ContactDataList::iterator it, int id, contacts_changed_e changeType);
+ void onPersonChanged(Contacts::Model::ContactDataList::iterator it, int id, contacts_changed_e changeType);
int m_FilterType;
- DbChangeObserver::CallbackHandle m_Handle;
- ContactDataList m_PersonList;
+ Contacts::Model::DbChangeObserver::CallbackHandle m_Handle;
+ Contacts::Model::ContactDataList m_PersonList;
};
}
}
#ifndef CONTACTS_LIST_MODEL_VCARD_PROVIDER_H
#define CONTACTS_LIST_MODEL_VCARD_PROVIDER_H
-#include "Contacts/ContactDataProvider.h"
+#include "Contacts/Model/ContactDataProvider.h"
namespace Contacts
{
/**
* @brief Provides list of contacts from vcard
*/
- class VcardProvider : public ContactDataProvider
+ class VcardProvider : public Contacts::Model::ContactDataProvider
{
public:
/**
* @see ContactDataProvider::getContactDataList()
* @return Contact data list
*/
- virtual const ContactDataList &getContactDataList() override;
+ virtual const Contacts::Model::ContactDataList &getContactDataList() override;
private:
contacts_list_h getListFromVcard(const char *path);
private:
- ContactDataList m_ContactsList;
+ Contacts::Model::ContactDataList m_ContactsList;
};
}
}
#include "Utils/Callback.h"
using namespace Contacts;
+using namespace Contacts::Model;
using namespace Contacts::List;
using namespace Contacts::List::Model;
using namespace Utils;
#include "Contacts/Utils.h"
using namespace Contacts;
+using namespace Contacts::Model;
using namespace Contacts::List::Model;
using namespace std::placeholders;
*
*/
-#include "Contacts/List/Model/ContactRecordData.h"
+#include "Contacts/Model/ContactRecordData.h"
#include "Contacts/List/Model/VcardProvider.h"
#include "Contacts/Utils.h"
#include "Utils/Logger.h"
using namespace Contacts;
+using namespace Contacts::Model;
using namespace Contacts::List::Model;
VcardProvider::VcardProvider(const char *path)