Tizen 2.0 Release
[apps/osp/Phone.git] / inc / PhnDialPresentationModel.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                PhnDialPresentationModel.h
19  * @brief               This is the header file for the %DialPresentationModel class.
20  *
21  * This header file contains the declarations for %DialPresentationModel class.
22  */
23 #ifndef PHNDIALPRESENTATIONMODEL_H_
24 #define PHNDIALPRESENTATIONMODEL_H_
25
26 #include <FApp.h>
27 #include <FBase.h>
28 #include "PhnRetrieveSuggestionsTasks.h"
29
30 class DialContactInfo;
31 class DialTabDialer;
32 class SettingsManager;
33
34 /**
35  * @class DialPresentationModel
36  * @brief This class acts as an interface between the Dialer Screen and core engine.
37  */
38 class DialPresentationModel
39                 : public Tizen::App::IAppControlResponseListener
40                 , public ISuggestionsRetrievedEventListener
41 {
42 public:
43         DialPresentationModel(DialTabDialer& pParentPanel);
44         ~DialPresentationModel();
45
46         /**
47          * Used to fetch the contacts suggestion list.
48          * Starts a new thread for async search of contacts, call logs with phone number and name.
49          */
50         bool FetchSuggestionList(const Tizen::Base::String& searchString);
51         //Used to fetch Speed dial mapping for pressed button, if present.
52         Tizen::Base::String* FetchSpeedDialNumberN(int actionId);
53         //Used to fetch contact at specified index from search result list.
54         DialContactInfo* GetSuggestionAtIndex(int index);
55         //Used to fetch the no. of suggested contacts in search result list.
56         int GetNumberOfSuggestions(void);
57         //clear search results
58         void ClearSearchResults(void);
59         //Used to open contacts "Add" AppControl
60         void AddContactsToAddressBook(Tizen::Base::String& contactNumber);
61         //Used to open Messaging "Compose" AppControl
62         void OpenMessagingAppControl(Tizen::Base::String& contactNumber);
63         //Used to fetch latest dialed or caller number from call logs
64         Tizen::Base::String* FetchLatestNumberFromLogsN(void);
65
66 protected:
67         //Called when the application control is completed.
68         virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData);
69         // Called when the retrieval of contact suggestion list is completed
70         virtual void HandleContactsRetrievalCompleted(Tizen::Base::Collection::IList* pContactsList);
71
72 private:
73         SettingsManager* __pSettingsManager;
74         Tizen::Base::Collection::ArrayList* __pNumberSuggestionList;
75         //Used to Control access to __pNumberSuggestionList
76         Tizen::Base::Runtime::Mutex __mutex;
77         Tizen::Base::String* __pSearchString;
78         /// Worker thread
79         Tizen::Base::Runtime::Thread* __pSearchThread;
80         RetrieveContactsListTask* __pAsyncSearchTask;
81         DialTabDialer& __pParentPanel;
82 };
83
84 #endif /* PHNDIALPRESENTATIONMODEL_H_ */