8e9ad3c4f6286afc822462de0a44534a60c9ecf3
[profile/tv/apps/native/settings.git] / src / settings_provider.c
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 #include "dbg.h"
18 #include "settings_provider.h"
19 #include <vconf.h>
20 //#include "tvtimer.h"
21 #include <sound_manager.h>
22 //#include <sound_manager_product.h>
23 #include <system_info.h>
24 //#include <system_info_key.h>
25
26 #define _ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
27
28 #define DATA_TYPE_INT "integer"
29 #define DATA_TYPE_DOUBLE "double"
30 #define DATA_TYPE_STRING "string"
31 #define DATA_TYPE_BOOL "bool"
32
33 #define KEY_PICTURE_SIZE "db/menu/picture/picturesize/mode"
34 #define KEY_CHANNEL_LOCK "db/menu/broadcasting/channel_lock"
35 #define KEY_SYSTEM_CLOCK_MODE "db/menu/system/time/clock/clock_mode"
36 #define KEY_SLEEPTIMER "db/menu/system/time/sleeptimer/value"
37 #define KEY_SLEEPTIMER_TIMET "db/menu/system/time/sleeptimer/time_t"
38 #define KEY_SLEEPTIMER_TIMERID "db/menu/system/time/sleeptimer/timer_id"
39 #define KEY_WAKEUP_TIMER_SETUP "db/menu/system/time/ontimer1/setup"
40 #define KEY_CHANGE_PASSCODE "db/menu/system/change_pin"
41 #define KEY_SUBTITLE_LANGUAGE "db/menu/subtitle/subtitlelanguage"
42 #define KEY_SYSTEM_LANGUAGE "db/menu_widget/language"
43 #define KEY_SYSTEM_COUNTRY "db/menu_widget/regionformat"
44
45 #define SYSTEM_LANGUAGE_DEFAULT_VALUE "en_US.utf8"
46 #define WAKEUP_TIMER_SETUP_DEFAULT_VALUE "OFF"
47 #define SYSTEM_COUNTRY_DEFAULT_VALUE "KOR"
48
49 enum item_type {
50         INVALID_TYPE = -1,
51         PICTURE_MODE = 0,
52         PICTURE_CONTRAST,
53         PICTURE_BRIGHTNESS,
54         PICTURE_SHARPNESS,
55         PICTURE_COLOR,
56         PICTURE_TINT,
57         PICTURE_HOMEBAR_OPACITY,
58         PICTURE_SCREEN_ADJUSTMENT,
59         SOUND_MODE,
60         SPEAKER_SETTINGS,
61         SYSTEM_SLEEPTIMER,
62         SYSTEM_WAKEUPTIMER,
63         SYSTEM_SUBTITLE,
64         SYSTEM_COUNTRY,
65         SYSTEM_LANGUAGE,
66         SYSTEM_RESET,
67         SYSTEM_PASSCODE,
68         SYSTEM_CLOCK_MODE,
69         CHANNEL_LOCK
70 };
71
72 struct keymap {
73         const char *key;
74         enum item_type type;
75 };
76
77 static struct keymap item_keymap[] = {
78         {
79                 .key = "settings/picture/picturemode",
80                 .type = PICTURE_MODE
81         },
82         {
83                 .key = "settings/picture/contrast",
84                 .type = PICTURE_CONTRAST
85         },
86         {
87                 .key = "settings/picture/brightness",
88                 .type = PICTURE_BRIGHTNESS
89         },
90         {
91                 .key = "settings/picture/sharpness",
92                 .type = PICTURE_SHARPNESS
93         },
94         {
95                 .key = "settings/picture/color",
96                 .type = PICTURE_COLOR
97         },
98         {
99                 .key = "settings/picture/tint",
100                 .type = PICTURE_TINT
101         },
102         {
103                 .key = "settings/picture/homebaropacity",
104                 .type = PICTURE_HOMEBAR_OPACITY
105         },
106         {
107                 .key = "settings/picture/screenadjustment",
108                 .type = PICTURE_SCREEN_ADJUSTMENT
109         },
110         {
111                 .key = "settings/sound/soundmode",
112                 .type = SOUND_MODE
113         },
114         {
115                 .key = "settings/sound/speakersettings",
116                 .type = SPEAKER_SETTINGS
117         },
118         {
119                 .key = "settings/system/sleeptimer",
120                 .type = SYSTEM_SLEEPTIMER
121         },
122         {
123                 .key = "settings/system/wakeup_timer_setup",
124                 .type = SYSTEM_WAKEUPTIMER
125         },
126         {
127                 .key = "settings/system/subtitle",
128                 .type = SYSTEM_SUBTITLE
129         },
130         {
131                 .key = "settings/system/country",
132                 .type = SYSTEM_COUNTRY
133         },
134         {
135                 .key = "settings/system/language",
136                 .type = SYSTEM_LANGUAGE
137         },
138         {
139                 .key = "settings/system/reset",
140                 .type = SYSTEM_RESET
141         },
142         {
143                 .key = "settings/system/change_passcode",
144                 .type = SYSTEM_PASSCODE
145         },
146         {
147                 .key = "settings/system/clock_mode",
148                 .type = SYSTEM_CLOCK_MODE
149         },
150         {
151                 .key = "settings/channel/channel_lock",
152                 .type = CHANNEL_LOCK
153         }
154 };
155
156 #if 0
157 static sound_tv_output_route_e speakersettings_item[] = {
158         SOUND_TV_OUTPUT_EXTERNAL_SPEAKER,
159         SOUND_TV_OUTPUT_SPEAKER ,
160         SOUND_TV_OUTPUT_RECEIVER,
161         SOUND_TV_OUTPUT_SOUND_SHARE
162 };
163 #endif
164
165 struct sleeptimer_data {
166         int id;
167         //tvtimer_h timer;
168 };
169
170 static unsigned int sleeptimer_value[] = {
171         0,
172         30,
173         60,
174         90,
175         120,
176         150,
177         180
178 };
179
180 /**
181 *  An timer foreach iteration callback for tvtimer_foreach_item.
182 *
183 *  This callback is invoked once iterate each timer.
184 *
185 *  @param timer [in] The TV timer info handler.
186 *  @param data [in] The function specific data passed by tvtimer_foreach_item.
187 *  @return void
188 */
189 #if 0
190 static void _timer_callback(tvtimer_h timer, void *data)
191 {
192         int id;
193         struct sleeptimer_data *priv;
194
195         if (!timer || !data) {
196                 _ERR("Invalid argument");
197                 return;
198         }
199
200         priv = data;
201
202         tvtimer_get_id(timer, &id);
203
204 #if 0
205         if (priv->id == id)
206                 priv->timer = timer;
207 #endif
208 }
209 #endif
210
211 /**
212 *  Set a sleep timer.
213 *
214 *  @param val [in] The index value for sleeptimer_value array.
215 *  @return 0 if success, -1 if fail.
216 */
217 #if 0
218 static int _set_sleeptimer(int val)
219 {
220         int size, r, id;
221         tvtimer_h timer;
222         struct sleeptimer_data data;
223
224         size = _ARRAY_SIZE(sleeptimer_value);
225         if (val < 0 || val >= size) {
226                 _ERR("value is invalid");
227                 return -1;
228         }
229
230         id = 0;
231         if (vconf_get_int(KEY_SLEEPTIMER_TIMERID, &id) != 0) {
232                 _ERR("Fail to get vconf value");
233                 return -1;
234         }
235
236         data.id = id;
237         data.timer = NULL;
238         tvtimer_foreach_item(_timer_callback, &data);
239
240         if (data.timer) {
241                 tvtimer_cancel_timer(data.timer);
242                 tvtimer_free(data.timer);
243         }
244
245         timer = NULL;
246
247         if (val != 0) {
248                 r = tvtimer_schedule_timer_after_delay(TVTIMER_SLEEP_TIMER,
249                                 sleeptimer_value[val]*60, 0,
250                                 NULL, NULL, &timer);
251                 if (r != 0) {
252                         _ERR("call tvtimer_schedule_timer_after_delay error");
253                         return -1;
254                 }
255         }
256
257         if (vconf_set_int(KEY_SLEEPTIMER, val) != 0) {
258                 _ERR("Fail to set vconf value");
259                 return -1;
260         }
261
262         if (timer) {
263                 tvtimer_get_id(timer, &id);
264                 if (vconf_set_int(KEY_SLEEPTIMER_TIMERID, id) != 0) {
265                         _ERR("Fail to set vconf value");
266                         return -1;
267                 }
268         }
269
270         return 0;
271 }
272 #endif
273
274 /**
275 *  Find item type according to key.
276 *
277 *  @param key [in] The key defined in json file to identify a item.
278 *  @return item type MARCO value, -1 if fail.
279 */
280 static enum item_type _find_type(const char *key)
281 {
282         int i, size;
283         enum item_type result;
284
285         if (!key) {
286                 _ERR("Invalid argument");
287                 return INVALID_TYPE;
288         }
289
290         result = INVALID_TYPE;
291
292         size = _ARRAY_SIZE(item_keymap);
293         for (i = 0; i < size; i++) {
294                 if (!strncmp(item_keymap[i].key,
295                                 key, strlen(item_keymap[i].key))) {
296                         result = item_keymap[i].type;
297                         break;
298                 }
299         }
300
301         return result;
302 }
303
304 /**
305 *  Find array index according to given array value and size.
306 *
307 *  @param array [in] The array want to retrieve.
308 *  @param size [in] The array size.
309 *  @param val [in] The given array value.
310 *  @param index [out] The array index want to get.
311 *  @return 0 if success, -1 if fail.
312 */
313 static int _find_index(unsigned int *array, int size, int val, int *index)
314 {
315         int i;
316
317         if (!array || !index)
318                 return -1;
319
320         for (i = 0; i < size; i++) {
321                 if (array[i] == val) {
322                         *index = i;
323                         return 0;
324                 }
325         }
326
327         return -1;
328 }
329
330 /**
331 *  Set data with integer value.
332 *
333 *  @param key [in] The key defined in json file to identify a item.
334 *  @param val [in] The value want to set to middleware.
335 *  @return 0 if success, -1 if fail.
336 */
337 static int _set_int(const char *key, int val)
338 {
339         enum item_type type;
340         int status;
341
342         if (!key) {
343                 _ERR("Invalid argument");
344                 return -1;
345         }
346
347         status = -1;
348         type = _find_type(key);
349
350         switch (type) {
351         case PICTURE_MODE:
352                 break;
353         case PICTURE_CONTRAST:
354                 break;
355         case PICTURE_BRIGHTNESS:
356                 break;
357         case PICTURE_SHARPNESS:
358                 break;
359         case PICTURE_COLOR:
360                 break;
361         case PICTURE_TINT:
362                 break;
363         case PICTURE_HOMEBAR_OPACITY:
364                 break;
365         case PICTURE_SCREEN_ADJUSTMENT:
366                 break;
367         case SOUND_MODE:
368                 break;
369         case SPEAKER_SETTINGS:
370 #if 0
371                 status = sound_manager_set_speaker_selection(
372                                 speakersettings_item[val]);
373 #endif
374                 break;
375         case SYSTEM_SLEEPTIMER:
376                 //status = _set_sleeptimer(val);
377                 break;
378         case SYSTEM_SUBTITLE:
379                 status = vconf_set_int(KEY_SUBTITLE_LANGUAGE, val);
380                 break;
381         case SYSTEM_RESET:
382                 break;
383         case SYSTEM_CLOCK_MODE:
384                 status = vconf_set_int(KEY_SYSTEM_CLOCK_MODE, val);
385                 break;
386         default:
387                 break;
388         }
389
390         return status;
391 }
392
393 /**
394 *  Get integer value data.
395 *
396 *  @param key [in] The key defined in json file to identify a item.
397 *  @param val [out] The value want to get from middleware.
398 *  @return 0 if success, -1 if fail.
399 */
400 static int _get_int(const char *key, int *val)
401 {
402         enum item_type type;
403         int status, size, index;
404
405         if (!key || !val) {
406                 _ERR("Invalid argument");
407                 return -1;
408         }
409
410         status = -1;
411         type = _find_type(key);
412
413         switch (type) {
414         case PICTURE_MODE:
415                 break;
416         case PICTURE_CONTRAST:
417                 break;
418         case PICTURE_BRIGHTNESS:
419                 break;
420         case PICTURE_SHARPNESS:
421                 break;
422         case PICTURE_COLOR:
423                 break;
424         case PICTURE_TINT:
425                 break;
426         case PICTURE_HOMEBAR_OPACITY:
427                 break;
428         case PICTURE_SCREEN_ADJUSTMENT:
429                 break;
430         case SOUND_MODE:
431                 break;
432         case SPEAKER_SETTINGS:
433 #if 0
434                 status = sound_manager_get_speaker_selection(
435                                 (sound_tv_output_route_e *)val);
436 #endif
437                 if (status == -1)
438                         break;
439
440 #if 0
441                 size = _ARRAY_SIZE(speakersettings_item);
442                 if (_find_index(speakersettings_item,
443                                 size, *val, &index) == -1) {
444                         status = -1;
445                         *val = 0;
446                 } else {
447                         *val = index;
448                 }
449 #endif
450
451                 break;
452         case SYSTEM_SLEEPTIMER:
453                 status = vconf_get_int(KEY_SLEEPTIMER, val);
454                 break;
455         case SYSTEM_SUBTITLE:
456                 status = vconf_get_int(KEY_SUBTITLE_LANGUAGE, val);
457                 break;
458         case SYSTEM_RESET:
459                 break;
460         case SYSTEM_CLOCK_MODE:
461                 status = vconf_get_int(KEY_SYSTEM_CLOCK_MODE, val);
462                 break;
463         default:
464                 break;
465         }
466
467         return status;
468 }
469
470 /**
471 *  Set data with float value.
472 *
473 *  @param key [in] The key defined in json file to identify a item.
474 *  @param val [in] The value want to set to middleware.
475 *  @return 0 if success, -1 if fail.
476 */
477 static int _set_double(const char *key, double val)
478 {
479         return 0;
480 }
481
482 /**
483 *  Get float value data.
484 *
485 *  @param key [in] The key defined in json file to identify a item.
486 *  @param val [out] The value want to get from middleware.
487 *  @return 0 if success, -1 if fail.
488 */
489 static int _get_double(const char *key, double *val)
490 {
491         return 0;
492 }
493
494 /**
495 *  Set data with string value.
496 *
497 *  @param key [in] The key defined in json file to identify a item.
498 *  @param val [in] The value want to set to middleware.
499 *  @return 0 if success, -1 if fail.
500 */
501 static int _set_string(const char *key, const char *val)
502 {
503         enum item_type type;
504         int status;
505
506         if (!key || !val) {
507                 _ERR("Invalid argument");
508                 return -1;
509         }
510
511         status = -1;
512         type = _find_type(key);
513
514         switch (type) {
515         case SYSTEM_LANGUAGE:
516                 status = vconf_set_str(KEY_SYSTEM_LANGUAGE, val);
517                 break;
518         case SYSTEM_COUNTRY:
519                 status = vconf_set_str(KEY_SYSTEM_COUNTRY, val);
520                 break;
521         case SYSTEM_PASSCODE:
522                 status = vconf_set_str(KEY_CHANGE_PASSCODE, val);
523                 break;
524         default:
525                 break;
526         }
527
528         return status;
529 }
530
531 /**
532 *  Get string value data.
533 *
534 *  @param key [in] The key defined in json file to identify a item.
535 *  @param val [out] The value want to get from middleware.
536 *  @return 0 if success, -1 if fail.
537 */
538 static int _get_string(const char *key, char **val)
539 {
540         enum item_type type;
541         int r;
542
543         if (!key) {
544                 _ERR("Invalid argument");
545                 return -1;
546         }
547
548         r = 0;
549         type = _find_type(key);
550
551         switch (type) {
552         case SYSTEM_LANGUAGE:
553                 *val = vconf_get_str(KEY_SYSTEM_LANGUAGE);
554                 if (*val == NULL) {
555                         *val = strdup(SYSTEM_LANGUAGE_DEFAULT_VALUE);
556                         r = -1;
557                 }
558
559                 break;
560         case SYSTEM_WAKEUPTIMER:
561                 *val = vconf_get_str(KEY_WAKEUP_TIMER_SETUP);
562                 if (*val == NULL) {
563                         *val = strdup(WAKEUP_TIMER_SETUP_DEFAULT_VALUE);
564                         r = -1;
565                 }
566
567                 break;
568         case SYSTEM_COUNTRY:
569                 *val = vconf_get_str(KEY_SYSTEM_COUNTRY);
570                 if (*val == NULL) {
571                         *val = strdup(SYSTEM_COUNTRY_DEFAULT_VALUE);
572                         r = -1;
573                 }
574
575                 break;
576         case SYSTEM_PASSCODE:
577                 *val = vconf_get_str(KEY_CHANGE_PASSCODE);
578                 break;
579         default:
580                 break;
581         }
582
583         return r;
584 }
585
586 /**
587 *  Set data with bool value.
588 *
589 *  @param key [in] The key defined in json file to identify a item.
590 *  @param val [in] The value want to set to middleware.
591 *  @return 0 if success, -1 if fail.
592 */
593 static int _set_bool(const char *key, const int val)
594 {
595         enum item_type type;
596         int r;
597
598         if (!key)
599                 return -1;
600
601         r = -1;
602         type = _find_type(key);
603
604         switch (type) {
605         case CHANNEL_LOCK:
606                 r = vconf_set_bool(KEY_CHANNEL_LOCK, val);
607                 break;
608         default:
609                 break;
610         }
611
612         return r;
613 }
614
615 /**
616 *  Get bool value data.
617 *
618 *  @param key [in] The key defined in json file to identify a item.
619 *  @param val [out] The value want to get from middleware.
620 *  @return 0 if success, -1 if fail.
621 */
622 static int _get_bool(const char *key, int *val)
623 {
624         enum item_type type;
625         int r;
626
627         if (!key || !val)
628                 return -1;
629
630         r = -1;
631         type = _find_type(key);
632
633         switch (type) {
634         case CHANNEL_LOCK:
635                 r = vconf_get_bool(KEY_CHANNEL_LOCK, val);
636                 break;
637         default:
638                 break;
639         }
640
641         return r;
642 }
643
644 /**
645 *  Set item value with four kinds of available data type.
646 *
647 *  @param item [in] The item want to set value.
648 *  @param val [in] The given value want to set.
649 *  @return 0 if success, -1 if fail.
650 */
651 int provider_set_list_value(struct settingitem *item, const char *val)
652 {
653         const char *key, *type;
654         int status;
655
656         if (!item || !val) {
657                 _ERR("Invalid argument");
658                 return -1;
659         }
660
661         key = settingitem_get_data_key(item);
662         if (!key) {
663                 _ERR("Get data key failed");
664                 return -1;
665         }
666
667         type = settingitem_get_data_type(item);
668         if (!type) {
669                 _ERR("Get data type failed");
670                 return -1;
671         }
672
673         status = -1;
674
675         if (!strncmp(type, DATA_TYPE_INT, strlen(type)))
676                 status = _set_int(key, atoi(val));
677         else if (!strncmp(type, DATA_TYPE_DOUBLE, strlen(type)))
678                 status = _set_double(key, atof(val));
679         else if (!strncmp(type, DATA_TYPE_STRING, strlen(type)))
680                 status = _set_string(key, val);
681         else if (!strncmp(type, DATA_TYPE_BOOL, strlen(type)))
682                 status = _set_bool(key, atoi(val));
683
684         return status;
685 }
686
687 /**
688 *  Get item value by four kinds of available data type.
689 *
690 *  @param item [in] The item want to get value.
691 *  @return string value if success, NULL on error.
692 */
693 char *provider_get_list_value(struct settingitem *item)
694 {
695         const char *key, *type;
696         int ival, bval;
697         double dval;
698         char *strval, *result;
699
700         if (!item) {
701                 _ERR("Invalid argument");
702                 return NULL;
703         }
704
705         key = settingitem_get_data_key(item);
706         if (!key) {
707                 _ERR("Get data key failed");
708                 return NULL;
709         }
710
711         type = settingitem_get_data_type(item);
712         if (!type) {
713                 _ERR("Get data type failed");
714                 return NULL;
715         }
716
717         result = calloc(1, ARRAY_SIZE);
718         if (!result) {
719                 _ERR("Fail to allocate memory");
720                 return NULL;
721         }
722
723         ival = 0;
724         dval = 0.0;
725         strval = NULL;
726         bval = 0;
727
728         if (!strncmp(type, DATA_TYPE_INT, strlen(type))) {
729                 _get_int(key, &ival);
730                 snprintf(result, ARRAY_SIZE, "%d", ival);
731         } else if (!strncmp(type, DATA_TYPE_DOUBLE, strlen(type))) {
732                 _get_double(key, &dval);
733                 snprintf(result, ARRAY_SIZE, "%f", dval);
734         } else if (!strncmp(type, DATA_TYPE_STRING, strlen(type))) {
735                 _get_string(key, &strval);
736                 snprintf(result, ARRAY_SIZE, "%s", strval);
737                 free(strval);
738         } else if (!strncmp(type, DATA_TYPE_BOOL, strlen(type))) {
739                 _get_bool(key, &bval);
740                 snprintf(result, ARRAY_SIZE, "%d", bval);
741         }
742
743         return result;
744 }
745
746 /**
747 *  Release string value.
748 *
749 *  @param val [in] The given value want to release.
750 *  @return void.
751 */
752 void provider_release_list_value(char *val)
753 {
754         if (!val) {
755                 _ERR("Invalid argument");
756                 return;
757         }
758
759         free(val);
760 }
761
762 /**
763 *  Set slider value.
764 *
765 *  @param item [in] The item want to set value.
766 *  @param val [in] The given value want to set.
767 *  @return 0 if success, -1 if fail.
768 */
769 int provider_set_slider_value(struct settingitem *item, const char *val)
770 {
771         return provider_set_list_value(item, val);
772 }
773
774 /**
775 *  Get slider value.
776 *
777 *  @param item [in] The item want to get value.
778 *  @return double float value, -1.0 if fail.
779 */
780 double provider_get_slider_value(struct settingitem *item)
781 {
782         const char *key, *type;
783         int ival;
784         double dval;
785
786         if (!item) {
787                 _ERR("Invalid argument");
788                 return -1.0;
789         }
790
791         key = settingitem_get_data_key(item);
792         if (!key) {
793                 _ERR("Get data key failed");
794                 return -1.0;
795         }
796
797         type = settingitem_get_data_type(item);
798         if (!type) {
799                 _ERR("Get data type failed");
800                 return -1.0;
801         }
802
803         ival = 0;
804         dval = 0.0;
805
806         if (!strncmp(type,
807                         DATA_TYPE_INT, strlen(type))) {
808                 _get_int(key, &ival);
809                 dval = ival;
810         } else if (!strncmp(type,
811                         DATA_TYPE_DOUBLE, strlen(type))) {
812                 _get_double(key, &dval);
813         }
814
815         return dval;
816 }
817
818 /**
819 *  Get display name that the item value have been selected.
820 *
821 *  @param item [in] The item want to get.
822 *  @return string value if success, NULL on error.
823 */
824 char *provider_get_selected_display_name(struct settingitem *item)
825 {
826         char *sel, *result;
827         const char *val, *disp;
828         Eina_List *list, *tmp;
829         struct listitem *litem;
830
831         if (!item) {
832                 _ERR("Invalid argument");
833                 return NULL;
834         }
835
836         list = settingitem_get_data_list(item);
837         if (!list) {
838                 _ERR("Get data list failed");
839                 return NULL;
840         }
841
842         sel = provider_get_list_value(item);
843         if (!sel) {
844                 _ERR("Provider get value failed");
845                 return NULL;
846         }
847
848         disp = NULL;
849
850         EINA_LIST_FOREACH(list, tmp, litem) {
851                 val = listitem_get_value(litem);
852                 if (val && !strncmp(sel, val, strlen(sel))) {
853                         disp = listitem_get_display_name(litem);
854                         break;
855                 }
856         }
857
858         if (!disp)
859                 disp = listitem_get_display_name(eina_list_nth(list, 0));
860
861         provider_release_list_value(sel);
862
863         result = NULL;
864
865         if (disp)
866                 result = strdup(disp);
867
868         return result;
869 }
870
871 /**
872 *  Get passcode value.
873 *
874 *  @param key [in] The key defined in json file to identify a item.
875 *  @param val [out] The passcode value get from middleware.
876 *  @return 0 if success, -1 if fail.
877 */
878 int provider_get_passcode(const char *key, char **val)
879 {
880         if (!key)
881                 return -1;
882
883         return _get_string(key, val);
884 }
885
886 /**
887 *  Initialize provider module.
888 *
889 *  @return 0 if success, -1 if fail.
890 */
891 int provider_init(void)
892 {
893         _DBG("Not Yet");
894 #if 0
895         if (tvtimer_init() != 0) {
896                 _ERR("Fail to init tvtimer");
897                 return -1;
898         }
899 #endif
900         return 0;
901 }
902
903 /**
904 *  Finalize provider module.
905 *
906 *  @return void.
907 */
908 void provider_fini(void)
909 {
910         _DBG("Not Yet");
911 #if 0
912         tvtimer_fini();
913 #endif
914 }