Tizen 2.0 Release
[apps/osp/Internet.git] / inc / IntSettingPresentationModel.h
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 //!Internet
19 /*@file:        IntSettingsManager.cpp
20  *@brief:       Used to define SettingsManager
21  */
22
23 #ifndef _INT_SETTINGS_PRESENTATION_MODEL_H_
24 #define _INT_SETTINGS_PRESENTATION_MODEL_H_
25
26 #include <FApp.h>
27 #include <FAppApp.h>
28 #include <FBase.h>
29 #include <FIo.h>
30 #include <FWeb.h>
31
32 #include "IntISettingChangeListener.h"
33
34
35 enum SettingValues
36 {
37         REGISTRY_SETTING_INVALID = -1,
38         REGISTRY_SETTING_HOMEPAGE = 0,
39         REGISTRY_SETTING_DEFAULT_VIEW,          //1
40         REGISTRY_SETTING_RUN_JAVASCRIPT,        //2
41         REGISTRY_SETTING_DISPLAY_IMAGES,        //3
42         REGISTRY_SETTING_HTML5_VIDEOS,          //4
43         REGISTRY_SETTING_WORD_WRAPPING,         //5
44         REGISTRY_SETTING_BLOCK_POPUP,           //6
45         REGISTRY_SETTING_ACCEPT_COOKIES,        //7
46         REGISTRY_SETTING_AUTOSAVE_ID_PASSWORD,  //8
47         REGISTRY_SETTING_SHOW_SECURITY_WARNINGS, //9
48         REGISTRY_SETTING_SEARCH_ENGINE,         //10
49         REGISTRY_SETTING_CASE_SENSITIVE,        //11
50         REGISTRY_SETTING_RUN_READER,            //12
51         REGISTRY_SETTING_READER_FONT_SIZE,              //13
52         REGISTRY_SETTING_FAVORITE_URL_VALUE,    //14
53         REGISTRY_SETTING_REMEMBER_FORM_DATA,    //15
54         REGISTRY_SETTING_REMEMBER_PASSWORD,             //16
55         MAX_REGISTRY_SETTING                    //17
56 };
57
58 class SettingPresentationModel
59 {
60 public:
61
62
63         /**
64          * @brief The method initializes the registry and the SettingsManager values.
65          *
66          * @return              An error code
67          * @param[in]   void
68          *
69          * @exception   E_SUCCESS                       The method is successful.
70          * @exception   E_INVALID_STATE         This instance has already been constructed.
71          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
72          * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
73          * @exception   E_SYSTEM                        A system error has occurred.
74          *
75          */
76         result Construct(void);
77
78         /**
79          * @brief               The method used to add a listener to get the setting change events
80          */
81         void AddSettingsEventListener(const ISettingChangeEventListener& pListener);
82
83
84
85         /**
86          * @name ClearCache
87          * @brief The method used to clear the cache of web browser
88          * @param[in]   void
89          * @return              String          The Search URL
90          */
91         void ClearCache(void);
92
93         /**
94          * @name ClearCookie
95          * @brief The method used to clear the cache of web browser
96          * @param[in]   void
97          * @return              String          The Search URL
98          */
99         void ClearCookie(void);
100
101         /**
102          * @brief The method used to get the default view
103          * @param[in]   void
104          * @return              String          The default view value
105          *
106          */
107         Tizen::Base::String GetDefaultView(void);
108
109         /**
110          * @brief The method used to get the Favorite URL
111          * @param[in]   void
112          * @return              String          The Favorite URL
113          */
114         Tizen::Base::String GetFavoriteUrl(void);
115
116         /**
117          * @brief               The method used to get the already created instance of the SettingPresentationModel
118          */
119         static SettingPresentationModel* GetInstance(void);
120
121         /**
122          * @brief The method used to set the homepage value
123          * @param[in]   void
124          * @return              String          The Homepage Value
125          */
126         Tizen::Base::String GetHomepage(void);
127
128         /**
129          * @brief The method used to get the value of reader font size
130          * @param[in]   void
131          * @return              int             fontSize of reader
132          */
133         int GetReaderFontSize(void);
134
135         /**
136          * @brief The method used to get the Save Password string value.
137          * @param[in]   void
138          * @return              String          The Save Password String
139          */
140         Tizen::Base::String GetSavePassword(void);
141
142         /**
143          * @brief The method used to get the Search Engine string value.
144          * @param[in]   void
145          * @return              String          The Search Engine String
146          */
147         Tizen::Base::String GetSearchEngine(void);
148
149         /**
150          * @brief The method used to get the Search URL Based on the default search engine value.
151          * @param[in]   void
152          * @return              String          The Search URL
153          */
154         Tizen::Base::String GetSearchUrl(const Tizen::Base::String& searchText);
155
156         bool GetPrivateOn(void);
157
158         /**
159          * @brief The method used to get the Block popup as true or false
160          * @param[in]   void
161          * @return              bool            true to enable and false for disable
162          */
163         bool IsBlockPopUp(void);
164
165         /**
166          * @brief The method used to get the Cookies Enabled as true or false
167          * @param[in]   void
168          * @return              bool            true to enable and false for disable
169          */
170         bool IsCookiesEnabled(void);
171
172         /**
173          * @brief The method used to get the case sensitivity as true or false
174          * @param[in]   void
175          * @return              bool            true to enable and false for disable
176          */
177         bool IsCaseSensitiveEnabled(void);
178
179         /**
180          * @brief The method used to get the Display Images value as true or false
181          * @param[in]   void
182          * @return              bool            true to enable and false for disable
183          */
184         bool IsDisplayImagesEnabled(void);
185
186         /**
187          * @brief The method used to get the HTML5 Videos as true or false
188          * @param[in]   void
189          * @return              bool            true to enable and false for disable
190          */
191         bool IsHtml5VideosEnabled(void);
192
193         /**
194          * @brief The method used to get the Remember password Enabled as true or false
195          * @param[in]   void
196          * @return              bool            true to enable and false for disable
197          */
198         bool IsRememberFormData(void);
199
200         /**
201          * @brief The method used to get the Remember password Enabled as true or false
202          * @param[in]   void
203          * @return              bool            true to enable and false for disable
204          */
205         bool IsRememberPassword(void);
206
207         /**
208          * @brief The method used to get the Javascript enabled value as true or false
209          * @param[in]   void
210          * @return              bool            true to enable and false for disable
211          */
212         bool IsRunJavascriptEnabled(void);
213
214         /**
215          * @brief The method used to get the Run Reader as true or false
216          * @param[in]   void
217          * @return              bool            true to enable and false for disable
218          */
219         bool IsRunReaderEnabled(void);
220
221         /**
222          * @brief The method used to get the Security Warnings as true or false
223          * @param[in]   void
224          * @return              bool            true to enable and false for disable
225          */
226         bool IsSecurityWarningsEnabled(void);
227
228         /**
229          * @brief The method used to get the Word Wrap as true or false
230          * @param[in]   void
231          * @return              bool            true to enable and false for disable
232          */
233         bool IsWordWrapEnabled(void);
234
235         /**
236          * @brief The method loads the data and the SettingsManager values from the registry.
237          *
238          * @return              An error code
239          * @param[in]   void
240          * @exception   E_SUCCESS                       The method is successful.
241          * @exception   E_INVALID_STATE         This instance has already been constructed.
242          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
243          * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
244          * @exception   E_SYSTEM                        A system error has occurred.
245          *
246          */
247         result LoadRegistry(void);
248
249         /**
250          * @brief               The method used to remove the ISettingsChangeListener
251          */
252         void RemoveSettingsEventListener(ISettingChangeEventListener& pListener);
253
254         /**
255          * @brief The method resets the registry and the SettingsManager values to default.
256          *
257          * @return              An error code
258          * @param[in]   void
259          * @exception   E_SUCCESS                       The method is successful.
260          * @exception   E_INVALID_STATE         This instance has already been constructed.
261          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
262          * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
263          * @exception   E_SYSTEM                        A system error has occurred.
264          *
265          */
266         result ResetRegistry(void);
267
268         /**
269          * @brief               The method used to set the Default values of settings
270          */
271         void SetDefaultValues(void);
272
273         /**
274          * @brief The method used to set the default view
275          * @param[in]   String          The default view value
276          * @return              void
277          */
278         void SetDefaultView(const Tizen::Base::String& viewLevel);
279
280         /**
281          * @brief The method used to set the homepage value
282          * @param[in]   String          The Homepage Value
283          * @return              void
284          */
285         void SetHomepage(const Tizen::Base::String& homePage);
286
287         /**
288          * @brief The method used to set the Javascript enabled value to true or false
289          * @param[in]   bool            true to enable and false for disable
290          * @return              void
291          */
292         void SetRunJavascriptEnabled(bool runJsEnabled);
293
294         /**
295          * @brief The method used to set the Display Images value to true or false
296          * @param[in]   bool            true to enable and false for disable
297          * @return              void
298          */
299         void SetDisplayImagesEnabled(bool displayImages);
300
301         /**
302          * @brief The method used to set the HTML5 Videos to true or false
303          * @param[in]   bool            true to enable and false for disable
304          * @return              void
305          */
306         void SetHtml5VideosEnabled(bool html5Videos);
307
308         /**
309          * @brief The method used to set the Word Wrap to true or false
310          * @param[in]   bool            true to enable and false for disable
311          * @return              void
312          */
313         void SetWordWrapEnabled(bool wordWrap);
314
315         /**
316          * @brief The method used to set the Block popup to true or false
317          * @param[in]   bool            true to enable and false for disable
318          * @return              void
319          */
320         void SetBlockPopUp(bool blockPopUp);
321
322         /**
323          * @brief The method used to set the Cookies Enabled to true or false
324          * @param[in]   bool            true to enable and false for disable
325          * @return              void
326          */
327         void SetCookiesEnabled(bool cookiesEnabled);
328
329         /**
330          * @brief The method used to set the Save Password string value.
331          * @param[in]   String          The Save Password String
332          * @return              void
333          */
334         void SetSavePassword(const Tizen::Base::String& savePassword);
335
336         /**
337          * @brief The method used to set Remember form data to true or false
338          * @param[in]   bool            true to enable false for disable
339          * @return              void
340          */
341         void SetRememberFormData(bool rememberFormData);
342
343         /**
344          * @brief The method used to set Remember password to true or false
345          * @param[in]   bool            true to enable false for disable
346          * @return              void
347          */
348         void SetRememberPassword(bool rememberPassword);
349
350         /**
351          * @brief The method used to enabling the Security Warnings to true or false
352          * @param[in]   bool            true to enable and false for disable
353          * @return              void
354          */
355         void SetSecurityWarningsEnabled(bool securityWarnings);
356
357         /**
358          * @brief The method used to set the Default Search Engine.
359          * @param[in]   String          The Search Engine String
360          * @return              void
361          */
362         void SetSearchEngine(const Tizen::Base::String& searchEngine);
363
364
365
366         void SetCaseSensitiveEnabled(bool caseSensitive);
367
368         /**
369          * @brief The method used to enabling the Reader to true or false
370          * @param[in]   bool            true to enable and false for disable
371          * @return              void
372          */
373         void SetRunReaderEnabled(bool runReader);
374
375         /**
376          * @brief The method used to set the value of reader font size
377          * @param[in]   int             fontSize of reader
378          * @return              void
379          */
380         void SetReaderFontSize(int fontSize);
381
382         /**
383          * @name GetWebSettings
384          * @brief The method used to get web browser settings
385          * @param[in]   void
386          * @return              WebSetting              The Settings of web browser
387          */
388         Tizen::Web::Controls::WebSetting& GetWebSettings(void);
389
390         /**
391          * @name SetFavoriteValue
392          * @brief The method used to set favourite URL for web browser
393          * @param[in]   val                                     favorite value to set
394          * @return              An error code
395          * @exception   E_INVALID_ARG           The length of the specified string for a section or entry is smaller than or equal to @c 0, or the specified string is a @c null value or string with '\0' and '\n'.
396          * @exception   E_KEY_NOT_FOUND         The specified key is not used in the application preferences.
397          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
398          * @exception   E_KEY_ALREADY_EXIST     The key has already been used in the application preferences.
399          * @exception   E_SUCCESS                       The method is successful.
400          */
401         result SetFavoriteValue(const Tizen::Base::String& val);
402
403         void SetPrivateOn(bool isPrivateOn);
404
405 private:
406         /**
407          * @brief The Default Constructor
408          */
409         SettingPresentationModel(void);
410
411         /**
412         * @brief                The Default Destructor
413         */
414         ~SettingPresentationModel(void);
415
416         /**
417          * copy constructor
418          */
419         SettingPresentationModel(const SettingPresentationModel& settingModelObj);
420
421         /**
422          * @brief               The method used to create the instance of the SettingsManager class
423          */
424         static void CreateInstance(void);
425
426         /**
427          * @brief               The method used to remove the already created instance of the SettingsManager
428          */
429         static void DestroyInstance(void);
430         /**
431          * assignment operator
432          */
433         SettingPresentationModel& operator=(const SettingPresentationModel& settingModelObj);
434
435         result SetValue(const int settingValueName, const Tizen::Base::String& val);
436
437 private:
438         static SettingPresentationModel* __pSettingsPresentationModel;
439
440         Tizen::Base::Collection::ArrayList __listenerList;
441         Tizen::Base::String __homePage;
442         Tizen::Base::String __defaultViewLevel;
443         Tizen::Base::String __favouriteURL;
444         bool __runJsEnabled;
445         bool __displayImages;
446         bool __html5Videos;
447         bool __wordWrap;
448         bool __blockPopUp;
449         bool __rememberFormData;
450         bool __rememberPassword;
451         bool __cookies;
452         Tizen::Base::String __savePassword;
453         bool __securityWarnings;
454         Tizen::Base::String __searchEngine;
455         bool __caseSensitive;
456         bool __runReader;
457         int __fontSize;
458         bool __isPrivateOn;
459         Tizen::Web::Controls::WebSetting __setting;
460
461         //      Tizen::Io::Registry* __pRegistry;
462         Tizen::Base::String __entry[MAX_REGISTRY_SETTING];
463         Tizen::Base::String __values[MAX_REGISTRY_SETTING];
464 };
465
466 #endif // _INT_SETTINGS_PRESENTATION_MODEL_H_