summaryrefslogtreecommitdiff
path: root/lib-contact/ct-list/src/CtListModelMergeContacts.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib-contact/ct-list/src/CtListModelMergeContacts.h')
-rw-r--r--lib-contact/ct-list/src/CtListModelMergeContacts.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/lib-contact/ct-list/src/CtListModelMergeContacts.h b/lib-contact/ct-list/src/CtListModelMergeContacts.h
new file mode 100644
index 0000000..8dbe802
--- /dev/null
+++ b/lib-contact/ct-list/src/CtListModelMergeContacts.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2009-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 __CT_LIST_MODEL_MERGE_CONTACTS_H_
+#define __CT_LIST_MODEL_MERGE_CONTACTS_H_
+
+#include <list>
+#include <thread>
+#include <memory>
+#include <mutex>
+
+class WView;
+
+struct __Group;
+
+struct __Person
+{
+ __Person();
+ int personId;
+ int addressbookMode;
+ int addressbookId;
+ int mergeCount;
+ std::string label;
+ std::string displayName;
+ std::string thumbnail;
+ bool representative;
+ bool favorite;
+ __Group* group;
+};
+
+struct __Group
+{
+ ~__Group();
+ std::string label;
+ int checkedCount;
+ std::list<std::unique_ptr<__Person> > members;
+ __Person* representative;
+};
+
+struct __PersonInfo
+{
+ bool inSimAddressbook;
+ bool grouped;
+ int addressbookId;
+ int addressbookMode;
+ int mergeCount;
+};
+
+class CtListModelMergeContacts
+{
+
+public:
+ CtListModelMergeContacts();
+ ~CtListModelMergeContacts();
+
+public:
+ void findMergeCandidates(std::function<void ()> resultCb);
+ std::list<std::unique_ptr<__Group> >& getMergeCandidates();
+
+ void lock();
+ void unlock();
+
+private:
+ void __appendGroup(std::unique_ptr<__Group>);
+ void __initSimAddressbookIds();
+ bool __isSimAddressbook(int addressbookId);
+
+ void __makeCandidatesByName(std::map<int, __PersonInfo>& personInfoMap);
+ void __makeCandidatesByEmail(std::map<int, __PersonInfo>& personInfoMap);
+ void __makeCandidatesByNumber(std::map<int, __PersonInfo>& personInfoMap);
+
+private:
+ int __simAddressbookIds[2];
+
+private:
+ int __numOfMergeableContact;
+ std::list<std::unique_ptr<__Group> > __groups;
+ std::map<int, __PersonInfo> __personInfoMap;
+ std::thread* __finder;
+ bool __canceled;
+ std::function<void ()> __resultCb;
+ std::mutex __lock;
+};
+
+#endif //__CT_LIST_MODEL_MERGE_CONTACTS_H_
+