Tizen 2.0 Release
[apps/osp/Phone.git] / inc / PhnRetrieveSuggestionsTasks.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                PhnRetrieveSuggestionsTasks.h
19  * @brief               This is the header file for the %RetrieveContactsListTask class.
20  *
21  * This header file contains the declarations for %RetrieveContactsListTask class.
22  */
23 #ifndef _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_
24 #define _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_
25
26 #include <FBase.h>
27 #include <FSocial.h>
28
29 class DialContactInfo;
30 //class CallLogDetails;
31
32 /**
33  * @class ISuggestionsRetrievedEventListener
34  * @brief This is event listener interface for informing that
35  * the retrieval of contact suggestion list is completed.
36  */
37 class ISuggestionsRetrievedEventListener
38 {
39 public:
40         virtual ~ISuggestionsRetrievedEventListener(void){};
41
42         /**
43          * Called when the retrieval of contact suggestion list is completed.
44          * Ownership transferred for 'pContactsMap' to listener.
45          */
46         virtual void HandleContactsRetrievalCompleted(Tizen::Base::Collection::IList* pContactsMap) = 0;
47 };
48
49 /**
50  * @class RetrieveContactsListTask
51  * @brief This Class used to provide Thread functionality for all Search Tasks asynchronously.
52  *
53  */
54 class RetrieveContactsListTask
55                 : public Tizen::Base::Object
56                 , public Tizen::Base::Runtime::IRunnable
57 {
58 public:
59         RetrieveContactsListTask( ISuggestionsRetrievedEventListener& pEventListener);
60         //Destructor
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);
66
67 private:
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);
80
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);
83         /**
84          * internal function to convert Contact to DialContactInfo.
85          * return null, if the contact does not have any phone numbers assigned to it.
86          */
87         DialContactInfo* ConvertToDialContactN(Tizen::Social::Contact& contact, Tizen::Base::String& matchedString);
88         /*DialContactInfo* ConvertLogDetailsToDialContactN(CallLogDetails& logDetails);*/
89
90 private:
91         Tizen::Social::Addressbook* __pAddressBook;
92         ISuggestionsRetrievedEventListener& __pEventListener;
93         Tizen::Base::Collection::ArrayList* __pContactsList;
94         Tizen::Base::String* __pNumberStr;
95 };
96
97 /**
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.
101  */
102 class SuggestionListComparer
103 : public Tizen::Base::Collection::IComparer
104 {
105 public:
106         SuggestionListComparer(){};
107         virtual ~SuggestionListComparer(){};
108         /**
109          * Used to compare two reference of 'DialContactInfo' and return 'cmpResult' as the comparison result.
110          *
111          * @code
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
115          */
116         virtual result Compare(const Tizen::Base::Object& objRef1, const Tizen::Base::Object& objRef2, int& cmpResult) const;
117 };
118
119 #endif // _PHN_RETRIEVE_SUGGESTIONS_TASKS_H_