2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file PhnRetrieveSuggestionsTasks.h
19 * @brief This is the header file for the %RetrieveContactsListTask class.
21 * This header file contains the declarations for %RetrieveContactsListTask class.
23 #ifndef _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_
24 #define _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_
29 class DialContactInfo;
30 //class CallLogDetails;
33 * @class ISuggestionsRetrievedEventListener
34 * @brief This is event listener interface for informing that
35 * the retrieval of contact suggestion list is completed.
37 class ISuggestionsRetrievedEventListener
40 virtual ~ISuggestionsRetrievedEventListener(void){};
43 * Called when the retrieval of contact suggestion list is completed.
44 * Ownership transferred for 'pContactsMap' to listener.
46 virtual void HandleContactsRetrievalCompleted(Tizen::Base::Collection::IList* pContactsMap) = 0;
50 * @class RetrieveContactsListTask
51 * @brief This Class used to provide Thread functionality for all Search Tasks asynchronously.
54 class RetrieveContactsListTask
55 : public Tizen::Base::Object
56 , public Tizen::Base::Runtime::IRunnable
59 RetrieveContactsListTask( ISuggestionsRetrievedEventListener& pEventListener);
61 ~RetrieveContactsListTask(void);
62 //2nd phase contruct to initialize search string and old search results if present.
63 result Construct(Tizen::Base::String& searchString,const Tizen::Base::Collection::IList* oldSearchResults);
64 ///called when the thread for search task starts
65 virtual Tizen::Base::Object* Run(void);
68 //internal function to search speed-dial numbers and add to list
69 void SearchSpeedDialForNumberN(void);
70 //internal function to search contacts by phone number and add to list.
71 void SearchContactsForNumber(void);
72 //internal function to searches call logs for phone number and add to list.
73 /*void SearchCallLogsForNumber(void);*/
74 //internal function to search contacts by name and add to list.
75 void SearchContactsForName(void);
76 //internal function to save contacts starting with 'searchStr'.
77 void SearchContactsWithInitialChar(Tizen::Base::String& searchStr);
78 //internal function to update the already fetched suggestion list
79 void UpdateSuggestionList(void);
81 //internal function to save searched contact by number to single consolidated list.
82 void SaveContactsToListByNumber(Tizen::Base::Collection::IList& saveList, Tizen::Base::String& matchedString);
84 * internal function to convert Contact to DialContactInfo.
85 * return null, if the contact does not have any phone numbers assigned to it.
87 DialContactInfo* ConvertToDialContactN(Tizen::Social::Contact& contact, Tizen::Base::String& matchedString);
88 /*DialContactInfo* ConvertLogDetailsToDialContactN(CallLogDetails& logDetails);*/
91 Tizen::Social::Addressbook* __pAddressBook;
92 ISuggestionsRetrievedEventListener& __pEventListener;
93 Tizen::Base::Collection::ArrayList* __pContactsList;
94 Tizen::Base::String* __pNumberStr;
98 * @class SuggestionListComparer
99 * @brief This Class is used to compare 2 objects of 'DialContactInfo' type and returns the comparison results.
100 * This class can be used to sort an ArrayList of 'DialContactInfo' objects.
102 class SuggestionListComparer
103 : public Tizen::Base::Collection::IComparer
106 SuggestionListComparer(){};
107 virtual ~SuggestionListComparer(){};
109 * Used to compare two reference of 'DialContactInfo' and return 'cmpResult' as the comparison result.
112 * < 0 if the value of @c obj1 is less than the value of @c obj2
113 * == 0 if the value of @c obj1 is equal to the value of @c obj2
114 * > 0 if the value of @c obj1 is greater than the value of @c obj2
116 virtual result Compare(const Tizen::Base::Object& objRef1, const Tizen::Base::Object& objRef2, int& cmpResult) const;
119 #endif // _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_