From b28f09499c8649d8cfb4668efb6779098d0eccb0 Mon Sep 17 00:00:00 2001 From: Donghyun Lee Date: Wed, 25 May 2016 19:35:22 +0900 Subject: [PATCH] LB updated --- org.tizen.devtools/.project | 2 +- org.tizen.devtools/META-INF/MANIFEST.MF | 2 +- org.tizen.devtools/about.html | 2 +- .../html/common_tools/da_overview.htm | 11 +- .../html/common_tools/da_table_filtering.htm | 113 + .../html/common_tools/da_timeline.htm | 4 +- .../html/common_tools/da_ui_hierarchy.htm | 150 +- org.tizen.devtools/html/common_tools/emulator.htm | 183 +- .../html/common_tools/emulator_features.htm | 158 +- .../html/common_tools/keyboard_shortcuts.htm | 238 +- .../html/common_tools/smart_dev_bridge.htm | 14 +- org.tizen.devtools/html/cover_page.htm | 14 +- .../html/download/2_0_release_notes.htm | 12 +- .../html/download/2_1_release_notes.htm | 18 +- .../html/download/2_2_1_release_notes.htm | 2 +- .../html/download/2_2_release_notes.htm | 4 +- .../html/download/2_3_1_release_notes.htm | 8 +- .../html/download/2_3_1_rev1_SDK_release_notes.htm | 6 +- .../html/download/2_3_release_notes.htm | 12 +- .../html/download/2_4_release_notes.htm | 28 +- .../html/download/2_4_rev1_release_notes.htm | 14 +- .../html/download/2_4_rev2_release_notes.htm | 2 +- .../html/download/2_4_rev3_release_notes.htm | 296 ++ .../html/download/2_4_rev4_release_notes.htm | 183 + .../html/download/2_4_rev5_release_notes.htm | 341 ++ .../html/download/advanced_configuration.htm | 99 +- org.tizen.devtools/html/download/download.htm | 533 +-- .../html/download/extension_sdks.htm | 104 +- .../html/download/installing_sdk.htm | 383 +- org.tizen.devtools/html/download/release_notes.htm | 7 +- .../sdk_hardware_accelerated_execution_manager.htm | 196 +- .../html/download/sdk_prerequisites.htm | 174 +- .../html/download/sdk_troubleshooting.htm | 146 +- .../html/download/uninstalling_sdk.htm | 239 +- org.tizen.devtools/html/download/updating_sdk.htm | 170 +- .../html/extension_sdk/extension_sdk.htm | 2 +- .../in_app_purchase_ programming_guide.htm | 1996 ++++---- .../html/images/adv_config_extra.png | Bin 0 -> 75019 bytes .../html/images/adv_config_package.png | Bin 0 -> 68632 bytes .../html/images/adv_config_proxy.png | Bin 0 -> 47097 bytes .../html/images/adv_config_sdk_image.png | Bin 0 -> 61697 bytes org.tizen.devtools/html/images/article.png | Bin 278 -> 0 bytes org.tizen.devtools/html/images/aside.png | Bin 286 -> 0 bytes org.tizen.devtools/html/images/audio.png | Bin 1522 -> 0 bytes org.tizen.devtools/html/images/canvas.png | Bin 1082 -> 0 bytes .../html/images/create_new_emulator.png | Bin 0 -> 74589 bytes .../html/images/create_new_emulator_platform.png | Bin 0 -> 16993 bytes .../html/images/create_new_emulator_setting.png | Bin 0 -> 112660 bytes .../html/images/create_new_emulator_template.png | Bin 0 -> 26684 bytes .../images/da_filtering_add_filter_property.png | Bin 0 -> 65509 bytes .../images/da_filtering_apply_filter_property.png | Bin 0 -> 185844 bytes .../da_filtering_delete_all_filter_properties.png | Bin 0 -> 193807 bytes .../images/da_filtering_delete_filter_property.png | Bin 0 -> 146069 bytes .../html/images/da_filtering_filter_dialog.png | Bin 0 -> 105902 bytes ...tering_verify_filter_properties_filter_icon.png | Bin 0 -> 124334 bytes ...tering_verify_filter_properties_filter_menu.png | Bin 0 -> 119271 bytes org.tizen.devtools/html/images/emulator_cli.png | Bin 186920 -> 62579 bytes .../html/images/emulator_clone_icon.png | Bin 0 -> 2933 bytes .../html/images/emulator_create_icon.png | Bin 0 -> 2873 bytes .../html/images/emulator_device_templates.png | Bin 0 -> 105162 bytes .../html/images/emulator_launch_button.png | Bin 0 -> 3155 bytes org.tizen.devtools/html/images/emulator_list.png | Bin 0 -> 66745 bytes .../images/emulator_list_in_emulator_manager.png | Bin 0 -> 103925 bytes .../html/images/emulator_manager.png | Bin 52760 -> 0 bytes .../images/emulator_manager_profile_button.png | Bin 0 -> 4198 bytes .../html/images/emulator_modify_icon.png | Bin 0 -> 3181 bytes .../html/images/emulator_platforms_list.png | Bin 0 -> 93978 bytes .../html/images/emulator_trash_icon.png | Bin 0 -> 2917 bytes org.tizen.devtools/html/images/enventor_about.png | Bin 1608 -> 779 bytes .../html/images/enventor_autocomplete.png | Bin 89881 -> 97477 bytes .../html/images/enventor_basic_view.png | Bin 103010 -> 97631 bytes .../html/images/enventor_braces_highlight.png | Bin 0 -> 97791 bytes .../html/images/enventor_candidate.png | Bin 89579 -> 98671 bytes .../images/enventor_colorselector_function.png | Bin 0 -> 108249 bytes .../html/images/enventor_console.png | Bin 856 -> 333 bytes .../html/images/enventor_console_error.png | Bin 107248 -> 113618 bytes .../html/images/enventor_edc_navigator.png | Bin 0 -> 111462 bytes org.tizen.devtools/html/images/enventor_find.png | Bin 1718 -> 828 bytes .../html/images/enventor_function.png | Bin 105528 -> 101007 bytes org.tizen.devtools/html/images/enventor_goto.png | Bin 1691 -> 603 bytes .../html/images/enventor_highlight.png | Bin 1419 -> 504 bytes .../html/images/enventor_image_preview.png | Bin 120109 -> 119688 bytes org.tizen.devtools/html/images/enventor_layout.png | Bin 73598 -> 83698 bytes org.tizen.devtools/html/images/enventor_lines.png | Bin 2082 -> 759 bytes .../html/images/enventor_live_image.png | Bin 0 -> 396 bytes .../html/images/enventor_live_rect.png | Bin 0 -> 257 bytes .../html/images/enventor_live_spacer.png | Bin 0 -> 396 bytes .../html/images/enventor_live_swallow.png | Bin 0 -> 879 bytes .../html/images/enventor_live_text.png | Bin 0 -> 465 bytes .../html/images/enventor_live_textblock.png | Bin 0 -> 561 bytes .../html/images/enventor_live_view_resize.png | Bin 0 -> 130088 bytes .../images/enventor_live_view_resize_control.png | Bin 0 -> 1645 bytes .../html/images/enventor_live_view_zoom.png | Bin 88535 -> 134947 bytes .../images/enventor_live_view_zoom_control.png | Bin 0 -> 1637 bytes .../html/images/enventor_liveedit.png | Bin 1384 -> 0 bytes .../html/images/enventor_navigator.png | Bin 0 -> 296 bytes .../html/images/enventor_part_highlight.png | Bin 96624 -> 105682 bytes .../html/images/enventor_part_objects.png | Bin 82653 -> 105584 bytes .../html/images/enventor_preview_object.png | Bin 85007 -> 108732 bytes org.tizen.devtools/html/images/enventor_redo.png | Bin 1430 -> 673 bytes org.tizen.devtools/html/images/enventor_save.png | Bin 1142 -> 411 bytes .../html/images/enventor_setting.png | Bin 1518 -> 774 bytes .../html/images/enventor_settings_window.png | Bin 88452 -> 79556 bytes .../html/images/enventor_source_code.png | Bin 76922 -> 78980 bytes org.tizen.devtools/html/images/enventor_status.png | Bin 732 -> 297 bytes .../html/images/enventor_swallow.png | Bin 1104 -> 382 bytes .../html/images/enventor_text_settings_window.png | Bin 88720 -> 81773 bytes .../html/images/enventor_text_view_zoom.png | Bin 89363 -> 106521 bytes org.tizen.devtools/html/images/enventor_undo.png | Bin 1620 -> 671 bytes org.tizen.devtools/html/images/extension_sdk.png | Bin 0 -> 75019 bytes .../html/images/extension_sdk_add_repository.png | Bin 0 -> 25069 bytes .../html/images/extension_sdk_modify.png | Bin 0 -> 26498 bytes .../html/images/extension_sdk_modify_confirm.png | Bin 0 -> 66596 bytes .../html/images/extension_sdk_modify_ok.png | Bin 0 -> 26645 bytes .../html/images/extension_sdk_remove.png | Bin 0 -> 73031 bytes .../html/images/extension_sdk_trash.png | Bin 0 -> 322 bytes org.tizen.devtools/html/images/figure.png | Bin 1129 -> 0 bytes org.tizen.devtools/html/images/footer.png | Bin 464 -> 0 bytes org.tizen.devtools/html/images/header.png | Bin 463 -> 0 bytes org.tizen.devtools/html/images/hgroup.png | Bin 853 -> 0 bytes org.tizen.devtools/html/images/hori_split_view.png | Bin 210 -> 0 bytes .../html/images/install23_advanced.png | Bin 0 -> 58498 bytes .../html/images/install23_components.png | Bin 0 -> 91014 bytes org.tizen.devtools/html/images/install23_image.png | Bin 0 -> 78630 bytes .../html/images/install23_install.png | Bin 0 -> 90762 bytes .../html/images/install23_manager.png | Bin 0 -> 227079 bytes org.tizen.devtools/html/images/install_cli.png | Bin 0 -> 38237 bytes .../html/images/install_complete.png | Bin 0 -> 96577 bytes org.tizen.devtools/html/images/install_gui.png | Bin 0 -> 88693 bytes org.tizen.devtools/html/images/keygen.png | Bin 1077 -> 0 bytes org.tizen.devtools/html/images/launch.png | Bin 1011 -> 0 bytes org.tizen.devtools/html/images/mark.png | Bin 865 -> 0 bytes org.tizen.devtools/html/images/math.png | Bin 935 -> 0 bytes org.tizen.devtools/html/images/meter.png | Bin 1062 -> 0 bytes org.tizen.devtools/html/images/mod_icon.png | Bin 452 -> 0 bytes .../html/images/multiple_screen_alt_loc_n.png | Bin 0 -> 32782 bytes .../html/images/multiple_screen_alt_resource_n.png | Bin 0 -> 100734 bytes .../html/images/multiple_screen_alt_set_n.png | Bin 0 -> 97868 bytes .../multiple_screen_alt_set_properties_n.png | Bin 0 -> 84254 bytes .../html/images/multiple_screen_config_map_n.png | Bin 0 -> 72956 bytes .../html/images/multiple_screen_config_n.png | Bin 0 -> 49432 bytes .../html/images/multiple_screen_loc_n.png | Bin 0 -> 41986 bytes .../images/multiple_screen_relationships_n.png | Bin 0 -> 47076 bytes .../html/images/native_application_wizard.png | Bin 145021 -> 217827 bytes org.tizen.devtools/html/images/nav.png | Bin 1567 -> 0 bytes org.tizen.devtools/html/images/nuib_fit.png | Bin 0 -> 3115 bytes .../html/images/nuib_launch_screenconfigurator.png | Bin 0 -> 2947 bytes org.tizen.devtools/html/images/nuib_locale.png | Bin 0 -> 843 bytes .../html/images/nuib_navigation_001.png | Bin 12084 -> 17738 bytes .../html/images/nuib_new_screen_configurator.png | Bin 0 -> 43835 bytes .../html/images/nuib_new_view_template_wizard.png | Bin 17942 -> 42561 bytes .../html/images/nuib_new_view_wizard.png | Bin 18674 -> 42422 bytes .../html/images/nuib_outline_001.png | Bin 8961 -> 25778 bytes .../html/images/nuib_resourcemanager_view.png | Bin 0 -> 16947 bytes org.tizen.devtools/html/images/nuib_resources.png | Bin 14407 -> 0 bytes org.tizen.devtools/html/images/nuib_scale.png | Bin 0 -> 1485 bytes .../html/images/nuib_screen_configurator.png | Bin 0 -> 2470 bytes org.tizen.devtools/html/images/nuib_source_tab.png | Bin 0 -> 119630 bytes org.tizen.devtools/html/images/nuib_ui_builder.png | Bin 202039 -> 211309 bytes org.tizen.devtools/html/images/nuib_we_editor.png | Bin 75592 -> 114010 bytes org.tizen.devtools/html/images/nuib_we_max_0.png | Bin 2984 -> 0 bytes .../html/images/nuib_we_resolution.png | Bin 6720 -> 0 bytes .../html/images/nuib_we_zoomin_0.png | Bin 2972 -> 0 bytes .../html/images/nuib_we_zoomout_0.png | Bin 2854 -> 0 bytes org.tizen.devtools/html/images/output.png | Bin 1060 -> 0 bytes org.tizen.devtools/html/images/progress.png | Bin 1176 -> 0 bytes org.tizen.devtools/html/images/properties_1.png | Bin 29726 -> 42728 bytes .../html/images/properties_go_to_1.png | Bin 53864 -> 59250 bytes .../html/images/properties_specification_1.png | Bin 70824 -> 55144 bytes .../html/images/rest_viewer_dialog.png | Bin 65103 -> 57169 bytes org.tizen.devtools/html/images/ruby.png | Bin 377 -> 0 bytes org.tizen.devtools/html/images/sdk2_0-haxm-cmd.png | Bin 52873 -> 23986 bytes .../html/images/sdk2_0-haxm-mac1.png | Bin 310014 -> 141155 bytes .../html/images/sdk2_0-haxm-mac2.png | Bin 336780 -> 127926 bytes .../html/images/sdk2_0-haxm-mac3.png | Bin 449000 -> 118324 bytes .../html/images/sdk2_0-haxm-mac4.png | Bin 305194 -> 108969 bytes .../html/images/sdk2_0-haxm-mac5.png | Bin 289717 -> 36697 bytes .../html/images/sdk2_0-haxm-mac6.png | Bin 263573 -> 131006 bytes .../html/images/sdk2_0-haxm-mac7.png | Bin 267254 -> 0 bytes .../html/images/sdk2_0-haxm-win1.png | Bin 245245 -> 127412 bytes .../html/images/sdk2_0-haxm-win2.png | Bin 215184 -> 0 bytes .../html/images/sdk2_0-haxm-win3.png | Bin 201058 -> 74901 bytes .../html/images/sdk2_0-haxm-win4.png | Bin 169864 -> 63653 bytes .../html/images/sdk2_0-haxm-win5.png | Bin 232606 -> 97530 bytes org.tizen.devtools/html/images/sdk_uninstaller.png | Bin 0 -> 173650 bytes .../html/images/sdk_uninstaller_uninstall_icon.png | Bin 0 -> 2392 bytes org.tizen.devtools/html/images/section.png | Bin 870 -> 0 bytes org.tizen.devtools/html/images/skin.png | Bin 1136 -> 0 bytes org.tizen.devtools/html/images/source.png | Bin 1880 -> 0 bytes org.tizen.devtools/html/images/source_view.png | Bin 335 -> 0 bytes org.tizen.devtools/html/images/storyboard_add.png | Bin 0 -> 52240 bytes .../html/images/storyboard_add_new.png | Bin 52782 -> 0 bytes org.tizen.devtools/html/images/storyboard_app.png | Bin 0 -> 125431 bytes .../html/images/storyboard_callback.png | Bin 0 -> 79892 bytes .../html/images/storyboard_codegen.png | Bin 106555 -> 0 bytes .../html/images/storyboard_comp_prop.png | Bin 0 -> 76177 bytes .../html/images/storyboard_conn_prop.png | Bin 0 -> 39752 bytes .../html/images/storyboard_conn_properties.png | Bin 32166 -> 0 bytes .../html/images/storyboard_contextmenu.png | Bin 19883 -> 0 bytes .../html/images/storyboard_diagram.png | Bin 97817 -> 0 bytes org.tizen.devtools/html/images/storyboard_drag.png | Bin 14722 -> 38562 bytes .../html/images/storyboard_events.png | Bin 0 -> 47793 bytes org.tizen.devtools/html/images/storyboard_new.png | Bin 0 -> 39754 bytes .../html/images/storyboard_options.png | Bin 0 -> 51868 bytes .../html/images/storyboard_properties.png | Bin 50209 -> 0 bytes .../html/images/storyboard_views.png | Bin 0 -> 35981 bytes .../html/images/storyboard_wizard.png | Bin 152591 -> 0 bytes org.tizen.devtools/html/images/summary.png | Bin 631 -> 0 bytes org.tizen.devtools/html/images/svg.png | Bin 909 -> 0 bytes .../html/images/thread_pool_lifecycle_1.png | Bin 30451 -> 0 bytes org.tizen.devtools/html/images/time.png | Bin 1444 -> 0 bytes org.tizen.devtools/html/images/uac.png | Bin 23985 -> 56046 bytes .../html/images/unit_test_create.png | Bin 91311 -> 66278 bytes .../update_manager_information_dialog_manager.png | Bin 0 -> 22821 bytes .../update_manager_information_dialog_sdk.png | Bin 0 -> 31777 bytes .../images/update_manager_installed_packages.png | Bin 0 -> 125465 bytes ...update_manager_installed_packages_uninstall.png | Bin 0 -> 129108 bytes .../update_manager_installed_packages_update.png | Bin 0 -> 124914 bytes .../html/images/update_manager_updatable_icon.png | Bin 0 -> 1064 bytes org.tizen.devtools/html/images/vert_split_view.png | Bin 201 -> 0 bytes org.tizen.devtools/html/images/video.png | Bin 768 -> 0 bytes .../html/images/web_application_wizard.png | Bin 171577 -> 94495 bytes org.tizen.devtools/html/index.htm | 67 +- .../html/native_tools/api_privilege_checker_n.htm | 2 +- .../html/native_tools/command_line_interface_n.htm | 25 +- .../html/native_tools/manifest_text_editor_n.htm | 20 +- .../html/native_tools/multiple_screens_n.htm | 414 ++ .../html/native_tools/project_conversion_n.htm | 4 +- .../html/native_tools/project_wizard_n.htm | 45 +- .../html/native_tools/resource_manager_n.htm | 4 +- .../html/native_tools/static_analyzer_n.htm | 2 +- .../html/native_tools/storyboard_n.htm | 112 +- org.tizen.devtools/html/native_tools/t_trace_n.htm | 11 +- org.tizen.devtools/html/native_tools/tools_n.htm | 2 +- .../html/native_tools/uibuilder_n.htm | 123 +- .../html/native_tools/unit_test_n.htm | 65 +- .../html/web_tools/config_editor_w.htm | 20 +- .../html/web_tools/content_assist_w.htm | 6 +- .../html/web_tools/html_editor_w.htm | 200 +- .../html/web_tools/js_analyzer_w.htm | 34 +- org.tizen.devtools/html/web_tools/js_editor_w.htm | 4 +- .../html/web_tools/privilege_checker_w.htm | 3 +- .../html/web_tools/project_wizard_w.htm | 36 +- .../html/web_tools/rest_viewer_w.htm | 6 +- .../html/web_tools/set_ide_preference_w.htm | 38 +- org.tizen.devtools/html/web_tools/tools_w.htm | 6 +- .../html/web_tools/web_simulator_features_w.htm | 9 +- .../html/web_tools/web_unit_test_tool_w.htm | 14 +- org.tizen.devtools/index.xml | 56 +- org.tizen.gettingstarted/.project | 2 +- org.tizen.gettingstarted/META-INF/MANIFEST.MF | 2 +- org.tizen.gettingstarted/about.html | 2 +- org.tizen.gettingstarted/html/cover_page.htm | 166 +- org.tizen.gettingstarted/html/images/Thumbs.db | Bin 0 -> 107520 bytes .../html/images/app_run_mn.png | Bin 0 -> 56557 bytes .../html/images/app_run_mw.png | Bin 0 -> 56761 bytes .../html/images/app_run_wn.png | Bin 0 -> 54724 bytes .../html/images/app_run_wn_watch.png | Bin 0 -> 54222 bytes .../html/images/app_run_wn_widget.png | Bin 0 -> 54089 bytes .../html/images/app_run_ww.png | Bin 0 -> 60147 bytes .../html/images/app_run_ww_watch.png | Bin 0 -> 56889 bytes .../html/images/basic_app_config_mn.png | Bin 0 -> 40142 bytes .../html/images/basic_app_config_w.png | Bin 0 -> 46638 bytes .../html/images/basic_app_config_wn.png | Bin 0 -> 40154 bytes .../html/images/basic_app_config_wn_watch.png | Bin 0 -> 40277 bytes .../html/images/basic_app_config_wn_widget.png | Bin 0 -> 40035 bytes .../html/images/basic_app_config_ww_watch.png | Bin 0 -> 28941 bytes .../html/images/basic_app_project_explorer_mn.png | Bin 0 -> 5725 bytes .../html/images/basic_app_project_explorer_mw.png | Bin 0 -> 8005 bytes .../html/images/basic_app_project_explorer_wn.png | Bin 0 -> 5765 bytes .../images/basic_app_project_explorer_wn_watch.png | Bin 0 -> 5830 bytes .../basic_app_project_explorer_wn_widget.png | Bin 0 -> 5827 bytes .../html/images/basic_app_project_explorer_ww.png | Bin 0 -> 7653 bytes .../images/basic_app_project_explorer_ww_watch.png | Bin 0 -> 9355 bytes .../html/images/basic_app_running_1_mw.png | Bin 0 -> 5746 bytes .../html/images/basic_app_running_1_ww.png | Bin 0 -> 5241 bytes .../html/images/basic_app_running_2_mw.png | Bin 0 -> 5032 bytes .../html/images/basic_app_running_2_ww.png | Bin 0 -> 4692 bytes .../html/images/basic_app_running_mn.png | Bin 0 -> 2204 bytes .../html/images/basic_app_running_wn.png | Bin 0 -> 4187 bytes .../html/images/basic_app_running_wn_watch.png | Bin 0 -> 5668 bytes .../html/images/basic_app_running_wn_widget.png | Bin 0 -> 4281 bytes .../html/images/basic_app_running_ww_watch.png | Bin 0 -> 5432 bytes .../html/images/build_automatic_n.png | Bin 0 -> 13915 bytes .../html/images/build_automatic_w.png | Bin 0 -> 13736 bytes .../html/images/build_icon_mn.png | Bin 0 -> 653 bytes .../html/images/build_manual_mn.png | Bin 0 -> 26470 bytes .../html/images/build_manual_mw.png | Bin 0 -> 28596 bytes .../html/images/build_manual_watch_wn.png | Bin 0 -> 26775 bytes .../html/images/build_manual_watch_ww.png | Bin 0 -> 30534 bytes .../html/images/build_manual_widget_wn.png | Bin 0 -> 26729 bytes .../html/images/build_manual_wn.png | Bin 0 -> 26520 bytes .../html/images/build_manual_ww.png | Bin 0 -> 28511 bytes .../html/images/build_ui_basic_mw.png | Bin 0 -> 29824 bytes .../html/images/build_ui_basic_textbox_mw.png | Bin 0 -> 29706 bytes .../html/images/build_ui_basic_textbox_ww.png | Bin 0 -> 8159 bytes .../html/images/build_ui_basic_ww.png | Bin 0 -> 5977 bytes .../html/images/change_perspective_n.png | Bin 0 -> 6199 bytes .../html/images/change_perspective_w.png | Bin 0 -> 5935 bytes .../html/images/create_project_1_n.png | Bin 0 -> 10670 bytes .../html/images/create_project_1_w.png | Bin 0 -> 10488 bytes .../html/images/create_project_2_mn.png | Bin 0 -> 51953 bytes .../html/images/create_project_2_mw.png | Bin 0 -> 51068 bytes .../html/images/create_project_2_wn.png | Bin 0 -> 54769 bytes .../html/images/create_project_2_wn_watch.png | Bin 0 -> 53236 bytes .../html/images/create_project_2_wn_widget.png | Bin 0 -> 52744 bytes .../html/images/create_project_2_ww.png | Bin 0 -> 63990 bytes .../html/images/create_project_2_ww_watch.png | Bin 0 -> 76332 bytes .../html/images/emulator_icon.png | Bin 0 -> 7787 bytes .../html/images/emulator_launch_mobile.png | Bin 0 -> 73435 bytes .../html/images/emulator_launch_wearable.png | Bin 0 -> 74350 bytes .../html/images/emulator_new_mobile.png | Bin 0 -> 64795 bytes .../html/images/emulator_new_wearable.png | Bin 0 -> 64730 bytes .../html/images/emulator_play.png | Bin 0 -> 582 bytes .../html/images/emulator_running_mn.png | Bin 0 -> 5025 bytes .../html/images/emulator_running_mw.png | Bin 0 -> 6272 bytes .../html/images/emulator_running_watch_ww.png | Bin 0 -> 19233 bytes .../html/images/emulator_running_wn.png | Bin 0 -> 27475 bytes .../html/images/emulator_running_wn_widget.png | Bin 0 -> 30267 bytes .../html/images/emulator_running_ww.png | Bin 0 -> 24835 bytes .../html/images/emulator_settings_mobile.png | Bin 0 -> 86201 bytes .../html/images/emulator_settings_wearable.png | Bin 0 -> 83552 bytes .../html/images/emulator_target_bt.png | Bin 0 -> 115003 bytes .../html/images/emulator_target_debug.png | Bin 0 -> 44344 bytes .../html/images/emulator_target_wifi.png | Bin 0 -> 65363 bytes .../html/images/emulator_window_mobile.png | Bin 0 -> 116648 bytes .../html/images/emulator_window_wearable.png | Bin 0 -> 42967 bytes .../html/images/first_app_download_wn.png | Bin 0 -> 100053 bytes org.tizen.gettingstarted/html/images/hello.png | Bin 15432 -> 0 bytes .../html/images/hello_wearable_emulator.png | Bin 25463 -> 0 bytes .../html/images/hello_wearable_js.png | Bin 155158 -> 0 bytes .../html/images/helloworld_index.png | Bin 151268 -> 0 bytes .../html/images/nuib_cadvl_wysiwyg_editor.png | Bin 105268 -> 0 bytes .../html/images/nuib_soubp_app_xml.png | Bin 459 -> 0 bytes .../html/images/nuib_soubp_folder.png | Bin 367 -> 0 bytes .../html/images/nuib_soubp_includes.png | Bin 665 -> 0 bytes .../html/images/nuib_soubp_layout_tuml.png | Bin 394 -> 0 bytes .../html/images/nuib_soubp_project_explorer.png | Bin 36138 -> 0 bytes .../html/images/nuib_soubp_tizen_icon.png | Bin 841 -> 0 bytes .../html/images/nuib_soubp_tizen_manifest_xml.png | Bin 483 -> 0 bytes .../html/images/profile_mobile.png | Bin 0 -> 151503 bytes .../html/images/profile_wearable.png | Bin 0 -> 99160 bytes .../html/images/remote_allow_gear_ww.png | Bin 0 -> 51376 bytes .../html/images/remote_conn_add_ww.png | Bin 0 -> 8380 bytes .../html/images/remote_conn_mgr_ww.png | Bin 0 -> 4067 bytes .../html/images/remote_conn_new_ww.png | Bin 0 -> 27414 bytes .../html/images/remote_connect_ww.png | Bin 0 -> 13666 bytes .../html/images/remote_connected_ww.png | Bin 0 -> 23620 bytes .../html/images/run_configurations_n.png | Bin 0 -> 64338 bytes .../html/images/run_configurations_n_watch.png | Bin 0 -> 65669 bytes .../html/images/run_configurations_n_widget.png | Bin 0 -> 65056 bytes .../html/images/run_configurations_w.png | Bin 0 -> 57561 bytes .../html/images/run_configurations_watch_ww.png | Bin 0 -> 56055 bytes .../html/images/run_new_config_wn.png | Bin 0 -> 542 bytes .../html/images/running_project.png | Bin 22712 -> 0 bytes .../html/images/simple_ui_hello_tau_mw.png | Bin 0 -> 51609 bytes .../html/images/simple_ui_hello_tau_ww.png | Bin 0 -> 5155 bytes .../html/images/simple_ui_screen_wn.png | Bin 0 -> 23969 bytes .../html/images/simple_ui_tau_adv_list_ww.png | Bin 0 -> 14297 bytes .../html/images/simple_ui_tau_anchor_list_mw.png | Bin 0 -> 26161 bytes .../html/images/simple_ui_tau_button_mw.png | Bin 0 -> 25214 bytes .../html/images/simple_ui_tau_create_mw.png | Bin 0 -> 362716 bytes .../html/images/simple_ui_tau_create_ww.png | Bin 0 -> 55982 bytes .../html/images/simple_ui_tau_css_mw.png | Bin 0 -> 10227 bytes .../html/images/simple_ui_tau_css_ww.png | Bin 0 -> 6095 bytes .../html/images/simple_ui_tau_dir_mw.png | Bin 0 -> 38965 bytes .../html/images/simple_ui_tau_dir_ww.png | Bin 0 -> 19326 bytes .../html/images/simple_ui_tau_list_mw.png | Bin 0 -> 23658 bytes .../html/images/simple_ui_tau_list_ww.png | Bin 0 -> 6374 bytes .../html/images/simple_ui_tau_move_mw.png | Bin 0 -> 25364 bytes .../html/images/simple_ui_tau_move_ww.png | Bin 0 -> 17753 bytes .../html/images/simple_ui_tau_new_js_mw.png | Bin 0 -> 70429 bytes .../html/images/simple_ui_tau_new_js_name_mw.png | Bin 0 -> 20435 bytes .../html/images/simple_ui_tau_relation_mw.png | Bin 0 -> 36289 bytes .../html/images/simple_ui_tau_relation_ww.png | Bin 0 -> 32553 bytes .../html/images/simple_ui_update_mgr_mw.png | Bin 0 -> 106444 bytes .../html/images/simple_ui_update_mgr_ww.png | Bin 0 -> 49297 bytes .../html/images/simulator_run_mw.png | Bin 0 -> 65868 bytes .../html/images/simulator_running_mw.png | Bin 0 -> 82860 bytes .../html/images/ui_builder_add.png | Bin 0 -> 720 bytes .../html/images/ui_builder_addview1.png | Bin 0 -> 12521 bytes .../html/images/ui_builder_addview2.png | Bin 0 -> 29398 bytes .../html/images/ui_builder_assist.png | Bin 0 -> 78562 bytes .../html/images/ui_builder_autocomplete.png | Bin 0 -> 63974 bytes .../html/images/ui_builder_change_view.png | Bin 0 -> 50441 bytes .../html/images/ui_builder_content_assist.png | Bin 0 -> 99235 bytes .../html/images/ui_builder_design_view.png | Bin 0 -> 57544 bytes .../html/images/ui_builder_drag.png | Bin 0 -> 59380 bytes .../html/images/ui_builder_drop.png | Bin 0 -> 51307 bytes .../html/images/ui_builder_edc.png | Bin 0 -> 21763 bytes .../html/images/ui_builder_efl_structure.png | Bin 0 -> 24500 bytes .../html/images/ui_builder_event_button_text.png | Bin 0 -> 24292 bytes .../images/ui_builder_event_generated_snippets.png | Bin 0 -> 58954 bytes .../html/images/ui_builder_event_handler_code.png | Bin 0 -> 80006 bytes .../html/images/ui_builder_event_layout.png | Bin 0 -> 147347 bytes .../html/images/ui_builder_event_tab.png | Bin 0 -> 96045 bytes .../html/images/ui_builder_folder.png | Bin 0 -> 350 bytes .../html/images/ui_builder_go.png | Bin 0 -> 717 bytes .../html/images/ui_builder_icon.png | Bin 0 -> 810 bytes .../html/images/ui_builder_layout.png | Bin 0 -> 467 bytes .../html/images/ui_builder_login.png | Bin 0 -> 76481 bytes .../html/images/ui_builder_manifest.png | Bin 0 -> 486 bytes .../html/images/ui_builder_negative.png | Bin 0 -> 104173 bytes .../html/images/ui_builder_new_dialog.png | Bin 0 -> 39071 bytes .../html/images/ui_builder_new_view.png | Bin 0 -> 37378 bytes .../html/images/ui_builder_positive.png | Bin 0 -> 106449 bytes .../html/images/ui_builder_project_details.png | Bin 0 -> 111520 bytes .../html/images/ui_builder_project_structure.png | Bin 0 -> 38505 bytes .../html/images/ui_builder_properties.png | Bin 0 -> 62673 bytes .../html/images/ui_builder_remove.png | Bin 0 -> 711 bytes .../html/images/ui_builder_retained_mode.png | Bin 0 -> 20970 bytes .../html/images/ui_builder_root.png | Bin 0 -> 7518 bytes .../html/images/ui_builder_run.png | Bin 0 -> 20937 bytes .../html/images/ui_builder_selection.png | Bin 0 -> 72404 bytes .../html/images/ui_builder_source.png | Bin 0 -> 82092 bytes .../html/images/ui_builder_storyboard_all.png | Bin 0 -> 31616 bytes .../html/images/ui_builder_storyboard_drag.png | Bin 0 -> 34002 bytes .../html/images/ui_builder_storyboard_drop.png | Bin 0 -> 39766 bytes .../html/images/ui_builder_storyboard_options.png | Bin 0 -> 54323 bytes .../images/ui_builder_storyboard_properties.png | Bin 0 -> 36237 bytes .../images/ui_builder_storyboard_transitions.png | Bin 0 -> 74810 bytes .../html/images/ui_builder_ui_hierarchy.png | Bin 0 -> 10928 bytes .../html/images/ui_builder_view_hierarchy.png | Bin 0 -> 11427 bytes .../html/images/ui_builder_view_shown.png | Bin 0 -> 86592 bytes .../html/images/ui_builder_views.png | Bin 0 -> 41280 bytes .../html/images/watch_run_change_wn.png | Bin 0 -> 37313 bytes .../html/images/watch_run_face_wn.png | Bin 0 -> 18336 bytes .../html/images/watch_run_install_watch_ww.png | Bin 0 -> 29550 bytes .../html/images/watch_run_install_wn.png | Bin 0 -> 56766 bytes .../html/images/widget_app_wearable.png | Bin 0 -> 74521 bytes .../html/images/widget_run_add_home_wn.png | Bin 0 -> 38045 bytes .../html/images/widget_run_home_wn.png | Bin 0 -> 30506 bytes org.tizen.gettingstarted/html/index.htm | 117 +- .../html/native/app_model/application_model_n.htm | 8 +- .../html/native/cover_page_n.htm | 18 +- .../html/native/details/app_filtering_n.htm | 8 +- .../html/native/details/details_n.htm | 56 +- .../html/native/details/error_handling_n.htm | 27 +- .../html/native/details/io_overview_n.htm | 2 +- .../html/native/details/sec_privileges_n.htm | 1157 ++--- .../html/native/details/tizen_apis_n.htm | 152 +- .../html/native/first_app/first_app_n.htm | 375 -- .../html/native/mobile/build_app_mn.htm | 101 + .../html/native/mobile/build_ui_mn.htm | 257 ++ .../html/native/mobile/create_project_mn.htm | 168 + .../html/native/mobile/first_app_mn.htm | 74 + .../html/native/mobile/run_app_mn.htm | 184 + .../html/native/process/app_dev_process_n.htm | 63 +- .../html/native/process/creating_app_project_n.htm | 99 + .../html/native/process/debugging_app_n.htm | 102 +- .../html/native/process/designing_app_ui_n.htm | 227 - .../html/native/process/performance_n.htm | 64 +- .../html/native/process/setting_properties_n.htm | 63 +- .../html/native/ui/ui_builder_app_design_mn.htm | 391 ++ .../html/native/ui/ui_builder_overview_mn.htm | 197 + .../html/native/wearable/build_app_wn.htm | 100 + .../html/native/wearable/build_ui_wn.htm | 247 + .../html/native/wearable/create_project_wn.htm | 168 + .../html/native/wearable/first_app_wn.htm | 86 + .../html/native/wearable/run_app_wn.htm | 219 + .../native/wearable_watch/build_app_watch_wn.htm | 101 + .../native/wearable_watch/build_ui_watch_wn.htm | 302 ++ .../wearable_watch/create_project_watch_wn.htm | 168 + .../native/wearable_watch/first_app_watch_wn.htm | 84 + .../native/wearable_watch/run_app_watch_wn.htm | 224 + .../native/wearable_widget/build_app_widget_wn.htm | 100 + .../native/wearable_widget/build_ui_widget_wn.htm | 349 ++ .../wearable_widget/create_project_widget_wn.htm | 182 + .../native/wearable_widget/first_app_widget_wn.htm | 90 + .../native/wearable_widget/run_app_widget_wn.htm | 227 + org.tizen.gettingstarted/html/preface.htm | 146 - org.tizen.gettingstarted/html/tizen_websites.htm | 81 - .../html/web/app_model/application_model_w.htm | 2 +- org.tizen.gettingstarted/html/web/cover_page_w.htm | 12 +- .../html/web/details/app_filtering_w.htm | 33 +- .../html/web/details/details_w.htm | 48 - .../html/web/details/sec_privileges_w.htm | 170 +- .../html/web/details/tizen_apis_w.htm | 74 +- .../html/web/details/web_runtime_w.htm | 10 +- .../html/web/first_app/first_app_w.htm | 161 - .../html/web/mobile/build_app_mw.htm | 98 + .../html/web/mobile/build_ui_mw.htm | 619 +++ .../html/web/mobile/create_project_mw.htm | 178 + .../html/web/mobile/first_app_mw.htm | 78 + .../html/web/mobile/run_app_mw.htm | 204 + .../html/web/process/app_dev_process_w.htm | 51 +- .../html/web/process/coding_app_w.htm | 2 +- .../html/web/process/creating_app_project_w.htm | 7 +- .../html/web/process/run_debug_app_w.htm | 3 +- .../html/web/process/setting_properties_w.htm | 95 +- .../html/web/wearable/build_app_ww.htm | 98 + .../html/web/wearable/build_ui_ww.htm | 611 +++ .../html/web/wearable/create_project_ww.htm | 175 + .../html/web/wearable/first_app_ww.htm | 87 + .../html/web/wearable/run_app_ww.htm | 223 + .../html/web/wearable_watch/build_app_watch_ww.htm | 96 + .../html/web/wearable_watch/build_ui_watch_ww.htm | 437 ++ .../web/wearable_watch/create_project_watch_ww.htm | 168 + .../html/web/wearable_watch/first_app_watch_ww.htm | 87 + .../html/web/wearable_watch/run_app_watch_ww.htm | 224 + org.tizen.gettingstarted/index.xml | 88 +- org.tizen.guides/.project | 2 +- org.tizen.guides/META-INF/MANIFEST.MF | 2 +- org.tizen.guides/about.html | 2 +- org.tizen.guides/html/cover_page.htm | 2 +- org.tizen.guides/html/images/adv_render_class.png | Bin 17474 -> 17936 bytes org.tizen.guides/html/images/align_hints.png | Bin 10254 -> 0 bytes .../html/images/aspect-control-both.png | Bin 12503 -> 0 bytes .../html/images/aspect-control-horizontal.png | Bin 12644 -> 0 bytes .../html/images/aspect-control-none.png | Bin 16217 -> 0 bytes org.tizen.guides/html/images/attach_camera.png | Bin 0 -> 118181 bytes org.tizen.guides/html/images/attach_images.png | Bin 0 -> 77076 bytes org.tizen.guides/html/images/attach_in.png | Bin 29659 -> 0 bytes org.tizen.guides/html/images/attach_mode.png | Bin 0 -> 77133 bytes org.tizen.guides/html/images/attach_more.png | Bin 0 -> 88905 bytes org.tizen.guides/html/images/attach_out.png | Bin 9125 -> 0 bytes org.tizen.guides/html/images/attach_panel_area.png | Bin 0 -> 90577 bytes org.tizen.guides/html/images/attach_show_app.png | Bin 177619 -> 0 bytes org.tizen.guides/html/images/attach_show_ui.png | Bin 242704 -> 0 bytes org.tizen.guides/html/images/attach_voice.png | Bin 0 -> 88839 bytes org.tizen.guides/html/images/cairo.png | Bin 4494 -> 0 bytes org.tizen.guides/html/images/cairo_draw.png | Bin 0 -> 2538 bytes org.tizen.guides/html/images/cairo_tizen.png | Bin 0 -> 11555 bytes org.tizen.guides/html/images/demuxer.png | Bin 0 -> 27949 bytes org.tizen.guides/html/images/efllibs.png | Bin 17622 -> 0 bytes org.tizen.guides/html/images/elementary_app.png | Bin 11935 -> 0 bytes org.tizen.guides/html/images/evas_architecture.png | Bin 37783 -> 0 bytes org.tizen.guides/html/images/iotivity.png | Bin 0 -> 22414 bytes org.tizen.guides/html/images/iotivity_observe.png | Bin 0 -> 34294 bytes org.tizen.guides/html/images/iotivity_request.png | Bin 0 -> 43914 bytes org.tizen.guides/html/images/iotivity_resource.png | Bin 0 -> 21722 bytes .../html/images/life_cycle_model_new.png | Bin 30482 -> 0 bytes .../html/images/life_cycle_model_old.png | Bin 86948 -> 0 bytes .../html/images/media_streamer_local_video.png | Bin 0 -> 130335 bytes .../media_streamer_local_video_subtitles.png | Bin 0 -> 146730 bytes .../html/images/media_streamer_phone.png | Bin 0 -> 347922 bytes .../images/media_streamer_stream_broadcast.png | Bin 0 -> 168606 bytes .../media_streamer_stream_broadcast_or_voip.png | Bin 0 -> 265192 bytes org.tizen.guides/html/images/muxer.png | Bin 0 -> 34078 bytes org.tizen.guides/html/images/opengl1.png | Bin 29281 -> 0 bytes org.tizen.guides/html/images/opengl2.png | Bin 9482 -> 0 bytes .../html/images/package_structure_new.png | Bin 16078 -> 0 bytes .../html/images/package_structure_old.png | Bin 36974 -> 0 bytes org.tizen.guides/html/images/padding-hints.png | Bin 7919 -> 0 bytes .../html/images/porting_installation_process.png | Bin 94567 -> 0 bytes org.tizen.guides/html/images/rel1_rel2_offsets.png | Bin 20541 -> 0 bytes .../html/images/rel1_rel2_offsets_and_relative.png | Bin 36613 -> 0 bytes org.tizen.guides/html/images/state_model_new.png | Bin 30703 -> 0 bytes org.tizen.guides/html/images/state_model_old.png | Bin 79475 -> 0 bytes .../html/images/using_players_state_changes.png | Bin 55186 -> 51766 bytes org.tizen.guides/html/index.htm | 422 +- .../html/native/account/account_guide_n.htm | 9 +- .../html/native/account/account_manager_n.htm | 4 +- .../html/native/account/fido_client_n.htm | 87 +- org.tizen.guides/html/native/account/oauth2_n.htm | 14 +- .../html/native/account/sync_manager_n.htm | 29 +- org.tizen.guides/html/native/api_comparison_n.htm | 1483 ------ org.tizen.guides/html/native/app/alarm_n.htm | 11 +- org.tizen.guides/html/native/app/app_manager_n.htm | 11 +- org.tizen.guides/html/native/app/appcontrol_n.htm | 276 +- org.tizen.guides/html/native/app/application_n.htm | 10 +- .../html/native/app/attach_panel_n.htm | 48 +- org.tizen.guides/html/native/app/badge_n.htm | 8 +- org.tizen.guides/html/native/app/bundle_n.htm | 10 +- .../html/native/app/common_appcontrol_n.htm | 668 ++- .../html/native/app/data_control_n.htm | 44 +- org.tizen.guides/html/native/app/event_n.htm | 4 +- .../html/native/app/internationalization_n.htm | 37 +- .../html/native/app/message_port_n.htm | 5 +- .../html/native/app/notification_n.htm | 4 +- org.tizen.guides/html/native/app/package_n.htm | 4 +- .../html/native/app/resource_manager_n.htm | 95 + org.tizen.guides/html/native/app/service_app_n.htm | 6 +- org.tizen.guides/html/native/app/shortcut_n.htm | 1 + org.tizen.guides/html/native/app/watch_n.htm | 4 +- org.tizen.guides/html/native/app/widget_n.htm | 26 +- org.tizen.guides/html/native/base/i18n_n.htm | 10 +- .../html/native/content/download_n.htm | 5 +- .../html/native/content/media_content_n.htm | 64 +- .../html/native/content/mime_type_n.htm | 1 + .../html/native/context/activity_recognition_n.htm | 3 +- .../html/native/context/context_guide_n.htm | 4 +- .../html/native/context/gesture_recognition_n.htm | 3 +- org.tizen.guides/html/native/context/history_n.htm | 10 +- org.tizen.guides/html/native/context/trigger_n.htm | 47 +- .../html/native/graphics/adv_performance_n.htm | 2 +- .../html/native/graphics/adv_rendering_n.htm | 229 +- .../html/native/graphics/assembly_n.htm | 4 +- org.tizen.guides/html/native/graphics/cairo_n.htm | 88 +- .../html/native/graphics/creating_opengles_n.htm | 94 +- .../html/native/graphics/fragment_shader_n.htm | 52 +- .../html/native/graphics/interactive_ui_n.htm | 144 +- .../html/native/graphics/polygon_mesh_n.htm | 2 +- org.tizen.guides/html/native/graphics/tbm_n.htm | 4 +- .../html/native/graphics/texturing_n.htm | 86 +- .../html/native/graphics/vertex_shader_n.htm | 234 +- org.tizen.guides/html/native/guides_n.htm | 12 +- .../html/native/location/geofence_n.htm | 39 +- .../html/native/location/here_credential_n.htm | 128 - .../html/native/location/here_credentials_n.htm | 132 + .../html/native/location/location_guide_n.htm | 8 +- .../html/native/location/location_n.htm | 42 +- org.tizen.guides/html/native/location/maps_n.htm | 21 +- org.tizen.guides/html/native/messaging/email_n.htm | 3 +- .../html/native/messaging/messages_n.htm | 4 +- org.tizen.guides/html/native/messaging/push_n.htm | 2 +- .../html/native/migration_guide_221_n.htm | 328 -- .../html/native/multimedia/audio_io_n.htm | 6 +- .../html/native/multimedia/camera_n.htm | 8 +- .../html/native/multimedia/image_util_n.htm | 11 +- .../html/native/multimedia/media_codecs_n.htm | 11 +- .../html/native/multimedia/media_controller_n.htm | 6 +- .../html/native/multimedia/media_demuxer_n.htm | 106 + .../html/native/multimedia/media_keys_n.htm | 7 +- .../html/native/multimedia/media_muxer_n.htm | 96 + .../html/native/multimedia/media_streamer_n.htm | 261 ++ .../html/native/multimedia/media_tools_n.htm | 5 +- .../html/native/multimedia/media_vision_n.htm | 8 +- .../html/native/multimedia/metadata_editor_n.htm | 2 +- .../native/multimedia/metadata_extractor_n.htm | 4 +- .../html/native/multimedia/multimedia_guide_n.htm | 8 +- .../html/native/multimedia/openal_n.htm | 28 +- .../html/native/multimedia/player_n.htm | 21 +- .../html/native/multimedia/radio_n.htm | 2 +- .../html/native/multimedia/recorder_n.htm | 4 +- .../html/native/multimedia/screen_mirroring_n.htm | 3 +- .../html/native/multimedia/sound_manager_n.htm | 8 +- .../html/native/multimedia/thumbnail_util_n.htm | 2 +- .../html/native/multimedia/tone_player_n.htm | 2 + .../html/native/multimedia/video_util_n.htm | 6 + .../html/native/multimedia/wav_player_n.htm | 6 +- .../html/native/network/bluetooth_n.htm | 17 +- .../html/native/network/connection_n.htm | 32 +- org.tizen.guides/html/native/network/curl_n.htm | 91 + org.tizen.guides/html/native/network/iotcon_n.htm | 126 + org.tizen.guides/html/native/network/mtp_n.htm | 101 + .../html/native/network/network_guide_n.htm | 4 + org.tizen.guides/html/native/network/nfc_n.htm | 57 +- .../html/native/network/smartcard_n.htm | 33 +- org.tizen.guides/html/native/network/vpn_n.htm | 154 + .../html/native/network/wifi_direct_n.htm | 12 +- org.tizen.guides/html/native/network/wifi_n.htm | 9 +- .../html/native/security/key_manager_n.htm | 14 +- .../html/native/security/privilege_n.htm | 2 +- org.tizen.guides/html/native/social/calendar_n.htm | 288 +- org.tizen.guides/html/native/social/contact_n.htm | 233 +- .../html/native/social/service_adaptor_n.htm | 42 +- .../html/native/social/social_guide_n.htm | 9 +- org.tizen.guides/html/native/system/device_n.htm | 17 +- org.tizen.guides/html/native/system/dlog_n.htm | 78 +- org.tizen.guides/html/native/system/feedback_n.htm | 2 +- .../html/native/system/runtime_info_n.htm | 4 +- org.tizen.guides/html/native/system/sensors_n.htm | 4 +- org.tizen.guides/html/native/system/settings_n.htm | 15 +- org.tizen.guides/html/native/system/storage_n.htm | 4 +- org.tizen.guides/html/native/system/sysinfo_n.htm | 95 +- org.tizen.guides/html/native/system/t-trace_n.htm | 2 +- .../html/native/telephony/phonenumber_util_n.htm | 14 +- .../html/native/telephony/telephony_guide_n.htm | 8 +- .../html/native/telephony/telephony_info_n.htm | 115 +- org.tizen.guides/html/native/ui/eom_n.htm | 8 +- org.tizen.guides/html/native/ui/minicontrol_n.htm | 4 +- org.tizen.guides/html/native/uix/ime_n.htm | 12 +- org.tizen.guides/html/native/uix/stt_n.htm | 10 +- org.tizen.guides/html/native/uix/tts_n.htm | 15 +- .../html/native/uix/voicecontrol_elm_n.htm | 7 +- .../html/native/uix/voicecontrol_n.htm | 6 +- org.tizen.guides/html/native/web/web_guide_n.htm | 14 +- .../html/web/tizen/account/account_guide_w.htm | 2 + .../html/web/tizen/application/alarm_w.htm | 3 + .../html/web/tizen/application/app_guide_w.htm | 31 +- .../html/web/tizen/application/appgroup_w.htm | 3 +- .../html/web/tizen/application/application_w.htm | 11 +- .../html/web/tizen/application/badge_w.htm | 2 +- .../web/tizen/application/common_appcontrol_w.htm | 2 +- .../html/web/tizen/application/data_w.htm | 11 +- .../html/web/tizen/application/inputdevice_w.htm | 16 +- .../html/web/tizen/application/message_port_w.htm | 8 +- .../html/web/tizen/application/noti_w.htm | 3 + .../html/web/tizen/application/package_w.htm | 2 +- org.tizen.guides/html/web/tizen/base/archive_w.htm | 3 +- .../html/web/tizen/base/base_guide_w.htm | 20 +- .../html/web/tizen/base/filesystem_w.htm | 3 + org.tizen.guides/html/web/tizen/base/tizen_w.htm | 911 ++-- .../html/web/tizen/content/content_guide_w.htm | 2 +- .../html/web/tizen/content/content_w.htm | 6 +- .../html/web/tizen/content/download_w.htm | 4 +- org.tizen.guides/html/web/tizen/guides_tizen_w.htm | 21 +- org.tizen.guides/html/web/tizen/ime/ime_w.htm | 6 +- .../html/web/tizen/localization/localization_w.htm | 2 +- .../html/web/tizen/messaging/messaging_guide_w.htm | 9 +- .../html/web/tizen/messaging/messaging_w.htm | 3 +- .../html/web/tizen/messaging/push_w.htm | 7 +- .../web/tizen/{content => multimedia}/exif_w.htm | 10 +- .../web/tizen/multimedia/media_controller_w.htm | 9 +- .../web/tizen/multimedia/multimedia_guide_w.htm | 10 +- .../html/web/tizen/multimedia/sound_w.htm | 4 +- .../html/web/tizen/network/bluetooth_w.htm | 2 + .../html/web/tizen/network/network_guide_w.htm | 1 + org.tizen.guides/html/web/tizen/network/nfc_w.htm | 6 +- .../html/web/tizen/network/secure_element_w.htm | 2 +- .../html/web/tizen/security/keymanager_w.htm | 25 +- .../html/web/tizen/security/security_guide_w.htm | 6 +- .../html/web/tizen/service/service_w.htm | 19 +- .../html/web/tizen/social/bookmark_w.htm | 2 + .../html/web/tizen/social/calendar_w.htm | 7 +- .../html/web/tizen/social/call_history_w.htm | 4 +- .../html/web/tizen/social/contact_w.htm | 4 +- .../html/web/tizen/social/data_sync_w.htm | 2 + .../html/web/tizen/social/social_guide_w.htm | 3 +- org.tizen.guides/html/web/tizen/system/ham_w.htm | 70 +- .../html/web/tizen/system/media_key_w.htm | 6 +- org.tizen.guides/html/web/tizen/system/power_w.htm | 2 + .../html/web/tizen/system/sensor_w.htm | 12 +- .../html/web/tizen/system/system_guide_w.htm | 18 +- .../html/web/tizen/system/system_info_w.htm | 11 +- .../html/web/tizen/system/system_setting_w.htm | 3 + .../web/w3c/communication/xmlhttprequest_w.htm | 4 +- .../html/web/w3c/device/browser_state_w.htm | 24 +- .../html/web/w3c/device/vibration_w.htm | 8 +- .../w3c/perf_opt/js_performance_improvement_w.htm | 2 +- .../html/web/w3c/perf_opt/minify_js_css_w.htm | 7 +- .../html/web/w3c/storage/storage_guide_w.htm | 2 +- .../html/web/w3c/supplement/typedarray_w.htm | 4 +- org.tizen.guides/index.xml | 364 +- org.tizen.tutorials/.project | 2 +- org.tizen.tutorials/META-INF/MANIFEST.MF | 2 +- org.tizen.tutorials/about.html | 2 +- org.tizen.tutorials/html/cover_page.htm | 2 +- .../html/images/application_page_layout.png | Bin 14671 -> 0 bytes .../html/images/application_store_sd.png | Bin 34166 -> 0 bytes org.tizen.tutorials/html/images/base_layout.png | Bin 10601 -> 0 bytes org.tizen.tutorials/html/images/cairo_basic.png | Bin 3530 -> 0 bytes .../html/images/cairo_draw_lines.png | Bin 0 -> 2504 bytes org.tizen.tutorials/html/images/cairo_evasgl.png | Bin 71084 -> 0 bytes .../html/images/cairo_image_png_sample.png | Bin 0 -> 65406 bytes .../html/images/cairo_text_sample.png | Bin 0 -> 4647 bytes org.tizen.tutorials/html/images/calculator_sd.png | Bin 58613 -> 0 bytes org.tizen.tutorials/html/images/circle_slider.png | Bin 37149 -> 0 bytes org.tizen.tutorials/html/images/cube.png | Bin 6543 -> 0 bytes org.tizen.tutorials/html/images/cube_matrix.png | Bin 29895 -> 0 bytes .../html/images/efl_complex_clock.png | Bin 24653 -> 0 bytes .../html/images/efl_complex_clock_tree.png | Bin 11642 -> 0 bytes org.tizen.tutorials/html/images/efl_libraries.png | Bin 38208 -> 0 bytes .../html/images/efl_simple_clock.png | Bin 15264 -> 0 bytes .../html/images/efl_simple_clock_tree.png | Bin 10811 -> 0 bytes org.tizen.tutorials/html/images/email_sample.png | Bin 81812 -> 0 bytes .../html/images/media_streamer_playing.png | Bin 0 -> 53999 bytes .../html/images/media_streamer_scenario.png | Bin 0 -> 34252 bytes .../html/images/resource_manager_add_images.png | Bin 0 -> 12272 bytes .../html/images/resource_manager_config.png | Bin 0 -> 15176 bytes .../html/images/resource_manager_config_icon.png | Bin 0 -> 900 bytes .../html/images/resource_manager_conn_explorer.png | Bin 0 -> 4801 bytes .../images/resource_manager_emulator_confirm.png | Bin 0 -> 105929 bytes .../html/images/resource_manager_emulator_new.png | Bin 0 -> 87406 bytes .../images/resource_manager_emulator_new_hd.png | Bin 0 -> 105918 bytes .../html/images/resource_manager_emulator_run.png | Bin 0 -> 97726 bytes .../images/resource_manager_emulator_run_hd.png | Bin 0 -> 97791 bytes .../resource_manager_emulator_run_hd_us_en.png | Bin 0 -> 29564 bytes .../images/resource_manager_emulator_run_ko_kr.png | Bin 0 -> 35988 bytes .../images/resource_manager_emulator_run_us_en.png | Bin 0 -> 40419 bytes .../images/resource_manager_emulator_running.png | Bin 0 -> 143024 bytes .../resource_manager_emulator_running_hd.png | Bin 0 -> 310373 bytes .../html/images/resource_manager_image_files.png | Bin 0 -> 12686 bytes .../html/images/resource_manager_res_xml.png | Bin 0 -> 73394 bytes .../html/images/resource_manager_show_view2.png | Bin 0 -> 7292 bytes org.tizen.tutorials/html/images/setting_sd.png | Bin 25318 -> 0 bytes org.tizen.tutorials/html/images/static_cube.png | Bin 6578 -> 0 bytes .../html/images/watchface_emulator.png | Bin 72245 -> 0 bytes .../html/images/watchface_project.png | Bin 167379 -> 0 bytes .../html/images/watchface_screen.png | Bin 2443 -> 0 bytes org.tizen.tutorials/html/index.htm | 392 +- .../html/native/account/account_tutorial_n.htm | 324 +- .../html/native/account/account_tutorials_n.htm | 20 +- .../html/native/account/fido_client_tutorial_n.htm | 174 +- .../html/native/account/oauth2_tutorial_n.htm | 251 +- .../native/account/sync_manager_tutorial_n.htm | 115 +- .../html/native/app_framework/alarm_tutorial_n.htm | 160 +- .../app_framework/app_manager_tutorial_n.htm | 84 +- .../native/app_framework/appcontrol_tutorial_n.htm | 119 +- .../app_framework/application_tutorial_n.htm | 117 +- .../app_framework/attach_panel_tutorial_n.htm | 269 +- .../html/native/app_framework/badge_tutorial_n.htm | 48 +- .../native/app_framework/bundle_tutorial_n.htm | 167 +- .../app_framework/data_control_tutorial_n.htm | 1015 ++-- .../html/native/app_framework/event_tutorial_n.htm | 134 +- .../app_framework/message_port_tutorial_n.htm | 204 +- .../app_framework/notification_tutorial_n.htm | 115 +- .../native/app_framework/package_tutorial_n.htm | 148 +- .../native/app_framework/preference_tutorial_n.htm | 39 +- .../app_framework/resource_manager_tutorial_n.htm | 236 + .../app_framework/service_app_tutorial_n.htm | 71 +- .../native/app_framework/shortcut_tutorial_n.htm | 47 +- .../html/native/app_framework/watch_tutorial_n.htm | 332 +- .../native/app_framework/widget_tutorial_n.htm | 310 +- .../html/native/base/i18n_tutorial_n.htm | 149 +- .../html/native/base/sqlite_tutorial_n.htm | 602 +-- .../html/native/content/download_tutorial_n.htm | 52 +- .../native/content/media_content_tutorial_n.htm | 1310 +++--- .../html/native/content/mime_type_tutorial_n.htm | 67 +- .../html/native/context/activity_tutorial_n.htm | 44 +- .../html/native/context/gesture_tutorial_n.htm | 63 +- .../html/native/context/history_tutorial_n.htm | 57 +- .../html/native/context/trigger_tutorial_n.htm | 70 +- .../html/native/graphics/cairo_tutorial_n.htm | 585 +-- .../native/graphics/graphic_comp_tutorial_n.htm | 222 +- .../html/native/graphics/opengl_tutorial_n.htm | 254 +- .../html/native/graphics/tbm_tutorial_n.htm | 55 +- .../html/native/location/geofence_tutorial_n.htm | 80 +- .../html/native/location/location_tutorial_n.htm | 193 +- .../html/native/location/location_tutorials_n.htm | 2 +- .../html/native/location/maps_tutorial_n.htm | 512 +-- .../html/native/messaging/email_tutorial_n.htm | 111 +- .../html/native/messaging/push_tutorial_n.htm | 46 +- .../html/native/messaging/sms_mms_tutorial_n.htm | 135 +- .../html/native/multimedia/audio_io_tutorial_n.htm | 245 +- .../html/native/multimedia/camera_tutorial_n.htm | 340 +- .../native/multimedia/image_util_tutorial_n.htm | 35 +- .../native/multimedia/media_codec_tutorial_n.htm | 73 +- .../multimedia/media_controller_tutorial_n.htm | 43 +- .../native/multimedia/media_demuxer_tutorial_n.htm | 265 ++ .../native/multimedia/media_key_tutorial_n.htm | 177 +- .../native/multimedia/media_muxer_tutorial_n.htm | 228 + .../multimedia/media_streamer_tutorial_n.htm | 361 ++ .../native/multimedia/media_tools_tutorial_n.htm | 195 +- .../native/multimedia/media_vision_tutorial_n.htm | 228 +- .../multimedia/metadata_editor_tutorial_n.htm | 40 +- .../multimedia/metadata_extractor_tutorial_n.htm | 117 +- .../native/multimedia/multimedia_tutorials_n.htm | 3 + .../html/native/multimedia/openal_tutorial_n.htm | 124 +- .../html/native/multimedia/player_tutorial_n.htm | 221 +- .../html/native/multimedia/radio_tutorial_n.htm | 98 +- .../html/native/multimedia/recorder_tutorial_n.htm | 174 +- .../multimedia/screen_mirroring_tutorial_n.htm | 335 +- .../native/multimedia/sound_manager_tutorial_n.htm | 202 +- .../multimedia/thumbnail_util_tutorial_n.htm | 50 +- .../native/multimedia/video_util_tutorial_n.htm | 40 +- .../native/multimedia/wav_player_tutorial_n.htm | 16 +- .../html/native/network/bluetooth_tutorial_n.htm | 1858 ++++---- .../html/native/network/connection_tutorial_n.htm | 565 ++- .../html/native/network/curl_tutorial_n.htm | 180 + .../html/native/network/iotcon_tutorial_n.htm | 652 +++ .../html/native/network/mtp_tutorial_n.htm | 486 ++ .../html/native/network/network_tutorials_n.htm | 4 + .../html/native/network/nfc_tutorial_n.htm | 870 ++-- .../html/native/network/smartcard_tutorial_n.htm | 314 +- .../html/native/network/vpn_tutorial_n.htm | 381 ++ .../html/native/network/wifi_direct_tutorial_n.htm | 334 +- .../html/native/network/wifi_tutorial_n.htm | 211 +- .../html/native/security/key_tutorial_n.htm | 447 +- .../html/native/security/privilege_tutorial_n.htm | 30 +- .../html/native/social/calendar_tutorial_n.htm | 697 +-- .../html/native/social/contact_tutorial_n.htm | 4828 +++++++++++--------- .../native/social/service_adaptor_tutorial_n.htm | 430 +- .../html/native/social/social_tutorials_n.htm | 15 +- .../html/native/system/device_tutorial_n.htm | 111 +- .../html/native/system/dlog_tutorial_n.htm | 20 +- .../html/native/system/runtime_tutorial_n.htm | 174 +- .../html/native/system/sensor_tutorial_n.htm | 41 +- .../html/native/system/storage_tutorial_n.htm | 28 +- .../html/native/system/sysinfo_tutorial_n.htm | 46 +- .../native/system/system_setting_tutorial_n.htm | 130 +- .../html/native/system/t-trace_tutorial_n.htm | 36 +- .../telephony/phonenumber_util_tutorial_n.htm | 97 +- .../native/telephony/telephony_info_tutorial_n.htm | 512 +-- .../native/telephony/telephony_tutorials_n.htm | 8 +- org.tizen.tutorials/html/native/tutorials_n.htm | 8 +- .../html/native/ui/eom_tutorial_n.htm | 298 +- .../html/native/ui/minicontrol_tutorial_n.htm | 6 +- .../html/native/uix/ime_tutorial_n.htm | 246 +- .../html/native/uix/stt_tutorial_n.htm | 443 +- .../html/native/uix/tts_tutorial_n.htm | 368 +- .../native/uix/voicecontrol_elm_tutorial_n.htm | 300 +- .../html/native/uix/voicecontrol_tutorial_n.htm | 597 ++- .../html/native/web/web_tutorials_n.htm | 310 +- .../html/web/tizen/account/account_tutorial_w.htm | 61 +- .../web/tizen/application/alarm_tutorial_w.htm | 12 +- .../html/web/tizen/application/app_tutorials_w.htm | 24 +- .../web/tizen/application/appgroup_tutorial_w.htm | 14 +- .../tizen/application/application_tutorial_w.htm | 14 +- .../web/tizen/application/badge_tutorial_w.htm | 33 +- .../html/web/tizen/application/data_tutorial_w.htm | 42 +- .../tizen/application/inputdevice_tutorial_w.htm | 27 +- .../tizen/application/message_port_tutorial_w.htm | 20 +- .../html/web/tizen/application/noti_tutorial_w.htm | 11 +- .../web/tizen/application/package_tutorial_w.htm | 20 +- .../html/web/tizen/base/archive_tutorial_w.htm | 15 +- .../html/web/tizen/base/base_tutorials_w.htm | 4 +- .../html/web/tizen/base/filesystem_tutorial_w.htm | 22 +- .../html/web/tizen/base/task_filemanager_w.htm | 4 +- .../html/web/tizen/base/tizen_tutorial_w.htm | 2 - .../html/web/tizen/content/content_tutorial_w.htm | 26 +- .../html/web/tizen/content/download_tutorial_w.htm | 14 +- .../web/tizen/content/task_downloadmanager_w.htm | 2 +- .../web/tizen/messaging/messaging_tutorial_w.htm | 23 +- .../web/tizen/messaging/messaging_tutorials_w.htm | 18 +- .../html/web/tizen/messaging/push_tutorial_w.htm | 13 +- .../html/web/tizen/messaging/task_chatter_w.htm | 4 +- .../{content => multimedia}/exif_tutorial_w.htm | 5 +- .../web/tizen/multimedia/fm_radio_tutorial_w.htm | 3 - .../multimedia/media_controller_tutorial_w.htm | 38 +- .../tizen/multimedia/multimedia_tutorials_w.htm | 8 +- .../html/web/tizen/multimedia/sound_tutorial_w.htm | 12 +- .../web/tizen/network/bluetooth_tutorial_w.htm | 28 +- .../html/web/tizen/network/network_tutorials_w.htm | 4 +- .../html/web/tizen/network/nfc_tutorial_w.htm | 16 +- .../tizen/network/secure_element_tutorial_w.htm | 17 +- .../web/tizen/network/task_bluetoothchat_w.htm | 10 +- .../web/tizen/network/task_contactsexchanger_w.htm | 12 +- .../web/tizen/security/keymanager_tutorial_w.htm | 209 +- .../web/tizen/security/security_tutorials_w.htm | 13 +- .../html/web/tizen/service/service_tutorial_w.htm | 22 +- .../html/web/tizen/social/bookmark_tutorial_w.htm | 13 +- .../html/web/tizen/social/calendar_tutorial_w.htm | 24 +- .../web/tizen/social/call_history_tutorial_w.htm | 21 +- .../html/web/tizen/social/contact_tutorial_w.htm | 23 +- .../html/web/tizen/social/data_sync_tutorial_w.htm | 12 +- .../html/web/tizen/social/social_tutorials_w.htm | 6 +- .../html/web/tizen/social/task_calllog_w.htm | 2 +- .../html/web/tizen/social/task_eventmanager_w.htm | 8 +- .../html/web/tizen/system/ham_tutorial_w.htm | 131 +- .../html/web/tizen/system/media_key_tutorial_w.htm | 5 +- .../html/web/tizen/system/power_tutorial_w.htm | 12 +- .../html/web/tizen/system/sensor_tutorial_w.htm | 61 +- .../web/tizen/system/system_info_tutorial_w.htm | 20 +- .../web/tizen/system/system_setting_tutorial_w.htm | 11 +- .../html/web/tizen/system/system_tutorials_w.htm | 13 +- .../html/web/tizen/system/task_systeminfo_w.htm | 2 +- .../html/web/tizen/system/time_tutorial_w.htm | 8 +- .../web/tizen/system/web_setting_tutorial_w.htm | 5 +- .../html/web/tizen/tutorials_tizen_w.htm | 26 +- .../w3c/communication/server_sent_tutorial_w.htm | 4 +- .../w3c/device/device_orientation_tutorial_w.htm | 18 +- .../w3c/device/screen_orientation_tutorial_w.htm | 10 +- .../html/web/w3c/device/task_touch_paint_mw.htm | 4 +- .../html/web/w3c/device/task_touch_paint_ww.htm | 2 +- .../html/web/w3c/device/touch_tutorial_w.htm | 14 +- .../html/web/w3c/graphics/canvas_tutorial_w.htm | 4 +- .../html/web/w3c/graphics/task_basicwatch_w.htm | 13 +- .../web/w3c/location/geolocation_tutorial_w.htm | 2 +- .../html/web/w3c/media/getusermedia_tutorial_w.htm | 10 +- .../web/w3c/media/media_capture_tutorial_w.htm | 8 +- .../html/web/w3c/media/webaudio_tutorial_w.htm | 2 +- .../web/w3c/perf_opt/web_workers_tutorial_w.htm | 2 +- .../html/web/w3c/security/iframe_tutorial_w.htm | 6 +- .../html/web/w3c/storage/appcache_tutorial_w.htm | 2 +- .../web/w3c/supplement/typedarray_tutorial_w.htm | 4 +- .../html/web/w3c/supplement/webgl_tutorial_w.htm | 12 +- .../html/web/w3c/tutorials_w3c_w.htm | 3 - .../web/w3c/watchface/developing_watch_app.htm | 555 --- org.tizen.tutorials/index.xml | 298 +- .../native/efl/accessibility_implementation_n.htm | 104 +- 952 files changed, 33834 insertions(+), 25112 deletions(-) create mode 100644 org.tizen.devtools/html/common_tools/da_table_filtering.htm create mode 100644 org.tizen.devtools/html/download/2_4_rev3_release_notes.htm create mode 100644 org.tizen.devtools/html/download/2_4_rev4_release_notes.htm create mode 100644 org.tizen.devtools/html/download/2_4_rev5_release_notes.htm create mode 100644 org.tizen.devtools/html/images/adv_config_extra.png create mode 100644 org.tizen.devtools/html/images/adv_config_package.png create mode 100644 org.tizen.devtools/html/images/adv_config_proxy.png create mode 100644 org.tizen.devtools/html/images/adv_config_sdk_image.png delete mode 100644 org.tizen.devtools/html/images/article.png delete mode 100644 org.tizen.devtools/html/images/aside.png delete mode 100644 org.tizen.devtools/html/images/audio.png delete mode 100644 org.tizen.devtools/html/images/canvas.png create mode 100644 org.tizen.devtools/html/images/create_new_emulator.png create mode 100644 org.tizen.devtools/html/images/create_new_emulator_platform.png create mode 100644 org.tizen.devtools/html/images/create_new_emulator_setting.png create mode 100644 org.tizen.devtools/html/images/create_new_emulator_template.png create mode 100644 org.tizen.devtools/html/images/da_filtering_add_filter_property.png create mode 100644 org.tizen.devtools/html/images/da_filtering_apply_filter_property.png create mode 100644 org.tizen.devtools/html/images/da_filtering_delete_all_filter_properties.png create mode 100644 org.tizen.devtools/html/images/da_filtering_delete_filter_property.png create mode 100644 org.tizen.devtools/html/images/da_filtering_filter_dialog.png create mode 100644 org.tizen.devtools/html/images/da_filtering_verify_filter_properties_filter_icon.png create mode 100644 org.tizen.devtools/html/images/da_filtering_verify_filter_properties_filter_menu.png create mode 100644 org.tizen.devtools/html/images/emulator_clone_icon.png create mode 100644 org.tizen.devtools/html/images/emulator_create_icon.png create mode 100644 org.tizen.devtools/html/images/emulator_device_templates.png create mode 100644 org.tizen.devtools/html/images/emulator_launch_button.png create mode 100644 org.tizen.devtools/html/images/emulator_list.png create mode 100644 org.tizen.devtools/html/images/emulator_list_in_emulator_manager.png delete mode 100644 org.tizen.devtools/html/images/emulator_manager.png create mode 100644 org.tizen.devtools/html/images/emulator_manager_profile_button.png create mode 100644 org.tizen.devtools/html/images/emulator_modify_icon.png create mode 100644 org.tizen.devtools/html/images/emulator_platforms_list.png create mode 100644 org.tizen.devtools/html/images/emulator_trash_icon.png create mode 100644 org.tizen.devtools/html/images/enventor_braces_highlight.png create mode 100644 org.tizen.devtools/html/images/enventor_colorselector_function.png create mode 100644 org.tizen.devtools/html/images/enventor_edc_navigator.png create mode 100644 org.tizen.devtools/html/images/enventor_live_image.png create mode 100644 org.tizen.devtools/html/images/enventor_live_rect.png create mode 100644 org.tizen.devtools/html/images/enventor_live_spacer.png create mode 100644 org.tizen.devtools/html/images/enventor_live_swallow.png create mode 100644 org.tizen.devtools/html/images/enventor_live_text.png create mode 100644 org.tizen.devtools/html/images/enventor_live_textblock.png create mode 100644 org.tizen.devtools/html/images/enventor_live_view_resize.png create mode 100644 org.tizen.devtools/html/images/enventor_live_view_resize_control.png create mode 100644 org.tizen.devtools/html/images/enventor_live_view_zoom_control.png delete mode 100644 org.tizen.devtools/html/images/enventor_liveedit.png create mode 100644 org.tizen.devtools/html/images/enventor_navigator.png create mode 100644 org.tizen.devtools/html/images/extension_sdk.png create mode 100644 org.tizen.devtools/html/images/extension_sdk_add_repository.png create mode 100644 org.tizen.devtools/html/images/extension_sdk_modify.png create mode 100644 org.tizen.devtools/html/images/extension_sdk_modify_confirm.png create mode 100644 org.tizen.devtools/html/images/extension_sdk_modify_ok.png create mode 100644 org.tizen.devtools/html/images/extension_sdk_remove.png create mode 100644 org.tizen.devtools/html/images/extension_sdk_trash.png delete mode 100644 org.tizen.devtools/html/images/figure.png delete mode 100644 org.tizen.devtools/html/images/footer.png delete mode 100644 org.tizen.devtools/html/images/header.png delete mode 100644 org.tizen.devtools/html/images/hgroup.png delete mode 100644 org.tizen.devtools/html/images/hori_split_view.png create mode 100644 org.tizen.devtools/html/images/install23_advanced.png create mode 100644 org.tizen.devtools/html/images/install23_components.png create mode 100644 org.tizen.devtools/html/images/install23_image.png create mode 100644 org.tizen.devtools/html/images/install23_install.png create mode 100644 org.tizen.devtools/html/images/install23_manager.png create mode 100644 org.tizen.devtools/html/images/install_cli.png create mode 100644 org.tizen.devtools/html/images/install_complete.png create mode 100644 org.tizen.devtools/html/images/install_gui.png delete mode 100644 org.tizen.devtools/html/images/keygen.png delete mode 100644 org.tizen.devtools/html/images/launch.png delete mode 100644 org.tizen.devtools/html/images/mark.png delete mode 100644 org.tizen.devtools/html/images/math.png delete mode 100644 org.tizen.devtools/html/images/meter.png delete mode 100644 org.tizen.devtools/html/images/mod_icon.png create mode 100644 org.tizen.devtools/html/images/multiple_screen_alt_loc_n.png create mode 100644 org.tizen.devtools/html/images/multiple_screen_alt_resource_n.png create mode 100644 org.tizen.devtools/html/images/multiple_screen_alt_set_n.png create mode 100644 org.tizen.devtools/html/images/multiple_screen_alt_set_properties_n.png create mode 100644 org.tizen.devtools/html/images/multiple_screen_config_map_n.png create mode 100644 org.tizen.devtools/html/images/multiple_screen_config_n.png create mode 100644 org.tizen.devtools/html/images/multiple_screen_loc_n.png create mode 100644 org.tizen.devtools/html/images/multiple_screen_relationships_n.png delete mode 100644 org.tizen.devtools/html/images/nav.png create mode 100644 org.tizen.devtools/html/images/nuib_fit.png create mode 100644 org.tizen.devtools/html/images/nuib_launch_screenconfigurator.png create mode 100644 org.tizen.devtools/html/images/nuib_locale.png create mode 100644 org.tizen.devtools/html/images/nuib_new_screen_configurator.png create mode 100644 org.tizen.devtools/html/images/nuib_resourcemanager_view.png delete mode 100644 org.tizen.devtools/html/images/nuib_resources.png create mode 100644 org.tizen.devtools/html/images/nuib_scale.png create mode 100644 org.tizen.devtools/html/images/nuib_screen_configurator.png create mode 100644 org.tizen.devtools/html/images/nuib_source_tab.png delete mode 100644 org.tizen.devtools/html/images/nuib_we_max_0.png delete mode 100644 org.tizen.devtools/html/images/nuib_we_resolution.png delete mode 100644 org.tizen.devtools/html/images/nuib_we_zoomin_0.png delete mode 100644 org.tizen.devtools/html/images/nuib_we_zoomout_0.png delete mode 100644 org.tizen.devtools/html/images/output.png delete mode 100644 org.tizen.devtools/html/images/progress.png delete mode 100644 org.tizen.devtools/html/images/ruby.png delete mode 100644 org.tizen.devtools/html/images/sdk2_0-haxm-mac7.png delete mode 100644 org.tizen.devtools/html/images/sdk2_0-haxm-win2.png create mode 100644 org.tizen.devtools/html/images/sdk_uninstaller.png create mode 100644 org.tizen.devtools/html/images/sdk_uninstaller_uninstall_icon.png delete mode 100644 org.tizen.devtools/html/images/section.png delete mode 100644 org.tizen.devtools/html/images/skin.png delete mode 100644 org.tizen.devtools/html/images/source.png delete mode 100644 org.tizen.devtools/html/images/source_view.png create mode 100644 org.tizen.devtools/html/images/storyboard_add.png delete mode 100644 org.tizen.devtools/html/images/storyboard_add_new.png create mode 100644 org.tizen.devtools/html/images/storyboard_app.png create mode 100644 org.tizen.devtools/html/images/storyboard_callback.png delete mode 100644 org.tizen.devtools/html/images/storyboard_codegen.png create mode 100644 org.tizen.devtools/html/images/storyboard_comp_prop.png create mode 100644 org.tizen.devtools/html/images/storyboard_conn_prop.png delete mode 100644 org.tizen.devtools/html/images/storyboard_conn_properties.png delete mode 100644 org.tizen.devtools/html/images/storyboard_contextmenu.png delete mode 100644 org.tizen.devtools/html/images/storyboard_diagram.png create mode 100644 org.tizen.devtools/html/images/storyboard_events.png create mode 100644 org.tizen.devtools/html/images/storyboard_new.png create mode 100644 org.tizen.devtools/html/images/storyboard_options.png delete mode 100644 org.tizen.devtools/html/images/storyboard_properties.png create mode 100644 org.tizen.devtools/html/images/storyboard_views.png delete mode 100644 org.tizen.devtools/html/images/storyboard_wizard.png delete mode 100644 org.tizen.devtools/html/images/summary.png delete mode 100644 org.tizen.devtools/html/images/svg.png delete mode 100644 org.tizen.devtools/html/images/thread_pool_lifecycle_1.png delete mode 100644 org.tizen.devtools/html/images/time.png create mode 100644 org.tizen.devtools/html/images/update_manager_information_dialog_manager.png create mode 100644 org.tizen.devtools/html/images/update_manager_information_dialog_sdk.png create mode 100644 org.tizen.devtools/html/images/update_manager_installed_packages.png create mode 100644 org.tizen.devtools/html/images/update_manager_installed_packages_uninstall.png create mode 100644 org.tizen.devtools/html/images/update_manager_installed_packages_update.png create mode 100644 org.tizen.devtools/html/images/update_manager_updatable_icon.png delete mode 100644 org.tizen.devtools/html/images/vert_split_view.png delete mode 100644 org.tizen.devtools/html/images/video.png create mode 100644 org.tizen.devtools/html/native_tools/multiple_screens_n.htm create mode 100644 org.tizen.gettingstarted/html/images/Thumbs.db create mode 100644 org.tizen.gettingstarted/html/images/app_run_mn.png create mode 100644 org.tizen.gettingstarted/html/images/app_run_mw.png create mode 100644 org.tizen.gettingstarted/html/images/app_run_wn.png create mode 100644 org.tizen.gettingstarted/html/images/app_run_wn_watch.png create mode 100644 org.tizen.gettingstarted/html/images/app_run_wn_widget.png create mode 100644 org.tizen.gettingstarted/html/images/app_run_ww.png create mode 100644 org.tizen.gettingstarted/html/images/app_run_ww_watch.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_config_mn.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_config_w.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_config_wn.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_config_wn_watch.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_config_wn_widget.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_config_ww_watch.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_project_explorer_mn.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_project_explorer_mw.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_project_explorer_wn.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_project_explorer_wn_watch.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_project_explorer_wn_widget.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_project_explorer_ww.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_project_explorer_ww_watch.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_1_mw.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_1_ww.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_2_mw.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_2_ww.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_mn.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_wn.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_wn_watch.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_wn_widget.png create mode 100644 org.tizen.gettingstarted/html/images/basic_app_running_ww_watch.png create mode 100644 org.tizen.gettingstarted/html/images/build_automatic_n.png create mode 100644 org.tizen.gettingstarted/html/images/build_automatic_w.png create mode 100644 org.tizen.gettingstarted/html/images/build_icon_mn.png create mode 100644 org.tizen.gettingstarted/html/images/build_manual_mn.png create mode 100644 org.tizen.gettingstarted/html/images/build_manual_mw.png create mode 100644 org.tizen.gettingstarted/html/images/build_manual_watch_wn.png create mode 100644 org.tizen.gettingstarted/html/images/build_manual_watch_ww.png create mode 100644 org.tizen.gettingstarted/html/images/build_manual_widget_wn.png create mode 100644 org.tizen.gettingstarted/html/images/build_manual_wn.png create mode 100644 org.tizen.gettingstarted/html/images/build_manual_ww.png create mode 100644 org.tizen.gettingstarted/html/images/build_ui_basic_mw.png create mode 100644 org.tizen.gettingstarted/html/images/build_ui_basic_textbox_mw.png create mode 100644 org.tizen.gettingstarted/html/images/build_ui_basic_textbox_ww.png create mode 100644 org.tizen.gettingstarted/html/images/build_ui_basic_ww.png create mode 100644 org.tizen.gettingstarted/html/images/change_perspective_n.png create mode 100644 org.tizen.gettingstarted/html/images/change_perspective_w.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_1_n.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_1_w.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_2_mn.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_2_mw.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_2_wn.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_2_wn_watch.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_2_wn_widget.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_2_ww.png create mode 100644 org.tizen.gettingstarted/html/images/create_project_2_ww_watch.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_icon.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_launch_mobile.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_launch_wearable.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_new_mobile.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_new_wearable.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_play.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_running_mn.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_running_mw.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_running_watch_ww.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_running_wn.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_running_wn_widget.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_running_ww.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_settings_mobile.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_settings_wearable.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_target_bt.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_target_debug.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_target_wifi.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_window_mobile.png create mode 100644 org.tizen.gettingstarted/html/images/emulator_window_wearable.png create mode 100644 org.tizen.gettingstarted/html/images/first_app_download_wn.png delete mode 100644 org.tizen.gettingstarted/html/images/hello.png delete mode 100644 org.tizen.gettingstarted/html/images/hello_wearable_emulator.png delete mode 100644 org.tizen.gettingstarted/html/images/hello_wearable_js.png delete mode 100644 org.tizen.gettingstarted/html/images/helloworld_index.png delete mode 100644 org.tizen.gettingstarted/html/images/nuib_cadvl_wysiwyg_editor.png delete mode 100644 org.tizen.gettingstarted/html/images/nuib_soubp_app_xml.png delete mode 100644 org.tizen.gettingstarted/html/images/nuib_soubp_folder.png delete mode 100644 org.tizen.gettingstarted/html/images/nuib_soubp_includes.png delete mode 100644 org.tizen.gettingstarted/html/images/nuib_soubp_layout_tuml.png delete mode 100644 org.tizen.gettingstarted/html/images/nuib_soubp_project_explorer.png delete mode 100644 org.tizen.gettingstarted/html/images/nuib_soubp_tizen_icon.png delete mode 100644 org.tizen.gettingstarted/html/images/nuib_soubp_tizen_manifest_xml.png create mode 100644 org.tizen.gettingstarted/html/images/profile_mobile.png create mode 100644 org.tizen.gettingstarted/html/images/profile_wearable.png create mode 100644 org.tizen.gettingstarted/html/images/remote_allow_gear_ww.png create mode 100644 org.tizen.gettingstarted/html/images/remote_conn_add_ww.png create mode 100644 org.tizen.gettingstarted/html/images/remote_conn_mgr_ww.png create mode 100644 org.tizen.gettingstarted/html/images/remote_conn_new_ww.png create mode 100644 org.tizen.gettingstarted/html/images/remote_connect_ww.png create mode 100644 org.tizen.gettingstarted/html/images/remote_connected_ww.png create mode 100644 org.tizen.gettingstarted/html/images/run_configurations_n.png create mode 100644 org.tizen.gettingstarted/html/images/run_configurations_n_watch.png create mode 100644 org.tizen.gettingstarted/html/images/run_configurations_n_widget.png create mode 100644 org.tizen.gettingstarted/html/images/run_configurations_w.png create mode 100644 org.tizen.gettingstarted/html/images/run_configurations_watch_ww.png create mode 100644 org.tizen.gettingstarted/html/images/run_new_config_wn.png delete mode 100644 org.tizen.gettingstarted/html/images/running_project.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_hello_tau_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_hello_tau_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_screen_wn.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_adv_list_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_anchor_list_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_button_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_create_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_create_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_css_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_css_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_dir_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_dir_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_list_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_list_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_move_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_move_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_new_js_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_new_js_name_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_relation_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_tau_relation_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_update_mgr_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simple_ui_update_mgr_ww.png create mode 100644 org.tizen.gettingstarted/html/images/simulator_run_mw.png create mode 100644 org.tizen.gettingstarted/html/images/simulator_running_mw.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_add.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_addview1.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_addview2.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_assist.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_autocomplete.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_change_view.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_content_assist.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_design_view.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_drag.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_drop.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_edc.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_efl_structure.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_event_button_text.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_event_generated_snippets.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_event_handler_code.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_event_layout.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_event_tab.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_folder.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_go.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_icon.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_layout.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_login.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_manifest.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_negative.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_new_dialog.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_new_view.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_positive.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_project_details.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_project_structure.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_properties.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_remove.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_retained_mode.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_root.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_run.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_selection.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_source.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_storyboard_all.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_storyboard_drag.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_storyboard_drop.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_storyboard_options.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_storyboard_properties.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_storyboard_transitions.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_ui_hierarchy.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_view_hierarchy.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_view_shown.png create mode 100644 org.tizen.gettingstarted/html/images/ui_builder_views.png create mode 100644 org.tizen.gettingstarted/html/images/watch_run_change_wn.png create mode 100644 org.tizen.gettingstarted/html/images/watch_run_face_wn.png create mode 100644 org.tizen.gettingstarted/html/images/watch_run_install_watch_ww.png create mode 100644 org.tizen.gettingstarted/html/images/watch_run_install_wn.png create mode 100644 org.tizen.gettingstarted/html/images/widget_app_wearable.png create mode 100644 org.tizen.gettingstarted/html/images/widget_run_add_home_wn.png create mode 100644 org.tizen.gettingstarted/html/images/widget_run_home_wn.png delete mode 100644 org.tizen.gettingstarted/html/native/first_app/first_app_n.htm create mode 100644 org.tizen.gettingstarted/html/native/mobile/build_app_mn.htm create mode 100644 org.tizen.gettingstarted/html/native/mobile/build_ui_mn.htm create mode 100644 org.tizen.gettingstarted/html/native/mobile/create_project_mn.htm create mode 100644 org.tizen.gettingstarted/html/native/mobile/first_app_mn.htm create mode 100644 org.tizen.gettingstarted/html/native/mobile/run_app_mn.htm create mode 100644 org.tizen.gettingstarted/html/native/process/creating_app_project_n.htm delete mode 100644 org.tizen.gettingstarted/html/native/process/designing_app_ui_n.htm create mode 100644 org.tizen.gettingstarted/html/native/ui/ui_builder_app_design_mn.htm create mode 100644 org.tizen.gettingstarted/html/native/ui/ui_builder_overview_mn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable/build_app_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable/build_ui_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable/create_project_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable/first_app_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable/run_app_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_watch/build_app_watch_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_watch/build_ui_watch_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_watch/create_project_watch_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_watch/first_app_watch_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_watch/run_app_watch_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_widget/build_app_widget_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_widget/build_ui_widget_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_widget/create_project_widget_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_widget/first_app_widget_wn.htm create mode 100644 org.tizen.gettingstarted/html/native/wearable_widget/run_app_widget_wn.htm delete mode 100644 org.tizen.gettingstarted/html/preface.htm delete mode 100644 org.tizen.gettingstarted/html/tizen_websites.htm delete mode 100644 org.tizen.gettingstarted/html/web/first_app/first_app_w.htm create mode 100644 org.tizen.gettingstarted/html/web/mobile/build_app_mw.htm create mode 100644 org.tizen.gettingstarted/html/web/mobile/build_ui_mw.htm create mode 100644 org.tizen.gettingstarted/html/web/mobile/create_project_mw.htm create mode 100644 org.tizen.gettingstarted/html/web/mobile/first_app_mw.htm create mode 100644 org.tizen.gettingstarted/html/web/mobile/run_app_mw.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable/build_app_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable/build_ui_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable/create_project_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable/first_app_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable/run_app_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable_watch/build_app_watch_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable_watch/build_ui_watch_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable_watch/create_project_watch_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable_watch/first_app_watch_ww.htm create mode 100644 org.tizen.gettingstarted/html/web/wearable_watch/run_app_watch_ww.htm delete mode 100644 org.tizen.guides/html/images/align_hints.png delete mode 100644 org.tizen.guides/html/images/aspect-control-both.png delete mode 100644 org.tizen.guides/html/images/aspect-control-horizontal.png delete mode 100644 org.tizen.guides/html/images/aspect-control-none.png create mode 100644 org.tizen.guides/html/images/attach_camera.png create mode 100644 org.tizen.guides/html/images/attach_images.png delete mode 100644 org.tizen.guides/html/images/attach_in.png create mode 100644 org.tizen.guides/html/images/attach_mode.png create mode 100644 org.tizen.guides/html/images/attach_more.png delete mode 100644 org.tizen.guides/html/images/attach_out.png create mode 100644 org.tizen.guides/html/images/attach_panel_area.png delete mode 100644 org.tizen.guides/html/images/attach_show_app.png delete mode 100644 org.tizen.guides/html/images/attach_show_ui.png create mode 100644 org.tizen.guides/html/images/attach_voice.png delete mode 100644 org.tizen.guides/html/images/cairo.png create mode 100644 org.tizen.guides/html/images/cairo_draw.png create mode 100644 org.tizen.guides/html/images/cairo_tizen.png create mode 100644 org.tizen.guides/html/images/demuxer.png delete mode 100644 org.tizen.guides/html/images/efllibs.png delete mode 100644 org.tizen.guides/html/images/elementary_app.png delete mode 100644 org.tizen.guides/html/images/evas_architecture.png create mode 100644 org.tizen.guides/html/images/iotivity.png create mode 100644 org.tizen.guides/html/images/iotivity_observe.png create mode 100644 org.tizen.guides/html/images/iotivity_request.png create mode 100644 org.tizen.guides/html/images/iotivity_resource.png delete mode 100644 org.tizen.guides/html/images/life_cycle_model_new.png delete mode 100644 org.tizen.guides/html/images/life_cycle_model_old.png create mode 100644 org.tizen.guides/html/images/media_streamer_local_video.png create mode 100644 org.tizen.guides/html/images/media_streamer_local_video_subtitles.png create mode 100644 org.tizen.guides/html/images/media_streamer_phone.png create mode 100644 org.tizen.guides/html/images/media_streamer_stream_broadcast.png create mode 100644 org.tizen.guides/html/images/media_streamer_stream_broadcast_or_voip.png create mode 100644 org.tizen.guides/html/images/muxer.png delete mode 100644 org.tizen.guides/html/images/opengl1.png delete mode 100644 org.tizen.guides/html/images/opengl2.png delete mode 100644 org.tizen.guides/html/images/package_structure_new.png delete mode 100644 org.tizen.guides/html/images/package_structure_old.png delete mode 100644 org.tizen.guides/html/images/padding-hints.png delete mode 100644 org.tizen.guides/html/images/porting_installation_process.png delete mode 100644 org.tizen.guides/html/images/rel1_rel2_offsets.png delete mode 100644 org.tizen.guides/html/images/rel1_rel2_offsets_and_relative.png delete mode 100644 org.tizen.guides/html/images/state_model_new.png delete mode 100644 org.tizen.guides/html/images/state_model_old.png delete mode 100644 org.tizen.guides/html/native/api_comparison_n.htm create mode 100644 org.tizen.guides/html/native/app/resource_manager_n.htm delete mode 100644 org.tizen.guides/html/native/location/here_credential_n.htm create mode 100644 org.tizen.guides/html/native/location/here_credentials_n.htm delete mode 100644 org.tizen.guides/html/native/migration_guide_221_n.htm create mode 100644 org.tizen.guides/html/native/multimedia/media_demuxer_n.htm create mode 100644 org.tizen.guides/html/native/multimedia/media_muxer_n.htm create mode 100644 org.tizen.guides/html/native/multimedia/media_streamer_n.htm create mode 100644 org.tizen.guides/html/native/network/curl_n.htm create mode 100644 org.tizen.guides/html/native/network/iotcon_n.htm create mode 100644 org.tizen.guides/html/native/network/mtp_n.htm create mode 100644 org.tizen.guides/html/native/network/vpn_n.htm rename org.tizen.guides/html/web/tizen/{content => multimedia}/exif_w.htm (84%) delete mode 100644 org.tizen.tutorials/html/images/application_page_layout.png delete mode 100644 org.tizen.tutorials/html/images/application_store_sd.png delete mode 100644 org.tizen.tutorials/html/images/base_layout.png delete mode 100644 org.tizen.tutorials/html/images/cairo_basic.png create mode 100644 org.tizen.tutorials/html/images/cairo_draw_lines.png delete mode 100644 org.tizen.tutorials/html/images/cairo_evasgl.png create mode 100644 org.tizen.tutorials/html/images/cairo_image_png_sample.png create mode 100644 org.tizen.tutorials/html/images/cairo_text_sample.png delete mode 100644 org.tizen.tutorials/html/images/calculator_sd.png delete mode 100644 org.tizen.tutorials/html/images/circle_slider.png delete mode 100644 org.tizen.tutorials/html/images/cube.png delete mode 100644 org.tizen.tutorials/html/images/cube_matrix.png delete mode 100644 org.tizen.tutorials/html/images/efl_complex_clock.png delete mode 100644 org.tizen.tutorials/html/images/efl_complex_clock_tree.png delete mode 100644 org.tizen.tutorials/html/images/efl_libraries.png delete mode 100644 org.tizen.tutorials/html/images/efl_simple_clock.png delete mode 100644 org.tizen.tutorials/html/images/efl_simple_clock_tree.png delete mode 100644 org.tizen.tutorials/html/images/email_sample.png create mode 100644 org.tizen.tutorials/html/images/media_streamer_playing.png create mode 100644 org.tizen.tutorials/html/images/media_streamer_scenario.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_add_images.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_config.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_config_icon.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_conn_explorer.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_confirm.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_new.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_new_hd.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_run.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_run_hd.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_run_hd_us_en.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_run_ko_kr.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_run_us_en.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_running.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_emulator_running_hd.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_image_files.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_res_xml.png create mode 100644 org.tizen.tutorials/html/images/resource_manager_show_view2.png delete mode 100644 org.tizen.tutorials/html/images/setting_sd.png delete mode 100644 org.tizen.tutorials/html/images/static_cube.png delete mode 100644 org.tizen.tutorials/html/images/watchface_emulator.png delete mode 100644 org.tizen.tutorials/html/images/watchface_project.png delete mode 100644 org.tizen.tutorials/html/images/watchface_screen.png create mode 100644 org.tizen.tutorials/html/native/app_framework/resource_manager_tutorial_n.htm create mode 100644 org.tizen.tutorials/html/native/multimedia/media_demuxer_tutorial_n.htm create mode 100644 org.tizen.tutorials/html/native/multimedia/media_muxer_tutorial_n.htm create mode 100644 org.tizen.tutorials/html/native/multimedia/media_streamer_tutorial_n.htm create mode 100644 org.tizen.tutorials/html/native/network/curl_tutorial_n.htm create mode 100644 org.tizen.tutorials/html/native/network/iotcon_tutorial_n.htm create mode 100644 org.tizen.tutorials/html/native/network/mtp_tutorial_n.htm create mode 100644 org.tizen.tutorials/html/native/network/vpn_tutorial_n.htm rename org.tizen.tutorials/html/web/tizen/{content => multimedia}/exif_tutorial_w.htm (99%) delete mode 100644 org.tizen.tutorials/html/web/w3c/watchface/developing_watch_app.htm diff --git a/org.tizen.devtools/.project b/org.tizen.devtools/.project index 543c836..8c4a8a6 100644 --- a/org.tizen.devtools/.project +++ b/org.tizen.devtools/.project @@ -1,6 +1,6 @@ - org.tizen.devtools_2.4.0 + org.tizen.devtools_3.0.0 diff --git a/org.tizen.devtools/META-INF/MANIFEST.MF b/org.tizen.devtools/META-INF/MANIFEST.MF index a0f882c..04b53de 100644 --- a/org.tizen.devtools/META-INF/MANIFEST.MF +++ b/org.tizen.devtools/META-INF/MANIFEST.MF @@ -2,6 +2,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 1 Bundle-Name: Tizen Tools Bundle-SymbolicName: org.tizen.devtools;singleton=true -Bundle-Version: 2.4.0 +Bundle-Version: 3.0.0 Bundle-Vendor: The Linux Foundation diff --git a/org.tizen.devtools/about.html b/org.tizen.devtools/about.html index 814330e..1b08fa5 100644 --- a/org.tizen.devtools/about.html +++ b/org.tizen.devtools/about.html @@ -10,7 +10,7 @@

About This Content

-

Tizen 2.4.0

+

Tizen 3.0.0

License

Except as noted, this content - excluding the Code Examples - is licensed under Creative Commons Attribution 3.0 and all of the Code Examples contained herein are licensed under BSD-3-Clause.
For details, see the Content License.

diff --git a/org.tizen.devtools/html/common_tools/da_overview.htm b/org.tizen.devtools/html/common_tools/da_overview.htm index 6a44a8d..8910cdc 100644 --- a/org.tizen.devtools/html/common_tools/da_overview.htm +++ b/org.tizen.devtools/html/common_tools/da_overview.htm @@ -26,8 +26,7 @@

Mobile Wearable

Dynamic Analyzer

-

You can monitor the performance and reliability of your Native application on a target device or the Emulator - by running the dynamic analyzer tool included within the Tizen SDK.

+

You can monitor the performance and reliability of your native application on a target device or the Emulator by running the dynamic analyzer tool included within the Tizen SDK.

Dynamic Analyzer provides various functions for profiling applications. To better understand the profiling result, you need to know about each component that tool screen contains, providing you with the tracing information of your application.

Figure: Dynamic Analyzer screen

Dynamic Analyzer screen

@@ -60,8 +59,8 @@

The OpenGL tab shows information about OpenGL® 2.0 and EvasGL.

  • CheckPoint

    The CheckPoint tab shows an analysis of variable values at specific points of code.

  • -
  • UI Hierarchy Analysis -

    The UI Hierarchy Analysis tab shows the information of EFL UI objects (Evas, Elementary, Edje).

  • +
  • UI Hierarchy +

    The UI Hierarchy tab shows information about the EFL UI objects (Evas, Elementary, and Edje).

  • Web

    The Web feature shows information about a Web application.

    @@ -86,6 +85,8 @@ For instructions on running the dynamic analyzer and ways to analyze the result and utilize the result for improving your application performance, see Dynamic Analysis.

    +

    You can use table filtering to see only the information you want in the result table.

    +

    Settings

    The settings button on the toolbar opens the Settings dialog box, which is used to adjust the dynamic analyzer functions during operation or stop.

    The Settings dialog box consists of the following tabs:

    @@ -109,7 +110,7 @@
  • Custom: This template can be configured by selecting the desired features. If you change a feature in another template, the change effects the custom template.
  • The overall overhead is an accumulation of each selected feature's overhead. Using a feature that has a high overhead, such as the OpenGL ES analysis, can reduce the processing speed of the application.

    -

    When you click the Details button in the Features tab, the Feature details dialog appears on the screen.

    +

    When you click the Details button in the Features tab, the Feature details dialog opens on the screen.

    Figure: Feature details

    Features tab

    diff --git a/org.tizen.devtools/html/common_tools/da_table_filtering.htm b/org.tizen.devtools/html/common_tools/da_table_filtering.htm new file mode 100644 index 0000000..8b7aa8f --- /dev/null +++ b/org.tizen.devtools/html/common_tools/da_table_filtering.htm @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + Table Filtering + + + + + + +
    +

    Table Filtering

    + +

    The Table Filtering feature of the dynamic analyzer provides the ability to show the information corresponding to the keyword you can set in the analysis result table.

    +

    The filter properties can be set in the Filter dialog.

    + +

    Applying Filter Properties

    +

    To use table filtering, you must set a filter property in the filter dialog. To open the filter dialog, click the dropdown button on the right side of each analysis result table's title bar and select Filter.

    + +

    Figure: Opening the filter dialog

    +

    Opening the filter dialog

    + +

    To add a filter property:

    +
      +
    1. Click Add.
    2. +
    3. Select a column where you want to set the filter.
    4. +
    5. Enter a keyword. + +

      Adding a filter property

      +
    6. +
    7. Click OK. + +
    8. +
    +

    When the filter is applied, a filter icon is displayed in the upper-right corner of the column set in the filter property, and the analysis result table's data includes only the entries with the keyword of the filter property.

    + +

    Figure: Applying the filter property

    +

    Applying the filter property

    + +

    Verifying Filter Properties

    +

    You can verify the filter properties through the filter dialog. There are 2 ways to open the filter dialog:

    +
      +
    • Click the dropdown menu button on the right side of the each analysis result table's title bar, and select Filter. +

      You can see all filter properties.

      +

      Figure: Verifying filter properties in the filter menu

      +

      Verify filter properties - Filter menu

      +
    • +
    • Click the filter icon. +

      You can see all filter properties. The filter property corresponding to the filter icon you click appears with a blue highlight.

      +

      Figure: Verifying filter properties through the filter icon

      +

      Verify filter properties - Filter icon

      +
    • +
    + + +

    Deleting Filter Properties

    +

    You can delete a filter through the same filter dialog as you add a filter.

    +

    To delete a filter, click the delete button on the right side of the filter property block, and click OK.

    +

    Figure: Deleting a filter property

    +

    Delete a filter property

    + + +

    If you want to delete all filter properties at once, click Clear and then confirm the deletion by clicking OK twice.

    + +

    Figure: Deleting all filter properties

    +

    Delete all filter properties

    + + + +
    + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.devtools/html/common_tools/da_timeline.htm b/org.tizen.devtools/html/common_tools/da_timeline.htm index 4a30c01..fc77a67 100644 --- a/org.tizen.devtools/html/common_tools/da_timeline.htm +++ b/org.tizen.devtools/html/common_tools/da_timeline.htm @@ -148,7 +148,7 @@
  • : Camera

  • -
  • Energy chart

    Shows the power consumption of Flash memory, CPU, LCD, Wi-Fi and Bluetooth.

    +
  • Energy chart

    Shows the power consumption of Flash memory, CPU, LCD, Wi-Fi, and Bluetooth.

    • : Total energy usage (mA)

    • : Flash memory (mA)

    • @@ -232,7 +232,7 @@
  • - diff --git a/org.tizen.devtools/html/common_tools/da_ui_hierarchy.htm b/org.tizen.devtools/html/common_tools/da_ui_hierarchy.htm index d2415df..a9f2935 100644 --- a/org.tizen.devtools/html/common_tools/da_ui_hierarchy.htm +++ b/org.tizen.devtools/html/common_tools/da_ui_hierarchy.htm @@ -18,98 +18,98 @@
    - +

    UI Hierarchy Analysis

    -

    The UI Hierarchy tab of the dynamic analyzer shows the information of EFL UI objects (Evas, Elementary, Edje). You can see the hierarchy relationship of all UI objects and the detailed information of each UI object.

    +

    The UI Hierarchy tab of the dynamic analyzer shows the information about the EFL UI objects (Evas, Elementary, Edje). You can see the hierarchy relationship of all UI objects and detailed information about each UI object.

    The tab consists of the following views:

      -
    1. Hierarchy Tree view shows the relationship of UI objects in tree format.
    2. -
    3. Overview shows the outline of the Hierarchy Tree view.
    4. -
    5. UI Object view shows the basic information of the selected UI object from the Hierarchy Tree view.
    6. -
    7. Properties view shows the properties of the selected UI object from the Hierarchy Tree view.
    8. -
    9. Layout view shows a block representation of your application.
    10. +
    11. Hierarchy Tree view shows the relationship of UI objects in a tree format.
    12. +
    13. Overview shows the outline of the hierarchy tree.
    14. +
    15. UI Object view shows basic information about the UI object selected from the hierarchy tree.
    16. +
    17. Properties view shows the properties of the UI object selected from the hierarchy tree.
    18. +
    19. Layout view shows a block representation of your application.
    -

    Figure: UI Hierarchy Analysis

    -

    UI Hierarchy Analysis

    +

    Figure: UI Hierarchy analysis

    +

    UI Hierarchy analysis

    -

    To use the UI Hierarchy analysis, do the following.

    -

    Figure: Setting for UI Hierarchy Analysis

    -

    Setting for UI Hierarchy Analysis

    - -

    Hierarchy Tree view

    -

    The Hierarchy Tree view provides you with following features.

    -
      -
    • You can see the relationships between the UI objects of your application.
    • -
    • You can zoom in and out the tree in the Hierarchy Tree view.
    • -
    • You can easily find the UI objects you want to see by using filtering options.
    • -
    • You can export the tree in the Hierarchy Tree view to an image file.
    • -
    +

    To use the UI Hierarchy tab, go to the dynamic analyzer settings, click Details, and select the tab.

    +

    Figure: Opening the UI Hierarchy tab

    +

    Opening the UI Hierarchy tab

    +

    Hierarchy Tree

    +

    The Hierarchy Tree view provides the following features:

    + +

    Figure: Hierarchy Tree view

    -

    Hierarchy Tree

    - -

    Displaying current information of the UI objects

    -

    When the UI of your application changes, the Hierarchy Tree view is not automatically updated. To update it, do the following :

    +

    Hierarchy Tree view

    + +
      +
    • You can view the relationships between the UI objects of your application. +

      When the application UI changes, the Hierarchy Tree view is not automatically updated. To update the view:

        -
      1. If you want to see only Elementary UI objects without Evas and Edje, select the elm Only check box at the upper left of the Hierarchy Tree view.
      2. -
      3. Click the refresh button at the upper left of the Hierarchy Tree view. In the view, each node represents the corresponding UI object and shows its type (e.g. elm_win).
      4. +
      5. To see only Elementary UI objects without Evas and Edje, select the elm Only check box at the top left corner.
      6. +
      7. Click the refresh button (Refresh). +

        In the view, each node represents a corresponding UI object and shows its type (such as elm_win).

      -

      Exporting the tree in the Hierarchy Tree view to an image file

      -To save a screenshot of tree view to an image file (PNG), click the export button at the upper right of the Hierarchy Tree view. And then the Save As dialog box appears. - -

      Finding the UI object

      -

      To find the UI objects in the tree, do the following : +

    • +
    • You can zoom in and out the hierarchy tree. +

      To zoom in or out of the tree, use the slider at the bottom right corner, or use a keyboard shortcut (Ctrl + mouse scroll wheel).

    • +
    • You can easily find the UI objects you want to see by using filtering options. +

      To find the UI objects in the tree:

        -
      1. Select a filtering option in the combo box at the lower left of the Hierarchy Tree view. The options are : +
      2. Select a filtering option in the combo box at the bottom left corner:
          -
        • Type : the type of UI object (e.g. elm_win, elm_button)
        • -
        • Name : the name set by the EFL API evas_object_name_set().
        • -
        • Text : the text in UI object. Some UI objects (e.g. Label, Text) have its text.
        • +
        • Type: Type of UI object (such as elm_win or elm_button)
        • +
        • Name: Name set by the EFL evas_object_name_set() function.
        • +
        • Text: Text in the UI object (such as a Label or Text object).
      3. -
      4. Enter the text in the search box at the lower left of the Hierarchy Tree view. The nodes that contain the search text will be highlighted with blue color.
      5. -
      +
    • Enter the search text in the search box. The nodes that contain the search text are highlighted in blue.
    • + +
    • You can export the hierarchy tree to an image file. +

      To save a screenshot of tree view to an image file (PNG), click the export button (Export) at the top right corner. In a dialog box, click Save As and define a location for the file.

    • +
    + -

    Zooming in/out a tree view

    -To zoom in/out a tree view, use the slider at the lower right of the Hierarchy Tree view, or use your keyboard shortcut (Ctrl + mouse scroll wheel). -

    Overview

    -

    The Overview represents the entire tree as the map style. The Hierarchy Tree view displays an enlarged tree which indicates a particular part of the whole tree in the Overview.

    -

    Through the Overview, you can also move around the whole hierarchy tree. Select and move the shaded rectangle in the Overview, and then the tree in the rectangle is displayed as an enlarged tree in the Hierarchy Tree view.

    +

    The Overview represents the entire tree in the map style. The Hierarchy Tree view displays an enlarged tree, which indicates a particular part of the whole tree in the Overview.

    +

    Through the Overview, you can move around the whole hierarchy tree. Select and move the shaded rectangle, and the tree in the rectangle is displayed as an enlarged tree in the Hierarchy Tree view.

    Figure: Overview

    -

    Overview

    +

    Overview

    + + +

    UI Object

    - -

    UI Object view

    -When you select a node in the Hierarchy Tree view, the basic information of the UI object appears in a small balloon above the node. +

    When you select a node in the Hierarchy Tree view, basic information about the selected UI object appears in a small balloon (UI Object view) above the node.

    Figure: UI Object view

    -

    UI Object view

    -In this small balloon, you can see the following: +

    UI Object view

    + +

    In the view, you can see the following:

      -
    • Image: The actual image of the UI object as displayed in your application. When the image is not available, a message appears instead. The messages are the following :

      +
    • Image: The actual image of the UI object as displayed in your application. When the image is not available, one of the following messages appears instead:

        -
      • App In Background : If the application is running in background, you cannot see the image. To see the image, you should bring the application to foreground and select the node again.
      • -
      • Not In Tracing : If you stop tracing the application, you cannot see the image. To see the image, you should start tracing.
      • -
      • No Image : When the UI object has no image, this message appears. (in case that the width or height of the UI object is 0.)
      • -
      • No Object : When the UI object does not exist anymore in the application, this message appears. This may happen because the Hierarchy Tree view is not automatically updated. See the Displaying current information of the UI objects.
      • +
      • App In Background: If the application is running in the background, you cannot see the image. To see the image, bring the application to the foreground and select the node again.
      • +
      • Not In Tracing: If you stop tracing the application, you cannot see the image. To see the image, start tracing.
      • +
      • No Image: If the UI object has no image, this message appears (in case that the width or height of the UI object is 0).
      • +
      • No Object: When the UI object does not exist anymore in the application, this message appears. This can happen because the Hierarchy Tree view is not automatically updated.
    Note

    If your application is built by setting the optimization option above O0 (default value), the API callstack-related information shown in the Call Trace view can be incorrect. To profile your application with the dynamic analyzer, you must not change the optimization option.

    +
    If your application is built by setting the optimization option above O0 (default value), the API callstack-related information shown in the Call Trace view can be incorrect. To profile your application with the dynamic analyzer, you must not change the optimization option.

    For information on the Call Trace view of a Web application, see Call Trace in Web Analysis.

    @@ -117,32 +117,32 @@ In this small balloon, you can see the following: - +
    Note
    If there are other UI objects intersecting the position of the UI object, those are also displayed.If there are other UI objects intersecting the position of the selected UI object, those are also displayed.
  • - -
  • Name : The name set by the EFL API evas_object_name_set(). If the name is not set, the message "No Name" appears instead of a name.
  • -
  • Number of children : The number of children UI objects. If the UI object has no child, the message "0 children" appears.
  • -
  • Address : The memory address of the UI object.
  • +
  • Name: The name set by the EFL evas_object_name_set() function. If the name is not set, the No Name message appears instead of the name.
  • +
  • Number of children: The number of child UI objects. If the UI object has no children, the 0 children message appears.
  • +
  • Address: The memory address of the UI object.
  • - -

    Properties view

    +

    Properties

    -

    The Properties view shows a list of the properties for the selected UI object from the Hierarchy Tree view. To find an individual property, expand a category name by clicking the arrow on its left. And then all the properties in that category are displayed.

    +

    The Properties view shows a list of the properties for the selected UI object from the Hierarchy Tree view. To find an individual property, expand a category name by clicking the arrow on its left.

    Figure: Properties view

    -

    Properties view

    -

    The properties are categorized by the type of EFL UI object (Evas, Elementary, Edje). The Properties view always shows Evas category because all of the EFL UI objects are the subtype of Evas.

    -

    If the UI object is the type of Elementary or Edje, the view shows those categories too. Each type's own properties are also categorized (e.g. elm_label).

    +

    Properties view

    + +

    The properties are categorized by the type of the EFL UI object (Evas, Elementary, or Edje). The Properties view always shows the Evas category, because all of the EFL UI objects are subtypes of Evas.

    +

    If the UI object is of the Elementary or Edje type, the view shows those categories too. Each type's own properties are also categorized (such as elm_label).

    - -

    Layout view

    -The Layout view shows a block representation of the application. When you select a node in the Hierarchy Tree view, the corresponding image is displayed and highlighted. + +

    Layout

    + +

    The Layout view shows a block representation of the application. When you select a node in the Hierarchy Tree view, the corresponding image is displayed and highlighted.

    Figure: Layout view

    -

    Layout view

    +

    Layout view

    + - diff --git a/org.tizen.devtools/html/common_tools/emulator.htm b/org.tizen.devtools/html/common_tools/emulator.htm index 5008192..42fce4b 100644 --- a/org.tizen.devtools/html/common_tools/emulator.htm +++ b/org.tizen.devtools/html/common_tools/emulator.htm @@ -60,13 +60,14 @@

    Emulator Manager

    -

    To start the Emulator quickly:

    +

    To start the Emulator:

      -
    1. Start the Emulator Manager: +
    2. Start the Emulator Manager using one of following methods:
        -
      • By using the Desktop or Start menu, go to: +
      • In the Desktop or Start menu, go to: + @@ -84,20 +85,21 @@
        Table: Starting the Emulator Manager
        Ubuntu
      • -
      • By using the Tizen IDE, click the Emulator Manager icon in the Connection Explorer view: +
      • In the Tizen IDE, click the Emulator Manager icon in the Connection Explorer view:

        Launch

    3. -
    4. Select your preferred profile tab, such as mobile or wearable.
    5. -
    6. Select Create New and click Confirm.
    7. -
    8. Click the Launch button ( Launch ) or press the ENTER keyboard key.
    9. -
    10. To stop the Emulator, right-click the Emulator and select Close.
    11. -
    - +
  • In the main screen of the Emulator Manager, click Create New Emulator. +

    Emulator list

    +
  • +
  • In the Create New Emulator dialog box, click Confirm. +

    Create new Emulator

    +
  • +
  • Click the launch button (launch) or press the Enter keyboard key.
  • +
  • To stop the Emulator, open the context menu, and click Close.
  • -

    Figure: Emulator Manager

    -

    Emulator Manager

    + @@ -110,20 +112,24 @@
    -

    You can also create a new virtual machine (VM) with the Emulator Manager CLI.

    +

    Managing the Emulator

    -

    The created VM is added under the current tab. The name of tab, <Profile>, refers to the image profile. You can create a VM by using a custom image in Base Image of the detail view. The background color of a custom VM is blue.

    - -

    You can also export a base image of the VM and manipulate the VM:

    +

    With the Emulator Manager, you can create an emulator instance for various Tizen devices and platforms. In the Emulator Manager, you can filter the emulator list using the profile buttons (Launch). You can create, launch, modify, and delete an emulator instance.

    +

    Figure: Emulator instances list

    +

    Emulator Manager

    + +

    To create an emulator instance, click Create New Emulator, select a platform and device template, and click Confirm. If you want to configure detailed settings, click Advance.

    +

    Figure: Setting new emulator instance

    +

    Emulator Manager

    + +

    If you want to create an emulator instance with a custom platform, click the create icon (create) and add a new platform. Creating a new platform is described in more detail at Platforms. The new emulator instance appears in the emulator list. In the list, a blue icon means a standard platform emulator and a green icon means a custom platform emulator.

    -

    Virtual Machine

    A virtual machine (VM) is a set of hardware options including the file system image. The Emulator Manager controls the virtual machines. When you launch the Emulator, you can specify the VM that you want to customize. Each VM has its own Emulator file system image. In other words, different VMs have different states of Emulators.

    @@ -148,41 +154,24 @@
  • Only the following characters are accepted: -, _, 0-9, a - z, and A - Z
  • -
  • Base Image -

    You can use the default base image. You can also change the base image and choose another image when you create a VM by clicking Create New under the "mobile-custom/wearable-custom" tab folder. This new VM is added under the "each custom" group. The correct image file extension of the custom base image is .x86.

  • - -
  • Display Resolution -

    Note that the following resolution has its own default display density.

    -
      -
    • Mobile -
        -
      • 480 x 800 (WVGA)
      • -
      • 540 x 960 (qHD)
      • -
      • 720 x 1280 (HD)
      • -
    • -
    • Wearable -
        -
      • 320 x 320
      • -
      • 360 x 360
      • -
      • 360 x 480
      • -
    • -
    -
  • +
  • Platform +

    You can select a platform to run on the emulator.

    +

    The Emulator Manager supports a custom platform. If you have a disk image file of the custom platform, you can register the custom platform to the Emulator Manager. (The file extension of the disk image must be .x86.)

  • + +
  • Display Resolution and Size +

    The display resolution and size (inch) are determined by the following device templates:

    -
  • Display Density -

    DPI (Dots Per Inch) value of the Emulator. The DPI depends on the display resolution.

    • Mobile
        -
      • 233 (480 x 800)
      • -
      • 220 (540 x 960)
      • -
      • 294 (720 x 1280)
      • +
      • HD mobile: 720 x 1280 (HD), 4.97 inch
      • +
      • WVGA mobile: 480 x 800 (WVGA), 4.0 inch
    • Wearable
        -
      • 316 (320 x 320)
      • -
      • 302 (360 x 360)
      • -
      • 300 (360 x 480)
      • +
      • 320x320 wearable: 320 x 320, 1.43 inch
      • +
      • 360x480 wearable: 360 x 480, 2.0 inch
      • +
      • Wearable circle: 360 x 360, 1.69 inch
  • @@ -204,7 +193,7 @@ - +
    Note
    In Windows®, only the 512 MB size is available.In 32-bit Windows®, only the 512 MB size is available.
    @@ -244,28 +233,61 @@ -
  • Advanced Option -

    You can attach and detach devices.

    +
  • Sensors +

    You can attach and detach the following sensors:

      -
    • Mobile -
        -
      • Camera: virtual, Webcam
      • -
      • Sensor: accelerometer, gyroscope, geo-magnetic, proximity, light, haptic, pressure, ultraviolet, heartbeat rate meter
      • -
      • Device: battery
      • -
      • Jack: earjack, charger, USB
      • -
    • -
    • Wearable -
        -
      • Camera: virtual, Webcam
      • -
      • Sensor: accelerometer, gyroscope, geomagnetic, proximity, light, haptic, pressure, ultraviolet, heartbeat rate meter
      • -
      • Device: battery
      • -
      • Jack: charger, USB
      • -
    • +
    • Accelerometer, gyroscope, geo-magnetic, proximity, light, haptic, pressure, ultraviolet, and heartbeat rate meter
  • +
  • Camera +
      +
    • Virtual, Webcam
    • +
    +
  • +
  • Connectivity +
      +
    • NFC
    • +
    +
  • + + + +

    Device Template

    + +

    The Emulator Manager provides a predefined device template, which enables creating and launching the emulator instance.

    +

    Click Templates in the Emulator Manager to open the Template panel. In the Template panel, you can create, modify, clone, or delete a device template, and see the generated templates.

    +

    Figure: Device templates

    +

    Emulator Manager

    + +

    To create a device template, click the create icon (Launch) to open the New Template dialog box.

    +

    After configuring the template, click Confirm. The new device template is added to the list with a green type icon. (The type icon for a predefined device template is blue.)

    +

    Figure: Creating new template

    +

    Emulator Manager

    +

    To manage the device template:

    + +

    Platforms

    +

    Click Platforms in the Emulator Manager to open the Platforms panel. In the Platforms panel, you can create, modify, or delete a custom platform, and see the generated platforms. Most application developers do not need a custom platform, but it can be useful for a platform developer.

    +

    Figure: Platforms list

    +

    Emulator Manager

    + +

    To create a custom platform, click the create icon (Launch).

    +

    In the New Platform dialog box, select a base platform and platform image file, and click Confirm. The newly created platform is added to the list with a green icon.

    +

    Figure: Creating a new platform

    +

    Emulator Manager

    +

    To manage the platforms:

    + + +

    Emulator Manager CLI

    You can create, modify, delete, and list your VMs through the command line interface commands. The CLI binary is located in:

    @@ -402,7 +424,7 @@ $egrep -c '(vmx|svm)' /proc/cpuinfo

    When you tap, it opens a list of options available for the current screen.

  • Home (mobile only) -

    If you long press the Home key, the Task switcher application appears as in a real device.

    +

    If you long-press the Home key, the Task switcher application opens as in a real device.

  • Back

    When you tap, it returns to the previous screen.

    @@ -444,7 +466,7 @@ $egrep -c '(vmx|svm)' /proc/cpuinfo Skin Name Skin name - + CPU Arch CPU architecture @@ -457,7 +479,7 @@ $egrep -c '(vmx|svm)' /proc/cpuinfo Display - Target display resolution and PPI(pixels per inch) + Target display resolution and PPI (pixels per inch) @@ -610,7 +632,7 @@ $egrep -c '(vmx|svm)' /proc/cpuinfo Host Directory Sharing Yes Yes - The specified host directory is mounted to /mnt/host to share resources. Therefore, the file transfer is possible through the host directory sharing feature without using the sdb utility. + The specified host directory is mounted to /mnt/host to share resources. Therefore, the file transfer is possible through the host directory sharing feature without using the SDB utility. @@ -684,7 +706,7 @@ $egrep -c '(vmx|svm)' /proc/cpuinfo Yes Yes You can inject a lux value into light sensor. - If you set brightness as auto, then display will be changed by injecting light value. + If you set brightness as auto, the display is changed by injecting light value. @@ -1043,32 +1065,31 @@ $egrep -c '(vmx|svm)' /proc/cpuinfo Table: Supported Emulator features - Feature - Detail + Feature + Detail Status Notes Skin -

    Skins are fitted to the screen resolution:

    +Skins are fitted to the screen resolution:
    • Mobile
      • WVGA (480 x 800, default)
      • -
      • qHD (540 x 960)
      • HD (720 x 1280)
      -
    • +
    • Wearable
      • 320 x 320
      • 360 x 360 (default)
      • 360 x 480
    • -
    + -

    4 orientation modes are supported:

    +

    4 orientation modes are supported:

    • Portrait (default), landscape, reverse portrait, and reverse landscape
    @@ -1082,7 +1103,7 @@ $egrep -c '(vmx|svm)' /proc/cpuinfo Touch -Maru touchscreen device +Maru touch screen device Supported Multi-touch is supported. @@ -1174,7 +1195,7 @@ $egrep -c '(vmx|svm)' /proc/cpuinfo Camera -

    Virtual camera device is available. It can be connected to a host machine's Webcam and import an animated GIF image file.

    +Virtual camera device is available. It can be connected to a host machine's Webcam and import an animated GIF image file.

    Support: preview, capture, and record

    Image format: YUYV, I420, and YV12

    Attributes: brightness and contrast

    diff --git a/org.tizen.devtools/html/common_tools/emulator_features.htm b/org.tizen.devtools/html/common_tools/emulator_features.htm index 10edf63..4ffc059 100644 --- a/org.tizen.devtools/html/common_tools/emulator_features.htm +++ b/org.tizen.devtools/html/common_tools/emulator_features.htm @@ -11,7 +11,7 @@ - Using the Extended Emulator Features + Extended Emulator Features @@ -36,7 +36,7 @@
    -

    Using the Extended Emulator Features

    +

    Extended Emulator Features

    The Emulator features can be extended in many ways. With the Emulator, you can:

    • Use multi-point touch
    • @@ -85,7 +85,7 @@ style="display: block; text-align: center; margin-left: auto; margin-right: auto

      To move 2 existing points symmetrically together, press and hold the CTRL (Command in Mac OS® X) and ALT keys, mouse-click an existing point, and move it to another location on the screen.

      Figure: Symmetrically moving 2 existing points

      -

      Symmetrical moving the two existing points

      +

      Symmetrical moving the 2 existing points

      Ending the Multi-point Touch

      @@ -434,7 +434,7 @@ resolution.height=800 Note - If you re-install the Tizen IDE, the custom skin folders are reset. + If you reinstall the Tizen IDE, the custom skin folders are reset. @@ -491,7 +491,7 @@ resolution.height=800 Note -On Android 4.2 and newer, the developer options are hidden by default. To make them available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find the developer options. +On Android 4.2 and newer, the developer options are hidden by default. To make them available, go to Settings > About phone and tap Build number 7 times. Return to the previous screen to find the developer options. @@ -559,9 +559,9 @@ resolution.height=800 Heartbeat hb.ignore=x No -This option is used to activate the Emulator debugging mode. Generally, a skin process for the Emulator periodically checks the heartbeat that an Emulator process sends.
      -When the Emulator is in the debugging mode using gdb, the skin process is terminated automatically, because the Emulator cannot send a heartbeat to the skin process. In that case, you can set the hb.ignore option as true to debug the Emulator.
      -If this option is true, the skin process does not check the heartbeat that the Emulator sends. The default value of this option is false. +This option is used to activate the Emulator debugging mode. Generally, a skin process for the Emulator periodically checks the heartbeat that an Emulator process sends. +

      When the Emulator is in the debugging mode using GDB, the skin process is terminated automatically, because the Emulator cannot send a heartbeat to the skin process. In that case, you can set the hb.ignore option as true to debug the Emulator.

      +

      If this option is true, the skin process does not check the heartbeat that the Emulator sends. The default value of this option is false.

      @@ -608,9 +608,9 @@ If this option is true< Enables the USB driver. -TouchScreen +Touch screen -device virtio-touchscreen-pci -Uses the Maru Touchscreen device for display. +Uses the Maru touch screen device for display. Kernel @@ -632,7 +632,7 @@ If this option is true< Sets the real time clock with UTC. -KVM (in Ubuntu®) +KVM (in Ubuntu) -enable-kvm Enables KVM (hardware virtualization support). @@ -821,6 +821,7 @@ maru-brightness -device virtio-vmodem-pci -device maru-camera -device virtio-tou Emulator manager binary to launch the emulator-manager.jar file + bin/emulator-manager.jar Emulator manager jar, which can also launch the @@ -831,9 +832,9 @@ maru-brightness -device virtio-vmodem-pci -device maru-camera -device virtio-tou bin/em-cli Emulator manager CLI (Command Line Interface) - + - bin/jna-<version>.jar + bin/jna-<VERSION>.jar JNA library @@ -875,56 +876,55 @@ maru-brightness -device virtio-vmodem-pci -device maru-camera -device virtio-tou -

      The following table describes the platform directories that are located in the <TIZEN_SDK>/platforms/<PLATFORM_VERSION>/common/emulator folder.

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Table: Platform directory common content
      NameDescription
      bin/Binary files
      bin/emulator-x86x86 Emulator binary, including QEMU
      bin/emulator-control-panel.jarEmulator Control Panel
      bin/emulator-control-panel-cli.jarEmulator Control Panel CLI (Command Line Interface)
      bin/protobuf.jarProtocol buffer library
      bin/libecp.jarProfile independent library for ECP
      bin/swt.jarSWT library
      data/bios/.bin files for initializing the guest OS
      data/kernel/Kernel image for the guest Linux OS
      Table: Platform directory common content
      NameDescription
      bin/Binary files
      bin/emulator-control-panel.jarEmulator Control Panel
      bin/emulator-control-panel-cli.jarEmulator Control Panel CLI (Command Line Interface)
      bin/emulator-x86x86 Emulator binary, including QEMU
      bin/libecp.jarProfile-independent library for ECP
      bin/protobuf.jarProtocol buffer library
      bin/swt.jarSWT library
      data/bios/.bin files for initializing the guest OS
      data/kernel/Kernel image for the guest Linux OS
      -

      The following table describes the platform directories that are located in the <TIZEN_SDK>/platforms/<PLATFORM_VERSION>/<PROFILE>/emulator-resources folder.

      + @@ -945,7 +945,7 @@ maru-brightness -device virtio-vmodem-pci -device maru-camera -device virtio-tou - + @@ -958,7 +958,7 @@ maru-brightness -device virtio-vmodem-pci -device maru-camera -device virtio-tou - + @@ -982,49 +982,49 @@ maru-brightness -device virtio-vmodem-pci -device maru-camera -device virtio-tou - - - - - - - - - + + + + + + + + + - + - + - + - - + + - + - + - + - - + +
      Table: Platform directory resource content
      XML file for the ecp-plugin.jar file configuration
      plugins/em-plugin-<PROFILE>.jarplugins/em-plugin-<PROFILE>.jar Plugin for the Emulator Manager
      skins/<SKIN_NAME>/layout.xmlMeta file for the Emulator skin layoutMetafile for the Emulator skin layout
      template/<IMAGE_NAME>.xmlName Description
      emulator-manager.logEmulator Manager log file
      last-created_<PROFILE>-<VERSION>_<image name>.xmlThis file saves properties of VM that user created last. And when user create new VM next time, properties in this file is displayed as default
      .em.lock This lock file is used for synchronization between VM operation like modify, delete, launch
      .tizen-em-infoConfiguration file for Emulator ManagerConfiguration file for the Emulator Manager
      emulator-manager.logEmulator Manager log file
      last-created_<PROFILE>-<VERSION>_<IMAGE_NAME>.xmlThis file saves properties of VM that user created last. And when user create new VM next time, properties in this file is displayed as default
      <image name>/<IMAGE_NAME>/ Target-specific images
      <image name>/gui.property<IMAGE_NAME>/gui.property Hidden data for the Emulator GUI
      <image name>/emulimg-<image name>.x86Writable <image name> image file<IMAGE_NAME>/emulimg-<IMAGE_NAME>.x86Writable <IMAGE_NAME> image file
      <image name>/swap-<image name>.img<IMAGE_NAME>/swap-<IMAGE_NAME>.img Swap image file
      <image name>/vm_config.xml<IMAGE_NAME>/vm_config.xml Hardware configuration (for more information, see Virtual Machine)
      <image name>/${USER}.lock<IMAGE_NAME>/${USER}.lock This lock file is used for synchronization between VM and Emulator Control Panel to set/get operations
      <image name>/logs/Log files (Emulator, kernel log)<IMAGE_NAME>/logs/Log files (Emulator and kernel logs)
      diff --git a/org.tizen.devtools/html/common_tools/keyboard_shortcuts.htm b/org.tizen.devtools/html/common_tools/keyboard_shortcuts.htm index 02cfaa9..46057f7 100644 --- a/org.tizen.devtools/html/common_tools/keyboard_shortcuts.htm +++ b/org.tizen.devtools/html/common_tools/keyboard_shortcuts.htm @@ -52,6 +52,7 @@

      Connection Explorer

      + @@ -88,6 +89,7 @@

      Build and Run

      Table: Connection Explorer shortcuts
      + @@ -135,6 +137,7 @@

      Debug

      Table: Build and run shortcuts
      + @@ -192,6 +195,7 @@

      Content Assist

      Table: Debug shortcuts
      + @@ -211,6 +215,7 @@

      Project Management

      Table: Content assist shortcuts
      + @@ -303,6 +308,7 @@

      Editor

      Table: Project management shortcuts
      + @@ -468,6 +474,7 @@

      Refactor

      Table: Editor shortcuts
      + @@ -527,6 +534,7 @@

      Native IDE

      Table: Refactor shortcuts
      + @@ -577,6 +585,7 @@

      Web IDE

      Table: Native IDE shortcuts
      + @@ -674,6 +683,7 @@

      Dynamic Analyzer

      Table: Web IDE shortcuts
      + @@ -820,6 +830,7 @@

      Emulator Manager

      Table: Dynamic analyzer shortcuts
      + @@ -853,6 +864,7 @@

      Emulator

      Table: Emulator Manager shortcuts
      + @@ -953,6 +965,7 @@

      Emulator Control Panel (ECP)

      Table: Emulator shortcuts
      + @@ -1153,6 +1166,7 @@

      EDC Editor

      Table: ECP shortcuts
      + @@ -1163,197 +1177,159 @@ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
      Table: Enventor shortcuts
      Keyboard shortcut

      Close the menu

      ubuntu

      Esc

      Close the menuubuntu windows macEsc

      Show shortcut keys

      ubuntu

      F1

      Show shortcut keysubuntu windows macF1

      Save the file

      ubuntu

      F3

      Show or hide the line numbersubuntu windows macF5

      Show or hide the line numbers

      ubuntu

      F5

      Show or hide the toolbarubuntu windows macF9

      Show or hide the toolbar

      ubuntu

      F9

      Show or hide the EDC navigatorubuntu windows macF10

      Show or hide the console view

      ubuntu

      F10

      Show or hide the status barubuntu windows macF11

      Show or hide the status bar

      ubuntu

      F11

      Show the configuration setting windowubuntu windows macF12

      Show the configuration setting window

      ubuntu

      F12

      Quick save and compile EDCubuntu windows macCtrl+S

      Quick save and compile EDC

      ubuntu

      Ctrl+S

      Enable or disable auto indentationubuntu windows macCtrl+I

      Enable or disable auto indentation

      ubuntu

      Ctrl+I

      Enable or disable auto completionubuntu windows macCtrl+O

      Enable or disable auto completion

      ubuntu

      Ctrl+O

      Show or hide virtual images to visualize SWALLOW part objectsubuntu windows macCtrl+W

      Show or hide virtual images to visualize SWALLOW part objects

      ubuntu

      Ctrl+W

      Enable or disable part object highlightingubuntu windows macCtrl+H

      Enable or disable part object highlighting

      ubuntu

      Ctrl+H

      Enable or disable full text viewubuntu windows macAlt+Left

      Enable or disable full text view

      ubuntu

      Ctrl+Left

      Enable or disable full live viewubuntu windows macAlt+Right

      Enable or disable full live view

      ubuntu

      Ctrl+Right

      Enable or disable full console viewubuntu windows macAlt+Up

      Enable or disable full console view

      ubuntu

      Ctrl+Up

      Enable or disable full live/text viewubuntu windows macAlt+Down

      Enable or disable full live/text view

      ubuntu

      Ctrl+Down

      Insert default template codeubuntu windows macCtrl+T

      Insert default template code

      ubuntu

      Ctrl+T

      View scale up/bigger font sizeubuntu windows macCtrl+Mouse wheel up

      Enable or disable LiveEdit function

      ubuntu

      Ctrl+E

      View scale down/smaller font sizeubuntu windows macCtrl+Mouse wheel down

      View scale up/bigger font size

      ubuntu

      Ctrl+Mouse wheel up

      Select all the textubuntu windows macCtrl+A

      View scale down/smaller font size

      ubuntu

      Ctrl+Mouse wheel down

      Select the wordubuntu windows macCtrl+Double-click

      Insert part template code: Textblock

      ubuntu

      Ctrl+Shift+B

      Undo text changesubuntu windows macCtrl+Z

      Insert part template code: Image

      ubuntu

      Ctrl+Shift+I

      Redo text changesubuntu windows macCtrl+R

      Insert part template code: Rectangle

      ubuntu

      Ctrl+Shift+R

      Copy selected textubuntu windows macCtrl+C

      Insert part template code: Text

      ubuntu

      Ctrl+Shift+T

      Paste copied textubuntu windows macCtrl+V

      Insert part template code: Spacer

      ubuntu

      Ctrl+Shift+S

      Cut selected textubuntu windows macCtrl+X

      Insert part template code: Swallow

      ubuntu

      Ctrl+Shift+W

      Delete a current lineubuntu windows macCtrl+D

      Select all the text

      ubuntu

      Ctrl+A

      Find and replace the given wordubuntu windows macCtrl+F

      Select the word

      ubuntu

      Ctrl+Double-click

      Go to the given lineubuntu windows macCtrl+L

      Undo text changes

      ubuntu

      Ctrl+Z

      Go to the top lineubuntu windows macCtrl+Home

      Redo text changes

      ubuntu

      Ctrl+R

      Copy selected text

      ubuntu

      Ctrl+C

      Paste copied text

      ubuntu

      Ctrl+V

      Cut selected text

      ubuntu

      Ctrl+X

      Delete a current line

      ubuntu

      Ctrl+D

      Find and replace the given word

      ubuntu

      Ctrl+F

      Go to the given line

      ubuntu

      Ctrl+L

      Go to the top line

      ubuntu

      Ctrl+Home

      Go to the bottom line

      ubuntu

      Ctrl+End

      Go to the bottom lineubuntu windows macCtrl+End
      diff --git a/org.tizen.devtools/html/common_tools/smart_dev_bridge.htm b/org.tizen.devtools/html/common_tools/smart_dev_bridge.htm index 4bb92aa..318ee3c 100644 --- a/org.tizen.devtools/html/common_tools/smart_dev_bridge.htm +++ b/org.tizen.devtools/html/common_tools/smart_dev_bridge.htm @@ -150,7 +150,7 @@ emulator-26200 device myemulator2 sdb install <path_to_tpk> -

      Push the tpk package file to the device and install it.

      + Push the tpk package file to the device and install it.

      The <path_to_tpk> parameter defines to the path to the tpk file. The following command shows an example:

      $ sdb install /home/tizen/ko983dw33q-1.0.0-i386.tpk
      @@ -158,7 +158,7 @@ emulator-26200 device myemulator2 sdb uninstall <appid> -

      Uninstall the application from the device.

      + Uninstall the application from the device.

      The <appid> parameter defines the application ID of the application. The following command shows an example:

      $ sdb uninstall ko983dw33q
      @@ -170,10 +170,10 @@ emulator-26200 device myemulator2

      The format for the <local> and <remote> parameters is tcp:<port>. The following example shows how to forward requests from host port 26102 to device port 9999:

      $ sdb forward tcp:26102 tcp:9999
      -

      After setting up port forwarding, development tools between the device and host can work remotely. For example, gdb in a host/gdbserver in a device, and gdbserver in a device open with the tcp:9999 port:

      +

      After setting up port forwarding, development tools between the device and host can work remotely. For example, GDB in a host/gdbserver in a device, and gdbserver in a device open with the tcp:9999 port:

      $ sdb shell gdbserver:9999 hellotizen
      -

      gdb in a host connects to localhost:26102

      +

      GDB in a host connects to localhost:26102:

      $ gdb hellotizen ... (gdb) target remote localhost:26102
      @@ -191,8 +191,10 @@ emulator-26200 device myemulator2 - sdb start-server - Start the server if it is not running. + sdb start-server [--only-detect-tizen] + Start the server. +

      If the [--only-detect-tizen] parameter is specified, the SDB detects Tizen devices only.

      +

      If you want the SDB to also detect Android devices, omit the parameter.

      diff --git a/org.tizen.devtools/html/cover_page.htm b/org.tizen.devtools/html/cover_page.htm index 9b5b8e5..f6a466a 100644 --- a/org.tizen.devtools/html/cover_page.htm +++ b/org.tizen.devtools/html/cover_page.htm @@ -33,13 +33,13 @@

      Download and install the SDK, manage its configurations, and read the release notes of different versions.

    • Common Tools -

      Learn about tools common to both Web and native application development.

      -
    • -
    • Web Tools -

      Learn about available Web application development tools.

      +

      Learn about tools common to both native and Web application development.

    • Native Tools

      Learn about available native application development tools.

      +
    • +
    • Web Tools +

      Learn about available Web application development tools.

    • Extension SDK

      Gather information about the Extension SDK: In-App Purchase.

      @@ -53,7 +53,7 @@

      The Tizen SDK consists of the following:

      • Platform binaries and libraries -

        Binaries of Tizen and 3rd party libraries

      • +

        Binaries of Tizen and third-party libraries

      • Header files

        Header files of Tizen

      • @@ -62,7 +62,7 @@

        The Tizen Integrated Development Environment (IDE) is based on the JSDT (JavaScript Development Tools) and Eclipse CDT (C/C++ Development Tools).

      • Tools -

        The Tizen SDK provides various tools for Web application and native application development. Some common tools can be used for all application types.

      • +

        The Tizen SDK provides various tools for native application and Web application development. Some common tools can be used for all application types.

      • Sample applications

        The Tizen SDK includes practical examples of using Tizen APIs in various applications.

      • @@ -99,7 +99,7 @@ style="font-family: Courier New,Courier,monospace">install-manager library - Tizen library and 3rd party libraries + Tizen library and third-party libraries
      • <tizen:privilege>: This tag is used to specify API permissions. (The <feature> tag is now be used to specify the required platform or hardware features.)
    • NPRuntime plug-in support in Web applications: -
      • In the 2.0 release, only the 3rd party libraries supported as public APIs, such as eglibc, can be used in NPRuntime plug-ins.
      • +
        • In the 2.0 release, only the third-party libraries supported as public APIs, such as eglibc, can be used in NPRuntime plug-ins.
    @@ -137,7 +137,7 @@
  • Web Runtime - -

    Properties specification

    +

    Figure: Attributes tab

    +

    Attributes tab

  • Event

    In the Event tab, you can create an event handler and bind it. If you click the Forward button, the C editor opens. When the event handler function is focused, you can start writing code.

    -

    Properties view

    +

    Figure: Event tab

    +

    Event tab

  • -

    Resources View

    +

    Resource Manager View

    +

    The Resource Manager view helps you to place resources to support specific device configurations, such as different screen densities.

    + +

    Figure: Resource Manager view

    +

    Resource Manager view

    +

    In the Resource Manager view, you can:

    -

    The Resources view displays the resources in the selected project. If the Resources view is not visible, open it from Window > Show View > Other > Tizen > Resources.

    -

    Figure: Resources view

    -

    Resources view

    -

    The Resources view provides the following features:

      -
    • Resource navigation -

      You can move files to child and parent folders.

      -
    • -
    • Resource management -

      You can copy, paste, delete, and rename resources.

      -
    • -
    • Resource filter -

      You can filter the view to show resources of a particular name or extension.

      -
    • -
    • Resource import -

      You can import files or folders.

      -
    • -
    • Easy editing -

      You can edit the resource property of the UI components using drag and drop.

      -
    • +
    • See all resource configurations that the project provides.
    • +
    • Create and remove multiple configuration-qualifier directories.
    • +
    • Copy the resources to an alternative directory by dragging and dropping into the view area. You can also remove the selected resource from the view by pressing Delete in the keyboard or clicking Delete in the context menu.
    • +
    • Generate code snippets by dragging and dropping into the source editor area.
    • + +
    - -

    WYSIWYG Editor

    +

    For more detailed information, see Resource Manager.

    + +

    WYSIWYG Editor

    The WYSIWYG Editor view is a WYSIWYG (What You See Is What You Get) editor for the UI Builder project.

    @@ -184,9 +169,9 @@

    The palette contains EFL UI components, which you can select and add to the design area.

    • Supported UI components in the 2.4 platform: -

      Scroller, Grid, Table, Box, Panes, Panel, Button, Check, Radio, Colorselector, Entry, Spinner, Slider, Naviframe, List, Genlist, Toolbar, Multibuttonentry, Gengrid, Index, Background, Datetime, Icon, Image, Label, Progressbar, and Layout

    • +

      Scroller, Grid, Table, Box, Panes, Panel, Button, Check, Radio, Colorselector, Entry, Spinner, Slider, List, Genlist, Toolbar, Multibuttonentry, Gengrid, Index, Flipselector, Background, Datetime, Image, Label, Progressbar, Layout, Map, and Calendar

    • Supported UI components in the 2.3.1 platform: -

      Scroller, Grid, Table, Box, Panes, Button, Check, Radio, Entry, Spinner, Slider, Naviframe, List, Genlist, Index, Background, Datetime, Icon, Image, Label, Progressbar, and Layout

    • +

      Scroller, Grid, Table, Box, Panes, Button, Check, Radio, Entry, Spinner, Slider, List, Genlist, Index, Background, Datetime, Image, Label, Progressbar, Layout, and Map

  • @@ -195,6 +180,7 @@
    • Select the view you want to edit using the view combo. + @@ -211,29 +197,31 @@
      Table: Toolbar buttons
      View button
    • -
    • Select the resolution of the design area using the drop-down menu.
    • -
    • Zoom within the design area.
      +
    • Select the screen configuration of the design area using the drop-down menu.
    • +
    • Select the locale of the design area using the drop-down menu.
    • +
    • +

      Screen Configurator

      +

      To design a UI layout for a specific screen configuration, you need to create a screen configuration. You can launch the Screen Configurator wizard by clicking the Screen Configurator icon ().

      +

      Figure: Screen Configurator

      +

      screenconfigurator

      +

      You can add, modify, and delete screen configurations in the Screen Configurator wizard.

      +
    • + +
    • Zoom within the design area. + - - - - - - - - - + - - + +
      Table: Toolbar zoom buttons
      Zoom button Description
      Zoom out.
      Zoom in.
      Maximize the design area on the screen.
      Change the design area size to a predefined percentage value.Move the indicator with a mouse to change the design area zoom level, or input a zoom level value in the text box.
      @@ -241,9 +229,36 @@
  • -

    Design area

    +

    Design tab

    You can work with UI components visually so that you can see what your application looks like as you build it.

  • + +
  • +

    Source tab

    +

    Figure: Source tab

    +

    sourcetab

    +

    Another UI programming method of the native UI Builder is to use the XML editor. You can edit your layout file in the Source tab.

    +

    The Source tab provides the following features:

    +
      +
    • Preview pane +

      While editing the layout file, you can see visualized result in the Preview pane.

      +
    • +
    • Content assist +

      It helps you to write code faster and more efficiently.

      +
    • +
    • Auto complete +

      If you select a tag in the suggested list with content assist, the auto complete feature automatically adds the end tag.

      +
    • +
    • Selection synchronization +

      If you move a focus to another UI component in the Source tab, the selection in the Preview pane is automatically synchronized.

      +
    • +
    +
  • + +
  • +

    Storyboard tab

    +

    You can design page transitions with the Storyboard.

    +
  • diff --git a/org.tizen.devtools/html/native_tools/unit_test_n.htm b/org.tizen.devtools/html/native_tools/unit_test_n.htm index 2b81d91..5f42afd 100644 --- a/org.tizen.devtools/html/native_tools/unit_test_n.htm +++ b/org.tizen.devtools/html/native_tools/unit_test_n.htm @@ -37,9 +37,9 @@

    Unit Test

    -

    Unit test tools verify that the unit works exactly as intended in the particular module's source code. If you encounter any problems due to code changes, they help identify the problem within a short period of time and make it right. The Tizen IDE provides an effective unit test tool for Tizen native applications. The tool offers the Unit Test Wizard for creating a unit test project, with which you can create and run test cases.

    +

    Unit test tools verify that the unit works exactly as intended in the particular module's source code. If you encounter any problems due to code changes, they help identify the problem within a short period of time and make it right. The Tizen IDE provides an effective unit test tool for Tizen native projects. The tool offers the Unit Test Wizard for creating a unit test project, with which you can create and run test cases.

    -

    To unit test your application:

    +

    To unit test your project:

    1. Create a test project.
    2. Edit a test project.
    3. @@ -53,7 +53,7 @@
    4. In the IDE menu, select File > New > Other > Tizen > Tizen Native Unit Test Project.
    5. In the New Tizen Unit Test Project window:
        -
      1. In the Select the Tizen project for test panel, select the application you want to test.
      2. +
      3. In the Select the Tizen project for test panel, select the project you want to test.
      4. Define a name for the test project.
      5. Define a destination folder where to save the project.

        Select the Use default location check box to save the test project in the IDE workspace, or browse to the required destination folder.

        @@ -64,8 +64,7 @@
      -

      The generated test project allows you to test your application.

      - +

      The generated test project allows you to test your project.

      Editing a Test Project

      @@ -78,6 +77,62 @@

      The unit test tool supports basic assertions, binary comparison, and string comparison in gtest. For more information, see https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md.

    + +

    To test your project written in the C code, a unit test project in the C++ language is provided. In this case, the function to be tested must be qualified as an extern "C" to avoid the "undefined reference" error as demangled symbols in the error message.

    +

    There are 2 forms of the extern "C" declaration:

    +
      +
    • Declare the extern "C" linkage specification in C header file:

      + +
      +#ifdef __cplusplus
      +extern "C"
      +{
      +    #endif
      +
      +    int foo;
      +    void bar();
      +
      +
      +    #ifdef __cplusplus
      +}
      +#endif
      +
    • +
    • Include the C headers in C++ code:

      + +
      +extern "C"
      +{
      +    #include "header.h"
      +}
      +
    • +
    +

    In the following example with a calculator sample project, write a test case for the utils_round() function declared in the utils/utils.h header:

    +
      +
    1. Create a calculator project named "Calculator", and for it a unit test project named "CalculatorTest".
    2. +
    3. Append the test method to the end of the CalculatorTest/src/CalculatorTestTestCase.cpp file:
    4. +
      +TEST_F(TestSuite, utils_round)
      +{
      +    double var = 3.5;
      +    /* long long utils_round(double value); */
      +
      +    EXPECT_EQ(utils_round(var), (long long)4);
      +}
      +
      +
    5. Change the line that includes the utils/utils.h file: +
      +#include "view/window.h"
      +#include "view/main-view.h"
      +extern "C"
      +{
      +    #include "utils/utils.h"
      +}
      +#include "utils/ui-utils.h"
      +
      +

      If you do not want to change the source code in the calculator project, you can declare the extern "C" linkage specifications in the test project as above.

      +
    6. +
    +

    Running a Test Project

    You can run a test project on the Emulator or a target device.

    diff --git a/org.tizen.devtools/html/web_tools/config_editor_w.htm b/org.tizen.devtools/html/web_tools/config_editor_w.htm index 75bdac7..6c366eb 100755 --- a/org.tizen.devtools/html/web_tools/config_editor_w.htm +++ b/org.tizen.devtools/html/web_tools/config_editor_w.htm @@ -546,7 +546,7 @@
  • launch_mode

    Optional; sets which launch mode is supported (available values: single (default), group, caller)

    • single: launched as a main application
    • group: launched as a sub application
    • -
    • caller: caller application defines the launch mode with the app_control_set_launch_mode() function
    +
  • caller: caller application defines the launch mode with the app_control_set_launch_mode() method
  • Since: 2.4

    @@ -635,7 +635,7 @@ - +
    Note
    Since Tizen 2.4, the system manages background processes more tightly. Even if background-support is set to enable, the Web application process can be suspended on the background. To guarantee that the application runs on the background, add at least one background category for the application with the <tizen:background-category> element. Only the background categories declared in the system can be used.Since Tizen 2.4, the system manages background processes more tightly. Even if background-support is set to enable, the Web application process can be suspended on the background. To guarantee that the application runs on the background, add at least one background category for the application with the <tizen:background-category> element. Only the background categories declared in the system can be used.
    @@ -833,7 +833,7 @@

    Attributes:

      -
    • name

      Mandatory; string.

    • +
    • name

      Mandatory; string

    Example:

    <tizen:profile name="mobile" />

    @@ -875,7 +875,7 @@
  • launch_mode

    Optional; sets which launch mode is supported (available values: single (default), group, caller)

    • single: launched as a main application
    • group: launched as a sub application
    • -
    • caller: caller application defines the launch mode with the app_control_set_launch_mode() function
    +
  • caller: caller application defines the launch mode with the app_control_set_launch_mode() method
  • Since: 2.4

    @@ -998,13 +998,13 @@ - +
    Note
    Since Tizen 2.4, the system manages background processes more tightly. Even if background-support is set to enable, the Web application process can be suspended on the background. To guarantee that the application runs on the background, add at least one background category for the application with the <tizen:background-category> element. Only the background categories declared in the system can be used.Since Tizen 2.4, the system manages background processes more tightly. Even if background-support is set to enable, the Web application process can be suspended on the background. To guarantee that the application runs on the background, add at least one background category for the application with the <tizen:background-category> element. Only the background categories declared in the system can be used.
  • context-menu

    Optional; Sets whether the context menu is shown (available values: enable (default), disable)

    If this option is enabled, the context menu is visible to the user.

  • -
  • encryption

    Optional; Sets whether Web Application resources are encrypted (available values: enable , disable (default))

    If this option is enabled, the application resources(HTML, JS and CSS files) are encrypted.

  • +
  • encryption

    Optional; Sets whether Web Application resources are encrypted (available values: enable, disable (default))

    If this option is enabled, the application resources(HTML, JS and CSS files) are encrypted.

  • screen-orientation

    Optional; Sets whether it locks orientation of Web Application (available values: portrait (default), landscape, auto-rotation)

    If this option is portrait or landscape, the orientation is locked to portrait or landscape respectively.

    If the option is auto-rotation, it follows device orientation setting.

  • install-location

    Optional; Sets where Web Application is installed (available values: auto (default), internal-only, prefer-external)

    o auto: the system defined install location.

    o internal-only: the device internal storage.

    o prefer-external: the external storage (if exists).

  • hwkey-event

    Optional; a hardware key event is sent to the Web application when the user presses the hardware key (available values: enable (default), disable)

    If this option is enabled, the tizenhwkey custom event is sent to the Web application. The tizenhwkey event object has a keyName attribute (available value: back).

  • @@ -1282,10 +1282,10 @@
  • id

    Mandatory; Tizen service ID, which is a combination of the Tizen wearable package ID and service name.

    The service ID is a set of characters (0~9, a~z, A~Z) and unique in the device. The minimum value is 1 byte and maximum value is 52 bytes.

    • -
    • auto-restart

      Optional; Sets whether service application is re-launched automatically when it is terminated. (available values: true , false (default))

    • +
    • auto-restart

      Optional; Sets whether service application is relaunched automatically when it is terminated (available values: true, false (default))

      -
    • on-boot

      Optional; Sets whether service application is launched automatically on device booting time. (available values: true , false (default))

    • +
    • on-boot

      Optional; Sets whether service application is launched automatically on device booting time (available values: true, false (default))

    Example:

    <tizen:service id="webService.application" auto-restart="true" on-boot="false">
        <tizen:name>WebService</tizen:name>
    @@ -1409,7 +1409,7 @@
     	
     	 

    Attributes:

      -
    • name

      Mandatory; string.

    • +
    • name

      Mandatory; string

    @@ -1430,7 +1430,7 @@

    Attributes:

      -
    • name

      Mandatory; string.

    • +
    • name

      Mandatory; string

    Example:

    <tizen:profile name="wearable" />

    diff --git a/org.tizen.devtools/html/web_tools/content_assist_w.htm b/org.tizen.devtools/html/web_tools/content_assist_w.htm index bf8edf1..dc997b9 100644 --- a/org.tizen.devtools/html/web_tools/content_assist_w.htm +++ b/org.tizen.devtools/html/web_tools/content_assist_w.htm @@ -27,7 +27,7 @@

    Content assist is a functionality provided in parts of the Tizen IDE. It helps you to write quick and efficient code as it completes the names of the APIs automatically on writing the initial part of the API name.

    -

    Tizen IDE supports Web API, W3C API, jQuery API, and jQuery Mobile API. User-defined and third party APIs can be supported by expanding the content assist functionality.

    +

    Tizen IDE supports Web API, W3C API, jQuery API, and jQuery Mobile API. User-defined and third-party APIs can be supported by expanding the content assist functionality.

    Figure: Content assist in the JavaScript editor

    Content assist in the JavaScript editor

    In the JavaScript editor or HTML editor, press Ctrl + Space to complete the code. A list of available code completions opens. To use content assist:

    @@ -41,13 +41,13 @@ Note - To activate content assist for user-defined and third party APIs, add the WIDL (Web Interface Definition Language) feature in the config.xml file. + To activate content assist for user-defined and third-party APIs, add the WIDL (Web Interface Definition Language) feature in the config.xml file.

    In the mobile Web JavaScript editor, you can activate content assist by . (dot). It can be set by checking the Enable auto activation checkbox in Window > Preferences > JavaScript > Editor > Content Assist.

    For more information, see Specifying Privileges in the Privilege Tab.

    -

    To expand content assist functionality to user-defined and third party APIs:

    +

    To expand content assist functionality to user-defined and third-party APIs:

    1. Prepare an API definition document using the WIDL standard. The Tizen IDE supports the .xml and .widlprocxml files.
    2. Add the definition file in the config.xml file.
    3. diff --git a/org.tizen.devtools/html/web_tools/html_editor_w.htm b/org.tizen.devtools/html/web_tools/html_editor_w.htm index fa1046a..b0e13b6 100644 --- a/org.tizen.devtools/html/web_tools/html_editor_w.htm +++ b/org.tizen.devtools/html/web_tools/html_editor_w.htm @@ -23,7 +23,6 @@

      Content

        -
      • HTML5 Elements
      • Breadcrumb
      • Advanced Content Assist
      • Advanced Content Hover
      • @@ -36,62 +35,13 @@

        HTML Editor

        -

        The Tizen Web IDE provides a WYSIWYG editor for editing HTML files. To clean up HTML code by adding indentation and carriage returns, use the Code Beautifier, and to remove unnecessary content from the HTML files, use the Code Minifier.

        -

        The editor supports a variety of HTML5 elements. The HTML editor is based on the Web Page Editor (WPE).

        +

        The Tizen Web IDE provides a text editor for an HTML file. The editor supports the basic features, such as writing, deleting, finding, and replacing.

        + +

        If you want to indent the codes in the HTML file and insert a carriage return at the end of the code in a CSS file, in the Project Explorer view, right-click the file and select Code Beautifier. To compress an HTML file, right-click the file select Code Minifier.

        +

        The HTML editor is based on the Structured Text Editor.

        The HTML editor has the following features:

          -
        • Design page
        • -
        • WYSIWYG Builder -
            -
          • Drag-and-drop HTML components from the Palette menu - - - - - - - - - -
            Note
            The editor has separate component Palette menus for HTML 4.0 and HTML5.
          • -
          • HTML design view
          • -
        • -
        • Modes -
            -
          • Editor mode toolbar
          • -
          • The following table lists the available modes. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            Available editor modes
            IconDescription
            Horizontal Split ViewHorizontally-split View (Ctrl+Shift+F9)
            Vertical Split ViewVertically-split View (Ctrl+Shift+F10)
            Designer ViewDesigner View (Ctrl+Shift+F11)
            Source ViewSource View (Ctrl+Shift+F12)
            SkinManage Skins (see Skins)
          • -
          -
        • PropertySheet

          After creating HTML files, you can preview them in a browser.

          - -

          HTML5 Elements

          -

          The following table lists the HTML5 elements supported by the HTML editor.

          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          - Supported HTML5 elements -
          IconElementDescription
          articlearticleSpecifies independent, self-contained content. Articles can be, for example, a forum post or a newspaper article.
          asideasideDefines content that is related to surrounding content but can also stand alone.
          audioaudioDefines a sound or audio stream.
          canvascanvasProvides scripts with a resolution-dependent bitmap canvas that is used for rendering graphs, game graphics, or other visual images on the fly.
          commandcommandDefines a command that a user can invoke.
          datalistdatalistDefines a set of option elements that represent predefined options for other controls.
          detailsdetailsDefines a disclosure widget from which users obtain additional information or controls.
          figurefigureDefines flow content, optionally with a caption, that is self-contained and is typically referenced as a single unit from the main flow of the document.
          footerfooterDefines a footer for a document or section.
          headerheaderDefines a header for a document or section.
          hgrouphgroupDefines the heading of a section.
          keygenkeygenDefines a key-pair generator control.
          markmarkDefines text that is marked or highlighted in a document due to its relevance in another context.
          mathmathDefines a MathML element.
          metermeterDefines a scalar measurement within a known range, or a fractional value. For example, disk usage.
          navnavDefines a section with navigation links.
          outputoutputDefines a result of a calculation.
          progressprogressRepresents the progress of a task.
          rubyrubyDefines ruby annotations.
          sectionsectionDefines a generic section in a document or application.
          sourcesourceDefines multiple alternative media resources for media elements.
          summarysummaryDefines a summary, caption, or legend within a details element.
          svgsvgDefines scalable vector graphics (SVG).
          timetimeDefines the time on a 24-hour clock, or a precise date in the proleptic Gregorian calendar, optionally with a time and a time-zone offset.
          videovideoUsed for playing videos or movies, and audio files with captions.
          diff --git a/org.tizen.devtools/html/web_tools/js_analyzer_w.htm b/org.tizen.devtools/html/web_tools/js_analyzer_w.htm index 3e305fa..b33c8ab 100644 --- a/org.tizen.devtools/html/web_tools/js_analyzer_w.htm +++ b/org.tizen.devtools/html/web_tools/js_analyzer_w.htm @@ -156,13 +156,13 @@ var test = outer(); /* Whenever the test is called, the result can be different from the expectation */ -/* 1st return */ +/* First return */ test(); -/* 2nd return */ +/* Second return */ test(); -/* 3rd return */ +/* Third return */ test();

    The JSA displays the following message:

    @@ -249,7 +249,7 @@ var arr2 = new Array(1, 2, 3);

    Modifying built-ins, such as Object.prototype and Array.prototype, can lead to debugging issues in production and must be avoided.

    -

    For example, the methods in prototypes of built-in objects are shared by every instance of the built-in objects. If the method are modified, it affects every instances of the built-in objects.

    +

    For example, the functions in prototypes of built-in objects are shared by every instance of the built-in objects. If the function is modified, it affects every instances of the built-in objects.

    This rule is introduced by the Google Javascript Style Guide. They say that "Modifying builtins like Object.prototype and Array.prototype are strictly forbidden. It leads to hard to debug issues in production and should be avoided."

    @@ -306,8 +306,8 @@ for (var key in arr) {

    Rule 11. Do Not Use Unclosed Braces

    -

    A method, an object, a code block, or a similar element which has an opening brace but no closing brace is not correct. The analysis detects this and stops with an error message.

    -

    In the following example, the temp() method needs a closing brace to indicate that the method definition is finished. The JSA detects this and creates an alarm, and the analysis is stopped because of the error.

    +

    A function, an object, a code block, or a similar element which has an opening brace but no closing brace is not correct. The analysis detects this and stops with an error message.

    +

    In the following example, the temp() function needs a closing brace to indicate that the function definition is finished. The JSA detects this and creates an alarm, and the analysis is stopped because of the error.

     /* The temp function needs the closing brace */
    @@ -319,7 +319,7 @@ function temp() {
     
     

    Rule 12. Do Not Use Unclosed Comments

    -

    Writing comment with only the begin comment and no closing comment is not correct. In some scenarios, it affects the implementation of the method or code block. The analysis detects this and stops with an error message.

    +

    Writing comment with only the begin comment and no closing comment is not correct. In some scenarios, it affects the implementation of the function or code block. The analysis detects this and stops with an error message.

    In the following example, the comment has no closing comment, and the for loop cannot be completed. The JSA detects it and creates an alarm, and the analysis is stopped because of the error.

    @@ -446,7 +446,7 @@ var alarm = tizen.alarm.gett(abs_alarm.id);

    Rule 2. Wrong Argument Number

    -

    Invoking a method with a wrong argument number is notified as an WebAPIError and the analysis proceeded.

    +

    Invoking a function with a wrong argument number is notified as an WebAPIError and the analysis proceeded.

    In the following example, the tizen.filesystem.resolve() function needs more than 1 argument. Since the number of arguments is 1, the JSA detects it and creates an alarm.

    @@ -460,9 +460,9 @@ tizen.filesystem.resolve('images'

    Rule 3. Missing Error Handling

    -

    Invoking an asynchronous method without an error callback is notified as an WebAPIError and the analysis proceeded.

    +

    Invoking an asynchronous function without an error callback is notified as an WebAPIError and the analysis proceeded.

    -

    In the following example, the tizen.filesystem.resolve() function needs an error callback function as its third argument. Because the error callback function does not exist, the JSA detects it and creates an alarm.

    +

    In the following example, the tizen.filesystem.resolve() function needs an error callback as its third argument. Because the error callback does not exist, the JSA detects it and creates an alarm.

    tizen.filesystem.resolve('images',
                              function(dir) {
    @@ -473,13 +473,13 @@ tizen.filesystem.resolve('images'
     
     

    The JSA displays the following message:

    -
    [Web API Rule] Call to tizen.filesystem.resolve is missing an error callback function; provide an error callback function.
    +
    [Web API Rule] Call to tizen.filesystem.resolve is missing an error callback; provide an error callback.

    Rule 4. Missing Exception Handling

    Invoking an API, which can throw an exception without the try-catch clause is notified as an WebAPIError and the analysis proceeded.

    -

    In the following example, the tizen.calendar.getCalendars() is a method that can throw exceptions, so it must be wrapped by a try-catch statement. Because the try-catch statement does not exist, the JSA detects it and creates an alarm.

    +

    In the following example, the tizen.calendar.getCalendars() is a function that can throw exceptions, so it must be wrapped by a try-catch statement. Because the try-catch statement does not exist, the JSA detects it and creates an alarm.

    /* tizen.calendar.getCalendars API can make exceptions, so it should be wrapped in a try-catch statement */
     tizen.calendar.getCalendars('EVENT', calendarListCallback, errorCallback);
    @@ -537,7 +537,7 @@ var invalidContactObj = new tizen.Contact(

    Invoking an API which is not defined in the current API version is noticed, although the analysis proceeds without stopping. If the Web API was defined in another API version or platform, the version name is provided in the error message.

    -

    In the following example, the Web App is developed for the Tizen 2.3 wearable platform, but the tizen.archive.open() method is defined in for the Tizen 2.3 mobile platform, so the JSA detects it and creates an alarm.

    +

    In the following example, the Web App is developed for the Tizen 2.3 wearable platform, but the tizen.archive.open() function is defined in for the Tizen 2.3 mobile platform, so the JSA detects it and creates an alarm.

     function onsuccess() { /* ... */ }
    @@ -560,7 +560,7 @@ try {
     
     

    To use a privileged Tizen Device API in a target device, the config.xml file of the Tizen Web application must have a corresponding privilege URL defined. An alarm is raised if the privilege is not found in the config.xml file.

    -

    In the following example, the Web application is using the tizen.application.launch() method, which requires the http://tizen.org/privilege/application.launch privilege, which is commented in the config.xml file. So an alarm is raised.

    +

    In the following example, the Web application is using the tizen.application.launch() function, which requires the http://tizen.org/privilege/application.launch privilege, which is commented in the config.xml file. So an alarm is raised.

    @@ -597,7 +597,7 @@ tizen.application.launch('targetApp0.main', onsuccess);
     
     

    Result Page View

    -

    The result page opens with the view shown in the following figure. The page is composed of 2 parts: issue table and all-sites timeline. You can switch between the parts using the menu at the top of the page.

    +

    The result page appears with the view shown in the following figure. The page is composed of 2 parts: issue table and all-sites timeline. You can switch between the parts using the menu at the top of the page.

    Figure: Result page with the issue table

    Result page with the issue table

    @@ -621,9 +621,9 @@ tizen.application.launch('targetApp0.main', onsuccess);

    In the above figure:

    • The anonymous event handler function at the line 10 is identified as a stale object that can cause a memory leak.
    • -
    • In the call tree view, a call hierarchy is shown for the method which contains the code that creates stale objects. The name of a node in the call tree view indicates the file name, line number, and column number. +
    • In the call tree view, a call hierarchy is shown for the function which contains the code that creates stale objects. The name of a node in the call tree view indicates the file name, line number, and column number.

      The "js/main_orig_.js:10:45" root element indicates that the memory leak occurs at line 10, column 45 in the js/main_orig_.js file.

      -

      Click the root element to move the source view to the location. Click the "js/main_orig_.js:27:5" child node to move the source view to line 27 where the method that contains the memory leak issue is called, and to highlight the method.

    • +

      Click the root element to move the source view to the location. Click the "js/main_orig_.js:27:5" child node to move the source view to line 27 where the function that contains the memory leak issue is called, and to highlight the function.

    • In the timeline view, the x axis represents the time elapse and the y axis represents the number of created objects from this site. Move the mouse to a specific time to show the number of stale and allocated instances on the graph.
    • In the access paths view, you can find out the scope of an object at runtime which leads to the location of the memory leak.
    diff --git a/org.tizen.devtools/html/web_tools/js_editor_w.htm b/org.tizen.devtools/html/web_tools/js_editor_w.htm index e426143..a95b5b3 100644 --- a/org.tizen.devtools/html/web_tools/js_editor_w.htm +++ b/org.tizen.devtools/html/web_tools/js_editor_w.htm @@ -41,8 +41,8 @@

    Checking JavaScript

    You can check JavaScript for the following:

      -
    • Syntax, using JSLint
    • -
    • Preferences for JSLint options
    • +
    • Syntax, using JSHint
    • +
    • Preferences for JSHint options

    You can check JavaScript in the following ways:

    @@ -214,9 +214,9 @@ uid(root, app) is applied to directories and files.

    -

    1 The {PackageId} is the package ID, such as org.tizen.browser.
    -2 {Random} means that there is a 28-byte random string created by the smack module.
    -3 {Cert Hash} refers to a 28-byte string where [Raw Hash] equals to Base64Encode (SHA1 author certificate in author-signature.xml) and {Cert Hash} replaces "/" with "#" in [Raw Hash].

    +

    1 The {PackageId} is the package ID, such as org.tizen.browser.

    +

    2 {Random} means that there is a 28-byte random string created by the smack module.

    +

    3 {Cert Hash} refers to a 28-byte string where [Raw Hash] equals to Base64Encode (SHA1 author certificate in author-signature.xml) and {Cert Hash} replaces "/" with "#" in [Raw Hash].

    Application Manifest

    diff --git a/org.tizen.gettingstarted/html/native/cover_page_n.htm b/org.tizen.gettingstarted/html/native/cover_page_n.htm index 7cde62a..3b428cc 100644 --- a/org.tizen.gettingstarted/html/native/cover_page_n.htm +++ b/org.tizen.gettingstarted/html/native/cover_page_n.htm @@ -31,15 +31,27 @@
    @@ -273,7 +270,7 @@ app_control_destroy(app_control);

    Getting the App Control Results

    -

    The app control result from the requested application is delivered to the caller application in the app_control handle with extra data. For some cases, the App Control API provides pre-defined extra data keys.

    +

    The app control result from the requested application is delivered to the caller application in the app_control handle with extra data. For some cases, the App Control API provides predefined extra data keys.

    If you cannot find a proper key, you can define your own key. However, the customized key must be shared between the caller and callee applications.

    The following code example gets the result of an app control request by implementing an app_control result callback:

    @@ -281,30 +278,23 @@ app_control_destroy(app_control);
     #include <app.h>
     #include <dlog.h>
    - 
    +
     #define TAG "MY_TAG"
    - 
    -// Callback function to get result
    -static void app_control_result(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) 
    +
    +/* Callback function to get result */
    +static void
    +app_control_result(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
     {
    -   char *value;
    - 
    -   if (result == APP_CONTROL_RESULT_SUCCEEDED) 
    -   {
    -      if (app_control_get_extra_data(reply, APP_CONTROL_DATA_SELECTED, &value) == APP_CONTROL_ERROR_NONE)
    -      {
    -         dlog_print(DLOG_INFO, TAG, "[app_control_result_cb] Succeeded: value(%s)", value);
    -      } 
    -      else 
    -      {
    -         dlog_print(DLOG_ERROR, TAG, "[app_control_result_cb] Failed");
    -      }
    - 
    -   } 
    -   else 
    -   {
    -      dlog_print(DLOG_ERROR, TAG, "[app_control_result_cb] APP_CONTROL_RESULT_FAILED.");
    -   }
    +    char *value;
    +
    +    if (result == APP_CONTROL_RESULT_SUCCEEDED) {
    +        if (app_control_get_extra_data(reply, APP_CONTROL_DATA_SELECTED, &value) == APP_CONTROL_ERROR_NONE)
    +            dlog_print(DLOG_INFO, TAG, "[app_control_result_cb] Succeeded: value(%s)", value);
    +        else
    +            dlog_print(DLOG_ERROR, TAG, "[app_control_result_cb] Failed");
    +    } else {
    +        dlog_print(DLOG_ERROR, TAG, "[app_control_result_cb] APP_CONTROL_RESULT_FAILED.");
    +    }
     }
     
    @@ -317,52 +307,46 @@ static void app_control_result(app_control_h request, app_control_h reply, app_c #define TAG "MY_TAG" app_control_h app_control; - + app_control_create(&app_control); - + app_control_set_operation(app_control, APP_CONTROL_OPERATION_CREATE_CONTENT); app_control_set_mime(app_control, "text/plain"); - -if (app_control_send_launch_request(app_control, app_control_result, NULL) == APP_CONTROL_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, TAG, "Succeeded: the application is launched."); -} -else -{ -   dlog_print(DLOG_ERROR, TAG, "Failed to launch an application."); -} - + +if (app_control_send_launch_request(app_control, app_control_result, NULL) == APP_CONTROL_ERROR_NONE) +    dlog_print(DLOG_INFO, TAG, "Succeeded: the application is launched."); +else +    dlog_print(DLOG_ERROR, TAG, "Failed to launch an application."); + app_control_destroy(app_control);

    The following code example implements an app_control callback in the callee application:

    -static void app_control(app_control_h app_control, void *user_data) 
    +static void app_control(app_control_h app_control, void *user_data)
     {
    -   struct appdata *ad = (struct appdata *)user_data;
    -   char *operation;
    -   char *mime;
    -   app_control_h reply;
    -   char *app_id;
    - 
    -   app_control_get_operation(app_control, &operation);
    - 
    -   if (!strcmp(operation, APP_CONTROL_OPERATION_CREATE_CONTENT)) 
    -   {
    -      app_control_get_mime(app_control, &mime);
    - 
    -      if (!strcmp(mime, "text/plain")) 
    -      {
    -         app_control_create(&reply);
    - 
    -         app_get_app_id(&app_id);
    -         app_control_add_extra_data(reply, APP_CONTROL_DATA_SELECTED, app_id);
    -         app_control_reply_to_launch_request(reply, app_control, APP_CONTROL_RESULT_SUCCEEDED);
    - 
    -         app_control_destroy(reply);
    -      }
    -   }
    +    struct appdata *ad = (struct appdata *)user_data;
    +    char *operation;
    +    char *mime;
    +    app_control_h reply;
    +    char *app_id;
    +
    +    app_control_get_operation(app_control, &operation);
    +
    +    if (!strcmp(operation, APP_CONTROL_OPERATION_CREATE_CONTENT)) {
    +        app_control_get_mime(app_control, &mime);
    +
    +        if (!strcmp(mime, "text/plain")) {
    +            app_control_create(&reply);
    +
    +            app_get_app_id(&app_id);
    +            app_control_add_extra_data(reply, APP_CONTROL_DATA_SELECTED, app_id);
    +            app_control_reply_to_launch_request(reply, app_control, APP_CONTROL_RESULT_SUCCEEDED);
    +
    +            app_control_destroy(reply);
    +        }
    +    }
     }
     
    @@ -503,6 +487,9 @@ static void app_control(app_control_h app_control, void *user_data) + @@ -548,6 +535,9 @@ static void app_control(app_control_h app_control, void *user_data)
  • Result (the reason for the failure is marked in bold):
  • + Table: Scenario when only the operation is provided +
    Filter ID
    + @@ -621,6 +611,9 @@ static void app_control(app_control_h app_control, void *user_data)
  • Result (the reason for the failure is marked in bold):
  • + Table: Scenario when the operation and URI are provided +
    Filter ID
    + @@ -694,6 +687,9 @@ static void app_control(app_control_h app_control, void *user_data)
  • Result (the reason for the failure is marked in bold):
  • + Table: Scenario when the operation and MIME type are provided +
    Filter ID
    + diff --git a/org.tizen.guides/html/native/app/application_n.htm b/org.tizen.guides/html/native/app/application_n.htm index dbce0af..4852b93 100644 --- a/org.tizen.guides/html/native/app/application_n.htm +++ b/org.tizen.guides/html/native/app/application_n.htm @@ -55,9 +55,13 @@
  • Launch applications with the App Control API
  • Localize application strings with the Internationalization API
  • Broadcast and subscribe to events with the Event API (in mobile applications only)
  • -
  • Manage application preferences
  • +
  • Set and get common resources for multiple devices with the Resource Manager API (in mobile applications only)
  • +
  • Manage application preferences with the Preference API
  • + +

    Before you start, remember to prepare your application to use the application functionality.

    +

    Managing the Event Loop

    In order for an application to operate successfully, it must receive events from the platform. For this, it must start the main event loop - this is mandatory for all Tizen native applications.

    The ui_app_main() function is used to start the event loop. Before calling this function, set up the app_event_callback_s structure variable, which is passed to the function.

    @@ -264,7 +268,7 @@       <background-category value="download"/>       <background-category value="background-network"/>    </ui-application> -   <service-application appid="org.tizen.test-service" exec="test-service" multiple="false" type="capp"/> +   <service-application appid="org.tizen.test-service" exec="test-service" multiple="false" type="capp">       <background-category value="background-network"/>       <background-category value="location"/>    </service-application> @@ -291,7 +295,7 @@       <metadata key="http://tizen.org/metadata/background-category/download"/>       <metadata key="http://tizen.org/metadata/background-category/background-network"/>    </ui-application> -   <service-application appid="org.tizen.test-service" exec="test-service" multiple="false" type="capp"/> +   <service-application appid="org.tizen.test-service" exec="test-service" multiple="false" type="capp">       <metadata key="http://tizen.org/metadata/background-category/background-network"/>       <metadata key="http://tizen.org/metadata/background-category/location"/>    </service-application> diff --git a/org.tizen.guides/html/native/app/attach_panel_n.htm b/org.tizen.guides/html/native/app/attach_panel_n.htm index 2b3c32b..44f0b0c 100644 --- a/org.tizen.guides/html/native/app/attach_panel_n.htm +++ b/org.tizen.guides/html/native/app/attach_panel_n.htm @@ -20,6 +20,7 @@
    +

    Related Info

    • Attach panel Tutorial
    • @@ -35,31 +36,42 @@

      This feature is supported in mobile applications only.

      -

      The following figures illustrate the attach panel architecture on the outside and inside.

      - -

      Figure: Attach panel outside architecture

      -

      Attach panel outside architecture

      - -

      The attach panel is a library for Tizen mobile applications. It is developed mainly by UIFW (EFL), but it also uses information from middleware libraries, such as AppFW and MMFW.

      - -

      Figure: Attach panel inside architecture

      -

      Attach panel inside architecture

      +

      Figure: Attach panel

      +

      Attach panel

      -

      The attach panel has UI components and manages user interactions on its interface. The layout component keeps on the tabbar and scroller components, which are connected to show the content synchronously. The scroller component has pages to display the content of, for example, images, camera, and voice recorder. Some UI components are shown on the panel by using a UI gadget, while others can be launched from the panel's More tab by application controls.

      +

      You can create an attach panel to allow the user to attach some files, and you can manage the attach panel.

      +

      The attach panel has UI components and it manages user interactions on its interface. The layout component keeps on the tabbar and scroller components, which are connected to show the content synchronously. The scroller component has pages to display the content of, for example, images, camera, and voice recorder. Some content is shown as a page on the panel, while others can be launched from the panel's More tab using application controls.

      -

      The attach panel has 2 main operation sequences:

      +

      The attach panel has half and full modes. The mode can be changed by swiping up and down the page. When the user adds files in the full mode, attach panel is hidden automatically. In the half mode, the user can add multiple files at a time.

      +

      Figure: Attach panel modes

      +

      Attach panel modes

      -
      • The caller application requests the attach panel to show the main content. The panel creates a UI gadget to show it, the user selects some content to attach, and the results are returned to the caller application. -

        Figure: Showing content with a UI gadget

        -

        Showing content with a UI gadget

        +

        You can manage the following types of content:

        +
          +
        • Images +

          For image content, the Attach panel API requires the http://tizen.org/privilege/mediastorage privilege. In the half mode, you can select only 1 image to be attached. In the full mode, you can select multiple images at once.

          +

          Figure: Images content

          +

          Images content

        • - -
        • The caller application requests the attach panel to show content. The panel launches a related application to show it, the user selects some content to attach, and the results are returned to the caller application. -

          Figure: Showing content with a related application

          -

          Showing content with a related application

          +
        • Camera +

          For camera content, the Attach panel API requires the http://tizen.org/privilege/mediastorage and http://tizen.org/privilege/camera privileges.

          +

          Figure: Camera content

          +

          Camera content

          +
        • +
        • Voice +

          For voice recorder content, the Attach panel API requires the http://tizen.org/privilege/recorder privilege.

          +

          Figure: Voice content

          +

          Voice content

          +
        • +
        • More tab +

          For the More tab, the Attach panel API requires the http://tizen.org/privilege/appmanager.launch privilege. The More tab shows the icons of the applications, for example, video, audio, calendar, contact, myfiles, and video recorder, that can be launched by clicking the applicable icon.

          +

          Figure: More content

          +

          More content

        +

        Before you start, remember to prepare your application to use the attach panel functionality.

        +
    diff --git a/org.tizen.guides/html/native/app/badge_n.htm b/org.tizen.guides/html/native/app/badge_n.htm index d565aff..de47ab9 100644 --- a/org.tizen.guides/html/native/app/badge_n.htm +++ b/org.tizen.guides/html/native/app/badge_n.htm @@ -32,14 +32,16 @@

    Badge

    -

    You can use badges in your application to inform the user about notifications and events. A badge is an image displayed on the application icon.

    +

    You can use badges in your application to inform the user about notifications and events. A badge is an image displayed on the application icon.

    -

    To create a badge, use the badge_add() method. The application that creates the badge can also update and remove it. When applications are signed with the same certificate, they can control each other's badges.

    -

    If an application not signed with the same certificate must be allowed manage a badge, use the badge_add() method with a writable application ID. The writable application ID enables another application to control your application to manage the badge. You can also configure your application to handle the badge itself.

    +

    To create a badge, use the badge_add() function. The application that creates the badge can also update and remove it. When applications are signed with the same certificate, they can control each other's badges.

    +

    If an application not signed with the same certificate must be allowed manage a badge, use the badge_add() function with a writable application ID. The writable application ID enables another application to control your application to manage the badge. You can also configure your application to handle the badge itself.

    Figure: Badge

    Badge

    + +

    Before you start, remember to prepare your application to use the badge functionality.

    diff --git a/org.tizen.guides/html/native/app/bundle_n.htm b/org.tizen.guides/html/native/app/bundle_n.htm index da36afe..b89f0e2 100644 --- a/org.tizen.guides/html/native/app/bundle_n.htm +++ b/org.tizen.guides/html/native/app/bundle_n.htm @@ -36,14 +36,14 @@

    A dictionary is an ordered or unordered list of key-value pairs, where keys are used to locate elements in the list. The key is always a string.

    The main features of the Bundle API include:

    -
    • Creating a bundle using the bundle_create() function.
    • -
    • Adding content to a bundle using the bundle_add_str(), bundle_add_str_array(), or bundle_add_byte() function.
    • +

      When no longer needed, release the bundle by calling the bundle_free() function.

      diff --git a/org.tizen.guides/html/native/app/common_appcontrol_n.htm b/org.tizen.guides/html/native/app/common_appcontrol_n.htm index 4869c19..c68f50f 100755 --- a/org.tizen.guides/html/native/app/common_appcontrol_n.htm +++ b/org.tizen.guides/html/native/app/common_appcontrol_n.htm @@ -97,7 +97,7 @@ app_control_destroy(app_control);

      Loading a Web Page

      -

      To open a web page, use the APP_CONTROL_OPERATION_VIEW operation and specify the Web URL in the URI.

      +

      To open a Web page, use the APP_CONTROL_OPERATION_VIEW operation and specify the Web URL in the URI.

      Figure: Loading a Web page

      Loading a Web page

      @@ -325,7 +325,7 @@ app_control_send_launch_request(service, NULL, NULL);
    + Table: Scenario when the operation, URI, and MIME type are provided +
    Filter ID

    Example Code

    -// To view a calendar event from a vcs file
    +/* To view a calendar event from a vcs file */
     app_control_h service;
     app_control_create(&service);
     
    @@ -336,7 +336,7 @@ app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP);
     app_control_send_launch_request(service, NULL, NULL);
     app_control_destroy(service);
     
    -// To view a calendar event from a calendar event ID
    +/* To view a calendar event from a calendar event ID */
     app_control_h service;
     app_control_create(&service);
     
    @@ -431,17 +431,17 @@ app_control_send_launch_request(service, NULL, NULL);
     	

    For example: tel:+821234567890

    Example Code

    -void 
    +void
     launchCall()
     {
    -   app_control_h request = NULL;
    -   app_control_create(&request);
    +    app_control_h request = NULL;
    +    app_control_create(&request);
     
    -   app_control_set_operation(request, APP_CONTROL_OPERATION_CALL);
    -   app_control_set_uri(request, "tel:0123456789");
    +    app_control_set_operation(request, APP_CONTROL_OPERATION_CALL);
    +    app_control_set_uri(request, "tel:0123456789");
     
    -   app_control_send_launch_request(request, NULL, NULL);
    -   app_control_destroy(request);
    +    app_control_send_launch_request(request, NULL, NULL);
    +    app_control_destroy(request);
     }
     
    @@ -461,17 +461,17 @@ launchCall()

    For example: tel:+821234567890

    Example Code

    -void 
    +void
     launchCall()
     {
    -   app_control_h request = NULL;
    -   app_control_create(&request);
    +    app_control_h request = NULL;
    +    app_control_create(&request);
     
    -   app_control_set_operation(request, APP_CONTROL_OPERATION_DIAL);
    -   app_control_set_uri(request, "tel:0123456789");
    +    app_control_set_operation(request, APP_CONTROL_OPERATION_DIAL);
    +    app_control_set_uri(request, "tel:0123456789");
     
    -   app_control_send_launch_request(request, NULL, NULL);
    -   app_control_destroy(request);
    +    app_control_send_launch_request(request, NULL, NULL);
    +    app_control_destroy(request);
     }
     
    @@ -765,7 +765,7 @@ app_control_set_operation(request, APP_CONTROL_OPERATION_EDIT); app_control_set_mime(request, "application/vnd.tizen.contact"); app_control_add_extra_data(request, APP_CONTROL_DATA_ID, personId); - + app_control_add_extra_data(request, APP_CONTROL_DATA_PHONE, "0987654321"); app_control_add_extra_data(request, APP_CONTROL_DATA_EMAIL, "2nd Email"); @@ -814,40 +814,40 @@ app_control_destroy(request);

    Example Code

    -int 
    +int
     launchContactDetails(const char* personId)
     {
    -   app_control_h request;
    -   app_control_create(&request);
    +    app_control_h request;
    +    app_control_create(&request);
     
    -   app_control_set_operation(request, APP_CONTROL_OPERATION_VIEW);
    -   app_control_set_mime(request, "application/vnd.tizen.contact");
    -   app_control_add_extra_data(request, APP_CONTROL_DATA_ID, personId);
    +    app_control_set_operation(request, APP_CONTROL_OPERATION_VIEW);
    +    app_control_set_mime(request, "application/vnd.tizen.contact");
    +    app_control_add_extra_data(request, APP_CONTROL_DATA_ID, personId);
     
    -   app_control_set_launch_mode(request, APP_CONTROL_LAUNCH_MODE_GROUP);
    +    app_control_set_launch_mode(request, APP_CONTROL_LAUNCH_MODE_GROUP);
     
    -   int result = app_control_send_launch_request(request, NULL, NULL);
    -   app_control_destroy(request);
    +    int result = app_control_send_launch_request(request, NULL, NULL);
    +    app_control_destroy(request);
     
    -   return result;
    +    return result;
     }
     
    -int 
    +int
     launchViewVcard(const char *uri)
     {
    -   app_control_h request;
    -   app_control_create(&request);
    +    app_control_h request;
    +    app_control_create(&request);
     
    -   app_control_set_operation(request, APP_CONTROL_OPERATION_VIEW);
    -   app_control_set_mime(request, "text/vcard");
    -   app_control_set_uri(request, uri);
    +    app_control_set_operation(request, APP_CONTROL_OPERATION_VIEW);
    +    app_control_set_mime(request, "text/vcard");
    +    app_control_set_uri(request, uri);
     
    -   app_control_set_launch_mode(request, APP_CONTROL_LAUNCH_MODE_GROUP);
    +    app_control_set_launch_mode(request, APP_CONTROL_LAUNCH_MODE_GROUP);
     
    -   int result = app_control_send_launch_request(request, NULL, NULL);
    -   app_control_destroy(request);
    +    int result = app_control_send_launch_request(request, NULL, NULL);
    +    app_control_destroy(request);
     
    -   return result;
    +    return result;
     }
     
    @@ -914,23 +914,23 @@ launchViewVcard(const char *uri)

    Example Code

    -int 
    +int
     launchContactPick(const char *selectionMode, const char *resultType,
                       app_control_reply_cb replyCallback, void *userData)
     {
    -   app_control_h request;
    -   app_control_create(&request);
    +    app_control_h request;
    +    app_control_create(&request);
     
    -   app_control_set_operation(request, APP_CONTROL_OPERATION_PICK);
    -   app_control_set_mime(request, "application/vnd.tizen.contact");
    +    app_control_set_operation(request, APP_CONTROL_OPERATION_PICK);
    +    app_control_set_mime(request, "application/vnd.tizen.contact");
     
    -   app_control_add_extra_data(request, APP_CONTROL_DATA_SELECTION_MODE, selectionMode);
    -   app_control_add_extra_data(request, APP_CONTROL_DATA_TYPE, resultType);
    +    app_control_add_extra_data(request, APP_CONTROL_DATA_SELECTION_MODE, selectionMode);
    +    app_control_add_extra_data(request, APP_CONTROL_DATA_TYPE, resultType);
     
    -   int result = app_control_send_launch_request(request, replyCallback, userData);
    -   app_control_destroy(request);
    +    int result = app_control_send_launch_request(request, replyCallback, userData);
    +    app_control_destroy(request);
     
    -   return result;
    +    return result;
     }
     
    @@ -1008,7 +1008,7 @@ app_control_destroy(service);

    Example Code

     #include <app_control.h>
    -char* contacts[3] = {contact1, contact2, contact3}; // contact1, contact2, contact3 are person IDs
    +char* contacts[3] = {contact1, contact2, contact3}; /* contact1, contact2, contact3 are person IDs */
     
     app_control_h service;
     app_control_create(&service);
    @@ -1385,41 +1385,37 @@ app_control_destroy(app_control);
     #include <app_control.h>
     #include <dlog.h>
     
    -int 
    +int
     show_maps_operation(void)
     {
    -   int ret = 0;
    -
    -   app_control_h service = NULL;
    -   app_control_create(&service);
    -   
    -   if (service == NULL)
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
    -
    -      return -1;
    -   }
    -   
    -   app_control_set_operation(service, APP_CONTROL_OPERATION_VIEW);
    -   app_control_set_uri(service, "geo:50.1,-50.1"); 
    -  
    -   ret = app_control_send_launch_request(service, NULL, NULL);
    -   app_control_destroy(service);
    -   
    -   if (ret == APP_CONTROL_ERROR_NONE)
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to request!\n");
    -	  
    -      return 0;
    -   }
    -   else
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to request!\n");
    -	  
    -      return -1;
    -   }
    -
    -   return 0;
    +    int ret = 0;
    +
    +    app_control_h service = NULL;
    +    app_control_create(&service);
    +
    +    if (service == NULL) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
    +
    +        return -1;
    +    }
    +
    +    app_control_set_operation(service, APP_CONTROL_OPERATION_VIEW);
    +    app_control_set_uri(service, "geo:50.1,-50.1");
    +
    +    ret = app_control_send_launch_request(service, NULL, NULL);
    +    app_control_destroy(service);
    +
    +    if (ret == APP_CONTROL_ERROR_NONE) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to request!\n");
    +
    +        return 0;
    +    } else {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to request!\n");
    +
    +        return -1;
    +    }
    +
    +    return 0;
     }
     
    @@ -1477,48 +1473,46 @@ show_maps_operation(void) #include <app_control.h> #include <dlog.h> -int +int pick_location_operation(void) { -   int ret = 0; - -   app_control_h service = NULL; -   app_control_create(&service); - -   if (service == NULL) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler"); - -      return -1; -   } - -   app_control_set_operation(service, APP_CONTROL_OPERATION_PICK); -   app_control_set_uri(service, "geo:0,0?q=Eiffel Tower"); -   app_control_add_extra_data(service, APP_CONTROL_DATA_TYPE, "poi"); - -   app_control_send_launch_request(service, pick_reply_cb, NULL); -   app_control_destroy(service); - -   return 0; +    int ret = 0; + +    app_control_h service = NULL; +    app_control_create(&service); + +    if (service == NULL) { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler"); + +        return -1; +    } + +    app_control_set_operation(service, APP_CONTROL_OPERATION_PICK); +    app_control_set_uri(service, "geo:0,0?q=Eiffel Tower"); +    app_control_add_extra_data(service, APP_CONTROL_DATA_TYPE, "poi"); + +    app_control_send_launch_request(service, pick_reply_cb, NULL); +    app_control_destroy(service); + +    return 0; } -void +void pick_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) { -   char *address = NULL; -   char *path = NULL; +    char *address = NULL; +    char *path = NULL; -   if (result == APP_CONTROL_RESULT_SUCCEEDED) -   { -      app_control_get_extra_data(reply, APP_CONTROL_DATA_SELECTED, &address); -      app_control_get_extra_data(reply, APP_CONTROL_DATA_PATH, &path); +    if (result == APP_CONTROL_RESULT_SUCCEEDED) { +        app_control_get_extra_data(reply, APP_CONTROL_DATA_SELECTED, &address); +        app_control_get_extra_data(reply, APP_CONTROL_DATA_PATH, &path); -      dlog_print(DLOG_INFO, LOG_TAG, "Selected address: %s", address); -      dlog_print(DLOG_INFO, LOG_TAG, "Map image path: %s", path); +        dlog_print(DLOG_INFO, LOG_TAG, "Selected address: %s", address); +        dlog_print(DLOG_INFO, LOG_TAG, "Map image path: %s", path); -      free(address); -      free(path); -   } +        free(address); +        free(path); +    } }
    @@ -1576,9 +1570,9 @@ app_control_h service; app_control_create(&service); app_control_set_operation(service, APP_CONTROL_OPERATION_COMPOSE); -app_control_set_uri(service, "mmsto:1234567890"); +app_control_set_uri(service, "mmsto:1234567890"); app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); -app_control_add_extra_data(service ,APP_CONTROL_DATA_TEXT, "My text"); +app_control_add_extra_data(service, APP_CONTROL_DATA_TEXT, "My text"); app_control_add_extra_data(service, APP_CONTROL_DATA_SUBJECT, "My subject"); app_control_send_launch_request(service, NULL, NULL); @@ -1686,7 +1680,7 @@ app_control_send_launch_request(service, NULL, NULL);

    Sharing Text in a Message

    -

    To share any text with an SMS or MSM message, use the APP_CONTROL_OPERATION_SHARE_TEXT operation.

    +

    To share any text with an SMS or MMS message, use the APP_CONTROL_OPERATION_SHARE_TEXT operation.

    Figure: Sharing text

    Sharing text

    @@ -1777,41 +1771,37 @@ app_control_send_launch_request(service, NULL, NULL); #include <app_control.h> #include <dlog.h> -int +int play_audio_operation(const char* audio_uri) { -   int ret = 0; +    int ret = 0; -   app_control_h service = NULL; -   app_control_create(&service); +    app_control_h service = NULL; +    app_control_create(&service); -   if (service == NULL) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler\n"); +    if (service == NULL) { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler\n"); -      return -1; -   } +        return -1; +    } -   app_control_set_operation(service, APP_CONTROL_OPERATION_VIEW); -   app_control_set_uri(service, audio_uri); +    app_control_set_operation(service, APP_CONTROL_OPERATION_VIEW); +    app_control_set_uri(service, audio_uri); -   ret = app_control_send_launch_request(service, NULL, NULL); -   app_control_destroy(service); +    ret = app_control_send_launch_request(service, NULL, NULL); +    app_control_destroy(service); -   if (ret == APP_CONTROL_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to request!\n"); +    if (ret == APP_CONTROL_ERROR_NONE) { +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to request!\n"); -      return 0; -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to request!\n"); +        return 0; +    } else { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to request!\n"); -      return -1; -   } +        return -1; +    } -   return 0; +    return 0; }
    @@ -1839,41 +1829,37 @@ play_audio_operation(const char* audio_uri) #include <app_control.h>> #include <dlog.h> -int +int view_image_operation(const char* image_uri) { -   int ret = 0; +    int ret = 0; -   app_control_h service = NULL; -   app_control_create(&service); +    app_control_h service = NULL; +    app_control_create(&service); -   if (service == NULL) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler\n"); +    if (service == NULL) { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler\n"); -      return -1; -   } +        return -1; +    } -   app_control_set_operation(service, APP_CONTROL_OPERATION_VIEW); -   app_control_set_uri(service, image_uri); +    app_control_set_operation(service, APP_CONTROL_OPERATION_VIEW); +    app_control_set_uri(service, image_uri); -   ret = app_control_send_launch_request(service, NULL, NULL); -   app_control_destroy(service); +    ret = app_control_send_launch_request(service, NULL, NULL); +    app_control_destroy(service); -   if (ret == APP_CONTROL_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to request!\n"); +    if (ret == APP_CONTROL_ERROR_NONE) { +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to request!\n"); -      return 0; -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to request!\n"); +        return 0; +    } else { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to request!\n"); -      return -1; -   } +        return -1; +    } -   return 0; +    return 0; } @@ -1936,41 +1922,37 @@ view_image_operation(const char* image_uri) #include <app_control.h> #include <dlog.h> -int +int retrieve_media_operation(const char* mime_type) { -   int ret = 0; +    int ret = 0; -   app_control_h service = NULL; -   app_control_create(&service); +    app_control_h service = NULL; +    app_control_create(&service); -   if (service == NULL) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler\n"); +    if (service == NULL) { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler\n"); -      return -1; -   } +        return -1; +    } -   app_control_set_operation(service, APP_CONTROL_OPERATION_PICK); -   app_control_set_mime(service, mime_type); +    app_control_set_operation(service, APP_CONTROL_OPERATION_PICK); +    app_control_set_mime(service, mime_type); -   ret = app_control_send_launch_request(service, NULL, NULL); -   app_control_destroy(service); +    ret = app_control_send_launch_request(service, NULL, NULL); +    app_control_destroy(service); -   if (ret == APP_CONTROL_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to request!\n"); +    if (ret == APP_CONTROL_ERROR_NONE) { +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to request!\n"); -      return 0; -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to request!\n"); +        return 0; +    } else { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to request!\n"); -      return -1; -   } +        return -1; +    } -   return 0; +    return 0; } @@ -1989,39 +1971,35 @@ retrieve_media_operation(const char* mime_type)

    Example Code

    -int 
    +int
     launch_setting(void)
     {
    -   int ret = 0;
    -   app_control_h service = NULL;
    -   app_control_create(&service);
    - 
    -   if (service == NULL) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
    +    int ret = 0;
    +    app_control_h service = NULL;
    +    app_control_create(&service);
     
    -      return -1;
    -   }
    - 
    -   app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING);
    +    if (service == NULL) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
     
    -   ret = app_control_send_launch_request(service, NULL, NULL);
    -   app_control_destroy(service);
    - 
    -   if (ret == APP_CONTROL_ERROR_NONE) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch settings!\n");
    +        return -1;
    +    }
    +
    +    app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING);
    +
    +    ret = app_control_send_launch_request(service, NULL, NULL);
    +    app_control_destroy(service);
     
    -      return 0;
    -   } 
    -   else 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch settings!\\n");
    +    if (ret == APP_CONTROL_ERROR_NONE) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch settings!\n");
     
    -      return -1;
    -   }
    +        return 0;
    +    } else {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch settings!\n");
     
    -   return 0;
    +        return -1;
    +    }
    +
    +    return 0;
     }
     
    @@ -2042,40 +2020,36 @@ launch_setting(void)

    Example Code

     #include <app_control.h>
    - 
    -int 
    +
    +int
     bt_enable_operation(void)
     {
    -   int ret = 0;
    -   app_control_h service = NULL;
    -   app_control_create(&service);
    - 
    -   if (service == NULL) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
    +    int ret = 0;
    +    app_control_h service = NULL;
    +    app_control_create(&service);
     
    -      return -1;
    -   }
    - 
    -   app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_BT_ENABLE);
    +    if (service == NULL) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
     
    -   ret = app_control_send_launch_request(service, NULL, NULL);
    -   app_control_destroy(service);
    - 
    -   if (ret == APP_CONTROL_ERROR_NONE) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch!\n");
    +        return -1;
    +    }
    +
    +    app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_BT_ENABLE);
    +
    +    ret = app_control_send_launch_request(service, NULL, NULL);
    +    app_control_destroy(service);
     
    -      return 0;
    -   } 
    -   else 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch!\n");
    +    if (ret == APP_CONTROL_ERROR_NONE) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch!\n");
     
    -      return -1;
    -   }
    +        return 0;
    +    } else {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch!\n");
     
    -   return 0;
    +        return -1;
    +    }
    +
    +    return 0;
     }
     
    @@ -2094,40 +2068,36 @@ bt_enable_operation(void)

    Example Code

     #include <app_control.h>
    - 
    -int 
    +
    +int
     bt_visibility_operation(void)
     {
    -   int ret = 0;
    -   app_control_h service = NULL;
    -   app_control_create(&service);
    - 
    -   if (service == NULL) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
    +    int ret = 0;
    +    app_control_h service = NULL;
    +    app_control_create(&service);
     
    -      return -1;
    -   }
    - 
    -   app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY);
    +    if (service == NULL) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
     
    -   ret = app_control_send_launch_request(service, NULL, NULL);
    -   app_control_destroy(service);
    - 
    -   if (ret == APP_CONTROL_ERROR_NONE) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch!\n");
    +        return -1;
    +    }
    +
    +    app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY);
    +
    +    ret = app_control_send_launch_request(service, NULL, NULL);
    +    app_control_destroy(service);
    +
    +    if (ret == APP_CONTROL_ERROR_NONE) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch!\n");
     
    -      return 0;
    -   } 
    -   else 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch!\n");
    +        return 0;
    +    } else {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch!\n");
     
    -      return -1;
    -   }
    +        return -1;
    +    }
     
    -   return 0;
    +    return 0;
     }
     
    @@ -2148,39 +2118,35 @@ bt_visibility_operation(void)

    Example Code

    -int 
    +int
     location_setting(void)
     {
    -   int ret = 0;
    -   app_control_h service = NULL;
    -   app_control_create(&service);
    - 
    -   if (service == NULL) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
    +    int ret = 0;
    +    app_control_h service = NULL;
    +    app_control_create(&service);
     
    -      return -1;
    -   }
    - 
    -   app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_LOCATION);
    +    if (service == NULL) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
     
    -   ret = app_control_send_launch_request(service, NULL, NULL);
    -   app_control_destroy(service);
    - 
    -   if (ret == APP_CONTROL_ERROR_NONE) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch location settings!\n");
    +        return -1;
    +    }
    +
    +    app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_LOCATION);
     
    -      return 0;
    -   } 
    -   else 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch location settings!\\n");
    +    ret = app_control_send_launch_request(service, NULL, NULL);
    +    app_control_destroy(service);
     
    -      return -1;
    -   }
    +    if (ret == APP_CONTROL_ERROR_NONE) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch location settings!\n");
     
    -   return 0;
    +        return 0;
    +    } else {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch location settings!\n");
    +
    +        return -1;
    +    }
    +
    +    return 0;
     }
     
    @@ -2202,40 +2168,36 @@ location_setting(void) #include <app_control.h> #include <dlog.h> -int +int nfc_setting(void) { -   int ret = 0; - -   app_control_h service = NULL; -   app_control_create(&service); - -   if (service == NULL) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler"); - -      return -1; -   } - -   app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_NFC); - -   ret = app_control_send_launch_request(service, NULL, NULL); -   app_control_destroy(service); - -   if (ret == APP_CONTROL_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch NFC settings app!\n"); - -      return 0; -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch NFC settings app!\n"); - -      return -1; -   } - -   return 0; +    int ret = 0; + +    app_control_h service = NULL; +    app_control_create(&service); + +    if (service == NULL) { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler"); + +        return -1; +    } + +    app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_NFC); + +    ret = app_control_send_launch_request(service, NULL, NULL); +    app_control_destroy(service); + +    if (ret == APP_CONTROL_ERROR_NONE) { +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch NFC settings app!\n"); + +        return 0; +    } else { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch NFC settings app!\n"); + +        return -1; +    } + +    return 0; } @@ -2254,34 +2216,32 @@ nfc_setting(void)

    Example Code

    -int 
    +int
     wifi_launch_operation(void)
     {
    -   int ret = 0;
    -   app_control_h service = NULL;
    -	
    -   ret = app_control_create(&service);
    -	 
    -   if (ret != APP_CONTROL_ERROR_NONE || service == NULL) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
    -
    -      return -1;
    -   }
    -	
    -   app_control_set_operation(service,  APP_CONTROL_OPERATION_SETTING_WIFI);
    +    int ret = 0;
    +    app_control_h service = NULL;
    +
    +    ret = app_control_create(&service);
    +
    +    if (ret != APP_CONTROL_ERROR_NONE || service == NULL) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to create app control handler");
    +
    +        return -1;
    +    }
     
    -   ret = app_control_send_launch_request(service, NULL, NULL);
    -   app_control_destroy(service);
    -	   
    -   if (ret != APP_CONTROL_ERROR_NONE) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch Wi-Fi setting application");
    +    app_control_set_operation(service,  APP_CONTROL_OPERATION_SETTING_WIFI);
     
    -      return -1;
    -   }
    +    ret = app_control_send_launch_request(service, NULL, NULL);
    +    app_control_destroy(service);
     
    -   return 0;
    +    if (ret != APP_CONTROL_ERROR_NONE) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to launch Wi-Fi setting application");
    +
    +        return -1;
    +    }
    +
    +    return 0;
     }
     
    @@ -2328,14 +2288,14 @@ wifi_launch_operation(void)

    Example Code

     #include <app_control.h>
    - 
    +
     app_control_h service;
     app_control_create(&service);
    - 
    +
     app_control_set_operation(service, APP_CONTROL_OPERATION_CREATE_CONTENT);
     app_control_set_mime(service, "audio/m4a");
     app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP);
    - 
    +
     app_control_send_launch_request(service, NULL, NULL);
     
    diff --git a/org.tizen.guides/html/native/app/data_control_n.htm b/org.tizen.guides/html/native/app/data_control_n.htm index b9c701e..a4c7b23 100644 --- a/org.tizen.guides/html/native/app/data_control_n.htm +++ b/org.tizen.guides/html/native/app/data_control_n.htm @@ -40,11 +40,11 @@

    Data Control

    Data control is a standard mechanism for exchanging specific data between applications.

    -

    All applications can request data shared by other applications using a data control. However, only service applications can provide their own data.

    +

    All applications can request data shared by other applications using a data control. However, only service applications can provide their own data.

    There are 2 types of data controls:

    -
    • DATA_CONTROL_SQL +
      • DATA_CONTROL_SQL

        Allows you to use a SQL-type data control to access specific data exported by other service applications. You can also define a SQL-type data control provider to export specific data from your service application.

      • -
      • DATA_CONTROL_MAP +
      • DATA_CONTROL_MAP

        Allows you to use a key-value-type data control to access data exported by other service applications. You can also define a key-value-type data control provider to export specific data from your service application.

      Data controls can supply operations to access shared data and get back results.

      The data control requires the following provider information:

      @@ -63,13 +63,15 @@

      Figure: Data control mechanism

      Data control mechanism

      +

      Before you start, remember to prepare your application to use the data control functionality.

      +

      Using Data Controls

      You can get a datacontrol_h instance from the datacontrol_map_create() or datacontrol_sql_create() function.

      -
      • Map type data control +
        • Map-type data control

          If you specify the datacontrol_h instance using the data_control_map_create(), data_control_map_set_provider_id(), or data_control_map_set_data_id() function, you can get the specific map-type data control uniquely.

          After resolving the data control, call the data control map APIs, such as data_control_map_set(), data_control_map_get(), data_control_map_add(), and data_control_map_remove().

          The result is returned by a response callback, such as data_control_map_get_response_cb(), data_control_map_set_response_cb(), data_control_map_add_response_cb(), or data_control_map_remove_response_cb() of the data_control_map_response_cb struct. The response callback is invoked when a service application finishes its operation.

        • -
        • Sql type data control +
        • SQL-type data control

          If you specify the datacontrol_h instance using the data_control_sql_create(), data_control_sql_set_provider_id(), or data_control_sql_set_data_id() function, you can get the specific SQL-type data control uniquely.

          After resolving the data control, call the data control SQL APIs, such as datacontrol_sql_select(), data_control_sql_insert(), data_control_sql_update(), and data_control_sql_delete().

          The result is returned by a response callback, such as data_control_sql_select_response_cb(), data_control_sql_insert_response_cb(), data_control_sql_update_response_cb(), or data_control_sql_delete_response_cb() of the data_control_sql_response_cb struct. The response callback is invoked when a service application finishes its operation.

          @@ -93,14 +95,14 @@

          The following code example describes how to add the <datacontrol> element:

           <?xml version="1.0" encoding="utf-8"?>
          -<manifest xmlns="http://tizen.org/ns/packages" package="@PACKAGE_NAME@" version="@VERSION@" 
          +<manifest xmlns="http://tizen.org/ns/packages" package="@PACKAGE_NAME@" version="@VERSION@"
                     install-location="internal-only">
              <label>datacontrolprovider</label>
              <author email="PUT YOUR EMAIL" href="www.tizen.org">PUT YOUR NAME</author>
              <description>datacontrolprovider</description>
          -   <ui-application appid="org.tizen.datacontrolprovider" 
          -                   exec="datacontrolprovider" 
          -                   nodisplay="true" multiple="false" type="capp" taskmanage="true" 
          +   <ui-application appid="org.tizen.datacontrolprovider"
          +                   exec="datacontrolprovider"
          +                   nodisplay="true" multiple="false" type="capp" taskmanage="true"
                              auto-restart="false" on-boot="false">
                 <datacontrol providerid = "Your Provider ID"
                              access="ReadWrite" type="Sql"/>
          @@ -169,22 +171,22 @@
               
           
           SQL 
          -     http://<vendor.com>/datacontrol/provider/sample 
          -     data1 
          -     
          -

          column1
          (type: Integer)

          - -

          column2
          (type: String)

          + http://<vendor.com>/datacontrol/provider/sample + data1 + column1 +

          (Type: Integer)

          + column2 +

          (Type: String)

          Read-Only Map - http://<vendor.com>/datacontrol/provider/sample2 - data2 - -

          key1
          (type: String)

          - -

          key2
          (type: String)

          + http://<vendor.com>/datacontrol/provider/sample2 + data2 + key1 +

          (Type: String)

          + key2 +

          (Type: String)

          Read-Write diff --git a/org.tizen.guides/html/native/app/event_n.htm b/org.tizen.guides/html/native/app/event_n.htm index 6131c84..f276de8 100644 --- a/org.tizen.guides/html/native/app/event_n.htm +++ b/org.tizen.guides/html/native/app/event_n.htm @@ -32,7 +32,7 @@

          Event

          -

          The application can broadcast its own events to all listeners, and subscribe to events. The events can be either predefined system events from the platform (only platform modules can broadcast system events) or user-defined events (broadcast by UI and service applications).

          +

          The application can broadcast its own events to all listeners, and subscribe to events. The events can be either predefined system events from the platform (only platform modules can broadcast system events) or user-defined events (broadcast by UI and service applications). Before you start, remember to prepare your application to use the event functionality.

          This feature is supported in mobile applications only.

          The main features of the Event API are:

          @@ -161,7 +161,7 @@
        • "disconnected": USB cable is not connected

        • "connected": USB cable is connected, but the service is not available

        • -
        • "available": USB service is available (for example, mtp or sdb)

          +
        • "available": USB service is available (for example, mtp or SDB)

        diff --git a/org.tizen.guides/html/native/app/internationalization_n.htm b/org.tizen.guides/html/native/app/internationalization_n.htm index 84b3d72..9f1ae41 100644 --- a/org.tizen.guides/html/native/app/internationalization_n.htm +++ b/org.tizen.guides/html/native/app/internationalization_n.htm @@ -46,8 +46,10 @@ Note -

        The .po files must be placed in the res/po directory of the application. The files can be edited using the PO File Editor provided by the Tizen SDK.

        -

        This .po file is compiled to the .mo file, and the .mo file's name is decided using the project name that you enter when you create the project in IDE. The application's appid is made based on the project name and the framework finds .mo file of the application with application's appid. Note that even if appid is changed in the tizen manifest editor, the .mo file name is not changed. It can make some problem when get string resources. Please be careful when you change the appid in the tizen manifest editor.

        + The .po files must be placed in the res/po directory of the application. The files can be edited using the PO File Editor provided by the Tizen SDK. +

        The .po file is compiled into a .mo file, and the .mo file name is decided using the project name that you define when you create the project in the IDE. The application appid is made based on the project name, and the framework finds the .mo file of the application with the application appid.

        +

        If you change the appid in the Tizen manifest editor later on, the .mo file name is not automatically changed. This can cause problems when getting the string resources. Be careful if you change the appid in the Tizen manifest editor.

        + @@ -66,8 +68,8 @@ char *hello_text = i18n_get_text("Hello");

        The most common way to use a translation involves the following APIs:

        -elm_object_translatable_text_set(Evas_Object *obj, const char *text)
        -elm_object_item_translatable_text_set(Elm_Object_Item *it, const char *text)
        +elm_object_translatable_text_set(Evas_Object *obj, const char *text);
        +elm_object_item_translatable_text_set(Elm_Object_Item *it, const char *text);
         

        They set the untranslated string for the "default" part of the given Evas_Object or Elm_Object_Item and mark the string as translatable.

        @@ -75,8 +77,8 @@ elm_object_item_translatable_text_set(Elm_Object_Item *it, const char *text)

        Similar functions are available if you wish to set the text for a part that is not "default":

        -elm_object_translatable_part_text_set(Evas_Object *obj, const char *part, const char *text)
        -elm_object_item_translatable_part_text_set(Elm_Object_Item *it, const char *part, const char *text)
        +elm_object_translatable_part_text_set(Evas_Object *obj, const char *part, const char *text);
        +elm_object_item_translatable_part_text_set(Elm_Object_Item *it, const char *part, const char *text);
         

        It is important to provide the untranslated string to these functions, because the EFLs trigger the translation themselves and re-translate the strings automatically, if the system language changes.

        @@ -109,9 +111,10 @@ char *i18n_get_text(const char *msgid);
         #include "app_i18n.h"
        -static char *_genlist_text_get(void *data, Evas_Object *obj, const char *part)
        +static char*
        +_genlist_text_get(void *data, Evas_Object *obj, const char *part)
         {
        -   return strdup(i18n_get_text("Some Text"));
        +    return strdup(i18n_get_text("Some Text"));
         }
         
        @@ -154,7 +157,7 @@ msgstr[2] "%d Komentarzy" "Plural-Forms: nplurals = 3; plural = n = = 1 ? 0 : n%10> = 2 && n%10< = 4 && (n%100<10 | | n%100> = 20) ? 1 : 2;\n" -

        There are three forms (including singular). The index is 0 (singular), if the given integer n is 1. Then, if (n % 10 >= 2 && % 10 <= 4 && (n % 100 < 10 | | n % 100 >= 20), the index is 1, otherwise it is 2.

        +

        There are 3 forms (including singular). The index is 0 (singular), if the given integer n is 1. Then, if (n % 10 >= 2 && % 10 <= 4 && (n % 100 < 10 | | n % 100 >= 20), the index is 1, otherwise it is 2.

        Handling Language Changes at Runtime

        @@ -166,17 +169,17 @@ msgstr[2] "%d Komentarzy" static void _app_language_changed(void *data) { -   char *language; -   // Retrieve the current system language -   system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &language); -   // Set the language in elementary -   elm_language_set(language); -   free(language); +    char *language; +    /* Retrieve the current system language */ +    system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &language); +    /* Set the language in elementary */ +    elm_language_set(language); +    free(language); } int main(int argc, char *argv[]) { -   ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &ad); +    ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &ad); } @@ -291,4 +294,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/native/app/message_port_n.htm b/org.tizen.guides/html/native/app/message_port_n.htm index 38d7bb5..f178b2d 100644 --- a/org.tizen.guides/html/native/app/message_port_n.htm +++ b/org.tizen.guides/html/native/app/message_port_n.htm @@ -33,11 +33,14 @@

        Message Port

        -

        Tizen applications can communicate with each other using message ports. Applications can send and receive messages through message port communication. The message data type for communication is a map data which consists of a bundle (key and value pair).

        +

        Tizen applications can communicate with each other using message ports. Applications can send and receive messages through message port communication. The message data type for communication is a map data which consists of a bundle (key and value pair).

        You can communicate between applications using 2 types of message port:

        • Local port is used to register your message port and prepare to receive messages from another application.

          To receive messages from the another application, set the callback from the local message port.

        • Remote port is used to send messages to other applications. The local message port information can be sent to the other application for bi-directional communication.
        + +

        Before you start, remember to prepare your application to use the message port functionality.

        +

        A message port supports 2 communication methods:

        • Uni-directional communication
          • Check whether the message port of a remote application is registered with the message_port_check_remote_port() function.
          • diff --git a/org.tizen.guides/html/native/app/notification_n.htm b/org.tizen.guides/html/native/app/notification_n.htm index 972193c..55f3f42 100644 --- a/org.tizen.guides/html/native/app/notification_n.htm +++ b/org.tizen.guides/html/native/app/notification_n.htm @@ -36,7 +36,7 @@

            Notification

            -

            An application can use notifications to keep the user informed of important information.

            +

            An application can use notifications to keep the user informed of important information.

            This feature is supported in mobile applications only.

            The Tizen Notification API requires the http://tizen.org/privilege/notification privilege.

            @@ -47,6 +47,8 @@
          • To control the detailed behavior of the notification or to show the progress bar in the on-going activity area, use the notification_create() function to get a notification handle and set the details.
          • To update the content of a notification, use the notification_update() function. You can also delete notifications when no longer needed.
          +

          Before you start, remember to prepare your application to use the notification functionality.

          +

          Notification Types

          Tizen provides notifications by using a combination of any of the following notification types:

          diff --git a/org.tizen.guides/html/native/app/package_n.htm b/org.tizen.guides/html/native/app/package_n.htm index 1104ce2..7a9cb34 100644 --- a/org.tizen.guides/html/native/app/package_n.htm +++ b/org.tizen.guides/html/native/app/package_n.htm @@ -32,7 +32,7 @@

          Package Manager

          -

          The package manager is used to retrieve detailed information of the installed packages on the device. This information includes the package name, label, path to the icon image, version, type, and installed storage.

          +

          The package manager is used to retrieve detailed information of the installed packages on the device. This information includes the package name, label, path to the icon image, version, type, and installed storage.

          The main features of the Package Manager API include:

          - +

          Before you start, remember to prepare your application to use the package manager functionality.

          diff --git a/org.tizen.guides/html/native/app/resource_manager_n.htm b/org.tizen.guides/html/native/app/resource_manager_n.htm new file mode 100644 index 0000000..f26c7b6 --- /dev/null +++ b/org.tizen.guides/html/native/app/resource_manager_n.htm @@ -0,0 +1,95 @@ + + + + + + + + + + + + + Resource Manager + + + + + +
          + +

          Resource Manager

          + +

          You can get or set common resources for multiple devices with different specifications.

          + +

          This feature is supported in mobile applications only.

          + +

          You can use different resources (such as images, layouts, and sounds) between devices with different device specifications. For example:

          + +
            +
          • To set a different button image for an application depending on the device's current language setting, use the app_resource_manager_get() function to get the appropriate resource file path.
          • +
          • To use different images depending on the device's screen resolution (DPI), use the same app_resource_manager_get() function to get the appropriate image file path.
          • +
          +

          You can test the different resources by running them in the emulator. Before you start, remember to prepare your application to use the resource manager functionality.

          + + + + + + + + + +
          Note
          The resource files must be in different folders and have the same filename. You can set the resources using the Resource Manager tool provided by the Tizen SDK.
          + +

          To use the app_resource_manager_get() function, you need 2 parameters:

          +
            +
          • Resource ID +

            The resource ID is an identifier for a specific resource. It consists of subdirectories and filenames including its extension. The same resources are located in different locations with the same filename for supporting multiple devices.

            +
          • +
          • Resource type +

            The resource type defines whether the resource is an image, layout, sound, or some other file type. There are 4 resource types, which are defined in the app_resource_e enumerator.

            + +

            Resources with the same resource type are grouped as a folder. The folder name is irrelevant to the actual resource type within it.

            +
          • +
          + + + + + + + +
          + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.guides/html/native/app/service_app_n.htm b/org.tizen.guides/html/native/app/service_app_n.htm index 5ae329d..377c14e 100644 --- a/org.tizen.guides/html/native/app/service_app_n.htm +++ b/org.tizen.guides/html/native/app/service_app_n.htm @@ -42,6 +42,8 @@

          The user can check the running service applications in the task switcher; however, no events occur if the user selects a service application from the task switcher. The main menu does not contain icons for service applications. Multiple service applications can be running simultaneously with other service and UI applications.

          +

          Before you start, remember to prepare your application to use the service application functionality.

          +

          The following figure and table describe the service application states.

          Figure: Running service applications

          @@ -120,12 +122,12 @@ service_app_low_memory_cb() -

          Used to take necessary actions in low memory situations.

          + Used to take necessary actions in low memory situations.

          Save data in the main memory to a persistent memory or storage, to avoid data loss in case the Tizen platform Low Memory Killer kills your application to get more free memory. Release any cached data in the main memory to secure more free memory.

          service_app_low_battery_cb() -

          Used to take necessary actions in low battery situations.

          + Used to take necessary actions in low battery situations.

          Save data in the main memory to a persistent memory or storage, to avoid data loss in case the power goes off completely. Stop heavy CPU consumption or power consumption activities to save the remaining power.

          diff --git a/org.tizen.guides/html/native/app/shortcut_n.htm b/org.tizen.guides/html/native/app/shortcut_n.htm index 9839308..b5239f9 100644 --- a/org.tizen.guides/html/native/app/shortcut_n.htm +++ b/org.tizen.guides/html/native/app/shortcut_n.htm @@ -35,6 +35,7 @@

          This feature is supported in mobile applications only.

          To add a shortcut, use the shortcut_add_to_home() function, which requests the Home application to add a new shortcut. You can also add a widget.

          +

          Before you start, remember to prepare your application to use the shortcut functionality.

          Figure: Shortcuts

          Shortcuts

          There are 2 types of shortcuts:

          diff --git a/org.tizen.guides/html/native/app/watch_n.htm b/org.tizen.guides/html/native/app/watch_n.htm index bbad863..95dae23 100644 --- a/org.tizen.guides/html/native/app/watch_n.htm +++ b/org.tizen.guides/html/native/app/watch_n.htm @@ -43,7 +43,7 @@

          The main features of the Watch Application API include:

          +

          Before you start, remember to prepare your application to use the watch functionality.

          +

          Application States and Events

          The following figure illustrates the watch application states during the application life-cycle:

          diff --git a/org.tizen.guides/html/native/app/widget_n.htm b/org.tizen.guides/html/native/app/widget_n.htm index 6e48416..ee53901 100644 --- a/org.tizen.guides/html/native/app/widget_n.htm +++ b/org.tizen.guides/html/native/app/widget_n.htm @@ -40,7 +40,7 @@

          Widget Application

          -

          You can create widget applications, which are Tizen native applications shown on the home screen. They are launched by the home screen when the user selects them in the Add Widget menu.

          +

          You can create widget applications, which are Tizen native applications shown on the home screen. They are launched by the home screen when the user selects them in the Add Widget menu.

          The main features of the Widget Application API include:

            @@ -67,6 +67,8 @@
          +

          Before you start, remember to prepare your application to use the widget functionality.

          +

          Widget Application and Widget Instance

          The widget application provides a life-cycle and methods for making and managing a widget class. It consists of 1 process and make the widget class in the widget_app_create() callback function. With this class, the framework can make instances whenever applications for widget viewers, such as home screen and lock screen, request for a widget instance.

          @@ -170,17 +172,17 @@ static widget_class_h widget_app_create(void *user_data) { -   widget_instance_lifecycle_callback_s ops = -   { -      .create = widget_instance_create, -      .destroy = widget_instance_destroy, -      .pause = widget_instance_pause, -      .resume = widget_instance_resume, -      .update = widget_instance_update, -      .resize = widget_instance_resize, -   }; - -   return widget_app_class_create(ops, user_data); +    widget_instance_lifecycle_callback_s ops = +    { +        .create = widget_instance_create, +        .destroy = widget_instance_destroy, +        .pause = widget_instance_pause, +        .resume = widget_instance_resume, +        .update = widget_instance_update, +        .resize = widget_instance_resize, +    }; + +    return widget_app_class_create(ops, user_data); } diff --git a/org.tizen.guides/html/native/base/i18n_n.htm b/org.tizen.guides/html/native/base/i18n_n.htm index 251fbdc..573c417 100644 --- a/org.tizen.guides/html/native/base/i18n_n.htm +++ b/org.tizen.guides/html/native/base/i18n_n.htm @@ -53,6 +53,8 @@

          You can generate flexible number or date format patterns, format and parse dates and numbers for any locale, and manage time zones. The i18n API is implemented by using the ICU library.

          +

          Before you start, remember to prepare your application to use the i18n functionality.

          +

          Ubrk

          The Ubrk API (in mobile and wearable applications) is used to find the location of boundaries in text. The i18n_ubreak_iterator_h handle maintains a current position and scans over the text returning the index of characters where the boundaries occur.

          The following boundary analyzing methods are available:

          @@ -253,7 +255,7 @@

          Udatepg

          The Udatepg API (in mobile and wearable applications) enables flexible generation of date format patterns, such as "yy-MM-dd". The user can build up the generator by adding successive patterns. After this, a query can be made using a pattern that includes only the desired fields and lengths. The generator returns the a pattern that is most similar to it.

          -

          The main method is the i18n_udatepg_get_best_pattern() function, since normally the Udatepg API is pre-built with data from a particular locale. However, generators can be built directly from other data as well. +

          The main method is the i18n_udatepg_get_best_pattern() function, since normally the Udatepg API is prebuilt with data from a particular locale. However, generators can be built directly from other data as well.

          Uenumeration

          @@ -284,11 +286,11 @@ -

          The first option is a valid ISO Language Code. These codes are the lower-case two-letter codes as defined by the ISO-639 standard. +

          The first option is a valid ISO Language Code. These codes are the lower-case 2-letter codes as defined by the ISO-639 standard.

          The second option includes an additional ISO Country Code.

          -

          The third option requires additional information on the variant. The variant codes are vendor and browser-specific. For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. Where there are two variants, separate them with an underscore, and put the most important one first. For example, a Traditional Spanish collation might be referenced, with ES, ES, Traditional_WIN. +

          The third option requires additional information on the variant. The variant codes are vendor and browser-specific. For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. Where there are 2 variants, separate them with an underscore, and put the most important one first. For example, a Traditional Spanish collation might be referenced, with ES, ES, Traditional_WIN.

          Because a locale is just an identifier for a region, no validity check is performed when you specify a locale. If you want to see whether particular resources are available for the locale you asked for, you must query those resources.

          @@ -357,7 +359,7 @@

          Any character can be preceded by a backslash in order to remove any special meaning. Whitespace characters are ignored, unless they are escaped.

          Property patterns specify a set of characters having a certain property as defined by the Unicode standard. Both the POSIX-like [:Lu:] and the Perl-like syntax \\p{Lu} are recognized.

          Patterns specify individual characters, ranges of characters, and Unicode property sets. When the elements are concatenated, they specify their union. To complement a set, place a '^' immediately after the opening '['. Property patterns are inverted by modifying their delimiters, [:^foo] and \\P{foo}. In any other location, '^' has no special meaning.

          -

          Ranges are indicated by placing a '-' between 2 characters, as in "a-z". This specifies the range of all characters from the left to the right, in Unicode order. If the left character is greater than or equal to the right character, it is a syntax error. If a '-' occurs as the first character after the opening '[' or '[^', or if it occurs as the last character before the closing ']', it is taken as a literal. This means that [a\-b], [-ab], and [ab-] all indicate the same set of three characters, 'a', 'b', and '-'.

          +

          Ranges are indicated by placing a '-' between 2 characters, as in "a-z". This specifies the range of all characters from the left to the right, in Unicode order. If the left character is greater than or equal to the right character, it is a syntax error. If a '-' occurs as the first character after the opening '[' or '[^', or if it occurs as the last character before the closing ']', it is taken as a literal. This means that [a\-b], [-ab], and [ab-] all indicate the same set of 3 characters, 'a', 'b', and '-'.

          Sets can be intersected using the '&' operator or the asymmetric set difference can be taken using the '-' operator. For example, [[:L:]&[\\u0000-\\u0FFF]] indicates the set of all Unicode letters with values less than 4096. Operators ('&' and '|') have equal precedence and bind left-to-right. This means that [[:L:]-[a-z]-[\\u0100-\\u01FF]] is equivalent to [[[:L:]-[a-z]]-[\\u0100-\\u01FF]]. This only really matters for difference; intersection is commutative.

          - + @@ -219,7 +235,8 @@ - + @@ -231,7 +248,8 @@ - + @@ -263,7 +281,8 @@ - + @@ -293,7 +312,8 @@ - + @@ -325,15 +345,18 @@ - + - + - +
          diff --git a/org.tizen.guides/html/native/content/download_n.htm b/org.tizen.guides/html/native/content/download_n.htm index 0e853e8..def9cf6 100644 --- a/org.tizen.guides/html/native/content/download_n.htm +++ b/org.tizen.guides/html/native/content/download_n.htm @@ -36,7 +36,8 @@

          Download

          -

          You can create and manage one or more download requests. Tizen allows you to create a new download process, configure the download URL or destination, and launch the process.

          +

          You can create and manage one or more download requests. Tizen allows you to create a new download process, configure the download URL or destination, and launch the process.

          +

          Before you start, remember to prepare your application to use the download functionality.

          This feature is supported in mobile applications only.

          @@ -108,7 +109,7 @@

          Stopping and Destroying a Download

          -

          The download_cancel() function can be used to stop downloading a file. The function changes the download state to DOWNLOAD_STATE_CANCELED. From this state, the download_start() function can be called to restart the download.

          +

          The download_cancel() function can be used to stop downloading a file. The function changes the download state to DOWNLOAD_STATE_CANCELED. From this state, the download_start() function can be called to restart the download.

          The download_destroy() function can be called to unload all data concerning a download_id handle from the memory. The download_id handle is stored for 48 hours (even if the device is powered off), unless the download_destroy() is called.

          diff --git a/org.tizen.guides/html/native/content/media_content_n.htm b/org.tizen.guides/html/native/content/media_content_n.htm index 4e016bb..17d4eb4 100644 --- a/org.tizen.guides/html/native/content/media_content_n.htm +++ b/org.tizen.guides/html/native/content/media_content_n.htm @@ -23,7 +23,7 @@

          Related Info

          @@ -43,26 +43,41 @@
          • SD card insertion and removal: Media files are updated only in the SD card.
          • Rebooting the device: Media files are updated in the internal memory and SD card in the device.
          -

          Media content is available to only use the files located in the specific paths. You can get the paths by using the int storage_get_directory(int storage_id, storage_directory_e type, char **path); function. For more information, see the Storage API (in mobile and wearable applications).

          +

          Media content is available to only use the files located in the specific paths. You can get the paths by using the storage_get_directory() function. For more information, see the Storage API (in mobile and wearable applications).

          + + + + + + + + + +
          Note
          To obtain information from the media database, you must first connect to it. When the connection is no longer needed, remember to disconnect from the media database.

          The main features of the Content module include:

          @@ -117,7 +132,8 @@
          TimelineThe time the media content was created
          You can use this value to sort the content.
          The time the media content was created +

          You can use this value to sort the content.

          Thumbnail path
          Media IDMedia ID of the audio content
          This value is same as the media ID in general information
          Media ID of the audio content +

          This value is same as the media ID in general information.

          Album
          Album ArtistAlbum artist of the audio content
          The artist and album artist can be the same.
          Album artist of the audio content +

          The artist and album artist can be the same.

          Genre
          Bit per sampleBit per sample of the audio content
          The bit per sample is the same as the sample format.
          The sample format is the number of digits in the digital representation of each sample.
          Bit per sample of the audio content +

          The bit per sample is the same as the sample format. The sample format is the number of digits in the digital representation of each sample.

          Sample rate
          Media IDMedia ID of the image
          This value is the same as the media ID in the general information.
          Media ID of the image +

          This value is the same as the media ID in the general information.

          Width
          Date takenThe time the image was created
          You can get this information from the EXIF tag.
          If there is no EXIF tag for the image, set the created time in the file system.
          The time the image was created +

          You can get this information from the EXIF tag. If there is no EXIF tag for the image, set the created time in the file system.

          Is burstshotCheck flag for a burst shot of the image
          The burst shot is a continuous shooting mode.
          Check flag for a burst shot of the image +

          The burst shot is a continuous shooting mode.

          Burstshot IDID of a burst shot image
          Assign the same ID to the burst shooting mode.
          ID of a burst shot image +

          Assign the same ID to the burst shooting mode.

          @@ -350,7 +373,8 @@ Media ID - The media ID of the video content
          This value is same with media ID of general information + The media ID of the video content +

          This value is same with media ID of general information.

          Album diff --git a/org.tizen.guides/html/native/content/mime_type_n.htm b/org.tizen.guides/html/native/content/mime_type_n.htm index b69c04b..de96cde 100644 --- a/org.tizen.guides/html/native/content/mime_type_n.htm +++ b/org.tizen.guides/html/native/content/mime_type_n.htm @@ -43,6 +43,7 @@
        • Getting associated extensions

          To get a list of extensions associated, for example, with an image or a JPEG MIME type, use the mime_type_get_file_extension() function.

        +

        Before you start, remember to prepare your application to use the MIME type functionality.

        diff --git a/org.tizen.guides/html/native/context/activity_recognition_n.htm b/org.tizen.guides/html/native/context/activity_recognition_n.htm index 2bd3d82..3a14e1e 100644 --- a/org.tizen.guides/html/native/context/activity_recognition_n.htm +++ b/org.tizen.guides/html/native/context/activity_recognition_n.htm @@ -35,7 +35,8 @@

        Activity Recognition

        -

        The activity recognizer can detect walking and running activity. It also recognizes the stationary state and activities on a moving vehicle.

        +

        The activity recognizer can detect walking and running activity. It also recognizes the stationary state and activities on a moving vehicle.

        +

        Before you start, remember to prepare your application to use the activity recognition functionality.

        diff --git a/org.tizen.guides/html/native/context/context_guide_n.htm b/org.tizen.guides/html/native/context/context_guide_n.htm index be7ba1d..6c5f90d 100644 --- a/org.tizen.guides/html/native/context/context_guide_n.htm +++ b/org.tizen.guides/html/native/context/context_guide_n.htm @@ -46,10 +46,10 @@

        The following guides apply in mobile applications only:

          -
        • Contextual Trigger -

          Enables you to compose rules to trigger a task based on contextual events and conditions.

        • Contextual History

          Enables you to get usage profiles, such as information about frequently used applications.

        • +
        • Contextual Trigger +

          Enables you to compose rules to trigger a task based on contextual events and conditions.

        diff --git a/org.tizen.guides/html/native/context/gesture_recognition_n.htm b/org.tizen.guides/html/native/context/gesture_recognition_n.htm index 1c4fd54..063e7ad 100644 --- a/org.tizen.guides/html/native/context/gesture_recognition_n.htm +++ b/org.tizen.guides/html/native/context/gesture_recognition_n.htm @@ -34,7 +34,7 @@

        Gesture Recognition

        -

        With gesture recognition, you can receive notifications about different device movement patterns, identify device states, and trigger events when the sensor data meets predefined conditions. In some cases, you can also listen to different states (started, in-progress, and ended).

        +

        With gesture recognition, you can receive notifications about different device movement patterns, identify device states, and trigger events when the sensor data meets predefined conditions. In some cases, you can also listen to different states (started, in-progress, and ended).

        The following gesture events are supported in Tizen devices:

        @@ -88,6 +88,7 @@

        Wrist-up event

        +

        Before you start, remember to prepare your application to use the gesture recognition functionality.

        diff --git a/org.tizen.guides/html/native/context/history_n.htm b/org.tizen.guides/html/native/context/history_n.htm index 5932043..237c0ba 100644 --- a/org.tizen.guides/html/native/context/history_n.htm +++ b/org.tizen.guides/html/native/context/history_n.htm @@ -41,18 +41,20 @@

        This feature is supported in mobile applications only.

        -

        The Contextual History API provides history data about application usage, media playback, communications, and device settings. When an application reads each type of history data, the application can set filters to specify the necessary statistics. The following example shows how to get information about the 5 most frequently used applications from the last 30 days.

        +

        The Contextual History API provides history data about application usage, media playback, communications, and device settings. When an application reads each type of history data, the application can set filters to specify the necessary statistics. The following example shows how to get information about the 5 most frequently used applications from the last 30 days.

        -// Setting filter key and values
        +/* Setting filter key and values */
         context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, 5);
         context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_TIME_SPAN, 30);
         
        -// Requesting the statistics
        +/* Requesting the statistics */
         context_history_list_h list;
         context_history_get_list(handle, CONTEXT_HISTORY_FREQUENTLY_USED_APP, filter, &list);
         

        -Once the context_history_list_h data handle is retrieved through the context_history_get_list() function, the attributes of each data record of the handle can be retrieved. You can use the context_history_list_get_current() function to get the current record and the context_history_record_get_string() and context_history_record_get_int() functions to access its values.

        +Once the context_history_list_h data handle is retrieved through the context_history_get_list() function, you can retrieve the attributes of each data record of the handle. You can use the context_history_list_get_current() function to get the current record and the context_history_record_get_string() and context_history_record_get_int() functions to access its values.

        + +

        Before you start, remember to prepare your application to use the contextual history functionality.

        History Data Types

        diff --git a/org.tizen.guides/html/native/context/trigger_n.htm b/org.tizen.guides/html/native/context/trigger_n.htm index 1d382c8..028d2a1 100644 --- a/org.tizen.guides/html/native/context/trigger_n.htm +++ b/org.tizen.guides/html/native/context/trigger_n.htm @@ -37,16 +37,17 @@

        Contextual Trigger

        -

        Tizen enables you to define rules as a combination of a contextual event, conditions, and an action. When the rule is enabled, the system starts to monitor the device status or user activities corresponding to the event defined in the rule. When the event is detected, the conditions are evaluated, and if the conditions are met, the action is triggered.

        +

        Tizen enables you to define rules as a combination of a contextual event, conditions, and an action. When the rule is enabled, the system starts to monitor the device status or user activities corresponding to the event defined in the rule. When the event is detected, the conditions are evaluated, and if the conditions are met, the action is triggered.

        This feature is supported in mobile applications only.

        -

        The action can be an application launching request using an App Control, or a notification posting. For example, every day at 10:00 PM, if the battery level is low, the application can post a notification to remind the user to charge the battery.

        +

        You can set an action that can be an application launching request using an App Control, or a notification posting. For example, every day at 10:00 PM, if the battery level is low, the application can post a notification to remind the user to charge the battery.

        +

        Before you start, remember to prepare your application to use the contextual trigger functionality.

        The main features of the Contextual Trigger API include:

        • Life-cycle management -

          Once a rule is composed and registered successfully into the system, a unique rule ID is assigned to it. You can use the rule ID to enable, disable, or permanently remove the rule.

          +

          Once a rule is composed and registered successfully into the system, a unique rule ID is assigned to it. You can use the rule ID to enable, disable, or permanently remove the rule.

          Figure: Rule states

          Rule States

          @@ -64,7 +65,7 @@
      • Rule retrieval -

        The application can retrieve a list of enabled and disabled rule IDs owned by the application.

        +

        The application can retrieve a list of enabled and disabled rule IDs owned by the application.

      If you only need to monitor a fundamental system event, such as the USB connection status, to launch a service application, and no condition is required, use event callbacks. In these cases, using the event system instead of the contextual trigger is more efficient, as the contextual trigger runs a rule engine to manage state changes of multiple event and condition items simultaneously.

      @@ -74,7 +75,7 @@
      • Event

        An event literally denotes a contextual event that can be recognized by the device, or a change in a certain contextual state of the device or the user. For example, connections to peripherals, changes in settings, location changes, or specific times can be used as events. Note that only 1 event can be defined in a rule, as it is used as the initiator of the verification of the conditions. If the system detects the occurrence of the designated event, it starts to verify the conditions.

      • Condition -

        A condition denotes a contextual state or fact that can be recognized by the device. For example, the current device status or the historical pattern of the device usage can be used as conditions. In a rule, the application can define 1 condition, multiple conditions, or even no condition. If you define multiple conditions in a rule, the application can choose the way of combining the conditions using logical conjunctions or disjunctions. In case of the logical conjunction, the rule is true only if all the conditions are met. Otherwise, the rule can be true if at least 1 condition is met. If no condition is given, the rule is satisfied instantly when the corresponding event occurs.

      • +

        A condition denotes a contextual state or fact that can be recognized by the device. For example, the current device status or the historical pattern of the device usage can be used as conditions. In a rule, the application can define 1 condition, multiple conditions, or even no condition. If you define multiple conditions in a rule, the application can choose the way of combining the conditions using logical conjunctions or disjunctions. In case of the logical conjunction, the rule is true only if all the conditions are met. Otherwise, the rule can be true if at least 1 condition is met. If no condition is given, the rule is satisfied instantly when the corresponding event occurs.

      • Action

        An action is triggered when the rule is satisfied. Each rule must basically contain 1 action only. However, because the action itself can be defined as an App Control, if necessary, you can implement an application that executes a series of tasks to create a complex context-aware service.

      @@ -90,7 +91,7 @@
      • An event represents a contextual state change or a contextual event literally, such as "headphone is plugged", "the battery level has dropped to low", or "the user enters his home".
      • A condition represents a current contextual state or a device or user profile inferred through the usage history, for example, "the current battery level is low", "Wi-Fi connection is active", or "(when receiving an incoming call) the number is the most frequent address in his call logs".
      -

      Defining an event or a condition can involve attribute comparisons and input option parameter settings. The following example illustrates how to formulate a simple rule of "at 10 PM, if the battery is not charging":

      +

      Defining an event or a condition can involve attribute comparisons and input option parameter settings. The following example illustrates how to formulate a simple rule of "at 10 PM, if the battery is not charging":

      1. Create a rule handle. The first parameter (CONTEXT_TRIGGER_LOGICAL_CONJUNCTION) denotes how to combine all condition entries.
        @@ -102,13 +103,13 @@ context_trigger_rule_create(CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &rule);
         

        A CONTEXT_TRIGGER_EVENT_TIME type event entry is created, and a key-value comparison of CONTEXT_TRIGGER_TIME_OF_DAY == 1320 is set to the event.

        -// Composing an event
        +/* Composing an event */
         context_trigger_rule_entry_h event = NULL;
         context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
         context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
         context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 1320);
         
        -// Adding the event to the rule and releasing the resources
        +/* Adding the event to the rule and releasing the resources */
         context_trigger_rule_add_entry(rule, event);
         context_trigger_rule_entry_destroy(event);
         
      2. @@ -116,13 +117,13 @@ context_trigger_rule_entry_destroy(event);
      3. Formulate the condition statement ("battery is not charging") and add it to the rule handle.

        In the condition entry of CONTEXT_TRIGGER_CONDITION_BATTERY, the comparison statement is defined as the equality check (CONTEXT_TRIGGER_EQUAL_TO) between the left operand (CONTEXT_TRIGGER_IS_CHARGING) and the right operand (CONTEXT_TRIGGER_FALSE).

        -// Composing a condition
        +/* Composing a condition */
         context_trigger_rule_entry_h condition = NULL;
         context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_BATTERY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition);
         context_trigger_rule_entry_add_key(condition, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CHARGING);
         context_trigger_rule_entry_add_comparison_int(condition, CONTEXT_TRIGGER_IS_CHARGING, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_FALSE);
         
        -// Adding the condition to the rule handle
        +/* Adding the condition to the rule handle */
         context_trigger_rule_add_entry(rule, condition);
         context_trigger_rule_entry_destroy(condition);
         
      @@ -367,9 +368,9 @@ context_trigger_rule_entry_destroy(condition);
       int place_id;
       
      -// The target place ID must be retrieved through the Geofence Manager API
      +/* Target place ID must be retrieved through the Geofence Manager API */
       
      -// Composing an event "when the user enters his home"
      +/* Composing an event "when the user enters his home" */
       context_trigger_rule_entry_h event = NULL;
       context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_PLACE, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
       context_trigger_rule_entry_add_option_int(event, CONTEXT_TRIGGER_PLACE_ID, place_id);
      @@ -378,20 +379,20 @@ context_trigger_rule_entry_add_option_int(event, CONTEXT_TRIGGER_PLACE_ID, place
       

      You can also use an attribute value of the event as an option (or a right operand of a comparison) in a condition. As an example, the logical statement "when receiving a message, if the sender's number is the most frequently communicated number" can be formulated as follows:

      -// Composing an event "when receiving a message"
      +/* Composing an event "when receiving a message" */
       context_trigger_rule_entry_h event = NULL;
       context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_MESSAGE, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
       context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_EVENT);
       context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_EVENT, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_RECEIVED);
       
      -// Composing a condition "if the sender's number is the most frequently communicated number"
      +/* Composing a condition "if the sender's number is the most frequently communicated number" */
       context_trigger_rule_entry_h condition = NULL;
       context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_COMMUNICATION_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition);
       
      -// The message sender's address is used as an option of the condition.
      +/* Message sender's address is used as an option of the condition */
       context_trigger_rule_entry_add_option(condition, CONTEXT_TRIGGER_ADDRESS, CONTEXT_TRIGGER_ADDRESS);
       
      -// Checking if the frequency rank of the address is equal to 1
      +/* Checking if the frequency rank of the address is equal to 1 */
       context_trigger_rule_entry_add_key(condition, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_RANK);
       context_trigger_rule_entry_add_comparison_int(condition, CONTEXT_TRIGGER_RANK, CONTEXT_TRIGGER_EQUAL_TO, 1);
       
      @@ -471,7 +472,7 @@ context_trigger_rule_entry_add_comparison_int(condition, CONTEXT_TRIGGER_RANK, C

      With the logical conjunction operator, the rule evaluation becomes true if all the conditions are met. On the other hand, with the logical disjunction operator, the rule evaluation becomes true if at least 1 of the conditions is met. If a rule has 1 condition or no condition, the logical operator has no effect on the evaluation result. The following example shows how to set the proper logical operator between conditions when creating rules:

      -// Composing an event and conditions
      +/* Composing an event and conditions */
       context_trigger_rule_entry_h battery_event;
       context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_BATTERY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &battery_event);
       context_trigger_rule_entry_add_key(battery_event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_LEVEL);
      @@ -487,7 +488,7 @@ context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_WIFI, CONTEXT_TR
       context_trigger_rule_entry_add_key(wifi_condition, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_STATE);
       context_trigger_rule_entry_add_comparison_string(wifi_condition, CONTEXT_TRIGGER_STATE, CONTEXT_TRIGGER_NOT_EQUAL_TO, CONTEXT_TRIGGER_DISABLED);
       
      -// Composing a rule "when the battery level becomes critical, if GPS AND Wi-Fi are enabled"
      +/* Composing a rule "when the battery level becomes critical, if GPS AND Wi-Fi are enabled" */
       context_trigger_rule_h conjunction_rule;
       context_trigger_rule_create(CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &conjunction_rule);
       context_trigger_rule_add_entry(conjunction_rule, battery_event);
      @@ -495,7 +496,7 @@ context_trigger_rule_add_entry(conjunction_rule, gps_condition);
       context_trigger_rule_add_entry(conjunction_rule, wifi_condition);
       context_trigger_rule_set_action_notification(conjunction_rule, ...);
       
      -// Composing a rule "when battery level becomes critical, if GPS OR Wi-Fi is enabled"
      +/* Composing a rule "when the battery level becomes critical, if GPS OR Wi-Fi is enabled" */
       context_trigger_rule_h disjunction_rule;
       context_trigger_rule_create(CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, &disjunction_rule);
       context_trigger_rule_add_entry(disjunction_rule, battery_event);
      @@ -511,7 +512,7 @@ context_trigger_rule_set_action_notification(disjunction_rule, ...);
       

      The following example illustrates the cases described above:

      -// Composing an event "at 4 PM every Monday"
      +/* Composing an event "at 4 PM every Monday" */
       context_trigger_rule_entry_h time_event;
       context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &time_event);
       context_trigger_rule_entry_add_key(time_event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION,  CONTEXT_TRIGGER_TIME_OF_DAY);
      @@ -519,7 +520,7 @@ context_trigger_rule_entry_add_comparison_int(time_event, CONTEXT_TRIGGER_TIME_O
       context_trigger_rule_entry_add_key(time_event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION,  CONTEXT_TRIGGER_DAY_OF_WEEK);
       context_trigger_rule_entry_add_comparison_string(time_event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_MON);
       
      -// Composing a condition "if an application belongs to the 5 most frequently used apps, or is used at least 10 times per day"
      +/* Composing a condition "if an application belongs to the 5 most frequently used apps, or is used at least 10 times per day" */
       context_trigger_rule_entry_h app_condition;
       context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, &app_condition);
       context_trigger_rule_entry_add_option_string(app_condition, CONTEXT_TRIGGER_APP_ID, /* Application ID */);
      @@ -534,14 +535,14 @@ context_trigger_rule_entry_add_comparison_int(app_condition, CONTEXT_TRIGGER_TOT
       

      Similarly as above, regarding an attribute, you can combine multiple comparisons in different ways. For example, if you want to check that the battery level is full or high, use a logical disjunction. If you also want to check whether the current time is between 18:30 and 21:30, use a logical conjunction. The following example illustrates how to compose such conditions:

      -// Composing a condition "if the battery level is full or high"
      +/* Composing a condition "if the battery level is full or high" */
       context_trigger_rule_entry_h battery_condition;
       context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_BATTERY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &battery_condition);
       context_trigger_rule_entry_add_key(battery_condition, CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, CONTEXT_TRIGGER_LEVEL);
       context_trigger_rule_entry_add_comparison_string(battery_condition, CONTEXT_TRIGGER_LEVEL, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_FULL);
       context_trigger_rule_entry_add_comparison_string(battery_condition, CONTEXT_TRIGGER_LEVEL, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_HIGH);
       
      -// Composing a condition "if the current time is between 18:30 and 21:30"
      +/* Composing a condition "if the current time is between 18:30 and 21:30" */
       context_trigger_rule_entry_h time_condition;
       context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &time_condition);
       context_trigger_rule_entry_add_key(time_condition, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION,  CONTEXT_TRIGGER_TIME_OF_DAY);
      diff --git a/org.tizen.guides/html/native/graphics/adv_performance_n.htm b/org.tizen.guides/html/native/graphics/adv_performance_n.htm
      index 26a193e..1b1a295 100644
      --- a/org.tizen.guides/html/native/graphics/adv_performance_n.htm
      +++ b/org.tizen.guides/html/native/graphics/adv_performance_n.htm
      @@ -40,7 +40,7 @@
       
    • If the polygon mesh is not frequently changed, you can use vertex buffer objects (VBO) in order to cache the data into the GPU memory, as illustrated in Uniforms and Attributes in OpenGL ES.
    • In general, you do not need to call the glFinish() function. As drawing commands are requested by the draw_glview() callback and are executed in the background, it is enough to call the glFlush() function at the end of the draw_glview() callback.
    • You are not required to clear every buffer, or to clear them at the same time. Instead, you can obtain the best performance by calling the glClear() function once per frame with all the buffers to be simultaneously cleared.
    • -
    • Do not create and destroy the graphic resources (such as textures and FBO) per frame. You can create and store them in the app_data structure in the init_glview() callback and re-use them later.
    • +
    • Do not create and destroy the graphic resources (such as textures and FBO) per frame. You can create and store them in the app_data structure in the init_glview() callback and reuse them later.
    • Try to avoid using the if statement in the shader code. Since the vertex and fragment shaders are executed in parallel (in batches) on most GPU architectures, if-then-else statement can block some other batches to determine which one can be run next. It means that parallel processing cannot be fully implemented.
    • Try to avoid writing a heavy fragment shader. If the same data apply to all fragments, do not compute the data in the fragment shader but compute them at the CPU side and provide them as uniforms. On the other hand, whenever the data can be computed at the vertex shader, use it.
    • In general, the glReadPixels() function is quite slow, because it reinforces CPU-GPU synchronization, drastically decreasing the overall performance. In most cases, it is possible to obtain the desired result with the framebuffer object (FBO), avoiding the use of glReadPixels(). With FBO, you can access the pixels of the framebuffer (the output of GPU processing) through a texture object (render-to-texture). Since it uses texture data from a GPU stage to another GPU stage, CPU does not have to be synchronized. If the application must use the glReadPixels()function, use another thread to avoid blocking the main thread.
    • diff --git a/org.tizen.guides/html/native/graphics/adv_rendering_n.htm b/org.tizen.guides/html/native/graphics/adv_rendering_n.htm index 1ac16fd..4df8f0a 100644 --- a/org.tizen.guides/html/native/graphics/adv_rendering_n.htm +++ b/org.tizen.guides/html/native/graphics/adv_rendering_n.htm @@ -73,59 +73,60 @@

      The following code creates an FBO as an 'off-screen-buffer' that enables render-to-texture:

      -// This function shows how to create new framebuffer object
      -// with texture color buffer and depth render buffer 
      -// To render a texture, bind framebuffer to 'newFbo' using
      -// glBindeFramebuffer() and make a drawcall. Then, just 
      -// use 'colorTex' as a general texture
      -// This function does not make a stencil buffer
      -// To use stencil buffer for off-screen-buffer, make another
      -// renderbuffer object and attach to framebuffer using
      -// glFramebufferRenderbuffer()
      -void 
      -createFbo() 
      +/*
      +   This function shows how to create new framebuffer object
      +   with texture color buffer and depth render buffer 
      +   To render a texture, bind framebuffer to 'newFbo' using
      +   glBindeFramebuffer() and make a drawcall. Then, just
      +   use 'colorTex' as a general texture
      +   This function does not make a stencil buffer
      +   To use stencil buffer for off-screen-buffer, make another
      +   renderbuffer object and attach to framebuffer using
      +   glFramebufferRenderbuffer()
      +*/
      +void
      +createFbo()
       {
      -   GLuint colorTex, depthRbo, newFbo;
      -
      -   // Size of texture and renderbuffer object
      -   // Check whether GL_MAX_RENDERBUFFER_SIZE >= width and height
      -   // using glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxSize)
      -   GLint  texWidth = 256, texHeight = 256;
      -
      -   // Generate texture object
      -   glGenTextures(1, &colorTex);
      -   glBindTexture(GL_TEXTURE_2D, colorTex);
      -   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
      -                texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
      -
      -   // Set texture wrapping and filtering mode
      -   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
      -   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      -   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
      -   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
      -
      -   // Generate renderbuffer object
      -   glGenRenderbuffers(1, &depthRbo);
      -   glBindRenderbuffer(GL_RENDERBUFFER, depthRbo);
      -   glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,  
      -                         texWidth, texWidth); // 16-bit depthbuffer
      -
      -   // Generate framebuffer object and bind texture and renderbuffer object to attachment points
      -   glGenFramebuffers(1, &newFbo);
      -   glBindFramebuffer(GL_FRAMEBUFFER, newFbo);
      -   glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 
      -                          GL_TEXTURE_2D, colorTex, 0);
      -   glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 
      -                             GL_RENDERBUFFER, depthRbo);
      -
      -   // Check for framebuffer complete
      -   if (glCheckFramebufferStatus(GL_FRAMEBUFFER) 
      -       != GL_FRAMEBUFFER_COMPLETE) 
      -   {
      -      dlog_print(DLOG_ERROR, LOG_TAG, "FrameBufferObject is not complete!\n");
      -   }
      -
      -   glBindFramebuffer(GL_FRAMEBUFFER, 0);
      +    GLuint colorTex, depthRbo, newFbo;
      +
      +    /* Size of texture and renderbuffer object */
      +    /* 
      +       Check whether GL_MAX_RENDERBUFFER_SIZE >= width and height
      +       using glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxSize)
      +    */
      +    GLint  texWidth = 256, texHeight = 256;
      +
      +    /* Generate texture object */
      +    glGenTextures(1, &colorTex);
      +    glBindTexture(GL_TEXTURE_2D, colorTex);
      +    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
      +                 texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
      +
      +    /* Set texture wrapping and filtering mode */
      +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
      +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
      +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
      +
      +    /* Generate renderbuffer object */
      +    glGenRenderbuffers(1, &depthRbo);
      +    glBindRenderbuffer(GL_RENDERBUFFER, depthRbo);
      +    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
      +                          texWidth, texWidth); /* 16-bit depthbuffer */
      +
      +    /* Generate framebuffer object and bind texture and renderbuffer object to attachment points */
      +    glGenFramebuffers(1, &newFbo);
      +    glBindFramebuffer(GL_FRAMEBUFFER, newFbo);
      +    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
      +                           GL_TEXTURE_2D, colorTex, 0);
      +    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
      +                              GL_RENDERBUFFER, depthRbo);
      +
      +    /* Check for framebuffer complete */
      +    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
      +        dlog_print(DLOG_ERROR, LOG_TAG, "FrameBufferObject is not complete!\n");
      +
      +    glBindFramebuffer(GL_FRAMEBUFFER, 0);
       }
       
      @@ -146,48 +147,46 @@ createFbo()

      The Texturing topic presents how to create texture objects using GL APIs. For using a cube map texture, provide GL_TEXTURE_CUBE_MAP instead of GL_TEXTURE_2D for the glGenTexture() and glBindTexture() functions.

      The following code creates a cube map texture for environment mapping:

      -void 
      -ImlRenderer::CreateCubeTex(const TexData *cubeTex, GLuint &target) 
      +void
      +ImlRenderer::CreateCubeTex(const TexData *cubeTex, GLuint &target)
       {
      -   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
      -   checkGlError("glPixelStorei");
      -   glGenTextures(1, &target);
      -   checkGlError("glGenTextures");
      -
      -   glBindTexture(GL_TEXTURE_CUBE_MAP, target);
      -   checkGlError("glBindTexture");
      -
      -   for (int i = 0; i < 6; ++i) 
      -   {
      -      TexBuffer((GLenum)GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, cubeTex[i]);
      -   }
      -
      -   glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
      -   checkGlError("glGenerateMipmap");
      -
      -   glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, 
      -                   GL_LINEAR_MIPMAP_LINEAR);
      -   checkGlError("glTexParameteri");
      -   glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      -   checkGlError("glTexParameteri");
      -
      -   glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
      -   checkGlError("glTexParameteri");
      -   glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT);
      -   checkGlError("glTexParameteri");
      -
      -   glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
      +    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
      +    checkGlError("glPixelStorei");
      +    glGenTextures(1, &target);
      +    checkGlError("glGenTextures");
      +
      +    glBindTexture(GL_TEXTURE_CUBE_MAP, target);
      +    checkGlError("glBindTexture");
      +
      +    for (int i = 0; i < 6; ++i)
      +        TexBuffer((GLenum)GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, cubeTex[i]);
      +
      +    glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
      +    checkGlError("glGenerateMipmap");
      +
      +    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,
      +                    GL_LINEAR_MIPMAP_LINEAR);
      +    checkGlError("glTexParameteri");
      +    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      +    checkGlError("glTexParameteri");
      +
      +    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
      +    checkGlError("glTexParameteri");
      +    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT);
      +    checkGlError("glTexParameteri");
      +
      +    glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
       }
       
      -void 
      +void
       ImlRenderer::TexBuffer(GLenum type, const TexData& newTex)
       {
      -   LOGI("ImlRenderer::TexBuffer");
      +    LOGI("ImlRenderer::TexBuffer");
       
      -   glTexImage2D(type, 0, newTex.format, newTex.width, newTex.height, 0,
      -                (GLenum)newTex.format, GL_UNSIGNED_BYTE, (void*)newTex.pixels);
      +    glTexImage2D(type, 0, newTex.format, newTex.width, newTex.height, 0,
      +                 (GLenum)newTex.format, GL_UNSIGNED_BYTE, (void*)newTex.pixels);
       
      -   checkGlError("glTexImage2D");
      +    checkGlError("glTexImage2D");
       }
       

      In the above code, see GL_TEXTURE_CUBE_MAP_POSITIVE_X, a parameter of the TexBuffer() function. It represents which side of the environment is contained in the cube map texture.

      @@ -201,16 +200,16 @@ uniform vec3 eyePos; varying vec3 v_normal; varying vec2 v_texCoord; -void -main() +void +main() { -   vec3 nor = normalize(v_normal); -   vec3 ray = normalize(eyePos); +    vec3 nor = normalize(v_normal); +    vec3 ray = normalize(eyePos); -   vec3 reflec = 2.0 * nor * dot(nor, ray) - ray; -   vec4 envColor = textureCube(s_texCube, reflec); +    vec3 reflec = 2.0 * nor * dot(nor, ray) - ray; +    vec4 envColor = textureCube(s_texCube, reflec); -   gl_FragColor = envColor; +    gl_FragColor = envColor; }
      @@ -224,7 +223,7 @@ main()

      The surface normal of a polygon mesh is computed per vertex at the modeling stage. It is the vertex normal. The tangent space is constructed per vertex so that its Z axis corresponds to the vertex normal, as shown in the right side of the above figure.

      -

      Three orthonormal vectors define the tangent space:

      +

      3 orthonormal vectors define the tangent space:

      • Vertex normal denoted by N
      • Vector denoted by T (for tangent)
      • @@ -250,22 +249,22 @@ varying vec2 v_texCoord; varying vec3 v_lightDirTS; varying vec3 v_viewTS; -void -main() +void +main() { -   vec4 world_pos = worldMat * vec4(position, 1.0); -   gl_Position = projMat * viewMat * world_pos; -   v_texCoord = texCoord; - -   vec3 nor = mat3(worldMat) * normal; -   vec3 tan = mat3(worldMat) * normalize(tangent); -   vec3 bin = cross(nor, tan); -   mat3 worldToTangentSpace = mat3(tan.x, bin.x, nor.x, -                                   tan.y, bin.y, nor.y, -                                   tan.z, bin.z, nor.z); - -   v_lightDirTS = worldToTangentSpace * (lightPos - world_pos.xyz) ; -   v_viewTS = worldToTangentSpace * (eyePos - world_pos.xyz); +    vec4 world_pos = worldMat * vec4(position, 1.0); +    gl_Position = projMat * viewMat * world_pos; +    v_texCoord = texCoord; + +    vec3 nor = mat3(worldMat) * normal; +    vec3 tan = mat3(worldMat) * normalize(tangent); +    vec3 bin = cross(nor, tan); +    mat3 worldToTangentSpace = mat3(tan.x, bin.x, nor.x, +                                    tan.y, bin.y, nor.y, +                                    tan.z, bin.z, nor.z); + +    v_lightDirTS = worldToTangentSpace * (lightPos - world_pos.xyz); +    v_viewTS = worldToTangentSpace * (eyePos - world_pos.xyz); }
      @@ -283,12 +282,12 @@ varying vec3 v_viewTS; vec3 phongLightFragNormal(vec3 Md, vec3 normal); -void -main() +void +main() { -   vec3 md = texture2D(s_tex0, v_texCoord).xyz; -   vec3 tanNor = normalize(texture2D(s_texNor, v_texCoord).xyz * 2.0 - vec3(1.0)); -   gl_FragColor = vec4(phongLightFragNormal(md, tanNor), 1.0); +    vec3 md = texture2D(s_tex0, v_texCoord).xyz; +    vec3 tanNor = normalize(texture2D(s_texNor, v_texCoord).xyz * 2.0 - vec3(1.0)); +    gl_FragColor = vec4(phongLightFragNormal(md, tanNor), 1.0); }
      diff --git a/org.tizen.guides/html/native/graphics/assembly_n.htm b/org.tizen.guides/html/native/graphics/assembly_n.htm index 52ae8b8..84cc2b7 100644 --- a/org.tizen.guides/html/native/graphics/assembly_n.htm +++ b/org.tizen.guides/html/native/graphics/assembly_n.htm @@ -81,9 +81,9 @@

      Figure: Color-interpolated triangles

      Color-interpolated triangles

      -

      In reality, however, the per-vertex attributes rarely include colors. In general, vertex normals and texture coordinates are interpolated. The following figure visualizes the interpolated normals. These per-fragment attributes are passed to the fragment shader.

      +

      In reality, however, the per-vertex attributes rarely include colors. In general, vertex normals and texture coordinates are interpolated. The following figure visualizes the interpolated normals, where the per-vertex normals (in blue) are first interpolated along the triangle edges (in green) and then interpolated along the scanlines (in red). These per-fragment attributes are passed to the fragment shader.

      -

      Figure: Interpolated normals (the blue per-vertex normals are first interpolated along the green triangle edges and then interpolated along the red scanlines)

      +

      Figure: Interpolated normals

      Interpolated normals

      diff --git a/org.tizen.guides/html/native/graphics/cairo_n.htm b/org.tizen.guides/html/native/graphics/cairo_n.htm index 19c35e9..beecb08 100644 --- a/org.tizen.guides/html/native/graphics/cairo_n.htm +++ b/org.tizen.guides/html/native/graphics/cairo_n.htm @@ -39,16 +39,18 @@

      Cairo

      -

      Cairo is a famous 2D graphics library with support for multiple output devices. It provides powerful drawing operations to create a graphical experience that you desire, including stroking, filling, compositing images, text rendering, and any affine transforms (such as scale, rotation, and shear). Within the Tizen, cairo is able to output to 2 different backends: Image and GL backend.

      +

      Cairo is a famous 2D graphics library with support for multiple output devices. It provides powerful drawing operations to create a graphical experience that you desire, including stroking, filling, compositing images, and any affine transforms (such as scale, rotation, and shear). You can also render text with Cairo. Within the Tizen framework, Cairo is able to output to 2 different backends: Image and GL backend.

      + +

      Before you start, remember to prepare your application to use the Cairo functionality.

      Cairo in Tizen

      -

      Cairo belongs to the Graphics layer in Tizen. As shown in the following figure, the rendering functionality of cairo is provided through the use of the APIs of the lower modules, such as Pixman or OpenGL ES.

      +

      Cairo belongs to the Graphics layer in Tizen. As shown in the following figure, the rendering functionality of Cairo is provided through the use of the APIs of the lower modules, such as Pixman or OpenGL ES.

      -

      Figure: Cairo within the Tizen

      -

      Cairo within the Tizen

      +

      Figure: Cairo within the Tizen framework

      +

      Cairo within the Tizen framework

      -

      The cairo GL backend allows hardware-accelerated rendering by targeting the OpenGL ES API. The goal of the cairo GL backend is to achieve better performance with equal functionality to the cairo Image backend, whenever possible.

      +

      The Cairo GL backend allows hardware-accelerated rendering by targeting the OpenGL ES API. The goal of the Cairo GL backend is to achieve better performance with equal functionality to the Cairo Image backend, whenever possible.

      @@ -56,20 +58,20 @@ - +
      Note
      Since Tizen only exposes EvasGL binding in place of EGL, cairo EvasGL APIs have been newly added and specified. To use the cairo GL backend in Tizen, an application must include in its source code the cairo-evas-gl.h header file instead of cairo-gl.h.Since Tizen only exposes EvasGL binding in place of EGL, Cairo EvasGL APIs have been newly added and specified. To use the Cairo GL backend in Tizen, an application must include in its source code the cairo-evas-gl.h header file instead of cairo-gl.h.

      Creating a Cairo Surface Linked with an Evas Object

      -

      To display the rendered output using cairo APIs, an application must link a Cairo surface with an Evas object. In this context, the cairo surface is an object that can hold the rendered result within cairo. Cairo can draw an image on the surface appropriate for a particular backend, and Evas can access the image data from the cairo surface.

      +

      To display the rendered output using Cairo APIs, an application must link a Cairo surface with an Evas object. In this context, the Cairo surface is an object that can hold the rendered result within Cairo. Cairo can draw an image on the surface appropriate for a particular backend, and Evas can access the image data from the Cairo surface.

      -

      Creating a Cairo Image Surface in Evas GL Backend

      +

      Creating a Cairo Image Surface in the Evas GL Backend

      To develop an application with Elementary, you create a window by using the elementary utility function, elm_win_util_standard_add(). And, in order to make the GL application use the GPU, you must call the elm_config_accel_preference_set() function before creating the window.

      -

      In the cairo Image backend, you can create a new cairo image surface by using the cairo_image_surface_create() or cairo_image_surface_create_for_data() function. The former function requires only the pixel format and dimensions to be specified, while the latter function requires additional data, such as a pointer to an image buffer (supplied by the application) in which to write the content. In order to display a result of cairo rendering, you must also link an Evas image object to the created cairo image surface. For this purpose, use the evas_object_image_data_set() function.

      +

      In the Cairo Image backend, you can create a new Cairo image surface by using the cairo_image_surface_create() or cairo_image_surface_create_for_data() function. The former function requires only the pixel format and dimensions to be specified, while the latter function requires additional data, such as a pointer to an image buffer (supplied by the application) in which to write the content. In order to display a result of Cairo rendering, you must also link an Evas image object to the created Cairo image surface. For this purpose, use the evas_object_image_data_set() function.

      To create the image surface:

      @@ -93,7 +95,7 @@ evas_object_show(img); cairo_surface_t *cairo_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT); cairo_t *cairo = cairo_create(cairo_surface); -// Cairo drawing +/* Cairo drawing */ cairo_surface_flush(cairo_surface); @@ -106,7 +108,7 @@ evas_object_image_data_update_add(img, 0, 0, WIDTH, HEIGHT);
    • With the cairo_image_surface_create_for_data() function.

      To use the function, you need a pointer to an image data, which can be retrieved with the evas_object_image_data_get() function. The function returns the data pointer of an image object and requires a parameter to determine whether the data is modified. If modification is enabled by setting the parameter to EINA_TRUE, Evas updates the image pixels in the next rendering cycle. Finally, you can link the pixel buffer with the image object by using the evas_object_image_data_set() function.

      -

      Since the default backend for Evas is GL, the cairo Image backend is much slower due to the memory copy operation, which occurs whenever the rendered result from Cairo is uploaded to Evas. To enhance the performance of Cairo Image backend to enable the zero copy feature, set the EVAS_IMAGE_CONTENT_HINT_DYNAMIC property with the evas_object_image_content_hint_set() function. For more information, see Optimizing Evas.

      +

      Since the default backend for Evas is GL, the Cairo Image backend is much slower due to the memory copy operation, which occurs whenever the rendered result from Cairo is uploaded to Evas. To enhance the performance of Cairo Image backend to enable the zero copy feature, set the EVAS_IMAGE_CONTENT_HINT_DYNAMIC property with the evas_object_image_content_hint_set() function. For more information, see Optimizing Evas.

      To update a rectangular region on the screen, the evas_object_image_data_update_add() function can be used. For more information about the image object functions of Evas, see Image Objects.

      @@ -123,10 +125,10 @@ evas_object_image_alpha_set(img, 0); evas_object_show(img); int row_stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, WIDTH); -unsigned char *imageData = (unsigned char *) evas_object_image_data_get(img, EINA_TRUE); -cairo_surface_t *cairo_surface = cairo_image_surface_create_for_data(imageData, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, row_stride); +unsigned char *imageData = (unsigned char *)evas_object_image_data_get(img, EINA_TRUE); +cairo_surface_t *cairo_surface = cairo_image_surface_create_for_data(imageData, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, row_stride); cairo_t *cairo = cairo_create(cairo_surface); -// Cairo drawing +/* Cairo drawing */ cairo_surface_flush(cairo_surface); @@ -142,17 +144,19 @@ evas_object_image_data_update_add(img, 0, 0, WIDTH, HEIGHT); Note - Take care when using the evas_object_image_data_set() function. You must match the evas_object_image_data_get() and evas_object_image_data_set() functions as a pair. Since the evas_object_image_data_get() function keeps a rendering sink, the rendered result with cairo can be reflected outside the Evas area, if the functions are not matched. + Take care when using the evas_object_image_data_set() function. You must match the evas_object_image_data_get() and evas_object_image_data_set() functions as a pair. Since the evas_object_image_data_get() function keeps a rendering sink, the rendered result with Cairo can be reflected outside the Evas area, if the functions are not matched.

      Creating a Cairo GL Surface in the Evas GL Backend

      +

      With the Cairo GL backend, you can create a Cairo surface using OpenGL.

      +

      To create the GL surface:

        -
      1. Since an application utilizing the cairo GL backend in Tizen is based on Evas GL, an Evas GL handler must be created with the evas_gl_new() function during the initial stage. +
      2. Since an application utilizing the Cairo GL backend in Tizen is based on Evas GL, an Evas GL handler must be created with the evas_gl_new() function during the initial stage.

        Afterwards, the evas_gl_config, evas_gl_surface, and evas_gl_context instances are created in that order. For more information on using Evas GL, see Creating OpenGL ES Applications and OpenGL ES Tutorial.

        @@ -174,7 +178,7 @@ evas_object_image_native_surface_set(img, &ns);
    • -
    • In Tizen, for the purpose of showing the rendered output on screen, a cairo GL application can use evas_object_image_pixels_dirty_set() function. This function allows the rendered result to be redrawn on the screen for every animator callback in the default update refresh rate. The rendered results are saved inside the Evas object (in this example, the img object) connected to the cairo GL backend during the cairo drawing. +
    • A Cairo GL application can use the evas_object_image_pixels_dirty_set() function in Tizen to show the rendered output on the screen. This function allows the rendered result to be redrawn on the screen for every animator callback in the default update refresh rate. The rendered results are saved inside the Evas object (in this example, the img object) connected to the Cairo GL backend during the Cairo drawing.
       evas_object_image_pixels_dirty_set(img, EINA_TRUE);
      @@ -182,16 +186,16 @@ evas_object_image_pixels_get_callback_set(img, cairo_drawing, 0);
       
    • -
    • If your application employs the cairo GL backend in Tizen, include the cairo-evas-gl.h header file instead of cairo-gl.h.
    • +
    • If your application employs the Cairo GL backend in Tizen, include the cairo-evas-gl.h header file instead of cairo-gl.h.
    • To fully use the GPU acceleration, set the CAIRO_GL_COMPOSITOR property to MSAA. -

      In addition, call the cairo_gl_device_set_thread_aware() function with cairo_device and 0 as input parameters to prevent unnecessary context switches. Cairo can be used in multithreaded environments, and switches out the current GL context by default after each draw finishes. Therefore, if no other thread uses cairo for GL rendering, set the thread_aware parameter to 0.

      +

      In addition, call the cairo_gl_device_set_thread_aware() function with cairo_device and 0 as input parameters to prevent unnecessary context switches. Cairo can be used in multithreaded environments, and switches out the current GL context by default after each draw finishes. Therefore, if no other thread uses Cairo for GL rendering, set the thread_aware parameter to 0.

      -

      To create the cairo GL surface with the cairo_gl_surface_create_for_evas_gl() function, a cairo_device and an evas_gl_surface must be created beforehand:

      +

      To create the Cairo GL surface with the cairo_gl_surface_create_for_evas_gl() function, a cairo_device and an evas_gl_surface must be created beforehand:

      • A cairo_device can be created with the cairo_evas_gl_device_create() function, which is an interface to the underlying rendering system. You also need the evas_gl_object and evas_gl_context as input parameters to the cairo_evas_gl_device_create() function.
      • -
      • A evas_gl_surface object is needed to render 2D graphics through the rendering functionality of the cairo GL backend.
      • +
      • A evas_gl_surface object is needed to render 2D graphics through the rendering functionality of the Cairo GL backend.
      @@ -201,11 +205,11 @@ cairo_boot_t thread_aware = 0;
       cairo_gl_device_set_thread_aware(cairo_device, thread_aware);
       cairo_surface_t *cairo_surface = cairo_gl_surface_create_for_evas_gl(cairo_device, evas_gl_surface, evas_gl_config, WIDTH, HEIGHT);
       cairo_t *cairo = cairo_create(cairo_surface);
      -// Cairo drawing
      +/* Cairo drawing */
       
    • -
    • When any drawing with the cairo API is finished, call the cairo_surface_flush() function. It guarantees a complete rendered result, because it does any pending drawing for the surface and also restores any temporary modifications cairo has made to the surface state. Specially, this function must be called before switching from drawing on the surface with cairo to drawing on it directly with native APIs. +
    • When any drawing with the Cairo API is finished, call the cairo_surface_flush() function. It guarantees a complete rendered result, because it does any pending drawing for the surface and also restores any temporary modifications Cairo has made to the surface state. Specially, this function must be called before switching from drawing on the surface with Cairo to drawing on it directly with native APIs.
       cairo_surface_flush(cairo_surface);
      @@ -215,18 +219,18 @@ cairo_surface_flush(cairo_surface);
       
       

      Drawing with Cairo

      -

      Drawing with Cairo to a surface is accomplished by calling the common backend interface functions. These rendering functions must be called properly for each backend. For more information about the common rendering functions, see the Cairo: A Vector Graphics Library manual.

      +

      Drawing with Cairo to a surface is accomplished by calling the common backend interface functions. These rendering functions must be called properly for each backend. For more information about the common rendering functions, see the Cairo: A Vector Graphics Library manual.

      -

      The following sections introduce a general example for drawing a line using cairo APIs, including some special guidelines. Occasionally, you need to adhere to special guidelines to overcome any cairo drawing limitations in Tizen.

      +

      The following sections introduce a general example for drawing a line using Cairo APIs, including some special guidelines. Occasionally, you need to adhere to special guidelines to overcome any Cairo drawing limitations in Tizen.

      Using a Surface to Source Pattern

      -

      Within the cairo API, some functions, such as cairo_set_source_surface() and cairo_mask_surface(), use a surface to set the source pattern. However, the performance of these functions in Tizen, under certain circumstances, can be heavily degraded if the source surface is created using the cairo_gl_surface_create_for_evas_gl() function.

      +

      Within the Cairo API, some functions, such as cairo_set_source_surface() and cairo_mask_surface(), use a surface to set the source pattern. However, the performance of these functions in Tizen, under certain circumstances, can be heavily degraded if the source surface is created using the cairo_gl_surface_create_for_evas_gl() function.

      -

      In Tizen, you can create a cairo GL surface with either the cairo_gl_surface_create() or cairo_gl_surface_create_for_evas_gl() function. To prevent performance issues, always create the source surface with the cairo_gl_surface_create() function.

      +

      In Tizen, you can create a Cairo GL surface with either the cairo_gl_surface_create() or cairo_gl_surface_create_for_evas_gl() function. To prevent performance issues, always create the source surface with the cairo_gl_surface_create() function.

      -// Create a surface for destination
      +/* Create a surface for destination */
       cairo_surface_t *cairo_surface = cairo_gl_surface_create_for_evas_gl(cr, evas_gl_surface, evas_gl_config, WIDTH, HEIGHT);
       
       Evas_GL_Config *evas_gl_config_source = evas_gl_config_new();
      @@ -235,7 +239,7 @@ evas_gl_config_source->stencil_bits = EVAS_GL_STENCIL_BIT_1;
       evas_gl_config_source->multisample_bits = EVAS_GL_MULTISAMPLE_LOW;
       evas_gl_surface_source = evas_gl_surface_create(evas_gl, evas_gl_config_source, WIDTH, HEIGHT);
       
      -// Create a surface for source
      +/* Create a surface for source */
       cairo_surface_t *image_surface = cairo_image_surface_create_from_png(image);
       cairo_surface_t *gl_surface = cairo_gl_surface_create(cairo_device, CAIRO_CONTENT_COLOR_ALPHA, image_width, image_height);
       cairo_t *cairo = cairo_create(gl_surface);
      @@ -246,7 +250,7 @@ cairo_pattern_create_for_surface(gl_surface);
       
       

      Support for Reading Various Image Files

      -

      Cairo does not support a functionality for reading image files in JPEG or SPI format; only PNG is supported. With a PNG file, you can use the cairo_image_surface_create_from_png() function to make a new image surface from the image. However, handle this function with care, because it is experimental and only offers very simple functionality for reading PNG files.

      +

      Cairo does not support a functionality for reading image files in JPEG or SPI format; only PNG is supported. With a PNG file, you can use the cairo_image_surface_create_from_png() function to make a new image surface from the image. However, handle this function with care, because it is experimental and only offers very simple functionality for reading PNG files.

       cairo_surface_t *image = cairo_image_surface_create_from_png("test_image.png");
      @@ -255,7 +259,7 @@ cairo_paint(cairo);
       cairo_surface_destroy(image);
       
      -

      On the other hand, cairo applications in Tizen can read JPEG and other image formats by using the Evas APIs. Evas supports image loaders for various formats as plug-in modules:

      +

      On the other hand, Cairo applications in Tizen can read JPEG and other image formats by using the Evas APIs. Evas supports image loaders for various formats as plug-in modules:

      1. Create an image buffer as a temporary buffer for decoding an image file with the evas_object_image_add() function.
      2. Use the evas_object_image_file_set() function to set the image file on the object (in this example, the decoded_img object).
      3. @@ -263,12 +267,12 @@ cairo_surface_destroy(image);
      -evas_object_geometry_get(win, NULL, NULL, &surface_w, &surface_h);  
      +evas_object_geometry_get(win, NULL, NULL, &surface_w, &surface_h);
       Evas_Object *inline_buffr = elm_win_add(win, "Img Read", ELM_WIN_INLINED_IMAGE);
       evas_object_move(inline_buffr, 0, 0);
       evas_object_resize(inline_buffr, surface_w, surface_h);
       
      -Evas_Object *decoded_img = evas_object_image_add(evas_object_evas_get(inline_buffer)); // As a temporary buffer
      +Evas_Object *decoded_img = evas_object_image_add(evas_object_evas_get(inline_buffer)); /* As a temporary buffer */
       evas_object_image_file_set(decoded_img, "test_image.jpeg", NULL);
       evas_object_image_size_get(decoded_img, &w, &h);
       evas_object_image_fill_set(decoded_img, 0, 0, w, h);
      @@ -276,27 +280,27 @@ evas_object_image_filled_set(decoded_img, EINA_TRUE);
       evas_object_resize(decoded_img, w, h);
       
      -

      After the image file reading is complete, you can create a cairo surface for the image object by using the evas_object_image_data_get() and cairo_image_surface_create_for_data() functions. The cairo surface is used to create a pattern with the cairo_set_source_surface() function for the cairo drawing. In addition, to prevent memory leaks, delete the temporary buffers that are no longer used.

      +

      After the image file reading is complete, you can create a Cairo surface for the image object by using the evas_object_image_data_get() and cairo_image_surface_create_for_data() functions. The Cairo surface is used to create a pattern with the cairo_set_source_surface() function for the Cairo drawing. In addition, to prevent memory leaks, delete the temporary buffers that are no longer used.

       src_buffer = (unsigned char *)evas_object_image_data_get(decoded_img, EINA_TRUE);
      -cairo_surface_t *source = cairo_image_surface_create_for_data(src_buffer, CAIRO_FORMAT_ARGB32, w, h, 
      +cairo_surface_t *source = cairo_image_surface_create_for_data(src_buffer, CAIRO_FORMAT_ARGB32, w, h,
                                                                     evas_object_image_stride_get(decoded_img));
       cairo_set_source_surface(cr, source, 0, 0);
       cairo_paint(cr);
       
      -evas_object_del (inline_buffr);
      +evas_object_del(inline_buffr);
       cairo_surface_destroy(img);
       

      Drawing a Line

      -

      Now, the general example will be introduced. The following example creates a line drawing with a rectangle, and a path that uses straight sections, arcs, and Bézier curves.

      +

      The following example creates a line drawing with a rectangle, and a path that uses straight sections, arcs, and Bézier curves.

      Figure: Rectangle and path drawing with Cairo

      Rectangle and path drawing with Cairo

      -

      To draw lines with cairo APIs:

      +

      To draw lines with Cairo APIs:

      1. Set the line width and color. @@ -365,21 +369,21 @@ cairo_rectangle(cairo, 0, 0, 400, 400);
    • -
    • If you need to create a stroke on a path, the cairo_stroke() function is a drawing operator that draws a stroke on the current path in accordance to the current line width and line color. After the function call, the current path is cleared from the cairo context. +
    • If you need to create a stroke on a path, the cairo_stroke() function is a drawing operator that draws a stroke on the current path in accordance to the current line width and line color. After the function call, the current path is cleared from the Cairo context.
       cairo_stroke(cairo);
       
    • -
    • To ensure that any pending cairo operations are drawn, use the cairo_surface_flush() function after finishing the cairo drawing: +
    • To ensure that any pending Cairo operations are drawn, use the cairo_surface_flush() function after finishing the Cairo drawing:
       cairo_surface_flush(surface);
       
    • -
    • Destroy the cairo objects when you terminate the application: +
    • Destroy the Cairo objects when you terminate the application:
       cairo_destroy(cairo);
      @@ -410,4 +414,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga
       
       
       
      -
      +
      \ No newline at end of file
      diff --git a/org.tizen.guides/html/native/graphics/creating_opengles_n.htm b/org.tizen.guides/html/native/graphics/creating_opengles_n.htm
      index 5bb4f23..7f60256 100644
      --- a/org.tizen.guides/html/native/graphics/creating_opengles_n.htm
      +++ b/org.tizen.guides/html/native/graphics/creating_opengles_n.htm
      @@ -35,7 +35,7 @@
       
       

      The following example shows the steps to create a GL application. From now on, the Elm_GLView component is shortened to GLView.

        -
      1. Create a basic application as presented in the HelloWorld example. +
      2. Create a basic application as presented in the mobile and wearable Tizen first application example.

        The UI application's skeleton makes available the window object, which can contain the GLView component.

      3. Enable hardware acceleration.

        To develop a GL application, call the elm_config_accel_preference_set() function before creating the window. It makes an application use the GPU.

        @@ -57,18 +57,21 @@ win = elm_win_util_standard_add(name, "OpenGL example");

        For more information, see the _Elm_GLView_mode enumerator (in mobile and wearable applications).

        In the following example, the alpha channel and depth buffer are enabled.

        -// Request a surface with alpha and a depth buffer elm_glview_mode_set(glview, ELM_GLVIEW_ALPHA | ELM_GLVIEW_DEPTH);
        +/* Request a surface with alpha and a depth buffer */
        +elm_glview_mode_set(glview, ELM_GLVIEW_ALPHA | ELM_GLVIEW_DEPTH);
         

        Additionally, you can select the policies for resizing and rendering. The following example shows how to decide what to do with the GL surface when the GLView component is resized. With the default ELM_GLVIEW_RESIZE_POLICY_RECREATE option, the GL surface is destroyed and created again with the new size. The resizing policy can also be set to ELM_GLVIEW_RESIZE_POLICY_SCALE. In that case, only the image object is scaled, not the underlying GL surface.

        -// The resize policy tells GLView what to do with the surface when it
        -// resizes. ELM_GLVIEW_RESIZE_POLICY_RECREATE tells it to
        -// destroy the current surface and recreate it to the new size
        +/*
        +   Resize policy tells GLView what to do with the surface when it
        +   resizes. ELM_GLVIEW_RESIZE_POLICY_RECREATE tells it to
        +   destroy the current surface and recreate it to the new size
        +*/
         elm_glview_resize_policy_set(glview, ELM_GLVIEW_RESIZE_POLICY_RECREATE);
         
      4. Get the GL function pointer. -

        Originally, an application must call the GL APIs using the Evas_GL abstraction layer in EFL. It means that you must get a set of function pointers for abstract GL functions from the Evas_GL object and call functions through the object. This can be annoying, especially when you want to re-use GL parts implemented at other platforms. To resolve this problem, EFL provides convenient helper macros, which are defined in the Elementary_GL_Helpers.h header file. The following example shows how to use the macros.

        +

        Originally, an application must call the GL APIs using the Evas_GL abstraction layer in EFL. It means that you must get a set of function pointers for abstract GL functions from the Evas_GL object and call functions through the object. This can be annoying, especially when you want to reuse GL parts implemented at other platforms. To resolve this problem, EFL provides convenient helper macros, which are defined in the Elementary_GL_Helpers.h header file. The following example shows how to use the macros.

         #include <Elementary_GL_Helpers.h>
         ELEMENTARY_GLVIEW_GLOBAL_DEFINE();
        @@ -76,13 +79,13 @@ ELEMENTARY_GLVIEW_GLOBAL_DEFINE();
         static Evas_Object*
         add_glview(Evas_Object* parent, appdata_s *ad)
         {
        -   Evas_Object* glview;
        +    Evas_Object* glview;
         
        -   // Create and initialize GLView
        -   glview = elm_glview_add(parent);
        +    /* Create and initialize GLView */
        +    glview = elm_glview_add(parent);
         
        -   // Prepare to use OpenGL ES APIs directly
        -   ELEMENTARY_GLVIEW_GLOBAL_USE(glview);
        +    /* Prepare to use OpenGL ES APIs directly */
        +    ELEMENTARY_GLVIEW_GLOBAL_USE(glview);
         }
         

        The ELEMENTARY_GLVIEW_GLOBAL_DEFINE() and ELEMENTARY_GLVIEW_GLOBAL_USE() macros must be in the same source code. If you have a global header file in your application, the ELEMENTARY_GLVIEW_GLOBAL_DECLARE() macro can be in the header file. However, you must be very careful when using these macros. The recommended solution is to use the ELEMENTARY_GLVIEW_USE() macro in every client function. The following are some situations where you must not use the helper macros:

        @@ -101,70 +104,71 @@ add_glview(Evas_Object* parent, appdata_s *ad)
      5. Set up callback functions.

        When you use the GLView component, you can set up necessary callback functions, which are called in the main loop to render a scene.

        -// Initialization callback
        +/* Initialization callback */
         elm_glview_init_func_set(glview, init_glview);
        -// Resizing callback
        +/* Resizing callback */
         elm_glview_resize_func_set(glview, resize_glview);
        -// Drawing callback
        +/* Drawing callback */
         elm_glview_render_func_set(glview, draw_glview);
        -// Deletion callback
        +/* Deletion callback */
         elm_glview_del_func_set(glview, del_glview);
         
        1. Set up the initialization callback.

          The initialization callback is called when the GLView is created.

          -// GL init callback
          -static void 
          +/* GL init callback */
          +static void
           init_glview(Evas_Object *glview)
           {
          -   // Set GL state color to pink
          -   glClearColor(1.0, 0.2, 0.6, 1.0);
          +    /* Set GL state color to pink */
          +    glClearColor(1.0, 0.2, 0.6, 1.0);
           
          -   // Do any form of OpenGL ES initialization here
          -   // init_shaders();
          -   // init_vertices();
          +    /* Do any form of OpenGL ES initialization here */
          +    /* init_shaders(); */
          +    /* init_vertices(); */
           }
           
        2. Set up the resizing callback.

          The resizing callback is called whenever the GLView component is resized. A common action is to reset the viewport. Because the GLView size can be changed by a parent container, you must set up a resizing callback and reset the viewport size with the new GLView size.

          -// GLView resize callback
          -static void 
          +/* GLView resize callback */
          +static void
           resize_glview(Evas_Object *glview)
           {
          -   int w, h;
          -   elm_glview_size_get(glview, &w, &h);
          -   glViewport(0, 0, w, h);
          +    int w;
          +    int h;
          +    elm_glview_size_get(glview, &w, &h);
          +    glViewport(0, 0, w, h);
           }
           
        3. Set up the drawing callback.

          The drawing callback is called whenever the GLView must be updated. The GL draw commands must be made here.

          -// GL draw callback
          -static void 
          +/* GL draw callback */
          +static void
           draw_glview(Evas_Object *glview)
           {
          -   // Paint it pink
          -   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
          +    /* Paint it pink */
          +    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
           
          -   // The usual OpenGL ES draw commands come here
          -   // draw_scene();
          +    /* Usual OpenGL ES draw commands come here */
          +    /* draw_scene(); */
           }
           
        4. Set up the deletion callback.

          The deletion callback is triggered when the GLView is being destroyed. No other callback can be called on the same object afterwards.

          -// GLView deletion callback
          -static void 
          +/* GLView deletion callback */
          +static void
           del_glview(Evas_Object *glview)
           {
          -   // Destroy all the OpenGL ES resources here
          -   // destroy_shaders();
          -   // destroy_objects();
          +    /* Destroy all the OpenGL ES resources here */
          +    /* destroy_shaders(); */
          +    /* destroy_objects(); */
           }
           
        5. @@ -172,6 +176,20 @@ del_glview(Evas_Object *glview)
        + + + + + + + + + + +
        Note
        In case the GL functions are called outside the 4 GLView callback functions, you must call the evas_gl_make_current() function before the GL function is called. However, this results in a performance degradation due to context switching, and only works if the direct rendering mode is not used. +

        If Direct Rendering is enabled, all GL functions must be called from the 4 GLView callback functions only. All other operations can break the rendering order and cause unexpected rendering.

        +
        + diff --git a/org.tizen.guides/html/native/graphics/fragment_shader_n.htm b/org.tizen.guides/html/native/graphics/fragment_shader_n.htm index dbb777b..deaeb55 100644 --- a/org.tizen.guides/html/native/graphics/fragment_shader_n.htm +++ b/org.tizen.guides/html/native/graphics/fragment_shader_n.htm @@ -57,10 +57,10 @@ uniform sampler2D s_tex0; varying vec2 v_texCoord; -void -main() +void +main() { -   gl_FragColor = texture2D(s_tex0, v_texCoord); +    gl_FragColor = texture2D(s_tex0, v_texCoord); }
      @@ -68,7 +68,7 @@ main()

      Obviously, texturing alone is never enough to make an object look realistic. You need lighting or illumination, which refers to the technique handling the interaction between light sources and objects. The most popular real-time lighting technique is based on the Phong lighting model. It is composed of diffuse, specular, ambient, and emissive terms. For the sake of simplicity, this topic presents only the diffuse term. (For more information, see Phong reflection model in Wikipedia.)

      The diffuse term is for the reflections from ideally diffuse surfaces, which are scattered with equal intensity in all directions (see the left image in the following figure). The amount of reflection perceived by the eye is proportional to the amount of incoming light. Consider a normalized light vector (denoted by l) connecting the surface point and the light source. The amount of incoming light is inversely proportional to the angle between l and the surface normal n (as shown in the middle image), and is described as n⋅l. In order to avoid negative reflection, it is modified into max(n⋅l, 0).

      -

      Figure: Diffuse reflection

      +

      Figure: Diffuse reflection

      Diffuse reflection

      @@ -79,7 +79,7 @@ main() -

      The diffuse term combines the intensity and color: max(n⋅l, 0) sd ⊗ md where sd is the light source color and md is the object material color. The right side of the Vertex and fragment shader outputs figure shows an object lit with the diffuse term only.

      +

      The diffuse term combines the intensity and color: max(n⋅l, 0) sd ⊗ md where sd is the light source color and md is the object material color. The right side of the Diffuse reflection figure shows an object lit with the diffuse term only.

      Fragment Shader for Lighting and Texturing

      @@ -98,13 +98,13 @@ varying vec3 v_position; varying vec3 v_normal; varying vec2 v_texCoord; -void -main() +void +main() { -   gl_Position = viewProjMat * worldMat * vec4(position, 1.0); -   v_position = (worldMat * vec4(position, 1.0)).xyz; -   v_normal = mat3(worldMat) * normal; -   v_texCoord = texCoord; +    gl_Position = viewProjMat * worldMat * vec4(position, 1.0); +    v_position = (worldMat * vec4(position, 1.0)).xyz; +    v_normal = mat3(worldMat) * normal; +    v_texCoord = texCoord; } @@ -119,29 +119,29 @@ varying vec3 v_position; varying vec3 v_normal; varying vec2 v_texCoord; -vec3 phongDiffuse(vec3 Md); // Forward declaration +vec3 phongDiffuse(vec3 Md); /* Forward declaration */ -void -main() +void +main() { -   vec3 Md = texture2D(s_tex0, v_texCoord).xyz; -   vec3 phongColor = phongDiffuse(Md); +    vec3 Md = texture2D(s_tex0, v_texCoord).xyz; +    vec3 phongColor = phongDiffuse(Md); -   gl_FragColor = vec4(phongColor, 1.0); +    gl_FragColor = vec4(phongColor, 1.0); } -vec3 -phongDiffuse(vec3 Md) +vec3 +phongDiffuse(vec3 Md) { -   // Diffuse term of Phong model per fragment -   vec3 lightDirection = normalize(lightPos - v_position); -   vec3 nor = normalize(v_normal); +    /* Diffuse term of Phong model per fragment */ +    vec3 lightDirection = normalize(lightPos - v_position); +    vec3 nor = normalize(v_normal); -   // Diffuse term -   float Diffuse = max(dot(nor, lightDirection), 0.0); -   vec3 PhongDiffuse = Diffuse * Sd * Md; +    /* Diffuse term */ +    float Diffuse = max(dot(nor, lightDirection), 0.0); +    vec3 PhongDiffuse = Diffuse * Sd * Md; -   return PhongDiffuse; +    return PhongDiffuse; } diff --git a/org.tizen.guides/html/native/graphics/interactive_ui_n.htm b/org.tizen.guides/html/native/graphics/interactive_ui_n.htm index f72de02..482be4b 100644 --- a/org.tizen.guides/html/native/graphics/interactive_ui_n.htm +++ b/org.tizen.guides/html/native/graphics/interactive_ui_n.htm @@ -53,20 +53,19 @@

      The following code shows how to add callback functions to Evas_object. The parameters, EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_MOUSE_UP, and EVAS_CALLBACK_MOUSE_MOVE, represent the specific events for which callbacks must be called. These events are defined in Evas_Callback_Type.

      -static Evas_Object *
      +static Evas_Object*
       add_glview(Evas_Object *parent, appdata_s *ad)
       {
      -   Evas_Object *glview;
      +    Evas_Object *glview;
       
      -   // Create and initialize GLView
      -   glview = elm_glview_add(parent);
      +    /* Create and initialize GLView */
      +    glview = elm_glview_add(parent);
       
      +    /* Initialize elm_GLView and set the rendering callback functions */
       
      -   // Initialize elm_GLView and set the rendering callback functions
      -
      -   evas_object_event_callback_add(glview, EVAS_CALLBACK_MOUSE_DOWN, mouse_down_cb, ad);
      -   evas_object_event_callback_add(glview, EVAS_CALLBACK_MOUSE_UP, mouse_up_cb, ad);
      -   evas_object_event_callback_add(glview, EVAS_CALLBACK_MOUSE_MOVE, mouse_move_cb, ad);
      +    evas_object_event_callback_add(glview, EVAS_CALLBACK_MOUSE_DOWN, mouse_down_cb, ad);
      +    evas_object_event_callback_add(glview, EVAS_CALLBACK_MOUSE_UP, mouse_up_cb, ad);
      +    evas_object_event_callback_add(glview, EVAS_CALLBACK_MOUSE_MOVE, mouse_move_cb, ad);
       }
       
    • @@ -75,39 +74,38 @@ add_glview(Evas_Object *parent, appdata_s *ad)

      The following code shows how to define the registered callback functions:

       static void
      -mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) 
      +mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
       {
      -   appdata_s *ad = (appdata_s *) data;
      -   ad->mouse_down = EINA_TRUE;
      -   elm_glview_changed_set(obj);
      +    appdata_s *ad = (appdata_s *)data;
      +    ad->mouse_down = EINA_TRUE;
      +    elm_glview_changed_set(obj);
       }
       
       static void
      -mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) 
      +mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
       {
      -   Evas_Event_Mouse_Move *ev;
      -   ev = (Evas_Event_Mouse_Move *) event_info;
      -   appdata_s *ad = (appdata_s *) data;
      -
      -   float dx = 0, dy = 0;
      -
      -   if (ad->mouse_down) 
      -   {
      -      dx = ev->cur.canvas.x - ev->prev.canvas.x;
      -      dy = ev->cur.canvas.y - ev->prev.canvas.y;
      -      ad->xangle += dy;
      -      ad->yangle += dx;
      -   }
      -   elm_glview_changed_set(obj);
      +    Evas_Event_Mouse_Move *ev;
      +    ev = (Evas_Event_Mouse_Move *)event_info;
      +    appdata_s *ad = (appdata_s *)data;
      +
      +    float dx = 0, dy = 0;
      +
      +    if (ad->mouse_down) {
      +        dx = ev->cur.canvas.x - ev->prev.canvas.x;
      +        dy = ev->cur.canvas.y - ev->prev.canvas.y;
      +        ad->xangle += dy;
      +        ad->yangle += dx;
      +    }
      +    elm_glview_changed_set(obj);
       }
       
       static void
      -mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) 
      +mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
       {
      -   appdata_s *ad = (appdata_s *) data;
      +    appdata_s *ad = (appdata_s *)data;
       
      -   ad->mouse_down = EINA_FALSE;
      -   elm_glview_changed_set(obj);
      +    ad->mouse_down = EINA_FALSE;
      +    elm_glview_changed_set(obj);
       }
       
      @@ -120,11 +118,15 @@ mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)

      The following example adds and deletes an animator with the callback function:

      1. Adding Ecore_Animator
        -// Add an animator so that the app regularly
        -// triggers updates of the GLView using elm_glview_changed_set()
        - 
        -// NOTE: If you delete OpenGL ES (GL), the animator keeps running trying to access GL
        -// To prevent it, delete the animator with ecore_animator_del()
        +/*
        +   Add an animator so that the app regularly
        +   triggers updates of the GLView using elm_glview_changed_set()
        +*/
        +
        +/*
        +   NOTE: If you delete OpenGL ES (GL), the animator keeps running trying to access GL
        +   To prevent it, delete the animator with ecore_animator_del()
        +*/
         
         Ecore_Animator *ani = ecore_animator_add(anim_cb, glview);
         evas_object_data_set(glview, "ani", ani);
        @@ -133,40 +135,41 @@ evas_object_event_callback_add(glview, EVAS_CALLBACK_DEL, del_anim_cb, ad);
         
      2. Setting up callback functions
        -static void 
        +static void
         del_anim_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
         {
        -   Ecore_Animator *ani = (Ecore_Animator *)evas_object_data_get(obj, "ani");
        -   ecore_animator_del(ani);
        +    Ecore_Animator *ani = (Ecore_Animator *)evas_object_data_get(obj, "ani");
        +    ecore_animator_del(ani);
         }
         
        -static Eina_Bool 
        +static Eina_Bool
         anim_cb(void *data)
         {
        -   elm_glview_changed_set((Evas_Object *)data);
        +    elm_glview_changed_set((Evas_Object *)data);
         
        -   return EINA_TRUE;
        +    return EINA_TRUE;
         }
        -
      + +

      The animator callback function is also triggered when the display is off. Use the ecore_animator_freeze() and ecore_animator_thaw() functions in the app_pause_cb() and app_resume_cb() callbacks for power saving.

      Integrating 3D Scene and 2D UI Components

      GLView can be used together with Elementary UI components. The following example creates a GLView and Elementary button component together in a simple box container. It is also possible to support interactions between 2D components and 3D scene.

      -// Create the box
      +/* Create the box */
       Evas_Object *box = elm_box_add(parent);
       
      -// Set the box to vertical
      +/* Set the box to vertical */
       elm_box_horizontal_set(box, EINA_FALSE);
      -// Box expands when its contents need more space
      +/* Box expands when its contents need more space */
       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
      -// Box fills the available space
      +/* Box fills the available space */
       evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
       
      -// Add glview to the box container
      +/* Add glview to the box container */
       ad->glview = add_glview(box, ad);
       elm_box_pack_end(box, ad->glview);
       
      -// Add button to the box container
      +/* Add button to the box container */
       Evas_Object *button = elm_button_add(box);
       evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
       evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 1);
      @@ -176,26 +179,29 @@ evas_object_show(button);
       elm_box_pack_end(box, button);
       
       static void
      -clicked_cb(void *user_data, Evas_Object *obj, void *event_info) 
      +clicked_cb(void *user_data, Evas_Object *obj, void *event_info)
       {
      -   appdata_s *ad = (appdata_s *) user_data;
      -
      -   // It is possible to change the 3D scene
      -   // For example, start animator to rotate the cube
      -   if (!ad->reset_anim) 
      -   {
      -      ad->reset_anim = EINA_TRUE;
      -
      -      // Setting animation angle for 0.75 seconds
      -      ad->tic_xangle = (ad->xangle - 45.0f) / 45.0f;
      -      ad->tic_yangle = (ad->yangle - 45.0f) / 45.0f;
      -
      -      // Add animator which calls elm_glview_changed_set() per frame
      -      // This rotates the object tic_x(y)angle along X(Y)-axis
      -      // until object reaches the initial angle
      -      ad->ani = ecore_animator_add(anim_cb, ad);
      -      evas_object_event_callback_add(ad->glview, EVAS_CALLBACK_DEL, del_anim, ad);
      -   }
      +    appdata_s *ad = (appdata_s *)user_data;
      +
      +    /*
      +       It is possible to change the 3D scene
      +       For example, start animator to rotate the cube
      +    */
      +    if (!ad->reset_anim) {
      +        ad->reset_anim = EINA_TRUE;
      +
      +        /* Setting animation angle for 0.75 seconds */
      +        ad->tic_xangle = (ad->xangle - 45.0f) / 45.0f;
      +        ad->tic_yangle = (ad->yangle - 45.0f) / 45.0f;
      +
      +        /* 
      +           Add animator which calls elm_glview_changed_set() per frame
      +           This rotates the object tic_x(y)angle along X(Y)-axis
      +           until object reaches the initial angle
      +        */
      +        ad->ani = ecore_animator_add(anim_cb, ad);
      +        evas_object_event_callback_add(ad->glview, EVAS_CALLBACK_DEL, del_anim, ad);
      +    }
       }
       
      diff --git a/org.tizen.guides/html/native/graphics/polygon_mesh_n.htm b/org.tizen.guides/html/native/graphics/polygon_mesh_n.htm index 2d4d79b..27e348b 100644 --- a/org.tizen.guides/html/native/graphics/polygon_mesh_n.htm +++ b/org.tizen.guides/html/native/graphics/polygon_mesh_n.htm @@ -73,7 +73,7 @@

      Figure: Low-resolution mesh of a unit sphere

      Low-resolution mesh of a unit sphere

      -

      The following figure shows some fractions of the OBJ file, where v stands for vertex position, vn stands for vertex normal, and f stands for face/triangle. The first v is indexed by 1 and so is the first vn. A triangle is defined by three instances of v//vn.

      +

      The following figure shows some fractions of the OBJ file, where v stands for vertex position, vn stands for vertex normal, and f stands for face/triangle. The first v is indexed by 1 and so is the first vn. A triangle is defined by 3 instances of v//vn.

      Figure: Fractions of an OBJ file

      Fractions of an OBJ file

      diff --git a/org.tizen.guides/html/native/graphics/tbm_n.htm b/org.tizen.guides/html/native/graphics/tbm_n.htm index 4a0706e..f6336e9 100644 --- a/org.tizen.guides/html/native/graphics/tbm_n.htm +++ b/org.tizen.guides/html/native/graphics/tbm_n.htm @@ -38,13 +38,13 @@

      The TBM surface provides the following main features:

        -
      • Creating a surface with defined width, height, and format
      • +
      • Creating a surface with defined width, height, and format
      • Getting a format list
      • Accessing the surface
      • Getting surface and plane information
      -

      The TBM surface provides various format typedefs. However, check that the system supports the graphic format in question.

      +

      The TBM surface provides various format typedefs. However, check that the system supports the graphic format in question. Also, before you start, remember to prepare your application to use the TBM surface functionality.

      Get surface and plane information using the tbm_surface_map() or the tbm_surface_get_info() function. The information of surface is assigned in the struct of tbm_surface_info_s.

      diff --git a/org.tizen.guides/html/native/graphics/texturing_n.htm b/org.tizen.guides/html/native/graphics/texturing_n.htm index f26f2fb..9db5983 100644 --- a/org.tizen.guides/html/native/graphics/texturing_n.htm +++ b/org.tizen.guides/html/native/graphics/texturing_n.htm @@ -117,7 +117,7 @@

      Figure: Selecting the mipmap levels

      Selecting the mipmap levels

      -

      There is of course a third option: not to do mipmapping but to use the original image (at level 0) instead. It can be filtered either by nearest point sampling or by bilinear interpolation. Therefore, minification has six varieties in total.

      +

      There is of course a third option: not to do mipmapping but to use the original image (at level 0) instead. It can be filtered either by nearest point sampling or by bilinear interpolation. Therefore, minification has 6 varieties in total.

      Texturing in GL

      @@ -134,61 +134,65 @@

      In order to generate a texture in GL, you usually have to decode the image file stored in the file system. In Tizen, you can use the Evas API (in mobile and wearable applications) to get the decoded bitmap buffer from the image file, as shown in the following example. The code creates an independent Ecore_Evas object, which contains Evas_Object. It provides a method to decode the designated image file and store the bitmap data into its own buffer. You can get the internal buffer pointer and then upload the buffer to the texture.

      -// Create GL Texture object from image file path
      -// @param[in] parent Evas object
      -// @param[in] filename image file path
      -// @return texture id
      -unsigned int 
      -create_texture(Evas_Object *parent, const char *filename) 
      +/*
      +   Create GL Texture object from image file path
      +   @param[in] parent Evas object
      +   @param[in] filename image file path
      +   @return texture id
      +*/
      +unsigned int
      +create_texture(Evas_Object *parent, const char *filename)
       {
      -   unsigned int gltex_object;
      -   int w, h;
      -   int surface_w, surface_h;
      -   evas_object_geometry_get(parent, NULL, NULL, &surface_w, &surface_h);
      +    unsigned int gltex_object;
      +    int w;
      +    int h;
      +    int surface_w;
      +    int surface_h;
      +    evas_object_geometry_get(parent, NULL, NULL, &surface_w, &surface_h);
       
      -   Evas_Object *inline_buffer = elm_win_add(parent,"Img Read",ELM_WIN_INLINED_IMAGE);
      -   evas_object_move(inline_buffer, 0, 0);
      -   evas_object_resize(inline_buffer, surface_w, surface_h);
      -   evas_object_show(inline_buffer);
      +    Evas_Object *inline_buffer = elm_win_add(parent,"Img Read",ELM_WIN_INLINED_IMAGE);
      +    evas_object_move(inline_buffer, 0, 0);
      +    evas_object_resize(inline_buffer, surface_w, surface_h);
      +    evas_object_show(inline_buffer);
       
      -   Evas *canvas = evas_object_evas_get(inline_buffer);
      -   Evas_Object *image = evas_object_image_add(canvas);
      +    Evas *canvas = evas_object_evas_get(inline_buffer);
      +    Evas_Object *image = evas_object_image_add(canvas);
       
      -   char path[200];
      -   sprintf(path, "%s%s", app_get_resource_path(), filename);
      -   evas_object_image_file_set(image, path, NULL);
      -   evas_object_image_size_get(image, &w, &h);
      -   evas_object_image_fill_set(image, 0, 0, w, h);
      -   evas_object_image_filled_set(image, EINA_TRUE);
      -   evas_object_resize(image, w, h);
      -   evas_object_show(image);
      +    char path[200];
      +    sprintf(path, "%s%s", app_get_resource_path(), filename);
      +    evas_object_image_file_set(image, path, NULL);
      +    evas_object_image_size_get(image, &w, &h);
      +    evas_object_image_fill_set(image, 0, 0, w, h);
      +    evas_object_image_filled_set(image, EINA_TRUE);
      +    evas_object_resize(image, w, h);
      +    evas_object_show(image);
       
      -   elm_win_render(inline_buffer);
      +    elm_win_render(inline_buffer);
       
      -   GLubyte *pixels;
      -   pixels = (GLubyte *) evas_object_image_data_get(image, EINA_FALSE);
      +    GLubyte *pixels;
      +    pixels = (GLubyte *)evas_object_image_data_get(image, EINA_FALSE);
       
      -   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
      -   glGenTextures(1, &gltex_object);
      +    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
      +    glGenTextures(1, &gltex_object);
       
      -   glBindTexture(GL_TEXTURE_2D, gltex_object);
      +    glBindTexture(GL_TEXTURE_2D, gltex_object);
       
      -   glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, w, h, 0, GL_BGRA_EXT,         
      -                GL_UNSIGNED_BYTE, pixels);
      +    glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, w, h, 0, GL_BGRA_EXT,
      +                 GL_UNSIGNED_BYTE, pixels);
       
      -   glGenerateMipmap(GL_TEXTURE_2D);
      +    glGenerateMipmap(GL_TEXTURE_2D);
       
      -   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
      -   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
      +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       
      -   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      -   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      +    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
       
      -   glBindTexture(GL_TEXTURE_2D, 0);
      +    glBindTexture(GL_TEXTURE_2D, 0);
       
      -   evas_object_del(inline_buffer);
      +    evas_object_del(inline_buffer);
       
      -   return gltex_object;
      +    return gltex_object;
       }
       
      diff --git a/org.tizen.guides/html/native/graphics/vertex_shader_n.htm b/org.tizen.guides/html/native/graphics/vertex_shader_n.htm index 7054ca1..8cc8edf 100644 --- a/org.tizen.guides/html/native/graphics/vertex_shader_n.htm +++ b/org.tizen.guides/html/native/graphics/vertex_shader_n.htm @@ -55,7 +55,7 @@

      Object Space, World Space, and World Transform

      Whereas the coordinate system used for creating an object is named object space, the virtual world containing all required objects is associated with the world space. The size, position, and orientation of an object in the world space are determined by what is called world transform. (GL calls this model transform.) Its main components are scaling, translation, and rotation. A distinct object has its own world transform. The following figure shows a world-transform example.

      -

      In the world space, many objects can exist. Among them, consider a teapot. In this example, its world transform is the combination of "rotation about the Y axis by 90 degrees" and "translation along the X axis by seven units".

      +

      In the world space, many objects can exist. Among them, consider a teapot. In this example, its world transform is the combination of "rotation about the Y axis by 90 degrees" and "translation along the X axis by 7 units".

      Figure: Transformation of a teapot object

      Transformation of a teapot object

      @@ -118,10 +118,10 @@

      Figure: Input and output of the vertex shader

      Input and output of the vertex shader

      -

      The following code shows an example vertex shader. The shader language is C-like but provides specialized types. For example, mat4 is a 4x4 matrix and vec3 is a 3D vector. The following vertex shader example has 5 input values: viewProjMat and worldMat are 'uniforms' described by the keyword uniform, whereas position, normal, and texCoord are 'attributes' described by the keyword attribute.

      +

      The following code shows an example vertex shader. The shader language is C-like but provides specialized types. For example, mat4 is a 4x4 matrix and vec3 is a 3D vector. The following vertex shader example has 5 input values: viewProjMat and worldMat are 'uniforms' described by the keyword uniform, whereas position, normal, and texCoord are 'attributes' described by the keyword attribute.

      -uniform mat4 viewProjMat; // 4x4 matrix for view+projection transforms
      -uniform mat4 worldMat; // 4x4 matrix for world transform
      +uniform mat4 viewProjMat; /* 4x4 matrix for view+projection transforms */
      +uniform mat4 worldMat; /* 4x4 matrix for world transform */
       
       attribute vec3 position;
       attribute vec3 normal;
      @@ -130,12 +130,12 @@ attribute vec2 texCoord;
       varying vec3 v_normal;
       varying vec2 v_texCoord;
       
      -void 
      -main() 
      +void
      +main()
       {
      -   gl_Position = viewProjMat * worldMat * vec4(position, 1.0);
      -   v_normal = mat3(worldMat) * normal;
      -   v_texCoord = texCoord;
      +    gl_Position = viewProjMat * worldMat * vec4(position, 1.0);
      +    v_normal = mat3(worldMat) * normal;
      +    v_texCoord = texCoord;
       }
       

      The output of the vertex shader must include the built-in variable, gl_Position, which stores the clip-space vertex position. This is the only required output of the vertex shader. Optional output variables are described with the keyword varying. The output usually includes vertex normal and texture coordinates. In the above example, the object-space vertex normal is transformed to the world space and output to v_normal. On the other hand, the texture coordinates, texCoord, is simply copied to v_texCoord.

      @@ -162,7 +162,7 @@ main()

      Consider a dynamic environment, where the scene objects continuously move. In the example vertex shader, worldMat must be updated per frame. On the other hand, viewProjMat must be updated if the eye moves. The GL program must update and provide them for the vertex shader. For this purpose, first find the uniform locations that have been determined during the link phase. Given a uniform name in the shader, the glGetUniformLocation() function returns its location (denoted by an integer) in the program.

      -// mProgram denotes the program object
      +/* mProgram denotes the program object */
       GLint mWHandle = glGetUniformLocation(mProgram, "worldMat")
       

      Then, use the glUniformMatrix4fv() function to load the uniform with the updated matrix, worldMat. A list of functions for loading various uniforms is available and is collectively named glUniformXXX(), representing a set of variations including the glUniform3f() and glUniformMatrix4x3fv() functions.

      @@ -180,17 +180,17 @@ GLint mWHandle = glGetUniformLocation(mProgram, "worldMat")
      1. Use the glGenBuffers() function, which is asked for n buffer objects and returns them in buffers. In general, n is 2: one for vertices and the other for indices.
      2. Use the glBindBuffer() function, where the first parameter is either GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER. This specifies what the buffer is used for. The glBindBuffer() function call creates a VBO.
      3. -
      4. The buffer object is filled with data using the glBufferData() function, where the first parameter is either GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER and the third parameter points to the vertex or index array.
      5. +
      6. The buffer object is filled with data using the glBufferData() function, where the first parameter is either GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER and the third parameter points to the vertex or index array.

      The GL program shown in the following example creates 2 VBOs:

       glGenBuffers(2, &VBO);
      -glBindBuffer(GL_ARRAY_BUFFER, // Target
      -             VBO[0]); // Buffer
      -glBufferData(GL_ARRAY_BUFFER, // Target
      -             sizeof(vertices), // Size
      -             vertices, // Data
      -             GL_STATIC_DRAW); // Usage
      +glBindBuffer(GL_ARRAY_BUFFER, /* Target */
      +             VBO[0]); /* Buffer */
      +glBufferData(GL_ARRAY_BUFFER, /* Target */
      +             sizeof(vertices), /* Size */
      +             vertices, /* Data */
      +             GL_STATIC_DRAW); /* Usage */
       
       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VBO[1]);
       glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices),
      @@ -202,22 +202,22 @@ glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices),
       
       

      Such a structure must be presented to the shader. For this purpose, the GL program first invokes the glEnableVertexAttribArray() function to enable each parameter. After that, the glVertexAttribPointer() function is called. In this function, the first parameter denotes the parameter index, the second specifies the number (1, 2, 3, or 4) of components per parameter, fifth specifies the byte distance between the consecutive parameters of the same kind, and the sixth points to the first occurrence of the parameter in bytes. The GL program shown in the following example details position, normal, and texCoord parameters.

      -int stride = sizeof(VertexStruct); // VertexStruct with 3 attributes
      +int stride = sizeof(VertexStruct); /* VertexStruct with 3 attributes */
       int offset = 0;
       
      -// position attribute
      -glEnableVertexAttribArray(0); // Position index = 0
      -glVertexAttribPointer(0, // Index
      -                      3, // Size
      -                      GL_FLOAT, // Type
      +/* Position attribute */
      +glEnableVertexAttribArray(0); /* Position index = 0 */
      +glVertexAttribPointer(0, /* Index */
      +                      3, /* Size */
      +                      GL_FLOAT, /* Type */
                             GL_FALSE, stride, (GLvoid*)offset);
       
      -offset += sizeof(vec3); // For accessing normal
      -glEnableVertexAttribArray(1); // Normal index = 1
      +offset += sizeof(vec3); /* For accessing normal */
      +glEnableVertexAttribArray(1); /* Normal index = 1 */
       glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)offset);
       
      -offset += sizeof(vec3); // For accessing texCoord
      -glEnableVertexAttribArray(2); // texCoord index = 2
      +offset += sizeof(vec3); /* For accessing texCoord */
      +glEnableVertexAttribArray(2); /* texCoord index = 2 */
       glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*)offset);
       
      @@ -231,17 +231,17 @@ glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*)offset);

    Assuming that you have only the vertex array for the low-resolution sphere, the glDrawArrays() function is invoked. In the following example, the first parameter specifies what kind of primitives to render. Valid values include, for example, GL_POINTS, GL_LINES, GL_TRIANGLES, and GL_TRIANGLE_FAN. The second parameter specifies the starting index "in the vertex array". The last parameter specifies the number of vertices to be drawn.

    -glDrawArrays(GL_TRIANGLES, // Mode
    -             0, // First
    -             144); // Count
    +glDrawArrays(GL_TRIANGLES, /* Mode */
    +             0, /* First */
    +             144); /* Count */
     

    When you have both the vertex array and index array, the glDrawElements() function is invoked. The first parameter is the same as in the glDrawArrays() function. The second parameter specifies the number of elements "in the index array". The third parameter specifies the type of the values in the indices. It must be GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT. The last parameter points to the offset in bytes into the storage allocated by the glBufferData() function.

    -glDrawElements(GL_TRIANGLES, // Mode 
    -               144, // Count
    -               GL_UNSIGNED_SHORT, // Type
    -               0); // Indices
    +glDrawElements(GL_TRIANGLES, /* Mode */
    +               144, /* Count */
    +               GL_UNSIGNED_SHORT, /* Type */
    +               0); /* Indices */
     
    @@ -249,127 +249,127 @@ glDrawElements(GL_TRIANGLES, // Mode

    The following example code presents how to use GL APIs in the callbacks of the GLView. In the init_glview() callback function, compile and link the shaders, and create VBOs.

    -// GL initialization callback
    -static void 
    -init_glview(Evas_Object *glview) 
    +/* GL initialization callback */
    +static void
    +init_glview(Evas_Object *glview)
     {
    -   // Set GL state color to black
    -   glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    +    /* Set GL state color to black */
    +    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
     
    -   appdata_s *ad = (appdata_s *) evas_object_data_get(glview, "ad");
    +    appdata_s *ad = (appdata_s *)evas_object_data_get(glview, "ad");
     
    -   if (!ad->initialized) 
    -   {
    -      init_shader_program(ad); // Compile and link shader
    -      create_vbo(ad); // Create vertex buffer object
    -      ad->texture = create_texture(ad->win, "tizen_noalpha.png");
    +    if (!ad->initialized) {
    +        init_shader_program(ad); /* Compile and link shader */
    +        create_vbo(ad); /* Create vertex buffer object */
    +        ad->texture = create_texture(ad->win, "tizen_noalpha.png");
     
    -      glEnable(GL_DEPTH_TEST);
    -      ad->initialized = EINA_TRUE;
    -   }
    +        glEnable(GL_DEPTH_TEST);
    +        ad->initialized = EINA_TRUE;
    +    }
     
    -   // Initialize application variables
    +    /* Initialize application variables */
     }
     
     static void
    -init_shader_program(appdata_s *ad) 
    +init_shader_program(appdata_s *ad)
     {
    -   const char *p;
    +    const char *p;
     
    -   p = vertex_tex_shader;
    -   ad->vtx_shader = glCreateShader(GL_VERTEX_SHADER);
    -   glShaderSource(ad->vtx_shader, 1, &p, NULL);
    -   glCompileShader(ad->vtx_shader);
    +    p = vertex_tex_shader;
    +    ad->vtx_shader = glCreateShader(GL_VERTEX_SHADER);
    +    glShaderSource(ad->vtx_shader, 1, &p, NULL);
    +    glCompileShader(ad->vtx_shader);
     
    -   p = fragment_tex_shader;
    -   ad->fgmt_shader = glCreateShader(GL_FRAGMENT_SHADER);
    -   glShaderSource(ad->fgmt_shader, 1, &p, NULL);
    -   glCompileShader(ad->fgmt_shader);
    +    p = fragment_tex_shader;
    +    ad->fgmt_shader = glCreateShader(GL_FRAGMENT_SHADER);
    +    glShaderSource(ad->fgmt_shader, 1, &p, NULL);
    +    glCompileShader(ad->fgmt_shader);
     
    -   ad->program = glCreateProgram();
    -   glAttachShader(ad->program, ad->vtx_shader);
    -   glAttachShader(ad->program, ad->fgmt_shader);
    +    ad->program = glCreateProgram();
    +    glAttachShader(ad->program, ad->vtx_shader);
    +    glAttachShader(ad->program, ad->fgmt_shader);
     
    -   glLinkProgram(ad->program);
    +    glLinkProgram(ad->program);
     
    -   ad->idx_a_position = glGetAttribLocation(ad->program, "a_position");
    -   ad->idx_a_tex = glGetAttribLocation(ad->program, "a_tex");
    +    ad->idx_a_position = glGetAttribLocation(ad->program, "a_position");
    +    ad->idx_a_tex = glGetAttribLocation(ad->program, "a_tex");
     
    -   ad->idx_wvp = glGetUniformLocation(ad->program, "u_wvpMatrix");
    -   ad->idx_tex = glGetUniformLocation(ad->program, "u_texSampler");
    +    ad->idx_wvp = glGetUniformLocation(ad->program, "u_wvpMatrix");
    +    ad->idx_tex = glGetUniformLocation(ad->program, "u_texSampler");
     
    -   glUseProgram(ad->program);
    +    glUseProgram(ad->program);
     }
     
    -static void 
    -create_vbo(appdata_s *ad) 
    +static void
    +create_vbo(appdata_s *ad)
     {
    -   glGenBuffers(1, &ad->vbo_vertex);
    -   glGenBuffers(1, &ad->vbo_color);
    -   glGenBuffers(1, &ad->vbo_texture);
    -
    -   glBindBuffer(GL_ARRAY_BUFFER, ad->vbo_vertex);
    -   glBufferData(GL_ARRAY_BUFFER, sizeof(cube_vertices), cube_vertices, 
    -                GL_STATIC_DRAW);
    -   glVertexAttribPointer(ad->idx_a_position, 3, GL_FLOAT, GL_FALSE, 
    -                         3 * sizeof(float), 0);
    -
    -   glBindBuffer(GL_ARRAY_BUFFER, ad->vbo_texture);
    -   glBufferData(GL_ARRAY_BUFFER, sizeof(cube_texs), cube_texs, 
    -                GL_STATIC_DRAW);
    -   glVertexAttribPointer(ad->idx_a_tex, 2, GL_FLOAT, GL_FALSE, 
    -                         2 * sizeof(float), 0);
    -
    -   glEnableVertexAttribArray(ad->idx_a_position);
    -   glEnableVertexAttribArray(ad->idx_a_tex);
    -
    -   glGenBuffers(1, &ad->vbo_index);
    -   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ad->vbo_index);
    -   glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(cube_indices), 
    -                cube_indices, GL_STATIC_DRAW);
    +    glGenBuffers(1, &ad->vbo_vertex);
    +    glGenBuffers(1, &ad->vbo_color);
    +    glGenBuffers(1, &ad->vbo_texture);
    +
    +    glBindBuffer(GL_ARRAY_BUFFER, ad->vbo_vertex);
    +    glBufferData(GL_ARRAY_BUFFER, sizeof(cube_vertices), cube_vertices,
    +                 GL_STATIC_DRAW);
    +    glVertexAttribPointer(ad->idx_a_position, 3, GL_FLOAT, GL_FALSE,
    +                          3 * sizeof(float), 0);
    +
    +    glBindBuffer(GL_ARRAY_BUFFER, ad->vbo_texture);
    +    glBufferData(GL_ARRAY_BUFFER, sizeof(cube_texs), cube_texs,
    +                 GL_STATIC_DRAW);
    +    glVertexAttribPointer(ad->idx_a_tex, 2, GL_FLOAT, GL_FALSE,
    +                          2 * sizeof(float), 0);
    +
    +    glEnableVertexAttribArray(ad->idx_a_position);
    +    glEnableVertexAttribArray(ad->idx_a_tex);
    +
    +    glGenBuffers(1, &ad->vbo_index);
    +    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ad->vbo_index);
    +    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(cube_indices),
    +                 cube_indices, GL_STATIC_DRAW);
     }
     

    In the draw_glview() callback, calculate the world, view, and projection matrices and then pass the combined matrix to the vertex shader through the glUniformXXX() function. When all uniforms are passed to the shader, the GL drawcall is made.

    -// GL drawing callback
    +/* GL drawing callback */
     static void
    -draw_glview(Evas_Object *glview) 
    +draw_glview(Evas_Object *glview)
     {
    -   appdata_s *ad = (appdata_s *) evas_object_data_get(glview, "ad");
    -   float world[16], viewproj[16];
    -   float aspect;
    +    appdata_s *ad = (appdata_s *)evas_object_data_get(glview, "ad");
    +    float world[16], viewproj[16];
    +    float aspect;
    +
    +    if (!ad)
    +        return;
     
    -   if (!ad)
    -      return;
    +    init_matrix(world);
    +    init_matrix(viewproj);
     
    -   init_matrix(world);
    -   init_matrix(viewproj);
    +    aspect = (float) ad->glview_w / (float) ad->glview_h;
     
    -   aspect = (float) ad->glview_w / (float) ad->glview_h;
    -    
    -   // View matrix is the identity matrix
    -   view_set_perspective(viewproj, 60.0f, aspect, 1.0f, 20.0f);
    +    /* View matrix is the identity matrix */
    +    view_set_perspective(viewproj, 60.0f, aspect, 1.0f, 20.0f);
     
    -   translate_xyz(world, 0.0f, 0.0f, -2.5f);
    -   rotate_xyz(world, ad->xangle, ad->yangle, 0.0f);
    +    translate_xyz(world, 0.0f, 0.0f, -2.5f);
    +    rotate_xyz(world, ad->xangle, ad->yangle, 0.0f);
     
    -   multiply_matrix(ad->wvp, viewproj, world);
    +    multiply_matrix(ad->wvp, viewproj, world);
     
    -   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    +    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
    -   glUniformMatrix4fv(ad->idx_wvp, 1, GL_FALSE, ad->wvp);
    +    glUniformMatrix4fv(ad->idx_wvp, 1, GL_FALSE, ad->wvp);
     
    -   glBindTexture(GL_TEXTURE_2D, ad->texture);
    -   glActiveTexture(GL_TEXTURE0);
    -   glUniform1i(ad->idx_tex, 0);
    +    glBindTexture(GL_TEXTURE_2D, ad->texture);
    +    glActiveTexture(GL_TEXTURE0);
    +    glUniform1i(ad->idx_tex, 0);
     
    -   glDrawElements(GL_TRIANGLES, cube_indices_count, GL_UNSIGNED_SHORT, 0);
    +    glDrawElements(GL_TRIANGLES, cube_indices_count, GL_UNSIGNED_SHORT, 0);
     
    -   glFlush();
    +    glFlush();
     }
     
    - + + diff --git a/org.tizen.guides/html/native/guides_n.htm b/org.tizen.guides/html/native/guides_n.htm index cf74a92..89165fc 100644 --- a/org.tizen.guides/html/native/guides_n.htm +++ b/org.tizen.guides/html/native/guides_n.htm @@ -38,10 +38,10 @@

    Select the API domain you are interested in and see what Tizen offers for your application:

      -
    • Migration Guide 2.2.1 to 2.3 -

      Enables you to migrate a Tizen 2.2.1 project to Tizen 2.3.

    • Migration Guide from 2.3 to 2.4

      Enables you to make your application conform to Tizen 2.4 regarding the application Framework APIs.

    • +
    • Account +

      Enables you to manage account information, such as receive sync operation notifications, obtain an access token by using the OAuth 2.0 authorization, and authenticate users using the FIDO network.

    • Application Framework

      Enables you to configure application properties, and manage application data, and runtime environment and behavior.

    • Base @@ -62,6 +62,8 @@

      Enables you to send data to networks and other applications, and receive data back from them.

    • Security

      Enables you to increase the security of your application through cryptography, encryption, and request control.

    • +
    • Social +

      Enables you to manage the user's personal data, such as contacts, calendars, and accounts.

    • System

      Enables you to handle log messages, device and system information, and manage system settings, sensors, and system storage.

    • Telephony @@ -69,11 +71,7 @@
    • UIX

      Enables you to handle UI extensions, which include managing sound data, such as voice commands, speech-to-text (STT), and text-to-speech (TTS).

    • Web -

      Enables you to access Web content.

    • -
    • Account -

      Enables you to manage account information, such as receive sync operation notifications, obtain an access token by using the OAuth 2.0 authorization and authenticate users using FIDO framework.

    • -
    • Social in mobile applications only -

      Enables you to manage the user's personal data, such as contacts, calendars, and accounts.

    • +

      Enables you to access Web content.

    • UI Framework in mobile applications only

      Enables you to create a visual outlook for your application to ensure the best possible user experience.

    diff --git a/org.tizen.guides/html/native/location/geofence_n.htm b/org.tizen.guides/html/native/location/geofence_n.htm index eb2346c..ca1e870 100644 --- a/org.tizen.guides/html/native/location/geofence_n.htm +++ b/org.tizen.guides/html/native/location/geofence_n.htm @@ -10,7 +10,7 @@ - Geofence + Geofence Manager @@ -39,34 +39,37 @@

    This feature is supported in mobile applications only.

    -

    The main features Geofnece Manager are:

    +

    The main features of the Geofence Manager API include:

    -

    Geofence Service

    -

    The Geofence Manager API is used to get notifications about the in or out state, depending on the geofence defined by the user.

    -

    Use the Geofence Manager API to:

    +

    Using the Geofence Service

    + +

    With the geofence service, you can:

    +

    Before you start, remember to prepare your application to use the geofence manager functionality.

    The geofence manager is set to GEOFENCE_MANAGER_ERROR_NONE if it is working correctly. The device can receive alerts about the geofence when a particular geofence service is started using the geofence_manager_start_geofence() function.

    If the user revokes a permission to use the location information, the geofence manager state is set to GEOFENCE_MANAGER_PERMISSION_DENIED and the same error is returned back to the application invoking the geofence service.

    Asynchronous geofence-related alerts (in or out) and event callbacks (a fence added or removed) are implemented with callback interfaces. The alerts are received using the GEOFENCE_STATE_UNCERTAIN, GEOFENCE_STATE_IN, and GEOFENCE_STATE_OUT values of the geofence_state_e enumerator.

    -

    Geofence Definition

    +

    Defining a Geofence

    The geofence definition defines the parameters of a geofence.

    The 3 types of available geofences are geopoint, Wi-Fi, and Bluetooth. When creating the geofence, the type can be defined using the GEOFENCE_TYPE_GEOPOINT, GEOFENCE_TYPE_WIFI, and GEOFENCE_TYPE_BT values of the geofence_type_e enumerator.

    The geopoint geofences require a geopoint and a radius, and the Wi-Fi and Bluetooth geofences require a MAC address. Based on the defined geofence type, the geofence manager creates the fence for the particular application.

    -

    Geofence Settings

    -

    Tizen provides the user a way of managing the geofence places and fence through the My places application. The following figure shows the default places and supported fences.

    +

    Managing the Geofence Service

    +

    Tizen provides the user a way of managing the geofence places and fences through the My places application. The following figure shows the default places and supported fences.

    Figure: My places

    My places

    My places controls the adding, removing, and updating of places and fences. Home, Office, and Car are the default places, and Map, Wi-Fi, and Bluetooth are the supported fence methods. Car supports only Wi-Fi and Bluetooth for a fence method.

    diff --git a/org.tizen.guides/html/native/location/here_credential_n.htm b/org.tizen.guides/html/native/location/here_credential_n.htm deleted file mode 100644 index 56fc959..0000000 --- a/org.tizen.guides/html/native/location/here_credential_n.htm +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - -How to get HERE credentials - - - -
    -
    -

    Mobile native

    -
    - -
    - - -

    How to get HERE credentials

    - -

    The HERE Maps Plug-in for Maps Service is provided as a representative one in the Tizen platform, and it is based on the HERE Maps services. As a policy on the HERE Maps, you need a credential of it.

    - -

    You can select HERE plans  depending on the number of request queries and the kind of supported features, and pay for the cost of HERE plans.

    - -

    This guide is written to share a summary of how to get new credentials. If you want to get more exact and detailed information, please visit HERE Developers.

    - - - -

    Step 1. Sign in

    -

    If you don't have any account, please register for accounts of the HERE Maps at first.

    -

    Sign in to yours:

    -

    - -

    Step 2. Select a plan for the HERE Maps services

    -

    You can see available plans in the Plans section on the top menu bar. 

    -

    Make a plan to use the HERE Maps services taking account of transactions:

    -

    -

    Click one of buttons such as "Try for free" or "Sign up", to continue.

    -

     

    - -

    Step 3. Register a new application

    -

    Register a new application to create a new credential.

    -
    Note: Depending on the region or country in contact details, you may not be able to register a new application successfully.
    -

     

    -

    The figure shows the form of Evaluation Plan, when you click "Try for free":

    -

    -

     

    -

    The figure shows the form of Evaluation Plan, when you click "Try for free":

    -

    -

     

    - -

    Step 4. Confirm the new credentials

    -

    You can check your credentials on Applications menu.

    -

    -

    If you click one of list, you can see app_id and app_code.

    -

    - -

    Step 5. Use the credential in your applications

    -

    You can use the credential in your application with maps_service_set_provider_key().

    -

    In case of the HERE Maps services there are two values provided for each credential, app_id and app_code. If app_id is "XXXX" and app_code is "YYYY", concatenate app_id and app_code with a separator '/' as below:

    - -
    -maps_service_h maps = NULL;
    -int error = maps_service_create("HERE", &maps);
    -error = maps_service_set_provider_key(maps, "XXXX/YYYY")
    -
    - - - - - - - - -
    Note
    - According to the HERE Maps, -
      -
    • app_id uniquely identifies your application.
    • -
    • app_code is used in the authentication process to identify a session.
    • -
    -
    - - - - - - - - - -Go to top - - - - - - diff --git a/org.tizen.guides/html/native/location/here_credentials_n.htm b/org.tizen.guides/html/native/location/here_credentials_n.htm new file mode 100644 index 0000000..e3d1ca7 --- /dev/null +++ b/org.tizen.guides/html/native/location/here_credentials_n.htm @@ -0,0 +1,132 @@ + + + + + + + + + + + + +Getting HERE Maps Credentials + + + +
    +
    +

    Mobile native

    +
    + +
    + +
    + +

    Getting HERE Maps Credentials

    + +

    The HERE Maps Plug-in for the Maps Service API is based on the HERE Maps services. It is provided as an example in the Tizen platform, and to use it on the HERE Maps, you need credentials for it.

    + +

    You can select HERE plans depending on the number of request queries and the kind of supported features you need, and pay for them accordingly. The following instructions provide a summary of how to get new credentials. For more detailed information, see HERE Developers.

    + +

    To get credentials:

    + +
      +
    1. Sign in. + +

      If you have no account, first register for the HERE Maps account.

      +

      When you have an account, sign in to it.

      +

      Sign in

      +
    2. + +
    3. Select a plan for using the HERE Maps services. + +

      You can see available plans in the Plans section on the top menu bar.

      +

      Select the plan taking account of the number of transactions you need, and click Try for free or Sign up.

      +

      Select the plan

      +
    4. + +
    5. Register a new application. +

      You must register a new application to create new credentials.

      + + + + + + + + + +
      Note
      Some regions or countries do not support the registration. If your contact details contain such a region or country, you cannot register a new application successfully. +

      Unsupported region or country

      + +

      The following figure shows the Evaluation plan form, which is opened when you click Try for free. Enter the required details.

      + +

      +
    6. + +
    7. Confirm the new credentials. +

      You can check the credentials in the Applications menu.

      +

      Confirmation

      +

      If you click an application in the list, you can see the app ID and code related to it.

      +

      Credentials

      +
    8. + +
    9. Use the credentials in your application. +

      You can use the credentials in your application with the maps_service_set_provider_key() function.

      +

      The HERE Maps services provides 2 values as credentials: app ID and app code. If the app ID is XXXX and the app code is YYYY, concatenate them with the "/" separator:

      + +
      +maps_service_h maps = NULL;
      +int error = maps_service_create("HERE", &maps);
      +error = maps_service_set_provider_key(maps, "XXXX/YYYY")
      +
      + + + + + + + + +
      Note
      + According to the HERE Maps: +
        +
      • The app ID uniquely identifies your application.
      • +
      • The app code is used in the authentication process to identify a session.
      • +
      +
      + +
    10. +
    + +
    + + + +Go to top + + + + + + diff --git a/org.tizen.guides/html/native/location/location_guide_n.htm b/org.tizen.guides/html/native/location/location_guide_n.htm index be719aa..2273ca7 100644 --- a/org.tizen.guides/html/native/location/location_guide_n.htm +++ b/org.tizen.guides/html/native/location/location_guide_n.htm @@ -33,7 +33,7 @@

    Location

    -

    Location features include location-based and related services.

    +

    Location features include access to location-based and -related services.

    The main location features are:

      @@ -41,13 +41,15 @@

      Provides the geographical location of the device.

    +

    The following guides apply in mobile applications only:

    • Geofence Manager

      Allows you to create and use geofences.

    • Maps Service -

      Allows you to create and use the maps services, such as geocoder, place searching, and routing.

    • +

      Allows you to create and use the maps services, such as geocoder, place searching, and routing.

    + @@ -70,4 +72,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/native/location/location_n.htm b/org.tizen.guides/html/native/location/location_n.htm index a26813c..0aa163d 100644 --- a/org.tizen.guides/html/native/location/location_n.htm +++ b/org.tizen.guides/html/native/location/location_n.htm @@ -10,7 +10,7 @@ - Location + Location Manager @@ -22,13 +22,13 @@

    Content

    Related Info

    @@ -40,15 +40,27 @@

    Location Manager

    -

    Location information has a geographical point on the Earth, and optionally location-related information can also contain information about altitude, accuracy about the geographical point and altitude, and the user speed and course of direction. Location Manager features include managing location information on the device.

    - -

    -

    The main features of Location Manager are:

    +

    Location information has a geographical point on the Earth, and optionally location-related information can also contain information about altitude, accuracy about the geographical point and altitude, and the user speed and course of direction. Location Manager features include managing location information on the device.

    +

    The main features of the Location Manager API include:

    + +

    Location Service

    + +

    The Location Manager API (in mobile and wearable applications) provides the current location using the location sources specified in the location method. You can use the location service to manage location information in various ways.

    +

    With the Location Manager, you can:

    + +

    Before you start, remember to prepare your application to use the location manager functionality.

    @@ -60,16 +72,8 @@

    However, satellite data is not supported on the Emulator, so GPS status data is available only on a target device.

    -
    + -

    Location Service

    -

    The Location Manager API (in mobile and wearable applications) provides the current location using the location sources specified in the location method.

    -

    With the Location Manager, you can:

    -
      -
    • Get the current location
    • -
    • Get the last known location
    • -
    • Get location updates
    • -

    Asynchronous location-related updates and region monitoring notifications are implemented with callback interfaces (functions whose names end with "cb").

    You can use the location state and updates as follows:

      diff --git a/org.tizen.guides/html/native/location/maps_n.htm b/org.tizen.guides/html/native/location/maps_n.htm index 717a8c3..3fdbe6f 100644 --- a/org.tizen.guides/html/native/location/maps_n.htm +++ b/org.tizen.guides/html/native/location/maps_n.htm @@ -39,20 +39,25 @@

      The main Maps Service API features are:

      • Discovering and selecting a map provider -

        You can also specifying basic maps preferences.

      • +

        You can also specify basic maps preferences.

      • Geocoding and reverse geocoding -

        You can get the geocode (geographical coordinates) of a place based on an address, or the reverse geocode (address) based on the geographical coordinates (latitude and longitude).

      • +

        You can get the geocode (geographical coordinates) of a place based on an address, or the reverse geocode (address) based on the geographical coordinates (latitude and longitude).

      • Searching places -

        You can query place information, corresponding to specified search keys and filters.

      • +

        You can query place information, corresponding to specified search keys and filters.

      • Searching routes -

        You can query a route that defines a path between a start and destination point, passing optionally through specific intermediate locations and calculated using a specified transportation method.

      • +

        You can query a route that defines a path between a start and destination point, passing optionally through specific intermediate locations and calculated using a specified transportation method.

      • Handling map service responses

        You can receive responses from the map service through various callbacks.

      +

      You can also cancel service requests and customize them.

      + +

      Before you start, remember to prepare your application to use the maps service functionality.

      +

      The following map provider is supported:

      @@ -78,7 +83,7 @@
      • Get a structured address based on place coordinates.
      -

      The reverse geocode response is structured address information, comprising, for example, of a street name, building number, city name, postal code, district name, state name, and country.

      +

      You can parse the reverse geocode response to use its details. The response consists of structured address information, comprising, for example, of a street name, building number, city name, postal code, district name, state name, and country.

      Place Search

      @@ -88,7 +93,7 @@
    • Query place information within a specified geographical area.
    • Query place information based on a free text address within a specified geographical area.
    • -

      The place search response is structured place information, comprising, for example, of a place ID, name and URL, address, geographical location and distance from the center of the search area, place category, rating, review, and image.

      +

      You can parse the place search response to use its details. The response consists of structured place information, comprising, for example, of a place ID, name and URL, address, geographical location and distance from the center of the search area, place category, rating, review, and image.

      @@ -107,7 +112,7 @@
    • Query a route from a starting point to a destination specified as a geographical location.
    • Query a route passing through a number of geographical locations.
    • -

      The route calculation response is structured route information, comprising, for example, of a route ID, geographical coordinates of the start and destination point, route bounding box, transportation mode, and total distance and duration.

      +

      You can parse the route calculation response to use its details. The response consists of structured route information, comprising, for example, of a route ID, geographical coordinates of the start and destination point, route bounding box, transportation mode, and total distance and duration.

      diff --git a/org.tizen.guides/html/native/messaging/email_n.htm b/org.tizen.guides/html/native/messaging/email_n.htm index 1459cad..d109d31 100644 --- a/org.tizen.guides/html/native/messaging/email_n.htm +++ b/org.tizen.guides/html/native/messaging/email_n.htm @@ -35,7 +35,7 @@

      This feature is supported in mobile applications only.

      -

      Email provides features for composing, saving, and sending email messages using an SMTP (SMTP used for sending emails through the Internet is described in the RFC5321/5322 standards). It provides services to applications that make use of the email service.

      +

      You can compose, save, and send email messages using an SMTP (SMTP used for sending emails through the Internet is described in the RFC5321/5322 standards). The Email API provides services to applications that make use of the email service.

      The Email API can be utilized by any component in the application layer which facilitates the end user to perform email messaging. For example, the Email APIs can be invoked by a multimedia module when the user wants to send a media file through email, or by an email application when the user tries to send an email message.

      @@ -49,6 +49,7 @@
    • Sending email messages.
    • Registering a callback function to be notified of the message status.
    • +

      Before you start, remember to prepare your application to use the email functionality.

      Email sending is asynchronous and the application must not wait for the result. The process can be slow (connections must be established), and even if the mail server is not available a message sending is not a failure if a spooling mechanism exists. Use the callback function to receive the status when the message has been sent.

      Note that once the email_send_message() function is called, the message content is out of the application's control. Even if the message appears not to have finished sending, it can no longer be modified.

      diff --git a/org.tizen.guides/html/native/messaging/messages_n.htm b/org.tizen.guides/html/native/messaging/messages_n.htm index ad9cc17..1c84b18 100644 --- a/org.tizen.guides/html/native/messaging/messages_n.htm +++ b/org.tizen.guides/html/native/messaging/messages_n.htm @@ -40,7 +40,9 @@
    • Multimedia messaging (MMS)

      You can create and send MMS messages. An image, audio, video, vCard, vCalendar, or a combination of them is supported as an attachment type in MMS messages. An image or audio attachment cannot be combined with video attachments.

    • Messaging notifications -

      You can register and unregister callback functions to be notified when an outgoing message is successfully sent or an incoming message has been received.

    • +

      You can register and deregister callback functions to be notified when an outgoing message is successfully sent or an incoming message has been received.

      + +

      Before you start, remember to prepare your application to use the messages functionality.

      The sent status of SMS and MMS can be checked asynchronously. You receive a separate status report for each SMS recipient, and one status report regardless of the number of MMS recipients.

      diff --git a/org.tizen.guides/html/native/messaging/push_n.htm b/org.tizen.guides/html/native/messaging/push_n.htm index 22a34b3..8b46372 100644 --- a/org.tizen.guides/html/native/messaging/push_n.htm +++ b/org.tizen.guides/html/native/messaging/push_n.htm @@ -52,7 +52,7 @@

      Service architecture

      The following steps illustrate a typical scenario for using the push messaging service on a Tizen device:

        -
      1. The application on the device registers for the push messaging service.
      2. +
      3. The application on the device registers for the push messaging service. Before you start, remember to prepare your application to use the push functionality.
      4. The device establishes a push session with the Tizen Server.

        The push session is managed by the Tizen server and device platform, so there is no need to create any code to manage it within the application.

      5. If the registration succeeds, the application receives a registration ID, which is a unique key for identifying the device and routing the push message.

        The application delivers the identifier to the application server.

      6. When the application server needs to send a push message to the application, it calls the Tizen server's open API. (For more information for server developers about sending push messages, see Sending Push Notifications.)

        A text message of up to 1024 bytes can be sent in a push message. If the application needs to download a large amount of data, the application server sends a link to the data in the push message.

        diff --git a/org.tizen.guides/html/native/migration_guide_221_n.htm b/org.tizen.guides/html/native/migration_guide_221_n.htm deleted file mode 100644 index e60e9a3..0000000 --- a/org.tizen.guides/html/native/migration_guide_221_n.htm +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - - - - - - - Migration Guide from 2.2.1 to 2.3 - - - - - - -
        -

        Migration Guide from 2.2.1 to 2.3

        - -

        The Tizen 2.3 release comes with a new version of the native API, created to give you a possibility to make fast and lightweight native applications. It replaces the native API used in the previous versions of Tizen (2.2.1). Combined with the Enlightenment Foundation libraries (EFL), the new native API provides powerful tools to create fantastic applications for Tizen.

        - -

        This feature is supported in mobile applications only.

        - -

        The purpose of this guide is to allow all the current Tizen application developers to port their current 2.2.1 native API-based applications to the new 2.3 native API as simply and quickly as possible. This guide contains basic guides on how to port your 2.2.1 native API application to the 2.3 native API. To fully understand the new API, familiarize yourself with the specifications and tutorials. This guide helps you to understand the main differences and start porting your applications.

        -

        For information about the differences between each module of the 2.2.1 and 2.3 version APIs, see API Comparison.

        - -

        Application Model Comparison

        - -

        The new API's application model is very similar to the one from the older version, so it is easy to adopt it.

        -

        The new 2.3 native API as well as the 2.2.1 version both support UI and service applications. UI applications have a graphical user interface, while service applications do not. Also, packaging applications follows same rules in both APIs. Only 1 UI application is allowed in one package. Applications in a package follow the same installation cycle but they have their own life-cycles. Each application in the package can be identified by its own ID. Applications can communicate with each other using the message port.

        -

        Multitasking in Tizen 2.3 works in a similar way as in Tizen 2.2.1, so only 1 application can work in the foreground. The rest are in a PAUSED state, so they are not visible for the user. Since service applications do not have a UI, they all run in the background the whole time.

        - -

        Different scenarios for switching between UI application states include:

        -
          -
        • Native application state transitions for 2.2.1: Tizen Native App Programming > Basics of Native App Programming > Application Model > Application Life-cycle > Frame State Transition
        • -
        • Native application state transitions for 2.3: The Application States and Transitions
        • - -
        -

        Basically, the scenarios are similar, and the same scenarios result in the same corresponding state transitions.

        -

        The main difference in developing UI applications is that the Tizen::Ui namespace has been replaced with the EFL. This change require you to recreate the user interface layer in your application. The EFL is very fast and customizable. Study its documentation to effectively use its features.

        - -

        Application Life-cycle

        - -

        The following figure shows the old 2.2.1 application life-cycle model.

        -

        Figure: 2.2.1 life-cycle model

        -

        2.2.1 life-cycle model

        - -

        The following figure shows the current application life-cycle model.

        -

        Figure: 2.3 life-cycle model

        -

        2.3 life-cycle model

        - -

        The following figures show the 2.2.1 and 2.3 state models.

        -

        Figure: 2.2.1 state model

        -

        2.2.1 state model

        - -

        Figure: 2.3 state model

        -

        2.3 state model

        - -

        The models have some differences, but basically they work very similarly. In both models, there are specific callbacks called during specific application states.

        -

        The main difference is that the old model has 2 life-cycles, one for the backend of the application and another one for the UI. The current model is more unified, so the backend code and the UI of the application are executed in the same callback functions.

        -

        First, the app_create_cb() function is called instead of OnAppInitializing(). Place the initialization code, such as loading and creating UI objects, there. After the initialization process (or the OnAppInitialized() callback in the 2.2.1 version), the application state becomes CREATED. Now the main event loop is being started and the app_control_cb() callback is called. The application state becomes RUNNING. This state is similar to the application state of the 2.2.1 version after OnAppInitialized() is executed.

        -

        When the application is running, the state can change to PAUSED or TERMINATED. Each state is preceded by a specific callback. Place your code in those callbacks to be executed before the application state changes. Those states are similar to the states from the 2.2.1 Native API, where the frame can be activated, deactivated, and minimized. If the state is PAUSED, it is possible to change it back to RUNNING. These situations are all described in the native Application API Reference.

        - -

        Package Management

        - -

        The package management during the porting process requires you to pay attention to the installation process and the actual application package structure.

        - -

        Application Installation Process

        - -

        The installation process in the new Native API is very similar to the one in the old API. The following figure shows the scheme.

        - -

        Figure: Installation process

        -

        Installation process

        - -

        The installation process looks similar to the one from the 2.2.1 Native API. In the new API, the Package Manager is still responsible for managing packages. Use this API for installing, uninstalling, and updating the packages.

        - -

        Application Package

        -

        In comparison with the 2.2.1 application package, the 2.3 native application package has fewer directories.

        - -

        Figure: 2.2.1 package structure

        -

        2.2.1 package structure

        - -

        Figure: 2.3 package structure

        -

        2.3 package structure

        - -

        In the current package structure, there are no separate info, setting, and shared directories. Despite this change, the rest of the directories are the same. The file extension remains .tpk.

        -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Table: 2.3 package directories
      DirectoryDescription
      <package ID>Fully qualified name of an application, such as org.tizen.calculator.
      binExecutable file of the application.
      libApplication library files.
      resRoot directory in which all resource files are located. -

      The application cannot write and modify any resource files.

      dataRoot directory in which the application's private data is located. -

      The application can read and write its own data files in the application -data directory.

      - -

      Application Launch and Termination

      - -

      The process of launching a 2.2.1 native API application can be found in: Tizen Native App Programming > Basics of Native App Programming > Application Model > Application Life-cycle > Launching Applications. A native application can also be launched from the Launcher or by another application.

      -

      The process of terminating a 2.2.1 native API application is described in: Tizen Native App Programming > Basics of Native App Programming > Application Model > Application Life-cycle > Terminating Applications. The possible scenarios for terminating the 2.3 native API application are the same as in the 2.2.1 API:

      -
        -
      • Application calls the ui_app_exit() function to terminate the main event loop.
      • -
      • Low Memory Killer terminates the application to free memory.
      • -
      - -

      UI and Service Applications

      -

      The main difference in creating UI applications is that the whole Tizen::Ui namespace has been replaced with the EFL. To create powerful applications for Tizen, study the EFL documentation.

      - -

      The new native API has the same idea of service applications as the 2.2.1 version:

      -
      • The guide for creating service applications in the 2.2.1 version can be found in: Tizen Native App Programming > Programming Guide > App: Controlling Your Application > Service Application Fundamentals. Also, the tutorial for the 2.2.1 version is in Tizen Native App Programming > Tutorials > App Tutorial > Task: Multi Proc Service App.

      • -
      • -

        The tutorial for the new 2.3 version is Service Application: Creating Background Applications.

      - -

      I/O Overview

      -

      In the old Tizen 2.2.1 applications, the operations related to accessing the file system and managing input and output were all defined in the Tizen::Io namespace. Now, all the functionalities of this namespace have been discarded in favor of open source libraries and other modules of the native API. To provide the same functionality as the previous Tizen::Io namespace, the current version of Tizen uses sqlite3 and EGlibc open libraries. It also uses the Message Port and Storage (a System submodule) from the native API, so handle I/O operations using these libraries and API modules.

      - -

      Object Ownership Policy

      -

      In the native API, the 'N' postfix for functions that return a new instance of an object with its ownership is no more supported. In this API, use the object_create() function, and free the memory with a function, such as object_destroy(). The following example is taken from the App Control module:

      -
      -static app_control_h app_control;
      -
      -int error_code = app_control_create(&app_control);
      -
      -error_code = app_control_destroy(app_control);
      -
      - -

      Check from the function documentation whether you have to free the resource you are using. There are many other functions, such as get_something(), which usually allocates memory to store an object or a value that is obtained. For example:

      -
      -char *uri;
      -
      -error_code = app_control_get_uri(app_control, &uri);
      -
      -if (uri != NULL)
      -{
      -   free(uri);
      -   uri = NULL;
      -}
      -
      - -

      In those cases, free memory as well. To be sure whether you need to release the resources to avoid memory leaks, check the API documentation.

      - -

      Low Memory Level Events

      -

      When the memory levels in the system are extremely low, the system terminates the application and removes it from the memory. However, it is possible to save the application state or context right before this happens. In the 2.2.1 version, it was done using the Tizen::App::IAppCheckpointEventListener interface. In the new native API, every time when the low level memory situation occurs on the device and the system wants to terminate some application, the app_event_cb() callback in that application is called. When you create your application, remember to place the code that must be executed in case of a low memory level in this callback and set the callback using the ui_app_add_event_handler() function.

      - -

      Scene Transitions

      -

      In the old 2.2.1 model, the UI scene transitions were handled by specific listeners, such as the Tizen::Ui::Controls::IFormBackEventListener and its OnFormBackRequested() event handler to listen to the Back key events for a backward scene transition. In the 2.3 model, all such actions are handled using the EFL and EFL Extension. The EFL has its own view manager for applications, called naviframe. A naviframe is a stack which holds views or pages as its items. When another view is launched, it is pushed on the top of the stack. Only the topmost view is displayed. The old views are stored on the stack. The EFL Extension provides functions to send key events to the naviframe top item or to pop it. Every time the user presses the Back key, the current view is removed from the stack and the view that was right under it becomes the topmost view and is displayed. The transition animation between views is handled by the EFL and depends on the theme applied to the UI component.

      - -

      Hardware Keys

      -

      With the arrival of the EFL, handling the hardware key events has changed. Until now, the 2.2.1 model provided the Tizen::Ui::Controls::IFormMenuEventListener interface. This interface delivered the OnFormMenuRequested() event handler to listen to the hardware Menu key events. Now, all this functionality is obtained using the EFL. In the EFL Extension documentation, find functions which enable you to manipulate the key modifiers. Use them to add handling for the hardware key events.

      - -

      Exceptions

      -

      Normally in the 2.3 API version, the exceptions model functions return an integer which indicates an error value. Usually, the value is 0 if there are no errors and the name format for this value is MODULE_NAME_ERROR_NONE. As in 2.2.1, the current API provides functions to get and set the last error value in the thread. In the 2.3 version, this functionality and the error enumerations are in the Base module. The following example shows how the current native API returns errors.

      -
      -int error_code = app_control_create(&app_control);
      -if (error_code != APP_CONTROL_ERROR_NONE) // Error occurred
      -
      - -

      Logs

      -

      The 2.3 native API provides a new method for managing logs. The dlog module is now responsible for these actions. It provides 2 functions to send data to the log output. It supports priority and tags, which can be used to easily filter log messages. The new logging system makes it easier to manage logs, since there are no multiple functions for dealing with different log levels. Set the priority (whether the log is an error or maybe a warning, info, or debug message) and filter the output logs according to the priority levels.

      - - - - - - - - - - - - - - - - - - - - - - - - - -
      Table: Priority levels
      PriorityDescription
      DLOG_DEBUGDebug message. -

      Log message which the developer want to check.

      DLOG_INFOInformation message. -

      Normal operational messages. Logs above this priority are always logged.

      DLOG_WARNWarning message. -

      Not an error, but an indication that an error occurs in the future if no action is taken.

      DLOG_ERRORError message. -

      Indicates an error.

      - -

      You can use the dlogutil command to view and follow the content of the log buffers:

      -
      -dlogutil [<option>] ... [<filter-spec>] ...  
      -
      - -

      Every log message has a tag and a priority associated with it. A filter expression follows the tag:priority format. The tag indicates the tag of interest and the priority indicates the minimum level of priority to report for that tag. Add any number of tag:priority specifications in a single filter expression. The tag of a log message indicates the system component from which the message originates. The priority is one of the following character values, ordered from lowest to highest priority:

      -
        -
      • D - Debug
      • -
      • I - Info
      • -
      • W - Warning
      • -
      • E - Error
      • -
      - -

      For example, to see the MY_APP tag with the debug priority:

      -
      # dlogutil MY_APP:D
      - -

      To see all log messages above the info priority:

      -
      # dlogutil *:I
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Table: List of logutil command options
      OptionDescription
      -b <buffer>Alternate log buffer. The main buffer is used by the default buffer.
      -cClears the entire log and exits.
      -dDumps the log and exits.
      -f <filename>Writes a log to the filename. The default is stdout.
      -gPrints the size of the specified log buffer and exits.
      -n <count>Sets the maximum number of rotated logs to count. The default value is 4. Requires the -r option.
      -r <Kbytes>Rotates the log file every Kbytes of output. The default value is 16. Requires the -f option.
      -sSets the default filter spec to silent.
      -v <format>Sets the output format for log messages. The default is the brief format.
      - - - -
    - -Go to top - - - - - - - - diff --git a/org.tizen.guides/html/native/multimedia/audio_io_n.htm b/org.tizen.guides/html/native/multimedia/audio_io_n.htm index 970592f..ce46aad 100644 --- a/org.tizen.guides/html/native/multimedia/audio_io_n.htm +++ b/org.tizen.guides/html/native/multimedia/audio_io_n.htm @@ -45,7 +45,11 @@
  • Playing uncompressed audio

    Enables you to create a multimedia application to play uncompressed PCM data.

  • - + +

    You can record and play audio synchronously, or do it asynchronously.

    + +

    Before you start, remember to prepare your application to use the audio input and output functionalities.

    +

    Recording Uncompressed Audio

    The Pulse Code Modulated (PCM) data contains non-compressed audio. The Audio Input API (in mobile and wearable applications) enables your application to record such data from a microphone type input device.

    Audio data is captured periodically, so to receive the audio PCM data from the input device, you must implement the audio input interface to notify the application of audio data events, such as the end of filling audio data.

    diff --git a/org.tizen.guides/html/native/multimedia/camera_n.htm b/org.tizen.guides/html/native/multimedia/camera_n.htm index 23d8ca0..f7792dd 100644 --- a/org.tizen.guides/html/native/multimedia/camera_n.htm +++ b/org.tizen.guides/html/native/multimedia/camera_n.htm @@ -45,8 +45,8 @@
  • Preview at the frame rate
  • Rotate and flip the preview
  • -
  • Capture and save images
  • -
  • Control the following camera settings: +
  • Capture and save images
  • +
  • Control the camera settings:
    • Contrast
    • Exposure
    • @@ -82,8 +82,8 @@

      Figure: Camera states in the normal mode

      Camera states in the normal mode

      -

      To display the camera preview, use the StartPreview() function.

      - +

      To display the camera preview, use the StartPreview() function.

      +

      Before you start, remember to prepare your application to use the messages functionality and configure the camera. When you have finished working with the camera, release the resources.

      diff --git a/org.tizen.guides/html/native/multimedia/image_util_n.htm b/org.tizen.guides/html/native/multimedia/image_util_n.htm index 57a7865..f9950d0 100644 --- a/org.tizen.guides/html/native/multimedia/image_util_n.htm +++ b/org.tizen.guides/html/native/multimedia/image_util_n.htm @@ -36,7 +36,7 @@
      • Conversion -

        You can change the colorspace format. The following tables define the supported formats.

        +

        You can change the colorspace format. The following tables define the supported formats.

        @@ -135,14 +135,15 @@
      • Resizing -

        You can change the image resolution.

      • +

        You can change the image resolution.

      • Rotation -

        You can change the image angle around the x or y axis.

      • +

        You can change the image angle around the x or y axis.

      • Crop -

        You can remove the outer parts of an image or change the aspect ratio.

      +

      You can remove the outer parts of an image or change the aspect ratio.

    +

    Before you start, remember to prepare your application to use the image util functionality.

    -

    You can decode and encode images with the following formats:

    +

    You can decode images and encode them with the following formats:

    • Bitmap formats:
      • YUV420, YUV422, RGB888, RGBA8888, BGRA8888, ARGB8888
    • diff --git a/org.tizen.guides/html/native/multimedia/media_codecs_n.htm b/org.tizen.guides/html/native/multimedia/media_codecs_n.htm index 5150d4c..82dac8d 100644 --- a/org.tizen.guides/html/native/multimedia/media_codecs_n.htm +++ b/org.tizen.guides/html/native/multimedia/media_codecs_n.htm @@ -34,15 +34,17 @@

      Media codec provides interfaces for encoding and decoding audio and video data.

      -

      To use codecs:

      +

      To use codecs:

      -
      1. Create a handle for the codec instance with the mediacodec_create() function. After a successful handle creation, your system can use the codec.

      2. +
        1. Create a handle for the codec instance with the mediacodec_create() function. After a successful handle creation, your system can use the codec.

        2. Set the codec configuration with the mediacodec_set_codec(), and mediacodec_set_vdec_info() or mediacodec_set_venc_info() functions.

          You can also prepare for the available ready state with the mediacodec_prepare() function.

        3. Decode and encode with the mediacodec_process_input() and mediacodec_get_output() functions.

        +

        Before you start, remember to prepare your application to use the media codec functionality.

        +

        A single MediaCodec instance handles 1 specific type of data (such as aac audio or H.264 video), and can encode or decode. The codec operates on "raw" data, so strip off any file headers (such as ID3 tags).

        @@ -50,6 +52,11 @@

        Figure: Media state changes

        Media state changes

        +

        After you have initialized the codecs, you can:

        + +
        1. Fill the media packet with data.
        2. +
        3. Run the media codec.
        + diff --git a/org.tizen.guides/html/native/multimedia/media_controller_n.htm b/org.tizen.guides/html/native/multimedia/media_controller_n.htm index f25e779..badcb75 100644 --- a/org.tizen.guides/html/native/multimedia/media_controller_n.htm +++ b/org.tizen.guides/html/native/multimedia/media_controller_n.htm @@ -31,7 +31,7 @@

        Media Controller

        -

        Tizen enables you to communicate between the media controller server and the media controller client.

        +

        Tizen enables you to communicate between the media controller server and the media controller client. You can send commands from the client to the server, and the client can request updated metadata and playback information from the server.

        This feature is supported in mobile applications only.

        @@ -40,7 +40,7 @@
        • Media controller server

          The media controller server provides current information about the registered application that you can send to the client.

          -

          To transfer the information at the client request, the media controller server updates the state information while the application is active. If application is terminated when the client request arrives, the media controller server transfers the latest information.

          +

          To transfer the information at the client request, the media controller server updates the state information while the application is active. If the application is terminated when the client request arrives, the media controller server transfers the latest information.

        • Media controller client

          You can request information, and the media controller client can receive it from the media controller server through a callback.

          @@ -181,6 +181,8 @@
        +

        Before you start, remember to prepare your application to use the media controller functionality.

        +
        diff --git a/org.tizen.guides/html/native/multimedia/media_demuxer_n.htm b/org.tizen.guides/html/native/multimedia/media_demuxer_n.htm new file mode 100644 index 0000000..f1454d3 --- /dev/null +++ b/org.tizen.guides/html/native/multimedia/media_demuxer_n.htm @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + Media Demuxer + + + + + + +
        +

        Media Demuxer

        + +

        You can demux any multiplexed media streams, such as MP4 and MP3.

        +

        The main features of the Media Demuxer API include:

        +
          +
        • Video, audio, and subtitle demultiplexing
        • +
        • MP4 demultiplexing support
        • +
        • MP3 parsing support
        • +
        • AAC parsing support
        • +
        • AMR parsing support
        • +
        + +

        Before you start, remember to prepare your application to use the media demuxer functionality.

        + +

        Tizen supports the following MP4 demultiplex streams:

        +
          +
        • Input streams: +
          • MP4 (M4A, M4V)
          • +
          • MP3, AAC, AMR-NB, AMR-WB
          +
        • +
        • Output elementary streams: +
            +
          • AVC/H.264 Video Elementary stream
          • +
          • MPEG-4 Video Elementary stream
          • +
          • MPEG-2 Video Elementary stream
          • +
          • MPEG Audio Elementary stream
          • +
          • AAC Audio Elementary stream
          • +
          +
        + +

        A media demuxer instance can be used to parse 1 multiplexed stream. The multiplexed stream can contain single or multiple elementary streams of various types, such as audio, video, or text. A single instance of the media demuxer can extract 1, more, or all of these elementary streams.

        + +

        The following figure illustrates the general media demuxer state changes.

        +

        Figure: Media demuxer state changes

        +

        Media demuxer state changes

        + + + + + + + + + + +
        Note
        All file types and container formats are not guaranteed to support the Media Demuxer API.
        + + + + +
        + +Go to top + + + + + + + + diff --git a/org.tizen.guides/html/native/multimedia/media_keys_n.htm b/org.tizen.guides/html/native/multimedia/media_keys_n.htm index baaba0d..8907ff8 100644 --- a/org.tizen.guides/html/native/multimedia/media_keys_n.htm +++ b/org.tizen.guides/html/native/multimedia/media_keys_n.htm @@ -32,15 +32,16 @@

        Media key

        -

        Tizen enables you to manage media key events. The media key events are generated by the remote control buttons in a Bluetooth headset or Bluetooth earphone. The media_key_e enumerator (in mobile and wearable applications) defines the available key types.

        +

        Tizen enables you to manage media key events. The media key events are generated by the remote control buttons in a Bluetooth headset or Bluetooth earphone. The media_key_e enumerator (in mobile and wearable applications) defines the available key types.

        The main features of the Media key API include:

        • Registering a callback

          You can register a callback for media key events using the media_key_reserve() function. The first parameter of the function defines the media_key_event_cb type callback, which you can implement to perform any actions you need.

        • -
        • Unregistering a callback -

          You can unregister a callback for media key events using the media_key_release() function.

        +
      3. Deregistering a callback +

        You can deregister a callback for media key events using the media_key_release() function.

    +

    Before you start, remember to prepare your application to use the media key functionality.

    diff --git a/org.tizen.guides/html/native/multimedia/media_muxer_n.htm b/org.tizen.guides/html/native/multimedia/media_muxer_n.htm new file mode 100644 index 0000000..ff8fad5 --- /dev/null +++ b/org.tizen.guides/html/native/multimedia/media_muxer_n.htm @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + Media Muxer + + + + + + +
    +

    Media Muxer

    + +

    You can create audio and video content with a given container format type, such as MP4.

    +

    The main features of the Media Muxer API include:

    +
      +
    • Video and audio elementary stream multiplexing
    • +
    • MP4 multiplexing support
    • +
    + +

    Tizen supports the MP4 multiplex output streams, and the following MP4 multiplex input elementary streams:

    +
      +
    • AVC/H.264 video elementary stream
    • +
    • MPEG-4 video elementary stream
    • +
    • MPEG-2 video elementary stream
    • +
    • MPEG audio elementary stream
    • +
    • AAC audio elementary stream
    • +
    + +

    A media muxer instance can be used to mux encoded media into 1 multiplexed stream. The media muxer can accommodate single or multiple encoded elementary streams of various types, such as audio, video, and text. A single instance of the media muxer can create 1 compatible container format by taking 1 or more elementary streams as input.

    + +

    Before you start, remember to prepare your application to use the media muxer functionality.

    + +

    The following figure illustrates the general media muxer state changes.

    +

    Figure: Media muxer state changes

    +

    Media muxer state changes

    + + + + + + + + + + +
    Note
    All file types and container formats are not guaranteed to support the Media Muxer API.
    + + + + +
    + +Go to top + + + + + + + + diff --git a/org.tizen.guides/html/native/multimedia/media_streamer_n.htm b/org.tizen.guides/html/native/multimedia/media_streamer_n.htm new file mode 100644 index 0000000..59a7427 --- /dev/null +++ b/org.tizen.guides/html/native/multimedia/media_streamer_n.htm @@ -0,0 +1,261 @@ + + + + + + + + + + + + + Media Streamer + + + + + + +
    + +

    Media Streamer

    + +

    Tizen enables you to use media streamer functionalities, such as playing video content and streaming video and audio over an IP. Media streaming allows you to stream content in 1 or both directions.

    + +

    Figure: Video call

    +

    Video call

    + +

    The media streamer is an object that manages media data flow in a kind of pipeline. The Media Streamer API provides various types of media processing pipelines using a simple GStreamer wrapper (Tizen uses GStreamer as a fundamental multimedia framework). To use the media streamer, familiarize yourself with how the GStreamer works. For more information, see http://gstreamer.freedesktop.org/.

    + +

    The media streamer works by using a collection of nodes, which are connected in a specific order to make a specific pipeline of multimedia data running through the nodes:

    + +
      +
    • The source nodes represent the source of the input data. The media streamer provides a common interface for getting a media stream from various source nodes, such as media files, network, and various input devices, such as cameras and microphones.
    • +
    • The topology nodes (transforming nodes) are used to transform the data along the pipeline.
    • +
    • The sink nodes are used to render the media stream data.
    • +
    + +

    The main features of the Media Streamer API include:

    + +
      +
    • +

      Creating the media streamer

      +

      You can create a media streamer handle used for linking content source and sink elements in server and client parts.

      +
    • +
    • +

      Plugging media streamer nodes in manual or autoplug mode

      +

      You can create a chain of media streamer nodes to properly play a video file or combine the server and client parts for streaming the content. This can be done manually or automatically within the Media Streamer framework.

      +
    • +
    • +

      Managing the media streamer parameters

      +

      You can set a number of parameters to properly play a video file or combine the server and client parts for playing or streaming the content. You can also get a number of parameters from the media streamer nodes to find out the characteristics of playing or streaming the content.

      +
    • +
    • +

      Playing files with the media streamer

      +

      You can play video files or launch content streaming over IP.

      +
    • +
    • +

      Destroying the media streamer

      +

      When no longer needed, you can destroy the media streamer handle used for linking content source and sink elements.

      +
    • +
    + +

    The Tizen Media Streamer framework can be used in many scenarios:

    + +
      +
    • +

      Playing a local video file

      +

      Figure: Playing a local video file

      +

      Playing a local video file

      +
    • +
    • +

      Playing a local video file with internal or external subtitles

      +

      Figure: Playing a local video file with subtitles

      +

      Playing a local video file with subtitles

      +
    • +
    • +

      Streaming a video file with or without internal subtitles through the IP protocol from the server part to the client part

      +

      Figure: Streaming a file through IP in the broadcast mode

      +

      Streaming a file through IP in the broadcast mode

      +
    • +
    • +

      Streaming video and audio content through the IP protocol from 1 device (server part) to another device (client part) in 1 way (broadcast mode) or both ways (VOIP mode)

      +

      Figure: Streaming video and audio content through IP in the broadcast or VOIP mode

      +

      Streaming video and audio content through IP in the broadcast or VOIP mode

      +
    • +
    + +

    Creating the Media Streamer

    + +

    The media streamer is created using the media_streamer_create(), media_streamer_node_create_src(), and media_streamer_node_create_sink() functions.

    + +

    The following types are examples of the source nodes according to their functionalities:

    + +
      +
    • MEDIA_STREAMER_NODE_SRC_TYPE_FILE

    • +
    • MEDIA_STREAMER_NODE_SRC_TYPE_CAMERA

    • +
    • MEDIA_STREAMER_NODE_SRC_TYPE_AUDIO_CAPTURE

    • +
    + +

    In the same concept, the following types are examples of the sink nodes:

    + +
      +
    • MEDIA_STREAMER_NODE_SINK_TYPE_OVERLAY

    • +
    • MEDIA_STREAMER_NODE_SINK_TYPE_AUDIO

    • +
    + +

    The media streamer RTP node is also created in case of a streaming scenario which is responsible for transmitting and receiving data through an IP.

    + +

    After the nodes are created, they are uploaded into the media streamer pipeline where, in connection with other topology nodes, they construct a logic chain to be launched according to the chosen scenario. The media_streamer_node_add() function is used to add a node to the media streamer.

    + +

    Plugging Media Streamer Nodes in Manual or Autoplug Mode

    + +

    The Media Streamer framework creates and links nodes for launching video encoding and decoding chains in manual or autoplug modes.

    + +
      +
    • +

      In the manual mode, a user takes responsibility on creating and linking the appropriate encoding or decoding chain of nodes to launch the media streamer for the chosen scenario.

      +

      The media streamer nodes are plugged in the manual mode using the media_streamer_node_create() and media_streamer_node_add() functions.

      +

      Link the media streamer nodes with the media_streamer_node_link() function.

      +

      The function attributes include src_pad_name and sink_pad_name, which can be src or sink, an income or outcome pads of the previous and the following nodes to be linked accordingly.

      +
    • +
    • In the autoplug mode, the video encoding and decoding chain of the media streamer is automatically constructed from the previously created source and sink nodes.

    • +
    + +

    Managing the Media Streamer Parameters

    + +

    The Media Streamer framework sets parameters onto the nodes for launching appropriate video encoding and decoding chains. It also gets parameters from the nodes to find out about the encoding and decoding characteristics of the node.

    + +

    Setting Parameters

    + +

    A parameter is set onto the media streamer node using the media_streamer_node_set_param() function. The function sets a possible parameter for the given node with the appropriate value. The possible parameter can be found in the media_streamer.h header file. The parameter can be, for example, MEDIA_STREAMER_PARAM_CAMERA_ID, MEDIA_STREAMER_PARAM_ROTATE, or MEDIA_STREAMER_PARAM_PORT. You can also set a parameter list using a bundle structure.

    + +

    The media_streamer_node_set_pad_format() function sets the media format onto the media streamer node pad. The pad of the media streamer node can be sink or src, which are income or outcome pads of the node. The following are examples of the format:

    + +
      +
    • MEDIA_FORMAT_RAW

    • +
    • +

      MEDIA_FORMAT_ENCODED

      +
        +
      • MEDIA_FORMAT_H263

      • +
      • MEDIA_FORMAT_YV12

      • +
      +
    • +
    + +

    You can use the following media streamer callbacks when setting parameters:

    + +
      +
    • The media_streamer_set_error_cb() and media_streamer_unset_error_cb() functions register and unregister an error callback function to be invoked when an error occurs.

    • +
    • The media_streamer_set_state_change_cb() and media_streamer_unset_state_change_cb() functions register and unregister a callback to be invoked after the media streamer state changes.

    • +
    • The media_streamer_src_set_buffer_status_cb() and media_streamer_src_unset_buffer_status_cb() functions register and unregister a callback function to be invoked when a buffer underrun or overflow occurs.

    • +
    • The media_streamer_sink_set_data_ready_cb() and media_streamer_sink_unset_data_ready_cb() functions register and unregister a callback function to be invoked when the custom sink is ready for data processing.

    • +
    • The media_streamer_sink_set_eos_cb() and media_streamer_sink_unset_eos_cb() functions register and unregister a callback function to be invoked when the custom sink detects the end-of-stream.

    • +
    + +

    Getting Parameters

    + +

    Use the media_streamer_node_get_param() function to get a parameter from the media streamer node. The function gets a parameter possible for the given node with the appropriate value. The possible parameters returned can be found in the media_streamer.h header file. They can be, for example, MEDIA_STREAMER_PARAM_CAMERA_ID, MEDIA_STREAMER_PARAM_ROTATE, or MEDIA_STREAMER_PARAM_PORT.

    + +

    You can also use the media_streamer_node_get_params() function to get the list of parameters from the created media streamer node in the bundle structure format.

    + +

    The media_streamer_node_get_pad_format() function gets the media format from the media streamer node pad. The pad of the media streamer node can be sink or src, which are income or outcome pads of the node. The following are examples of the format:

    + +
      +
    • MEDIA_FORMAT_RAW

    • +
    • +

      MEDIA_FORMAT_ENCODED

      +
        +
      • MEDIA_FORMAT_H263

      • +
      • MEDIA_FORMAT_YV12

      • +
      +
    • +
    + +

    To get the name from the media streamer node pad, use the media_streamer_node_get_pad_name() function. The src_pad_num parameter defines the number of src pads in the previous node, and the sink_pad_num parameter defines the number of sink pads in the following node.

    + +

    You can get the media streamer state using the media_streamer_get_state() function. The states of the media streamer node can be found in the media_streamer.h header file. The state can be, for example, MEDIA_STREAMER_STATE_READY.

    + +

    Playing Files with the Media Streamer

    + +

    Before playing the media streamer, it must be prepared and the state of the media streamer nodes must be set to the MEDIA_STREAMER_STATE_READY state in server and client parts.

    + +

    The media_streamer_prepare() function prepares the media streamer. With this function, the encoding chain of the media streamer nodes becomes fully constructed, if the autoplug mode is chosen within the streaming scenario.

    + +

    To play or stream files with the media streamer, use the media_streamer_play() function in server and client parts. The media streamer state changes to MEDIA_STREAMER_STATE_PLAYING. With this function, the decoding chain of the media streamer nodes becomes fully constructed, if the autoplug mode is chosen within the streaming or playing scenario. The media streamer starts playing or streaming content, and the appropriate content appears on the sink nodes.

    + +

    You can control the playing status of the media streamer:

    + +
      +
    • +

      Pause

      +

      The media_streamer_pause() function sets the media streamer state to MEDIA_STREAMER_STATE_PAUSED in the playing mode or at the server part in the streaming mode. Playing or streaming of the content pauses, and this can be seen on the sink nodes.

      +
    • +
    • +

      Stop

      +

      The media_streamer_stop() function sets the media streamer state to MEDIA_STREAMER_STATE_PAUSED in the playing mode or at the server part in the streaming mode. The position of the content is set to the 0sec position. Playing or streaming of the content stops, and this can be seen on the sink nodes.

      +
    • +
    • +

      Seek

      +

      The media_streamer_set_play_position() function seeks the content at the appropriate playing position set in milliseconds in the playing mode or at the server part in the video file streaming mode. Playing or streaming of the content seeks to the appropriate position, and this can be seen on the sink nodes.

      +
    • +
    • +

      Get info

      +

      The media_streamer_get_play_position() and media_streamer_get_duration() functions get the media streamer playing position and duration of the content in milliseconds in the playing mode or at the server part in the video file streaming mode.

      +
    • +
    + +

    Destroying the Media Streamer

    + +

    Before destroying the media streamer, it must be unprepared using the media_streamer_unprepare() function, and the state of the media streamer nodes must be set to MEDIA_STREAMER_STATE_IDLE.

    + +

    With the media_streamer_unprepare() function, the media streamer nodes within the encoding and decoding chains become disconnected, if the autoplug mode is chosen in the streaming or playing scenario. Any intermediate topology nodes between the source and sink nodes that have been automatically created are removed.

    + +

    Use the media_streamer_node_remove() and media_streamer_node_destroy() functions to remove and destroy a media streamer node created in the manual mode.

    + +

    To destroy the media streamer, use the media_streamer_destroy() function. The media streamer nodes that have not been removed manually from the media streamer are removed automatically.

    + + + +
    + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.guides/html/native/multimedia/media_tools_n.htm b/org.tizen.guides/html/native/multimedia/media_tools_n.htm index 12c7cb4..c6cff02 100644 --- a/org.tizen.guides/html/native/multimedia/media_tools_n.htm +++ b/org.tizen.guides/html/native/multimedia/media_tools_n.htm @@ -36,12 +36,13 @@

    The main features of the Media Tool API include:

    • Creating the media_format_h handle to specify video or audio information.

      -

      You can set and get video or audio information using the media_format_h handle.

    • +

      You can set and get video or audio information using the media_format_h handle.

    • Creating the media_packet_h handle to include metadata (such as pts, dts, and duration) and allocate a buffer to the heap or TBM surface.

      -

      You can set and get the metadata using the created media_packet_h handle. Some media_packet_h metadata are NOT filled after creating the media_packet_h handle: pts, dts, duration, extradata, codec data, codec data size, and buffer flags.

      +

      You can set and get the metadata using the created media_packet_h handle. Some media_packet_h metadata are NOT filled after creating the media_packet_h handle: pts, dts, duration, extradata, codec data, codec data size, and buffer flags.

    +

    Before you start, remember to prepare your application to use the media tool functionality.

    The media_format_h handle is created by the caller, who can set and get the video or audio information. The media_format_h handle creates the media_packet_h handle and allocates the buffer. The caller can set and get the metadata with the media_packet_h handle.

    diff --git a/org.tizen.guides/html/native/multimedia/media_vision_n.htm b/org.tizen.guides/html/native/multimedia/media_vision_n.htm index b266d39..14a245f 100644 --- a/org.tizen.guides/html/native/multimedia/media_vision_n.htm +++ b/org.tizen.guides/html/native/multimedia/media_vision_n.htm @@ -40,10 +40,10 @@
    • Handling images -

      You can handle images by creating a source handle and filling it from an image buffer or media packet. Create the source handle with the mv_create_source() function, and fill it with the mv_source_fill_by_buffer() or mv_source_fill_by_media_packet() function.

      +

      You can handle images by creating a source handle and filling it from an image buffer or media packet. Create the source handle with the mv_create_source() function, and fill it with the mv_source_fill_by_buffer() or mv_source_fill_by_media_packet() function.

    • Detecting barcodes -

      You can detect barcodes in an image or from camera preview streams, and then decrypt them to display messages to the user.

      +

      You can detect barcodes in an image or from camera preview streams, and then decrypt them to display messages to the user.

      Before detecting a barcode, you must define the barcode detection target attribute value:

      • Detect both 1D and 2D barcodes
      • @@ -52,7 +52,7 @@
    • Generating barcodes -

      You can encrypt a given message, generate a barcode from it, and save it in a memory or as a file.

      +

      You can encrypt a given message, generate a barcode from it, and save it in a memory or as a file.

      Before generating a barcode, you must define the barcode text generation attribute value:

      • Generate barcode without an input message
      • @@ -120,7 +120,7 @@ INTERLEAVED 2 of 5 - Interleaved two of five with numeric digits + Interleaved 2 of 5 with numeric digits

        UPC-A

        diff --git a/org.tizen.guides/html/native/multimedia/metadata_editor_n.htm b/org.tizen.guides/html/native/multimedia/metadata_editor_n.htm index 28e94ae..c6ecb36 100644 --- a/org.tizen.guides/html/native/multimedia/metadata_editor_n.htm +++ b/org.tizen.guides/html/native/multimedia/metadata_editor_n.htm @@ -31,7 +31,7 @@

        Metadata Editor

        -

        You can edit the metadata of several popular audio formats using the metadata editor. You can add and remove album art, or update the information of the audio file.

        +

        You can edit the metadata of several popular audio formats using the metadata editor. You can add and remove album art, or update the information of the audio file. Remember to initialize the metadata editor before you start.

        This feature is supported in mobile applications only.

        diff --git a/org.tizen.guides/html/native/multimedia/metadata_extractor_n.htm b/org.tizen.guides/html/native/multimedia/metadata_extractor_n.htm index 3ce3d7e..88b48be 100644 --- a/org.tizen.guides/html/native/multimedia/metadata_extractor_n.htm +++ b/org.tizen.guides/html/native/multimedia/metadata_extractor_n.htm @@ -22,7 +22,7 @@

        Related Info

        @@ -32,7 +32,7 @@

        Metadata Extractor

        -

        Media files, such as mp3 and mp4 files, contain metadata. Metadata extractor enables you to extract metadata from the media files.

        +

        Media files, such as mp3 and mp4 files, contain metadata. Metadata extractor enables you to extract metadata from the media files. Remember to initialize it before use.

        Figure: Getting metadata

        Getting metadata

        diff --git a/org.tizen.guides/html/native/multimedia/multimedia_guide_n.htm b/org.tizen.guides/html/native/multimedia/multimedia_guide_n.htm index 24055ba..08be41a 100644 --- a/org.tizen.guides/html/native/multimedia/multimedia_guide_n.htm +++ b/org.tizen.guides/html/native/multimedia/multimedia_guide_n.htm @@ -41,8 +41,14 @@

        Enables you to view and process (decode, encode, convert, and compress) bitmap images in the JPEG format.

      • Media Codec

        Enables you to use codecs to encode and decode video and audio data.

      • +
      • Media Demuxer +

        Enables you to parse multiplexed media streams.

      • Media key -

        Enables you to manage callbacks for media key events.

      • +

        Enables you to manage callbacks for media key events.

        +
      • Media Muxer +

        Enables you to mux encoded media into a multiplexed stream.

      • +
      • Media Streamer +

        Enables you to play and stream audio and video content over an IP.

      • Media Tool

        Enables you to use media tools to manage various media handles.

      • Metadata Extractor

        Enables you to extract metadata from the media files.

      • diff --git a/org.tizen.guides/html/native/multimedia/openal_n.htm b/org.tizen.guides/html/native/multimedia/openal_n.htm index 6d44827..57ffab4 100644 --- a/org.tizen.guides/html/native/multimedia/openal_n.htm +++ b/org.tizen.guides/html/native/multimedia/openal_n.htm @@ -51,20 +51,18 @@
        • Creating a context

          You must first open an audio device through which your audio stream flows. After the device is successfully opened, create and activate a context. Once your device is associated with a current context, your commands are applied to that context.

          -

          To create a context:

          +

          To create a context:

          -// Open default device
          -device = alcOpenDevice(NULL); 
          -if (device != NULL) 
          -{
          -   // Create context
          -   context=alcCreateContext(device, NULL); 
          -   if (context != NULL) 
          -   {
          -      // Set active context
          -      alcMakeContextCurrent(context); 
          -   }
          +/* Open default device */
          +device = alcOpenDevice(NULL);
          +if (device != NULL) {
          +    /* Create context */
          +    context=alcCreateContext(device, NULL);
          +    if (context != NULL) {
          +        /* Set active context */
          +        alcMakeContextCurrent(context);
          +    }
           }
           
          @@ -85,14 +83,14 @@ if (device != NULL)
        • Requesting a source and buffer

          To play a sound, a source object is required. Through the source, you can update the stream attributes, such as the default gain and the position of the sound.

          -

          In addition, you need an audio buffer that contains your audio data.

          +

          In addition, you need to request an audio buffer that contains your audio data.

        • Controlling the audio stream -

          When the source and buffer are ready, you can manage the playback by playing, stopping, rewinding, or pausing your audio stream. All the control commands are operated with the source you have acquired.

        • +

          When the source and buffer are ready, you can manage the playback by playing, stopping, rewinding, or pausing your audio stream. All the control commands are operated with the source you have acquired.

        -

        To use OpenAL, you must create a context and the initial set of buffers, load the buffers with sample data, create sources, attach the buffers to the sources, set the locations and directions for the listener and sources, and set the initial values for the OpenAL state global.

        +

        To use OpenAL, you must create a context and the initial set of buffers, load the buffers with sample data, create sources, attach the buffers to the sources, set the locations and directions for the listener and sources, and set the initial values for the OpenAL state global. You can also queue buffers.

        diff --git a/org.tizen.guides/html/native/multimedia/player_n.htm b/org.tizen.guides/html/native/multimedia/player_n.htm index 48b3e00..b4adeae 100644 --- a/org.tizen.guides/html/native/multimedia/player_n.htm +++ b/org.tizen.guides/html/native/multimedia/player_n.htm @@ -37,13 +37,13 @@

        Player

        -

        You can play audio, video, and tones in your application.

        +

        You can play audio, video, and tones in your application. Remember to initialize the player before use.

        The main player features are:

        -

        The maximum count of a player instance is limited by the system and multimedia resources. The maximum count is a system-wide count and it can be applied depending on the CPU model, CPU speed, CPU core number, CPU load from other applications, and the available memory. Thus, the exact count can be smaller than the maximum count, in which case the prepare functions fail. A reasonable working player count is under 10.

        +

        The maximum count of a player instance is limited by the system and multimedia resources. The maximum count is a system-wide count and it can be applied depending on the CPU model, CPU speed, CPU core number, CPU load from other applications, and the available memory. Thus, the exact count can be smaller than the maximum count, in which case the prepare functions fail. A reasonable working player count is under 10. You can stop a player to free up system resources.

        The player works based on the audio session manager policy. This means that an application can be interrupted by another application if a resource is in conflict or it has an audio policy rule to follow. You can change the session's property directly by using the Sound Manager API (in mobile and wearable applications).

        The callback interface specifies the functions used to notify the player status during playback events. Since the player engine works asynchronously, you must implement this listener to ensure that the player flows correctly. When each player operation is completed, an event is generated, and the player_completed_cb() function is called. If an error occurs in the player engine, you are notified if you have registered the player_error_cb() callback.

        If the player state is changed to ready, the multimedia resource is available and you can get content information of the media. You can also get content information in a playing state in some cases of playback streaming.

        @@ -73,7 +73,7 @@

        The player_interrupted_cb() function is called when an application is interrupted by another application. The player is paused or moved to an idle state according to the audio policy. You must check the state of the current instance and take appropriate action. If the player is changed to a paused state due to an interruption, the PLAYER_INTERRUPTED_COMPLETED can be called at the end of the interruption. For example, if the application is interrupted by a call, alarm, or notification, the completed message is posted. However, no messages are posted if the interruption has other causes. Make sure you handle the application accordingly when audio switching occurs between various applications.

        -

        Multiple instances of the player can be used to play several audio data streams concurrently. This means that your application can play multiple uncompressed audio files at the same time.

        +

        You can use multiple instances of the player to play several audio data streams concurrently. This means that your application can play multiple uncompressed audio files at the same time.

        The following figure illustrates the general player state changes:

        Figure: Player state changes

        @@ -107,17 +107,15 @@ The main features of the Player API include:
      • Player

        Use the Player API to control audio and video stream.

        After changing to the READY state, properties such as volume, sound type, latency mode, mute mode, and looping mode can be adjusted.

        -

        To learn about these features, see the Player Tutorial.

      • Display

        Use the Display API to play video stream.

        -

        After changing to the IDLE state, create the display handle and set the display type.

        -

        To learn about these features, see the Setting Display Parameters.

        +

        After changing to the IDLE state, create the display handle and set the display type.

        +
      • Stream Info

        Use the Stream Info API to play video stream.

        -

        After changing to the READY state, you can retrieve stream information.

        -

        To learn about these features, see the Getting Stream Information.

        +

        After changing to the READY state, you can retrieve stream information.

      • Audio Effect @@ -125,9 +123,8 @@ The main features of the Player API include:

        After changing to the IDLE state, you can adjust the audio effect.

      • Subtitle -

        Use the Subtitle API to read the subtitle track.

        +

        Use the Subtitle API to read the subtitle track.

        After changing to the READY state, the subtitle can be read.

        -

        To learn about these features, see the Inserting Subtitles.

      diff --git a/org.tizen.guides/html/native/multimedia/radio_n.htm b/org.tizen.guides/html/native/multimedia/radio_n.htm index b4224aa..b8bdd55 100644 --- a/org.tizen.guides/html/native/multimedia/radio_n.htm +++ b/org.tizen.guides/html/native/multimedia/radio_n.htm @@ -43,7 +43,7 @@
    • Setting the state of the radio
    -

    A handle for radio instance is created using the radio_create() function. A successful creation of the handle requires a radio tuner. You can switch the radio on and off using the radio_start() and radio_stop() functions. Select the radio frequency using the radio_set_frequency() function or radio_seek_up() and radio_seek_down() functions.

    +

    Create a handle for a radio instance using the radio_create() function. A successful creation of the handle requires a radio tuner. You can switch the radio on and off using the radio_start() and radio_stop() functions. Scan for frequencies and select the radio frequency using the radio_set_frequency() function, or seek an adjacent channel with the radio_seek_up() and radio_seek_down() functions.

    The Radio API allows only one instance at the time. Radio playback can be interrupted by another radio application.

    diff --git a/org.tizen.guides/html/native/multimedia/recorder_n.htm b/org.tizen.guides/html/native/multimedia/recorder_n.htm index fd0a2a0..3b44aa6 100644 --- a/org.tizen.guides/html/native/multimedia/recorder_n.htm +++ b/org.tizen.guides/html/native/multimedia/recorder_n.htm @@ -45,8 +45,10 @@
  • Controlling the system volume level
  • +

    To record audio or record a video, you need to initialize the audio recorder or the video recorder.

    +

    The following file formats are supported:

    -
      +
      • Video: mp4 and 3gp
      • Audio: m4a and amr
      diff --git a/org.tizen.guides/html/native/multimedia/screen_mirroring_n.htm b/org.tizen.guides/html/native/multimedia/screen_mirroring_n.htm index 3aeb448..67466cd 100644 --- a/org.tizen.guides/html/native/multimedia/screen_mirroring_n.htm +++ b/org.tizen.guides/html/native/multimedia/screen_mirroring_n.htm @@ -31,7 +31,7 @@

      Screen Mirroring

      -

      You can mirror the device screen and sound to another device wirelessly using the screen mirroring feature. It follows the Wi-Fi Display Technical Specification and supports the feature as a sink, which receives shared data from a source device that supports the Wi-Fi Display, and displays it.

      +

      You can mirror the device screen and sound to another device wirelessly using the screen mirroring feature. Tizen follows the Wi-Fi Display Technical Specification and supports the feature as a sink, which receives shared data from a source device that supports the Wi-Fi Display, and displays it. Remember to initialize the screen mirroring sink and prepare it before you start, and release the resources when you are done.

      This feature is supported in mobile applications only.

      @@ -46,6 +46,7 @@
    • Monitoring state changes in the screen mirroring sink

      To track state changes, you can register a callback with the scmirroring_sink_set_state_changed_cb() function. The callback is triggered when the screen mirroring state changes or an error occurs.

      Since all functions that change the state are synchronous (except for scmirroring_sink_connect(), scmirroring_sink_start(), scmirroring_sink_pause(), and scmirroring_sink_resume()) most function results are passed to the application through the callback mechanism.

      +

      You can also handle exceptions if any occur.

    diff --git a/org.tizen.guides/html/native/multimedia/sound_manager_n.htm b/org.tizen.guides/html/native/multimedia/sound_manager_n.htm index a19fc91..27495e0 100644 --- a/org.tizen.guides/html/native/multimedia/sound_manager_n.htm +++ b/org.tizen.guides/html/native/multimedia/sound_manager_n.htm @@ -38,19 +38,19 @@

    Sound Manager

    -

    The sound manager allows you to control the audio behavior of your application.

    +

    The sound manager allows you to control the audio behavior of your application.

    The main features of the Sound Manager API include:

    Volume Control

    diff --git a/org.tizen.guides/html/native/multimedia/thumbnail_util_n.htm b/org.tizen.guides/html/native/multimedia/thumbnail_util_n.htm index 01e58de..de96bae 100644 --- a/org.tizen.guides/html/native/multimedia/thumbnail_util_n.htm +++ b/org.tizen.guides/html/native/multimedia/thumbnail_util_n.htm @@ -38,7 +38,7 @@

    The main features of the Thumbnail Util API include:

    • Video and image thumbnails -

      You can create thumbnails with video and image files. Audio files are not supported.

    • +

      You can create thumbnails with video and image files. Audio files are not supported. Remember to initialize the thumbnail utility before use.

    • Custom size

      You can create the thumbnail using any size you like. The Thumbnail Util API outputs the results according to the size you have set. This means that the thumbnail can be generated even if the output size differs from the original aspect ratio.

    diff --git a/org.tizen.guides/html/native/multimedia/tone_player_n.htm b/org.tizen.guides/html/native/multimedia/tone_player_n.htm index dcd6e16..bd4fcd0 100644 --- a/org.tizen.guides/html/native/multimedia/tone_player_n.htm +++ b/org.tizen.guides/html/native/multimedia/tone_player_n.htm @@ -39,6 +39,8 @@
  • Use a DTMF (Dual Tone Multi Frequency) preset frequency value of the tone_type_e.

  • +

    After you initialize the tone player, you can start and stop playing a tone. You can also play a tone for a specified duration.

    +

    The following figures illustrate the general tone player states, and how the state changes when your application calls the Tone player API.

    Figure: Tone player states

    Tone player states

    diff --git a/org.tizen.guides/html/native/multimedia/video_util_n.htm b/org.tizen.guides/html/native/multimedia/video_util_n.htm index dcc35d2..9ac3d94 100644 --- a/org.tizen.guides/html/native/multimedia/video_util_n.htm +++ b/org.tizen.guides/html/native/multimedia/video_util_n.htm @@ -42,6 +42,12 @@

    This feature is supported in mobile applications only.

    +

    With the Video Util API you can:

    + +

    The following figure shows the result of the video file size change (due to scaling and container and codec format change).

    Figure: Transcoder

    diff --git a/org.tizen.guides/html/native/multimedia/wav_player_n.htm b/org.tizen.guides/html/native/multimedia/wav_player_n.htm index 7e2a128..9fcb05e 100644 --- a/org.tizen.guides/html/native/multimedia/wav_player_n.htm +++ b/org.tizen.guides/html/native/multimedia/wav_player_n.htm @@ -38,10 +38,10 @@
  • wav player header

    When using the wav player header, your application uses its own user interface.

  • The WAV Player API provides controlling functions for using audio resources. The resources can be a media file stored in the device.

    -

    Use the WAV Player API to enable your application to play audio and control playback. The audio features of this API include:

    +

    Use the WAV Player API to enable your application to play audio and control playback. The audio features of this API let you:

      -
    • Playing audio media from local files
    • -
    • Controlling playback using play and stop
    • +
    • Play audio media from local files
    • +
    • Control playback using play and stop

    The audio formats your application can use with the WAV Player API include:

    diff --git a/org.tizen.guides/html/native/network/bluetooth_n.htm b/org.tizen.guides/html/native/network/bluetooth_n.htm index fb40070..6887d17 100644 --- a/org.tizen.guides/html/native/network/bluetooth_n.htm +++ b/org.tizen.guides/html/native/network/bluetooth_n.htm @@ -40,12 +40,12 @@
    • Managing the local Bluetooth adapter -

      The Bluetooth Adapter API (in mobile and wearable applications) provides functions for setting up Bluetooth and discovering other devices. The API is used to control the Bluetooth adapter: you must enable the adapter before any other Bluetooth actions, and when you no longer need it, disable it to save device power.

      -

      You can control the visibility of the device, meaning whether its name appears to others searching for Bluetooth devices. In addition, you discover neighboring Bluetooth devices. This process is asynchronous, so you must build and hold the list of devices in the neighborhood.

      +

      The Bluetooth Adapter API (in mobile and wearable applications) provides functions for setting up Bluetooth and discovering other devices. The API is used to control the Bluetooth adapter: you must enable the adapter before any other Bluetooth actions, and when you no longer need it, disable it to save device power. You can check and monitor the adapter state.

      +

      You can control the visibility of the device, meaning whether its name appears to others searching for Bluetooth devices. In addition, you can discover neighboring Bluetooth devices. This process is asynchronous, so you must build and hold the list of devices in the neighborhood.

    • Discovering devices -

      The Bluetooth Device API (in mobile and wearable applications) provides functions for managing bonds with other devices and searching for supported services. The API is used to handle the connection with other devices and to search for services available on remote devices.

      -

      You can discover other Bluetooth devices. The device discovery process can retrieve multiple types of Bluetooth devices, such as printers, mobile phones, and headphones.

      +

      The Bluetooth Device API (in mobile and wearable applications) provides functions for managing bonds with other devices and searching for supported services. The API is used to handle the connection with other devices and to search for services available on remote devices.

      +

      You can discover other Bluetooth devices. The device discovery process can retrieve multiple types of Bluetooth devices, such as printers, mobile phones, and headphones.

    • Creating a bonding with a Bluetooth device

      You can create a bonding with another device with the Bluetooth Device API. The bonding allows the 2 devices to establish a connection.

      @@ -53,13 +53,15 @@
    • Connecting to and exchanging data with a Bluetooth device using a Bluetooth socket

      The Bluetooth Socket API (in mobile and wearable applications) provides functions for managing connections to other devices and exchanging data. The API is used for exchanging data between 2 Bluetooth devices, where your device can have the role both of a server (service provider) and client (service user). The connection creation process differs based on the role. After the connection is established, the processes for exchanging data and disconnecting are the same for both roles.

      -

      When you attempt to open a connection to another device, a Service Discovery Protocol (SDP) look-up is performed on the device, and the protocol and channel to be used for the connection are determined. If a connection is established and the socket is opened successfully, a BluetoothSocket instance with an open state is returned. The socket is subsequently used for exchanging data between the connected devices.

      +

      When you attempt to open a connection to another device, a Service Discovery Protocol (SDP) look-up is performed on the device, and the protocol and channel to be used for the connection are determined. If a connection is established and the socket is opened successfully, a BluetoothSocket instance with an open state is returned. The socket is subsequently used for exchanging data between the connected devices.

      +

      You can use Serial Port Profile (SPP) operations to connect to other devices, exchange data, and disconnect from connected devices.

    • Connecting to audio devices with Bluetooth

      Connect to Bluetooth audio devices, such as headset, hand-free, and headphone using the Bluetooth Audio API (in mobile and wearable applications).

    • Handling attributes with Bluetooth GATT

      The Bluetooth GATT API (in mobile and wearable applications) provides functions for creating and destroying the GATT client handle, discovering, reading, and modifying attributes, and setting and releasing callbacks to be notified when characteristic values are changed at the remote device.

      -

      As a client, you can connect to and use a specific service on the server device. Once the connection is established, the client can manage the service attributes. When the GATT client operations are no longer required, unregister the callbacks and destroy GATT client handle.

      +

      As a client, you can connect to and use a specific service on the server device. Once the connection is established, the client can manage the service attributes. When the GATT client operations are no longer required, deregister the callbacks and destroy the GATT client handle.

      +

      You can use GATT operations to handle preconditions, manage client operations, manage getter operations, and manage setter operations.

    • Connecting to health devices with Bluetooth HDP

      Manage connections to health devices and exchange data using the Bluetooth HDP API (in mobile and wearable applications).

      @@ -74,12 +76,15 @@
    • Exchanging data with Bluetooth LE

      The Bluetooth LE Adapter API (in mobile and wearable applications) provides functions for managing the Bluetooth Low Energy (BLE) connections with other BLE devices and exchanging data between them.

      You can control the visibility of the BLE device, meaning whether its name appears to others searching for BLE devices. In addition, you discover neighboring BLE devices. This process is asynchronous, so you must build and hold the list of devices in the neighborhood.

      +

      You can use LE operations to manage scans, discover nearby devices, add advertising data, set the advertising connectable mode, set the advertising mode, and start and stop advertising.

    • Controlling remote audio and video devices with Bluetooth AVRCP

      The Bluetooth AVRCP feature (in mobile applications) provides functions for remotely controlling audio and video devices.

      Bluetooth AVRCP is used with A2DP. You can handle remote controls (such as play, pause, stop, equalizer, repeat, shuffle, and scan) through AVRCP.

    +

    Initialize Bluetooth before you start and release all resources when you are done.

    +

    Bluetooth use is based on profiles. Tizen Bluetooth features support the Audio, GATT, HDP, HID, and OPP client and server profiles.

    diff --git a/org.tizen.guides/html/native/network/connection_n.htm b/org.tizen.guides/html/native/network/connection_n.htm index 4b77061..bbea077 100644 --- a/org.tizen.guides/html/native/network/connection_n.htm +++ b/org.tizen.guides/html/native/network/connection_n.htm @@ -39,16 +39,25 @@

    Connection

    The connection features enable you to create a network connection and perform various operations over the connection. The application can access connection details, such as the IP address, proxy information, gateway information, and connection statistics.

    +

    With the connection APIs, you can work with IP sockets:

    +

    Connection Manager

    -

    The Connection Manager API (in mobile and wearable applications) provides functions for managing data connections. It allows you to get a state of the connection interface such as Bluetooth, cellular, and Wi-Fi. It also contains functions for getting the IP address, proxy information, and gateway information.

    +

    The Connection Manager API (in mobile and wearable applications) provides functions for managing data connections. It allows you to get a state of the connection interface such as Bluetooth, cellular, and Wi-Fi. It also contains functions for getting the IP address, proxy, and gateway information, and registering property change callbacks.

    -

    The Connection Manager API is related with libcurl and sockets. After a network connection is established, you can create a socket on the kernel Linux stack to be used directly or by libcurl or any other network library. If you want to create a socket directly without libcurl, you must check whether you are using the IPv4 or IPv6 environment, and create an applicable IP socket.

    +

    The Connection Manager API is related to libcurl (see the Curl guide) and sockets. After a network connection is established, you can create a socket on the kernel Linux stack to be used directly or by libcurl or any other network library. If you want to create a socket directly without libcurl, you must check whether you are using the IPv4 or IPv6 environment, and create an applicable IP socket.

    The Connection Manager provides the following typedefs and enumerators for managing data connections:

    • connection_h -

      Connection handle for all connection functions. To use the Connection Manager API, first create a connection handle using the connection_create() function. Afterwards, you can obtain network information.

    • +

      Connection handle for all connection functions. To use the Connection Manager API, first create a connection handle using the connection_create() function. Afterwards, you can obtain network information.

    • connection_profile_h

      Profile handle, which provides information according to the connection type.

    • Connection state enumerators @@ -60,12 +69,25 @@
    • connection_address_family_e

      Enumeration for the address family. It provides IPv4 and IPv6. You can use it as a parameter when you get the IP address of the current connection or proxy.

    + + + + + + + + + +
    Note
    To handle HTTP and HTTPS request in a proxy environment, get the proxy address using the Connection Manager and then set the proxy address using the Connection Profile API (in mobile and wearable applications). +

    In case of libcurl, you can use the CURLOPT_PROXY option.

    + +

    Connection Profile

    The Connection Profile API (in mobile and wearable applications) provides functions for mapping a connection profile. It allows you to use a connection_profile_h handle for getting details about the connection.

    Each profile is defined by a set of configuration information defined in the connection_profile_h handle. The profile provides different information according to the connection type (such as Bluetooth, cellular, ethernet, and Wi-Fi).

    -

    The following tables define the available profile information, which you can get using the connection_profile_get_*() function.

    +

    The following tables define the available profile information, which you can get using the connection_profile_get_XXX() function.

    @@ -206,7 +228,7 @@

    Connection Statistics

    -

    Use the Connection Statistics API (in mobile and wearable applications) to gather and reset statistics on the network usage, such as the amount of sent or received data. The statistics also provide functions for getting the cumulative size of packets sent or received since the last reset based on the operation mode, such as packet switching (PS).

    +

    Use the Connection Statistics API (in mobile and wearable applications) to gather statistics on the network usage, such as the amount of sent or received data. The statistics also provide functions for getting the cumulative size of packets sent or received since the last reset based on the operation mode, such as packet switching (PS).

    diff --git a/org.tizen.guides/html/native/network/curl_n.htm b/org.tizen.guides/html/native/network/curl_n.htm new file mode 100644 index 0000000..f4ad682 --- /dev/null +++ b/org.tizen.guides/html/native/network/curl_n.htm @@ -0,0 +1,91 @@ + + + + + + + + + + + + + Curl + + + + + +
    +

    Curl

    + +

    You can implement URL-related transfer activities in Tizen without a Web browser using the open source libcurl library, version 7.40. libcurl is a client-side URL transfer library that supports, among other protocols, HTTP, HTTPS, FTP, and file URIs.

    + +

    The main features of the Curl API include:

    +
    + + + + + + + + +
    Note
    In some cases, such as with Internet access, your application requires some privileges. For more information on which privileges to set in the application manifest file, see Non-API Bound Privileges.
    + +
  • Managing the proxy address +

    You can get and set the proxy address in multiple ways.

    + + + + + + + + + +
    Note
    In a proxy environment, the libcurl library does not know the proxy address. To handle HTTP and HTTPS requests in a proxy environment, first get the proxy address using the connection manager, and then set the proxy address using the Curl API.
    +
  • +
  • Transferring HTTP requests +

    You can transfer HTTP requests using the curl_easy_setopt() function.

  • + + + + + + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.guides/html/native/network/iotcon_n.htm b/org.tizen.guides/html/native/network/iotcon_n.htm new file mode 100644 index 0000000..f3a4023 --- /dev/null +++ b/org.tizen.guides/html/native/network/iotcon_n.htm @@ -0,0 +1,126 @@ + + + + + + + + + + + + + Iotcon + + + + + +
    +

    Iotcon

    + +

    IoTivity offers seamless device-to-device connectivity to address the emerging needs of the Internet of Things (IoT) through the open source reference implementation of the OIC (Open Interconnect Consortium) standard specifications. IoT connectivity (Iotcon) provides the means of using IoTivity in Tizen.

    + +

    Figure: IoTivity in Tizen

    +

    IoTivity in Tizen

    + +

    IoT connectivity is usually handled with a server and client. The server is responsible for creating and providing resources, and the client can access those resources through requests.

    + +

    The main features of the Iotcon API include:

    +
      +
    • Resource management +

      Entities in the physical world, such as a light, a fan, or modules of a home appliance, are represented as resources with the following properties:

      +
        +
      • Resource URI path: Value that corresponds to a resource
      • +
      • Resource types: Values for identifying a resource
      • +
      • Resource interfaces: List of the interfaces supported by the resource
      • +
      • Resource properties: Whether the resource is observable and discoverable
      • +
      + +

      You can manage the IoT resources with the server, which can create resources and later destroy them using the iotcon_resource_create() and iotcon_resource_destroy() functions of the Resource API (in mobile and wearable applications). After creating a resource, the server can bind the resource types and resource interfaces using the iotcon_resource_bind_type() and iotcon_resource_bind_interface() functions. After a resource is destroyed, the client cannot access the resource anymore.

      + +

      If the resource is discoverable, the client can find the resource. Otherwise, only the clients that already know the resource information can access it. If the resource is observable, the client can observe it.

      +
    • + +
    • Remote resource management +

      If the resource created by the server is discoverable, the client that knows the resource type can find the resource using the iotcon_find_resource() function of the Client API (in mobile and wearable applications). If the host_address (the first parameter) is NULL, the find request is sent as multicast. If the resource_type (the third parameter) is NULL, the request finds every resource type. If the client does not know the server host address or the resource type of the resource, it cannot find the resource.

      + +

      If the client wants to access a resource whose information it already knows, it can make a proxy using the iotcon_remote_resource_create() function of the Remote Resource API (in mobile and wearable applications) and access the resource through that proxy.

      + +

      You can use the client to get various information about the resource through the iotcon_remote_resource_h handle and the iotcon_remote_resource_get_XXX() functions. You can retrieve, for example, the resource URI path, host address, type, and interfaces. You can also retrieve the device ID, which defines the device to which the resource belongs. Different resources in the same device have the same device ID.

      +
    • + +
    • CRUDN request and response +

      The client can send various requests to the server resources using the Remote Resource API:

      +
        +
      • GET request: Use the iotcon_remote_resource_get() function to read the resource information and get a representation of the resource from the server.
      • +
      • PUT request: Use the iotcon_remote_resource_put() function to ask the server to update the resource representation.
      • +
      • POST request: Use the iotcon_remote_resource_post() function to ask the server to create a new resource.
      • +
      • DELETE request: Use the iotcon_remote_resource_delete() function to ask the server to delete a resource.
      • +
      + +

      The server receives the request, processes it using the iotcon_request_handler_cb() callback, and sends a response to the client using the iotcon_response_send() function of the Response API (in mobile and wearable applications).

      +

      The client can check the result and the response in the iotcon_remote_resource_response_cb() callback. If the result of the request differs from IOTCON_ERROR_NONE, the response information is not reliable.

      + +

      Figure: Requests and responses

      +

      Requests and responses

      + +

      If the server resource is observable, the client can register a callback with the iotcon_remote_resource_observe_register() function of the Remote Resource API to observe the resource. When the resource state changes, the server notifies the client through the registered callback. Note that, depending on the network environment, the order in which the notifications are sent can be mixed. If the observe_policy (the second parameter of the registration function) is IOTCON_OBSERVE_IGNORE_OUT_OF_ORDER, the client only receives up-to-date notifications. Otherwise, it receives all notifications, including stale notifications.

      +

      If the resource is not observable, the client cannot receive any notifications.

      + +

      Figure: Observe and notify

      +

      Observe and notify

      +
    • + +
    • Resource representation +

      Resource representation is a snapshot of a resource at a particular time, representing the resource information exchanged in the request and response interactions between the server and client. The resource representation contains resource properties and the state of the resource.

      + +

      Figure: Resource representation

      +

      Resource representation

      + +

      To manage the representation, use the Representation (in mobile and wearable applications) and State (in mobile and wearable applications) APIs:

      +
        +
      • Create a resource representation with the iotcon_representation_create() function.
      • +
      • Set the properties on the created representation with the iotcon_representation_set_XXX() functions.
      • +
      • Create a resource state with the iotcon_state_create() function.
      • +
      • Use the created state to set resource attributes by adding key-value pairs with the iotcon_state_add_XXX() functions.
      • +
      +
    • +
    + + + +
    + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.guides/html/native/network/mtp_n.htm b/org.tizen.guides/html/native/network/mtp_n.htm new file mode 100644 index 0000000..db1d80e --- /dev/null +++ b/org.tizen.guides/html/native/network/mtp_n.htm @@ -0,0 +1,101 @@ + + + + + + + + + + + + + MTP + + + + + +
    +

    MTP

    + +

    The Media Transfer Protocol (MTP) is an extension of the Picture Transfer Protocol (PTP), a protocol for file transfers between 2 devices.

    + +

    The extension consists of the MTP initiator and MTP responder. The host, which connects to the MTP device, is called the MTP initiator, and the MTP device is called the MTP responder. One MTP initiator can manage multiple MTP responders. The MTP initiator only sends requests to the MTP responder, and the MTP responder only responds to the MTP initiator.

    + +

    The MTP consists of 3 components:

    + +
      +
    • MTP device is a device that supports MTP. It has an MTP responder role and 1 or more MTP storages.
    • +
    • MTP storage is the storage in the MTP device. It has zero or more MTP objects.
    • +
    • MTP object is the actual file. Each file in the device has a unique handle called "object handle". (The handle is not unique in each storage.) +

      The MTP object has a parent object, so it can indicate a file hierarchy. If the parent object is 0, the object is in the root of the storage.

    • +
    + +

    The MTP API supports importing the MTP object and its metadata to the MTP initiator from the MTP responder. There is no MTP Responder API because it is only used in responding to a request from the initiator.

    + +

    The main features of the MTP API include:

    + + +

    The MTP API can be used in all profiles, but it is most popular in the TV profile.

    + +

    The internal implementation of the MTP references the MTP specification and uses LIBMTP.

    + + + + + + + + + + +
    Note
    Currently, the MTP API has the following limitations in Tizen 3.0: +
    • Only the PTP subset of the MTP is supported.
    • +
    • The transportation layer is possible only through USB.
    + + + +
    + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.guides/html/native/network/network_guide_n.htm b/org.tizen.guides/html/native/network/network_guide_n.htm index 28168c5..d1f57e0 100644 --- a/org.tizen.guides/html/native/network/network_guide_n.htm +++ b/org.tizen.guides/html/native/network/network_guide_n.htm @@ -37,12 +37,16 @@
    • Connection

      Enables you to get information about the connected network, set up and configure network connections, and track information, such as sent and received size.

    • Bluetooth

      Enables you to use Bluetooth functionalities, such as managing the local Bluetooth adapter, bonding, and exchanging data between Bluetooth-enabled devices.

    • +
    • Curl

      Enables you to perform URL-related transfer activities with various protocols.

    • +
    • Iotcon

      Enables you to use IoTivity in Tizen.

    • +
    • MTP

      Enables you to transfer files between 2 devices.

    • NFC

      Enables you to use Near Field Communication (NFC) functionalities, such as reading and writing tags, and emulating a smart card.

    • Smartcard

      Enables you to access secure elements (SE) through smart card features.

    • Wi-Fi

      Enables you to connect to a Wireless Local Area Network (WLAN) and transfer data over the network.

    The following guides apply in mobile applications only:

      +
    • VPN Service

      Enables you to allow the users to initialize the VPN device, and manage routing, DNS, and firewall features.

    • Wi-Fi Direct

      Enables you to connect to Wi-Fi Direct™ devices and manage Wi-Fi Direct™ connections.

    diff --git a/org.tizen.guides/html/native/network/nfc_n.htm b/org.tizen.guides/html/native/network/nfc_n.htm index 4f99d25..6989439 100644 --- a/org.tizen.guides/html/native/network/nfc_n.htm +++ b/org.tizen.guides/html/native/network/nfc_n.htm @@ -38,61 +38,64 @@
    • NFC management -

      The Manager API (in mobile and wearable applications) provides functions, for example, for:

      +

      With the Manager API (in mobile and wearable applications), you can, for example:

    • NDEF support

      The NFC Data Exchange Format (NDEF) is a packet message format used in the reader/writer and peer-to-peer modes.

      -

      The NDEF API (in mobile and wearable applications) provides functions for:

      +

      With the NDEF API (in mobile and wearable applications), you can:

        -
      • Creating NDEF records
      • -
      • Retrieving a specific field of an NDEF record
      • -
      • Creating NDEF messages
      • -
      • Inserting and removing NDEF records to and from an NDEF message
      • +
      • Create NDEF records.
      • +
      • Retrieve a specific field of an NDEF record.
      • +
      • Create NDEF messages.
      • +
      • Insert and remove NDEF records to and from an NDEF message.
    • Reader/writer mode -

      The TAG API (in mobile and wearable applications) provides functions, for example, for:

      +

      With the TAG API (in mobile and wearable applications), you can, for example:

        -
      • Retrieving the tag type
      • -
      • Reading an NDEF message from a tag
      • -
      • Writing an NDEF message to a tag
      • -
      • Formatting a tag for using NDEF
      • -
      • Handling type-specific tag operations (currently only MIFARE)
      • +
      • Retrieve the tag type.
      • +
      • Read an NDEF message from a tag.
      • +
      • Write an NDEF message to a tag.
      • +
      • Format a tag for using NDEF.
      • +
      • Handle type-specific tag operations (currently only MIFARE).
    • Peer-to-peer mode -

      The Peer to Peer API (in mobile and wearable applications) provides functions for:

      +

      With the Peer to Peer API (in mobile and wearable applications), you can:

        -
      • Sending an NDEF message to a peer device
      • -
      • Receiving an NDEF message from a peer device
      • -
      +
    • Send an NDEF message to a peer device.
    • +
    • Receive an NDEF message from a peer device.
    • +
    +

    Initialize NFC P2P before you start.

  • Card emulation mode -

    The card emulation mode allows an NFC device to function as a smart card. The mode provides access to secure elements (SEs).

    +

    The card emulation mode allows an NFC device to function as a smart card. The mode provides access to secure elements (SEs).

    The NFC controller in the device routes all data from the reader directly to the secure element, and an applet handles all of the data in the SE. The user does not participate at all in the operation.

    Figure: Traditional card emulation

    Traditional card emulation

    -

    The Card Emulation API (in mobile and wearable applications) provides functions for:

    +

    With the Card Emulation API (in mobile and wearable applications), you can:

      -
    • Enabling and disabling the card emulation mode
    • -
    • Retrieving the card emulation status
    • -
    • Opening and closing a secure element
    • -
    • Sending an application protocol data unit (APDU) to a secure element
    • -
    • Retrieving an Answer To Reset (ATR) from a secure element
    • +
    • Enable and disable the card emulation mode.
    • +
    • Retrieve the card emulation status.
    • +
    • Open and close a secure element.
    • +
    • Send an application protocol data unit (APDU) to a secure element.
    • +
    • Retrieve an Answer To Reset (ATR) from a secure element.
    diff --git a/org.tizen.guides/html/native/network/smartcard_n.htm b/org.tizen.guides/html/native/network/smartcard_n.htm index bd4ee82..61d7cef 100644 --- a/org.tizen.guides/html/native/network/smartcard_n.htm +++ b/org.tizen.guides/html/native/network/smartcard_n.htm @@ -38,19 +38,21 @@
    • SE service -

      The SE Service API (in mobile and wearable applications) allows you to initialize and deinitialize the smart card features, and get the available readers. The SE service functions as a connector to the SE framework system.

      +

      The SE Service API (in mobile and wearable applications) allows you to initialize and deinitialize the smart card features, and get the available readers. The SE service functions as a connector to the SE framework system.

    • Reader -

      The Reader API (in mobile and wearable applications) allows you to access the SE connected with the selected reader. You can get the reader name and open and close sessions.

      +

      The Reader API (in mobile and wearable applications) allows you to access the SE connected with the selected reader. You can get the reader name and open and close sessions.

    • Session -

      A session is an open connection between an application on the device and a SE. The Session API (in mobile and wearable applications) allows you to open and close basic and logical channels, and get ATR (answer to reset).

      +

      A session is an open connection between an application on the device and a SE. The Session API (in mobile and wearable applications) allows you to open and close basic and logical channels, and get ATR (answer to reset).

    • Channel -

      A channel is an open connection between an application on the device and an applet on the SE. The Channel API (in mobile and wearable applications) allows you to close channels and transmit application protocol data units (APDU).

      +

      A channel is an open connection between an application on the device and an applet on the SE. The Channel API (in mobile and wearable applications) allows you to close channels and transmit application protocol data units (APDU).

    +

    All of the above are used when you send a transmission.

    +

    The following figure illustrates the smart card service architecture in Tizen. The smart card service sends and receives data through the terminal of each SE.

    Figure: Smart card service architecture

    Smart card service architecture

    @@ -63,6 +65,29 @@ The Open Mobile API can facilitate the memory management by calling the API twice (for an example, see section 6.3.1, Usage pattern, in the SIMalliance Open Mobile 3.0 API specification). However, Tizen Smartcard API does not follow this allocation style.
  • For the SE Service object management, Tizen provides functions for initialization and deinitialization.
  • +
    + + + + + + + + +
    Note
    In some Tizen devices, after a specified time, the screen is automatically switched off and the CPU goes to the resting state. If this occurs during communication with the SE using the Smartcard API, the API may not function normally. +

    To avoid the screen switching off and the CPU going to the resting state, use the Device API to lock the device CPU (not LDC):

    + +
    +#include <nfc.h>
    +#include <device/power.h>
    +
    +device_power_request_lock(POWER_LOCK_CPU, 300000);
    +/* Input your Smartcard API code */
    +device_power_release_lock(POWER_LOCK_CPU);
    +
    +
    + + diff --git a/org.tizen.guides/html/native/network/vpn_n.htm b/org.tizen.guides/html/native/network/vpn_n.htm new file mode 100644 index 0000000..72b2250 --- /dev/null +++ b/org.tizen.guides/html/native/network/vpn_n.htm @@ -0,0 +1,154 @@ + + + + + + + + + + + + + VPN Service + + + +
    +
    +

    Mobile native

    +
    + + +
    + +
    +

    VPN Service

    + +

    A Virtual Private Network (VPN) connects 2 computers securely and privately over the internet. Using the VPN service, you can allow the users of your application to initialize the VPN device, and manage routing, DNS, and firewall features.

    + +

    This feature is supported in mobile applications only.

    + +

    The main features of the VPN Service API include:

    +
      +
    • VPN manager +

      You can create or initialize the tunnel interface for the VPN device with various functions. The application can use those functions to get various tunnel details, such as the tunnel ID and tunnel name, MTU for the tunnel interface, and connection statistics.

      +

      You can also set various details, such as the MTU for the tunnel interface, and the session name.

      +

      The vpnsvc_tun_s structure contains detailed information about the tunnel interface, such as the ID, name, and MTU. The possible errors are defined with the vpnsvc_error_e enumerator.

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Table: Common macros
      MacroDescription
      _MAX_FILE_PATH_LENMaximum file path length
      _USER_SETTING_DEFAULT_MTUDefault MTU
      _USER_SETTING_DEFAULT_SESSIONDefault session name
      VPNSVC_IP4_STRING_LENIPv4 address string length
      VPNSVC_TUN_IF_NAME_LENTunnel interface name length
      VPNSVC_SESSION_STRING_LENSession name string length
      +
    • +
    • VPN profile +

      You can map the VPN profile and get details about the VPN service using the vpnsvc_h handle.

      +

      The VPN profile provides different functions for routing management, DNS management, and firewall management:

      +
        +
      • The vpnsvc_up() function is used to set up the tunnel interface by setting the default route and DNS parameters.
      • +
      • The vpnsvc_block_networks() function is used to block network traffic by creating a route parameter for allowed VPN and original interface routes.
      • +
      +
    • +
    • VPN statistics +

      The VPN service allows you to track data transfer information. Use the VPN statistics to gather and reset statistics on network usage, such as the size of the sent or received data, in bytes:

      +
        +
      • The vpnsvc_read() function is used to read the data from tunnel interface in a specified time period.
      • +
      • The vpnsvc_write() function is used to write data to a tunnel file descriptor with a specific size.
      • +
    • +
    + +

    The VPN service uses 2 mechanisms for managing access control between the application and service:

    +
      +
    • Privilege: +

      The application needs the http://developer.samsung.com/tizen/vpnservice privilege (partner level) for accessing the VPN service daemon. Add the privilege to the application manifest file (tizen-manifest.xml).

      +
    • +
    • VPN license: +

      The VPN configurations, such as DNS, routing, and firewall (iptables), need an admin capability. The VPN service daemon checks the application's VPN license to verify that the client application has the admin capability.

      +
    • +
    + +

    VPN Connection Components

    + +

    A VPN connection includes the following components:

    +
      +
    • VPN server +

      A computer that accepts VPN connections from VPN clients.

      +
    • +
    • VPN client +

      A computer that initiates a VPN connection to a VPN server. A VPN client can be an individual computer or a router.

      +
    • +
    • Tunnel +

      The portion of the connection in which your data is encapsulated.

      +
    • +
    • VPN connection +

      The portion of the connection in which your data is encrypted. For typical secure VPN connections, the data is encrypted and encapsulated along the same portion of the connection.

      +
    • +
    • Tunneling protocols +

      Protocols that are used to manage tunnels and encapsulate private data. Data that is tunneled must also be encrypted to be a VPN connection.

      +
    • +
    • Tunneled data +

      Data that is usually sent across a private point-to-point link.

      +
    • +
    • Transit inter-network +

      The shared or public network crossed by the encapsulated data. The transit inter-network can be the Internet or a private IP-based intranet.

      +
    • +
    + + + +
    + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.guides/html/native/network/wifi_direct_n.htm b/org.tizen.guides/html/native/network/wifi_direct_n.htm index 76a989d..1ffd0d5 100644 --- a/org.tizen.guides/html/native/network/wifi_direct_n.htm +++ b/org.tizen.guides/html/native/network/wifi_direct_n.htm @@ -39,14 +39,16 @@

    A Wi-Fi Direct™ device can join an existing group by associating itself with the group owner, as long as the allowed number of clients is not exceeded.

    -

    The main features of the Wi-FI Direct™ include:

    +

    With Wi-FI Direct™ you can:

    +

    Remember to initialize Wi-Fi Direct™ before you start.

    + diff --git a/org.tizen.guides/html/native/network/wifi_n.htm b/org.tizen.guides/html/native/network/wifi_n.htm index 43fa985..f017aa5 100644 --- a/org.tizen.guides/html/native/network/wifi_n.htm +++ b/org.tizen.guides/html/native/network/wifi_n.htm @@ -61,19 +61,18 @@

    Wi-Fi Manager

    -

    The Tizen Wi-Fi Manager API (in mobile and wearable applications) provides functions for managing Wi-Fi connection.

    +

    The Tizen Wi-Fi Manager API (in mobile and wearable applications) provides functions for using a Wi-Fi connection.

    Using the Wi-Fi Manager, you can implement features that allow the users of your application to:

    • Activate and deactivate a Wi-Fi device -

      You can activate and deactivate a local Wi-Fi device using the wifi_activate() and wifi_deactivate() functions. Both functions have a callback function as the first parameter. The callback function is called after the activation or deactivation is completed. You can use the NULL value, if you want no notifications.

      +

      You can activate and deactivate a local Wi-Fi device using the wifi_activate() and wifi_deactivate() functions. Both functions have a callback function as the first parameter. The callback function is called after the activation or deactivation is completed. You can use the NULL value, if you want no notifications.

    • Connect to an access point -

      You can connect to an access point asynchronously using the wifi_connect() function.

      +

      You can connect to an access point asynchronously using the wifi_connect() function.

    • Scan the access points -

      To scan access points, use the wifi_scan() and wifi_foreach_found_aps() functions.

      +

      To scan access points, use the wifi_scan() and wifi_foreach_found_aps() functions.

      The wifi_scan() function starts the scan asynchronously. When the scan is finished, a callback function is called. The wifi_foreach_found_aps() function allows you to get the result of the scan. It also invokes a callback function.

    -

    Access Point

    diff --git a/org.tizen.guides/html/native/security/key_manager_n.htm b/org.tizen.guides/html/native/security/key_manager_n.htm index b6b581a..7d68d70 100644 --- a/org.tizen.guides/html/native/security/key_manager_n.htm +++ b/org.tizen.guides/html/native/security/key_manager_n.htm @@ -32,7 +32,7 @@

    Key Manager

    -

    The key manager provides functions to securely store keys, certificates, and sensitive data related to users and their password-protected APPs. Additionally, it provides secure cryptographic operations for non-exportable keys without revealing the key values to clients.

    +

    The key manager provides functions to securely store keys, certificates, and sensitive data related to users and their password-protected applications. Additionally, it provides secure cryptographic operations for non-exportable keys without revealing the key values to clients.

    A key manager stores keys, certificates, and sensitive user data in a central secure repository. The central secure repository is protected by a password.

    @@ -59,16 +59,16 @@

    The user login control is implemented as follows:

      -
    • A user's database file is encrypted by the user's DKEK (domain key encryption key). A DKEK of a user is randomly generated and stored as encrypted with a user password when a user logs in for the first time.
    • +
    • A user's database file is encrypted by the user's DKEK (domain key encryption key). The user DKEK is randomly generated and stored encrypted with a user password when a user logs in for the first time.
    • When a user logs in, the key manager decrypts the user DKEK with a user password. During the login session, any client can access the data which is protected by a user password. When a user logs out, the key manager removes the user DKEK from the memory.
    • -
    • When a user logs in, logs out, or changes their password, the key manager must be notified. Only privileged APPs, such as LockScreen APP or Setting APP, can notify the key manager.
    • +
    • When a user logs in, logs out, or changes their password, the key manager must be notified. Only privileged applications, such as LockScreen or Setting, can notify the key manager.
    • When a user changes their password, the key manager re-encrypts the user DKEK with the new password.
  • Data access control -

    By default, only the owner of a data can access to the data. If the owner grants the access to other applications, those applications can read or delete the data from the key manager database.

    +

    By default, only the data owner can access the data. If the owner grants access to other applications, those applications can read or delete the data from the key manager database.

    When an application is deleted, the data and access control information granted by the application are also removed.

  • @@ -78,7 +78,7 @@

    The key manager provides 2 types of APIs (in mobile and wearable applications):

    +

    Initialize the key manager before you start.

    +
    diff --git a/org.tizen.guides/html/native/security/privilege_n.htm b/org.tizen.guides/html/native/security/privilege_n.htm index 910a7d3..9351b0d 100644 --- a/org.tizen.guides/html/native/security/privilege_n.htm +++ b/org.tizen.guides/html/native/security/privilege_n.htm @@ -34,7 +34,7 @@

    Tizen provides privilege information for user notification.

    -

    The following information can be retrieved:

    +

    You can retrieve the following information:

    • Privilege name: Privilege description in a simple present participle form.
    • Privilege description: Detailed information on permissions, including accessible resources and functionality, that the application can get with this privilege. It also contains information related to billing or device performance, such as cost or increase battery usage.
    • diff --git a/org.tizen.guides/html/native/social/calendar_n.htm b/org.tizen.guides/html/native/social/calendar_n.htm index ab920d6..1de719b 100644 --- a/org.tizen.guides/html/native/social/calendar_n.htm +++ b/org.tizen.guides/html/native/social/calendar_n.htm @@ -48,11 +48,13 @@

      A calendar is a system of organizing days for social purposes. It is composed of records, such as events and todos. The records consist of subrecords, such as alarms, attendees, or extensions. For example, if an event has a recurrence rule (meaning that it happens multiple times), separate instances are generated for each time the event occurs.

      This feature is supported in mobile applications only.

      + +

      The calendar information is stored in a calendar database. To manage the information in the database, you must connect to the calendar service.

      Figure: Calendar model

      Calendar model

      -

      The Calendar Service supports vCalendars.

      +

      The calendar service supports vCalendars.

      The main features of the Calendar API include:

        @@ -65,9 +67,11 @@

      Each account can have multiple calendar books. The calendar book name does not need to be unique on the device because it is handled with an ID. Since the local device address book has no account, its related account ID is zero.

      -
    • Events and tasks +
    • Events and todos
        -
      • Set properties, such as summary, start time, and description.
      • +
      • Create events and todos, set properties for them, such as summary, start time, and description, and store them in the database.
      • +
      • Update event and todo details in the database.
      • +
      • Delete events and todos from the database.
      • Set reminders.
    • @@ -89,7 +93,7 @@
       calendar_connect();
       
      -// Jobs for records
      +/* Jobs for records */
       
       calendar_disconnect();
       
      @@ -128,33 +132,37 @@ calendar_record_h event = NULL; calendar_record_create(_calendar_event._uri, &event); -// Set default calendar book id +/* Set default calendar book ID */ calendar_record_set_int(event, _calendar_event.calendar_id, DEFAULT_EVENT_CALENDAR_BOOK_ID); -// Set other fields +/* Set other fields */ int event_id = 0; calendar_db_insert_record(event &event_id); -// Destroy +/* Destroy */ calendar_record_destroy(event, true);

      To receive a list of existing calendar books, use the following code:

      -
      calendar_list_h calendar_book_list = NULL;
      -calendar_db_get_all_records(_calendar_calendar_book._uri, 0, 0, &calendar_book_list);
      +
      +calendar_list_h calendar_book_list = NULL;
      +calendar_db_get_all_records(_calendar_calendar_book._uri, 0, 0, &calendar_book_list);
      +

      In the calendar_db_get_all_records() function, you need as parameters the URI of the view to get records from, the index from which results are received, the maximum number of results, and the record list.

      Database Change Notifications

      -

      To detect the calendar database changes, register a callback with the calendar_db_add_changed_cb() function. To unregister the callback and ignore database changes, use the calendar_db_remove_changed_cb() function.

      +

      To detect the event and todo changes in the calendar database, register a callback with the calendar_db_add_changed_cb() function. To deregister the callback and ignore database changes, use the calendar_db_remove_changed_cb() function.

      Clients wait calendar change notifications on the client side. If the calendar is changed by another module, the server publishes an inotify event. The Inotify module broadcasts to the subscribed modules, and an internal inotify handler is called at the client side. A user callback function is called with the user data.

      -
      // Add callback function
      +
      +/* Add callback function */
       void __event_changed_ cb(const char *view_uri, void *user_data) {}
      -// Add change notification callback
      -calendar_db_add_changed_cb(_calendar_event._uri, __event_changed_cb, NULL);
      +/* Add change notification callback */ +calendar_db_add_changed_cb(_calendar_event._uri, __event_changed_cb, NULL); +

      Events and Instances

      An event record describes various properties, such as description, categories, and priority. It also contains information on when the event takes place. In a recurring event, there are more than one instance of the event. Each instance has its corresponding instance record.

      @@ -163,7 +171,7 @@ calendar_db_add_changed_cb(_calendar_event._uri, __event_changed_cb, NULL);Figure: Views and databases

      Views and databases

      -

      The following table illustrates and example of a recurring event and its instances.

      +

      The following table illustrates an example of a recurring event and its instances.

    @@ -240,8 +248,10 @@ calendar_db_add_changed_cb(_calendar_event._uri, __event_changed_cb, NULL);
    +

    When you have a recurring event, you can remove a specific recurrence instance from it, or add exceptions to the recurrence.

    +

    Exceptions

    -

    If one of the instances of a recurring event is modified (such as its summary or date) or deleted, it is called an exception. For example, if 2nd instance date is modified from 16th to 17th, 17th is the exception.

    +

    If 1 of the instances of a recurring event is modified (such as its summary or date) or deleted, it is called an exception. For example, if the second instance date is modified from 16th to 17th, 17th is the exception.

    @@ -272,7 +282,7 @@ calendar_db_add_changed_cb(_calendar_event._uri, __event_changed_cb, NULL);To get the changes in an exception, use the calendar_db_get_changes_exception_by_version() function. The instances and exceptions are deleted together when the original event is deleted.

    Filters and Queries

    -

    Queries are used to retrieve data which satisfies a given criteria, like an integer property being greater than a given value, or a string property containing a given substring. The criteria are defined by creating filters and adding conditions to them, joining them with logical operators. Also, instead of a condition, another filter can be added to create more complex filters.

    +

    Queries are used to retrieve event and todo data which satisfies a given criteria, like an integer property being greater than a given value, or a string property containing a given substring. The criteria are defined by creating filters and adding conditions to them, joining them with logical operators. Also, instead of a condition, another filter can be added to create more complex filters.

    When a filter is ready, it can be set as a property of a query. Other query properties allow configuring how the returned results are grouped and sorted.

    The operator precedence in filters is determined by the order in which the conditions and filters are added. The following table shows an example of how the operator precedence works.

    @@ -317,93 +327,102 @@ Meaning (C5 AND (C1 OR C2)) AND (C3 OR C4)

    The following code creates a filter, accepting events with high priority or those that include the word "meeting" in their description.

    -
    calendar_filter_h filter = NULL;
    - 
    -// Create a filter returning event type records
    +
    +calendar_filter_h filter = NULL;
    +
    +/* Create a filter returning event type records */
     calendar_filter_create(_calendar_event._uri, &filter);
    - 
    -// Add a 'priority equals high' condition
    +
    +/* Add a 'priority equals high' condition */
     calendar_filter_add_int(filter, _calendar_event.priority, CALENDAR_MATCH_EQUAL, CALENDAR_EVENT_PRIORITY_HIGH);
    - 
    -// Add OR operator
    +
    +/* Add OR operator */
     calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
    - 
    -// Add a 'description contains "meeting"' condition
    -calendar_filter_add_str(filter, _calendar_event.description, CALENDAR_MATCH_CONTAINS, "meeting");
    - + +/* Add a 'description contains "meeting"' condition */ +calendar_filter_add_str(filter, _calendar_event.description, CALENDAR_MATCH_CONTAINS, "meeting"); +
    +

    Insert the filter into the query and execute the query:

    -
    calendar_query_h query = NULL;
    +
    +calendar_query_h query = NULL;
     calendar_list_h list = NULL;
    - 
    -// Create a query returning event type records
    +
    +/* Create a query returning event type records */
     calendar_query_create(_calendar_event._uri, &query);
    - 
    -// Add the filter
    +
    +/* Add the filter */
     calendar_query_set_filter(query, filter);
    - 
    -// Execute the query, results are returned in a list
    +
    +/* Execute the query, results are returned in a list */
     calendar_db_get_records_with_query(query, 0, 0, &list);
    - 
    +
     calendar_filter_destroy(filter);
     calendar_query_destroy(query);
    - 
    -// Use the list
    - 
    -calendar_list_destroy(list, true);
    + +/* Use the list */ + +calendar_list_destroy(list, true); +

    Projections

    Projection is related to searching with filters and queries. A projection allows you to query the data for just those specific properties of a record that you actually need, at lower latency and cost than retrieving the entire set of properties.

    The following example code creates a filter that gets only the event ID, summary, and start time from those records whose summary has "test" (string filter). It creates a query, adds the filter to it, and receives the results in a list.

    -
    calendar_query_h query = NULL;
    +
    +calendar_query_h query = NULL;
     calendar_filter_h filter = NULL;
     
    -// Set query with filter
    +/* Set query with filter */
     calendar_query_create(_calendar_event_calendar_book_attendee._uri, &query);
     calendar_filter_create(_calendar_event_calendar_book_attendee._uri, &filter);
     calendar_filter_add_str(filter, _calendar_event.summary, CALENDAR_MATCH_CONTAINS, "test");
     calendar_query_set_filter(query, filter);
     
    -// Set projection
    +/* Set projection */
     unsigned int projection[3];
     projection[0] = _calendar_event_calendar_book_attendee.event_id;
     projection[1] = _calendar_event_calendar_book_attendee.summary;
     projection[2] = _calendar_event_calendar_book_attendee.start_time;
     
    -// Get list
    +/* Get list */
     calendar_query_set_projection(query, projection, 3);
     calendar_db_get_records_with_query(query, 0, 0, &list);
     
    -// Destroy handle
    +/* Destroy handle */
     calendar_filter_destroy(filter);
     calendar_query_destroy(query);
    -calendar_list_destroy(list, true);
    +calendar_list_destroy(list, true); +

    Records

    -

    An important concept in the Calendar Service APIs is a record. Although a record represents an actual record in the internal database, you can consider it as a structure describing a single (but complex) entity, like a calendar event or a time zone.

    +

    An important concept in the Calendar APIs is a record. Although a record represents an actual record in the internal database, you can consider it as a structure describing a single (but complex) entity, like a calendar event or a time zone.

    A record has many properties, for example, a todo record has the todo description, priority, progress, creation time, last modified and completed time, and many others.

    A record can also contain an identifier field, which holds an ID of another record. Setting this field's value establishes a relation between the records, for example, a calendar event contains the ID of a calendar book to which it belongs.

    URI

    A record type is identified by a structure called the view. For example, the _calendar_event view describes the properties of the calendar event record. Every view has a special field - _uri - that uniquely identifies the view. In many cases, you must provide the _uri value to indicate what type of record you want to create or operate on.

    -
    // Create an event with _calendar_event view
    +
    +/* Create an event with _calendar_event view */
     calendar_record_h record = NULL;
     calendar_record_create(_calendar_event._uri, &record);
     

    Record Handle

    To use a record, you must obtain its handle. You can use many methods to obtain the handle, for example, you can create a new record or refer to the child records of a record.

    -
    // Create an event and get a handle
    +
    +/* Create an event and get a handle */
     calendar_record_h event = NULL;
     calendar_record_create(_calendar_event._uri, &event);
     
    -// Get the record handle with ID
    +/* Get the record handle with ID */
     calendar_record_h event2 = NULL;
    -calendar_db_get_record(_calendar_event._uri, event_id, &event2);
    +calendar_db_get_record(_calendar_event._uri, event_id, &event2); +

    Basic Types

    Records contain properties of basic types: integer, lli (long integer, long long int), double, string, bool, and time. The time type holds either a long long int, or 3 integers (year, month, day).

    @@ -452,22 +471,24 @@ calendar_db_get_record(_calendar_event._uri, event_id, &event2);

    The following code example creates an event and inserts it into the default event book.

    -
    // Create an event
    +
    +/* Create an event */
     calendar_record_h event = NULL;
     calendar_record_create(_calendar_event._uri, &event);
    - 
    -// Set event summary
    +
    +/* Set event summary */
     calendar_record_set_str(event, _calendar_event.summary, "Meeting");
    - 
    -// Put the event into the default calendar book for events
    +
    +/* Put the event into the default calendar book for events */
     calendar_record_set_int(event, _calendar_event.calendar_book_id, book_id);
    - 
    -// Insert calendar book into the database
    +
    +/* Insert calendar book into the database */
     int event_id = 0;
     calendar_db_insert_record(event, &event_id);
     
    -// Destroy
    -calendar_record_destroy(event, true);
    +/* Destroy */ +calendar_record_destroy(event, true); +

    Reminders

    @@ -477,33 +498,35 @@ calendar_record_destroy(event, true);

    Alarm process

    To get a reminder when an alarm is triggered, the application must set the reminder mime name. After the reminder mime name is set, insert an alarm as a child of an event record:

    -
    // Set alarm
    +
    +/* Set alarm */
     calendar_record_h alarm = NULL;
     calendar_record_create(_calendar_alarm._uri, &alarm);
     calendar_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
    -calendar_record_set_lli(alarm, _calendar_alarm.time, (1404036000 - 60)); // Before 60 sec
    +calendar_record_set_lli(alarm, _calendar_alarm.time, (1404036000 - 60)); /* Before 60 sec */
     
    -// Add alarm as child
    -calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm);
    +/* Add alarm as child */ +calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm); +

    When the registered alarm is triggered and the alarm manager notices it, the calendar service calls those packages that have the reminder mime name.

    Time Structure

    The calendar time structure, calendar_caltime_s, is defined as follows:

    -
    typedef struct
    -{
    -   calendar_time_type_e type;
    -   union 
    -   {
    -      long long int utime;
    -      struct 
    -      {
    -         int year;
    -         int month;
    -         int mday;
    -      } date;
    -   } time;
    -} calendar_time_s;
    +
    +struct _calendar_time_s {
    +    calendar_time_type_e type;
    +    union {
    +        long long int utime;
    +        struct {
    +            int year;
    +            int month;
    +            int mday;
    +        } date;
    +    } time;
    +};
    +typedef struct _calendar_time_s calendar_time_s;
    +

    Use this structure when setting the calendar time (_CALENDAR_PROPERTY_CALTIME) properties of the records.

    The time structure can hold 2 types of data: UTC time (long long int) and date, given as year, month, and day of the month (3 integers). These types are identified by the values of the calendar_time_type_e variable, and they determine the usage of the structure.

    @@ -538,66 +561,68 @@ calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm);<

    For example, when setting the start time of an event, the local time zone must be stored in the start_tzid property.

    When converting local time to UTC time, use the function illustrated in the following example. It converts the given date and time to the corresponding UTC time, considering the given time zone (first argument). The function uses the i18n API.

    -
    #define ms2sec(ms) (long long int)(ms / 1000.0)
    - 
    -long long int _time_convert_itol(char *tzid, int y, int mon, int d, int h, int min, int s)
    +
    +#define ms2sec(ms) (long long int)(ms / 1000.0)
    +
    +long long int 
    +_time_convert_itol(char *tzid, int y, int mon, int d, int h, int min, int s)
     {
    -   int ret = 0;
    -   i18n_uchar utf16_timezone[64] = {0};
    -   i18n_ustring_copy_ua_n(utf16_timezone, tzid, sizeof(utf16_timezone)/sizeof(i18n_uchar));
    +    int ret = 0;
    +    i18n_uchar utf16_timezone[64] = {0};
    +    i18n_ustring_copy_ua_n(utf16_timezone, tzid, sizeof(utf16_timezone)/sizeof(i18n_uchar));
     
    -   i18n_ucalendar_h ucal = NULL;
    -   char *loc_default = NULL;
    +    i18n_ucalendar_h ucal = NULL;
    +    char *loc_default = NULL;
     
    -   i18n_ulocale_get_default((const char **)&loc_default);
    -   ret = i18n_ucalendar_create(utf16_timezone, -1, loc_default, I18N_UCALENDAR_GREGORIAN, &ucal);
    -   if (I18N_ERROR_NONE != ret) 
    -   {
    -      dlog_print(DLOG_DEBUG, LOG_TAG, "i18n_ucalendar_create() failed (%d)\n", ret);
    +    i18n_ulocale_get_default((const char **)&loc_default);
    +    ret = i18n_ucalendar_create(utf16_timezone, -1, loc_default, I18N_UCALENDAR_GREGORIAN, &ucal);
    +    if (I18N_ERROR_NONE != ret) {
    +        dlog_print(DLOG_DEBUG, LOG_TAG, "i18n_ucalendar_create() failed (%d)\n", ret);
     
    -      return -1;
    -   }
    +        return -1;
    +    }
     
    -   i18n_ucalendar_set_date_time(ucal, y, mon - 1, d, h, min, s);
    +    i18n_ucalendar_set_date_time(ucal, y, mon - 1, d, h, min, s);
     
    -   i18n_udate date;
    -   ret = i18n_ucalendar_get_milliseconds(ucal, &date);
    -   if (I18N_ERROR_NONE != ret) 
    -   {
    -      dlog_print(DLOG_DEBUG, LOG_TAG, "i18n_ucalendar_create() failed (%d)\n", ret);
    -      i18n_ucalendar_destroy(ucal);
    +    i18n_udate date;
    +    ret = i18n_ucalendar_get_milliseconds(ucal, &date);
    +    if (I18N_ERROR_NONE != ret) {
    +        dlog_print(DLOG_DEBUG, LOG_TAG, "i18n_ucalendar_create() failed (%d)\n", ret);
    +        i18n_ucalendar_destroy(ucal);
     
    -      return -1;
    -   }
    -   i18n_ucalendar_destroy(ucal);
    +        return -1;
    +    }
    +    i18n_ucalendar_destroy(ucal);
     
    -   return ms2sec(date);
    +    return ms2sec(date);
     }
    -
    // Fill calendar time structures (start and end time)
    +
    +/* Fill calendar time structures (start and end time) */
     calendar_time_s st = {0};
     calendar_time_s et = {0};
    - 
    +
     st.type = CALENDAR_TIME_UTIME;
     st.time.utime = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 11, 0, 0);
    - 
    +
     et.type = CALENDAR_TIME_UTIME;
     et.time.utime = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 12, 0, 0);
    - 
    -// Create an event record
    - 
    -// Set local time zone of start time
    +
    +/* Create an event record */
    +
    +/* Set local time zone of start time */
     calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
    - 
    -// Set start time
    +
    +/* Set start time */
     calendar_record_set_caltime(event, _calendar_event.start_time, st);
    - 
    -// Set local time zone of end time
    +
    +/* Set local time zone of end time */
     calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
    - 
    -// Set end time
    -calendar_record_set_caltime(event, _calendar_event.end_time, et);
    + +/* Set end time */ +calendar_record_set_caltime(event, _calendar_event.end_time, et); +

    Date Usage

    Another usage of the time structure is an all day event. In case of such events, the structure type field must be set to CALENDAR_TIME_LOCALTIME. Only the date (no time) is stored. Such structures can be used to set the start and end time of an event.

    @@ -649,26 +674,29 @@ calendar_record_set_caltime(event, _calendar_event.end_time, et);

    Figure: Properties

    Properties

    -
    // Create an event with _calendar_event view
    +
    +/* Create an event with _calendar_event view */
     calendar_record_h event = NULL;
     calendar_record_create(_calendar_event._uri, &event);
    - 
    -// Set event summary to _calendar_event view
    +
    +/* Set event summary to _calendar_event view */
     calendar_record_set_str(event, _calendar_event.summary, "Meeting");
     

    Version

    The calendar service uses a version system in the following APIs:

    -
    int calendar_db_get_current_version(int *calendar_db_version);
    +
    +int calendar_db_get_current_version(int *calendar_db_version);
     int calendar_db_get_changes_by_version(..., int *current_calendar_db_version);
     int calendar_db_get_last_change_version(int *last_change_version);
    -int calendar_db_get_changes_exception_by_version(..., int calendar_db_version, ...);
    +int calendar_db_get_changes_exception_by_version(..., int calendar_db_version, ...); +

    Whenever modifications are made in the database, the version number is increased. If sync applications, such as Google or Facebook, sync at version 13 and try to sync again every 1 minute, they want to get the changes from version 14 to the current version.

    To get the current version, the calendar_db_get_current_version() function is used. The calendar_db_get_changes_by_version() function retrieves the modified record list. The calendar_db_get_changes_exception_by_version() function is used to get modified instances in a recurring event.

    vCalendar

    -

    Use vCalendar to exchange personal calendar and schedule information. In order to avoid confusion with this referenced work, this is to be known as the vCalendar specification. vCalendar ver2.0 is known as iCalendar. The following snippet shows an example of the vCalendar.

    +

    Use the vCalendar to exchange personal calendar and schedule information. In order to avoid confusion with this referenced work, this is to be known as the vCalendar specification. vCalendar ver2.0 is known as iCalendar. The following snippet shows an example of the vCalendar.

     BEGIN:VCALENDAR
     VERSION:2.0
    @@ -681,28 +709,28 @@ END:VEVENT
     END:VCALENDAR
     
    -

    The calendar service provides APIs to compose a vCalendar stream. With the stream, it is possible to create files transmit data with JSON data.

    +

    The calendar service provides APIs to compose a vCalendar stream. With the stream, it is possible to create files transmit data with JSON data.

     calendar_list_h list = NULL;
    -// Create or get list to make vcalendar stream
    +/* Create or get list to make a vcalendar stream */
     
     char *stream = NULL;
     calendar_vcalendar_make_from_records(list, &stream);
     
    -// Jobs for stream
    +/* Jobs for stream */
     
    -// Free
    +/* Free */
     free(stream);
     
    -

    vCalendar can be parsed with calendar service APIs as well.

    +

    You can parse the vCalendar with calendar APIs as well.

    -// Read stream from file
    +/* Read stream from file */
     
     calendar_list_h list = NULL;
     calendar_vcalendar_parse_to_calendar(stream, &list);
     
    -// Jobs for list
    +/* Jobs for list */
     calendar_list_destroy(list, true);
     
    diff --git a/org.tizen.guides/html/native/social/contact_n.htm b/org.tizen.guides/html/native/social/contact_n.htm index 4eaeb66..66a5e58 100644 --- a/org.tizen.guides/html/native/social/contact_n.htm +++ b/org.tizen.guides/html/native/social/contact_n.htm @@ -16,7 +16,7 @@ @@ -45,8 +46,8 @@

    Contacts

    Contact features provide functions for managing contact information, such as address books, groups, persons, and phone logs.

    - -

    This feature is supported in mobile applications only.

    + +

    The contact information is stored in a contacts database. To manage the information in the database, you must connect to the contact service.

    A contact object is always associated with a specific address book. A person object is an aggregation of one or more contacts associated with the same person.

    @@ -55,16 +56,17 @@

    Figure: Contact structure

    Contact structure

    -

    The Contact Service supports vCards.

    +

    The contact service supports vCards, allowing you to import contact information from a vCard or export it to a vCard format. You can also import contacts from the device SIM card to the contacts database.

    The main features of the Contacts API include:

  • Accounts -
    • Handle accounts using an account ID created with the Account Manager API.
    • +
      • Handle accounts using an account ID created with the Account Manager API (in mobile and wearable applications).
      • Have the related account ID of 0 because local device address book has no account.
      • Create only one address book each.
    • Address books @@ -72,13 +74,16 @@
    • Create address books using the local device (with no account), service providers (such as Samsung account), or applications (such as ChatON or Joyn).
  • Groups -
    • Combine contacts on the same address book.
    • -
    • Set up many-to-many relationships between groups and contacts.
  • +
  • Lists
  • Persons
  • My profile
    • Manage My profile. My profile has similar properties as the contact information, but no properties, such as group relation, ringtone, and message alert.
    • @@ -86,9 +91,11 @@
    • Activities
      • Store social activities.
    • Speed dials -
      • Provide a shortcut dialing number key information.
    • +
    • Phone logs -
      • Store call or message logs.
    +
  • The following figure illustrates the different entities in the Contact Service, and their relationships.

    @@ -107,13 +114,14 @@ int contacts_db_replace_records(contacts_list_h list, int record_id_array[], uns

    The following code example inserts 2 contact records using a bulk API:

    -
    contacts_record_h contact1;
    +
    +contacts_record_h contact1;
     contacts_record_create(_contacts_contact.uri, &contact1);
    -// Fill contact record
    +/* Fill contact record */
     
     contacts_record_h contact2;
     contacts_record_create(_contacts_contact._uri, &contact2);
    -// Fill contact record
    +/* Fill contact record */
     
     contacts_list_h list = NULL;
     contacts_list_create(&list);
    @@ -124,31 +132,34 @@ contacts_list_add(list, contact2);
     int **ids = NULL;
     unsigned int count = 0;
     
    -// Insert contact records using bulk APIs
    +/* Insert contact records using bulk APIs */
     contacts_db_insert_records(list, &ids, &count);
     
    -// Use IDs
    +/* Use IDs */
     
     contacts_list_destroy(list, true);
    -free(ids);
    +free(ids); +

    Database Change Notifications

    -

    To detect the contact database changes, use the Database API functions. Register a callback with the contacts_db_add_changed_cb() function. To unregister the callback and ignore database changes, use the contacts_db_remove_changed_cb() function.

    -

    Clients wait contacts change notifications on the client side. If the contact is changed by another module, the server publishes a notification. The notification module broadcasts to the subscribed modules and a user callback function is called with the user data. The following example registers person changes notification callback:

    +

    To detect the person and group changes in the contacts database, use the Database API functions (in mobile and wearable applications). Register a callback with the contacts_db_add_changed_cb() function. To deregister the callback and ignore database changes, use the contacts_db_remove_changed_cb() function.

    +

    Clients wait contact change notifications on the client side. If the contact is changed by another module, the server publishes a notification. The notification module broadcasts to the subscribed modules and a user callback function is called with the user data. The following example registers a person change notification callback:

    -static void __person_changed_ cb(const char *view_uri, void *user_data)
    +static void 
    +__person_changed_ cb(const char *view_uri, void *user_data)
     {
    -   // Jobs for the callback function
    +    /* Jobs for the callback function */
     }
    -// Add a change notification callback
    -contacts_db_add_changed_cb(_contacts_person._uri, __person_changed_cb, NULL);
    +/* Add a change notification callback */ +contacts_db_add_changed_cb(_contacts_person._uri, __person_changed_cb, NULL); +

    Filters and Queries

    -

    Queries are used to retrieve data which satisfies a given criteria, like an integer property being greater than a given value, or a string property containing a given substring. Query needs a filter which can set the condition for search. The Contact Service provides query APIs for sorting set projections and removing duplicated results.

    +

    Queries are used to retrieve person, group, speed dial, and log data which satisfies a given criteria, like an integer property being greater than a given value, or a string property containing a given substring. Query needs a filter which can set the condition for search. The Contact Service provides query APIs for sorting set projections and removing duplicated results.

    Filters

    @@ -156,13 +167,18 @@ contacts_db_add_changed_cb(_contacts_person._uri, __person_changed_cb, NULL);

    When creating a filter, specify the filter type you want to create using the _uri property. A filter handle must be destroyed after use.

     int contacts_filter_create(const char* view_uri, contacts_filter_h* filter);
    -int contacts_filter_destroy(contacts_filter_h filter);
    +int contacts_filter_destroy(contacts_filter_h filter); +

    The following example sets the filter condition to contain a given substring:

    -
    contacts_filter_add_str(filter, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, "1234");
    +
    +contacts_filter_add_str(filter, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, "1234");
    +

    The following example sets the filter condition to property value is true:

    -
    contacts_filter_add_bool(filter, _contacts_person.is_favorite, true);
    +
    +contacts_filter_add_bool(filter, _contacts_person.is_favorite, true);
    +

    Conditions can be added to a filter. Join the conditions by using the logical operators AND and OR.

    @@ -170,7 +186,8 @@ int contacts_filter_destroy(contacts_filter_h filter);
     contacts_filter_add_str(filter1, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, "1234");
     contacts_filter_add_operator(filter1, CONTACTS_FILTER_OPERATOR_OR);
    -contacts_filter_add_str(filter1, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, "5678");
    +contacts_filter_add_str(filter1, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, "5678"); +

    Additionally, filters can join each other by using the logical operators AND and OR.

    @@ -246,7 +263,7 @@ contacts_db_get_records_with_query(query, 0, 0, &list); contacts_filter_destroy(filter); contacts_query_destroy(query); -// Use the list +/* Use the list */ contacts_list_destroy(list, true); @@ -254,7 +271,9 @@ contacts_list_destroy(list, true);

    Sorting

    Sort query results list by property ID:

    -
    int contacts_query_set_sort(contacts_query_h query, unsigned int property_id, bool is_ascending);
    +
    +int contacts_query_set_sort(contacts_query_h query, unsigned int property_id, bool is_ascending);
    +

    Sort query results by person ID:

    @@ -272,26 +291,28 @@ contacts_list_destroy(person_list, true);
     

    Projection

    Projection allows you to query data for specific properties of a record, at lower latency and cost than retrieving all properties:

    -
    int contacts_query_set_projection(contacts_query_h query, unsigned int property_ids[], int count)
    +
    +int contacts_query_set_projection(contacts_query_h query, unsigned int property_ids[], int count);
    +

    The following example creates a filter which gets only the person ID, display name, and image thumbnail path from the person record which "test" (string filter) as vibration path. Create a query and add the filter to it, results are received in a list.

     contacts_filter_add_str(filter, _contacts_person.vibration, CONTACTS_MATCH_CONTAINS, "test");
     contacts_query_set_filter(query, filter);
     
    -// Set projections
    +/* Set projections */
     unsigned int person_projection[] =
     {
    -   _contacts_person.id,
    -   _contacts_person.display_name,
    -   _contacts_person.image_thumbnail_path,
    +    _contacts_person.id,
    +    _contacts_person.display_name,
    +    _contacts_person.image_thumbnail_path,
     };
     
     contacts_query_set_projection(query, person_projection, sizeof(person_projection)/sizeof(int));
     
     contacts_db_get_records_with_query(query, 0, 0, &person_list);
     
    -// Use the list
    +/* Use the list */
     
     contacts_query_destroy(query);
     contacts_filter_destroy(filter);
    @@ -300,15 +321,17 @@ contacts_list_destroy(person_list, true);
     
     

    Distinct

    -

    If you query a read-only view with a set projection, the result list can contain duplicates. Remove duplicates using contacts_query_set_distinct.

    -
    int contacts_query_set_distinct(contacts_query_h query, bool set)
    +

    If you query a read-only view with a set projection, the result list can contain duplicates. Remove duplicates using the contacts_query_set_distinct() function.

    +
    +int contacts_query_set_distinct(contacts_query_h query, bool set);
    +

    The following example removes duplicates:

     unsigned int projection[] =
     {
    -   _contacts_person_number.person_id,
    -   _contacts_person_number.display_name,
    +    _contacts_person_number.person_id,
    +    _contacts_person_number.display_name,
     };
     contacts_filter_create(_contacts_person_number._uri, &filter);
     contacts_filter_add_bool(filter, _contacts_person_number.has_phonenumber, true);
    @@ -317,12 +340,12 @@ contacts_query_create(_contacts_person_number._uri, &query);
     contacts_query_set_projection(query, projection, sizeof(projection)/sizeof(int));
     contacts_query_set_filter(query, filter);
     
    -// Set distinct (remove duplicates)
    +/* Set distinct (remove duplicates) */
     contacts_query_set_distinct(query, true);
     
     contacts_db_get_records_with_query(query, 0, 0, &list);
     
    -// Use the list
    +/* Use the list */
     
     contacts_list_destroy(list, true);
     contacts_query_destroy(query);
    @@ -343,11 +366,11 @@ int contacts_list_destroy(contacts_list_h contacts_list, bool delete_child);
     
     

    The following example creates a list handle:

    -// Get a list handle with a query
    +/* Get a list handle with a query */
     contacts_list_h list = NULL;
     contacts_list_create(&list);
     
    -// Use the list
    +/* Use the list */
     
     contacts_list_destroy(list, true);
     
    @@ -355,11 +378,11 @@ contacts_list_destroy(list, true);

    The following example gets the person list handle from the database:

    -// Get a list handle with a query
    +/* Get a list handle with a query */
     contacts_list_h list = NULL;
     contacts_db_get_all_records(_contacts_person._uri, 0, 0, &list);
     
    -// Use the list
    +/* Use the list */
     
     contacts_list_destroy(list, true);
     
    @@ -376,23 +399,24 @@ int contacts_list_prev(contacts_list_h contacts_list);

    Get a record of the current cursor:

    -
    int contacts_list_get_current_record_p(contacts_list_h contacts_list, contacts_record_h* record);
    +
    +int contacts_list_get_current_record_p(contacts_list_h contacts_list, contacts_record_h* record);
    +

    The following example creates a loop list:

     contacts_list_h list = NULL;
     contacts_record_h record = NULL;
     contacts_db_get_all_records(_contacts_person._uri, 0, 0, &list);
    -do
    -{
    -   contacts_list_get_current_record_p(list, &record);
    -   if (NULL == record)
    -      break;
    -   char *name = NULL;
    -   contacts_record_get_str_p(record, _contacts_person.display_name, &name);
    -   dlog_print(DLOG_DEBUG, LOG_TAG, "name=%s", name);
    +do {
    +    contacts_list_get_current_record_p(list, &record);
    +    if (NULL == record)
    +        break;
    +    char *name = NULL;
    +    contacts_record_get_str_p(record, _contacts_person.display_name, &name);
    +    dlog_print(DLOG_DEBUG, LOG_TAG, "name=%s", name);
     } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
    -contacts_list_destroy(list, true); // Destroy child records automatically
    +contacts_list_destroy(list, true); /* Destroy child records automatically */
     

    Adding and Removing

    @@ -416,7 +440,7 @@ contacts_record_set_str(group2, _contacts_group.name, "group test2"); contacts_list_h list = NULL; contacts_list_create(&list); -// Add records to the list +/* Add records to the list */ contacts_list_add(list, group1); contacts_list_add(list, group2); @@ -426,7 +450,7 @@ contacts_list_destroy(list, true);

    Persons and Contacts

    -

    Persons are virtual contacts that keep merged information of contacts linked together. A person is created automatically when a contact record is inserted in the Contacts database. A person record cannot be created directly. Every contact must be linked to at least 1 person.

    +

    Persons are virtual contacts that keep merged information of contacts linked together. A person is created automatically when a contact record is inserted in the contacts database. A person record cannot be created directly. Every contact must be linked to at least 1 person.

    The following figure illustrates the process of creating a person record.

    Figure: Creating a person

    @@ -453,6 +477,8 @@ contacts_list_destroy(list, true);

    The contained data can also be a reference to another record. For example, a contact record contains the address property, which is a reference to an address record. An address record belongs to a contact record - its contact_id property is set to the identifier of the corresponding contact. In this case, the address is the child record of the contact and the contact is the parent record.

    Effectively, a record can be a node in a tree or graph of relations between records.

    +

    You can create records in the database, retrieve individual record details or lists of multiple records, delete records, and combine contact records by linking them into a single person.

    +

    URI

    A record type is identified by a structure called the view, which contains identifiers of its properties. Every view has a special field - _uri - that uniquely identifies the view. In many cases, you must provide the _uri value to indicate what type of record you want to create or operate on.

    @@ -480,12 +506,16 @@ contacts_list_destroy(list, true);

    When creating a record, you must specify what type of record you want to create by using the URI property. The following code examples creates a contact record and obtains its handle:

    -
    contacts_record_h contact = NULL;
    -contacts_record_create(_contacts_contact._uri, &contact);
    +
    +contacts_record_h contact = NULL;
    +contacts_record_create(_contacts_contact._uri, &contact);
    +

    The following example shows how to get a contact record with ID:

    -
    contacts_record_h contact = NULL;
    -contacts_db_get_record(_contacts_contact._uri, id, &contact);
    +
    +contacts_record_h contact = NULL;
    +contacts_db_get_record(_contacts_contact._uri, id, &contact);
    +

    Basic Types

    @@ -559,7 +589,8 @@ contacts_record_set_str(contact, _contacts_contact.ringtone_path, ringtone_path)

    The following example shows that there are 2 ways of getting string property:

     contacts_record_get_str(record, _contacts_person.display_name, &display_name);
    -contacts_record_get_str_p(record, _contacts_person.display_name, &display_name);
    +contacts_record_get_str_p(record, _contacts_person.display_name, &display_name); +

    In the first case, the returned string should be freed by the application. In second one, the display_name value is freed automatically when destroying the record handle.

    @@ -580,7 +611,7 @@ contacts_record_h image = NULL; int contact_id = 0; -// Image and address record can be child records of contact record +/* Image and address record can be child records of contact record */ contacts_record_create(_contacts_contact._uri, &contact); contacts_record_create(_contacts_image._uri, &image); @@ -595,7 +626,7 @@ contacts_record_create(_contacts_address._uri, &address); contacts_record_set_str(address, _contacts_address.country, "Korea"); contacts_record_add_child_record(contact, _contacts_contact.address, address); -// Insert contact to the database +/* Insert contact to the database */ contacts_db_insert_record(contact, &contact_id); contacts_record_destroy(contact, true);
    @@ -630,42 +661,44 @@ contacts_record_add_child_record(contact, _contacts_contact.name, name); int contact_id = 0; contacts_db_insert_record(contact, &contact_id); -contacts_record_destroy(contact, true); // Contact is no longer usable +contacts_record_destroy(contact, true); /* Contact is no longer usable */ -contacts_db_get_record(_contacts_contact._uri, contact_id, &contact); // Contact is now a handle to the same record as before +contacts_db_get_record(_contacts_contact._uri, contact_id, &contact); /* Contact is now a handle to the same record as before */ char *display_name = NULL; contacts_record_get_str(contact, _contacts_contact.display_name, &display_name); -contacts_record_destroy(contact, true); // Contact is no longer usable +contacts_record_destroy(contact, true); /* Contact is no longer usable */

    Identifiers can be used to establish a relationship between 2 records. The following code example sets an address record's contact_id property to the ID of the contact. The contact_id relates between the address record and the contact which is identified by the contact_id. After the ID is set, the address becomes one of the addresses connected to the contact. The address is now the contact's child record, and the contact is the parent record. The following example adds an address record to a contact_id:

    -
    int contact_id = ... // Acquire the ID of the created contact
    +
    +int contact_id = ... /* Acquire the ID of the created contact */
     int address_id = 0;
     contacts_record_create(_contacts_address._uri, &address);
     contacts_record_set_int(address, _contacts_address.contact_id, contact_id);
    -// Set other address properties
    +/* Set other address properties */
     
    -contacts_db_insert_record(address, &address_id);
    +contacts_db_insert_record(address, &address_id); +

    With a record handle, you can access all records of a specific type related to the given record.

    The following code example changes a country of addresses which are child records of a contact. Each address can be traversed by using the contacts_record_get_child_record_at_p() function. It is possible to apply the changes by updating the contact which is the parent record:

    -int contact_id = ... // Acquire ID of the created contact
    +int contact_id = ... /* Acquire ID of the created contact */
     unsigned int address_num = 0;
     int i = 0;
     contacts_db_get_record(_contacts_contact._uri, contact_id, &contact);
     contacts_record_get_child_record_count(contact, _contacts_contact.address, &address_num);
    -for (i = 0; i < address_num; i++)
    -{
    -   contacts_record_h address = NULL;
    -   contacts_record_get_child_record_at_p(contact, _contacts_contact.address, i, &address);
    -   contacts_record_set_str(address, _contacts_address.country, "Korea");
    +for (i = 0; i < address_num; i++) {
    +    contacts_record_h address = NULL;
    +    contacts_record_get_child_record_at_p(contact, _contacts_contact.address, i, &address);
    +    contacts_record_set_str(address, _contacts_address.country, "Korea");
     }
     contacts_db_update_record(contact);
    -contacts_record_destroy(contact, true);
    +contacts_record_destroy(contact, true); +

    Views and Properties

    @@ -679,36 +712,39 @@ contacts_record_destroy(contact, true);

    Figure: Properties

    Properties

    -

    For more information, see the View/Property API.

    +

    For more information, see the View/Property API (in mobile and wearable applications).

    vCards

    -

    The Contact Service provides functions for parsing and making vCards. The vCard APIs are based on the vCard v3.0 specification.

    +

    The Contact Service provides functions for parsing and making vCards. The vCard APIs are based on the vCard v3.0 specification.

    Parsing vCards

    -

    There are 2 ways for parsing vCards. The following example shows parsing vCard from stream and inserting it to the database. +

    There are 2 ways of importing contact information by parsing vCards. The following example shows parsing vCard from stream and inserting it to the database.

    -
    // Make a contact record list from the vCard stream
    +
    +/* Make a contact record list from the vCard stream */
     contacts_list_h list = NULL;
     contacts_vcard_parse_to_contacts(vcard_stream, &list);
    -// Use the contact record list
    +/* Use the contact record list */
     
    -contacts_list_destroy(list, true);
    +contacts_list_destroy(list, true); +

    The following example shows parsing vCard from a file and inserting it to database:

    -
    // Get a record handle of the _contacts_contact view
    +
    +/* Get a record handle of the _contacts_contact view */
     static bool __vcard_parse_cb(contacts_record_h record, void *user_data)
     {
    -   int id = 0;
    -   contacts_db_insert_record(record, &id);
    +    int id = 0;
    +    contacts_db_insert_record(record, &id);
     
    -   // Return false to break out of the loop
    -   // Return true to continue with the next iteration of the loop
    -   return true;
    +    /* Return false to break out of the loop */
    +    /* Return true to continue with the next iteration of the loop */
    +    return true;
     }
     
    -// Parse the vCard from a file
    +/* Parse the vCard from a file */
     char *resource_path = app_get_resource_path();
     char vcard_path[1024];
     snprintf(vcard_path, sizeof(vcard_path), "%s/vcard.vcf", resource_path);
    @@ -718,17 +754,20 @@ contacts_vcard_parse_to_contact_foreach(vcard_path, __vcard_parse_cb, NULL);
     
     
     

    Making a vCard Stream

    -

    You can make a vCard stream from a contact, person, or my profile record. The following code example makes a vCard stream using a contact record:

    -
    contacts_record_h contact;
    +

    You can export contact information and make a vCard stream from a contact, person, or my profile record. The following code example makes a vCard stream using a contact record:

    +
    +contacts_record_h contact;
     char *vcard_stream = NULL;
     
     contacts_db_get_record(_contacts_contact._uri, contact_id, &contact);
     contacts_vcard_make_from_contact(contact, &vcard_stream);
    -// Use the vcard stream
    +/* Use the vcard stream */
     
     free(vcard_stream);
    -contacts_record_destroy(contact, true);
    - +contacts_record_destroy(contact, true); +
    + + diff --git a/org.tizen.guides/html/native/social/service_adaptor_n.htm b/org.tizen.guides/html/native/social/service_adaptor_n.htm index 9190aa6..f5fdc99 100644 --- a/org.tizen.guides/html/native/social/service_adaptor_n.htm +++ b/org.tizen.guides/html/native/social/service_adaptor_n.htm @@ -70,10 +70,11 @@
  • Storage adaptor

    This adaptor handles files transfers to and from a cloud. It allows you to:

  • Contact adaptor @@ -119,14 +120,14 @@

    To start a plugin, use the following process:

    -
    1. Create a Service Adaptor with the service_adaptor_create() function.
    2. +
      1. Create a Service Adaptor with the service_adaptor_create() function.
      2. With a valid Service Adaptor handler, iterate through all installed plugins with the service_adaptor_foreach_plugin() function.
      3. Inside the callback (invoked for each plugin), get the plugin_uri value, which is passed to the service_adaptor_create_plugin() function.
      4. Request a start initialization for the service plugin with the service_plugin_start() function.

      The following example starts all installed Auth and Storage plugins appending each plugin_uri to the list object:

      -bool 
      +bool
       _plugin_iterator_cb(char *plugin_uri, int service_mask, void *user_data);
       
       service_adaptor_h service_adaptor = NULL;
      @@ -135,29 +136,28 @@ ret = service_adaptor_create(&service_adaptor);
       Evas_Object *list;
       ret = service_adaptor_foreach_plugin(service_adaptor, _plugin_iterator_cb, (void *)list);
       
      -bool 
      +bool
       _plugin_iterator_cb(char *plugin_uri, int service_mask, void *user_data)
       {
      -   Evas_Object *list = (Evas_Object *)user_data;
      +    Evas_Object *list = (Evas_Object *)user_data;
       
      -   if (!plugin_uri || !list)
      -      return false;
      +    if (!plugin_uri || !list)
      +        return false;
       
      -   if ((service_mask & SERVICE_PLUGIN_SERVICE_AUTH) && (service_mask & SERVICE_PLUGIN_SERVICE_STORAGE))
      -   {
      -      elm_list_item_append(list, plugin_uri, NULL, NULL, _show_plugin_view, plugin_uri);
      +    if ((service_mask & SERVICE_PLUGIN_SERVICE_AUTH) && (service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)) {
      +        elm_list_item_append(list, plugin_uri, NULL, NULL, _show_plugin_view, plugin_uri);
       
      -      service_plugin_h plugin = NULL;
      -      service_adaptor_create_plugin(service_adaptor, plugin_uri, &plugin);
      +        service_plugin_h plugin = NULL;
      +        service_adaptor_create_plugin(service_adaptor, plugin_uri, &plugin);
       
      -      // Hide this using config file or user input, because it is security information
      -      service_plugin_add_property(plugin, SERVICE_PLUGIN_PROPERTY_APP_KEY, "enasvv4l8hdbmhn");
      -      service_plugin_add_property(plugin, SERVICE_PLUGIN_PROPERTY_APP_SECRET, "uqhl4pp8mo7hmgn");
      -		
      -      service_plugin_start(plugin, (SERVICE_PLUGIN_SERVICE_AUTH | SERVICE_PLUGIN_SERVICE_STORAGE));
      -   }
      +        /* Hide this using config file or user input, because it is security information */
      +        service_plugin_add_property(plugin, SERVICE_PLUGIN_PROPERTY_APP_KEY, "enasvv4l8hdbmhn");
      +        service_plugin_add_property(plugin, SERVICE_PLUGIN_PROPERTY_APP_SECRET, "uqhl4pp8mo7hmgn");
       
      -   return true;
      +        service_plugin_start(plugin, (SERVICE_PLUGIN_SERVICE_AUTH | SERVICE_PLUGIN_SERVICE_STORAGE));
      +    }
      +
      +    return true;
       }
       
      diff --git a/org.tizen.guides/html/native/social/social_guide_n.htm b/org.tizen.guides/html/native/social/social_guide_n.htm index 0c428f8..adf18e4 100644 --- a/org.tizen.guides/html/native/social/social_guide_n.htm +++ b/org.tizen.guides/html/native/social/social_guide_n.htm @@ -16,7 +16,7 @@ @@ -35,10 +36,14 @@

      Social features include managing personal data, such as contacts and schedules, on the device.

      +

      The main social features are:

      +
        +
      • Contacts

        Allows you to work with contact information in your application by retrieving and managing individual contact information, searching for contacts, and receiving address book change notifications.

      • +
      +

      The following guides apply in mobile applications only:

      • Calendar

        Allows you to work with personal scheduling data by managing calendars, events, and todos, and setting reminders and recurrence properties. You can also search for calendar book entries and receive calendar book change notifications.

      • -
      • Contacts

        Allows you to work with contact information in your application by retrieving and managing individual contact information, searching for contacts, and receiving address book change notifications.

      • Service Adaptor

        Allows you to work with cloud storages and services by managing authentication, contact information and file transfers to and from the cloud.

      diff --git a/org.tizen.guides/html/native/system/device_n.htm b/org.tizen.guides/html/native/system/device_n.htm index 02e2614..d17a421 100644 --- a/org.tizen.guides/html/native/system/device_n.htm +++ b/org.tizen.guides/html/native/system/device_n.htm @@ -34,20 +34,21 @@

      Device

      -

      Device features provide functions to control attached devices. The following functionalities are supported:

      +

      Device features provide functions to control attached devices and monitor device changes. The following functionalities are supported:

      • Battery -

        Get the current percentage, the charging state, and the current level state using the Battery API (in mobile and wearable applications).

      • +

        Get battery details, such as the current percentage, the charging state, and the current level state, using the Battery API (in mobile and wearable applications).

      • Display -

        Get the number of displays, the maximum brightness of the display, the current brightness, and the display state. You can also change the current brightness and the display state using the Display API (in mobile and wearable applications).

      • +

        Get and set display details, such as the number of displays, the maximum brightness of the display, the current brightness, and the display state, using the Display API (in mobile and wearable applications).

      • Haptic -

        Get the number of haptic devices. You can also open or close the haptic handle, and request the vibration effects to play or stop using the Haptic API (in mobile and wearable applications).

      • +

        Manage the haptic devices by, for example, getting the number of haptic devices, opening or closing the haptic handle, and requesting the vibration effects to play or stop, with the Haptic API (in mobile and wearable applications).

      • IR -

        Get the information whether IR device is available. You can also transmit IR pattern using the IR API (in mobile and wearable applications).

      • +

        Manage the IR devices by, for example, determining whether an IR device is available and transmitting an IR pattern, using the IR API (in mobile and wearable applications).

      • LED -

        Get the maximum and current brightness of the camera flash LED. You can also change the current brightness of the camera flash LED, and request the service LED to play or stop effects using the Led API (in mobile and wearable applications).

      • +

        Manage the camera flash LED by, for example, getting the maximum and current brightness of the LED. You can also change the current brightness of the camera flash LED, and request the service LED to play or stop effects using the Led API (in mobile and wearable applications).

      • Power -

        Request the power state to be locked or unlocked, and change the power state using the Power API (in mobile and wearable applications).

      - +

      Request the power state to be locked or unlocked using the Power API (in mobile and wearable applications).

      + +
      diff --git a/org.tizen.guides/html/native/system/dlog_n.htm b/org.tizen.guides/html/native/system/dlog_n.htm index 4e0609b..d134a97 100644 --- a/org.tizen.guides/html/native/system/dlog_n.htm +++ b/org.tizen.guides/html/native/system/dlog_n.htm @@ -45,9 +45,9 @@

      The dlog logging service consists of the dlogutil dlog library, and it supports sending log messages to a circular log device. The log device is a circular buffer used to collect log messages from various applications and the system.

      -

      The dlog service sends a log message to the circular buffer with APIs, including Priority and Tag information. With this information, it is easy to filter and check the messages with dlogutil.

      +

      The dlog service sends a log message to the circular buffer with APIs, including Priority and Tag information. With this information, it is easy to filter and check the messages with dlogutil.

      -

      Before using dlog, you should know which priorities and tags to use and where to write (format, buffer).

      +

      Before using dlog, you should know which priorities and tags to use and where to write (format, buffer). You also need to initialize dlog.

      Priority

      @@ -89,34 +89,34 @@
    3. Info

      Use dlog_print(or dlog_vprint) function with DLOG_INFO priority when you need info messages to be displayed with a specified tag.

      -// Print the "Initialization successful." info message with the tag to the console
      -dlog_print(DLOG_INFO, "MyTag", "Initialization successful.");
    4. +/* Print the "Initialization successful." info message with the tag to the console */ +dlog_print(DLOG_INFO, "MyTag", "Initialization successful."); +
  • Debug

    Use dlog_print(or dlog_vprint) function with DLOG_DEBUG priority when you need debug messages to be displayed with a specified tag.

    -// Print the debug message "string: Test" to the console
    +/* Print the debug message "string: Test" to the console */
     dlog_print(DLOG_DEBUG, "MyTag", "string:","%s", "Test");
     
  • Error

    Use dlog_print(or dlog_vprint) function with DLOG_ERROR priority when you need error messages to be displayed with a specified tag.

    -if (something_wrong)
    -{
    -   // Print the error message with the tag to the console
    -   dlog_print(DLOG_ERROR, "MyTag", "An unexpected error occurred");     
    +if (something_wrong) {
    +    /* Print the error message with the tag to the console */
    +    dlog_print(DLOG_ERROR, "MyTag", "An unexpected error occurred");
     }
     
  • Warning

    Use dlog_print(or dlog_vprint) function with DLOG_WARN priority when you need warning messages to be displayed with a specified tag.

    -// Print the warning message with the tag to the console
    -dlog_print(DLOG_WARN, "MyTag", "warning!");     
    +/* Print the warning message with the tag to the console */
    +dlog_print(DLOG_WARN, "MyTag", "warning!");
     
  • Log macros belong to Info, Debug, Error, and Warn log levels. To filter logs based on their levels, select the applicable log type in the Log view. You can also search logs by keywords, such as Pid, Tid, Tag, and Message. The following figure shows the output of a log macro.

    Figure: Log macro output

    -

    Figure: Log macro output

    +

    Log macro output

    Tag

    A tag is used to identify the source of the log message.

    @@ -157,32 +157,35 @@ dlog_print(DLOG_WARN, "MyTag", "warning!");
     #include <dlog.h>
    -int main(void)
    +int
    +main(void)
     {
    -   int integer = 21;
    -   char string[] = "test dlog";
    -   dlog_print(DLOG_INFO, "USR_TAG", "test dlog");
    -   dlog_print(DLOG_INFO, "USR_TAG", "%s, %d", string, integer);
    +    int integer = 21;
    +    char string[] = "test dlog";
    +    dlog_print(DLOG_INFO, "USR_TAG", "test dlog");
    +    dlog_print(DLOG_INFO, "USR_TAG", "%s, %d", string, integer);
     
    -   return 0;
    +    return 0;
     }
     #include <dlog.h>
    -void my_debug_print(char *format, ...)
    +void
    +my_debug_print(char *format, ...)
     {
    -   va_list ap;
    -   va_start(ap, format);
    -   dlog_vprint(DLOG_INFO, "USR_TAG", format, ap);
    -   va_end(ap);
    +    va_list ap;
    +    va_start(ap, format);
    +    dlog_vprint(DLOG_INFO, "USR_TAG", format, ap);
    +    va_end(ap);
     }
     
    -int main(void)
    +int
    +main(void)
     {
    -   my_debug_print("%s", "test dlog");
    -   my_debug_print("%s, %d", "test dlog", 21);
    +    my_debug_print("%s", "test dlog");
    +    my_debug_print("%s, %d", "test dlog", 21);
     
    -   return 0;
    +    return 0;
     }
     
    @@ -191,18 +194,17 @@ int main(void)
     location_manager_h location_handle;
     int result = location_manager_create(LOCATION_METHOD_GPS, location_handle);
    -if (result != LOCATIONS_ERROR_NONE)
    -{
    -   dlog_print(DLOG_INFO, "MyTag", "Creation of the location manager failed.");
    +if (result != LOCATIONS_ERROR_NONE) {
    +    dlog_print(DLOG_INFO, "MyTag", "Creation of the location manager failed.");
     
    -   return false;
    +    return false;
     }
     

    While working with the SDK this information is available in the Log tab. While working with the target device, one can also use dlogutil utility.

    dlogutil

    -

    You can collect and print out logs with logutil. Logutil supports filtering, and managing the log device.

    +

    You can collect and print out logs with logutil. Logutil supports filtering, and managing the log device.

    Using Logutil Commands

    You can use a logutil command to view and follow the content of the log buffers. The general usage is:

    @@ -225,11 +227,15 @@ dlogutil [<option>] ... [<filter-spec>] ...

    For example, if you want to see all log messages with the MyApp tag that are above the debug priority:

    -
    # dlogutil MyApp:D
    +
    +# dlogutil MyApp:D
    +

    If you want to see all log messages above the info priority:

    -
    # dlogutil *:I
    +
    +# dlogutil *:I
    +

    Controlling Log Output Format

    The log messages contain a number of metadata fields in addition to tag and priority. You can modify the output format for messages so that they display a specific metadata field. To do so, use the -v option when starting dlogutil and specify one of the supported output formats:

    @@ -244,7 +250,9 @@ dlogutil [<option>] ... [<filter-spec>] ...
  • long: Displays all metadata fields and separates messages with blank lines
  • -
    # dlogutil [-v <format>]
    +
    +# dlogutil [-v <format>]
    +

    List of Logutil Command Options

    diff --git a/org.tizen.guides/html/native/system/feedback_n.htm b/org.tizen.guides/html/native/system/feedback_n.htm index e17ba76..d89016b 100644 --- a/org.tizen.guides/html/native/system/feedback_n.htm +++ b/org.tizen.guides/html/native/system/feedback_n.htm @@ -33,7 +33,7 @@

    Feedback

    -

    You can play a feedback pattern using sound or vibration.

    +

    You can play a feedback pattern using sound or vibration. You can play feedback for a specific pattern or play it for a specific type and pattern. You can also check whether a specific pattern is supported.

    This feature is supported in mobile applications only.

    The main features of the Feedback API include:

    diff --git a/org.tizen.guides/html/native/system/runtime_info_n.htm b/org.tizen.guides/html/native/system/runtime_info_n.htm index dce3203..25e3bbd 100644 --- a/org.tizen.guides/html/native/system/runtime_info_n.htm +++ b/org.tizen.guides/html/native/system/runtime_info_n.htm @@ -34,8 +34,8 @@

    Runtime information

    -

    Tizen provides various runtime information and enables your application to access it.

    -

    To obtain the information, query a runtime info key. The keys are listed in the following table. +

    Tizen provides various runtime information and enables your application to access it and monitor changes in it.

    +

    To obtain the information, query a runtime info key or use a specific function. The keys are listed in the following table.

    - +
    diff --git a/org.tizen.guides/html/native/system/sensors_n.htm b/org.tizen.guides/html/native/system/sensors_n.htm index 0b81743..0e6bb9c 100644 --- a/org.tizen.guides/html/native/system/sensors_n.htm +++ b/org.tizen.guides/html/native/system/sensors_n.htm @@ -81,14 +81,14 @@
  • Heart Rate Monitor LED IR Sensor
  • Heart Rate Monitor LED Red Sensor
  • -

    The Sensor API enables your application to receive data from the device's internal sensors. The application can receive the sensor data only when the data is modified.

    +

    The Sensor API enables your application to receive data from the device's internal sensors and monitor when sensor accuracy changes. The application can receive the sensor data only when the data is modified.

    - +
    Note

    All sensors may not be available on all devices.

    All sensors may not be available on all devices. You can check whether a sensor is supported.
    diff --git a/org.tizen.guides/html/native/system/settings_n.htm b/org.tizen.guides/html/native/system/settings_n.htm index 3deec9e..c7d2457 100644 --- a/org.tizen.guides/html/native/system/settings_n.htm +++ b/org.tizen.guides/html/native/system/settings_n.htm @@ -34,7 +34,7 @@

    System Settings

    -

    Tizen provides functions for getting the system configuration related to user preferences.

    +

    Tizen provides functions with which you can get the system configuration related to user preferences.

    The main features of the System Settings API include accessing system-wide configurations, such as ringtone, wallpaper, and font.

    @@ -59,7 +59,7 @@
    NOTIFIER system_settings_set_changed_cb

    system_settings_unset_changed_cb

    Register and unregister callback functions when the SETTER related to the key is called.Register and deregister callback functions when the SETTER related to the key is called.
    @@ -242,20 +242,21 @@

    The following example shows a typical use case: An application sees the name of the current wallpaper and you want to print out a message when the wallpaper changes:

    -void _img_cb (system_settings_key_e key, void *user_data)
    +void 
    +_img_cb(system_settings_key_e key, void *user_data)
     {
    -   printf("THIS IS CALLED BY USER APPLICATION WHEN THE WALLPAPER CHANGES \n");
    +    printf("THIS IS CALLED BY USER APPLICATION WHEN THE WALLPAPER CHANGES \n");
     }
     
    -// NOTIFIER 1 - Registering a callback function
    +/* NOTIFIER 1 - Registering a callback function */
     system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, _img_cb, NULL);
     char * path;
     
    -// GETTER
    +/* GETTER */
     system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &path);
     printf ("path of the current wallpaper is %s \n", path);
     
    -// NOTIFIER 2 - Deregistering a callback function
    +/* NOTIFIER 2 - Deregistering a callback function */
     system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN);
     
    diff --git a/org.tizen.guides/html/native/system/storage_n.htm b/org.tizen.guides/html/native/system/storage_n.htm index 8a6e22c..5126a60 100644 --- a/org.tizen.guides/html/native/system/storage_n.htm +++ b/org.tizen.guides/html/native/system/storage_n.htm @@ -85,10 +85,10 @@

    The main features of the Storage API include:

      -
    • Storage management

      You can manage different storages on the device with the Storage APIs.

      You can retrieve additional information about the storages, including which storage is supported in the device using the storage_foreach_device_supported() function. The callback function returns the storage type, mount state, and virtual root path.

      +
    • Storage management

      You can manage different storages on the device with the Storage APIs.

      You can retrieve additional information about the storages, including which storage is supported in the device using the storage_foreach_device_supported() function. The callback function returns the storage type, mount state, and virtual root path. You can also retrieve memory sizes and monitor storage state changes.

    • Storage space management -

      You can get the available and total space size of the storage with the storage_get_total_space() and storage_get_available_space() functions. They return the storage size, excluding the minimum memory size to launch the low memory pop-up in case of a low memory situation. Consequently, the available size must be less than the original available size, and you must use these functions to get the memory size. For the same reason, you cannot use the statvfs function directly in Tizen. Instead, use storage_get_internal_memory_size() and storage_get_external_memory_size(). The Statvfs structure has a different structure size defined by "__USE_FILE_OFFSET64". However, you can ignore this, since the Storage API uses a proper function automatically.

    +

    You can get the available and total space size of the storage with the storage_get_total_space() and storage_get_available_space() functions. They return the storage size, excluding the minimum memory size to launch the low memory pop-up in case of a low memory situation. Consequently, the available size must be less than the original available size, and you must use these functions to get the memory size. For the same reason, you cannot use the statvfs function directly in Tizen. Instead, use storage_get_internal_memory_size() and storage_get_external_memory_size(). The Statvfs structure has a different structure size defined by "__USE_FILE_OFFSET64". However, you can ignore this, since the Storage API uses a proper function automatically.

    diff --git a/org.tizen.guides/html/native/system/sysinfo_n.htm b/org.tizen.guides/html/native/system/sysinfo_n.htm index d6a4283..3154dfe 100644 --- a/org.tizen.guides/html/native/system/sysinfo_n.htm +++ b/org.tizen.guides/html/native/system/sysinfo_n.htm @@ -39,7 +39,7 @@

    System Information

    -

    System information features enable your application to retrieve information about fixed platform features or device capabilities by querying system information keys.

    +

    System information features enable your application to retrieve information about fixed platform features or device capabilities by querying system information keys. You can also check for supported features.

    - + - - - - + + + + - + - + - + - - - - + + + + @@ -615,18 +615,18 @@ the Tizen reference implementation. - - + + - - + + - - + +
    @@ -562,32 +562,32 @@ the Tizen reference implementation.
    Key Type Description
    http://tizen.org/feature/platform.core.cpu.archstringThe platform returns the type of CPU like "ARMv7".
    http://tizen.org/feature/platform.core.cpu.archStringThe platform returns the type of the CPU, such as "ARMv7".
    http://tizen.org/feature/platform.core.cpu.arch.armv6 boolThe platform returns true for this key, if the device runs on the ARMv6 CPU architecture. The platform returns true for this key, if the device runs on the ARMv6 CPU architecture.
    http://tizen.org/feature/platform.core.cpu.arch.armv7 boolThe platform returns true for this key, if the device runs on the ARMv7 CPU architecture. The platform returns true for this key, if the device runs on the ARMv7 CPU architecture.
    http://tizen.org/feature/platform.core.cpu.arch.x86 boolThe platform returns true for this key, if the device runs on the x86 CPU architecture. The platform returns true for this key, if the device runs on the x86 CPU architecture.
    http://tizen.org/feature/platform.core.cpu.frequencyintThe platform returns the max frequency of CPU.
    http://tizen.org/feature/platform.core.cpu.frequencyintThe platform returns the maximum frequency of the CPU.
    http://tizen.org/feature/platform.core.fpu.arch.sse2 bool
    http://tizen.org/feature/platform.native.api.versionstringThe platform returns the version of native api in the "[Major].[Minor]" format.StringThe platform returns the version of the native API in the "[Major].[Minor]" format.
    http://tizen.org/feature/platform.versionstringThe platform returns the version of platform in the "[Major].[Minor].[Patch Version]" format.StringThe platform returns the version of the platform in the "[Major].[Minor].[Patch Version]" format.
    http://tizen.org/feature/platform.web.api.versionstringThe platform returns the version of web api in the "[Major].[Minor]" format.StringThe platform returns the version of the Web API in the "[Major].[Minor]" format.
    @@ -817,7 +817,7 @@ the Tizen reference implementation. The platform returns true for this key, if the device supports the barometer sensor. - http://tizen.org/feature/sensor.barometer.wakeup + http://tizen.org/feature/sensor.barometer.wakeup bool The platform returns true for this key and the http://tizen.org/feature/sensor.barometer key, if the device supports the wake-up operation by the barometer sensor. @@ -1035,7 +1035,7 @@ the Tizen reference implementation. Description - http://tizen.org/feature/usb.accessory + http://tizen.org/feature/usb.accessory bool The platform returns true for this key, if the device supports the USB client or accessory mode. @@ -1104,39 +1104,40 @@ the Tizen reference implementation. Description - http://tizen.org/system/build.date - String - The platform returns the build date. The build date is made when platform image is created. - - http://tizen.org/system/build.id + http://tizen.org/system/build.date String - The platform returns the build id. The build id is made when platform image is created. + The platform returns the build date. The build date is made when the platform image is created. - http://tizen.org/system/build.string - String - The platform returns the build information string. The build information string is made when platform image is created. - + http://tizen.org/system/build.id + String + The platform returns the build ID. The build ID is made when the platform image is created. + - http://tizen.org/system/build.time + http://tizen.org/system/build.string String - The platform returns the build time. The build time is made when platform image is created. + The platform returns the build information string. The build information string is made when the platform image is created. - http://tizen.org/system/build.type + http://tizen.org/system/build.time String - The platform returns the build type like "user" or "eng". The build type is made when platform image is created. + The platform returns the build time. The build time is made when the platform image is created. - http://tizen.org/system/build.variant - String - The platform returns the variant release information. The variant release information is made when platform image is created. - + http://tizen.org/system/build.type + String + The platform returns the build type, such as "user" or "eng". The build type is made when the platform image is created. + - http://tizen.org/system/build.version.release - String - The platform returns the build version information. The build version information is made when platform image is created. - + http://tizen.org/system/build.variant + String + The platform returns the variant release information. The variant release information is made when the platform image is created. + + + http://tizen.org/system/build.version.release + String + The platform returns the build version information. The build version information is made when the platform image is created. + @@ -1171,7 +1172,7 @@ the Tizen reference implementation. Description - http://tizen.org/system/model_name + http://tizen.org/system/model_name String The platform returns the device model name. @@ -1194,12 +1195,12 @@ the Tizen reference implementation. The platform returns the device communication processor name. - http://tizen.org/system/platform.name + http://tizen.org/system/platform.name String The platform returns the platform name. - http://tizen.org/system/platform.processor + http://tizen.org/system/platform.processor String The platform returns the device processor name. @@ -1218,7 +1219,7 @@ the Tizen reference implementation. Description - http://tizen.org/system/tizenid + http://tizen.org/system/tizenid String The platform returns the TizenID. TizenID is a randomly generated value based on the model name. diff --git a/org.tizen.guides/html/native/system/t-trace_n.htm b/org.tizen.guides/html/native/system/t-trace_n.htm index cca9dee..19a398c 100644 --- a/org.tizen.guides/html/native/system/t-trace_n.htm +++ b/org.tizen.guides/html/native/system/t-trace_n.htm @@ -34,7 +34,7 @@

    T-trace

    -

    You can insert tracepoints in Tizen native applications to perform trace operations with the T-trace tool. The tracepoints allow the framework to write application traces to the system trace buffer to align them with the T-trace traces from the Tizen platform.

    +

    You can insert tracepoints in Tizen native applications to perform trace operations with the T-trace tool. The tracepoints allow the framework to write application traces to the system trace buffer to align them with the T-trace traces from the Tizen platform. Remember to initialize tracing before you start.

    This feature is supported in mobile applications only.

    diff --git a/org.tizen.guides/html/native/telephony/phonenumber_util_n.htm b/org.tizen.guides/html/native/telephony/phonenumber_util_n.htm index 70c3f5c..a9207be 100644 --- a/org.tizen.guides/html/native/telephony/phonenumber_util_n.htm +++ b/org.tizen.guides/html/native/telephony/phonenumber_util_n.htm @@ -16,7 +16,7 @@ @@ -31,17 +32,18 @@

    Phonenumber utils

    -

    Tizen enables you to parse and format phone numbers. The Phonenumber utils APIs are implemented with the libphonenumber opensource library.

    - -

    This feature is supported in mobile applications only.

    +

    Tizen enables you to parse and format phone numbers. The Phonenumber utils APIs are implemented with the libphonenumber open source library.

    The main features of the Phonenumber utils API include:

    • Retrieving the location information -

      You can get the location based on the phone number, region, and language using the phone_number_get_location_from_number() function. If the function cannot provide the location with the passed language, it uses English.

    • +

      You can get the location based on the phone number, region, and language using the phone_number_get_location_from_number() function. If the function cannot provide the location with the passed language, it uses English.

    • Formatting the phone number -

      You can format the phone number string based on the region using the dash ("-") and space (" ") characters using the phone_number_get_formatted_number() function.

    • +

      You can format the phone number string based on the region using the dash ("-") and space (" ") characters using the phone_number_get_formatted_number() function.

      + +
    • Normalizing the phone number +

      You can normalize the phone number using the phone_number_get_normalized_number() function.

    diff --git a/org.tizen.guides/html/native/telephony/telephony_guide_n.htm b/org.tizen.guides/html/native/telephony/telephony_guide_n.htm index 83e7730..578ad4b 100644 --- a/org.tizen.guides/html/native/telephony/telephony_guide_n.htm +++ b/org.tizen.guides/html/native/telephony/telephony_guide_n.htm @@ -35,16 +35,12 @@

    The main telephony features are:

    -

    The following guides apply in mobile applications only:

    - -
    diff --git a/org.tizen.guides/html/native/telephony/telephony_info_n.htm b/org.tizen.guides/html/native/telephony/telephony_info_n.htm index b0dbad4..4a82985 100644 --- a/org.tizen.guides/html/native/telephony/telephony_info_n.htm +++ b/org.tizen.guides/html/native/telephony/telephony_info_n.htm @@ -38,44 +38,35 @@

    Telephony Information

    -

    Telephony information features include call, SIM, network, and modem information using the Telephony Service.

    +

    Telephony information features include call, SIM, network, and modem information using the Telephony Service.

    The main telephony information features are:

    +

    Access (without changing) IMEI information.

    The following figure illustrates the Telephony Service and APIs.

    Figure: Telephony APIs and Telephony Service

    Telephony APIs and Telephony Service

    -

    Prerequisites

    -

    To use the telephony APIs, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file.

    -
    -<privileges>
    -    <privilege>http://tizen.org/privilege/telephony</privilege>
    -    <privilege>http://tizen.org/privilege/location.coarse</privilege>
    -</privileges>
    -
    -

    Call Information

    The Call API (in mobile and wearable applications) provides the following functions:

    • telephony_call_get_preferred_voice_subscription() -

      Gets the current value for the preferred voice call subscription. It returns one of the telephony_call_preferred_voice_subs_e values.

    • +

      Gets the current value for the preferred voice call subscription. It returns one of the telephony_call_preferred_voice_subs_e values (in mobile and wearable applications).

    • telephony_call_get_call_list()

      Gets the list of the current call. It returns the current call count and the call handle.

    • telephony_call_release_call_list() @@ -85,11 +76,11 @@
    • telephony_call_get_number()

      Gets the call number.

    • telephony_call_get_type() -

      Gets the call type. It returns one of the telephony_call_type_e values.

    • +

      Gets the call type. It returns one of the telephony_call_type_e values (in mobile and wearable applications).

    • telephony_call_get_status() -

      Gets the call status. It returns one of the telephony_call_status_e values.

    • +

      Gets the call status. It returns one of the telephony_call_status_e values (in mobile and wearable applications).

    • telephony_call_get_direction() -

      Gets the call direction: MO (Mobile Originated) or MT (Mobile Terminated). It returns one of the telephony_call_direction_e values.

    • +

      Gets the call direction: MO (Mobile Originated) or MT (Mobile Terminated). It returns one of the telephony_call_direction_e values (in mobile and wearable applications).

    • telephony_call_get_conference_status()

      Determines whether the call is conference call. It returns true for a conference call or false for a single call.

    @@ -174,19 +165,19 @@
  • telephony_sim_get_subscriber_number()

    Gets the subscriber number embedded in the SIM card. This value contains the MSISDN related to the subscriber. You get the subscriber number as a string, which needs to be freed by the application.

  • telephony_sim_get_state() -

    Gets the state of the SIM. It returns one of the telephony_sim_state_e values.

  • +

    Gets the state of the SIM. It returns one of the telephony_sim_state_e values (in mobile and wearable applications).

  • telephony_sim_is_changed()

    Checks whether the current SIM card differs from the previous SIM card.

  • telephony_sim_get_application_list() -

    Gets the application list on the UICC. It returns one of the masking (telephony_sim_application_type_e) values.

  • +

    Gets the application list on the UICC. It returns one of the masking values (telephony_sim_application_type_e in mobile and wearable applications).

  • telephony_sim_get_subscriber_id()

    Gets the subscriber ID as a string, which needs to be freed by the application.

  • telephony_sim_get_lock_state() -

    Gets the SIM card lock state. If SIM card is locked, you can use this function to retrieve lock state.

  • +

    Gets the SIM card lock state. If the SIM card is locked, you can use this function to retrieve the lock state.

  • telephony_sim_get_group_id1() -

    Gets the Group Identifier Level 1(GID1) embedded in the SIM card.

  • +

    Gets the Group Identifier Level 1 (GID1) embedded in the SIM card.

  • telephony_sim_get_call_forwarding_indicator_state() -

    Gets the call forwarding indicator state of the SIM. If the state is true, incoming call will be forwarded to the selected number.

  • +

    Gets the call forwarding indicator state of the SIM. If the state is true, incoming call is forwarded to the selected number.

    To get SIM state change notifications, the application must register for the notifications with the telephony_set_noti_cb() function, by specifying the notification ID.

    @@ -239,19 +230,19 @@
  • telephony_network_get_network_name()

    Gets the name of the current registered network. You get the network name as a string, which needs to be freed by the application.

  • telephony_network_get_type() -

    Gets the network service type of the current registered network. It returns one of the telephony_network_type_e values.

  • +

    Gets the network service type of the current registered network. It returns one of the telephony_network_type_e values (in mobile and wearable applications).

  • telephony_network_get_service_state() -

    Gets the current network state of the telephony service. It returns one of the telephony_network_service_state_e values.

  • +

    Gets the current network state of the telephony service. It returns one of the telephony_network_service_state_e values (in mobile and wearable applications).

  • telephony_network_get_ps_type() -

    Gets the packet service type of the currently registered network. It returns one of the telephony_network_ps_type_e values.

  • +

    Gets the packet service type of the currently registered network. It returns one of the telephony_network_ps_type_e values (in mobile and wearable applications).

  • telephony_network_get_network_name_option() -

    Gets the network name option of the currently registered network. It returns one of the telephony_network_name_option_e values.

  • +

    Gets the network name option of the currently registered network. It returns one of the telephony_network_name_option_e values (in mobile and wearable applications).

  • telephony_network_get_default_data_subscription() -

    Gets the current default subscription for the data service (packet-switched). It returns one of the telephony_network_default_data_subs_e values.

  • +

    Gets the current default subscription for the data service (packet-switched). It returns one of the telephony_network_default_data_subs_e values (in mobile and wearable applications).

  • telephony_network_get_default_subscription() -

    Gets the current default subscription for the voice service (circuit-switched). It returns one of the telephony_network_default_subs_e values.

  • +

    Gets the current default subscription for the voice service (circuit-switched). It returns one of the telephony_network_default_subs_e values (in mobile and wearable applications).

  • telephony_network_get_selection_mode() -

    Gets the network selection mode. If returns one of the telephony_network_selection_mode_e values.

  • +

    Gets the network selection mode. It returns one of the telephony_network_selection_mode_e values (in mobile and wearable applications).

  • telephony_network_get_tac()

    Gets the TAC (Tracking Area Code) of the current location.

  • telephony_network_get_system_id() @@ -264,6 +255,7 @@

    Gets the base station latitude of the current location.

  • telephony_network_get_base_station_longitude()

    Gets the base station longitude of the current location.

  • +

    To get network-related information change notifications, the application must register for the notifications with the telephony_set_noti_cb() function, by specifying the notification ID.

    @@ -311,36 +303,37 @@ Default subscription TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION - - Location Area Code - TELEPHONY_NOTI_NETWORK_LAC - - - Tracking Area Code - TELEPHONY_NOTI_NETWORK_TAC - - - System ID - TELEPHONY_NOTI_NETWORK_SYSTEM_ID - - - Network ID - TELEPHONY_NOTI_NETWORK_NETWORK_ID - - - Base station ID - TELEPHONY_NOTI_NETWORK_BS_ID - - - Base station latitude - TELEPHONY_NOTI_NETWORK_BS_LATITUDE - - - Base station longitude - TELEPHONY_NOTI_NETWORK_BS_LONGITUDE - + + Location Area Code + TELEPHONY_NOTI_NETWORK_LAC + + + Tracking Area Code + TELEPHONY_NOTI_NETWORK_TAC + + + System ID + TELEPHONY_NOTI_NETWORK_SYSTEM_ID + + + Network ID + TELEPHONY_NOTI_NETWORK_NETWORK_ID + + + Base station ID + TELEPHONY_NOTI_NETWORK_BS_ID + + + Base station latitude + TELEPHONY_NOTI_NETWORK_BS_LATITUDE + + + Base station longitude + TELEPHONY_NOTI_NETWORK_BS_LONGITUDE + +

    Modem Information

    @@ -348,10 +341,10 @@
    • telephony_modem_get_imei()

      Gets the IMEI (International Mobile Station Equipment Identity) of the mobile phone. You get the IMEI as a string, which needs to be freed by the application.

    • telephony_modem_get_power_status() -

      Gets the power status of the modem. It returns one of the telephony_modem_power_status_e values.

    • +

      Gets the power status of the modem. It returns one of the telephony_modem_power_status_e values (in mobile and wearable applications).

    • telephony_modem_get_meid()

      Gets the MEID (Mobile Equipment Identifier) of a mobile phone. You get the MEID as a string, which needs to be freed by the application.

    • -
    + @@ -375,4 +368,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/native/ui/eom_n.htm b/org.tizen.guides/html/native/ui/eom_n.htm index 1658b94..12c0b99 100644 --- a/org.tizen.guides/html/native/ui/eom_n.htm +++ b/org.tizen.guides/html/native/ui/eom_n.htm @@ -34,7 +34,9 @@

    The External Output Manager (EOM) is a module for controlling the external output devices.

    -

    This feature is supported in mobile applications only.

    +

    This feature is supported in mobile applications only.

    + +

    Before you start, remember to initialize the external output for use.

    The main features of the External Output Manager API include:

      @@ -86,11 +88,11 @@
    • Receiving notifications

      The EOM can send a notification event to the application. The EOM tracks several changes, such as additions and removals in the external output, mode changes, and attribute state changes, and can notify the application about them.

    • Getting information about the external output device -

      You can get information about the external output device by using various functions. For example, to get the ID of the external output device, use the eom_get_eom_output_ids() function, and to get attribute information, use the eom_get_output_attribute() function.

      +

      You can get information about the external output device by using various functions. For example, to get the ID of the external output device, use the eom_get_eom_output_ids() function, and to get attribute information, use the eom_get_output_attribute() function.

    • Setting the external output

      The application can set information (such as attributes and window size) in the EOM.

      -

      Use the eom_set_output_attribute() function to set the presentation mode, and use the eom_set_output_window() function to set the window to the external output with the best resolution of the external output device.

      +

      Use the eom_set_output_attribute() function to set the presentation mode, and use the eom_set_output_window() function to set the window to the external output with the best resolution of the external output device.

    diff --git a/org.tizen.guides/html/native/ui/minicontrol_n.htm b/org.tizen.guides/html/native/ui/minicontrol_n.htm index 86063ad..8788bc3 100644 --- a/org.tizen.guides/html/native/ui/minicontrol_n.htm +++ b/org.tizen.guides/html/native/ui/minicontrol_n.htm @@ -38,9 +38,9 @@

    The main features of the Minicontrol API include:

    • Creating a minicontrol -

      You can create minicontrols using the Minicontrol provider API, which requires the http://tizen.org/privilege/minicontrol.provider privilege:

      +

      You can create minicontrols using the Minicontrol provider API, which requires the http://tizen.org/privilege/minicontrol.provider privilege:

      • To create a minicontrol, use the minicontrol_create_window() function, which returns an Evas_Object of the minicontrol window.
      • -
      • To send a request, use the minicontrol_send_event() function to get a minicontrol handle and set the details.
      +
    • To send a request, use the minicontrol_send_event() function to get a minicontrol handle and set the details. You can use the same function to hide the quick panel, when needed.
  • Hosting minicontrols

    You can host minicontrols, such as lock screens, on your application using the Minicontrol viewer API:

    diff --git a/org.tizen.guides/html/native/uix/ime_n.htm b/org.tizen.guides/html/native/uix/ime_n.htm index 0f3ad95..210191f 100644 --- a/org.tizen.guides/html/native/uix/ime_n.htm +++ b/org.tizen.guides/html/native/uix/ime_n.htm @@ -42,7 +42,7 @@
    • Managing the IME life-cycle -

      The system can have multiple keyboards, and the user can choose which one to use as the default keyboard. The IME application starts its life-cycle when it is selected as the default keyboard. The following figure shows the IME application life-cycle.

      +

      The system can have multiple keyboards, and the user can choose which one to use as the default keyboard. The IME application starts its life-cycle when it is selected as the default keyboard. The following figure shows the IME application life-cycle.

      Figure: IME application life-cycle

      IME application life-cycle

      @@ -56,7 +56,7 @@
    • Managing the main loop and event callback functions -

      The IME application must implement the ime_app_main() function. It is the main entry point, in which you can register event callback functions and call the ime_run() function to start the main loop.

      +

      The IME application must implement the ime_app_main() function. It is the main entry point, in which you can register event callback functions and call the ime_run() function to start the main loop.

      During its life-cycle, the IME application can receive a number of events from the Tizen input service framework through the callback functions. You must register the mandatory create(), terminate(), show(), and hide() callbacks. Other callbacks can be registered as required by the specific IME application.

    • Showing and hiding the keyboard @@ -65,7 +65,7 @@

      The client application can set various configurations for each text input UI control, such as the cursor position, key layout type, return key type, and flags of predictive text. The configurations are delivered to the IME application though the show() callback function, to allow the keyboard to show the correct look to the user.

    • Using the keyboard option menu -

      Each keyboard can offer its own option menu to allow the user to manage the keyboard settings. Nowadays, most platforms provide the keyboard option menu from the device Settings application or from the keyboard directly.

      +

      Each keyboard can offer its own option menu to allow the user to manage the keyboard settings. Nowadays, most platforms provide the keyboard option menu from the device Settings application or from the keyboard directly.

      You can register callback functions that are called when the keyboard option menu opens or closes. These callback functions can be registered before the ime_run() function call in the ime_app_main() function.

      The device Settings application triggers the callback function to open the keyboard option menu. The keyboard itself can also trigger the callback function to open its option menu.

    @@ -74,17 +74,17 @@
    • Showing the IME list -

      You can request the installed IME list menu to be opened. If a new IME has been installed, the user can see its name in the IME list, and can use the toggle button to enable the keyboard they want. All keyboards enabled in the IME list are shown in the IME selector to allow the user to select them as the default keyboard.

      +

      You can request the installed IME list menu to be opened. If a new IME has been installed, the user can see its name in the IME list, and can use the toggle button to enable the keyboard they want. All keyboards enabled in the IME list are shown in the IME selector to allow the user to select them as the default keyboard.

      Figure: IME list

      IME list

    • Showing the IME selector -

      You can request the IME selector menu to be opened. When the user opens the IME selector menu, it shows all the keyboards enabled in the IME list. The user can change the default keyboard by selecting a new one. By clicking Select keyboard, the user can return to the IME list menu to enable a new IME.

      +

      You can request the IME selector menu to be opened. When the user opens the IME selector menu, it shows all the keyboards enabled in the IME list. The user can change the default keyboard by selecting a new one. By clicking Select keyboard, the user can return to the IME list menu to enable a new IME.

      Figure: IME selector

      IME selector

    • Checking the IME status -

      You can check whether a specific IME is enabled or disabled in the system keyboard setting. You can also check which IME is currently selected as the default keyboard. These features are useful when the user installs a new keyboard. And you can also get the number of IMEs which enabled (usable).

    • +

      You can check whether a specific IME is enabled or disabled in the system keyboard setting. You can also check which IME is currently selected as the default keyboard. These features are useful when the user installs a new keyboard. And you can also get the number of IMEs which enabled (usable).

    diff --git a/org.tizen.guides/html/native/uix/stt_n.htm b/org.tizen.guides/html/native/uix/stt_n.htm index 26544ff..28f0762 100644 --- a/org.tizen.guides/html/native/uix/stt_n.htm +++ b/org.tizen.guides/html/native/uix/stt_n.htm @@ -39,7 +39,7 @@

    STT

    -

    The STT (speech-to-text) features enable recognizing sound data recorded by the user and sending the result as text. When your application creates a handle and prepares the STT service by the API, the STT daemon is invoked and connected for background work. This daemon and your application communicate as the server and the client.

    +

    The STT (speech-to-text) features enable recognizing sound data recorded by the user and sending the result as text. When your application creates a handle and prepares the STT service by the API, the STT daemon is invoked and connected for background work. This daemon and your application communicate as the server and the client.

    Basic STT Processes

    @@ -47,13 +47,13 @@
    • Create a handle and register callback functions.
        -
      • Create a STT handle, which is used for distinguishing your application from other applications also using the STT.
      • -
      • Get notified on state changes, language changes, recognition results, and errors by registered callback functions.
      • +
      • Create a STT handle, which is used for distinguishing your application from other applications also using the STT.
      • +
      • Get notifications on state changes, language changes, recognition results, and errors by registered callback functions.
    • Start, stop, and cancel recognition.
        -
      • Start recording the user voice by microphone and analyze the recorded data as text.
      • +
      • Start recording the user voice by microphone and analyze the recorded data as text.
      • If you stop the recording manually by the API, the STT stops the recording and recognizes the sound data. The recognized text is then sent by the registered callback function.
      • You also can set sounds which are played before the STT recording starts or after the recording stops.
      @@ -75,7 +75,7 @@

      Getting STT Information

      You can get the following information about the STT:

        -
      • Get the current state of the STT. The state is also applied as a precondition for each function.
      • +
      • Get the current state of the STT. The state is also applied as a precondition for each function.
      • Get the default language.
        • You can start recognition with the language that you want as a parameter of the start API. However, if you do not set a specific language, the STT starts recording and uses the default language for recognition.
        • The default language can be changed by the STT setting an application or by the display language changing. If the display language is changed to a non-supported one, the STT language is changed to UK English.
      • diff --git a/org.tizen.guides/html/native/uix/tts_n.htm b/org.tizen.guides/html/native/uix/tts_n.htm index 2461a26..9890c76 100644 --- a/org.tizen.guides/html/native/uix/tts_n.htm +++ b/org.tizen.guides/html/native/uix/tts_n.htm @@ -39,7 +39,7 @@

        TTS

        -

        The TTS (text-to-speech) features include synthesizing text into sound data as utterances and playing them. It is also possible to pause and stop playing. When your application creates a handle and prepares the TTS service by the API, the TTS daemon is invoked and connected for background work. This daemon and your application communicate as the server and the client.

        +

        The TTS (text-to-speech) features include synthesizing text into sound data as utterances and playing them. It is also possible to pause and stop playing. When your application creates a handle and prepares the TTS service by the API, the TTS daemon is invoked and connected for background work. This daemon and your application communicate as the server and the client.

        Basic TTS Processes

        @@ -47,19 +47,20 @@
        • Create a handle and register callback functions.
            -
          • Create a TTS handle which is used for distinguishing your application from other applications also using the TTS.
          • -
          • To get notifications about state changes, language changes, starting or finishing utterances, and errors, register callback functions.
          • +
          • Create a TTS handle which is used for distinguishing your application from other applications also using the TTS.
          • +
          • To get notifications about state changes, language changes, starting or finishing utterances, and errors, register callback functions.
        • -
        • Add text. +
        • Add text and set the mode.
            -
          • Add the text that you want to read out by the TTS module. The requested text is handled as an utterance. You can add several texts, and they are managed using a queue.
          • +
          • Add the text that you want to read out by the TTS module. The requested text is handled as an utterance. You can add several texts, and they are managed using a queue.
          • There is a limit on the maximum text length for one utterance, and the time spent for synthesizing is dependent on the text length.
          • +
          • Get and set the TTS mode to manage audio mixing with other sources.
        • Play, pause, and stop playback.
        • @@ -73,7 +74,7 @@

          Getting TTS Information

          You can get the following information about the TTS:

            -
          • Get the current state of the TTS. The state is also applied as a precondition for each function.
          • +
          • Get the current state of the TTS. The state is also applied as a precondition for each function.
          • Get the default voice.
            • In the TTS, the voice is defined as a combination of the language and the type, such as male or female.
            • diff --git a/org.tizen.guides/html/native/uix/voicecontrol_elm_n.htm b/org.tizen.guides/html/native/uix/voicecontrol_elm_n.htm index b53e75a..174c695 100644 --- a/org.tizen.guides/html/native/uix/voicecontrol_elm_n.htm +++ b/org.tizen.guides/html/native/uix/voicecontrol_elm_n.htm @@ -63,9 +63,9 @@

              The main features of the Voice control elementary API include:

              • Managing commands and hints -

                You can set commands and hints for visible UI components on the application screen. The hint message shows the user which command must be spoken to interact with that UI component. When the user speaks a command, the command is executed.

              • +

                You can set commands and hints for visible UI components on the application screen. The hint message shows the user which command must be spoken to interact with that UI component. When the user speaks a command, the command is executed.

              • Retrieving information -

                You can get various information from the Voice control elementary API:

                +

                You can get various information from the Voice control elementary API:

                • Default language

                  You can start the recognition with any language you want. However, if you do not set a specific language, the Voice control elementary library start recognizing voice commands with the default language.

                • Supported language @@ -75,6 +75,7 @@
                +

                You can set and unset a callback to get notifications when the system or application language changes.

                The following table lists the EFL UI components that support voice commands, and the actions supported by each component and already defined in the configuration file. Note that the label component only supports the hint without any action command.

                @@ -185,7 +186,7 @@

                To use the voice commands:

                -
                1. Initialize the Voice control elementary library and create a handle. +
                  1. Initialize the Voice control elementary library and create a handle.

                    The Voice control elementary handle is used to set user-defined commands and hints for the corresponding UI component in the application.

                  2. Set commands and hints.

                    With a handle related to the individual UI component in the application screen, you can specify a command used to distinguish that component from others.

                    diff --git a/org.tizen.guides/html/native/uix/voicecontrol_n.htm b/org.tizen.guides/html/native/uix/voicecontrol_n.htm index abf8a53..e7503ee 100644 --- a/org.tizen.guides/html/native/uix/voicecontrol_n.htm +++ b/org.tizen.guides/html/native/uix/voicecontrol_n.htm @@ -41,7 +41,7 @@
                  3. Managing commands

                    You can use the Voice control service to register commands as foreground or background type. When the user speaks a registered command, the callback function returns the recognition result.

                  4. Retrieving information -

                    You can get various information from the voice control:

                    +

                    You can get various information from the voice control:

                    • Voice control state

                      The state is changed by functions and applied as a precondition of each API.

                    • Voice control service state @@ -56,14 +56,14 @@

                      To use the voice control:

                      -
                      1. Initialize the voice control and register callback functions. +
                        1. Initialize the voice control and register callback functions.

                          The initialization allows the voice control to distinguish your application from any other applications also using voice control. The registered callbacks allow you to receive notifications about changes in the service state, language, and recognition result, and about any errors.

                        2. Prepare the voice control.

                          The preparation connects the Voice control service for background work, such as recording and recognizing the user voice.

                          When the application initializes and prepares the voice control, the Voice control daemon is invoked and connected for background work. The daemon and the application communicate as server and client.

                        3. Set commands. -

                          You can create a command list, and add or remove individual commands in the list. When creating an individual command, set the command text and type for each command handle. When all commands are created and added to the command list, set the command list to the voice control for recognition.

                        4. +

                          You can create a command list, and add or remove individual commands in the list. When creating an individual command, set the command text and type for each command handle. When all commands are created and added to the command list, set the command list to the voice control for recognition.

                        5. Get the recognition result.

                          The recognition result is sent through a registered callback function.

                          If the registered command is duplicated or the user speaks multiple commands, the recognition result can contain multiple results. If you set duplicated commands, the Voice control service can reject the command. The rejection is shown in the result event.

                        6. diff --git a/org.tizen.guides/html/native/web/web_guide_n.htm b/org.tizen.guides/html/native/web/web_guide_n.htm index a212368..eddab77 100644 --- a/org.tizen.guides/html/native/web/web_guide_n.htm +++ b/org.tizen.guides/html/native/web/web_guide_n.htm @@ -34,7 +34,7 @@

                          Web

                          -

                          Web features include accessing Web content in your application.

                          +

                          Web features include accessing Web content in your application. Before you start, remember to initialize the EWK WebKit for use.

                          The main Web features are:

                            @@ -42,7 +42,17 @@

                            Enables you to access the Web pages and Web content.

                            The WebView API implements the EFL WebKit (EWK), which covers various features for Web browsing, such as loading and displaying Web pages and navigating through the browsing history. The EFL APIs (in mobile and wearable applications), such as evas_*, elm_*, and eina_*, are used to build up a complete application supporting Web browsing.

                            -
                          +
                    + +

                    To use the Web features to create a simple Web browser:

                    +
                      +
                    1. Create a window object, and set the window layout and view. +

                      Later on, you can use various helper functions to find the created window.

                    2. +
                    3. Show the window and set the focus. +

                      You can handle key and mouse events in the window.

                    4. +
                    5. When no longer needed, terminate the window.
                    6. +
                    + diff --git a/org.tizen.guides/html/web/tizen/account/account_guide_w.htm b/org.tizen.guides/html/web/tizen/account/account_guide_w.htm index 48785ea..2ee5d83 100644 --- a/org.tizen.guides/html/web/tizen/account/account_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/account/account_guide_w.htm @@ -77,6 +77,8 @@ +

                    Before you start, remember to prepare your application to use the account functionality.

                    +

                    The account provider application declares the account capabilities. The capability name is decided by the author of the account provider application, and must have an IRI form. For example:

                    • http://tizen.org/account/capability/contact is used when the account is related to contacts.
                    • http://tizen.org/account/capability/calendar is used when the account is related to the calendar. diff --git a/org.tizen.guides/html/web/tizen/application/alarm_w.htm b/org.tizen.guides/html/web/tizen/application/alarm_w.htm index f2e8fca..8acf883 100644 --- a/org.tizen.guides/html/web/tizen/application/alarm_w.htm +++ b/org.tizen.guides/html/web/tizen/application/alarm_w.htm @@ -42,6 +42,9 @@
                    • Application launches with alarms

                      You can set an alarm to launch an application when triggered.

                    • Alarm events

                      You can retrieve information about the next alarm event using the AlarmAbsolute (in mobile and wearable applications) and AlarmRelative (in mobile and wearable applications) interfaces. They provide the time and date of the next scheduled absolute alarm, or the time remaining before the next relative alarm.

                    + +

                    Before you start, remember to prepare your application to use the alarm functionality.

                    +

                    To define a time period for the relative alarm or for the recurrence of an absolute alarm, you can use the following predefined constants from the Alarm API:

                    • tizen.alarm.PERIOD_MINUTE represents the number of seconds in a minute (60).
                    • diff --git a/org.tizen.guides/html/web/tizen/application/app_guide_w.htm b/org.tizen.guides/html/web/tizen/application/app_guide_w.htm index db52947..794743b 100644 --- a/org.tizen.guides/html/web/tizen/application/app_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/application/app_guide_w.htm @@ -10,7 +10,7 @@ - Application + Application Framework @@ -23,29 +23,30 @@

                      Related Info

                      -

                      Application

                      -

                      Application features include managing various types of applications and packages, badges, notifications, input devices and handling events, communicate with other web or native applications.

                      -

                      The main application features are:

                      +

                      Application Framework

                      +

                      Application framework features include managing various types of applications and packages, badges, notifications, input devices, and events, and communicating with other Web or native applications.

                      +

                      The main application framework features are:

                      • Alarm

                        Allows you to schedule an application to be run at a specific time

                      • Application

                        Allows you to monitor and retrieve information about the applications installed or running on the device, manage control mechanisms that launch other applications, and broadcast and listen for events.

                      • Application Group

                        Allows you to define the application launch mode and group your applications into entities that can be managed together.

                      • -
                      • Badge

                        Allows you to create and update badges on the home screen.

                      • -
                      • Data Control

                        Enables you to use data stored and provided by another application.

                      • -
                      • Input Device

                        Allows you to manage input keys in the application.

                      • -
                      • Message Port

                        Allows you to send and receive messages through message ports.

                      • -
                      • Notification

                        Allows you to create and display different types of notifications.

                      • -
                      • Package

                        Allows you to retrieve information about packages and manage package installation.

                      • -
                      - +
                    • Badge

                      Allows you to create and update badges on the home screen.

                    • +
                    • Data Control +

                      Enables you to use data stored and provided by another application.

                    • +
                    • Input Device +

                      Allows you to manage input keys in the application.

                    • +
                    • Message Port

                      Allows you to send and receive messages through message ports.

                    • +
                    • Notification

                      Allows you to create and display different types of notifications.

                    • +
                    • Package

                      Allows you to retrieve information about packages and manage package installation.

                    • +
                    diff --git a/org.tizen.guides/html/web/tizen/application/appgroup_w.htm b/org.tizen.guides/html/web/tizen/application/appgroup_w.htm index 4d5b046..32c83f7 100644 --- a/org.tizen.guides/html/web/tizen/application/appgroup_w.htm +++ b/org.tizen.guides/html/web/tizen/application/appgroup_w.htm @@ -43,7 +43,7 @@
                  5. The GROUP launch mode means that the application can be launched as a sub application belonging to the same group as the caller application which is causing the application to be launched.
                  6. -

                    Additionally, if the launch mode is not set to SINGLE in the config.xml file and the application is launched by the launchAppControl() function (in mobile and wearable applications) with the ApplicationControl object (in mobile and wearable applications), the launchMode property of this object overrides the launch mode of the called application. If the launch mode in the config.xml file is set to SINGLE, the value of the ApplicationControl.launchMode property is ignored and the sub application is always called in the SINGLE mode.

                    +

                    Additionally, if the launch mode is not set to SINGLE in the config.xml file and the application is launched by the launchAppControl() method (in mobile and wearable applications) with the ApplicationControl object (in mobile and wearable applications), the launchMode property of this object overrides the launch mode of the called application. If the launch mode in the config.xml file is set to SINGLE, the value of the ApplicationControl.launchMode property is ignored and the sub application is always called in the SINGLE mode.

                  7. Managing the application group

                    Applications in a same group act as if they are in 1 stack. For example, if an application A wants to send an email using an email application B, the application A can launch the email application B, making the email application B a sub application in the same group as the application A. When both applications are running, and the user presses the home button, both applications are hidden. When the user later resumes the caller application (application A), the email application B is shown on top of the caller application.

                    @@ -55,6 +55,7 @@
                  8. +

                    Before you start, remember to prepare your application to use the application group functionality.

                    diff --git a/org.tizen.guides/html/web/tizen/application/application_w.htm b/org.tizen.guides/html/web/tizen/application/application_w.htm index d78c1d3..d4a844a 100755 --- a/org.tizen.guides/html/web/tizen/application/application_w.htm +++ b/org.tizen.guides/html/web/tizen/application/application_w.htm @@ -68,6 +68,7 @@ +

                    Before you start, remember to prepare your application to use the fundamental functionality.

                    Application Controls

                    An application control is a mechanism for using operations, such as calling, Web browsing, and playing media items, which are exported by other applications. It allows you to conveniently launch other applications whose functionalities you need in your application. If you need to use functionality from another application, launching an application control allows you to request the system to launch that application according to your requirements. You can launch applications based on your immediate needs - you do not need to know their identifiers or specifications.

                    @@ -154,7 +155,7 @@ tizen.application.launchAppControl(appControl, null, successCb, errCb, null); /* Assuming that the filesystem virtual root "images" has been resolved and saved in variable images */ var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view",                                               images.resolve("image12.jpg").toURI(), -                                              "image/*", null , null); +                                              "image/*", null, null); tizen.application.findAppControl(appControl, function(appInfos, appCtrl) { @@ -217,7 +218,7 @@ tizen.application.findAppControl(appControl, function(appInfos, appCtrl) /* Assuming that the filesystem virtual root "images" has been resolved and saved in variable images */ var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view",                                               images.resolve("image12.jpg").toURI(), -                                              null, null , null); +                                              null, null, null);

                    When the system attempts to resolve the request and find the application to be launched, it checks the service descriptions. In the following example, the application with the first service description is not launched, since the uri information does not match the request. However, the application with the second service description is a match and can be launched:

                    @@ -267,7 +268,7 @@ window.addEventListener("appcontrol", function onAppControl()
                        var reqAppControl = tizen.application.getCurrentApplication.getRequestedAppControl();
                        if (reqAppControl)
                        {
                    -      // Handle the application control request
                    +      /* Handle the application control request */
                        }
                     });
                    @@ -284,7 +285,7 @@ window.addEventListener("appcontrol", function onAppControl()

                    Allowing Applications to Run on the Background

                    -

                    When a Web application becomes invisible (moves to the background), it is suspended. Before Tizen 2.4, to continue to execute the application on the background, you had to set the background-support attribute of the <tizen:setting> element to enable in the config.xml file (in mobile and wearable applications).

                    +

                    When a Web application becomes invisible (moves to the background), it is suspended. Before Tizen 2.4, to continue to execute the application on the background, you had to set the background-support attribute of the <tizen:setting> element to enable in the config.xml file (in mobile and wearable applications).

                    Since Tizen 2.4, the background process management policy has been changed. The system does not allow applications to run on the background except when they are explicitly declared to do so by having a specific background category. For more information on the available background categories, see the Allowed background application policy table.

                    @@ -294,7 +295,7 @@ window.addEventListener("appcontrol", function onAppControl()
                - +
                Note
                To guarantee that a Web application runs on the background, at least one background-category element must be declared in the config.xml file (in mobile and wearable applications), and the background-support attribute of the <tizen:setting> element must be set to enable.To guarantee that a Web application runs on the background, at least one background-category element must be declared in the config.xml file (in mobile and wearable applications), and the background-support attribute of the <tizen:setting> element must be set to enable.
                diff --git a/org.tizen.guides/html/web/tizen/application/badge_w.htm b/org.tizen.guides/html/web/tizen/application/badge_w.htm index b45ab61..9220f02 100644 --- a/org.tizen.guides/html/web/tizen/application/badge_w.htm +++ b/org.tizen.guides/html/web/tizen/application/badge_w.htm @@ -48,7 +48,7 @@

                You can receive notifications on badge changes to display and react to badges.

              - +

              Before you start, remember to prepare your application to use the badge functionality.

              diff --git a/org.tizen.guides/html/web/tizen/application/common_appcontrol_w.htm b/org.tizen.guides/html/web/tizen/application/common_appcontrol_w.htm index 219fb85..7a3592f 100644 --- a/org.tizen.guides/html/web/tizen/application/common_appcontrol_w.htm +++ b/org.tizen.guides/html/web/tizen/application/common_appcontrol_w.htm @@ -1544,7 +1544,7 @@ tizen.application.launchAppControl(appControl, null,

              Sharing Text in a Message

              -

              To share any text with an SMS or MSM message, use the http://tizen.org/appcontrol/operation/share_text operation.

              +

              To share any text with an SMS or MMS message, use the http://tizen.org/appcontrol/operation/share_text operation.

              Figure: Sharing text

              Sharing text

              diff --git a/org.tizen.guides/html/web/tizen/application/data_w.htm b/org.tizen.guides/html/web/tizen/application/data_w.htm index 2bf01ba..cf07b49 100644 --- a/org.tizen.guides/html/web/tizen/application/data_w.htm +++ b/org.tizen.guides/html/web/tizen/application/data_w.htm @@ -34,19 +34,18 @@

              Data Control

              Data control allows you to read and modify data stored and provided by another application. The application storing and controlling the data is called a DataControl provider application. The application using the data is called a DataControl consumer application. A single DataControl provider can serve multiple DataControl consumers.

              - -

              The Data control API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable applications. All mandatory APIs are supported on the Tizen Emulators.

              +

              The Data Control API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable applications. All mandatory APIs are supported on the Tizen Emulators.

              The main data control features are:

              - +

              Before you start, remember to prepare your application to use the data control functionality.

              @@ -70,4 +69,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/web/tizen/application/inputdevice_w.htm b/org.tizen.guides/html/web/tizen/application/inputdevice_w.htm index f6365a0..fecf224 100644 --- a/org.tizen.guides/html/web/tizen/application/inputdevice_w.htm +++ b/org.tizen.guides/html/web/tizen/application/inputdevice_w.htm @@ -16,7 +16,7 @@
            +

        Input Device

        Tizen enables you to manage input device keys.

        - -

        The Input Device API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices.

        + +

        The Input Device API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The Input Device API is not supported on any Tizen Emulators.

        The main features of the Input Device API include:

        • Gathering a list of supported keys

          You can get a list of all supported keys - using the InputDeviceManager interface (in mobile and wearable applications).

        • + using the InputDeviceManager interface (in mobile and wearable applications).

        • Getting key information by its name

          You can gather information about the key by its name - using the InputDeviceManager interface and InputDeviceKey object (in mobile and wearable applications).

        • -
        • Registering and unregistering key events -

          When you want to react to Input Device key presses, register the applicable key using the InputDeviceManager interface. After registering the input device key, the application receives a DOM keyboard event when the key is pressed or released. When the events are no longer needed, unregister the key.

          + using the InputDeviceManager interface and InputDeviceKey object (in mobile and wearable applications).

        • +
        • Registering and deregistering key events +

          When you want to react to Input Device key presses, register the applicable key using the InputDeviceManager interface. After registering the input device key, the application receives a DOM keyboard event when the key is pressed or released. When the events are no longer needed, deregister the key.

          The application cannot register the mandatory keys (ArrowLeft, ArrowRight, ArrowUp, ArrowDown, Enter, and Back).

        diff --git a/org.tizen.guides/html/web/tizen/application/message_port_w.htm b/org.tizen.guides/html/web/tizen/application/message_port_w.htm index 13fa416..9e2f7d2 100644 --- a/org.tizen.guides/html/web/tizen/application/message_port_w.htm +++ b/org.tizen.guides/html/web/tizen/application/message_port_w.htm @@ -32,13 +32,13 @@

        Message Port

        -

        Tizen Web applications can communicate with other Web or native applications. The message data type for the communication is map data, which consists of a string key and value that can be string, string array, byte stream or byte stream array.

        +

        Tizen Web applications can communicate with other Web or native applications. The message data type for the communication is map data, which consists of a string key and value that can be a string, string array, byte stream, or byte stream array.

        The Message Port API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable devices. All mandatory APIs are supported on the Tizen Emulators.

        You can send and receive messages through 2 types of message ports:

        • The LocalMessagePort interface (in mobile and wearable applications) is used to register your message port and prepare to receive messages from other applications. -

          To receive messages from other applications, you must register a callback function to the local message port.

        • +

          To receive messages from other applications, you must register a callback to the local message port.

        • The RemoteMessagePort interface (in mobile and wearable applications) is used to send messages to other applications.

          The local message port information can be sent to another application for bi-directional communication.

        @@ -48,7 +48,7 @@
        • A Tizen Web application can send messages to another application using the sendMessage() method of the RemoteMessagePort interface.

          To receive response messages from the other application, your application can specify a local message port when it sends the message. You can receive response messages using the callback method which is registered through the addMessagePortListener() method of the LocalMessagePort interface.

        • -
        • The application that wants to receive messages from your application can mostly be implemented as a Tizen Web or native application. To implement it as a native application, see the mobile native Message Port Communication guide.
        +
      • The application that wants to receive messages from your application can mostly be implemented as a Tizen native or Web application. To implement it as a native application, see the native Message Port Communication guide.

      Figure: Message port communication

      Message port communication

      @@ -79,4 +79,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/web/tizen/application/noti_w.htm b/org.tizen.guides/html/web/tizen/application/noti_w.htm index b806104..c86e141 100644 --- a/org.tizen.guides/html/web/tizen/application/noti_w.htm +++ b/org.tizen.guides/html/web/tizen/application/noti_w.htm @@ -43,6 +43,9 @@
    • Creating progress notifications
    • Managing notifications
    + +

    Before you start, remember to prepare your application to use the notification functionality.

    +

    To display a notification, you need to create a Notification object (in mobile and wearable applications), or its subtype.

    diff --git a/org.tizen.guides/html/web/tizen/application/package_w.htm b/org.tizen.guides/html/web/tizen/application/package_w.htm index 7802870..9eba17d 100644 --- a/org.tizen.guides/html/web/tizen/application/package_w.htm +++ b/org.tizen.guides/html/web/tizen/application/package_w.htm @@ -46,7 +46,7 @@
  • Package change notifications

    You can receive notifications of changes in the list of installed packages. The setPackageInfoEventListener() method of the PackageManager interface registers an event listener for changes in the installed packages list. To unsubscribe the listener, use the unsetPackageInfoEventListener() method. You can use the PackageInformationEventCallback interface (in mobile and wearable applications) to define listeners for receiving notifications.

  • - +

    Before you start, remember to prepare your application to use the package functionality.

    diff --git a/org.tizen.guides/html/web/tizen/base/archive_w.htm b/org.tizen.guides/html/web/tizen/base/archive_w.htm index ac340d4..5a870f6 100644 --- a/org.tizen.guides/html/web/tizen/base/archive_w.htm +++ b/org.tizen.guides/html/web/tizen/base/archive_w.htm @@ -45,10 +45,11 @@
  • Accessing archive content

    You can read the content of an archive file using the ArchiveFile interface (in mobile and wearable applications).

  • Creating new archives

    You can create archive files and add files into them using the ArchiveFile interface.

  • Extracting archived files

    You can extract a single file or all files from an archive file using the ArchiveFile interface.

  • -
  • Aborting operations

    You can abort an on-going archive operation using the operation ID and the abort() method of the ArchiveManager interface.

    +
  • Aborting operations

    You can abort an on-going archive operation using the operation ID and the abort() method of the ArchiveManager interface.

    You can abort the operations for the open(), add(), extractAll(), getEntries(), getEntryByName(), and extract() methods.

  • +

    Before you start, remember to prepare your application to use the archive functionality.

    To start any kind of zip operation (packing or unpacking), you must first call the open() method of the ArchiveManager interface (in mobile and wearable applications). The first parameter of is a FileReference object (in mobile and wearable applications), which can be a File object (in mobile and wearable applications) or the virtual path. The second parameter is a FileMode enumerator (in mobile and wearable applications), whose values are described in the following table.

    diff --git a/org.tizen.guides/html/web/tizen/base/base_guide_w.htm b/org.tizen.guides/html/web/tizen/base/base_guide_w.htm index 0399605..a707142 100644 --- a/org.tizen.guides/html/web/tizen/base/base_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/base/base_guide_w.htm @@ -22,24 +22,24 @@
    - -

    Base

    -

    Base features include managing the common files, zip archive files and handling events and organizing data.

    +

    Base

    +

    Base features include managing the common files and zip archive files, handling events, and organizing data.

    The main base features are:

    +
    • Archive

      Enables you to operate on the zip archive files.

    • -
    • Filesystem

      Enables you to manage the files and directories in the device file system.

    • -
    • Tizen

      Enables you to handling events and organizing data.

    • -
    - +
  • Filesystem

    Enables you to manage the files and directories in the device file system.

  • +
  • Tizen

    Enables you to handle events and organize data.

  • + +
    diff --git a/org.tizen.guides/html/web/tizen/base/filesystem_w.htm b/org.tizen.guides/html/web/tizen/base/filesystem_w.htm index 69a239d..a3e6a26 100644 --- a/org.tizen.guides/html/web/tizen/base/filesystem_w.htm +++ b/org.tizen.guides/html/web/tizen/base/filesystem_w.htm @@ -88,6 +88,9 @@
    + +

    Before you start, remember to prepare your application to use the file system functionality.

    +

    The main features of the Filesystem API include:

    • File storage management

      You can manage different storages on the device with the FileSystemManager interface (in mobile and wearable applications).

      You can retrieve additional information about the storages, including listing available storages and receiving storage change notifications with the listStorages() and addStorageStateChangeListener() methods provided by the FileSystemManager interface.

    • diff --git a/org.tizen.guides/html/web/tizen/base/tizen_w.htm b/org.tizen.guides/html/web/tizen/base/tizen_w.htm index 91fe28e..7cca4b2 100644 --- a/org.tizen.guides/html/web/tizen/base/tizen_w.htm +++ b/org.tizen.guides/html/web/tizen/base/tizen_w.htm @@ -113,11 +113,7 @@ var event = new tizen.CalendarEvent( Table: Calendar filter attributes - - - - - + Attribute @@ -125,124 +121,124 @@ var event = new tizen.CalendarEvent( Attribute range filter supported -

      id

      -

      Yes

      -

      No

      + id + Yes + No -

      id.uid

      -

      Yes

      -

      No

      + id.uid + Yes + No -

      description

      -

      Yes

      -

      No

      + description + Yes + No -

      summary

      -

      Yes

      -

      No

      + summary + Yes + No -

      isAllDay

      -

      Yes

      -

      No

      + isAllDay + Yes + No -

      isDetached

      -

      Yes

      -

      No

      + isDetached + Yes + No -

      startDate

      -

      Yes

      -

      Yes

      + startDate + Yes + Yes -

      location

      -

      Yes

      -

      No

      + location + Yes + No -

      geolocation.latitude

      -

      Yes

      -

      Yes

      + geolocation.latitude + Yes + Yes -

      geolocation.longitude

      -

      Yes

      -

      Yes

      + geolocation.longitude + Yes + Yes -

      organizer

      -

      Yes

      -

      No

      + organizer + Yes + No -

      visibility

      -

      Yes

      -

      No

      + visibility + Yes + No -

      status

      -

      Yes

      -

      No

      + status + Yes + No -

      priority

      -

      Yes

      -

      No

      + priority + Yes + No -

      categories

      -

      Yes

      -

      No

      + categories + Yes + No -

      dueDate

      -

      Yes

      -

      Yes

      + dueDate + Yes + Yes -

      completedDate

      -

      Yes

      -

      Yes

      + completedDate + Yes + Yes -

      progress

      -

      Yes

      -

      Yes

      + progress + Yes + Yes -

      endDate

      -

      Yes

      -

      Yes

      + endDate + Yes + Yes -

      availability

      -

      Yes

      -

      No

      + availability + Yes + No -

      lastModificationDate

      -

      Yes

      -

      Yes

      + lastModificationDate + Yes + Yes -

      alarms

      -

      No*

      -

      No

      + alarms + No* + No -

      attendees

      -

      No*

      -

      No

      + attendees + No* + No -

      recurrenceRule

      -

      No*

      -

      No

      + recurrenceRule + No* + No @@ -253,11 +249,6 @@ var event = new tizen.CalendarEvent( Table: Call History filter attributes - - - - - Attribute @@ -265,44 +256,44 @@ var event = new tizen.CalendarEvent( Attribute range filter supported -

      uid

      -

      Yes

      -

      Yes

      + uid + Yes + Yes -

      type

      -

      Yes

      -

      No

      + type + Yes + No -

      features

      -

      Yes

      -

      No

      + features + Yes + No -

      remoteParties.remoteParty

      -

      Yes

      -

      Yes

      + remoteParties.remoteParty + Yes + Yes -

      remoteParties.personId

      -

      Yes

      -

      Yes

      + remoteParties.personId + Yes + Yes -

      startTime

      -

      Yes

      -

      Yes

      + startTime + Yes + Yes -

      duration

      -

      Yes

      -

      Yes

      + duration + Yes + Yes -

      direction

      -

      Yes

      -

      No

      + direction + Yes + No @@ -312,11 +303,7 @@ var event = new tizen.CalendarEvent( Table: Contact filter attributes - - - - - + Attribute @@ -324,204 +311,204 @@ var event = new tizen.CalendarEvent( Attribute range filter supported -

      id

      -

      Yes

      -

      Yes

      + id + Yes + Yes -

      personId

      -

      Yes

      -

      Yes

      + personId + Yes + Yes -

      lastUpdated

      -

      Yes

      -

      Yes

      + lastUpdated + Yes + Yes -

      isFavorite

      -

      Yes

      -

      Yes

      + isFavorite + Yes + Yes -

      birthday

      -

      Yes

      -

      Yes

      + birthday + Yes + Yes -

      photoURI

      -

      Yes

      -

      No

      + photoURI + Yes + No -

      ringtoneURI

      -

      Yes

      -

      No

      + ringtoneURI + Yes + No -

      name.prefix

      -

      Yes

      -

      No

      + name.prefix + Yes + No -

      name.suffix

      -

      Yes

      -

      No

      + name.suffix + Yes + No -

      name.firstName

      -

      Yes

      -

      No

      + name.firstName + Yes + No -

      name.middleName

      -

      Yes

      -

      No

      + name.middleName + Yes + No -

      name.lastName

      -

      Yes

      -

      No

      + name.lastName + Yes + No -

      name.nicknames

      -

      Yes

      -

      No

      + name.nicknames + Yes + No -

      name.phoneticFirstName

      -

      Yes

      -

      No

      + name.phoneticFirstName + Yes + No -

      name.phoneticLastName

      -

      Yes

      -

      No

      + name.phoneticLastName + Yes + No -

      name.displayName

      -

      Yes

      -

      No

      + name.displayName + Yes + No -

      addresses.country

      -

      Yes

      -

      No

      + addresses.country + Yes + No -

      addresses.region

      -

      Yes

      -

      No

      + addresses.region + Yes + No -

      addresses.city

      -

      Yes

      -

      No

      + addresses.city + Yes + No -

      addresses.streetAddress

      -

      Yes

      -

      No

      + addresses.streetAddress + Yes + No -

      addresses.additionalInformation

      -

      Yes

      -

      No

      + addresses.additionalInformation + Yes + No -

      addresses.postalCode

      -

      Yes

      -

      No

      + addresses.postalCode + Yes + No -

      addresses.isDefault

      -

      Yes

      -

      No

      + addresses.isDefault + Yes + No -

      addresses.types

      -

      No

      -

      No

      + addresses.types + No + No -

      phoneNumbers.number

      -

      Yes

      -

      No

      + phoneNumbers.number + Yes + No -

      phoneNumbers.isDefault

      -

      Yes

      -

      No

      + phoneNumbers.isDefault + Yes + No -

      phoneNumbers.types

      -

      No

      -

      No

      + phoneNumbers.types + No + No -

      emails.email

      -

      Yes

      -

      No

      + emails.email + Yes + No -

      emails.isDefault

      -

      Yes

      -

      No

      + emails.isDefault + Yes + No -

      emails.types

      -

      No

      -

      No

      + emails.types + No + No -

      anniversaries.date

      -

      Yes

      -

      Yes

      + anniversaries.date + Yes + Yes -

      anniversaries.label

      -

      Yes

      -

      No

      + anniversaries.label + Yes + No -

      organizations.name

      -

      Yes

      -

      No

      + organizations.name + Yes + No -

      organizations.department

      -

      Yes

      -

      No

      + organizations.department + Yes + No -

      organizations.title

      -

      Yes

      -

      No

      + organizations.title + Yes + No -

      organizations.role

      -

      Yes

      -

      No

      + organizations.role + Yes + No -

      organizations.logoUri

      -

      Yes

      -

      No

      + organizations.logoUri + Yes + No -

      urls.url

      -

      Yes

      -

      No

      + urls.url + Yes + No -

      urls.type

      -

      No

      -

      No

      + urls.type + No + No -

      groupIds

      -

      Yes

      -

      Yes

      + groupIds + Yes + Yes @@ -530,11 +517,7 @@ var event = new tizen.CalendarEvent( Table: Person filter attributes - - - - - + Attribute @@ -542,49 +525,49 @@ var event = new tizen.CalendarEvent( Attribute range filter supported -

      id

      -

      Yes

      -

      No

      + id + Yes + No -

      displayName

      -

      Yes

      -

      No

      + displayName + Yes + No -

      contactCount

      -

      Yes

      -

      Yes

      + contactCount + Yes + Yes -

      hasPhoneNumber

      -

      Yes

      -

      No

      + hasPhoneNumber + Yes + No -

      hasEmail

      -

      Yes

      -

      No

      + hasEmail + Yes + No -

      isFavorite

      -

      Yes

      -

      No

      + isFavorite + Yes + No -

      photoURI

      -

      Yes

      -

      No

      + photoURI + Yes + No -

      ringtoneURI

      -

      Yes

      -

      No

      + ringtoneURI + Yes + No -

      displayContactId

      -

      Yes

      -

      No

      + displayContactId + Yes + No @@ -594,11 +577,7 @@ var event = new tizen.CalendarEvent( Table: Content filter attributes - - - - - + Attribute @@ -606,124 +585,124 @@ var event = new tizen.CalendarEvent( Attribute range filter supported -

      id

      -

      Yes

      -

      No

      + id + Yes + No -

      type

      -

      Yes

      -

      No

      + type + Yes + No -

      mimeType

      -

      No

      -

      No

      + mimeType + No + No -

      name

      -

      Yes

      -

      No

      + name + Yes + No -

      title

      -

      Yes

      -

      No

      + title + Yes + No -

      contentURI

      -

      Yes

      -

      No

      + contentURI + Yes + No -

      thumbnailURIs

      -

      Yes

      -

      No

      + thumbnailURIs + Yes + No -

      releaseDate

      -

      Yes

      -

      Yes

      + releaseDate + Yes + Yes -

      modifedDate

      -

      Yes

      -

      Yes

      + modifedDate + Yes + Yes -

      size

      -

      No

      -

      No

      + size + No + No -

      description

      -

      Yes

      -

      No

      + description + Yes + No -

      rating

      -

      Yes

      -

      Yes

      + rating + Yes + Yes -

      geolocation.latitude

      -

      Yes

      -

      Yes

      + geolocation.latitude + Yes + Yes -

      geolocation.longitude

      -

      Yes

      -

      Yes

      + geolocation.longitude + Yes + Yes -

      album

      -

      Yes

      -

      No

      + album + Yes + No -

      genres

      -

      Yes

      -

      No

      + genres + Yes + No -

      artists

      -

      Yes

      -

      No

      + artists + Yes + No -

      composers

      -

      No

      -

      No

      + composers + No + No -

      lyrics

      -

      No

      -

      No

      + lyrics + No + No -

      copyright

      -

      No

      -

      No

      + copyright + No + No -

      bitrate

      -

      No

      -

      No

      + bitrate + No + No -

      trackNumber

      -

      No

      -

      No

      + trackNumber + No + No -

      duration

      -

      No

      -

      No

      + duration + No + No -

      orientation

      -

      No

      -

      No

      + orientation + No + No @@ -734,11 +713,6 @@ var event = new tizen.CalendarEvent( Table: Filter attributes for finding messages - - - - - Attribute @@ -746,94 +720,94 @@ var event = new tizen.CalendarEvent( Attribute range filter supported -

      id

      -

      Yes

      -

      No

      + id + Yes + No -

      serviceId

      -

      Yes

      -

      No

      + serviceId + Yes + No -

      conversationId

      -

      No

      -

      No

      + conversationId + No + No -

      folderId

      -

      Yes

      -

      No

      + folderId + Yes + No -

      type

      -

      Yes

      -

      No

      + type + Yes + No -

      timestamp

      -

      No

      -

      Yes

      + timestamp + No + Yes -

      from

      -

      Yes

      -

      No

      + from + Yes + No -

      to

      -

      Yes

      -

      No

      + to + Yes + No -

      cc

      -

      Yes

      -

      No

      + cc + Yes + No -

      bcc

      -

      Yes

      -

      No

      + bcc + Yes + No -

      body.plainBody

      -

      Yes

      -

      No

      + body.plainBody + Yes + No -

      isRead

      -

      Yes

      -

      No

      + isRead + Yes + No -

      hasAttachment

      -

      Yes

      -

      No

      + hasAttachment + Yes + No -

      isHighPriority

      -

      Yes

      -

      No

      + isHighPriority + Yes + No -

      subject

      -

      Yes

      -

      No

      + subject + Yes + No -

      isResponseTo

      -

      No

      -

      No

      + isResponseTo + No + No -

      messageStatus

      -

      No

      -

      No

      + messageStatus + No + No -

      attachments

      -

      No

      -

      No

      + attachments + No + No @@ -842,11 +816,7 @@ var event = new tizen.CalendarEvent( Table: Filter attributes for finding conversations - - - - - + Attribute @@ -854,69 +824,69 @@ var event = new tizen.CalendarEvent( Attribute range filter supported -

      id

      -

      Yes

      -

      No

      + id + Yes + No -

      type

      -

      Yes

      -

      No

      + type + Yes + No -

      timestamp

      -

      No

      -

      Yes

      + timestamp + No + Yes -

      messageCount

      -

      Yes

      -

      No

      + messageCount + Yes + No -

      unreadMessages

      -

      Yes

      -

      No

      + unreadMessages + Yes + No -

      preview

      -

      Yes

      -

      No

      + preview + Yes + No -

      subject

      -

      No

      -

      No

      + subject + No + No -

      isRead

      -

      No

      -

      No

      + isRead + No + No -

      from

      -

      Yes

      -

      No

      + from + Yes + No -

      to

      -

      Yes

      -

      No

      + to + Yes + No -

      cc

      -

      No

      -

      No

      + cc + No + No -

      bcc

      -

      No

      -

      No

      + bcc + No + No -

      lastMessageId

      -

      No

      -

      No

      + lastMessageId + No + No @@ -925,11 +895,6 @@ var event = new tizen.CalendarEvent( Table: Filter attributes for finding message folders - - - - - Attribute @@ -937,44 +902,44 @@ var event = new tizen.CalendarEvent( Attribute range filter supported -

      id

      -

      No

      -

      No

      + id + No + No -

      parentId

      -

      No

      -

      No

      + parentId + No + No -

      serviceId

      -

      Yes

      -

      No

      + serviceId + Yes + No -

      contentType

      -

      No

      -

      No

      + contentType + No + No -

      name

      -

      No

      -

      No

      + name + No + No -

      path

      -

      No

      -

      No

      + path + No + No -

      type

      -

      No

      -

      No

      + type + No + No -

      synchronizable

      -

      No

      -

      No

      + synchronizable + No + No @@ -1013,4 +978,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/web/tizen/content/content_guide_w.htm b/org.tizen.guides/html/web/tizen/content/content_guide_w.htm index 6d3b435..85cccf1 100644 --- a/org.tizen.guides/html/web/tizen/content/content_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/content/content_guide_w.htm @@ -36,7 +36,7 @@

      The main content features are:

      • Content

        Allows you to search and manage multimedia content locally.

      • -
      • Download

        Enables you to download files from the Internet and monitor the download progress and status.

      • +
      • Download

        Enables you to download files from the Internet and monitor the download progress and status.

      diff --git a/org.tizen.guides/html/web/tizen/content/content_w.htm b/org.tizen.guides/html/web/tizen/content/content_w.htm index 5463eec..c5d42a8 100644 --- a/org.tizen.guides/html/web/tizen/content/content_w.htm +++ b/org.tizen.guides/html/web/tizen/content/content_w.htm @@ -75,7 +75,9 @@
  • - + +

    Before you start, remember to prepare your application to use the content functionality.

    +
    @@ -98,4 +100,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/web/tizen/content/download_w.htm b/org.tizen.guides/html/web/tizen/content/download_w.htm index 4f864fe..c9277dd 100644 --- a/org.tizen.guides/html/web/tizen/content/download_w.htm +++ b/org.tizen.guides/html/web/tizen/content/download_w.htm @@ -42,7 +42,9 @@
  • Managing downloads

    You can start, pause, resume, and cancel a download of content using the DownloadManager interface (in mobile and wearable applications).

  • Checking the download state and information

    You can access the current download state and retrieve the download information using the DownloadManager interface. The states are defined in the DownloadState enumerator (in mobile and wearable applications).

  • - + +

    Before you start, remember to prepare your application to use the download functionality.

    +
    diff --git a/org.tizen.guides/html/web/tizen/guides_tizen_w.htm b/org.tizen.guides/html/web/tizen/guides_tizen_w.htm index 2a3629c..4d18ea5 100644 --- a/org.tizen.guides/html/web/tizen/guides_tizen_w.htm +++ b/org.tizen.guides/html/web/tizen/guides_tizen_w.htm @@ -39,23 +39,26 @@

    The following guides describe features provided by the Tizen Web Device API:

    • Base -

      Enables you to handle generic events and sort and filter data.

    • -
    • Account -

      Enables you to manage Accounts and Account Information.

    • +

      Enables you to manage the common files and zip archive files, handle events, and organize data.

      +
    • Application Framework -

      Enables you to configure application properties, and manage application data, packages, and alarms, and launch applications.

    • +

      Enables you to manage various types of applications and packages, badges, notifications, input devices, and events, and communicate with other Web or native applications.

    • Content

      Enables you to manage files, playlists, and downloads, and view file details.

    • Messaging -

      Enables you to manage and receive SMS, MMS, and Email Messages.

    • +

      Enables you to manage and receive SMS, MMS, and email messages, and handle push notifications.

    • Multimedia -

      Enables you to manage the device sound levels and media keys.

    • +

      Enables you to manage the EXIF information, device sound levels, FM radio, and media controller.

    • Network

      Enables you to send data to networks and other applications, and receive data back from them.

    • -
    • Social in mobile applications only -

      Enables you to manage the user's personal data, such as contacts, calendars, and call and browsing history, on the device.

    • +
    • Security +

      Enables you to store and recall data in a secure manner.

    • System -

      Enables you to access and manage and retrieve information from the device and its sensors.

    • +

      Enables you to access, manage, and retrieve information from the device and its sensors.

      +
    • Account in mobile applications only +

      Enables you to manage accounts and account information.

    • +
    • Social in mobile applications only +

      Enables you to manage the user's personal data, such as contacts, calendars, and call and browsing history, on the device.

    diff --git a/org.tizen.guides/html/web/tizen/ime/ime_w.htm b/org.tizen.guides/html/web/tizen/ime/ime_w.htm index d844efa..38685eb 100644 --- a/org.tizen.guides/html/web/tizen/ime/ime_w.htm +++ b/org.tizen.guides/html/web/tizen/ime/ime_w.htm @@ -403,7 +403,7 @@ Keycode:
    <tizen:uuid>6153122a-a429-40d2-ef21-a75f468c202c</tizen:uuid>
  • - tizen:languages + tizen:languages

    The locale string in the <tizen:language> element can be used to display the input language the specific Input Method Editor supports. The <tizen:languages> parent element can have more than 1 <tizen:language> child element.

    @@ -420,8 +420,8 @@ Keycode:
          Note 
          
          
    -     Two-letter primary codes are reserved for [ISO639] language abbreviations. Two-letter codes include fr (French), de (German), it (Italian), nl (Dutch), el (Greek), es (Spanish), pt (Portuguese), ar (Arabic), he (Hebrew), ru (Russian), zh (Chinese), ja (Japanese), hi (Hindi), ur (Urdu), and sa (Sanskrit).
    -

    Any two-letter subcode is understood to be a [ISO3166] country code. For more information, see http://www.w3.org/TR/html401/struct/dirlang.html.

    + 2-letter primary codes are reserved for [ISO639] language abbreviations. 2-letter codes include fr (French), de (German), it (Italian), nl (Dutch), el (Greek), es (Spanish), pt (Portuguese), ar (Arabic), he (Hebrew), ru (Russian), zh (Chinese), ja (Japanese), hi (Hindi), ur (Urdu), and sa (Sanskrit). +

    Any 2-letter subcode is understood to be a [ISO3166] country code. For more information, see http://www.w3.org/TR/html401/struct/dirlang.html.

    diff --git a/org.tizen.guides/html/web/tizen/localization/localization_w.htm b/org.tizen.guides/html/web/tizen/localization/localization_w.htm index ddb1f34..7ce32d1 100644 --- a/org.tizen.guides/html/web/tizen/localization/localization_w.htm +++ b/org.tizen.guides/html/web/tizen/localization/localization_w.htm @@ -60,7 +60,7 @@ LANG_JSON_DATA=
  • Load language resources.

    To load language resources, add the <script> element containing the language resource file in your index.html file:

    -
    <script src="language.js"></script>
    +
    <script src="language.js"></script>

    The Web Runtime loads the language.js file for the current locale and you can use the defined string element to display localized content. For example:

    log("hello="+LANG_JSON_DATA["hello"]);
    diff --git a/org.tizen.guides/html/web/tizen/messaging/messaging_guide_w.htm b/org.tizen.guides/html/web/tizen/messaging/messaging_guide_w.htm index 3d56229..d48f34f 100644 --- a/org.tizen.guides/html/web/tizen/messaging/messaging_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/messaging/messaging_guide_w.htm @@ -32,15 +32,16 @@

    Messaging

    -

    Messaging features include managing messaging functionalities for SMS, MMS, email and receive push notifications from a push server.

    +

    Messaging features include managing messaging functionalities for SMS, MMS, and email, and receiving push notifications from a push server.

    The main messaging features are:

      -
    • Push

      Allows you to receive push notifications from a push server.

    • +
    • Push

      Allows you to receive push notifications from a push server.

    -

    The following guides apply in mobile applications only:

    +

    The following guides apply in mobile applications only:

      -
    • Messaging

      Allows you to create applications with messaging functionalities using SMS, MMS, and email.

    • +
    • Messaging +

      Allows you to create applications with messaging functionalities using SMS, MMS, and email.

    diff --git a/org.tizen.guides/html/web/tizen/messaging/messaging_w.htm b/org.tizen.guides/html/web/tizen/messaging/messaging_w.htm index febb488..646bbcc 100644 --- a/org.tizen.guides/html/web/tizen/messaging/messaging_w.htm +++ b/org.tizen.guides/html/web/tizen/messaging/messaging_w.htm @@ -37,6 +37,7 @@

    The messaging process used in HTML5 involves Uniform Resource Identifiers (URIs), which form values of attributes, such as tel, mailto, and sms. These attributes invoke external services which then perform the messaging tasks. The Messaging API minimizes your coding efforts by providing one-step capabilities to perform all high-level messaging-related operations.

    +

    Before you start, remember to prepare your application to use the messaging functionality.

    The main features of the Messaging API include:

    @@ -34,13 +34,14 @@

    Tizen provides a functionality for you to communicate between the media controller server and client.

    -

    This feature is supported in mobile applications only.

    - - +

    The Media Controller API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable applications. All mandatory APIs are supported on the Tizen Emulators.

    +

    To manage the media using the Media Controller API, you have to develop 2 applications:

    • Client that sends requests to the server in order to change, for example, the playback state and position modes.
    • Server that directly manages the media on the device.
    +

    Before you start, remember to prepare your application to use the media controller functionality.

    +

    The main features of the Media Controller API include:

    • Setting up the client and server pair diff --git a/org.tizen.guides/html/web/tizen/multimedia/multimedia_guide_w.htm b/org.tizen.guides/html/web/tizen/multimedia/multimedia_guide_w.htm index 16bd833..0d46b92 100644 --- a/org.tizen.guides/html/web/tizen/multimedia/multimedia_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/multimedia/multimedia_guide_w.htm @@ -35,15 +35,15 @@

      The main multimedia features are:

      • Exif

        Enables you to access and modify EXIF information in a JPEG file.

      • -
      • Media Controller

        Enables you to communicate between the media controller server and client.

      • +
      • Media Controller

        Enables you to communicate between the media controller server and client.

      • Sound

        Enables you to control the volume level of several sound types and get information about the current sound mode and the state of the current sound devices.

      -

      The following guides apply in mobile applications only:

      +

      The following guides apply in mobile applications only:

        -
      • FM Radio

        Enables you to access and control the device FM radio.

      • -
      - +
    • FM Radio +

      Enables you to access and control the device FM radio.

    • +
    diff --git a/org.tizen.guides/html/web/tizen/multimedia/sound_w.htm b/org.tizen.guides/html/web/tizen/multimedia/sound_w.htm index 2dcfecc..0667145 100644 --- a/org.tizen.guides/html/web/tizen/multimedia/sound_w.htm +++ b/org.tizen.guides/html/web/tizen/multimedia/sound_w.htm @@ -44,7 +44,9 @@
  • Monitoring changes in the volume level and sound mode

    You can monitor changes in the volume level and sound mode by registering appropriate listeners.

  • Monitoring changes in the sound device state

    You can monitor changes in the state of sound devices with the addDeviceStateChangeListener() method.

  • - + +

    Before you start, remember to prepare your application to use the sound functionality.

    +
    diff --git a/org.tizen.guides/html/web/tizen/network/bluetooth_w.htm b/org.tizen.guides/html/web/tizen/network/bluetooth_w.htm index aff150e..c5bc8e9 100644 --- a/org.tizen.guides/html/web/tizen/network/bluetooth_w.htm +++ b/org.tizen.guides/html/web/tizen/network/bluetooth_w.htm @@ -35,6 +35,8 @@

    You can use Bluetooth functionalities in your application, such as managing the local Bluetooth adapter, bonding, and exchanging data between Bluetooth-enabled devices. The Bluetooth standard provides a peer-to-peer (P2P) data exchange functionality over short distance between compliant devices.

    The Bluetooth API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The Bluetooth API is not supported on any Tizen Emulators.

    + +

    Before you start, remember to prepare your application to use the Bluetooth functionality.

    The main features of the Bluetooth API include:

      diff --git a/org.tizen.guides/html/web/tizen/network/network_guide_w.htm b/org.tizen.guides/html/web/tizen/network/network_guide_w.htm index 5c7ae92..0d48507 100644 --- a/org.tizen.guides/html/web/tizen/network/network_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/network/network_guide_w.htm @@ -40,6 +40,7 @@
    • Secure Element

      Allows you to access secure elements, such as SIM card and secure SD card, in a device.

    + diff --git a/org.tizen.guides/html/web/tizen/network/nfc_w.htm b/org.tizen.guides/html/web/tizen/network/nfc_w.htm index 491244d..20af8f0 100644 --- a/org.tizen.guides/html/web/tizen/network/nfc_w.htm +++ b/org.tizen.guides/html/web/tizen/network/nfc_w.htm @@ -35,7 +35,7 @@

    Near Field Communication (NFC) service enables information exchange between NFC-enabled devices (called "peers") or tags. The NFC-enabled devices can share contacts, photos, and videos, and can also act as smart cards. You can use an NFC-enabled device to communicate with NFC tags for a variety of activities, such as paying the grocery bill or downloading a coupon.

    -

    The NFC API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The NFC API is not supported on any Tizen Emulators.

    +

    The NFC API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The NFC API is supported on the Tizen wearable Emulator, but not on the Tizen mobile Emulator.

    NFC provides the following advantages over short-range communication technologies, such as Bluetooth:

      @@ -56,7 +56,9 @@

      The NFC forum defines the NFC data exchange format (NDEF) for encapsulating the data exchanged between 2 NFC-enabled devices or an NFC-enabled device and an NFC tag. An NDEF message can store data in various formats, such as text, Multipurpose Internet Mail Extension (MIME) type object, or ultra-short RagTime Document (RTD). The NFC tags use NDEF for exchanging messages.

      -

      + +

      Before you start, remember to prepare your application to use the NFC functionality.

      +

      The main features of the NFC API include:

      • NFC device management

        You can manage NFC connectivity by enabling or disabling the NFC service.

        To use NFC, retrieve the default NFC adapter using the getDefaultAdapter() method of the NFCAdapter interface (in mobile and wearable applications). You can enable and disable NFC using the setPowered() method.

      • diff --git a/org.tizen.guides/html/web/tizen/network/secure_element_w.htm b/org.tizen.guides/html/web/tizen/network/secure_element_w.htm index ea8313c..459f1bd 100644 --- a/org.tizen.guides/html/web/tizen/network/secure_element_w.htm +++ b/org.tizen.guides/html/web/tizen/network/secure_element_w.htm @@ -43,7 +43,7 @@
      • Transmitting APDUs to the applet

        You can transmit application protocol data units (APDU) to a secure element using a channel.

      - +

      Before you start, remember to prepare your application to use the secure element functionality.

      diff --git a/org.tizen.guides/html/web/tizen/security/keymanager_w.htm b/org.tizen.guides/html/web/tizen/security/keymanager_w.htm index 40deda3..247935f 100644 --- a/org.tizen.guides/html/web/tizen/security/keymanager_w.htm +++ b/org.tizen.guides/html/web/tizen/security/keymanager_w.htm @@ -22,16 +22,19 @@

    Key Manager

    -

    The key manager provides functions to securely store keys, certificates, and sensitive data related to users and their password-protected APPs. Additionally, it provides secure cryptographic operations for non-exportable keys without revealing the key values to clients.

    +

    The key manager provides functions to securely store keys, certificates, and sensitive data related to users and their password-protected applications. Additionally, it provides secure cryptographic operations for non-exportable keys without revealing the key values to clients.

    +

    The Key Manager API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable devices. All mandatory APIs are supported on the Tizen Emulators.

    A key manager stores keys, certificates, and sensitive user data in a central secure repository. The central secure repository is protected by a password.

    @@ -57,16 +60,16 @@

    The user login control is implemented as follows:

      -
    • A user's database file is encrypted by the user's DKEK (domain key encryption key). A DKEK of a user is randomly generated and stored as encrypted with a user password when a user logs in for the first time.
    • +
    • A user's database file is encrypted by the user's DKEK (domain key encryption key). The user DKEK is randomly generated and stored encrypted with a user password when a user logs in for the first time.
    • When a user logs in, the key manager decrypts the user DKEK with a user password. During the login session, any client can access the data which is protected by a user password. When a user logs out, the key manager removes the user DKEK from the memory.
    • -
    • When a user logs in, logs out, or changes their password, the key manager must be notified. Only privileged APPs, such as LockScreen APP or Setting APP, can notify the key manager.
    • +
    • When a user logs in, logs out, or changes their password, the key manager must be notified. Only privileged applications, such as LockScreen or Setting, can notify the key manager.
    • When a user changes their password, the key manager re-encrypts the user DKEK with the new password.
  • Data access control -

    By default, only the owner of a data can access to the data. If the owner grants the access to other applications, those applications can read or delete the data from the key manager database.

    +

    By default, only the data owner can access the data. If the owner grants access to other applications, those applications can read or delete the data from the key manager database.

    When an application is deleted, the data and access control information granted by the application are also removed.

  • @@ -74,13 +77,11 @@

    Figure: Key manager process

    Key manager process

    -

    The key manager provides API for:

    -
      -
    • Secure repository APIs

      All APPs can use the secure repository APIs to:

      +

      The key manager provides secure repository APIs. All applications can use the secure repository APIs to:

    • -
    +
  • Save, get, or remove data
  • + +
    diff --git a/org.tizen.guides/html/web/tizen/security/security_guide_w.htm b/org.tizen.guides/html/web/tizen/security/security_guide_w.htm index 1152096..0ff1f0c 100644 --- a/org.tizen.guides/html/web/tizen/security/security_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/security/security_guide_w.htm @@ -23,17 +23,19 @@

    Related Info

    Security

    -

    Security features include information on how your application can store and recall data in secured manner.

    +

    Security features include storing and recalling data in a secure manner in your application.

    The main security features are:

      -
    • Key Manager

      Allows you to use Security functionalities, such as storing and recalling private data.Key Manager

      Allows you to use security functionalities, such as storing and recalling private data.

    diff --git a/org.tizen.guides/html/web/tizen/service/service_w.htm b/org.tizen.guides/html/web/tizen/service/service_w.htm index 1559bb1..dbf89a0 100644 --- a/org.tizen.guides/html/web/tizen/service/service_w.htm +++ b/org.tizen.guides/html/web/tizen/service/service_w.htm @@ -42,7 +42,7 @@

    A service application is a type of Tizen Web application that provides an environment for running JavaScript in the background without a graphical user interface (the application follows the ECMA-262 specification). The service application is used to perform tasks which need to run periodically or continuously but do not require user interaction. For example, a service application can be used for getting data or listening to platform events in the background. As service applications do not have UI components, they run on top of a more light-weight runtime than UI applications. Therefore, you can expect them to perform better and consume less memory.

    -

    Service applications are packaged with a UI application. They can be launched by another application through the launch() and launchAppControl() functions of the Application API by using an explicit application ID. You can also register them to be launched automatically at boot time.

    +

    Service applications are packaged with a UI application. They can be launched by another application through the launch() and launchAppControl() methods of the Application API by using an explicit application ID. You can also register them to be launched automatically at boot time.

    The device main menu does not contain any icons for service applications, because the applications run in the background. The task switcher does not show them either. Service applications can run simultaneously with other service and UI applications.

    @@ -56,6 +56,7 @@
    +

    Before you start, remember to prepare your application to use the service functionality.

    Fundamentals

    @@ -74,29 +75,29 @@ Alarm - This API provides functions for setting and unsetting alarms. + This API provides methods for setting and unsetting alarms. Application This API provides information about the currently running and installed applications and ways to launch other applications. -

    Note that the getRequestedAppControl() function is only valid inside the onRequest() callback.

    +

    Note that the getRequestedAppControl() method is only valid inside the onRequest() callback.

    Package - This API provides functions to install and uninstall Tizen packages and to get information about installed packages. + This API provides methods to install and uninstall Tizen packages and to get information about installed packages. Filesystem - This API provides functions to access the file system of a device and to read, write, copy, move, and delete files. + This API provides methods to access the file system of a device and to read, write, copy, move, and delete files. Message Port - This API provides functions for an application to communicate with other applications. + This API provides methods for an application to communicate with other applications. Power This API provides interfaces and methods for controlling power resources. -

    Note that the isScreenOn(), restoreScreenBrightness(), turnScreenOn(), turnScreenOff(), setScreenBrightness(), and getScreenBrightness() functions are not supported for wearable Web service applications.

    +

    Note that the isScreenOn(), restoreScreenBrightness(), turnScreenOn(), turnScreenOff(), setScreenBrightness(), and getScreenBrightness() methods are not supported for wearable Web service applications.

    System Information @@ -106,7 +107,7 @@

    Life-cycle

    -

    To make sure that you can run a service application, export a number of functions using the CommonJS Modules API. The functions need to be added to the module.exports object which is provided by the environment. These functions are called when there are life-cycle changes or application control events which are triggered by the application management framework.

    +

    To make sure that you can run a service application, export a number of methods using the CommonJS Modules API. The methods need to be added to the module.exports object which is provided by the environment. These methods are called when there are life-cycle changes or application control events which are triggered by the application management framework.

    Figure: State transitions

    State transitions

    @@ -114,7 +115,7 @@
    • onStart(): The entry point of the service. It is called after the service runtime finishes the set-up.
    • -
    • onRequest(): The listener for application control callbacks. It is provided to handle requests from other applications. You can understand the intention of the request and reply to it using the tizen.application.getCurrentApplication().getRequestedAppControl() function. This callback is also called when the application is first launched as an application launch is considered to be a request as well.
    • +
    • onRequest(): The listener for application control callbacks. It is provided to handle requests from other applications. You can understand the intention of the request and reply to it using the tizen.application.getCurrentApplication().getRequestedAppControl() method. This callback is also called when the application is first launched as an application launch is considered to be a request as well.
    • onExit(): This is called when the service ends. You can release resources or save the context by using this callback.

    Package Management

    diff --git a/org.tizen.guides/html/web/tizen/social/bookmark_w.htm b/org.tizen.guides/html/web/tizen/social/bookmark_w.htm index 5c6da32..f9bd88f 100644 --- a/org.tizen.guides/html/web/tizen/social/bookmark_w.htm +++ b/org.tizen.guides/html/web/tizen/social/bookmark_w.htm @@ -44,6 +44,8 @@
  • Managing bookmarks

    You can retrieve a list of current bookmarks of the Tizen Web browser using the BookmarkManager interface. You can also delete bookmark folders and items.

  • +

    Before you start, remember to prepare your application to use the bookmark functionality.

    +
    diff --git a/org.tizen.guides/html/web/tizen/social/calendar_w.htm b/org.tizen.guides/html/web/tizen/social/calendar_w.htm index 11108d3..80badc0 100644 --- a/org.tizen.guides/html/web/tizen/social/calendar_w.htm +++ b/org.tizen.guides/html/web/tizen/social/calendar_w.htm @@ -51,6 +51,9 @@

    The events and tasks are identified using the CalendarItemId typedef, which is either a CalendarTaskId (for tasks) or CalendarEventId (for events). In recurring events, the CalendarEventId contains a recurrence ID (rid) in addition to the actual event ID, to separately identify each occurrence of the recurring event.

    The Calendar API uses the TZDate object of the Time API and not the standard JavaScript Date object to handle difficult issues related to the time zone, because the TZDate object handles exact time and provides various utility methods.

    + +

    Before you start, remember to prepare your application to use the calendar functionality.

    +

    The main features of the Calendar API include:

      @@ -83,7 +86,7 @@
    • Calendar change notifications

      You can keep the calendar in your application synchronized with user-specific calendars, such as a calendar on a social networking Web site, by receiving notifications in your application when calendar items change.

      The addChangeListener() method of the Calendar interface registers an event listener, which starts asynchronously once the addChangeListener() method returns the subscription identifier for the listener. You can use the CalendarChangeCallback interface to define listener event handlers for receiving the notifications.

      Every change made to the calendar database triggers an event for which you can define a notification. For batch mode operations, each operation generates only a single event. A recurring calendar event is treated as one event.

    • -
    • iCalendar 2.0 format conversions

      You can convert a calendar event or task to the iCalendar format or back using the CalendarEvent or CalendarTask object constructor and the convertToString() method of the CalendarItem interface, respectively.

      The conversion allows you to exchange calendar data between applications by sharing files with the .ics extension. The iCalendar format is independent of the underlying transport protocol, meaning that calendar items can be exchanged using a variety of transports, including HTTP, SMTP, and Infrared.

      The iCalendar format can be used to store calendar item information and exchange calendar data over the internet.

      The following example shows a sample event and task in the iCalendar format:

      +
    • iCalendar 2.0 format conversions

      You can convert a calendar event or task to the iCalendar format or back using the CalendarEvent or CalendarTask object constructor and the convertToString() method of the CalendarItem interface, respectively.

      The conversion allows you to exchange calendar data between applications by sharing files with the .ics extension. The iCalendar format is independent of the underlying transport protocol, meaning that calendar items can be exchanged using a variety of transports, including HTTP, SMTP, and Infrared.

      The iCalendar format can be used to store calendar item information and exchange calendar data over the Internet.

      The following example shows a sample event and task in the iCalendar format:

       /* Event */
       BEGIN:VCALENDAR
      @@ -128,4 +131,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga
       
       
       
      -
      +
      \ No newline at end of file
      diff --git a/org.tizen.guides/html/web/tizen/social/call_history_w.htm b/org.tizen.guides/html/web/tizen/social/call_history_w.htm
      index e8b8c21..77eea67 100644
      --- a/org.tizen.guides/html/web/tizen/social/call_history_w.htm
      +++ b/org.tizen.guides/html/web/tizen/social/call_history_w.htm
      @@ -45,6 +45,8 @@
          
    • Change tracking

      You can register event listeners to monitor changes in the call history using the CallHistoryChangeCallback listener interface.

    +

    Before you start, remember to prepare your application to use the call history functionality.

    + @@ -66,4 +68,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/web/tizen/social/contact_w.htm b/org.tizen.guides/html/web/tizen/social/contact_w.htm index 79df2e6..4b56b5e 100644 --- a/org.tizen.guides/html/web/tizen/social/contact_w.htm +++ b/org.tizen.guides/html/web/tizen/social/contact_w.htm @@ -38,6 +38,8 @@

    This feature is supported in mobile applications only.

    +

    Before you start, remember to prepare your application to use the contact functionality.

    +

    The main features of the Contact API include:

    • Address book management @@ -93,4 +95,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/web/tizen/social/data_sync_w.htm b/org.tizen.guides/html/web/tizen/social/data_sync_w.htm index 21470c4..e0d02c1 100644 --- a/org.tizen.guides/html/web/tizen/social/data_sync_w.htm +++ b/org.tizen.guides/html/web/tizen/social/data_sync_w.htm @@ -45,6 +45,8 @@
    • Retrieving synchronization process information

      After starting the synchronization process using the startSync() method of the DataSynchronizationManager interface, you can monitor the progress of the operation. Use the SyncProgressCallback interface to define listeners for receiving notifications. After the synchronization is completed, you can retrieve statistics using the getLastSyncStatistics() method.

    +

    Before you start, remember to prepare your application to use the data synchronization functionality.

    + diff --git a/org.tizen.guides/html/web/tizen/social/social_guide_w.htm b/org.tizen.guides/html/web/tizen/social/social_guide_w.htm index 3c543a1..0d34cda 100644 --- a/org.tizen.guides/html/web/tizen/social/social_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/social/social_guide_w.htm @@ -35,9 +35,8 @@

    Social features include managing call and browsing history, bookmarks, and calendars, and synchronizing device data.

    -

    The Social API domain is supported in mobile applications only.

    +

    The following guides apply in mobile applications only:

    -

    The main social features are:

    +
    @@ -57,48 +60,49 @@ + - + + - + + - + + - + + - + - - + + + - - - + + + +
    Table: Human activity monitors and capabilities
    Monitor CapabilityNotes
    Pedometer and accumulative pedometer

    http://tizen.org/feature/sensor.pedometer

    http://tizen.org/feature/sensor.pedometerWhen the pedometer sensor is started, a change callback is invoked when data changes. Use the getHumanActivityData() method to get the current data. +

    The accumulative pedometer sensor does not have to be started by your application as long as step counting is enabled by any other application or the system. Listener registered with the setAccumulativePedometerListener() method is called when accumulative counters are changed.

    Wrist up

    http://tizen.org/feature/sensor.wrist_up

    http://tizen.org/feature/sensor.wrist_upThe wrist up sensor is notified when the relevant gesture is performed. The sensor must be enabled using the start() method. An event listener invoked when the gesture is detected. This sensor does not provide any data.
    Heart rate monitor

    http://tizen.org/feature/sensor.heart_rate_monitor

    http://tizen.org/feature/sensor.heart_rate_monitorWhen the heart rate monitor (HRM) sensor is started, a change callback is invoked when data changes. Use the getHumanActivityData() method to get the current data.
    GPS

    http://tizen.org/feature/location.batch

    http://tizen.org/feature/location.batchWhen the GPS sensor is started, a change callback is invoked when data changes. Use the getHumanActivityData() method to get the current data. +

    The GPS sensor provides both the current value and a short history of last recorded GPS positions. The sensor supports sampling intervals, which can be used to create more power-efficient applications.

    Sleep monitor

    http://tizen.org/feature/sensor.sleep_monitor

    http://tizen.org/feature/sensor.sleep_monitorWhen the sleep sensor is started, a change callback is invoked when data changes. Use the getHumanActivityData() method to get the current data.
    Activity Recognition

    http://tizen.org/feature/sensor.activity_recognition

    Activity recognitionhttp://tizen.org/feature/sensor.activity_recognitionTo recognize an activity, start listening for it using the addActivityRecognitionListener() method. The following activity types can be recognized: +
      +
    • STATIONARY
    • +
    • WALKING
    • +
    • RUNNING
    • +
    • IN_VEHICLE
    • +
    -

    When the pedometer, HRM, GPS and sleep monitor sensors are started, a change callback is invoked when data changes. Use the getHumanActivityData() method to get current data.

    -

    The GPS sensor provides both the current value and a short history of last recorded GPS positions. GPS sensor supports sampling intervals, which could be used to create more power efficient applications.

    -

    The accumulative pedometer sensor does not have to be started by your application as long as step counting is enabled by any other application or the system. Listener registered with the setAccumulativePedometerListener() method is called when accumulative counters are changed.

    -

    The wrist up sensor is notified when the relevant gesture is performed. The sensor must be enabled using the start() method. An event listener invoked when the gesture is detected. This sensor does not provide any data.

    -

    -The activity can be recognized if we start listening for it using the method addActivityRecognitionListener(). There are four activity types that can be recognized: -

      -
    • STATIONARY - The stationary activity recognition type
    • -
    • WALKING - The walking activity recognition type
    • -
    • RUNNING - The running activity recognition type
    • -
    • IN_VEHICLE - The in-vehicle activity recognition type
    • -
    -

    - @@ -121,4 +125,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/web/tizen/system/media_key_w.htm b/org.tizen.guides/html/web/tizen/system/media_key_w.htm index 988c343..c0c4c09 100644 --- a/org.tizen.guides/html/web/tizen/system/media_key_w.htm +++ b/org.tizen.guides/html/web/tizen/system/media_key_w.htm @@ -22,7 +22,7 @@

    Related Info

    @@ -36,11 +36,11 @@

    The Media Key API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The Media Key API is not supported on any Tizen Emulators.

    -

    The media keys are used to control multimedia playback. The user can click keys, such as PLAY and FAST FORWARD, and you can detect the key clicks in your application and change the playback accordingly.

    +

    The media keys are used to control multimedia playback. The user can click keys, such as PLAY and FAST FORWARD, and you can detect the key clicks in your application and change the playback accordingly.

    The main features of the Media Key API include:

      -
    • Registering a listener

      You can register and unregister a listener for the media key state changes.

      +
    • Registering a listener

      You can register and deregister a listener for the media key state changes.

      diff --git a/org.tizen.guides/html/web/tizen/system/power_w.htm b/org.tizen.guides/html/web/tizen/system/power_w.htm index 69c8f1e..0546c73 100644 --- a/org.tizen.guides/html/web/tizen/system/power_w.htm +++ b/org.tizen.guides/html/web/tizen/system/power_w.htm @@ -79,6 +79,8 @@

      The Power API allows you to get and set the screen brightness and switch the screen on and off.

      +

      Before you start, remember to prepare your application to use the power functionality.

      +
    diff --git a/org.tizen.guides/html/web/tizen/system/sensor_w.htm b/org.tizen.guides/html/web/tizen/system/sensor_w.htm index 1c4e33c..db9bdc4 100644 --- a/org.tizen.guides/html/web/tizen/system/sensor_w.htm +++ b/org.tizen.guides/html/web/tizen/system/sensor_w.htm @@ -57,27 +57,27 @@ Light sensor -

    http://tizen.org/feature/sensor.photometer

    + http://tizen.org/feature/sensor.photometer Magnetic sensor -

    http://tizen.org/feature/sensor.magnetometer

    + http://tizen.org/feature/sensor.magnetometer Pressure sensor -

    http://tizen.org/feature/sensor.barometer

    + http://tizen.org/feature/sensor.barometer Proximity sensor -

    http://tizen.org/feature/sensor.proximity

    + http://tizen.org/feature/sensor.proximity Ultraviolet sensor -

    http://tizen.org/feature/sensor.ultraviolet

    + http://tizen.org/feature/sensor.ultraviolet Heart rate monitor sensor -

    http://tizen.org/feature/sensor.heart_rate_monitor

    + http://tizen.org/feature/sensor.heart_rate_monitor diff --git a/org.tizen.guides/html/web/tizen/system/system_guide_w.htm b/org.tizen.guides/html/web/tizen/system/system_guide_w.htm index d9ee32d..75ac0ec 100644 --- a/org.tizen.guides/html/web/tizen/system/system_guide_w.htm +++ b/org.tizen.guides/html/web/tizen/system/system_guide_w.htm @@ -37,17 +37,19 @@
    • Human Activity Monitor

      Enables you to access the human activity data from various sensors on the device.

    • Media Key

      Enables you to handle media keys in your application.

    • -
    • Power

      Enables you to access the state of the device power resource.

    • +
    • Power

      Enables you to access the state of the device power resource.

    • Sensor

      Enables you to manage sensor data from various sensors on the device.

    • System Information

      Enables you to access and monitor various device details, such as battery level, available device storage, version number, model name, and the cellular network being used.

    • System Setting

      Enables you to access the device wallpaper settings, such as the home screen and lock screen wallpaper image, incoming call ringtone, and email notification tone.

    • -
    • Time

      Enables you to use locale-specific calendar features by retrieving date and time information, and manage time features, such as the time zone.

    • -
    - -

    The following guides apply in mobile applications only:

    -
      -
    • Web Setting

      Enables you to set Web view properties, such as setting Web view user agents and deleting Web view cookies.

    • -
    +
  • Time

    Enables you to use locale-specific calendar features by retrieving date and time information, and manage time features, such as the time zone.

  • + + +

    The following guides apply in mobile applications only:

    +
      +
    • Web Setting +

      Enables you to set Web view properties, such as setting Web view user agents and deleting Web view cookies.

    • +
    + diff --git a/org.tizen.guides/html/web/tizen/system/system_info_w.htm b/org.tizen.guides/html/web/tizen/system/system_info_w.htm index 5af476f..780e917 100644 --- a/org.tizen.guides/html/web/tizen/system/system_info_w.htm +++ b/org.tizen.guides/html/web/tizen/system/system_info_w.htm @@ -114,6 +114,9 @@ tr.images td {
  • Property state updates

    You can receive state updates when a change occurs in a specific property.

    The addPropertyValueChangeListener() method registers an event listener for a specific property, and returns the subscription identifier for the listener. You can use the SystemInfoPropertySuccessCallback interface (in mobile and wearable applications) to define the event handler for receiving the change notification.

  • + +

    Before you start, remember to prepare your application to use the system information functionality.

    +

    The system properties are defines as subtypes of the SystemInfoProperty interface (in mobile and wearable applications). The following table lists the available subtypes, and the related SystemInfoPropertyId type (in mobile and wearable applications) values.

    - + - + - + @@ -235,4 +238,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.guides/html/web/tizen/system/system_setting_w.htm b/org.tizen.guides/html/web/tizen/system/system_setting_w.htm index 4e4dbe2..da346f2 100644 --- a/org.tizen.guides/html/web/tizen/system/system_setting_w.htm +++ b/org.tizen.guides/html/web/tizen/system/system_setting_w.htm @@ -65,6 +65,9 @@
    @@ -170,16 +173,16 @@ tr.images td {
    CELLULAR_NETWORK Provides information about the cellular network. With this property, you can, for example, retrieve the network details that allow your application to access the network.
    SystemInfoEthernetNetwork (in mobile and wearable applications) ETHERNET_NETWORKProvides information about the ethernet network. With this property, you can, for example, retrieve the network details that allow your application to access the network.Provides information about the Ethernet network. With this property, you can, for example, retrieve the network details that allow your application to access the network.
    SystemInfoNetProxyNetwork (in mobile and wearable applications) NET_PROXY_NETWORK Provides information about the proxy type network. With this property, you can, for example, retrieve the network details that allow your application to access the network.
    SystemInfoSIM (in mobile and wearable applications) SIM
    + +

    Before you start, remember to prepare your application to use the system setting functionality.

    + diff --git a/org.tizen.guides/html/web/w3c/communication/xmlhttprequest_w.htm b/org.tizen.guides/html/web/w3c/communication/xmlhttprequest_w.htm index c942dc1..9315d1f 100644 --- a/org.tizen.guides/html/web/w3c/communication/xmlhttprequest_w.htm +++ b/org.tizen.guides/html/web/w3c/communication/xmlhttprequest_w.htm @@ -61,7 +61,7 @@
  • Supporting various response types -

    The older XMLHttpRequest API only supported the text/html format for sending requests. The XMLHttpRequest Level 2 API supports various response types, such as arraybuffer, blob, document, json, and text. +

    The older XMLHttpRequest API only supported the text/html format for sending requests. The XMLHttpRequest Level 2 API supports various response types, such as arraybuffer, blob, document, json, and text.

  • Supporting form data @@ -93,7 +93,7 @@
  • Supporting various response types -

    The older XMLHttpRequest API only supported the text/html format for sending requests. The XMLHttpRequest Level 1 API supports various response types, such as arraybuffer, blob, document, json, and text. +

    The older XMLHttpRequest API only supported the text/html format for sending requests. The XMLHttpRequest Level 1 API supports various response types, such as arraybuffer, blob, document, json, and text.

  • Supporting form data diff --git a/org.tizen.guides/html/web/w3c/device/browser_state_w.htm b/org.tizen.guides/html/web/w3c/device/browser_state_w.htm index 7aee3e6..c92f780 100644 --- a/org.tizen.guides/html/web/w3c/device/browser_state_w.htm +++ b/org.tizen.guides/html/web/w3c/device/browser_state_w.htm @@ -38,11 +38,7 @@ - - - - - + @@ -50,19 +46,19 @@ - - - + + + - - - + + + - - - + + +
    Table: Browser state attributes and events
    Attribute or eventDescription

    onLine

    readonly Boolean

    If the browser is connected to the network, this attribute returns true; otherwise false.

    onLinereadonly Boolean If the browser is connected to the network, this attribute returns true; otherwise false.

    online

    Event

    When the return value of the onLine attribute changes from false to true, a connection is established and this event is triggered.

    onlineEventWhen the return value of the onLine attribute changes from false to true, a connection is established and this event is triggered.

    offline

    Event

    When the return value of the onLine attribute changes from true to false, a connection is lost and this event is triggered.

    offlineEventWhen the return value of the onLine attribute changes from true to false, a connection is lost and this event is triggered.
    diff --git a/org.tizen.guides/html/web/w3c/device/vibration_w.htm b/org.tizen.guides/html/web/w3c/device/vibration_w.htm index d9252e9..678ce6b 100644 --- a/org.tizen.guides/html/web/w3c/device/vibration_w.htm +++ b/org.tizen.guides/html/web/w3c/device/vibration_w.htm @@ -49,12 +49,12 @@ Description -

    time

    -

    Vibration time in milliseconds.

    + time + Vibration time in milliseconds. -

    pattern

    -

    Vibration pattern represented by a list of time entries. Odd entries represent vibration time in milliseconds, and even entries still periods in milliseconds between the vibrations.

    + pattern + Vibration pattern represented by a list of time entries. Odd entries represent vibration time in milliseconds, and even entries still periods in milliseconds between the vibrations. diff --git a/org.tizen.guides/html/web/w3c/perf_opt/js_performance_improvement_w.htm b/org.tizen.guides/html/web/w3c/perf_opt/js_performance_improvement_w.htm index 1c9983b..0c75668 100644 --- a/org.tizen.guides/html/web/w3c/perf_opt/js_performance_improvement_w.htm +++ b/org.tizen.guides/html/web/w3c/perf_opt/js_performance_improvement_w.htm @@ -78,7 +78,7 @@ for (var i = 0, len = array_list.length; i < len; i++)

    Removing Slow Loop Statements

    -

    The for - in loop is relatively slower than the other loops, such as for , while, and do - while, as it assigns object properties to the variable (idx in the example below), navigating the object every time the loop is iterated. The following example shows how modifying the loop improves performance.

    +

    The for - in loop is relatively slower than the other loops, such as for, while, and do - while, as it assigns object properties to the variable (idx in the example below), navigating the object every time the loop is iterated. The following example shows how modifying the loop improves performance.

    /* Code#1 */
     var array_list = [0,1,2,3,4,5,6,7,8,9],
         new_array_list = [];
    diff --git a/org.tizen.guides/html/web/w3c/perf_opt/minify_js_css_w.htm b/org.tizen.guides/html/web/w3c/perf_opt/minify_js_css_w.htm
    index c085ede..7b79f20 100644
    --- a/org.tizen.guides/html/web/w3c/perf_opt/minify_js_css_w.htm
    +++ b/org.tizen.guides/html/web/w3c/perf_opt/minify_js_css_w.htm
    @@ -42,11 +42,8 @@
     		
     		
     			Summary
    -			
    -					

    JavaScript-optimized compiler created by Google

    - -

    Task-based automatic JavaScript build tool

    - + JavaScript-optimized compiler created by Google + Task-based automatic JavaScript build tool diff --git a/org.tizen.guides/html/web/w3c/storage/storage_guide_w.htm b/org.tizen.guides/html/web/w3c/storage/storage_guide_w.htm index 1724925..fcff434 100644 --- a/org.tizen.guides/html/web/w3c/storage/storage_guide_w.htm +++ b/org.tizen.guides/html/web/w3c/storage/storage_guide_w.htm @@ -35,7 +35,7 @@

    The main storage features are:

    • File

      Enables you to retrieve file content and information, slice data objects, and manage sandboxed file systems.

    • -
    • Indexed Database

      Enables you to create an object store, save data in it, and open.

    • +
    • Indexed Database

      Enables you to create an object store, save data in it, and open it.

    • Web Storage

      Enables you to use session storage and local storage.

    diff --git a/org.tizen.guides/html/web/w3c/supplement/typedarray_w.htm b/org.tizen.guides/html/web/w3c/supplement/typedarray_w.htm index 2b407a7..04cd382 100644 --- a/org.tizen.guides/html/web/w3c/supplement/typedarray_w.htm +++ b/org.tizen.guides/html/web/w3c/supplement/typedarray_w.htm @@ -23,7 +23,7 @@

    Related Info

    @@ -43,7 +43,7 @@
  • Raw graphic buffers
  • -

    Additionally, a typed array can be used to manage in-memory binary data of byte layouts, and assist in efficiently manipulating raw data for complex and powerful Web applications, such as audio and video operation, Web sockets, and the File API operations.

    +

    Additionally, a typed array can be used to manage in-memory binary data of byte layouts, and assist in efficiently manipulating raw data for complex and powerful Web applications, such as audio and video operation, Web sockets, and the File API operations.

    The main features of the Typed Array - Khronos API include:

  • -
  • Watch Application
  • -

    Native Application

    - - - diff --git a/org.tizen.tutorials/html/native/account/account_tutorial_n.htm b/org.tizen.tutorials/html/native/account/account_tutorial_n.htm index 5ce192d..4fec7ab 100644 --- a/org.tizen.tutorials/html/native/account/account_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/account/account_tutorial_n.htm @@ -21,6 +21,7 @@ @@ -52,7 +54,6 @@

    This tutorial demonstrates how you can create, delete, and update accounts in the account database, and manage account information, such as user name, display name, domain name, and email address.

    -

    Warm-up

    Become familiar with the Account Manager API basics by learning about:

    @@ -93,11 +94,21 @@ +

    Prerequisites

    + +

    To use the Account Manager API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

    +
    +<privileges>
    +   <privilege>http://tizen.org/privilege/account.read</privilege>
    +   <privilege>http://tizen.org/privilege/account.write</privilege>
    +</privileges>
    +
    +

    Initializing the Accounts

    To initialize the account manager:

      -
    1. To use the functions and data types of the Account Manager API, include the <account.h> header file in your application:

      +
    2. To use the functions and data types of the Account Manager API (in mobile and wearable applications), include the <account.h> header file in your application:

       #include <account.h>
       
      @@ -110,22 +121,12 @@ #include <time.h> #include <dlog.h> -// Account handle +/* Account handle */ static account_h account = NULL; static int account_id = 0; int ret = 0;
    3. - -
    4. Add the required privileges to the manifest file of your application:

      - -
        -
      • http://tizen.org/privilege/account.read: to use APIs for reading account data from the account database -
      • - -
      • http://tizen.org/privilege/account.write: to use APIs for writing account data to the account database -
      • - -
    +

    Creating and Managing an Account

    @@ -163,7 +164,7 @@ ret = account_set_icon_path(account, image_path);
  • When the account is configured, use the account_insert_to_db() function to insert the account to the account database. Use the account ID as the second parameter (account_id): -
    +
     ret = account_insert_to_db(account, &account_id);
     
  • @@ -182,7 +183,7 @@ int total_count = -1; ret = account_get_total_count_from_db(&total_count); ret = account_foreach_account_from_db(on_account_read, NULL); - +
  • Define the callback function for the account_foreach_account_from_db() function to retrieve information for each account. @@ -190,49 +191,49 @@ ret = account_foreach_account_from_db(on_account_read, NULL);

    To get more details, use the account_get_account_id(), account_get_user_name(), account_get_display_name(), and account_get_icon_path() functions:

    -static bool 
    +static bool
     on_account_read(account_h account, void *user_data)
     {
    -   char *name = NULL;
    -   char *display_name = NULL;
    -   char *icon_path = NULL;
    -   // Get the account ID
    -   ret = account_get_account_id(account, &account_id);
    -   if (ret != ACCOUNT_ERROR_NONE)
    -   {
    -      // Error handling
    -      return false;
    -   }
    -   // Get the user name
    -   ret = account_get_user_name(account, &name);
    -   if (ret != ACCOUNT_ERROR_NONE)
    -   {
    -      // Error handling
    -      return false;
    -   }
    -   dlog_print(DLOG_INFO, LOG_TAG, "name: %s", name);
    -   // Get the display name
    -   ret = account_get_display_name(account, &display_name);
    -   if (ret != ACCOUNT_ERROR_NONE)
    -   {
    -      // Error handling
    -      return false;
    -   }
    -   dlog_print(DLOG_INFO, LOG_TAG, "display_name: %s", display_name);
    -   // Get the icon path
    -   ret = account_get_icon_path(account, &icon_path);
    -   if (ret != ACCOUNT_ERROR_NONE)
    -   {
    -      // Error handling
    -      return false;
    -   }
    -   dlog_print(DLOG_INFO, LOG_TAG, "icon_path: %s", icon_path);
    -
    -   free(name);
    -   free(display_name);
    -   free(icon_path);
    -
    -   return true;
    +    char *name = NULL;
    +    char *display_name = NULL;
    +    char *icon_path = NULL;
    +    /* Get the account ID */
    +    ret = account_get_account_id(account, &account_id);
    +    if (ret != ACCOUNT_ERROR_NONE) {
    +        /* Error handling */
    +
    +        return false;
    +    }
    +    /* Get the user name */
    +    ret = account_get_user_name(account, &name);
    +    if (ret != ACCOUNT_ERROR_NONE) {
    +        /* Error handling */
    +
    +        return false;
    +    }
    +    dlog_print(DLOG_INFO, LOG_TAG, "name: %s", name);
    +    /* Get the display name */
    +    ret = account_get_display_name(account, &display_name);
    +    if (ret != ACCOUNT_ERROR_NONE) {
    +        /* Error handling */
    +
    +        return false;
    +    }
    +    dlog_print(DLOG_INFO, LOG_TAG, "display_name: %s", display_name);
    +    /* Get the icon path */
    +    ret = account_get_icon_path(account, &icon_path);
    +    if (ret != ACCOUNT_ERROR_NONE) {
    +        /* Error handling */
    +
    +        return false;
    +    }
    +    dlog_print(DLOG_INFO, LOG_TAG, "icon_path: %s", icon_path);
    +
    +    free(name);
    +    free(display_name);
    +    free(icon_path);
    +
    +    return true;
     }
     
  • @@ -243,15 +244,16 @@ on_account_read(account_h account, void *user_data)

    To retrieve accounts by a specific account provider:

    1. Define the account_cb() callback for getting account data: -
      -static bool 
      -account_callback(account_h account, void* user_data) // account_cb() callback
      +
      +static bool
      +account_callback(account_h account, void* user_data) /* account_cb() callback */
       {
      -   // Called once for each account in the database
      +    /* Called once for each account in the database */
       }
       
    2. Retrieve the accounts of a specific account provider using the account_query_account_by_package_name() function, and specifying the callback for getting account data and the package name of the account provider: -
      int ret = -1;
      +
      +int ret = -1;
       char* package_name = "package_name";
       ret = account_query_account_by_package_name(account_callback, package_name, NULL);
       
    3. @@ -263,10 +265,10 @@ ret = account_query_account_by_package_name(account_callback, package_name, NULL
      1. Define the account_type_cb() callback for getting account providers:
        -static bool 
        -account_type_callback(account_type_h account_type, void* user_data) // account_type_cb() callback
        +static bool
        +account_type_callback(account_type_h account_type, void* user_data) /* account_type_cb() callback */
         {
        -   // Called once for each account type in the database
        +    /* Called once for each account type in the database */
         }
         
      2. @@ -314,7 +316,8 @@ ret = account_destroy(account);
        1. Add the required information in the manifest file: -
          <account>
          +
          +<account>
              <account-provider appid="app-id name" providerid="url style string" multiple-accounts-support="true or false">
                 <icon section="account">application icon name</icon>
                 <icon section="account-small">application small icon name</icon>
          @@ -324,7 +327,8 @@ ret = account_destroy(account);
                 <capability>http://tizen.org/account/capability/contact</capability>
                 <capability>http://tizen.org/account/capability/calendar</capability>
              </account-provider>
          -</account>
          +</account> +

          The required information includes:

          • appid="app-id name" @@ -386,7 +390,7 @@ Create_Account(&account, "Person", "DiplayPerson", " account_set_capability(account, "Custom", ACCOUNT_CAPABILITY_ENABLED); account_set_capability(account, "Next", ACCOUNT_CAPABILITY_ENABLED); - + account_set_capability(account, "Another", ACCOUNT_CAPABILITY_DISABLED); account_insert_to_db(account, &id[0]); @@ -417,18 +421,18 @@ account_destroy(account);
          • Create an account.
            -static int 
            -Create_Account(account_h * account, char * account_name, char * display_name, char *  domain_name, char * email_address)
            +static int
            +Create_Account(account_h* account, char* account_name, char* display_name, char* domain_name, char* email_address)
             {
            -   account_create(account);
            +    account_create(account);
             
            -   account_set_user_name(*account, account_name);
            +    account_set_user_name(*account, account_name);
             
            -   account_set_display_name(*account, display_name);
            +    account_set_display_name(*account, display_name);
             
            -   account_set_domain_name(*account, domain_name);
            +    account_set_domain_name(*account, domain_name);
             
            -   account_set_email_address(*account, email_address);
            +    account_set_email_address(*account, email_address);
             }
             
        @@ -438,77 +442,70 @@ Create_Account(account_h * account, char * account_name, char * display_name, ch

        List all accounts to verify the database insertion:

        -struct 
        -Account_Records
        -{
        -   int count;
        -   int tab[100];
        +struct Account_Records {
        +    int count;
        +    int tab[100];
         };
         
         struct Account_Records rec;
        - 
        +
         List_Accounts(&rec);
         
      3. If the account list is not empty (NULL), the List_Accounts() function counts all records in the database. Obtain the records using the account_foreach_account_from_db() function.

        -static void 
        +static void
         List_Accounts(struct Account_Records* rec)
         {
        -   if (rec != NULL)
        -   {
        -      rec->count = 0;
        -   }
        -   account_foreach_account_from_db(on_account_read, rec);
        +    if (rec != NULL)
        +        rec->count = 0;
        +    account_foreach_account_from_db(on_account_read, rec);
         }
         
      4. Call the on_account_read() callback function for each found record. If the second parameter (user_data) is not NULL, the function is counting the existing accounts. String data returned by the account_get_xxx() functions must be released with the free() function. Data prepared with the sprintf() function can, for example, be sent to stdout.

        -static bool 
        +static bool
         on_account_read(account_h account, void *user_data)
         {
        -   int account_id = 0;
        -   char *name = NULL;
        -   char *display_name = NULL;
        -   struct Account_Records * rec = (struct Account_Records *)user_data;
        -   char buf[100];
        +    int account_id = 0;
        +    char *name = NULL;
        +    char *display_name = NULL;
        +    struct Account_Records * rec = (struct Account_Records *)user_data;
        +    char buf[100];
         
        -   account_get_account_id(account, &account_id);
        +    account_get_account_id(account, &account_id);
         
        -   sprintf(buf, "MyCallback ID: %d\n", account_id);
        +    sprintf(buf, "MyCallback ID: %d\n", account_id);
         
        -   if (user_data != NULL)
        -   {
        -      rec->tab[rec->count++] = account_id;
        -   }
        -   account_get_user_name(account, &name);
        -   sprintf(buf, "MyCallback Name: %s\n", name);
        +    if (user_data != NULL)
        +        rec->tab[rec->count++] = account_id;
        +    account_get_user_name(account, &name);
        +    sprintf(buf, "MyCallback Name: %s\n", name);
         
        -   free(name);
        +    free(name);
         
        -   account_get_display_name(account, &display_name);
        -   sprintf(buf, "MyCallback Disp.: %s\n", display_name);
        +    account_get_display_name(account, &display_name);
        +    sprintf(buf, "MyCallback Disp.: %s\n", display_name);
         
        -   free(display_name);
        +    free(display_name);
         
        -   return 0;
        +    return 0;
         }
         
    4. Query the account by its ID with the account_query_account_by_account_id() function. This function requires an existing handle to an account as an input parameter.
      -for (i = 0; i < rec.count; i++)
      -{
      -   account_create(&account);
      -   account_query_account_by_account_id(rec.tab[i], &account);
      +for (i = 0; i < rec.count; i++) {
      +    account_create(&account);
      +    account_query_account_by_account_id(rec.tab[i], &account);
       
      -   Show_Account(account);
      +    Show_Account(account);
       
      -   account_destroy(account);
      +    account_destroy(account);
       }
       
    5. @@ -516,31 +513,31 @@ for (i = 0; i < rec.count; i++)
    6. Show the account:
      -static int 
      +static int
       Show_Account(account_h acc)
       {
      -   int account_id = 0;
      -   char *name = NULL;
      -   char *display_name = NULL;
      -   char buf[100];
      +    int account_id = 0;
      +    char *name = NULL;
      +    char *display_name = NULL;
      +    char buf[100];
       
      -   account_get_account_id(acc, &account_id);
      +    account_get_account_id(acc, &account_id);
       
      -   sprintf(buf, "Show_Account ID: %d\n", account_id);
      +    sprintf(buf, "Show_Account ID: %d\n", account_id);
       
      -   account_get_user_name(acc, &name);
      +    account_get_user_name(acc, &name);
       
      -   sprintf(buf, "Show_Account Name: %s\n", name);
      +    sprintf(buf, "Show_Account Name: %s\n", name);
       
      -   free(name);
      +    free(name);
       
      -   account_get_display_name(acc, &display_name);
      +    account_get_display_name(acc, &display_name);
       
      -   sprintf(buf, "Show_Account Disp.: %s\n", display_name);
      +    sprintf(buf, "Show_Account Disp.: %s\n", display_name);
       
      -   free(display_name);
      +    free(display_name);
       
      -   return 0;
      +    return 0;
       }
       
    7. @@ -562,7 +559,7 @@ account_query_account_by_user_name(on_account_read, "Human", NULL);

      The package name has to be released when no longer needed.

      -char * package_name;
      +char* package_name;
       account_get_package_name(account, &package_name);
       account_query_account_by_package_name(on_account_read, package_name, NULL);
       free(package_name);
      @@ -577,7 +574,7 @@ account_query_account_by_capability(on_account_read, "Custom", ACCOUNT
       
      -
    8. Query by capability type. +
    9. Query by capability type.

      This function is similar to the account_query_account_by_capability() function, but returns all accounts with a specified capability, without checking their state.

      @@ -591,13 +588,13 @@ account_query_account_by_capability_type(on_account_read, "Next", NULL
       
       account_query_capability_by_account_id(_capability_cb, id[0], NULL);
       
      -static bool 
      +static bool
       _capability_cb(const char *capability_type, account_capability_state_e capability_state, void *user_data)
       {
      -   char buf[200];
      -   sprintf(buf, "Found capability: %s on state %d\n", capability_type, capability_state);
      +    char buf[200];
      +    sprintf(buf, "Found capability: %s on state %d\n", capability_type, capability_state);
       
      -   return true;
      +    return true;
       }
       
    10. @@ -614,18 +611,18 @@ account_destroy(account);

      To manage account secrecy:

        -
      1. Select the secrecy level using the account_secrecy_state_e enumeration: +
      2. Select the secrecy level using the account_secrecy_state_e enumeration (in mobile and wearable applications):
        -static 
        +static
         account_h account = NULL;
         account_secrecy_state_e secret;
        - 
        +
         char buf[200];
         int ret;
         int id;
         
        -// Account 1
        +/* Account 1 */
         Create_Account(&account, "Security 1", "Invalid", "NOBODY", "anony@mous.not");
         
         account_set_secret(account, ACCOUNT_SECRECY_INVALID);
        @@ -638,7 +635,7 @@ sprintf(buf, "Account 1 secret: %d\n", secret);
         
         account_destroy(account);
         
        -// Account 2
        +/* Account 2 */
         
         Create_Account(&account, "Security 2", "Invisible", " NOBODY", "anony1@mous.not");
         
        @@ -652,7 +649,7 @@ sprintf(buf, "Account 2 secret: %d\n", secret);
         
         account_destroy(account);
         
        -// Account 3
        +/* Account 3 */
         
         Create_Account(&account, "Secret 3", "Visible", " NOBODY", "anony2@mous.not");
         
        @@ -672,7 +669,7 @@ List_Accounts(NULL);
         

        Secrecy is only linked with the visibility on the account settings screen. The account is still visible and can be accessed using a query or a foreach function. For further information on how to add your application to the account screen, see Adding an Application on the Account Screen.

        -// List_Account() console output
        +/* List_Account() console output */
         MyCallback ID: 12
         MyCallback Name: Security 1
         MyCallback Disp.: Invalid
        @@ -771,14 +768,14 @@ account_destroy(account);
         
      3. Create the account event callback. When any action is taking place on any account when a notification is subscribed, a callback function is invoked. The callback function provides in its parameters the event type as a string, the ID of the account associated with the actual change, and, additionally, the user data registered while subscribing the notification.
        -bool 
        +bool
         _account_event_cb(const char *event_type, int account_id, void *user_data)
         {
        -   char buf[200];
        +    char buf[200];
         
        -   sprintf(buf, "ACCOUNT EVENT: %s, %d\n", event_type, account_id);
        +    sprintf(buf, "ACCOUNT EVENT: %s, %d\n", event_type, account_id);
         
        -   return true;
        +    return true;
         }
         
      4. @@ -830,22 +827,21 @@ account_type_create(&account_type);
         int multiple_account_support = -1;
        -char *your_app_id = "com.tizen.example"; // App ID for retrieving account types
        +char *your_app_id = "com.tizen.example"; /* App ID for retrieving account types */
         char *app_id = NULL;
         char *provider_feature = NULL;
         char *icon_path = NULL;
         
        -if (account_type_query_app_id_exist(your_app_id))
        -{
        -   account_type_query_by_app_id(your_app_id, &account_type);
        +if (account_type_query_app_id_exist(your_app_id)) {
        +    account_type_query_by_app_id(your_app_id, &account_type);
         
        -   account_type_get_app_id(account_type, &app_id);
        +    account_type_get_app_id(account_type, &app_id);
         
        -   account_type_get_multiple_account_support(account_type, &multiple_account_support);
        +    account_type_get_multiple_account_support(account_type, &multiple_account_support);
         
        -   account_type_get_icon_path(account_type, &icon_path);
        +    account_type_get_icon_path(account_type, &icon_path);
         
        -   account_type_get_provider_feature(account_type, &provider_feature);
        +    account_type_get_provider_feature(account_type, &provider_feature);
         }
         
      5. @@ -861,33 +857,33 @@ account_type_query_label_by_app_id(_account_label_cb, type_id, NULL);

        While listing the labels, the user has access to the ID of the account type, label and its local value, and the user data passed while casting the query function.

        -bool 
        +bool
         _account_label_cb(char *app_id, char *label, char *locale, void *user_data)
         {
        -   char buf[200];
        +    char buf[200];
         
        -   sprintf(buf, "Get Label ID: %s LABEL: %s LOCALE %s\n", app_id, label, locale);
        +    sprintf(buf, "Get Label ID: %s LABEL: %s LOCALE %s\n", app_id, label, locale);
         
        -   return true;
        +    return true;
         }
         

        The account type callback has access to the account type and user data.

        -bool 
        +bool
         _account_type_cb(account_type_h account_type, void *user_data)
         {
        -   char * id;
        -   int support;
        -   char buf[200];
        +    char * id;
        +    int support;
        +    char buf[200];
         
        -   account_type_get_app_id(account_type, &id);
        +    account_type_get_app_id(account_type, &id);
         
        -   account_type_get_multiple_account_support(account_type, &support);
        -   sprintf(buf, "Account Type ID: %s Multiple support %d:\n", id, support);
        +    account_type_get_multiple_account_support(account_type, &support);
        +    sprintf(buf, "Account Type ID: %s Multiple support %d:\n", id, support);
         
        -   return true;
        +    return true;
         }
         
        @@ -927,4 +923,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/account/account_tutorials_n.htm b/org.tizen.tutorials/html/native/account/account_tutorials_n.htm index ac1f740..8bfe7ef 100644 --- a/org.tizen.tutorials/html/native/account/account_tutorials_n.htm +++ b/org.tizen.tutorials/html/native/account/account_tutorials_n.htm @@ -22,7 +22,8 @@

        Related Info

        @@ -31,17 +32,16 @@

        Account: Managing Account Data

        -

        The account tutorials demonstrate how to use the following features in creating Tizen native applications.

        - +

        The account tutorials demonstrate how to use the following features in creating Tizen native applications:

        + @@ -67,4 +67,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/account/fido_client_tutorial_n.htm b/org.tizen.tutorials/html/native/account/fido_client_tutorial_n.htm index d2fdf51..c711efc 100644 --- a/org.tizen.tutorials/html/native/account/fido_client_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/account/fido_client_tutorial_n.htm @@ -10,7 +10,7 @@ - FIDO Client Tutorial + Fido Client: Authenticating Users Using the FIDO Framework @@ -21,197 +21,207 @@
        -

        FIDO Client

        +

        Fido Client: Authenticating Users Using the FIDO Framework

        -

        This tutorial demonstrates how you can find the authenticator supported by the device, register the user, authenticate the user and then de-register the user.

        -

        Please make sure that FIDO UAF feature is supported by the device.

        +

        This tutorial demonstrates how you can find the authenticator supported by the device, register the user, authenticate the user, and then deregister the user. Make sure that the FIDO UAF feature is supported by the device.

        Warm-up

        -

        Become familiar with FIDO Framework API basics by learning about:

        +

        Become familiar with the Fido API basics by learning about:

        -

        Find FIDO authenticator

        +

        Finding the FIDO Authenticator

        -

        Find Authenticator function is used to obtain the list of all available authenticators.

        +

        To obtain the list of all available authenticators, use the fido_foreach_authenticator() function:

         void
         start_discover(void *data, Evas_Object *obj, void *event_info)
         {
        -   int ret = fido_foreach_authenticator(auth_list_cb, data);
        +    int ret = fido_foreach_authenticator(auth_list_cb, data);
         }
         
         static void
         auth_list_cb(const fido_authenticator_h auth, void *user_data)
         {
        -   appdata_s *ad = user_data;
        -   __print_authinfo(auth, ad);
        +    appdata_s *ad = user_data;
        +    __print_authinfo(auth, ad);
         }
         
         static void
         __print_authinfo(fido_authenticator_h auth, appdata_s *ad)
         {
        -   char *title =  NULL;
        -   fido_authenticator_get_title(auth, &title);
        +    char *title = NULL;
        +    fido_authenticator_get_title(auth, &title);
         
        -   char *aaid = NULL;
        -   fido_authenticator_get_aaid(auth, &aaid);
        +    char *aaid = NULL;
        +    fido_authenticator_get_aaid(auth, &aaid);
         }
         
        -

        Check UAF Message Supported

        +

        Checking the UAF Message Support

        -

        This function checks whether the given UAF protocol message can be processed by the device.

        - -
      6. After you click Check UAF Message Supported on the main screen, on success 'TRUE' will be displayed in a pop up (as shown in the above figure).

      7. +

        To check whether the given UAF protocol message can be processed by the device, use the fido_uaf_is_supported() function:

         void
         start_check_policy(void *data, Evas_Object *obj, void *event_info)
         {
        -   bool is_supported = false;
        -   int ret = fido_uaf_is_supported(json_reg, &is_supported);
        +    bool is_supported = false;
        +    int ret = fido_uaf_is_supported(json_reg, &is_supported);
         
        -   char str[2048] = {0,};
        -   str[0] = '\0';
        +    char str[2048] = {0,};
        +    str[0] = '\0';
         
        -   strcpy(str, "CHECK POLICY RESPONSE | ");
        -   if (is_supported == true)
        -      sprintf(str, "TRUE");
        -   else
        -      sprintf(str, "FALSE");
        +    strcpy(str, "CHECK POLICY RESPONSE | ");
        +    if (is_supported == true)
        +        sprintf(str, "TRUE");
        +    else
        +        sprintf(str, "FALSE");
         
        -   create_popup(str, (appdata_s *) user_data);
        -   free(error_string);
        +    create_popup(str, (appdata_s *)user_data);
        +    free(error_string);
         }
         
        -

        Protocol Conversation

        +

        Managing the Protocol Conversation

        + +

        The core UAF protocol consists of conceptual conversations between the FIDO UAF client and the FIDO server.

        -

        The core UAF protocol consists of conceptual conversations between a FIDO UAF Client and FIDO Server.

        +

        To manage the conversations:

        -
        1. Registeration.

        2. -

          UAF allows the relying party to register a FIDO Authenticator with the user's account at the relying party. The relying party can specify a policy for supporting various FIDO Authenticator types. A FIDO UAF Client will only register existing authenticators in accordance with that policy.

          +
            +
          1. Register an authenticator. +

            UAF allows the relying party to register a FIDO authenticator with the user account at the relying party. The relying party can specify a policy for supporting various FIDO authenticator types. A FIDO UAF client only registers existing authenticators in accordance with that policy.

             void
             start_registration(void *data, Evas_Object *obj, void *event_info)
             {
            -   int ret = fido_uaf_get_response_message(json_reg, NULL, _process_cb, data);
            +    int ret = fido_uaf_get_response_message(json_reg, NULL, _process_cb, data);
             }
             
             static void
             _process_cb(fido_error_e tizen_error_code, const char *uaf_response, void *user_data)
             {
            -   char str[2048] = {0,};
            -   if (tizen_error_code == 0 && uaf_response != NULL) {
            -      const int max_popup_str_len = strlen(uaf_response) + 500;
            -      char *popup_str = calloc(1, max_popup_str_len);
            -      snprintf(popup_str, max_popup_str_len - 1, "UAF Response =%s", uaf_response);
            -      create_popup(popup_str, (appdata_s *) user_data);
            -      free(popup_str);
            -   }
            +    char str[2048] = {0,};
            +    if (tizen_error_code == 0 && uaf_response != NULL) {
            +        const int max_popup_str_len = strlen(uaf_response) + 500;
            +        char *popup_str = calloc(1, max_popup_str_len);
            +        snprintf(popup_str, max_popup_str_len - 1, "UAF Response =%s", uaf_response);
            +        create_popup(popup_str, (appdata_s *)user_data);
            +        free(popup_str);
            +    }
             }
             
            - -
          2. Authentication.

          3. -

            UAF allows the relying party to prompt the end user to authenticate using a previously registered FIDO Authenticator. This authentication can be invoked any time, at the relying party's discretion.

            + +
          4. Authenticate a user. +

            UAF allows the relying party to prompt the end user to authenticate using a previously registered FIDO authenticator. This authentication can be invoked any time, at the relying party's discretion.

             void
             start_auth(void *data, Evas_Object *obj, void *event_info)
             {
            -   int ret = fido_uaf_get_response_message(json_auth, NULL, _process_cb, data);
            +    int ret = fido_uaf_get_response_message(json_auth, NULL, _process_cb, data);
             }
             
            - -
          5. Deregistration.

          6. + +
          7. Deregister an authentication key.

            The relying party can trigger the deletion of the account-related authentication key material.

             void
             start_de_registration(void *data, Evas_Object *obj, void *event_info)
             {
            -   int ret = fido_uaf_get_response_message(json_dereg, NULL, _process_dereg_cb, data);
            +    int ret = fido_uaf_get_response_message(json_dereg, NULL, _process_dereg_cb, data);
             }
             
             static void
             _process_dereg_cb(int tizen_error_code, char *uaf_response, void *user_data)
             {
            -   char *error_string = get_error_code(tizen_error_code);
            -   create_popup(error_string, (appdata_s *) user_data);
            -   free(error_string);
            +    char *error_string = get_error_code(tizen_error_code);
            +    create_popup(error_string, (appdata_s *)user_data);
            +    free(error_string);
             }
            -
          -

          Set Server Result

          + + +
        + +

        Setting the Server Result

        -

        Set Server Result is used to indicate the status code resulting from a FIDO UAF message delivered to the remote server.

        -
        1. Set Server Result with Success

        2. +

          The server result is used to indicate the status code resulting from a FIDO UAF message delivered to the remote server.

          + +

          To set the server result:

          + +
          • Set the server result with success:
             void
             start_notify_pos(void *data, Evas_Object *obj, void *event_info)
             {
            -   if (json_reg != NULL)
            -      int ret = fido_uaf_get_response_message(json_reg, NULL, _process_cb_for_notify_pos, data);
            +    if (json_reg != NULL)
            +        int ret = fido_uaf_get_response_message(json_reg, NULL, _process_cb_for_notify_pos, data);
             }
             
             static void
             _process_cb_for_notify_pos(fido_error_e tizen_error_code, const char *uaf_response, void *user_data)
             {
            -   int ret = fido_uaf_set_server_result(FIDO_SERVER_STATUS_CODE_OK, uaf_response);
            +    int ret = fido_uaf_set_server_result(FIDO_SERVER_STATUS_CODE_OK, uaf_response);
             
            -   char *error_string = get_error_code(tizen_error_code);
            -   create_popup(error_string, (appdata_s *) user_data);
            -   free(error_string);
            +    char *error_string = get_error_code(tizen_error_code);
            +    create_popup(error_string, (appdata_s *)user_data);
            +    free(error_string);
             }
             
            - -
          • Set Server Result with Failure

          • + +
          • Set the server result with failure:
             void
             start_notify_neg(void *data, Evas_Object *obj, void *event_info)
             {
            -   int ret = fido_uaf_get_response_message(json_reg, NULL, _process_cb_for_notify_neg, data);
            +    int ret = fido_uaf_get_response_message(json_reg, NULL, _process_cb_for_notify_neg, data);
             }
             
             static void
             _process_cb_for_notify_neg(fido_error_e tizen_error_code, const char *uaf_response, void *user_data)
             {
            -   int ret = fido_uaf_set_server_result(0, uaf_response);
            +    int ret = fido_uaf_set_server_result(0, uaf_response);
             
            -   char *error_string = get_error_code(tizen_error_code);
            -   create_popup(error_string, (appdata_s *) user_data);
            -   free(error_string);
            +    char *error_string = get_error_code(tizen_error_code);
            +    create_popup(error_string, (appdata_s *)user_data);
            +    free(error_string);
             }
            -
        + + + diff --git a/org.tizen.tutorials/html/native/account/oauth2_tutorial_n.htm b/org.tizen.tutorials/html/native/account/oauth2_tutorial_n.htm index 5ed0d39..96f3687 100644 --- a/org.tizen.tutorials/html/native/account/oauth2_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/account/oauth2_tutorial_n.htm @@ -21,6 +21,7 @@
        @@ -39,7 +41,6 @@

        This tutorial demonstrates how you can create a request for OAuth 2.0 authentication and authorization grant from a server, obtain an access token using the manager handle, and retrieve this info from the response handle returned in the callback.

        -

        Warm-up

        Become familiar with the OAuth 2.0 API basics by learning about:

        @@ -57,11 +58,20 @@

        Obtain information from the OAuth 2.0 response handle returned in a callback.

        +

        Prerequisites

        + +

        To use the OAuth 2.0 API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

        +
        +<privileges>
        +   <privilege>http://tizen.org/privilege/internet</privilege>
        +</privileges>
        +
        +

        Initializing the OAuth 2.0 Manager

        To initialize the OAuth 2.0 manager:

          -
        1. To use the functions and data types of the OAuth 2.0 API, include the <oauth2.h> header file in your application:

          +
        2. To use the functions and data types of the OAuth 2.0 API (in mobile and wearable applications), include the <oauth2.h> header file in your application:

           #include <oauth2.h>
           
          @@ -75,8 +85,6 @@ int ret = OAUTH2_ERROR_NONE; ret = oauth2_manager_create(&mgr)
        3. -
        4. Add the http://tizen.org/privilege/internet privilege to the manifest file of your application to use the APIs for OAuth 2.0 authentication and connecting to the Web servers.

        5. -
        6. When you no longer need it, free the OAuth 2.0 manager handle with the oauth2_manager_destroy() function:
          @@ -157,34 +165,36 @@ ret = oauth2_request_destroy(request);
           void
           grant_response_cb(oauth2_response_h response, void* user_data)
           {
          -   // Authorization code response callback
          -   char *auth_code = NULL;
          -   oauth2_response_get_authorization_code(response, &auth_code);
          +    /* Authorization code response callback */
          +    char *auth_code = NULL;
          +    oauth2_response_get_authorization_code(response, &auth_code);
           }
           
           void
           request_auth_code(void)
           {
          -   oauth2_manager_h mgr = NULL;
          -   int ret = oauth2_manager_create(&mgr);
          +    oauth2_manager_h mgr = NULL;
          +    int ret = oauth2_manager_create(&mgr);
           
          -   oauth2_request_h request = NULL;
          -   ret = oauth2_request_create(&request);
          +    oauth2_request_h request = NULL;
          +    ret = oauth2_request_create(&request);
           
          -   // Set all the required parameters needed as per the Web server's
          -   // OAuth 2.0 authentication policy before making the request
          +    /*
          +       Set all the required parameters needed as per the Web server's
          +       OAuth 2.0 authentication policy before making the request
          +    */
           
          -   // Set the response_type as "code"
          -   ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_CODE);
          +    /* Set the response_type as "code" */
          +    ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_CODE);
           
          -   // Set the application client ID registered in the server
          -   ret = oauth2_request_set_client_id(request, "app_client_id");
          +    /* Set the application client ID registered in the server */
          +    ret = oauth2_request_set_client_id(request, "app_client_id");
           
          -   // Set the redirect URI for the server to redirect the flow after the authentication
          -   ret = oauth2_request_set_redirection_url(request, "https://developer.tizen.org");
          +    /* Set the redirect URI for the server to redirect the flow after the authentication */
          +    ret = oauth2_request_set_redirection_url(request, "https://developer.tizen.org");
           
          -   // Request the server for the authorization grant; the response from the server is returned in the callback
          -   ret = oauth2_manager_request_authorization_grant(mgr, request, grant_response_cb, user_data);
          +    /* Request the server for the authorization grant; the response from the server is returned in the callback */
          +    ret = oauth2_manager_request_authorization_grant(mgr, request, grant_response_cb, user_data);
           }
           
        7. @@ -201,33 +211,33 @@ request_auth_code(void) void request_auth_code(void) { -   oauth2_manager_h mgr = NULL; -   int ret = oauth2_manager_create(&mgr); +    oauth2_manager_h mgr = NULL; +    int ret = oauth2_manager_create(&mgr); -   oauth2_request_h request = NULL; -   ret = oauth2_request_create(&request); +    oauth2_request_h request = NULL; +    ret = oauth2_request_create(&request); -   // Set all the required parameters needed as per the Web server's -   // OAuth 2.0 authentication policy before making the request +    /* +     Set all the required parameters needed as per the Web server's +     OAuth 2.0 authentication policy before making the request +    */ -   ret = oauth2_request_set_auth_end_point_url(request, "https://login.live.com/oauth20_authorize.srf"); +    ret = oauth2_request_set_auth_end_point_url(request, "https://login.live.com/oauth20_authorize.srf"); -   ret = oauth2_request_set_token_end_point_url(request, "https://login.live.com/oauth20_token.srf"); +    ret = oauth2_request_set_token_end_point_url(request, "https://login.live.com/oauth20_token.srf"); -   ret = oauth2_request_set_redirection_url(request, "https://developer.tizen.org"); +    ret = oauth2_request_set_redirection_url(request, "https://developer.tizen.org"); -   ret = oauth2_request_set_client_id(request, "WINDOWS_CLIENT_ID"); +    ret = oauth2_request_set_client_id(request, "WINDOWS_CLIENT_ID"); -   ret = oauth2_request_set_client_secret(request, "WINDOWS_CLIENT_SECRET"); +    ret = oauth2_request_set_client_secret(request, "WINDOWS_CLIENT_SECRET"); -   ret = oauth2_request_set_scope(request, "wl.basic"); +    ret = oauth2_request_set_scope(request, "wl.basic"); -   ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_CODE); +    ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_CODE); -   if (mgr && request) -   { -      ret = oauth2_manager_request_authorization_grant(mgr, request, grant_response_cb, request); -   } +    if (mgr && request) +        ret = oauth2_manager_request_authorization_grant(mgr, request, grant_response_cb, request); } @@ -237,35 +247,32 @@ request_auth_code(void) void access_token_cb(oauth2_response_h response, void* user_data) { -   // Access token response callback +    /* Access token response callback */ -   char *access_token = NULL; -   oauth2_response_get_access_token(response, &access_token); +    char *access_token = NULL; +    oauth2_response_get_access_token(response, &access_token); } void grant_response_cb(oauth2_response_h response, void* user_data) { -   // Authorization code response callback +    /* Authorization code response callback */ -   char *auth_code = NULL; -   oauth2_response_get_authorization_code(response, &auth_code); +    char *auth_code = NULL; +    oauth2_response_get_authorization_code(response, &auth_code); -   if (auth_code) -   { -      oauth2_manager_h mgr = NULL; -      int ret = oauth2_manager_create(&mgr); +    if (auth_code) { +        oauth2_manager_h mgr = NULL; +        int ret = oauth2_manager_create(&mgr); -      // Request handle was passed as the user data -      oauth2_request_h request = (oauth2_request_h) user_data; +        /* Request handle was passed as the user data */ +        oauth2_request_h request = (oauth2_request_h) user_data; -      ret = oauth2_request_set_authorization_code(request, auth_code); +        ret = oauth2_request_set_authorization_code(request, auth_code); -      if (mgr && request) -      { -         ret = oauth2_manager_request_access_token(mgr, request, access_token_cb, NULL); -      } -   } +        if (mgr && request) +            ret = oauth2_manager_request_access_token(mgr, request, access_token_cb, NULL); +    } }
        @@ -280,42 +287,41 @@ grant_response_cb(oauth2_response_h response, void* user_data) void token_response_cb(oauth2_response_h response, void* user_data) { -   // Access token response callback +    /* Access token response callback */ -   char *access_token = NULL; -   oauth2_response_get_access_token(response, &access_token); +    char *access_token = NULL; +    oauth2_response_get_access_token(response, &access_token); } void request_access_token(void) { -   oauth2_manager_h mgr = NULL; -   int ret = oauth2_manager_create(&mgr); +    oauth2_manager_h mgr = NULL; +    int ret = oauth2_manager_create(&mgr); -   oauth2_request_h request = NULL; -   ret = oauth2_request_create(&request); +    oauth2_request_h request = NULL; +    ret = oauth2_request_create(&request); -   // Set all the required parameters needed as per the Web server's -   // OAuth 2.0 authentication policy before making the request +    /* +     Set all the required parameters needed as per the Web server's +     OAuth 2.0 authentication policy before making the request +    */ -   ret = oauth2_request_set_auth_end_point_url(request, "https://www.facebook.com/dialog/oauth"); +    ret = oauth2_request_set_auth_end_point_url(request, "https://www.facebook.com/dialog/oauth"); -   ret = oauth2_request_set_redirection_url(request, "https://developer.tizen.org"); +    ret = oauth2_request_set_redirection_url(request, "https://developer.tizen.org"); -   ret = oauth2_request_set_client_id(request, "SAMPLE_CLIENT_ID"); +    ret = oauth2_request_set_client_id(request, "SAMPLE_CLIENT_ID"); -   ret = oauth2_request_set_scope(request, "read_stream"); +    ret = oauth2_request_set_scope(request, "read_stream"); -   ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_TOKEN); +    ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_TOKEN); -   if (mgr && request) -   { -      ret = oauth2_manager_request_token(mgr, request, token_response_cb, request); -      if (ret != OAUTH2_ERROR_NONE) -      { -         dlog_print(DLOG_ERROR, LOG_TAG, "Access Token request failed"); -      } -   } +    if (mgr && request) { +        ret = oauth2_manager_request_token(mgr, request, token_response_cb, request); +        if (ret != OAUTH2_ERROR_NONE) +            dlog_print(DLOG_ERROR, LOG_TAG, "Access Token request failed"); +    } } @@ -328,83 +334,82 @@ request_access_token(void) void token_response_cb(oauth2_response_h response, void* user_data) { -   // Access token response callback +    /* Access token response callback */ -   char *access_token = NULL; -   oauth2_response_get_access_token(response, &access_token); +    char *access_token = NULL; +    oauth2_response_get_access_token(response, &access_token); } void refresh_token_response_cb(oauth2_response_h response, void* user_data) { -   char *acc_token = NULL; -   oauth2_response_get_access_token(response, &acc_token); +    char *acc_token = NULL; +    oauth2_response_get_access_token(response, &acc_token); -   char *ref_token = NULL; -   oauth2_response_get_refresh_token(response, &ref_token); +    char *ref_token = NULL; +    oauth2_response_get_refresh_token(response, &ref_token); -   char *auth_code = NULL; -   oauth2_response_get_authorization_code(response, &auth_code); -   if (auth_code) -   { -      oauth2_manager_h mgr = (oauth2_manager_h) user_data; +    char *auth_code = NULL; +    oauth2_response_get_authorization_code(response, &auth_code); +    if (auth_code) { +        oauth2_manager_h mgr = (oauth2_manager_h) user_data; -      oauth2_request_h request = NULL; +        oauth2_request_h request = NULL; -      int ret = oauth2_request_create(&request); +        int ret = oauth2_request_create(&request); -      // Set all the required parameters needed as per the Web server's -      // OAuth 2.0 authentication policy before making the request +        /* +         Set all the required parameters needed as per the Web server's +         OAuth 2.0 authentication policy before making the request +        */ -      ret = oauth2_request_set_refresh_token_url(request, "https://www.googleapis.com/oauth2/v3/token"); +        ret = oauth2_request_set_refresh_token_url(request, "https://www.googleapis.com/oauth2/v3/token"); -      ret = oauth2_request_set_refresh_token(request, ref_token); +        ret = oauth2_request_set_refresh_token(request, ref_token); -      ret = oauth2_request_set_client_id(request, "GOOGLE_CLIENT_ID"); +        ret = oauth2_request_set_client_id(request, "GOOGLE_CLIENT_ID"); -      ret = oauth2_request_set_client_secret(request, "GOOGLE_CLIENT_SECRET"); +        ret = oauth2_request_set_client_secret(request, "GOOGLE_CLIENT_SECRET"); -      ret = oauth2_request_set_grant_type(request, OAUTH2_GRANT_TYPE_REFRESH); +        ret = oauth2_request_set_grant_type(request, OAUTH2_GRANT_TYPE_REFRESH); -      ret = oauth2_request_set_client_authentication_type(request, OAUTH2_CLIENT_AUTHENTICATION_TYPE_REQUEST_BODY); +        ret = oauth2_request_set_client_authentication_type(request, OAUTH2_CLIENT_AUTHENTICATION_TYPE_REQUEST_BODY); -      if (mgr && request) -      { -         ret = oauth2_manager_refresh_access_token(mgr, request, token_response_cb, NULL); -      } -   } +        if (mgr && request) +            ret = oauth2_manager_refresh_access_token(mgr, request, token_response_cb, NULL); +    } } void request_access_token(void) { -   oauth2_manager_h mgr = NULL; -   int ret = oauth2_manager_create(&mgr); +    oauth2_manager_h mgr = NULL; +    int ret = oauth2_manager_create(&mgr); -   oauth2_request_h request = NULL; -   ret = oauth2_request_create(&request); +    oauth2_request_h request = NULL; +    ret = oauth2_request_create(&request); -   // Set all the required parameters needed as per the Web server's -   // OAuth 2.0 authentication policy before making the request +    /* +     Set all the required parameters needed as per the Web server's +     OAuth 2.0 authentication policy before making the request +    */ -   ret = oauth2_request_set_auth_end_point_url(request, "https://accounts.google.com/o/oauth2/auth"); +    ret = oauth2_request_set_auth_end_point_url(request, "https://accounts.google.com/o/oauth2/auth"); -   ret = oauth2_request_set_token_end_point_url(request, "https://accounts.google.com/o/oauth2/token"); +    ret = oauth2_request_set_token_end_point_url(request, "https://accounts.google.com/o/oauth2/token"); -   ret = oauth2_request_set_redirection_url(request, "https://localhost:8080"); +    ret = oauth2_request_set_redirection_url(request, "https://localhost:8080"); -   ret = oauth2_request_set_client_id(request, "GOOGLE_CLIENT_ID"); +    ret = oauth2_request_set_client_id(request, "GOOGLE_CLIENT_ID"); -   ret = oauth2_request_set_client_secret(request, "GOOGLE_CLIENT_SECRET"); +    ret = oauth2_request_set_client_secret(request, "GOOGLE_CLIENT_SECRET"); -   ret = oauth2_request_set_scope(request, "email"); +    ret = oauth2_request_set_scope(request, "email"); -   ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_CODE); +    ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_CODE); -   if (mgr && request) -   { -      ret = oauth2_manager_request_token(mgr, request, refresh_token_response_cb, mgr); -   } +    if (mgr && request) +        ret = oauth2_manager_request_token(mgr, request, refresh_token_response_cb, mgr); } @@ -440,7 +445,7 @@ ret = oauth2_response_get_token_type(response, &token_type);

        If the created request is incorrect or missing required permissions, the server response contains an error. Retrieve the error information from the response handle to check the issue:

        -oauth2_error_h e_handle =  NULL;
        +oauth2_error_h e_handle = NULL;
         int error_code = 0;
         int platform_error_code = 0;
         char *description = NULL;
        diff --git a/org.tizen.tutorials/html/native/account/sync_manager_tutorial_n.htm b/org.tizen.tutorials/html/native/account/sync_manager_tutorial_n.htm
        index 06ca63e..7e5875b 100644
        --- a/org.tizen.tutorials/html/native/account/sync_manager_tutorial_n.htm
        +++ b/org.tizen.tutorials/html/native/account/sync_manager_tutorial_n.htm
        @@ -37,6 +37,7 @@
         		
         	
        @@ -81,7 +82,7 @@ result = sync_adapter_set_callbacks(on_start_cb, on_cancel_cb); -
      8. To use the functions and data types of the Sync Manager API, include the <sync_manager.h> header file in your UI application: +
      9. To use the functions and data types of the Sync Manager API (in mobile and wearable applications), include the <sync_manager.h> header file in your UI application:
         #include <sync_manager.h>
         
      10. @@ -112,27 +113,27 @@ int sync_job_id = -1;
      11. Add an on-demand sync job:
        -result = sync_manager_on_demand_sync_job(account, sync_job_name, SYNC_OPTION_NONE, 
        +result = sync_manager_on_demand_sync_job(account, sync_job_name, SYNC_OPTION_NONE,
                                                  sync_job_user_data, &sync_job_id);
         

        This function can be used with various options, as shown in the following example. The SYNC_OPTION_NO_RETRY option means the sync job is not performed again when it fails. The SYNC_OPTION_EXPEDITED option means the other sync job is operated as soon as possible. The call with the OR structure lets the other sync job operate just once with priority.

        -result = sync_manager_on_demand_sync_job(account, sync_job_name2, SYNC_OPTION_NO_RETRY, 
        +result = sync_manager_on_demand_sync_job(account, sync_job_name2, SYNC_OPTION_NO_RETRY,
                                                  sync_job_user_data, &sync_job_id2);
        -result = sync_manager_on_demand_sync_job(account, sync_job_name3, SYNC_OPTION_EXPEDITED, 
        +result = sync_manager_on_demand_sync_job(account, sync_job_name3, SYNC_OPTION_EXPEDITED,
                                                  sync_job_user_data, &sync_job_id3);
        -result = sync_manager_on_demand_sync_job(account, sync_job_name4, 
        -                                         (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), 
        +result = sync_manager_on_demand_sync_job(account, sync_job_name4,
        +                                         (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED),
                                                  sync_job_user_data, &sync_job_id4);
         

        This function can also be called like in the following example, because the account handle and user data are not mandatory:

        -result = sync_manager_on_demand_sync_job(NULL, sync_job_name, SYNC_OPTION_NONE, 
        +result = sync_manager_on_demand_sync_job(NULL, sync_job_name, SYNC_OPTION_NONE,
                                                  sync_job_user_data, &sync_job_id);
        -result = sync_manager_on_demand_sync_job(account, sync_job_name2, SYNC_OPTION_NO_RETRY, 
        +result = sync_manager_on_demand_sync_job(account, sync_job_name2, SYNC_OPTION_NO_RETRY,
                                                  NULL, &sync_job_id2);
        -result = sync_manager_on_demand_sync_job(NULL, sync_job_name3, SYNC_OPTION_EXPEDITED, 
        +result = sync_manager_on_demand_sync_job(NULL, sync_job_name3, SYNC_OPTION_EXPEDITED,
                                                  NULL, &sync_job_id3);
         

        If the on-demand sync job addition process succeeds, the SYNC_ERROR_NONE value is returned.

        @@ -171,7 +172,7 @@ result = sync_adapter_set_callbacks(on_start_cb, on_cancel_cb);
      12. -
      13. To use the functions and data types of the Sync Manager API, include the <sync_manager.h> header file in your UI application: +
      14. To use the functions and data types of the Sync Manager API (in mobile and wearable applications), include the <sync_manager.h> header file in your UI application:
         #include <sync_manager.h>
         
        @@ -206,32 +207,32 @@ int sync_job_id = -1;
      15. Add a periodic sync job with an interval as 30 minutes.

        This function operates the sync job with the given period interval.

        -result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period, 
        -                                            SYNC_OPTION_NONE, sync_job_user_data, 
        +result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period,
        +                                            SYNC_OPTION_NONE, sync_job_user_data,
                                                     &sync_job_id);
         

        This function can be used with various options, as shown in the following example. The SYNC_OPTION_NO_RETRY option means a sync job is not performed again when it fails. The SYNC_OPTION_EXPEDITED option means another sync job is operated as soon as possible. The call with the OR structure lets the other sync job operate just once with priority.

        -result = sync_manager_add_periodic_sync_job(account, sync_job_name2, sync_period2, 
        -                                            SYNC_OPTION_NO_RETRY, sync_job_user_data, 
        +result = sync_manager_add_periodic_sync_job(account, sync_job_name2, sync_period2,
        +                                            SYNC_OPTION_NO_RETRY, sync_job_user_data,
                                                     &sync_job_id2);
        -result = sync_manager_add_periodic_sync_job(account, sync_job_name3, sync_period3, 
        -                                            SYNC_OPTION_EXPEDITED, sync_job_user_data, 
        +result = sync_manager_add_periodic_sync_job(account, sync_job_name3, sync_period3,
        +                                            SYNC_OPTION_EXPEDITED, sync_job_user_data,
                                                     &sync_job_id3);
        -result = sync_manager_add_periodic_sync_job(account, sync_job_name4, sync_period4, 
        -                                            (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), 
        +result = sync_manager_add_periodic_sync_job(account, sync_job_name4, sync_period4,
        +                                            (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED),
                                                     sync_job_user_data, &sync_job_id4);
         

        This function can also be called like in the following example, because the account handle and user data are not mandatory:

        -result = sync_manager_add_periodic_sync_job(NULL, sync_job_name, sync_period, 
        -                                            SYNC_OPTION_NONE, sync_job_user_data, 
        +result = sync_manager_add_periodic_sync_job(NULL, sync_job_name, sync_period,
        +                                            SYNC_OPTION_NONE, sync_job_user_data,
                                                     &sync_job_id);
        -result = sync_manager_add_periodic_sync_job(account, sync_job_name2, sync_period2, 
        -                                            SYNC_OPTION_NO_RETRY, NULL, 
        +result = sync_manager_add_periodic_sync_job(account, sync_job_name2, sync_period2,
        +                                            SYNC_OPTION_NO_RETRY, NULL,
                                                     &sync_job_id2);
        -result = sync_manager_add_periodic_sync_job(NULL, sync_job_name3, sync_period3, 
        -                                            SYNC_OPTION_EXPEDITED, NULL, 
        +result = sync_manager_add_periodic_sync_job(NULL, sync_job_name3, sync_period3,
        +                                            SYNC_OPTION_EXPEDITED, NULL,
                                                     &sync_job_id3);
         

        If the periodic sync job addition process succeeds, the SYNC_ERROR_NONE value is returned.

        @@ -239,11 +240,11 @@ result = sync_manager_add_periodic_sync_job(NULL, sync_job_name3, sync_period3,
      16. The sync_manager_add_periodic_sync_job() function can renew a registered periodic sync job by using the same sync_job_name as before:
        -result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period, 
        -                                            SYNC_OPTION_NONE, sync_job_user_data, 
        +result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period,
        +                                            SYNC_OPTION_NONE, sync_job_user_data,
                                                     &sync_job_id);
        -result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period2, 
        -                                            SYNC_OPTION_EXPEDITED, sync_job_user_data2, 
        +result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period2,
        +                                            SYNC_OPTION_EXPEDITED, sync_job_user_data2,
                                                     &sync_job_id);
         

        All the function parameters can be reset except sync_job_name and sync_job_id, which are used to manage a specific sync job.

        @@ -284,7 +285,7 @@ result = sync_adapter_set_callbacks(on_start_cb, on_cancel_cb);
      17. -
      18. To use the functions and data types of the Sync Manager API, include the <sync_manager.h> header file in your UI application: +
      19. To use the functions and data types of the Sync Manager API (in mobile and wearable applications), include the <sync_manager.h> header file in your UI application:
         #include <sync_manager.h>
         
        @@ -321,34 +322,34 @@ int sync_job_id = -1;
      20. Add a data change sync job for the calendar capability.

        The sync_manager_add_data_change_sync_job() function operates a sync job only for a registered capability.

        -result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, 
        -                                               SYNC_OPTION_NONE, sync_job_user_data, 
        +result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar,
        +                                               SYNC_OPTION_NONE, sync_job_user_data,
                                                        &sync_job_id);
         

        This function can be used with various options, as shown in the following example. The SYNC_OPTION_NO_RETRY option means a sync job is not performed again when it fails. The SYNC_OPTION_EXPEDITED option means another sync job is operated as soon as possible. The call with the OR structure lets the other sync job operate just once with priority.

        -result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, 
        -                                               SYNC_OPTION_NO_RETRY, sync_job_user_data, 
        +result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar,
        +                                               SYNC_OPTION_NO_RETRY, sync_job_user_data,
                                                        &sync_job_id2);
        -result = sync_manager_add_data_change_sync_job(account, sync_capability_contact, 
        -                                               SYNC_OPTION_EXPEDITED, sync_job_user_data, 
        +result = sync_manager_add_data_change_sync_job(account, sync_capability_contact,
        +                                               SYNC_OPTION_EXPEDITED, sync_job_user_data,
                                                        &sync_job_id3);
        -result = sync_manager_add_data_change_sync_job(account, sync_capability_image, 
        -                                               (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), 
        +result = sync_manager_add_data_change_sync_job(account, sync_capability_image,
        +                                               (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED),
                                                        sync_job_user_data, &sync_job_id4);
         

        This function can also be called like in the following example, because the account handle and user data are not mandatory:

         result = sync_manager_add_data_change_sync_job(NULL, sync_capability_music,
        -                                               SYNC_OPTION_NONE, sync_job_user_data, 
        +                                               SYNC_OPTION_NONE, sync_job_user_data,
                                                        &sync_job_id);
        -result = sync_manager_add_data_change_sync_job(account, sync_capability_sound, 
        -                                               SYNC_OPTION_NO_RETRY, NULL, 
        +result = sync_manager_add_data_change_sync_job(account, sync_capability_sound,
        +                                               SYNC_OPTION_NO_RETRY, NULL,
                                                        &sync_job_id2);
        -result = sync_manager_add_data_change_sync_job(NULL, sync_capability_video, 
        -                                               SYNC_OPTION_EXPEDITED, NULL, 
        +result = sync_manager_add_data_change_sync_job(NULL, sync_capability_video,
        +                                               SYNC_OPTION_EXPEDITED, NULL,
                                                        &sync_job_id3);
         

        If the data change sync job addition process succeeds, the SYNC_ERROR_NONE value is returned.

        @@ -356,11 +357,11 @@ result = sync_manager_add_data_change_sync_job(NULL, sync_capability_video,
      21. The sync_manager_add_data_change_sync_job() function can renew a registered data change sync job by using the same sync_capability as before:
        -result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, 
        -                                               SYNC_OPTION_NONE, sync_job_user_data, 
        +result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar,
        +                                               SYNC_OPTION_NONE, sync_job_user_data,
                                                        &sync_job_id);
        -result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, 
        -                                               SYNC_OPTION_EXPEDITED, sync_job_user_data2, 
        +result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar,
        +                                               SYNC_OPTION_EXPEDITED, sync_job_user_data2,
                                                        &sync_job_id);
         

        All the function parameters can be reset except sync_capability and sync_job_id, which are used to manage a specific sync job.

        @@ -391,7 +392,7 @@ sync_adapter_unset_callbacks();

        To iterate all registered sync jobs to manage them more efficiently:

          -
        1. To use the functions and data types of the Sync Manager API, include the <sync_manager.h> header file in your UI application: +
        2. To use the functions and data types of the Sync Manager API (in mobile and wearable applications), include the <sync_manager.h> header file in your UI application:
           #include <sync_manager.h>
           
          @@ -406,11 +407,11 @@ result = sync_manager_foreach_sync_job(sync_job_cb, NULL);
        3. Define the sync_job_cb() callback, which is invoked separately for every registered sync job. In the callback, the sync jobs are verified with a corresponding data.
          -bool 
          -sync_job_cb(account_h account, const char *sync_job_name, const char *sync_capability, 
          +bool
          +sync_job_cb(account_h account, const char *sync_job_name, const char *sync_capability,
                       int sync_job_id, bundle *sync_job_user_data, void *user_data)
           {
          -   // Verify the registered sync jobs
          +    /* Verify the registered sync jobs */
           }
           
        4. @@ -422,7 +423,7 @@ sync_job_cb(account_h account, const char *sync_job_name, const char *sync_capab

          To set callbacks to receive notifications about sync operations:

            -
          1. To use the functions and data types of the Sync Adapter API, include the <sync_adapter.h> header file in your service application: +
          2. To use the functions and data types of the Sync Adapter API (in mobile and wearable applications), include the <sync_adapter.h> header file in your service application:
             #include <sync_adapter.h>
            @@ -439,18 +440,18 @@ result = sync_adapter_set_callbacks(on_start_cb, on_cancel_cb);
             
             
          3. When the on_start_cb() callback is invoked, the predefined data sync process is performed inside the callback function. The on_cancel_cb() callback works in a similar way and cancels the data sync process.
            -bool 
            -on_start_cb(account_h account, const char *sync_job_name, 
            +bool
            +on_start_cb(account_h account, const char *sync_job_name,
                         const char *sync_capability, bundle *sync_job_user_data)
             {
            -   // Start the data sync process
            +    /* Start the data sync process */
             }
             
            -void 
            -on_cancel_cb(account_h account, const char *sync_job_name, 
            +void
            +on_cancel_cb(account_h account, const char *sync_job_name,
                          const char *sync_capability, bundle *sync_job_user_data)
             {
            -   // Cancel the data sync process
            +    /* Cancel the data sync process */
             }
             
          4. diff --git a/org.tizen.tutorials/html/native/app_framework/alarm_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/alarm_tutorial_n.htm index 9f2ee97..82aece8 100644 --- a/org.tizen.tutorials/html/native/app_framework/alarm_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/alarm_tutorial_n.htm @@ -23,7 +23,7 @@

            Content

            +
          5. +

          Setting an Alarm after Specific Time

          @@ -91,25 +98,24 @@
          1. -

            Implement the AlarmRegister application

            -

            The AlarmRegister application requires the http://tizen.org/privilege/alarm.set privilege.

            +

            Implement the AlarmRegister application:

            1. To identify which application to start when the alarm expires, the Alarm API needs the app_control_h handle.

              Obtain the app_control_h handle of a specific app by calling the app_control_set_app_id() function. You can get the AlarmTarget app_id from the tizen-manifest.xml file.

              -bool 
              +bool
               init_alarm()
               {
              -   int ret;
              -   int DELAY = 2;
              -   int REMIND = 1;
              -   int alarm_id;
              -
              -   app_control_h app_control = NULL;
              -   ret = app_control_create(&app_control);
              -   ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
              -   ret = app_control_set_app_id(app_control, "org.tizen.alarmslave");
              +    int ret;
              +    int DELAY = 2;
              +    int REMIND = 1;
              +    int alarm_id;
              +
              +    app_control_h app_control = NULL;
              +    ret = app_control_create(&app_control);
              +    ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
              +    ret = app_control_set_app_id(app_control, "org.tizen.alarmslave");
               
            2. @@ -118,26 +124,26 @@ init_alarm()

              To schedule an alarm after a delay, use the alarm_schedule_after_delay() function:

              -   ret = alarm_schedule_after_delay(app_control, DELAY, REMIND, &alarm_id);
              +    ret = alarm_schedule_after_delay(app_control, DELAY, REMIND, &alarm_id);
               
              -   return true;
              +    return true;
               }
               
          2. -

            Implement the AlarmTarget application

            +

            Implement the AlarmTarget application:

            A scheduled alarm calls AlarmTarget's app_control_cb() callback when the alarm expires:

            -void 
            +void
             service_app_control(app_control_h app_control, void *data)
             {
            -   dlog_print(DLOG_INFO, LOG_TAG, "app_control called by Alarm API.");
            +    dlog_print(DLOG_INFO, LOG_TAG, "app_control called by Alarm API.");
             }
             
          3. -
          +

        Setting an Alarm on a Specific Date

        @@ -196,11 +202,12 @@ service_app_control(app_control_h app_control, void *data)

        The following code schedules an application control to invoke after 4 seconds (using the date.tm_sec member). Using, for example, date.tm_mday, can set the alarm to another day of the month. Since the third parameter is set to 0, the alarm is executed only once.

        -
        struct tm date;
        +
        +struct tm date;
         ret = alarm_get_current_time(&date);
         
         date.tm_sec+=4;
        -ret = alarm_schedule_at_date(app, &date, 0, &alarm_id);	
        +ret = alarm_schedule_at_date(app, &date, 0, &alarm_id);
         
        @@ -223,13 +230,13 @@ ret = alarm_schedule_at_date(app, &date, 0, &alarm_id);

        The following code schedules an application control to invoke on TUESDAY and FRIDAY:

        -
        +
         struct tm date;
         ret = alarm_get_current_time(&date);
         
         time_t time_current = mktime(&date);
         dlog_print(DLOG_INFO, TAG, "Schedule on date: %s ", ctime(&time_current));
        -ret = alarm_schedule_with_recurrence_week_flag(app_control, &date, 
        +ret = alarm_schedule_with_recurrence_week_flag(app_control, &date,
                                                        ALARM_WEEK_FLAG_TUESDAY | ALARM_WEEK_FLAG_FRIDAY, &alarm_id);
         
        @@ -242,58 +249,51 @@ ret = alarm_schedule_with_recurrence_week_flag(app_control, &date,

        The following code implements the callback for the alarm_foreach_registered_alarm() function. It lists all registered alarms and alarm recurrence days. At the end of the function, the alarm_cancel() function is called to cancel every scheduled alarm.

        -static bool 
        +static bool
         on_foreach_registered_alarm(int alarm_id, void *user_data)
         {
        -   int flag;
        -   int ret = 0;
        -   struct tm date;
        -   time_t time_current;
        -
        -   ret = alarm_get_scheduled_date(alarm_id, &date);
        -   if (ret != ALARM_ERROR_NONE)
        -   {
        -      dlog_print(DLOG_ERROR, TAG, "Get time Error: %d ", ret);
        -   }
        -
        -   // Logging scheduled alarm info
        -   time_current = mktime(&date);
        -   dlog_print(DLOG_INFO, TAG, "Registered alarm:%d on date:%s ", alarm_id, ctime(&time_current));
        -
        -   ret = alarm_get_scheduled_recurrence_week_flag(alarm_id, &flag);
        -   if (ret == 0)
        -   {
        -      if (flag & ALARM_WEEK_FLAG_SUNDAY)
        -         dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on SUNDAY \n");
        -      if (flag & ALARM_WEEK_FLAG_MONDAY)
        -         dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on MONDAY \n");
        -      if (flag & ALARM_WEEK_FLAG_TUESDAY)
        -         dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on TUESDAY \n");
        -      if (flag & ALARM_WEEK_FLAG_WEDNESDAY)
        -         dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on WEDNESDAY \n");
        -      if (flag & ALARM_WEEK_FLAG_THURSDAY)
        -         dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on THURSDAY \n");
        -      if (flag & ALARM_WEEK_FLAG_FRIDAY)
        -         dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on FRIDAY \n");
        -      if (flag & ALARM_WEEK_FLAG_SATURDAY)
        -         dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on SATURDAY \n");
        -   }
        -
        -   // Cancel scheduled alarms
        -   ret = alarm_cancel(alarm_id);
        -   if (ret != ALARM_ERROR_NONE) 
        -   {
        -      dlog_print(DLOG_ERROR, TAG, "Cancel Error: %d ", ret);
        -   }
        -
        -   return true;
        +    int flag;
        +    int ret = 0;
        +    struct tm date;
        +    time_t time_current;
        +
        +    ret = alarm_get_scheduled_date(alarm_id, &date);
        +    if (ret != ALARM_ERROR_NONE)
        +        dlog_print(DLOG_ERROR, TAG, "Get time Error: %d ", ret);
        +
        +    /* Logging scheduled alarm info */
        +    time_current = mktime(&date);
        +    dlog_print(DLOG_INFO, TAG, "Registered alarm:%d on date:%s ", alarm_id, ctime(&time_current));
        +
        +    ret = alarm_get_scheduled_recurrence_week_flag(alarm_id, &flag);
        +    if (ret == 0) {
        +        if (flag & ALARM_WEEK_FLAG_SUNDAY)
        +            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on SUNDAY \n");
        +        if (flag & ALARM_WEEK_FLAG_MONDAY)
        +            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on MONDAY \n");
        +        if (flag & ALARM_WEEK_FLAG_TUESDAY)
        +            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on TUESDAY \n");
        +        if (flag & ALARM_WEEK_FLAG_WEDNESDAY)
        +            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on WEDNESDAY \n");
        +        if (flag & ALARM_WEEK_FLAG_THURSDAY)
        +            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on THURSDAY \n");
        +        if (flag & ALARM_WEEK_FLAG_FRIDAY)
        +            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on FRIDAY \n");
        +        if (flag & ALARM_WEEK_FLAG_SATURDAY)
        +            dlog_print(DLOG_INFO, TAG, "Alarm Recurrence on SATURDAY \n");
        +    }
        +
        +    /* Cancel scheduled alarms */
        +    ret = alarm_cancel(alarm_id);
        +    if (ret != ALARM_ERROR_NONE)
        +        dlog_print(DLOG_ERROR, TAG, "Cancel Error: %d ", ret);
        +
        +    return true;
         }
         
         ret = alarm_foreach_registered_alarm(on_foreach_registered_alarm, NULL);
        -if (ret != ALARM_ERROR_NONE) 
        -{
        -   dlog_print(DLOG_ERROR, TAG, "Listing Error: %d ", ret);
        -}
        +if (ret != ALARM_ERROR_NONE)
        +    dlog_print(DLOG_ERROR, TAG, "Listing Error: %d ", ret);
         
        diff --git a/org.tizen.tutorials/html/native/app_framework/app_manager_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/app_manager_tutorial_n.htm index 0d61893..faaea29 100644 --- a/org.tizen.tutorials/html/native/app_framework/app_manager_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/app_manager_tutorial_n.htm @@ -23,6 +23,7 @@

        Content

        @@ -45,20 +46,24 @@

        Warm-up

        Become familiar with the Application Manager API basics by learning about:

        + +

        Prerequisites

        +

        To use the functions and data types of the Application Manager API (in mobile and wearable applications), include the <app_manager.h> header file in your application:

        +
        +#include <app_manager.h>
        +
        +

        Managing the Application Context

        To get the running application context and its details, and to operate on the context:

          -
        1. To use the functions and data types of the Application Manager API (in mobile and wearable applications), include the <app_manager.h> header file in your application:

          -
          -#include <app_manager.h>
          -
        2. -
        3. Get the context of the currently running application with the app_manager_get_app_context() function. Its parameters are the ID of the application from which the context is being obtained, and the handle (app_context_h*) to the application context which is filled with the received context.

          When an application is not running, it is impossible to get its context.

          @@ -92,17 +97,13 @@ bool terminated = false; ret = app_context_is_terminated(app_context, &terminated); if (false == terminated) -{ -   // Application is running -} -else -{ -   // Application is terminated -} +    /* Application is running */ +else +    /* Application is terminated */
      22. Clone the given context handle:

        -
        +
         app_context_h app_context_cloned = NULL;
         
         ret = app_context_clone(&app_context_cloned, app_context);
        @@ -114,23 +115,20 @@ bool equal = false;
         ret = app_context_is_equal(app_context, app_context_cloned, &equal);
         
         if (equal)
        -{
        -   // Contexts are equal
        -} 
        -else 
        -{
        -   // Contexts are not equal
        -}
        +    /* Contexts are equal */
        +else
        +    /* Contexts are not equal */
         
      23. When you no longer need the application context, call the app_context_destroy() function to remove the handle and release all resources to prevent memory leaks:

        -if (app_context) 
        -{
        -   ret = app_context_destroy(app_context);
        -   if (APP_MANAGER_ERROR_NONE != ret) // Error handling 
        -      app_context = NULL;
        +if (app_context) {
        +    ret = app_context_destroy(app_context);
        +    if (APP_MANAGER_ERROR_NONE != ret)
        +        /* Error handling */
        +
        +        app_context = NULL;
         }
         
      24. @@ -139,11 +137,6 @@ if (app_context)

        To get information on filtered applications:

          -
        1. To use the functions and data types of the Application Manager API (in mobile and wearable applications), include the <app_manager.h> header file in your application:

          -
          -#include <app_manager.h>
          -
        2. -
        3. Create the app_info_filter_h handle using the app_info_filter_create() function:
          @@ -161,37 +154,36 @@ ret = app_info_filter_add_string(app_info_filter, PACKAGE_INFO_PROP_APP_TYPE, &q
           
        4. Call the app_info_filter_foreach_appinfo() function and use its callback to retrieve all filtered applications and print their information:
          -bool 
          +bool
           filter_cb(app_info_filter_h app_info, void *user_data)
           {
          -   int ret;
          +    int ret;
           
          -   char *app_id = NULL;
          +    char *app_id = NULL;
           
          -   if (app_info_get_app_id(app_info, &app_id))
          -      return false;
          +    if (app_info_get_app_id(app_info, &app_id))
          +        return false;
           
          -   dlog_print(DLOG_INFO, TAG, "app_id \t= [%s]\n", app_id);
          +    dlog_print(DLOG_INFO, TAG, "app_id \t= [%s]\n", app_id);
           
          -   free(app_id);
          +    free(app_id);
           
          -   return true;
          +    return true;
           }
           
           ret = app_info_filter_foreach_appinfo(filter_cb, NULL);
           if (ret != APP_MANAGER_ERROR_NONE)
          -{
          -   dlog_print(DLOG_ERROR, TAG, "foreach_app_info_filter error: %d", ret);
          -}
          +    dlog_print(DLOG_ERROR, TAG, "foreach_app_info_filter error: %d", ret);
           
        5. When you no longer need the filter, call the app_info_filter_destroy() function to remove the handle and release all resources:
          -if (app_info_filter_h)
          -{
          -   ret = app_info_filter_destroy(app_info_filter_h);
          -   if (APP_MANAGER_ERROR_NONE != ret) // Error handling
          -      app_info_filter_h = NULL;
          +if (app_info_filter_h) {
          +    ret = app_info_filter_destroy(app_info_filter_h);
          +    if (APP_MANAGER_ERROR_NONE != ret)
          +        /* Error handling */
          +
          +        app_info_filter_h = NULL;
           }
           
        diff --git a/org.tizen.tutorials/html/native/app_framework/appcontrol_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/appcontrol_tutorial_n.htm index f656359..cc3efdd 100644 --- a/org.tizen.tutorials/html/native/app_framework/appcontrol_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/appcontrol_tutorial_n.htm @@ -23,6 +23,7 @@

        Content

        @@ -46,27 +47,29 @@

        Become familiar with the App Control API basics by learning about:

        +

        Prerequisites

        +

        To use the functions and data types of the App Control API (in mobile and wearable applications), include the <app_control.h> header file in your application:

        +
        +#include <app_control.h>
        +
        +

        Running Applications Using Extra Data

        To run a specific application control with some preconfigured parameters:

          -
        1. To use the functions and data types of the App Control API (in mobile and wearable applications), include the <app_control.h> header file in your application:

          -
          -#include <app_control.h>
          -
          -
        2. -
        3. Prepare the application control:

           ret = app_control_create(&app);
           if (ret != APP_CONTROL_ERROR_NONE)
          -   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_create() failed. err = %d", ret);
          +    dlog_print(DLOG_ERROR, LOG_TAG, "app_control_create() failed. err = %d", ret);
           
        4. @@ -75,11 +78,11 @@ if (ret != APP_CONTROL_ERROR_NONE)
           ret = app_control_set_operation(app, APP_CONTROL_OPERATION_VIEW);
           if (ret != APP_CONTROL_ERROR_NONE)
          -   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_set_operation() failed. err = %d", ret);
          +    dlog_print(DLOG_ERROR, LOG_TAG, "app_control_set_operation() failed. err = %d", ret);
           
           ret = app_control_set_mime(app, "image/jpeg");
           if (ret != APP_CONTROL_ERROR_NONE)
          -   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_set_mime() failed. err = %d", ret);
          +    dlog_print(DLOG_ERROR, LOG_TAG, "app_control_set_mime() failed. err = %d", ret);
           

          For more information on the common application services and the extra data related to them, see Common Application Controls.

          @@ -89,7 +92,7 @@ if (ret != APP_CONTROL_ERROR_NONE)
           ret = app_control_add_extra_data(app, Your Message Key, message);
           if (ret != APP_CONTROL_ERROR_NONE)
          -   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_add_extra_data() failed. err = %d", ret);
          +    dlog_print(DLOG_ERROR, LOG_TAG, "app_control_add_extra_data() failed. err = %d", ret);
           
        5. @@ -98,7 +101,7 @@ if (ret != APP_CONTROL_ERROR_NONE)
           ret = app_control_send_launch_request(app, NULL, NULL);
           if (ret != APP_CONTROL_ERROR_NONE)
          -   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_send_launch_request() failed. err = %d", ret);
          +    dlog_print(DLOG_ERROR, LOG_TAG, "app_control_send_launch_request() failed. err = %d", ret);
           
        @@ -115,26 +118,24 @@ if (ret != APP_CONTROL_ERROR_NONE)
      25. Read the extra data set to the app_control instance using the app_control_foreach_extra_data() function. The same function used on the app_control_h instance returned by the app_control reply allows you to read the reply message.

        -
        +
         bool
         _app_control_extra_data_cb(app_control_h app_control, const char *key, void *user_data)
         {
        -   int ret;
        -   char *value;
        -   
        -   ret = app_control_get_extra_data(app, key, &value);
        -   if (ret != APP_CONTROL_ERROR_NONE) 
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "app_control_get_extra_data() failed. err = %d", ret);
        -   }
        -   dlog_print(DLOG_DEBUG, LOG_TAG, "[value] %s", value);
        -
        -   return true;
        +    int ret;
        +    char *value;
        +
        +    ret = app_control_get_extra_data(app, key, &value);
        +    if (ret != APP_CONTROL_ERROR_NONE)
        +        dlog_print(DLOG_ERROR, LOG_TAG, "app_control_get_extra_data() failed. err = %d", ret);
        +    dlog_print(DLOG_DEBUG, LOG_TAG, "[value] %s", value);
        +
        +    return true;
         }
         
         ret = app_control_foreach_extra_data(app, _app_control_extra_data_cb, 0);
         if (ret != APP_CONTROL_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_foreach_extra_data() failed. err = %d", ret);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "app_control_foreach_extra_data() failed. err = %d", ret);
         
      26. @@ -145,7 +146,7 @@ if (ret != APP_CONTROL_ERROR_NONE)
         ret = app_control_destroy(app);
         if (ret != APP_CONTROL_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_destroy() failed. err = %d", ret);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "app_control_destroy() failed. err = %d", ret);
         
        @@ -158,61 +159,63 @@ if (ret != APP_CONTROL_ERROR_NONE)
        1. Create the UI with the Launch button:
          -static void 
          +static void
           create_base_gui(appdata_s *ad)
           {
          -   Evas_Object *bigbox, *bx, *bt;
          +    Evas_Object *bigbox;
          +    Evas_Object *bx;
          +    Evas_Object *bt;
           
          -   ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
          -   elm_win_autodel_set(ad->win, EINA_TRUE);
          +    ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
          +    elm_win_autodel_set(ad->win, EINA_TRUE);
           
          -   evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
          -   eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
          +    evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
          +    eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
           
          -   bigbox = elm_box_add(ad->win);
          -   evas_object_size_hint_weight_set(bigbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
          -   elm_win_resize_object_add(ad->win, bigbox);
          -   evas_object_show(bigbox);
          +    bigbox = elm_box_add(ad->win);
          +    evas_object_size_hint_weight_set(bigbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
          +    elm_win_resize_object_add(ad->win, bigbox);
          +    evas_object_show(bigbox);
           
          -   bx = elm_box_add(ad->win);
          -   elm_box_pack_end(bigbox, bx);
          -   evas_object_show(bx);
          +    bx = elm_box_add(ad->win);
          +    elm_box_pack_end(bigbox, bx);
          +    evas_object_show(bx);
           
          -   bt = elm_label_add(ad->win);
          -   elm_object_text_set(bt, "AGT3");
          -   elm_box_pack_end(bx, bt);
          -   evas_object_show(bt);
          +    bt = elm_label_add(ad->win);
          +    elm_object_text_set(bt, "AGT3");
          +    elm_box_pack_end(bx, bt);
          +    evas_object_show(bt);
           
          -   bt = elm_button_add(ad->win);
          -   elm_object_text_set(bt, "Launch");
          -   elm_box_pack_end(bx, bt);
          -   evas_object_show(bt);
          -   evas_object_smart_callback_add(bt, "clicked", button_click_cb, NULL);
          +    bt = elm_button_add(ad->win);
          +    elm_object_text_set(bt, "Launch");
          +    elm_box_pack_end(bx, bt);
          +    evas_object_show(bt);
          +    evas_object_smart_callback_add(bt, "clicked", button_click_cb, NULL);
           
          -   evas_object_show(ad->win);
          +    evas_object_show(ad->win);
           }
        2. When the button is clicked, use an application control to launch the sub application.

          Define the launch mode for the application to be called using the app_control_set_launch_mode() function. The second parameter defines the launch mode with the app_control_launch_mode_e enumerator (in mobile applications).

          -static void 
          +static void
           button_click_cb(void *data, Evas_Object *obj, void *event_info)
           {
          -   app_control_h h;
          +    app_control_h h;
           
          -   app_control_create(&h);
          -   app_control_set_operation(h, "http://tizen.org/appcontrol/operation/view");
          -   app_control_set_mime(h, "application/pdf");
          -   app_control_set_launch_mode(h, APP_CONTROL_LAUNCH_MODE_GROUP);
          -   app_control_send_launch_request(h, NULL, NULL);
          +    app_control_create(&h);
          +    app_control_set_operation(h, "http://tizen.org/appcontrol/operation/view");
          +    app_control_set_mime(h, "application/pdf");
          +    app_control_set_launch_mode(h, APP_CONTROL_LAUNCH_MODE_GROUP);
          +    app_control_send_launch_request(h, NULL, NULL);
           
          -   app_control_destroy(h);
          +    app_control_destroy(h);
           }
           
          -static void 
          +static void
           app_control(app_control_h app_control, void *data)
           {
          -   // Handle the launch request
          +    /* Handle the launch request */
           }
           
        3. diff --git a/org.tizen.tutorials/html/native/app_framework/application_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/application_tutorial_n.htm index 5c831ae..b21fd6e 100644 --- a/org.tizen.tutorials/html/native/app_framework/application_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/application_tutorial_n.htm @@ -23,6 +23,7 @@ - +
          @@ -45,6 +46,8 @@

          Become familiar with the Application API basics by learning about:

          @@ -57,9 +60,17 @@
        4. Preference: Managing Preferences

          Manage application preferences.

        5. Event: Managing Events (in mobile applications only) -

          Broadcast and subscribe to system and user-defined events.

        6. +

          Broadcast and subscribe to system and user-defined events.

          +
        7. Resource Manager: Setting and Getting Resources (in mobile applications only) +

          Set resources and get the resource file path.

        8. +

          Prerequisites

          +

          To use the functions and data types of the Application API (in mobile and wearable applications), include the <app.h> header file in your application:

          +
          +#include <app.h>
          +
          +

          Handling the Application Fundamentals

          The Application API is a simple framework all Tizen applications are based on. It only handles interactions between applications and the operating system.

          @@ -69,17 +80,14 @@

          Start the application with the main() function. It initializes the Application API and starts the application.

          The following code is a minimal application using the Application API. It only builds and runs.

          -// Add this include to be able to use the functions from the Application API
          -#include <app.h>
          -
           int
           main(int argc, char *argv[])
           {
          -   // Create a ui_app_lifecycle_callback_s object and initialize its contents to 0
          -   ui_app_lifecycle_callback_s event_callback = {0,};
          +    /* Create a ui_app_lifecycle_callback_s object and initialize its contents to 0 */
          +    ui_app_lifecycle_callback_s event_callback = {0,};
           
          -   // Run the application
          -   return ui_app_main(&argc, &argv, &event_callback, NULL);
          +    /* Run the application */
          +    return ui_app_main(&argc, &argv, &event_callback, NULL);
           }
           
          @@ -110,81 +118,84 @@ main(int argc, char *argv[])

          The following example shows a basic application state callback implementation:

          -#include <app.h>
          -
          -// Structure to store the data for application logic; it is given
          -// to each callback invoked through the Application API
          -typedef struct 
          -appdata 
          -{
          -   char *several;
          -   char *fields;
          -} appdata_s;
          +/*
          +   Structure to store the data for application logic; it is given
          +   to each callback invoked through the Application API
          +*/
          +struct appdata {
          +    char *several;
          +    char *fields;
          +};
          +typedef struct appdata appdata_s;
           
           static bool
           app_create(void *data)
           {
          -   // Hook to take necessary actions before main event loop starts; this
          -   // usually means initializing the UI and application data (the "data"
          -   // parameter to this function)
          -
          -   appdata_s *ad = data;
          -   create_gui(ad);
          -
          -   // If this function returns true, the main loop starts
          -   // If this function returns false, the application is terminated
          -   return true;
          +    /*
          +       Hook to take necessary actions before main event loop starts; this
          +       usually means initializing the UI and application data (the "data"
          +       parameter to this function)
          +    */
          +
          +    appdata_s *ad = data;
          +    create_gui(ad);
          +
          +    /* If this function returns true, the main loop starts */
          +    /* If this function returns false, the application is terminated */
          +    return true;
           }
           
           static void
           app_control(app_control_h app_control, void *data)
           {
          -   // Handle the launch request, show the user the task requested through the
          -   // "app_control" parameter (see the next step)
          +    /*
          +       Handle the launch request, show the user the task requested through the
          +       "app_control" parameter (see the next step)
          +    */
           }
           
           static void
           app_pause(void *data)
           {
          -   // Take necessary actions when application becomes invisible
          +    /* Take necessary actions when application becomes invisible */
           }
           
           static void
           app_resume(void *data)
           {
          -   // Take necessary actions when application becomes visible
          +    /* Take necessary actions when application becomes visible */
           }
           
           static void
           app_terminate(void *data)
           {
          -   // Release all resources
          -   appdata_s *ad = data;
          +    /* Release all resources */
          +    appdata_s *ad = data;
           
          -   if (!ad) 
          -   {
          -      return;
          -   }
          +    if (!ad)
          +        return;
           
          -   // If specific steps are needed:
          -   // destroy_gui(ad);
          +    /*
          +       If specific steps are needed:
          +       destroy_gui(ad);
          +    */
           }
           
           int
           main(int argc, char *argv[])
           {
          -   appdata_s ad = {0,};
          -   ui_app_lifecycle_callback_s event_callback = {0,};
          -
          -   // Set the callbacks for the application logic
          -   event_callback.create = app_create;
          -   event_callback.terminate = app_terminate;
          -   event_callback.pause = app_pause;
          -   event_callback.resume = app_resume;
          -   event_callback.app_control = app_control;
          -
          -   // Note the &ad below is how the struct is given to the callbacks
          -   return ui_app_main(argc, argv, &event_callback, &ad);
          +    appdata_s ad = {0,};
          +    ui_app_lifecycle_callback_s event_callback = {0,};
          +
          +    /* Set the callbacks for the application logic */
          +    event_callback.create = app_create;
          +    event_callback.terminate = app_terminate;
          +    event_callback.pause = app_pause;
          +    event_callback.resume = app_resume;
          +    event_callback.app_control = app_control;
          +
          +    /* Note the &ad below is how the struct is given to the callbacks */
          +    return ui_app_main(argc, argv, &event_callback, &ad);
           }
           
          diff --git a/org.tizen.tutorials/html/native/app_framework/attach_panel_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/attach_panel_tutorial_n.htm index 1b0b978..bc0ee83 100644 --- a/org.tizen.tutorials/html/native/app_framework/attach_panel_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/attach_panel_tutorial_n.htm @@ -23,7 +23,7 @@ -
          +
          @@ -47,21 +47,33 @@

          Warm-up

          Become familiar with the Attach panel API basics by learning about:

          +

          Prerequisites

          -

          Initializing an Attach Panel

          - -

          To initialize an attach panel for use:

          -
            -
          1. -

            To use the functions and data types of the Attach panel API, include the <attach_panel.h> header file in your application:

            +

            To enable your application to use the attach panel functionality:

            +
              +
            1. +

              To use the Attach panel API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

              +
              +<privileges>
              +   <!--To add the image viewer, camera, or voice recorder UI gadget in the attach panel-->
              +   <privilege>http://tizen.org/privilege/mediastorage</privilege>
              +   <privilege>http://tizen.org/privilege/camera</privilege>
              +   <privilege>http://tizen.org/privilege/recorder</privilege>
              +   <!--To launch apps from the More tab-->
              +   <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
              +</privileges>
              +
              +
            2. +
            3. +

              To use the functions and data types of the Attach panel API, include the <attach_panel.h> header file in your application:

               #include <attach_panel.h>
               
              @@ -70,41 +82,29 @@

              Declare global variables.

              To create and manage an attach panel, you must create variables for a conformant and the attach panel.

              -static struct 
              -{
              -   Evas_Object *conformant;
              -   attach_panel_h attach_panel;
              -} s_info = 
              +static struct {
              +    Evas_Object *conformant;
              +    attach_panel_h attach_panel;
              +} s_info =
               {
              -   .conformant = NULL,
              -   .attach_panel = NULL,
              +    .conformant = NULL,
              +    .attach_panel = NULL,
               };
               
              -static void 
              +static void
               _create_conformant(Evas_Object *win)
               {
              -   Evas_Object *conformant = NULL;
              -   conformant = elm_conformant_add(win);
              -   evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
              -   elm_win_resize_object_add(win, conformant);
              -   elm_win_conformant_set(win, EINA_TRUE);
              -   evas_object_show(conformant);
              -
              -   s_info.conformant = conformant;
              +    Evas_Object *conformant = NULL;
              +    conformant = elm_conformant_add(win);
              +    evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
              +    elm_win_resize_object_add(win, conformant);
              +    elm_win_conformant_set(win, EINA_TRUE);
              +    evas_object_show(conformant);
              +
              +    s_info.conformant = conformant;
               }
               
            4. -
            5. -

              If you want to add the camera or voice recorder UI gadget in the attach panel, or add an application to be launched from the More tab, set the applicable privileges in the manifest file of your application:

              -
              -<privileges>
              -   <privilege>http://tizen.org/privilege/camera</privilege>
              -   <privilege>http://tizen.org/privilege/recorder</privilege>
              -   <!--Launch privilege allows you to launch apps from the More tab-->
              -   <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
              -</privileges>
              -
              -

            Creating an Attach Panel

            @@ -121,9 +121,7 @@ int ret = ATTACH_PANEL_ERROR_NONE; ret = attach_panel_create(s_info.conformant, &attach_panel); if (ret != ATTACH_PANEL_ERROR_NONE || !attach_panel) -{ -   // Error handling -} +    /* Error handling */ attach_panel_show(attach_panel); s_info.attach_panel = attach_panel; @@ -136,10 +134,8 @@ s_info.attach_panel = attach_panel; bundle *extra_data = NULL; extra_data = bundle_create(); -if (!extra_data) -{ -   // Error handling -} +if (!extra_data) +    /* Error handling */ bundle_add_str(extra_data, http://tizen.org/appcontrol/data/total_count, "3"); @@ -163,62 +159,52 @@ bundle_free(extra_data);
          2. To get the published events from the panel side, register a callback using the attach_panel_set_event_cb() function. The callback is triggered when reserved events (defined in the attach_panel_event enumerator) are published from the panel side.
          3. -static void 
            -_result_cb(attach_panel_h attach_panel, attach_panel_content_category_e content_category, 
            +static void
            +_result_cb(attach_panel_h attach_panel, attach_panel_content_category_e content_category,
                        app_control_h result, app_control_result_e result_code, void *data)                                 
             {
            -   char **select = NULL;
            -   int i = 0;
            -   int length = 0;
            -   int ret = APP_CONTROL_ERROR_NONE;
            -   if (!result) 
            -   {
            -      // Error handling
            -   }
            -   if (APP_CONTROL_RESULT_SUCCEEDED != result_code) 
            -   {
            -      // Error handling
            -   }
            -   ret = app_control_get_extra_data_array(result, "http://tizen.org/appcontrol/data/selected", &select, &length);
            -   if (APP_CONTROL_ERROR_NONE != ret || !select) 
            -   {
            -      // Error handling
            -   }
            -
            -   for (; i < length; i++) 
            -   {
            -      printf("path is %s, %d\n", select[i], length);
            -      free(select[i]);
            -   }
            -   free(select);
            +    char **select = NULL;
            +    int i = 0;
            +    int length = 0;
            +    int ret = APP_CONTROL_ERROR_NONE;
            +    if (!result)
            +        /* Error handling */
            +    if (APP_CONTROL_RESULT_SUCCEEDED != result_code)
            +        /* Error handling */
            +    ret = app_control_get_extra_data_array(result, "http://tizen.org/appcontrol/data/selected", &select, &length);
            +    if (APP_CONTROL_ERROR_NONE != ret || !select)
            +        /* Error handling */
            +
            +    for (; i < length; i++) {
            +        printf("path is %s, %d\n", select[i], length);
            +        free(select[i]);
            +    }
            +    free(select);
             }
             
            -static void 
            +static void
             _event_cb(attach_panel_h attach_panel, attach_panel_event_e event, void *event_info, void *data)
             {
            -   int ret = 0;
            -   if (!) 
            -   {
            -      // Error handling
            -   }
            -   switch (event) 
            -   {
            -      case ATTACH_PANEL_EVENT_SHOW_START:
            -         break;
            -      case ATTACH_PANEL_EVENT_SHOW_FINISH:
            -         break;
            -      case ATTACH_PANEL_EVENT_HIDE_START:
            -         break;
            -      case ATTACH_PANEL_EVENT_HIDE_FINISH:
            -         break;
            -   }
            +    int ret = 0;
            +    if (!)
            +        /* Error handling */
            +    switch (event) {
            +    case ATTACH_PANEL_EVENT_SHOW_START:
            +        break;
            +    case ATTACH_PANEL_EVENT_SHOW_FINISH:
            +        break;
            +    case ATTACH_PANEL_EVENT_HIDE_START:
            +        break;
            +    case ATTACH_PANEL_EVENT_HIDE_FINISH:
            +        break;
            +    }
             }
             
            -static int 
            +static int
             app_control(void *data)
             {
            -   attach_panel_set_result_cb(s_info.attach_panel, _result_cb, NULL);
            -   attach_panel_set_event_cb(s_info.attach_panel, _event_cb, NULL);
            +    attach_panel_set_result_cb(s_info.attach_panel, _result_cb, NULL);
            +    attach_panel_set_event_cb(s_info.attach_panel, _event_cb, NULL);
             }
             
            @@ -229,23 +215,22 @@ app_control(void *data)
             bool visible = false;
             
            -if (s_info.attach_panel) 
            -{
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_IMAGE);
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CAMERA);
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_VOICE);
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_VIDEO);
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_AUDIO);
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CALENDAR);
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CONTACT);
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_MYFILES);
            -   attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_VIDEO_RECORDER);
            -
            -   attach_panel_unset_result_cb(s_info.attach_panel);
            -   attach_panel_unset_event_cb(s_info.attach_panel);
            -
            -   attach_panel_destroy(s_info.attach_panel);
            -   s_info.attach_panel = NULL;
            +if (s_info.attach_panel) {
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_IMAGE);
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CAMERA);
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_VOICE);
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_VIDEO);
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_AUDIO);
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CALENDAR);
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CONTACT);
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_MYFILES);
            +    attach_panel_remove_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_VIDEO_RECORDER);
            +
            +    attach_panel_unset_result_cb(s_info.attach_panel);
            +    attach_panel_unset_event_cb(s_info.attach_panel);
            +
            +    attach_panel_destroy(s_info.attach_panel);
            +    s_info.attach_panel = NULL;
             }
             
            @@ -261,25 +246,21 @@ if (s_info.attach_panel)
          4. To set some information to the content category after adding the category, use the attach_panel_set_extra_data() function, which sets extra data to send to the content category using a bundle:
            -static void 
            +static void
             _reset_bundle(void *data)
             {
            -   bundle *extra_data = NULL;
            -   int ret = APP_CONTROL_ERROR_NONE;
            -
            -   extra_data = bundle_create();
            -   if (!extra_data) 
            -   {
            -      // Error handling
            -   }
            -
            -   bundle_add_str(extra_data, http://tizen.org/appcontrol/data/total_count, "5");
            -   ret = attach_panel_set_extra_data(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_IMAGE, extra_data);
            -   if (ATTACH_PANEL_ERROR_NONE != ret) 
            -   {
            -      // Error handling
            -   }
            -   bundle_free(extra_data);
            +    bundle *extra_data = NULL;
            +    int ret = APP_CONTROL_ERROR_NONE;
            +
            +    extra_data = bundle_create();
            +    if (!extra_data)
            +        /* Error handling */
            +
            +    bundle_add_str(extra_data, http://tizen.org/appcontrol/data/total_count, "5");
            +    ret = attach_panel_set_extra_data(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_IMAGE, extra_data);
            +    if (ATTACH_PANEL_ERROR_NONE != ret)
            +        /* Error handling */
            +    bundle_free(extra_data);
             }
             
          5. To show or hide the attach panel, use the attach_panel_show() and attach_panel_hide() functions: @@ -288,20 +269,15 @@ _reset_bundle(void *data) attach_panel_h attach_panel; int ret = ATTACH_PANEL_ERROR_NONE; -if (s_info.attach_panel) -{ -   attach_panel_hide(s_info.attach_panel); -} -else -{ -   ret = attach_panel_create(s_info.conformant, &attach_panel); -   if(ret != ATTACH_PANEL_ERROR_NONE || !attach_panel) -   { -      // Error handling -   } -   attach_panel_add_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CAMERA, NULL); -   attach_panel_show(attach_panel); -   s_info.attach_panel = attach_panel; +if (s_info.attach_panel) { +    attach_panel_hide(s_info.attach_panel); +} else { +    ret = attach_panel_create(s_info.conformant, &attach_panel); +    if (ret != ATTACH_PANEL_ERROR_NONE || !attach_panel) +        /* Error handling */ +    attach_panel_add_content_category(s_info.attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CAMERA, NULL); +    attach_panel_show(attach_panel); +    s_info.attach_panel = attach_panel; }
          6. To know whether the attach panel is visible, use the attach_panel_get_visibility() function. It fills the second parameter with a Boolean value that shows whether the panel is visible. @@ -309,17 +285,12 @@ else
             bool visible = false;
             
            -if (s_info.attach_panel) 
            -{
            -   attach_panel_get_visibility(s_info.attach_panel, &visible);
            -   if (visible) 
            -   {
            -      attach_panel_hide(s_info.attach_panel);
            -   } 
            -   else 
            -   {
            -      attach_panel_show(s_info.attach_panel);
            -   }
            +if (s_info.attach_panel) {
            +    attach_panel_get_visibility(s_info.attach_panel, &visible);
            +    if (visible)
            +        attach_panel_hide(s_info.attach_panel);
            +    else
            +        attach_panel_show(s_info.attach_panel);
             }
             
          7. diff --git a/org.tizen.tutorials/html/native/app_framework/badge_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/badge_tutorial_n.htm index 6a7c5b0..371c638 100644 --- a/org.tizen.tutorials/html/native/app_framework/badge_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/badge_tutorial_n.htm @@ -23,7 +23,7 @@

            Content

            @@ -47,8 +47,8 @@

            Become familiar with the Badge API basics by learning about:

            -

            Initializing the Badge Functionality

            +

            Prerequisites

            -

            To initialize the badge functionality:

            +

            To enable your application to use the badge functionality:

              -
            1. To use the functions and data types of the Badge API (in mobile and wearable applications), include the <badge.h> header file in your application:

              +
            2. +

              To use the Badge API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

              +
              +<privileges>
              +   <privilege>http://tizen.org/privilege/notification</privilege>
              +</privileges>
              +
              +
            3. +
            4. To use the functions and data types of the Badge API, include the <badge.h> header file in your application:

               #include <stdio.h>
               #include <stdlib.h>
              @@ -71,14 +79,14 @@
               

              To ensure that a Badge function has been executed properly, make sure that the return is equal to BADGE_ERROR_NONE.

            5. -
            6. Add the http://tizen.org/privilege/notification privilege to the manifest file of the application to manage badges.
            7. Declare the variables for the return value and application (package name):
               static int ret = 0;
               
              -#define TEST_PKG "org.tizen.badgeapp"
              +#define TEST_PKG "org.tizen.badgeapp" +

            Creating and Removing a Badge

            @@ -91,9 +99,7 @@ static int ret = 0;
             ret = badge_add(TEST_PKG);
             if (ret != BADGE_ERROR_NONE)
            -{
            -   // Error handling
            -}
            +    /* Error handling */
             
          8. @@ -102,9 +108,7 @@ if (ret != BADGE_ERROR_NONE)
             ret = badge_remove(TEST_PKG);
             if (ret != BADGE_ERROR_NONE)
            -{
            -   // Error handling
            -}
            +    /* Error handling */
             
          9. Managing the Badge

            @@ -118,9 +122,7 @@ if (ret != BADGE_ERROR_NONE) unsigned int count = 0; ret = badge_get_count(TEST_PKG, &count); if (ret != BADGE_ERROR_NONE) -{ -   // Error handling -} +    /* Error handling */ @@ -129,9 +131,7 @@ if (ret != BADGE_ERROR_NONE)
             ret = badge_set_count(TEST_PKG, count+1);
             if (ret != BADGE_ERROR_NONE)
            -{
            -   // Error handling
            -}
            +    /* Error handling */
             
          10. Get the display attribute and check whether the badge is visible with the badge_get_display() function. @@ -140,9 +140,7 @@ if (ret != BADGE_ERROR_NONE) unsigned int is_displayed = false; ret = badge_get_display(TEST_PKG, &is_displayed); if (ret != BADGE_ERROR_NONE) -{ -   // Error handling -} +    /* Error handling */
          11. Set the display attribute with the badge_set_display() function to hide or show the badge. @@ -150,9 +148,7 @@ if (ret != BADGE_ERROR_NONE)
             ret = badge_set_display(TEST_PKG, 1);
             if (ret != BADGE_ERROR_NONE)
            -{
            -   // Error handling
            -}
            +    /* Error handling */
             
          12. diff --git a/org.tizen.tutorials/html/native/app_framework/bundle_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/bundle_tutorial_n.htm index 1356049..4406b39 100644 --- a/org.tizen.tutorials/html/native/app_framework/bundle_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/bundle_tutorial_n.htm @@ -23,7 +23,7 @@

            Content

              -
            • Initializing a Bundle
            • +
            • Prerequisites
            • Content management
              • Adding Content to a Bundle
              • @@ -50,8 +50,8 @@

                Warm-up

                Become familiar with the Bundle API basics by learning about:

                  -
                • Initializing a Bundle -

                  Initialize a bundle for use.

                • +
                • Prerequisites +

                  Prepare your application to use the bundle functionality.

                • Content management -

                  Initializing a Bundle

                  +

                  Prerequisites

                  -

                  To initialize a bundle:

                  +

                  To enable your application to use the bundle functionality:

                  1. To use the functions and data types of the Bundle API (in mobile and wearable applications), include the <bundle.h> header file in your application:

                    @@ -78,13 +78,17 @@
                  2. Before you can perform any operations on a bundle, create the bundle instance. Each bundle is independent from other bundles and stores its own set of records.

                    -
                    bundle* bund = NULL;
                    +
                    +bundle* bund = NULL;
                     
                    -bund = bundle_create();
                    +bund = bundle_create(); +
                  3. When no longer needed, release the bundle by calling the bundle_free() function:

                    -
                    bundle_free(bund);
                    +
                    +bundle_free(bund);
                    +
                  @@ -127,9 +131,9 @@ bund = bundle_create(); const char* array [3] = {"Var1", "Var2", "Var3"}; int array_len = 3; -bundle_add_str(bund, "Str", "String content"); +bundle_add_str(bund, "Str", "String content"); -bundle_add_str_array(bund, "Array", array, array_len); +bundle_add_str_array(bund, "Array", array, array_len); bundle_add_byte(bund, "Byte", "Byte content", 12); @@ -153,29 +157,29 @@ bundle_add_byte(bund, "Byte", "Byte content", 12);

                  You can also get the number of bundle items with the bundle_get_count() function, and the type of a value with a specific key with the bundle_get_type() function.

                  -void 
                  +void
                   test_bundle_add_del_get(void)
                   {
                  -   bundle *b = NULL;
                  -   int count = 0;
                  -   char *value;
                  +    bundle *b = NULL;
                  +    int count = 0;
                  +    char *value;
                   
                  -   b = bundle_create();
                  +    b = bundle_create();
                   
                  -   bundle_add_str(b, "key1", "val1");
                  -   bundle_add_str(b, "key2", "val2");
                  -   bundle_get_str(b, "key2", &value);
                  -   dlog_print(DLOG_DEBUG, LOG_TAG, "the value of key2: %s", value);
                  +    bundle_add_str(b, "key1", "val1");
                  +    bundle_add_str(b, "key2", "val2");
                  +    bundle_get_str(b, "key2", &value);
                  +    dlog_print(DLOG_DEBUG, LOG_TAG, "the value of key2: %s", value);
                   
                  -   count = bundle_get_count(b);
                  -   dlog_print(DLOG_DEBUG, LOG_TAG, "the number of bundle items: %d", count);
                  +    count = bundle_get_count(b);
                  +    dlog_print(DLOG_DEBUG, LOG_TAG, "the number of bundle items: %d", count);
                   
                • Delete a key-value pair from the bundle content using the bundle_del() function:
                  -   bundle_del(b, "key2");
                  +    bundle_del(b, "key2");
                   
                  -   bundle_free(b);
                  +    bundle_free(b);
                   }
                   
                • @@ -189,59 +193,53 @@ test_bundle_add_del_get(void)

                  After the bundle_foreach() function call, the callback function is invoked for each record in the bundle:

                  -void 
                  +void
                   iterate_bundle_foreach(const char *key, const int type, bundle_keyval_t *kv, void *user_data)
                   {
                  -   dlog_print(DLOG_DEBUG, LOG_TAG, "key: %s, type: %d ", key, type);
                  -    
                  -   void *ptr = NULL;
                  -   char *buff = NULL;
                  -   unsigned int size = 0;
                  -   if (type == BUNDLE_TYPE_STR) 
                  -   {
                  -      bundle_keyval_get_basic_val((bundle_keyval_t *) kv, &ptr, &size);
                  -      buff = malloc(sizeof(char)* size + 1);
                  -      snprintf(buff, size + 1, "%s", ((char*) ptr));
                  -      dlog_print(DLOG_DEBUG, LOG_TAG, "Found STR -KEY: %s, VAL: %s, SIZE: %d", key, buff, size);
                  -      free(buff);
                  -   } 
                  -   else if (type == BUNDLE_TYPE_BYTE) 
                  -   { 
                  -      bundle_keyval_get_basic_val((bundle_keyval_t *) kv, &ptr, &size);
                  -      buff = malloc(sizeof(char)* size + 1);
                  -      snprintf(buff, size + 1, "%s", ((char*) ptr));
                  -      dlog_print(DLOG_DEBUG, LOG_TAG, "Found STR -KEY: %s, VAL: %s, SIZE: %d", key, buff, size);
                  -      free(buff);
                  -   } 
                  -   else if (type == BUNDLE_TYPE_STR_ARRAY) 
                  -   { 
                  -      void ** array;
                  -      unsigned int len = 0;
                  -      size_t *element_size = NULL;
                  -      dlog_print(DLOG_DEBUG, LOG_TAG, "Found STR_ARRAY -KEY: %s", key);
                  -      bundle_keyval_get_array_val((bundle_keyval_t *) kv, &array, &len, &element_size);
                  -      dlog_print(DLOG_DEBUG, LOG_TAG, "-Array len: %d", len);
                  -      for (int i = 0; i < len; i++) 
                  -      { 
                  -         dlog_print(DLOG_DEBUG, LOG_TAG, "-%s", (char*)array[i]);
                  -      }
                  -   }    
                  +    dlog_print(DLOG_DEBUG, LOG_TAG, "key: %s, type: %d ", key, type);
                  +
                  +    void *ptr = NULL;
                  +    char *buff = NULL;
                  +    unsigned int size = 0;
                  +    if (type == BUNDLE_TYPE_STR) {
                  +        bundle_keyval_get_basic_val((bundle_keyval_t *)kv, &ptr, &size);
                  +        buff = malloc(sizeof(char)* size + 1);
                  +        snprintf(buff, size + 1, "%s", ((char*)ptr));
                  +        dlog_print(DLOG_DEBUG, LOG_TAG, "Found STR -KEY: %s, VAL: %s, SIZE: %d", key, buff, size);
                  +        free(buff);
                  +    } else if (type == BUNDLE_TYPE_BYTE) {
                  +        bundle_keyval_get_basic_val((bundle_keyval_t *)kv, &ptr, &size);
                  +        buff = malloc(sizeof(char)* size + 1);
                  +        snprintf(buff, size + 1, "%s", ((char*)ptr));
                  +        dlog_print(DLOG_DEBUG, LOG_TAG, "Found STR -KEY: %s, VAL: %s, SIZE: %d", key, buff, size);
                  +        free(buff);
                  +    } else if (type == BUNDLE_TYPE_STR_ARRAY) {
                  +        void ** array;
                  +        unsigned int len = 0;
                  +        size_t *element_size = NULL;
                  +        dlog_print(DLOG_DEBUG, LOG_TAG, "Found STR_ARRAY -KEY: %s", key);
                  +        bundle_keyval_get_array_val((bundle_keyval_t *)kv, &array, &len, &element_size);
                  +        dlog_print(DLOG_DEBUG, LOG_TAG, "-Array len: %d", len);
                  +        for (int i = 0; i < len; i++)
                  +            dlog_print(DLOG_DEBUG, LOG_TAG, "-%s", (char*)array[i]);
                  +    }
                   }
                   
                  -void 
                  +void
                   test_bundle_foreach(void)
                   {
                  -   const char *s_arr[] = {"abc", "bcd", "cde"};
                  -   bundle *b;
                  -   b = bundle_create();
                  +    const char *s_arr[] = {"abc", "bcd", "cde"};
                  +    bundle *b;
                  +    b = bundle_create();
                   
                  -   bundle_add_str(b, "k1", "v1");
                  -   bundle_add_byte(b, "k2", "v2", 3);  
                  -   bundle_add_str_array(b, "k3", s_arr, 3);
                  -  
                  -   bundle_foreach(b, iterate_bundle_foreach, NULL);
                  -   bundle_free(b);
                  -}
                  +    bundle_add_str(b, "k1", "v1"); +    bundle_add_byte(b, "k2", "v2", 3); +    bundle_add_str_array(b, "k3", s_arr, 3); + +    bundle_foreach(b, iterate_bundle_foreach, NULL); +    bundle_free(b); +} +

                  Encoding and Decoding a Bundle

                  @@ -249,31 +247,32 @@ test_bundle_foreach(void)

                  To open the encoded bundle, use the bundle_decode() function. When you no longer need them, release the encoded data and the created bundle.

                  -void 
                  +void
                   test_bundle_encode_decode(void)
                   {
                  -   bundle *b1, *b2;
                  -   bundle_raw *r;
                  -   int size_r;
                  -   char *value;
                  +    bundle *b1;
                  +    bundle *b1;
                  +    bundle_raw *r;
                  +    int size_r;
                  +    char *value;
                   
                  -   b1 = bundle_create();
                  -   bundle_add_str(b1, "k1", "v1");
                  -   bundle_add_str(b1, "k2", "v2");
                  +    b1 = bundle_create();
                  +    bundle_add_str(b1, "k1", "v1");
                  +    bundle_add_str(b1, "k2", "v2");
                   
                  -   bundle_encode(b1, &r, &size_r);
                  +    bundle_encode(b1, &r, &size_r);
                   
                  -   b2 = bundle_decode(r, size_r);
                  +    b2 = bundle_decode(r, size_r);
                   
                  -   bundle_get_str(b1, "k1", &value);
                  -   dlog_print(DLOG_DEBUG, LOG_TAG, "value of k1 after decode: %s", value);
                  +    bundle_get_str(b1, "k1", &value);
                  +    dlog_print(DLOG_DEBUG, LOG_TAG, "value of k1 after decode: %s", value);
                   
                  -   bundle_free(b1);
                  -   bundle_free(b2);
                  +    bundle_free(b1);
                  +    bundle_free(b2);
                   }
                   
                  - + diff --git a/org.tizen.tutorials/html/native/app_framework/data_control_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/data_control_tutorial_n.htm index 85d59eb..caacc96 100644 --- a/org.tizen.tutorials/html/native/app_framework/data_control_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/data_control_tutorial_n.htm @@ -23,7 +23,7 @@

                  Content

                  @@ -47,8 +47,8 @@

                  Warm-up

                  Become familiar with the Data Control API basics by learning about:

                  -

                  Initializing Data Controls

                  -

                  To initialize data controls:

                  +

                  Prerequisites

                  + +

                  To enable your application to use the data control functionality:

                  1. -

                    To use the functions and data types of the Data Control API (in mobile and wearable applications), include the <data_control.h> header file in your application:

                    +

                    To use the Data Control API (in mobile and wearable applications), the consumer application has to request permission by adding the following privileges to the tizen-manifest.xml file:

                    +
                    +<privileges>
                    +   <privilege>http://tizen.org/privilege/datasharing</privilege>
                    +   <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
                    +</privileges>
                    +
                    +
                  2. +
                  3. +

                    The data control use cases run 2 applications. Each application plays a different role: one for the consumer, another for the provider.

                    +

                    For the provider application, in the IDE, double-click tizen-manifest.xml, and in the Tizen Manifest Editor, go to Advanced > Data Control > Add. Add the Read and Write access rights to both SQL and Map types.

                    +
                  4. +
                  5. +

                    To use the functions and data types of the Data Control API, include the <data_control.h> header file in your application:

                     #include <data_control.h>
                     
                    @@ -71,14 +85,6 @@
                     

                    To execute this application, the <sqlite3.h>, <stdlib.h>, <glib.h>, and <string.h> header files have to be included too.

                  6. - -
                  7. -

                    The data control use cases run 2 applications. Each application plays a different role: one for the consumer, another for the provider.

                    -
                      -
                    • For the consumer application, add the http://tizen.org/privilege/datasharing and http://tizen.org/privilege/appmanager.launch privileges to the manifest file of the application.
                    • -
                    • For the provider application, in the IDE, double-click tizen-manifest.xml, and in the Tizen Manifest Editor, go to Advanced > Data Control > Add. Add the Read and Write access rights to both SQL and Map types. -
                    -

                  Working with Map-type Data Controls

                  @@ -90,205 +96,170 @@

                  The provider application stores and provides data to the consumer application. The provider application has 4 operations: get, add, remove, and set. To use the map-type Data Control API, these 4 operation callbacks must be implemented.

                  -typedef struct 
                  -map_data
                  -{
                  -   char **str_arr;
                  -   int arr_size;
                  -} map_data_s;
                  +struct map_data {
                  +    char **str_arr;
                  +    int arr_size;
                  +};
                  +typedef struct map_data map_data_s;
                   
                   static GHashTable *map_repository_test;
                  -void 
                  +void
                   get_value_request_cb(int request_id, data_control_h provider, const char *key, void *user_data)
                   {
                  -   map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key);
                  -
                  -   int ret_value_count = 0;
                  -   char **val_arr = NULL;
                  -   if (map_data != NULL)
                  -   {
                  -      val_arr = map_data->str_arr;
                  -      ret_value_count = map_data->arr_size;
                  -   }
                  -
                  -   int ret = data_control_provider_send_map_get_value_result(request_id, val_arr, ret_value_count);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "send_map_get_result failed with error: %d", ret);
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Get value success request_id: %d", request_id);
                  -   }
                  +    map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key);
                  +
                  +    int ret_value_count = 0;
                  +    char **val_arr = NULL;
                  +    if (map_data != NULL) {
                  +        val_arr = map_data->str_arr;
                  +        ret_value_count = map_data->arr_size;
                  +    }
                  +
                  +    int ret = data_control_provider_send_map_get_value_result(request_id, val_arr, ret_value_count);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "send_map_get_result failed with error: %d", ret);
                  +    else
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Get value success request_id: %d", request_id);
                   }
                   
                  -void 
                  -set_value_request_cb(int request_id, data_control_h provider, const char *key, 
                  +void
                  +set_value_request_cb(int request_id, data_control_h provider, const char *key,
                                        const char *old_value, const char *new_value, void *user_data)
                   {
                  -   map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key);
                  -   if (map_data != NULL)
                  -   {
                  -      for (int i = 0; i < map_data->arr_size; i++)
                  -      {
                  -         if (strcmp(map_data->str_arr[i], old_value) == 0)
                  -         {
                  -            map_data->str_arr[i] = g_strdup(new_value);
                  -         }
                  -      }
                  -   }
                  -
                  -   int ret = data_control_provider_send_map_result(request_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "send_map_result failed with error: %d", ret);
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Set value success request_id: %d", request_id);
                  -   }
                  +    map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key);
                  +    if (map_data != NULL) {
                  +        for (int i = 0; i < map_data->arr_size; i++) {
                  +            if (strcmp(map_data->str_arr[i], old_value) == 0)
                  +                map_data->str_arr[i] = g_strdup(new_value);
                  +        }
                  +    }
                  +
                  +    int ret = data_control_provider_send_map_result(request_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "send_map_result failed with error: %d", ret);
                  +    else
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Set value success request_id: %d", request_id);
                   }
                   
                  -void 
                  -add_value_request_cb(int request_id, data_control_h provider, const char *key, 
                  +void
                  +add_value_request_cb(int request_id, data_control_h provider, const char *key,
                                        const char *value, void *user_data)
                   {
                  -   map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key);
                  -
                  -   if (map_data == NULL)
                  -   {
                  -      map_data = (map_data_s*)(g_malloc(sizeof(*map_data)));
                  -      map_data->arr_size = 0;
                  -      map_data->str_arr = (char**) calloc(1, sizeof(char*));
                  -      map_data->str_arr[0] = g_strdup(value);
                  -      g_hash_table_insert(map_repository_test, g_strdup(key), map_data);
                  -   }
                  -   else
                  -   {
                  -      char **new_arr = (char**) calloc(map_data->arr_size+2, sizeof(char*));
                  -      for (int i = 0; i < map_data->arr_size; i++)
                  -      {
                  -         new_arr[i] = g_strdup(map_data->str_arr[i]);
                  -      }
                  -      free(map_data->str_arr);
                  -      new_arr[map_data->arr_size] = g_strdup(value);
                  -      map_data->str_arr = g_strdupv(new_arr);
                  -      free(new_arr);
                  -   }
                  -   map_data->arr_size += 1;
                  -
                  -   int ret = data_control_provider_send_map_result(request_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "send_map_result failed with error: %d", ret);
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Add value success request_id: %d %d %s", 
                  -                 request_id, map_data->arr_size, map_data->str_arr[0]);
                  -   }
                  +    map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key);
                  +
                  +    if (map_data == NULL) {
                  +        map_data = (map_data_s*)(g_malloc(sizeof(*map_data)));
                  +        map_data->arr_size = 0;
                  +        map_data->str_arr = (char**)calloc(1, sizeof(char*));
                  +        map_data->str_arr[0] = g_strdup(value);
                  +        g_hash_table_insert(map_repository_test, g_strdup(key), map_data);
                  +    } else {
                  +        char **new_arr = (char**)calloc(map_data->arr_size+2, sizeof(char*));
                  +        for (int i = 0; i < map_data->arr_size; i++)
                  +            new_arr[i] = g_strdup(map_data->str_arr[i]);
                  +        free(map_data->str_arr);
                  +        new_arr[map_data->arr_size] = g_strdup(value);
                  +        map_data->str_arr = g_strdupv(new_arr);
                  +        free(new_arr);
                  +    }
                  +    map_data->arr_size += 1;
                  +
                  +    int ret = data_control_provider_send_map_result(request_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE) {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "send_map_result failed with error: %d", ret);
                  +    } else {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Add value success request_id: %d %d %s",
                  +                   request_id, map_data->arr_size, map_data->str_arr[0]);
                  +    }
                   }
                   
                  -void 
                  -remove_value_request_cb(int request_id, data_control_h provider, const char *key, 
                  +void
                  +remove_value_request_cb(int request_id, data_control_h provider, const char *key,
                                           const char *value, void *user_data)
                   {
                  -   map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key);
                  -
                  -   if (map_data != NULL)
                  -   {
                  -      int size = map_data->arr_size;
                  -      for (int i = 0; i < size; i++)
                  -      {
                  -         if (strcmp(map_data->str_arr[i], value) == 0)
                  -         {
                  -            free(map_data->str_arr[i]);
                  -            map_data->arr_size--;
                  -         }
                  -      }
                  -      if (map_data->arr_size == 0)
                  -      {
                  -         if (!g_hash_table_remove(map_repository_test, key))
                  -         {
                  -            dlog_print(DLOG_ERROR, LOG_TAG, "remove value failed -%s", key);
                  -
                  -            return;
                  -         }
                  -      }
                  -   }
                  -
                  -   int ret = data_control_provider_send_map_result(request_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "send_map_result failed with error: %d", ret);
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Remove value Success");
                  -   }
                  +    map_data_s* map_data = (map_data_s*)g_hash_table_lookup(map_repository_test, key);
                  +
                  +    if (map_data != NULL) {
                  +        int size = map_data->arr_size;
                  +        for (int i = 0; i < size; i++) {
                  +            if (strcmp(map_data->str_arr[i], value) == 0) {
                  +                free(map_data->str_arr[i]);
                  +                map_data->arr_size--;
                  +            }
                  +        }
                  +        if (map_data->arr_size == 0) {
                  +            if (!g_hash_table_remove(map_repository_test, key)) {
                  +                dlog_print(DLOG_ERROR, LOG_TAG, "remove value failed -%s", key);
                  +
                  +                return;
                  +            }
                  +        }
                  +    }
                  +
                  +    int ret = data_control_provider_send_map_result(request_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "send_map_result failed with error: %d", ret);
                  +    else
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Remove value Success");
                   }
                   
                • Register the callbacks within the app_create() function (generated by the IDE) using the data_control_provider_map_register_cb() function:

                  -void 
                  +void
                   __free_key(gpointer data)
                   {
                  -   if (data)
                  -   {
                  -      g_free(data);
                  -      data = NULL;
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Remove key");
                  -   }
                  +    if (data) {
                  +        g_free(data);
                  +        data = NULL;
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Remove key");
                  +    }
                   }
                   
                   void
                   __free_data(gpointer data)
                   {
                  -   if (data)
                  -   {
                  -      g_free(data);
                  -      data = NULL;
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Remove value");
                  -   }
                  +    if (data) {
                  +        g_free(data);
                  +        data = NULL;
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Remove value");
                  +    }
                   }
                   
                   data_control_provider_map_cb map_callback;
                  -void 
                  +void
                   initialize_datacontrol_provider()
                   {
                  -   map_repository_test = g_hash_table_new_full(g_str_hash, g_str_equal, __free_key, __free_data);
                  -
                  -   map_callback.get_cb = get_value_request_cb;
                  -   map_callback.add_cb = add_value_request_cb;
                  -   map_callback.remove_cb = remove_value_request_cb;
                  -   map_callback.set_cb = set_value_request_cb;
                  -
                  -   int result = data_control_provider_map_register_cb(&map_callback);
                  -   if (result != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "data_control_provider_map_register_cb failed with error: %d", result);
                  -   }
                  -   else 
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Provider map register success");
                  -   }
                  -}	
                  +    map_repository_test = g_hash_table_new_full(g_str_hash, g_str_equal, __free_key, __free_data);
                  +
                  +    map_callback.get_cb = get_value_request_cb;
                  +    map_callback.add_cb = add_value_request_cb;
                  +    map_callback.remove_cb = remove_value_request_cb;
                  +    map_callback.set_cb = set_value_request_cb;
                  +
                  +    int result = data_control_provider_map_register_cb(&map_callback);
                  +    if (result != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "data_control_provider_map_register_cb failed with error: %d", result);
                  +    else
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Provider map register success");
                  +}
                   
                   static bool
                   app_create(void *data)
                   {
                  -   // Take necessary actions before main event loop starts
                  -   // Initialize UI resources and application data
                  -   // If this function returns true, the main loop of application starts
                  -   // If this function returns false, the application is terminated 
                  -   appdata_s *ad = data;
                  -
                  -   create_base_gui(ad);
                  -   initialize_datacontrol_provider()
                  -
                  -   return true;
                  +    /*
                  +       Take necessary actions before main event loop starts
                  +       Initialize UI resources and application data
                  +       If this function returns true, the main loop of application starts
                  +       If this function returns false, the application is terminated
                  +    */
                  +    appdata_s *ad = data;
                  +
                  +    create_base_gui(ad);
                  +    initialize_datacontrol_provider()
                  +
                  +    return true;
                   }
                   
                • @@ -298,70 +269,56 @@ app_create(void *data)

                  Implement the response callbacks. The response callbacks receive the request result and data from the provider.

                  -// Callback functions 
                  +/* Callback functions */
                   void
                   map_get_response_cb(int request_id, data_control_h provider,
                  -                    char **ret_value_list, int ret_value_count, bool provider_ret, 
                  +                    char **ret_value_list, int ret_value_count, bool provider_ret,
                                       const char *error, void *user_data)
                   {
                  -   if (provider_ret)
                  -   {
                  -
                  -      dlog_print(DLOG_INFO, LOG_TAG, "The get operation is successful. Value count: %d ", ret_value_count);
                  -      for (int i = 0; i < ret_value_count; i++)
                  -         dlog_print(DLOG_INFO, LOG_TAG, "(%d) Return value: %s ", i , ret_value_list[i]);
                  -
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "The get operation for the request %d failed. error message: %s", 
                  -                 request_id, error);
                  -   }
                  +    if (provider_ret) {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "The get operation is successful. Value count: %d ", ret_value_count);
                  +        for (int i = 0; i < ret_value_count; i++)
                  +            dlog_print(DLOG_INFO, LOG_TAG, "(%d) Return value: %s ", i, ret_value_list[i]);
                  +    } else {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "The get operation for the request %d failed. error message: %s",
                  +                   request_id, error);
                  +    }
                   }
                   
                  -void 
                  -map_set_response_cb(int request_id, data_control_h provider, bool provider_ret, 
                  +void
                  +map_set_response_cb(int request_id, data_control_h provider, bool provider_ret,
                                       const char *error, void *user_data)
                   {
                  -   if (provider_ret)
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "The set operation is successful");
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "The set operation for the request %d failed. error message: %s", 
                  -                 request_id, error);
                  -   }
                  +    if (provider_ret) {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "The set operation is successful");
                  +    } else {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "The set operation for the request %d failed. error message: %s",
                  +                   request_id, error);
                  +    }
                   }
                   
                  -void 
                  -map_add_response_cb(int request_id, data_control_h provider, bool provider_ret, 
                  +void
                  +map_add_response_cb(int request_id, data_control_h provider, bool provider_ret,
                                       const char *error, void *user_data)
                   {
                  -   if (provider_ret)
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "The add operation is successful");
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "The add operation for the request %d failed. error message: %s", 
                  -                 request_id, error);
                  -   }
                  +    if (provider_ret) {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "The add operation is successful");
                  +    } else {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "The add operation for the request %d failed. error message: %s",
                  +                   request_id, error);
                  +    }
                   }
                   
                  -void 
                  -map_remove_response_cb(int request_id, data_control_h provider, bool provider_ret, 
                  +void
                  +map_remove_response_cb(int request_id, data_control_h provider, bool provider_ret,
                                          const char *error, void *user_data)
                   {
                  -   if (provider_ret)
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "The remove operation is successful");
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "The remove operation for the request %d failed. error message: %s", 
                  -                 request_id, error);
                  -   }
                  +    if (provider_ret) {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "The remove operation is successful");
                  +    } else {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "The remove operation for the request %d failed. error message: %s",
                  +                   request_id, error);
                  +    }
                   }
                   
                  @@ -369,84 +326,75 @@ map_remove_response_cb(int request_id, data_control_h provider, bool provider_re

                  To identify the provider and data, initialize a data control handler. The initializing process has to be performed within the app_create() function generated by the IDE.

                   data_control_map_response_cb map_callback;
                  -void 
                  +void
                   initialize_datacontrol_consumer(appdata_s *ad)
                   {
                  -   const char *provider_id = Your Provider ID;
                  -   const char *data_id = "table";
                  -   int ret;
                  -
                  -   // Create data control handler
                  -   ret = data_control_map_create(&(ad->provider_h));
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "creating data control provider failed with error: %d", ret);
                  -   }
                  -   ret = data_control_map_set_provider_id(ad->provider_h, provider_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "setting provider id failed with error: %d", ret);
                  -   }
                  -   ret = data_control_map_set_data_id(ad->provider_h, data_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "setting data id failed with error: %d", ret);
                  -   }
                  -
                  -   // Set response callback
                  -   map_callback.get_cb = map_get_response_cb;
                  -   map_callback.set_cb = map_set_response_cb;
                  -   map_callback.add_cb = map_add_response_cb;
                  -   map_callback.remove_cb = map_remove_response_cb;
                  -
                  -   // Register response callback
                  -   ret = data_control_map_register_response_cb(ad->provider_h, &map_callback, NULL);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function failed with error: %d", ret);
                  -
                  -      if (ret == DATA_CONTROL_ERROR_IO_ERROR) 
                  -      {
                  -         dlog_print(DLOG_ERROR, LOG_TAG, "I/O error");
                  -      }
                  -      else 
                  -      {
                  -         dlog_print(DLOG_ERROR, LOG_TAG, "Out of memory");
                  -      }
                  -   }
                  -
                  -   int req_id = 0;
                  -
                  -   // Add value
                  -   const char *key = "key";
                  -   const char *value = "value";
                  -   data_control_map_add(provider_map, key, value, &req_id);
                  - 
                  -   // Get value
                  -   data_control_map_get(provider_map, key, &req_id);
                  -
                  -   // Set value
                  -   const char *old_value = "old value";
                  -   const char *new_value = "new value";
                  -   data_control_map_set(provider_map, key, old_value, new_value, &req_id);
                  -   
                  -   // Remove value
                  -   data_control_map_remove(provider_map, key, value, &req_id);
                  +    const char *provider_id = Your Provider ID;
                  +    const char *data_id = "table";
                  +    int ret;
                  +
                  +    /* Create data control handler */
                  +    ret = data_control_map_create(&(ad->provider_h));
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "creating data control provider failed with error: %d", ret);
                  +    ret = data_control_map_set_provider_id(ad->provider_h, provider_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "setting provider id failed with error: %d", ret);
                  +    ret = data_control_map_set_data_id(ad->provider_h, data_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "setting data id failed with error: %d", ret);
                  +
                  +    /* Set response callback */
                  +    map_callback.get_cb = map_get_response_cb;
                  +    map_callback.set_cb = map_set_response_cb;
                  +    map_callback.add_cb = map_add_response_cb;
                  +    map_callback.remove_cb = map_remove_response_cb;
                  +
                  +    /* Register response callback */
                  +    ret = data_control_map_register_response_cb(ad->provider_h, &map_callback, NULL);
                  +    if (ret != DATA_CONTROL_ERROR_NONE) {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function failed with error: %d", ret);
                  +
                  +        if (ret == DATA_CONTROL_ERROR_IO_ERROR)
                  +            dlog_print(DLOG_ERROR, LOG_TAG, "I/O error");
                  +        else
                  +            dlog_print(DLOG_ERROR, LOG_TAG, "Out of memory");
                  +    }
                  +
                  +    int req_id = 0;
                  +
                  +    /* Add value */
                  +    const char *key = "key";
                  +    const char *value = "value";
                  +    data_control_map_add(provider_map, key, value, &req_id);
                  +
                  +    /* Get value */
                  +    data_control_map_get(provider_map, key, &req_id);
                  +
                  +    /* Set value */
                  +    const char *old_value = "old value";
                  +    const char *new_value = "new value";
                  +    data_control_map_set(provider_map, key, old_value, new_value, &req_id);
                  +
                  +    /* Remove value */
                  +    data_control_map_remove(provider_map, key, value, &req_id);
                   }
                   
                   static bool
                   app_create(void *data)
                   {
                  -   // Take necessary actions before main event loop starts
                  -   // Initialize UI resources and application data
                  -   // If this function returns true, the main loop of application starts
                  -   // If this function returns false, the application is terminated 
                  -   appdata_s *ad = data;
                  -
                  -   create_base_gui(ad);
                  -   initialize_datacontrol_consumer(ad);
                  -
                  -   return true;
                  +    /*
                  +       Take necessary actions before main event loop starts
                  +       Initialize UI resources and application data
                  +       If this function returns true, the main loop of application starts
                  +       If this function returns false, the application is terminated
                  +    */
                  +    appdata_s *ad = data;
                  +
                  +    create_base_gui(ad);
                  +    initialize_datacontrol_consumer(ad);
                  +
                  +    return true;
                   }
                   
                  @@ -464,162 +412,143 @@ app_create(void *data)
                   data_control_provider_sql_cb *sql_callback;
                   static sqlite3* db;
                  -void 
                  +void
                   insert_request_cb(int request_id, data_control_h provider, bundle *insert_data, void *user_data)
                   {
                  -   char* command = data_control_provider_create_insert_statement(provider, insert_data);
                  -   int ret = sqlite3_exec(db, command, NULL, NULL, NULL);
                  -
                  -   if (ret != SQLITE_OK)
                  -   {
                  -      data_control_provider_send_error(request_id, sqlite3_errmsg(db));
                  -      free(command);
                  -
                  -      return;
                  -   }
                  -   dlog_print(DLOG_INFO, LOG_TAG, "[insert_request_cb] insert success");
                  -
                  -   long long inserted_row_id = sqlite3_last_insert_rowid(db);
                  -   ret = data_control_provider_send_insert_result(request_id, inserted_row_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "insert_send_result failed with error: %d", ret);
                  -   }
                  -   dlog_print(DLOG_INFO, LOG_TAG, "[insert_request_cb] send result success");
                  -
                  -   free(command);
                  +    char* command = data_control_provider_create_insert_statement(provider, insert_data);
                  +    int ret = sqlite3_exec(db, command, NULL, NULL, NULL);
                  +
                  +    if (ret != SQLITE_OK) {
                  +        data_control_provider_send_error(request_id, sqlite3_errmsg(db));
                  +        free(command);
                  +
                  +        return;
                  +    }
                  +    dlog_print(DLOG_INFO, LOG_TAG, "[insert_request_cb] insert success");
                  +
                  +    long long inserted_row_id = sqlite3_last_insert_rowid(db);
                  +    ret = data_control_provider_send_insert_result(request_id, inserted_row_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "insert_send_result failed with error: %d", ret);
                  +    dlog_print(DLOG_INFO, LOG_TAG, "[insert_request_cb] send result success");
                  +
                  +    free(command);
                   }
                   
                  -void 
                  +void
                   delete_request_cb(int request_id, data_control_h provider, const char *where, void *user_data)
                   {
                  -   dlog_print(DLOG_INFO, LOG_TAG, "[delete_request_cb] request_id(%d)", request_id);
                  -   char* command = data_control_provider_create_delete_statement(provider, where);
                  -   int ret = sqlite3_exec(db, command, NULL, NULL, NULL);
                  -   if (ret != SQLITE_OK)
                  -   {
                  -      data_control_provider_send_error(request_id, sqlite3_errmsg(db));
                  -      free(command);
                  -
                  -      return;
                  -   }	
                  -
                  -   ret = data_control_provider_send_delete_result(request_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "delete_send_result failed with error: %d", ret);
                  -   }
                  -   dlog_print(DLOG_INFO, LOG_TAG, "[delete_request_cb] delete success");
                  -
                  -   free(command);
                  +    dlog_print(DLOG_INFO, LOG_TAG, "[delete_request_cb] request_id(%d)", request_id);
                  +    char* command = data_control_provider_create_delete_statement(provider, where);
                  +    int ret = sqlite3_exec(db, command, NULL, NULL, NULL);
                  +    if (ret != SQLITE_OK) {
                  +        data_control_provider_send_error(request_id, sqlite3_errmsg(db));
                  +        free(command);
                  +
                  +        return;
                  +    }
                  +
                  +    ret = data_control_provider_send_delete_result(request_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "delete_send_result failed with error: %d", ret);
                  +    dlog_print(DLOG_INFO, LOG_TAG, "[delete_request_cb] delete success");
                  +
                  +    free(command);
                   }
                   
                  -void 
                  -select_request_cb(int request_id, data_control_h provider, const char **column_list, 
                  +void
                  +select_request_cb(int request_id, data_control_h provider, const char **column_list,
                                     int column_count, const char *where, const char *order, void *user_data)
                   {
                  -   sqlite3_stmt* sql_stmt = NULL;
                  -
                  -   char* command = data_control_provider_create_select_statement(provider, column_list, 
                  -                                                                 column_count, where, order);
                  -   int ret = sqlite3_prepare_v2(db, command, strlen(command), &sql_stmt, NULL);
                  -   if (ret != SQLITE_OK)
                  -   {
                  -      data_control_provider_send_error(request_id, sqlite3_errmsg(db));
                  -      free(command);
                  -
                  -      return;
                  -   }	
                  -
                  -   ret = data_control_provider_send_select_result(request_id, (void *)sql_stmt);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "select_send_result failed with error: %d", ret);
                  -   }
                  -   dlog_print(DLOG_INFO, LOG_TAG, "[select_request_cb] send result success");
                  -
                  -   sqlite3_finalize(sql_stmt);
                  -   free(command);
                  +    sqlite3_stmt* sql_stmt = NULL;
                  +
                  +    char* command = data_control_provider_create_select_statement(provider, column_list,
                  +                                                                  column_count, where, order);
                  +    int ret = sqlite3_prepare_v2(db, command, strlen(command), &sql_stmt, NULL);
                  +    if (ret != SQLITE_OK) {
                  +        data_control_provider_send_error(request_id, sqlite3_errmsg(db));
                  +        free(command);
                  +
                  +        return;
                  +    }
                  +
                  +    ret = data_control_provider_send_select_result(request_id, (void *)sql_stmt);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "select_send_result failed with error: %d", ret);
                  +    dlog_print(DLOG_INFO, LOG_TAG, "[select_request_cb] send result success");
                  +
                  +    sqlite3_finalize(sql_stmt);
                  +    free(command);
                   }
                   
                  -void 
                  -update_request_cb(int request_id, data_control_h provider, bundle *update_data, 
                  +void
                  +update_request_cb(int request_id, data_control_h provider, bundle *update_data,
                                     const char *where, void *user_data)
                   {
                  -   char* command = data_control_provider_create_update_statement(provider, update_data, where);
                  -   int ret = sqlite3_exec(db, command, NULL, NULL, NULL);
                  -   if (ret != SQLITE_OK)
                  -   {
                  -      data_control_provider_send_error(request_id, sqlite3_errmsg(db));
                  -      free(command);
                  -
                  -      return;
                  -   }
                  -
                  -   ret = data_control_provider_send_update_result(request_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "update_send_result failed with error: %d", ret);
                  -   }
                  -   dlog_print(DLOG_INFO, LOG_TAG, "[update_request_cb] send result success");
                  -
                  -   free(command);
                  +    char* command = data_control_provider_create_update_statement(provider, update_data, where);
                  +    int ret = sqlite3_exec(db, command, NULL, NULL, NULL);
                  +    if (ret != SQLITE_OK) {
                  +        data_control_provider_send_error(request_id, sqlite3_errmsg(db));
                  +        free(command);
                  +
                  +        return;
                  +    }
                  +
                  +    ret = data_control_provider_send_update_result(request_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "update_send_result failed with error: %d", ret);
                  +    dlog_print(DLOG_INFO, LOG_TAG, "[update_request_cb] send result success");
                  +
                  +    free(command);
                   }
                   
                • Register the callbacks and create the database:

                  -int 
                  +int
                   create_database()
                   {
                  -   dlog_print(DLOG_INFO, LOG_TAG, "%s%s", app_get_data_path(), "test.db");
                  +    dlog_print(DLOG_INFO, LOG_TAG, "%s%s", app_get_data_path(), "test.db");
                   
                  -   int open_flags = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
                  +    int open_flags = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
                   
                  -   int ret = sqlite3_open_v2(Your DB Path, &db, open_flags, NULL);
                  -   if (ret != SQLITE_OK)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "database creation failed with error: %d", ret);
                  +    int ret = sqlite3_open_v2(Your DB Path, &db, open_flags, NULL);
                  +    if (ret != SQLITE_OK) {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "database creation failed with error: %d", ret);
                   
                  -      return ret;
                  -   }
                  +        return ret;
                  +    }
                   
                  -   char* sql_command = "CREATE TABLE IF NOT EXISTS Dictionary (WORD VARCHAR(30), WORD_DESC TEXT, WORD_NUM INT, Point INT)";
                  -   ret = sqlite3_exec(db, sql_command, NULL, NULL, NULL);
                  -   if (ret != SQLITE_OK)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "database table creation failed with error: %d", ret);
                  -   }
                  -   dlog_print(DLOG_INFO, LOG_TAG, "DB init Success.");
                  +    char* sql_command = "CREATE TABLE IF NOT EXISTS Dictionary (WORD VARCHAR(30), WORD_DESC TEXT, WORD_NUM INT, Point INT)";
                  +    ret = sqlite3_exec(db, sql_command, NULL, NULL, NULL);
                  +    if (ret != SQLITE_OK)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "database table creation failed with error: %d", ret);
                  +    dlog_print(DLOG_INFO, LOG_TAG, "DB init Success.");
                   
                  -   return ret;
                  +    return ret;
                   }
                   
                   void
                   initialize_datacontrol_provider()
                   {
                  -   dlog_print(DLOG_INFO, LOG_TAG, "initialize_datacontrol_provider");
                  -
                  -   int result = create_database();
                  -   if (result != SQLITE_OK)
                  -      return;
                  -
                  -   sql_callback = (data_control_provider_sql_cb *) malloc(sizeof(data_control_provider_sql_cb));
                  -   sql_callback->select_cb = select_request_cb;
                  -   sql_callback->insert_cb = insert_request_cb;
                  -   sql_callback->delete_cb = delete_request_cb;
                  -   sql_callback->update_cb = update_request_cb;
                  -   result = data_control_provider_sql_register_cb(sql_callback, NULL);
                  -   if (result != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, "data_control_sql_response_c failed with error: %d", result);
                  -   }
                  -   else 
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Provider SQL register success");
                  -   }
                  -}		
                  +    dlog_print(DLOG_INFO, LOG_TAG, "initialize_datacontrol_provider");
                  +
                  +    int result = create_database();
                  +    if (result != SQLITE_OK)
                  +        return;
                  +
                  +    sql_callback = (data_control_provider_sql_cb *)malloc(sizeof(data_control_provider_sql_cb));
                  +    sql_callback->select_cb = select_request_cb;
                  +    sql_callback->insert_cb = insert_request_cb;
                  +    sql_callback->delete_cb = delete_request_cb;
                  +    sql_callback->update_cb = update_request_cb;
                  +    result = data_control_provider_sql_register_cb(sql_callback, NULL);
                  +    if (result != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, "data_control_sql_response_c failed with error: %d", result);
                  +    else
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Provider SQL register success");
                  +}
                   
                • @@ -629,79 +558,65 @@ initialize_datacontrol_provider()

                  Implement the response callbacks. The response callbacks receive the request result and data from the provider.

                  -void 
                  -sql_delete_response_cb(int request_id, data_control_h provider, bool provider_result, 
                  +void
                  +sql_delete_response_cb(int request_id, data_control_h provider, bool provider_result,
                                          const char *error, void *user_data)
                   {
                  -   if (provider_result)
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "The delete operation is successful");
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "The delete operation for the request %d failed. error message: %s", 
                  -                 request_id, error);
                  -   }
                  +    if (provider_result) {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "The delete operation is successful");
                  +    } else {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "The delete operation for the request %d failed. error message: %s",
                  +                   request_id, error);
                  +    }
                   }
                   
                  -void 
                  -sql_insert_response_cb(int request_id, data_control_h provider, long long inserted_row_id, 
                  +void
                  +sql_insert_response_cb(int request_id, data_control_h provider, long long inserted_row_id,
                                          bool provider_result, const char *error, void *user_data)
                   {
                  -   if (provider_result)
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "The insert operation is successful");
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "The insert operation for the request %d failed. error message: %s", 
                  -                 request_id, error);
                  -   }
                  +    if (provider_result) {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "The insert operation is successful");
                  +    } else {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "The insert operation for the request %d failed. error message: %s",
                  +                   request_id, error);
                  +    }
                   }
                   
                  -void 
                  -sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor cursor, 
                  +void
                  +sql_select_response_cb(int request_id, data_control_h provider, result_set_cursor cursor,
                                          bool provider_result, const char *error, void *user_data)
                   {
                  -   if (provider_result)
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "The select operation is successful");
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "The select operation for the request %d failed. error message: %s", 
                  -                 request_id, error);
                  -   }
                  -
                  -   while (data_control_sql_step_next(cursor) == DATA_CONTROL_ERROR_NONE) 
                  -   {
                  -
                  -      char word[32] = {0,};
                  -      char word_desc[32] = {0,};
                  -      long long word_number = -1;
                  -
                  -      data_control_sql_get_text_data(cursor, 0, word);
                  -      data_control_sql_get_text_data(cursor, 1, word_desc);
                  -      data_control_sql_get_int64_data(cursor, 2, &word_number);
                  -
                  -      dlog_print(DLOG_INFO, LOG_TAG, "Word: %s, Word DESC: %s, Word NUM: %ld ", 
                  -                 word, word_desc, word_number);
                  -   }
                  +    if (provider_result) {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "The select operation is successful");
                  +    } else {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "The select operation for the request %d failed. error message: %s",
                  +                   request_id, error);
                  +    }
                  +
                  +    while (data_control_sql_step_next(cursor) == DATA_CONTROL_ERROR_NONE) {
                  +        char word[32] = {0,};
                  +        char word_desc[32] = {0,};
                  +        long long word_number = -1;
                  +
                  +        data_control_sql_get_text_data(cursor, 0, word);
                  +        data_control_sql_get_text_data(cursor, 1, word_desc);
                  +        data_control_sql_get_int64_data(cursor, 2, &word_number);
                  +
                  +        dlog_print(DLOG_INFO, LOG_TAG, "Word: %s, Word DESC: %s, Word NUM: %ld ",
                  +                   word, word_desc, word_number);
                  +    }
                   }
                   
                  -void 
                  -sql_update_response_cb(int request_id, data_control_h provider, bool provider_result, 
                  +void
                  +sql_update_response_cb(int request_id, data_control_h provider, bool provider_result,
                                          const char *error, void *user_data)
                   {
                  -   if (provider_result)
                  -   {
                  -      dlog_print(DLOG_INFO, LOG_TAG, "The update operation is successful");
                  -   }
                  -   else
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "The update operation for the request %d failed. error message: %s", 
                  -                 request_id, error);
                  -   }
                  +    if (provider_result) {
                  +        dlog_print(DLOG_INFO, LOG_TAG, "The update operation is successful");
                  +    } else {
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "The update operation for the request %d failed. error message: %s",
                  +                   request_id, error);
                  +    }
                   }
                   
                  @@ -709,89 +624,83 @@ sql_update_response_cb(int request_id, data_control_h provider, bool provider_re

                  To identify the provider and data, initialize a data control handler. The initializing process has to be performed within the app_create() function generated by the IDE.

                   data_control_sql_response_cb sql_callback;
                  -void 
                  +void
                   initialize_datacontrol_consumer(appdata_s *ad)
                   {
                  -   int ret;
                  -
                  -   const char *provider_id = Your Provider ID;
                  -   const char *data_id = "Dictionary";
                  -
                  -   ret = data_control_sql_create(&(ad->provider_h));
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "creating data control provider failed with error: %d", ret);
                  -   }
                  -
                  -   ret = data_control_sql_set_provider_id(ad->provider_h, provider_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "setting provider id failed with error: %d", ret);
                  -   }
                  -
                  -   ret = data_control_sql_set_data_id(ad->provider_h, data_id);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "setting data id failed with error: %d", ret);
                  -   }
                  -
                  -   sql_callback.delete_cb = sql_delete_response_cb;
                  -   sql_callback.insert_cb = sql_insert_response_cb;
                  -   sql_callback.select_cb = sql_select_response_cb;
                  -   sql_callback.update_cb = sql_update_response_cb;
                  -
                  -   ret = data_control_sql_register_response_cb(ad->provider_h, &sql_callback, NULL);
                  -   if (ret != DATA_CONTROL_ERROR_NONE)
                  -   {
                  -      dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function failed with error: %d", ret);
                  -   }
                  -
                  -   dlog_print(DLOG_INFO, LOG_TAG, "Init data control success");
                  -
                  -   int req_id = 0; 
                  -   
                  -   // Insert row
                  -   bundle *b = bundle_create();
                  -   bundle_add_str(b, "WORD", "'test'");
                  -   bundle_add_str(b, "WORD_DESC", "'test desc'");
                  -
                  -   data_control_sql_insert(provider_sql, b, &req_id);
                  -
                  -   // Select row
                  -   char *column_list[2];
                  -   column_list[0] = "WORD";
                  -   column_list[1] = "WORD_DESC";
                  -   
                  -   const char *where = "WORD = 'test'";
                  -   const char *order = "WORD ASC";
                  -
                  -   data_control_sql_select(provider_sql, column_list, 2, where, order, &req_id);
                  -
                  -   // Add row
                  -   bundle_add_str(b, "WORD", "'test_new'");
                  -   data_control_sql_update(provider_sql, b, where, &req_id);
                  -
                  -   // Delete row
                  -   const char *where_delete = "WORD = 'test'";
                  -   result = data_control_sql_delete(provider_sql, where_delete, &req_id);
                  -
                  -   // Free memory
                  -   bundle_free(b);
                  +    int ret;
                  +
                  +    const char *provider_id = Your Provider ID;
                  +    const char *data_id = "Dictionary";
                  +
                  +    ret = data_control_sql_create(&(ad->provider_h));
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "creating data control provider failed with error: %d", ret);
                  +
                  +    ret = data_control_sql_set_provider_id(ad->provider_h, provider_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "setting provider id failed with error: %d", ret);
                  +
                  +    ret = data_control_sql_set_data_id(ad->provider_h, data_id);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "setting data id failed with error: %d", ret);
                  +
                  +    sql_callback.delete_cb = sql_delete_response_cb;
                  +    sql_callback.insert_cb = sql_insert_response_cb;
                  +    sql_callback.select_cb = sql_select_response_cb;
                  +    sql_callback.update_cb = sql_update_response_cb;
                  +
                  +    ret = data_control_sql_register_response_cb(ad->provider_h, &sql_callback, NULL);
                  +    if (ret != DATA_CONTROL_ERROR_NONE)
                  +        dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function failed with error: %d", ret);
                  +
                  +    dlog_print(DLOG_INFO, LOG_TAG, "Init data control success");
                  +
                  +    int req_id = 0;
                  +
                  +    /* Insert row */
                  +    bundle *b = bundle_create();
                  +    bundle_add_str(b, "WORD", "'test'");
                  +    bundle_add_str(b, "WORD_DESC", "'test desc'");
                  +
                  +    data_control_sql_insert(provider_sql, b, &req_id);
                  +
                  +    /* Select row */
                  +    char *column_list[2];
                  +    column_list[0] = "WORD";
                  +    column_list[1] = "WORD_DESC";
                  +
                  +    const char *where = "WORD = 'test'";
                  +    const char *order = "WORD ASC";
                  +
                  +    data_control_sql_select(provider_sql, column_list, 2, where, order, &req_id);
                  +
                  +    /* Add row */
                  +    bundle_add_str(b, "WORD", "'test_new'");
                  +    data_control_sql_update(provider_sql, b, where, &req_id);
                  +
                  +    /* Delete row */
                  +    const char *where_delete = "WORD = 'test'";
                  +    result = data_control_sql_delete(provider_sql, where_delete, &req_id);
                  +
                  +    /* Free memory */
                  +    bundle_free(b);
                   }
                   
                   static bool
                   app_create(void *data)
                   {
                  -   // Take necessary actions before main event loop starts
                  -   // Initialize UI resources and application data
                  -   // If this function returns true, the main loop of application starts
                  -   // If this function returns false, the application is terminated 
                  -   appdata_s *ad = data;
                  -
                  -   create_base_gui(ad);
                  -   initialize_datacontrol_consumer(ad);
                  -
                  -   return true;
                  +    /*
                  +       Take necessary actions before main event loop starts
                  +       Initialize UI resources and application data
                  +       If this function returns true, the main loop of application starts
                  +       If this function returns false, the application is terminated
                  +    */
                  +    appdata_s *ad = data;
                  +
                  +    create_base_gui(ad);
                  +    initialize_datacontrol_consumer(ad);
                  +
                  +    return true;
                   }
                   
                  diff --git a/org.tizen.tutorials/html/native/app_framework/event_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/event_tutorial_n.htm index 969b7d8..ee91e94 100644 --- a/org.tizen.tutorials/html/native/app_framework/event_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/event_tutorial_n.htm @@ -23,6 +23,7 @@ -
                  +
                  @@ -47,6 +48,8 @@

                  Warm-up

                  Become familiar with the Event API basics by learning about:

                  +

                  Prerequisites

                  -

                  Subscribing to an Event

                  - -

                  To subscribe to a predefined system event or user-defined event:

                  +

                  To enable your application to use the event functionality:

                    -
                  1. To use the functions and data types of the Event API, include the <app_event.h> header file in your application: +
                  2. +

                    To use the functions and data types of the Event API, include the <app_event.h> header file in your application:

                    -#include <app_event.h> 
                    +#include <app_event.h>
                     
                  3. +
                  4. To use Launch-On-Events in your application, define the http://tizen.org/appcontrol/operation/launch_on_event operation in the tizen-manifest.xml file. +

                    The URI name for the operation represents the event name in the Launch-On-Event format (event://{Event_Name}).

                    + +
                    +<app-control>
                    +   <operation name="http://tizen.org/appcontrol/operation/launch_on_event"/>
                    +   <uri name="event://tizen.system.event.battery_charger_status"/>
                    +</app-control>
                    +
                    +
                  5. +
                  + +

                  Subscribing to an Event

                  + +

                  To subscribe to a predefined system event or user-defined event:

                  +
                  1. Add an event handler.

                    One event can have multiple event handlers, and one handler can be registered multiple times.

                    • Add an event handler for a system event:
                      -static void 
                      -battery_event_callback(const char *event_name, bundle *event_data, void *user_data) 
                      +static void
                      +battery_event_callback(const char *event_name, bundle *event_data, void *user_data)
                       {
                      -   // event_name is the event name 
                      -   dlog_print(DLOG_INFO, LOG_TAG, "event_name is [%s]", event_name);
                      +    /* event_name is the event name */
                      +    dlog_print(DLOG_INFO, LOG_TAG, "event_name is [%s]", event_name);
                       
                      -   // event_data is the event data, its type is bundle
                      -   char *battery_level_status = NULL;
                      -   battery_level_status = bundle_get_val(event_data, EVENT_KEY_BATTERY_LEVEL_STATUS);
                      +    /* event_data is the event data, its type is bundle */
                      +    char *battery_level_status = NULL;
                      +    battery_level_status = bundle_get_val(event_data, EVENT_KEY_BATTERY_LEVEL_STATUS);
                       }
                       
                       event_handler_h handler;
                       
                      -// Register the event handler
                      +/* Register the event handler */
                       int ret = event_add_event_handler(SYSTEM_EVENT_BATTERY_LEVEL_STATUS,
                                                         (event_cb)battery_event_cb, user_data, &handler);
                       if (ret != EVENT_ERROR_NONE)
                      -   dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret);
                      +    dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret);
                       
                    • @@ -107,7 +126,7 @@ ret = event_add_event_handler("event.org.tizen.senderapp.user_event",                               "CUSTOM_EVENT_KEY", &event_handler); if (ret != EVENT_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret); +    dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret);
                  2. @@ -117,7 +136,7 @@ if (ret != EVENT_ERROR_NONE)
                     ret = event_remove_event_handler(handler);
                     if (ret != EVENT_ERROR_NONE)
                    -   dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret);
                    +    dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret);
                     
                    @@ -129,19 +148,14 @@ if (ret != EVENT_ERROR_NONE)

                    To publish an event to all listeners:

                      -
                    1. To use the functions and data types of the Event API, include the <app_event.h> header file in your application: -
                      -#include <app_event.h> 
                      -
                      -
                    2. Create the callback for handling the event:
                      -static void 
                      +static void
                       user_event_cb(const char *event_name, bundle *event_data, void *user_data)
                       {
                      -   dlog_print(DLOG_INFO, LOG_TAG, "user_event_cb: %s \n", event_name);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "user_event_cb: %s \n", event_name);
                       
                      -   return;
                      +    return;
                       }
                       
                    3. @@ -155,7 +169,7 @@ ret = event_add_event_handler("event.org.tizen.senderapp.user_event",                               user_event_cb, "CUSTOM_EVENT_KEY", &event_handler); if (ret != EVENT_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret); +    dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret); event_data = bundle_create(); @@ -167,7 +181,7 @@ ret = bundle_add_str(event_data, user_data_key, user_data); ret = event_publish_app_event("event.org.tizen.senderapp.user_event", event_data); if (ret != EVENT_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret); +    dlog_print(DLOG_ERROR, LOG_TAG, "err: [%d]", ret);
                    4. When no longer needed, free the bundle: @@ -179,66 +193,48 @@ ret = bundle_free(event_data);

                      Managing Launch-On-Events

                      -

                      To manage a Launch-On-Event:

                      -
        - +
        Note
        Only service applications can register and receive Launch-On-Events.Only service applications can register and receive Launch-On-Events. +

        The Launch-On-Event operation cannot be requested using the app_control_send_launch_request() function, unlike other application control operations.

        - -
          -
        1. To register an interest in a Launch-On-Event, define the http://tizen.org/appcontrol/operation/launch_on_event operation in the tizen-manifest.xml file. The URI name for the operation represents the event name in the Launch-On-Event format (event://{Event_Name}). -
          -<app-control>
          -   <operation name="http://tizen.org/appcontrol/operation/launch_on_event"/>
          -   <uri name="event://tizen.system.event.battery_charger_status"/>
          -</app-control>
          -
          - -

          The Launch-On-Event operation cannot be requested using the app_control_send_launch_request() function, unlike other application control operations.

          -
        2. - -
        3. Receive the event: +

          To receive the Launch-On-Event:

          -static void 
          +static void
           *app_control(app_control_h app_control, void *data)
           {
          -   char *event_uri = "event://tizen.system.event.battery_charger_status";
          -   char *operation, char *uri, char *event_value;
          -   ret = app_control_get_operation(app_control, &operation);
          -
          -   if (ret == APP_CONTROL_ERROR_NONE && operation &&
          -       strcmp(operation, APP_CONTROL_OPERATION_LAUNCH_ON_EVENT) == 0) 
          -   {
          -      ret = app_control_get_uri(app_control, &uri);
          -      if (ret == APP_CONTROL_ERROR_NONE && uri) 
          -      {
          -         if (strncmp(uri, event_uri, strlen(event_uri) + 1) == 0) 
          -         {
          -            ret = app_control_get_extra_data(app_control, "battery_charger_status", &event_value);
          -            if (ret == APP_CONTROL_ERROR_NONE && event_value) 
          -            {
          -               free(event_value);
          +    char *event_uri = "event://tizen.system.event.battery_charger_status";
          +    char *operation;
          +    char *uri;
          +    char *event_value;
          +    ret = app_control_get_operation(app_control, &operation);
          +
          +    if (ret == APP_CONTROL_ERROR_NONE && operation &&
          +         strcmp(operation, APP_CONTROL_OPERATION_LAUNCH_ON_EVENT) == 0) {
          +        ret = app_control_get_uri(app_control, &uri);
          +        if (ret == APP_CONTROL_ERROR_NONE && uri) {
          +            if (strncmp(uri, event_uri, strlen(event_uri) + 1) == 0) {
          +                ret = app_control_get_extra_data(app_control, "battery_charger_status", &event_value);
          +                if (ret == APP_CONTROL_ERROR_NONE && event_value)
          +                    free(event_value);
          +                /* Use event_add_event_handler() for further event subscriptions here */
                       }
          -            // Use event_add_event_handler() for further event subscriptions here
          -         }
          -         free(uri);
          -      }
          -      free(operation);
          -   }
          +            free(uri);
          +        }
          +        free(operation);
          +    }
           }
           

          The application can get the event name and data in the first app_control_cb() callback, which is called after the application state changes to created.

          -
        4. -
        + diff --git a/org.tizen.tutorials/html/native/app_framework/message_port_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/message_port_tutorial_n.htm index f1a3ffa..8e35f84 100644 --- a/org.tizen.tutorials/html/native/app_framework/message_port_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/message_port_tutorial_n.htm @@ -23,7 +23,7 @@ - +

        Message Port: Passing Messages Between Applications

        -

        This tutorial demonstrates how you can register, unregister, and check the message port, and send messages through it.

        +

        This tutorial demonstrates how you can register, deregister, and check the message port, and send messages through it.

        Warm-up

        Become familiar with the Message Port API basics by learning about:

        -

        Initializing Message Port Communication

        +

        Prerequisites

        -

        To initialize message port communication:

        +

        To enable your application to use the message port functionality:

          -
        1. +
        2. You need 2 applications to communicate with each other through the message port.

        3. +
        4. To use trusted message port communication, create an author certificate, register the certificate in the IDE, and grant permissions by the application certificate in the manifest editor.

        5. +
        6. To use the functions and data types of the Message Port API (in mobile and wearable applications), include the <message_port.h> header file in your application:

           #include <message_port.h>
          -
        7. - -
        8. You need 2 applications to communicate with each other through the message port.

          - -

          To use trusted message port communication, create an author certificate, register the certificate to the IDE, and grant permissions by the application certificate in the manifest editor.

        +
      27. +

      Using Uni-directional Communication

      @@ -91,28 +90,24 @@

      To register the local port, call the message_port_register_local_port() function and implement a callback for it in Application 2:

      -void 
      -message_port_cb(int local_port_id, const char *remote_app_id, const char *remote_port, 
      +void
      +message_port_cb(int local_port_id, const char *remote_app_id, const char *remote_port,
                       bool trusted_remote_port, bundle *message, void *user_data)
       {
      -   char *command = NULL;
      -   char *data = NULL;
      -   bundle_get_str(message, "command", &command);
      -   bundle_get_str(message, "data", &data);
      -   
      -   dlog_print(DLOG_INFO, TAG, "Message from %s, command: %s data: %s", 
      -              remote_app_id, command, data);
      +    char *command = NULL;
      +    char *data = NULL;
      +    bundle_get_str(message, "command", &command);
      +    bundle_get_str(message, "data", &data);
      +    
      +    dlog_print(DLOG_INFO, TAG, "Message from %s, command: %s data: %s",
      +               remote_app_id, command, data);
       }
       
       int port_id = message_port_register_local_port(local_port, message_port_cb, NULL);
      -if (port_id < 0) 
      -{
      -   dlog_print(DLOG_ERROR, LOG_TAG, "Port register error: %d", port_id);
      -} 
      -else 
      -{
      -   dlog_print(DLOG_INFO, LOG_TAG, "port_id: %d", port_id);
      -} 
      +if (port_id < 0)
      +    dlog_print(DLOG_ERROR, LOG_TAG, "Port register error: %d", port_id);
      +else
      +    dlog_print(DLOG_INFO, LOG_TAG, "port_id: %d", port_id);
       
      @@ -121,19 +116,17 @@ else

      To check the remote port, call the message_port_check_remote_port() function in Application 1:

      -bool 
      -test_check_remote_port() 
      +bool
      +test_check_remote_port()
       {
      -   int ret;
      -   bool found;
      +    int ret;
      +    bool found;
       
      -   ret = message_port_check_remote_port(remote_app_id, remote_port, &found);
      -   if (ret != MESSAGE_PORT_ERROR_NONE) 
      -   {
      -      dlog_print(DLOG_ERROR, TAG, "message_port_check_remote_port error: %d", ret);	   
      -   }
      +    ret = message_port_check_remote_port(remote_app_id, remote_port, &found);
      +    if (ret != MESSAGE_PORT_ERROR_NONE)
      +        dlog_print(DLOG_ERROR, TAG, "message_port_check_remote_port error: %d", ret);
       
      -   return found;
      +    return found;
       }
       
      @@ -145,24 +138,20 @@ test_check_remote_port()

      To send a message, call the message_port_send_message() function in Application 1:

      -void 
      +void
       send_message(void)
       {
      -   int ret;
      -   bundle *b = bundle_create();
      -   bundle_add_str(b, "command", "begin");
      -   bundle_add_str(b, "data", "dummy");
      -   ret = message_port_send_message(remote_app_id, remote_port, b);
      -   if (ret != MESSAGE_PORT_ERROR_NONE) 
      -   {
      -      dlog_print(DLOG_ERROR, TAG, "message_port_check_remote_port error: %d", ret);
      -   }
      -   else 
      -   {
      -      dlog_print(DLOG_INFO, TAG, "Send message done");
      -   }
      -   bundle_free(b);
      -} 
      +    int ret;
      +    bundle *b = bundle_create();
      +    bundle_add_str(b, "command", "begin");
      +    bundle_add_str(b, "data", "dummy");
      +    ret = message_port_send_message(remote_app_id, remote_port, b);
      +    if (ret != MESSAGE_PORT_ERROR_NONE)
      +        dlog_print(DLOG_ERROR, TAG, "message_port_check_remote_port error: %d", ret);
      +    else
      +        dlog_print(DLOG_INFO, TAG, "Send message done");
      +    bundle_free(b);
      +}
       
    @@ -178,29 +167,27 @@ send_message(void)
    -void 
    -message_port_cb(int local_port_id, const char *remote_app_id, const char *remote_port, 
    +void
    +message_port_cb(int local_port_id, const char *remote_app_id, const char *remote_port,
                     bool trusted_remote_port, bundle *message, void *user_data)
     {
    -   int ret;
    -   char *command = NULL;
    -   char *data = NULL;
    -   bundle_get_str(message, "command", &command);
    -   bundle_get_str(message, "data", &data);
    -
    -   dlog_print(DLOG_INFO, TAG, "Message from %s, command: %s data: %s", 
    -              remote_app_id, command, data);
    -
    -   bundle *reply = bundle_create();
    -   bundle_add_str(reply, "result", "GOT_IT");
    -   ret = message_port_send_message(remote_app_id, remote_port, reply);
    -   bundle_free(reply);
    -   if (ret != MESSAGE_PORT_ERROR_NONE) 
    -   {
    -      dlog_print(DLOG_ERROR, TAG, "Port send message error: %d", ret);
    -   }
    +    int ret;
    +    char *command = NULL;
    +    char *data = NULL;
    +    bundle_get_str(message, "command", &command);
    +    bundle_get_str(message, "data", &data);
    +
    +    dlog_print(DLOG_INFO, TAG, "Message from %s, command: %s data: %s",
    +               remote_app_id, command, data);
    +
    +    bundle *reply = bundle_create();
    +    bundle_add_str(reply, "result", "GOT_IT");
    +    ret = message_port_send_message(remote_app_id, remote_port, reply);
    +    bundle_free(reply);
    +    if (ret != MESSAGE_PORT_ERROR_NONE)
    +        dlog_print(DLOG_ERROR, TAG, "Port send message error: %d", ret);
     }
    -
    +
  • @@ -208,24 +195,20 @@ message_port_cb(int local_port_id, const char *remote_app_id, const char *remote

    Call the message_port_register_local_port() function in Application 1:

    -void 
    -message_port_cb(int local_port_id, const char *remote_app_id, const char *remote_port, 
    -                bool trusted_remote_port, bundle *message, void *user_data) 
    +void
    +message_port_cb(int local_port_id, const char *remote_app_id, const char *remote_port,
    +                bool trusted_remote_port, bundle *message, void *user_data)
     {
    -   char *result = NULL;
    -   bundle_get_str(message, "result", &result);
    -   dlog_print(DLOG_INFO, TAG, "Message from %s, result: %s ", remote_app_id, result);
    -}	
    +    char *result = NULL;
    +    bundle_get_str(message, "result", &result);
    +    dlog_print(DLOG_INFO, TAG, "Message from %s, result: %s ", remote_app_id, result);
    +}
     
     int local_port_id = message_port_register_local_port(local_port, message_port_cb);
    -if (local_port_id < 0) 
    -{
    -   dlog_print(DLOG_ERROR, TAG, "Port register error: %d", local_port_id);
    -} 
    -else 
    -{
    -   dlog_print(DLOG_INFO, TAG, "port_id: %d", port_id);
    -}
    +if (local_port_id < 0)
    +    dlog_print(DLOG_ERROR, TAG, "Port register error: %d", local_port_id);
    +else
    +    dlog_print(DLOG_INFO, TAG, "port_id: %d", port_id);
     
  • @@ -233,30 +216,25 @@ else

    Send a message with local port information.

    To get a response from the receiver, local port information must be sent to the receiver when the message is delivered. To do this, call the message_port_send_message_with_local_port() function in Application 1.

    -void 
    -send_message_with_local_port(int local_port_id) 
    +void
    +send_message_with_local_port(int local_port_id)
     {
    -   int ret;
    -   bundle *b = bundle_create();
    -   bundle_add_str(b, "command", "begin");
    -   bundle_add_str(b, "data", "dummy");
    -
    -   ret = message_port_send_message_with_local_port(remote_app_id, remote_port, b, local_port_id);
    -   if (ret != MESSAGE_PORT_ERROR_NONE) 
    -   {
    -      dlog_print(DLOG_ERROR, TAG, "message_port_send_message_with_local_port error: %d", ret);
    -   }
    -   else 
    -   {
    -      dlog_print(DLOG_INFO, TAG, "Send message done");
    -   }
    -   bundle_free(b);
    +    int ret;
    +    bundle *b = bundle_create();
    +    bundle_add_str(b, "command", "begin");
    +    bundle_add_str(b, "data", "dummy");
    +
    +    ret = message_port_send_message_with_local_port(remote_app_id, remote_port, b, local_port_id);
    +    if (ret != MESSAGE_PORT_ERROR_NONE)
    +        dlog_print(DLOG_ERROR, TAG, "message_port_send_message_with_local_port error: %d", ret);
    +    else
    +        dlog_print(DLOG_INFO, TAG, "Send message done");
    +    bundle_free(b);
     }
     
    -if (test_check_remote_port()) 
    -{
    -   dlog_print(DLOG_INFO, TAG, "Remote port check success.");
    -   send_message_with_local_port(local_port_id);
    +if (test_check_remote_port()) {
    +    dlog_print(DLOG_INFO, TAG, "Remote port check success.");
    +    send_message_with_local_port(local_port_id);
     }
     
    diff --git a/org.tizen.tutorials/html/native/app_framework/notification_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/notification_tutorial_n.htm index 2bc0bed..0af3564 100644 --- a/org.tizen.tutorials/html/native/app_framework/notification_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/notification_tutorial_n.htm @@ -23,9 +23,9 @@

    Content

      +
    • Prerequisites
    • Set-up @@ -59,10 +59,10 @@

      Become familiar with the Notification API basics by learning about:

        +
      • Prerequisites +

        Prepare your application to use the notification functionality.

      • Set-up -

        Initializing Notifications

        +

        Prerequisites

        -

        To initialize notifications:

        +

        To enable your application to use the notification functionality:

        1. To use the functions and data types of the Notification API, include the <notification.h> header file in your application:
           #include <notification.h>
          @@ -103,7 +103,7 @@
           
           static notification_h notification = NULL;
           char *image_path[BUFLEN];
          -char * shared_path = app_get_shared_resource_path();
          +char *shared_path = app_get_shared_resource_path();
           snprintf(image_path, BUFLEN, "%stutorial_native_api_application.png", shared_path);
           free(shared_path);
           
        @@ -117,9 +117,7 @@ free(shared_path);
         notification = notification_create(NOTIFICATION_TYPE_ONGOING);
         if (notification != NULL)
        -{
        -   // Notification was initialized successfully
        -}
        +    /* Notification was initialized successfully */
         
        @@ -139,9 +137,7 @@ ret = notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, "te                             NULL, NOTIFICATION_VARIABLE_TYPE_NONE); if (ret != NOTIFICATION_ERROR_NONE) -{ -   // Error handling -} +    /* Error handling */
      • @@ -152,9 +148,7 @@ if (ret != NOTIFICATION_ERROR_NONE)
         ret = notification_set_time_to_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT, time(NULL));
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
        +    /* Error handling */
         
        @@ -165,9 +159,7 @@ if (ret != NOTIFICATION_ERROR_NONE)
         ret = notification_set_image(notification, NOTIFICATION_IMAGE_TYPE_ICON, image_path);
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
        +    /* Error handling */
         
        @@ -179,9 +171,7 @@ if (ret != NOTIFICATION_ERROR_NONE) ret = notification_set_display_applist(notification,                                        NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER); if (ret != NOTIFICATION_ERROR_NONE) -{ -   // Error handling -} +    /* Error handling */ @@ -200,15 +190,11 @@ if (ret != NOTIFICATION_ERROR_NONE)
         ret = notification_set_led(notification, NOTIFICATION_LED_OP_ON, 100);
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
        +    /* Error handling */
         
         ret = notification_set_led_time_period(notification, 100, 100);
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
        +    /* Error handling */
         
      • Notification properties: @@ -218,9 +204,7 @@ if (ret != NOTIFICATION_ERROR_NONE)
         ret = notification_set_property(notification, NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
        +    /* Error handling */
         
      • Button on the active notification: @@ -235,20 +219,16 @@ if (ret != NOTIFICATION_ERROR_NONE)
         noti_err = notification_add_button(noti, NOTIFICATION_BUTTON_1);
        -if (noti_err != NOTIFICATION_ERROR_NONE) 
        -{
        -   // Error handling
        -}
        +if (noti_err != NOTIFICATION_ERROR_NONE)
        +    /* Error handling */
         
         app_control_h app_control = NULL;
         
         app_control_create(&app_control);
         app_control_set_app_id(app_control, "org.tizen.app");
         noti_err  = notification_set_event_handler(noti, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, app_control);
        -if (noti_err != NOTIFICATION_ERROR_NONE) 
        -{
        -   // Error handling
        -}
        +if (noti_err != NOTIFICATION_ERROR_NONE)
        +    /* Error handling */
         
         app_control_destroy(app_control);
         
        @@ -263,9 +243,7 @@ app_control_destroy(app_control);
         ret = notification_post(notification);
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
        +    /* Error handling */
         

        Updating Notification Content

        @@ -274,9 +252,7 @@ if (ret != NOTIFICATION_ERROR_NONE)
         ret = notification_update(notification);
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
        +    /* Error handling */
         

        Deleting a Notification

        @@ -287,16 +263,14 @@ if (ret != NOTIFICATION_ERROR_NONE)
         ret = notification_delete(notification);
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
      • +    /* Error handling */ +
      • After deleting the notification, free the internal structure data of the notification handle by calling the notification_free() function:

        ret = notification_free(notification);
         if (ret != NOTIFICATION_ERROR_NONE)
        -{
        -   // Error handling
        -}
      • +    /* Error handling */ +

        Displaying the Progress Bar

        @@ -308,12 +282,12 @@ if (ret != NOTIFICATION_ERROR_NONE)
         notification_h notification = NULL;
         
        -// Create a notification
        +/* Create a notification */
         notification = notification_create(NOTIFICATION_TYPE_ONGOING);
         PRINT_MSG("notification_create %s", (notification != NULL) ? "succeed" : "failed");
         
        -// Set the parameters
        -int ret = notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, "text", 
        +/* Set the parameters */
        +int ret = notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, "text",
                                         NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
         PRINT_MSG("notification_set_text %s", (ret == 0) ? "succeed" : "failed");
         
        @@ -323,39 +297,38 @@ PRINT_MSG("notification_set_progress %s", (ret == 0) ? "succeed&q
         ret = notification_set_tag(notification, "noti_tag");
         PRINT_MSG("notification_set_tag %s", (ret == 0) ? "succeed" : "failed");
         
        -// Send the notification
        +/* Send the notification */
         ret = notification_post(notification);
         PRINT_MSG("notification_post %s", (ret == 0) ? "succeed" : "failed");
         
        -// Change the status of the notification
        +/* Change the status of the notification */
         ecore_timer_add(1, timeout_func, NULL);
         
      • To update the progress bar, retrieve the notification handle with the notification_load_by_tag() function, set and get the progress data, and update the notification:
        -static 
        +static
         Eina_Bool timeout_func(void *data)
         {
        -   static int i = 0;
        -   double progress = 0;
        -   i++;
        -   notification_h notification = notification_load_by_tag("noti_tag");
        -   notification_set_progress(notification, ((double) i / 10.0));
        -   notification_get_progress(notification, &progress);
        -   notification_update(notification);
        +    static int i = 0;
        +    double progress = 0;
        +    i++;
        +    notification_h notification = notification_load_by_tag("noti_tag");
        +    notification_set_progress(notification, ((double) i / 10.0));
        +    notification_get_progress(notification, &progress);
        +    notification_update(notification);
         
        -   dlog_print(DLOG_INFO, "NOTIFICATION", "Progress: %f\n", progress);
        +    dlog_print(DLOG_INFO, "NOTIFICATION", "Progress: %f\n", progress);
         
        -   if (10 == i)
        -   { 
        -      dlog_print(DLOG_INFO, "NOTIFICATION", "End of awaiting!n"); 
        -      notification_delete(notification);
        +    if (10 == i) {
        +        dlog_print(DLOG_INFO, "NOTIFICATION", "End of awaiting!n");
        +        notification_delete(notification);
         
        -      return ECORE_CALLBACK_DONE; 
        -   } 
        +        return ECORE_CALLBACK_DONE;
        +    }
         
        -   return ECORE_CALLBACK_PASS_ON;
        +    return ECORE_CALLBACK_PASS_ON;
         }
         
      • diff --git a/org.tizen.tutorials/html/native/app_framework/package_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/package_tutorial_n.htm index 981d085..26c994f 100644 --- a/org.tizen.tutorials/html/native/app_framework/package_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/package_tutorial_n.htm @@ -23,7 +23,7 @@

        Content

          -
        • Initializing the Package Functionality
        • +
        • Prerequisites
        • Retrieving All Package Information
        • Retrieving Specific Package Information
        • Monitoring Package Events
        • @@ -47,8 +47,8 @@

          Warm-up

          Become familiar with the Package Manager API basics by learning about:

          -

          Initializing the Package Functionality

          +

          Prerequisites

          -

          To initialize the package functionality:

          +

          To enable your application to use the package manager functionality:

            -
          1. To use the functions and data types of the Package Manager API (in mobile and wearable applications), include the <package_manager.h> header file in your application:

            +
          2. +

            To use the Package Manager API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

            +
            +<privileges>
            +   <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
            +</privileges>
            +
            +
          3. +
          4. To use the functions and data types of the Package Manager API, include the <package_manager.h> header file in your application:

             #include <package_manager.h>
             
          5. - -
          6. Add the http://tizen.org/privilege/packagemanager.info privilege to the manifest file of the application to get package information.

            -

          Retrieving All Package Information

          @@ -78,55 +83,53 @@
        • Define the package_info_cb() callback function, which is invoked for each retrieved package and used to access the package information:
          -void 
          +void
           package_info_cb(package_info_h package_info, void *user_data)
           {
          -   int ret;
          -
          -   char *pkg = NULL;
          -   char *label = NULL;
          -   char *icon = NULL;
          -   char *version = NULL;
          -   char *type = NULL;
          -   package_info_installed_storage_type_e storage;
          -   bool system;
          -   bool removable;
          -   bool preload;
          -
          -   package_info_get_package(package_info, &pkg);
          -   package_info_get_label(package_info, &label);
          -   package_info_get_icon(package_info, &icon);
          -   package_info_get_version(package_info, &version);
          -   package_info_get_type(package_info, &type);
          -   package_info_get_installed_storage(package_info, &storage);
          -   package_info_is_system_package(package_info, &system);
          -   package_info_is_removable_package(package_info, &removable);
          -   package_info_is_preload_package(package_info, &preload);
          -
          -   dlog_print(DLOG_INFO, TAG, "pkg \t= [%s]\n", pkg);
          -   dlog_print(DLOG_INFO, TAG, "label \t= [%s]\n", label);
          -   dlog_print(DLOG_INFO, TAG, "icon \t= [%s]\n", icon);
          -   dlog_print(DLOG_INFO, TAG, "version \t= [%s]\n", version);
          -   dlog_print(DLOG_INFO, TAG, "type \t= [%s]\n", type);
          -   dlog_print(DLOG_INFO, TAG, "storage \t= [%d]\n", storage);
          -   dlog_print(DLOG_INFO, TAG, "system \t= [%d]\n", system);
          -   dlog_print(DLOG_INFO, TAG, "removable \t= [%d]\n", removable);
          -   dlog_print(DLOG_INFO, TAG, "preload \t= [%d]\n", preload);
          -
          -   free(pkg);
          -   free(label);
          -   free(icon);
          -   free(version);
          -   free(type);
          +    int ret;
          +
          +    char *pkg = NULL;
          +    char *label = NULL;
          +    char *icon = NULL;
          +    char *version = NULL;
          +    char *type = NULL;
          +    package_info_installed_storage_type_e storage;
          +    bool system;
          +    bool removable;
          +    bool preload;
          +
          +    package_info_get_package(package_info, &pkg);
          +    package_info_get_label(package_info, &label);
          +    package_info_get_icon(package_info, &icon);
          +    package_info_get_version(package_info, &version);
          +    package_info_get_type(package_info, &type);
          +    package_info_get_installed_storage(package_info, &storage);
          +    package_info_is_system_package(package_info, &system);
          +    package_info_is_removable_package(package_info, &removable);
          +    package_info_is_preload_package(package_info, &preload);
          +
          +    dlog_print(DLOG_INFO, TAG, "pkg \t= [%s]\n", pkg);
          +    dlog_print(DLOG_INFO, TAG, "label \t= [%s]\n", label);
          +    dlog_print(DLOG_INFO, TAG, "icon \t= [%s]\n", icon);
          +    dlog_print(DLOG_INFO, TAG, "version \t= [%s]\n", version);
          +    dlog_print(DLOG_INFO, TAG, "type \t= [%s]\n", type);
          +    dlog_print(DLOG_INFO, TAG, "storage \t= [%d]\n", storage);
          +    dlog_print(DLOG_INFO, TAG, "system \t= [%d]\n", system);
          +    dlog_print(DLOG_INFO, TAG, "removable \t= [%d]\n", removable);
          +    dlog_print(DLOG_INFO, TAG, "preload \t= [%d]\n", preload);
          +
          +    free(pkg);
          +    free(label);
          +    free(icon);
          +    free(version);
          +    free(type);
           }
           
        • Use the package_manager_foreach_package_info() function to retrieve all package information by invoking a callback for each retrieved package:
           ret = package_manager_foreach_package_info(package_info_cb, NULL);
          -if (ret != PACKAGE_MANAGER_ERROR_NONE) 
          -{
          -   dlog_print(DLOG_ERROR, TAG, "foreach_package_info error: %d", ret);
          -}
          +if (ret != PACKAGE_MANAGER_ERROR_NONE)
          +    dlog_print(DLOG_ERROR, TAG, "foreach_package_info error: %d", ret);
           
        • Retrieving Specific Package Information

          @@ -166,7 +169,7 @@ free(label); free(icon); free(version); -// Use package information +/* Use package information */
        • When no longer needed, release the package information handle with the package_info_destroy() function: @@ -182,35 +185,30 @@ package_info_destroy(package_info);
        • Create the package manager handle (package_manager_h) using the package_manager_create() function:

          -package_manager_create(package_manager_h *manager)
          +package_manager_create(package_manager_h *manager);
           
        • Set the package event to monitor by calling the package_manager_set_event_status() function.

          The second parameter defines the package status that you want to monitor. The possible values are listed in the package_manager_status_type_e enumeration (in mobile and wearable applications).

          -
          package_manager_set_event_status(manager, PACKAGE_MANAGER_STATUS_TYPE_ALL);
          +
          +package_manager_set_event_status(manager, PACKAGE_MANAGER_STATUS_TYPE_ALL);
          +
        • Register a callback function to be invoked when the event (status change) you set above happens, and implement the callback: -
          void 
          -event_cb(const char *type, const char *package, package_manager_event_type_e event_type, 
          -         package_manager_event_state_e event_state, int progress, 
          +
          +void
          +event_cb(const char *type, const char *package, package_manager_event_type_e event_type,
          +         package_manager_event_state_e event_state, int progress,
                    package_manager_error_e error, void *user_data)
           {
          -   if (event_state == PACKAGE_MANAGER_EVENT_STATE_STARTED)
          -   {
          -      dlog_print(DLOG_INFO, LOG_TAG, "Started");
          -   }
          -   else if (event_state == PACKAGE_MANAGER_EVENT_STATE_PROCESSING)
          -   {
          -      dlog_print(DLOG_INFO, LOG_TAG, "Progress: %d", progress);
          -   }
          -   else if (event_state == PACKAGE_MANAGER_EVENT_STATE_COMPLETED)
          -   {
          -      dlog_print(DLOG_INFO, LOG_TAG, "Completed");
          -   }
          -   else
          -   {
          -      dlog_print(DLOG_INFO, LOG_TAG, "Failed");
          -   }
          +    if (event_state == PACKAGE_MANAGER_EVENT_STATE_STARTED)
          +        dlog_print(DLOG_INFO, LOG_TAG, "Started");
          +    else if (event_state == PACKAGE_MANAGER_EVENT_STATE_PROCESSING)
          +        dlog_print(DLOG_INFO, LOG_TAG, "Progress: %d", progress);
          +    else if (event_state == PACKAGE_MANAGER_EVENT_STATE_COMPLETED)
          +        dlog_print(DLOG_INFO, LOG_TAG, "Completed");
          +    else
          +        dlog_print(DLOG_INFO, LOG_TAG, "Failed");
           }
           
           package_manager_set_event_cb(manager, event_cb, NULL);
          @@ -218,7 +216,9 @@ package_manager_set_event_cb(manager, event_cb, NULL);
           
        • Free the package manager: -
          package_manager_destroy(package_manager_h manager);
          +
          +package_manager_destroy(package_manager_h manager);
          +
        • diff --git a/org.tizen.tutorials/html/native/app_framework/preference_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/preference_tutorial_n.htm index e3c3784..edbf580 100644 --- a/org.tizen.tutorials/html/native/app_framework/preference_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/preference_tutorial_n.htm @@ -23,6 +23,7 @@

          Content

          Related Info

          @@ -45,17 +46,21 @@

          Become familiar with the Preference API basics by learning about:

          -

          Managing Application Preferences

          +

          Prerequisites

          -

          You can set and get application preference data. Any stored preference data can also be shared among the applications in the same package.

          To use the functions and data types of the Preference API (in mobile and wearable applications), include the <app_preference.h> header file in your application:

           #include <app_preference.h>
           
          +

          Managing Application Preferences

          + +

          You can set and get application preference data. Any stored preference data can also be shared among the applications in the same package.

          To manage preferences:

            @@ -124,23 +129,25 @@ preference_set_changed_cb(integer_key, preference_changed_cb_impl, &previous

            Pass custom parameters to the callback function in the user_data field.

            -void 
            +void
             preference_changed_cb_impl(const char *key, void *user_data)
             {
            -   int ret = 0;
            -   int integer_output = 0;
            -
            -   dlog_print(DLOG_DEBUG, LOG_TAG, "[preference_changed_cb_impl]\n");
            -   preference_get_int(key, &integer_output);
            -     
            -   dlog_print(DLOG_DEBUG, LOG_TAG, "Key: %s has changed its value to %d \n", 
            -              key, integer_output);
            +    int ret = 0;
            +    int integer_output = 0;
            +
            +    dlog_print(DLOG_DEBUG, LOG_TAG, "[preference_changed_cb_impl]\n");
            +    preference_get_int(key, &integer_output);
            +
            +    dlog_print(DLOG_DEBUG, LOG_TAG, "Key: %s has changed its value to %d \n",
            +               key, integer_output);
             }
             

            When no longer needed, unset the callback function based on a variable key:

            -
            preference_unset_changed_cb(const char *key);
            +
            +preference_unset_changed_cb(const char *key);
            +
          • To list all records, use the foreach function. The function calls a specific callback function for each key-value pair in the database. You can pass additional data to the function in the user_data field. @@ -148,13 +155,13 @@ preference_changed_cb_impl(const char *key, void *user_data)

            If the callback function returns false, or if all the records have been opened, the foreach function ends.

            -bool 
            +bool
             preference_foreach_item_cb(const char *key, void *user_data)
             {
            -   dlog_print(DLOG_DEBUG, LOG_TAG, "[preference_foreach_item_cb]\n");
            -   dlog_print(DLOG_DEBUG, LOG_TAG, "Key found: %s\n", key);
            +    dlog_print(DLOG_DEBUG, LOG_TAG, "[preference_foreach_item_cb]\n");
            +    dlog_print(DLOG_DEBUG, LOG_TAG, "Key found: %s\n", key);
             
            -   return true;
            +    return true;
             }
             
             preference_foreach_item(preference_foreach_item_cb, NULL);
            diff --git a/org.tizen.tutorials/html/native/app_framework/resource_manager_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/resource_manager_tutorial_n.htm
            new file mode 100644
            index 0000000..ad09c40
            --- /dev/null
            +++ b/org.tizen.tutorials/html/native/app_framework/resource_manager_tutorial_n.htm
            @@ -0,0 +1,236 @@
            +
            +
            +
            +	
            +	
            +	
            +	
            +		
            +	
            +	
            +	
            +	
            +
            +	Resource Manager: Setting and Getting Resources
            +
            +
            +
            +
            +	
            +
            +
            + +

            Resource Manager: Setting and Getting Resources

            + + +

            This tutorial demonstrates how you can set resources and get the appropriate resource file path using the Resource Manager tool.

            + +

            This feature is supported in mobile applications only.

            + + + + + + + + + + +
            Note
            The Resource Manager tool is supported since Tizen 2.4. +

            If you cannot access the Resource Manager view in the IDE, check the version and API version attributes in the <manifest> element of the application manifest file.

            +

            For more information about the Resource Manager tool, see Resource Manager.

            +
            + +

            Warm-up

            +

            Become familiar with the Resource Manager tool and Resource Manager API basics by learning about:

            + + +

            Prerequisites

            + +

            To use the functions and resource types of the Resource Manager API, include the <app_resource_manager.h> header file in your application:

            +
            +#include <app_resource_manager.h>
            +
            + + +

            Setting Resources Using the Resource Manager Tool

            + +

            To set the resources:

            +
              +
            1. To activate the Resource Manager view content in the IDE, select the project in the Project Explorer view. +

              Show view

              + +

              If the Resource Manager view is not visible, open it: in the IDE menu, go to Window > Show View > Other > Tizen > Resource Manager.

              +
            2. +
            3. To open the Resource Configuration Dialog window, click the Resource Manager configuration icon icon in the Resource Manager view toolbar menu.
            4. +
            5. To add resource directories for the required languages and screen resolutions, select them in the Language and DPI drop-down menus, and click Add. +

              The resource directory hierarchy is created.

              +

              Resource configuration dialog

              +
            6. +
            7. To add images in the created resource directory, drag and drop them in the Resource Manager view, or copy them directly to the resource directories. +

              Add images Image files for variants

              + + + + + + + + + +
              Note
              The file names of the resources that you want to use interchangeably based on the device conditions must be the same.
              +

              +
            8. +
            9. To view the resource directories, use the res.xml file. +

              The IDE creates the res.xml file automatically when you build the application package.

              +

              res.xml file

              +
            10. +
            + +

            Getting the Resource File Path

            +

            To get the appropriate resource file path in your code:

            +
              +
            1. Create the resource manager using the app_resource_manager_init() function. +
              +app_resource_manager_init();
              +
              +

              If the function returns APP_RESOURCE_ERROR_NONE, the resource manager has been successfully created.

              +
            2. +
            3. Get the resource path using the app_resource_manager_get() function: +
              +Evas_Object *img
              +char *img_path = NULL;
              +
              +app_resource_manager_get(APP_RESOURCE_TYPE_IMAGE, "flag.png", &img_path);
              +
              +Evas* canvas = evas_object_evas_get(ad->conform);
              +img = evas_object_image_filled_add(canvas);
              +
              +if (img_path != NULL) {
              +    evas_object_image_file_set(img, img_path, NULL);
              +
              +    evas_object_move(img, 50, 50);
              +    evas_object_resize(img, 300, 200);
              +    evas_object_show(img);
              +    free(img_path);
              +}
              +
              +

              If the function returns APP_RESOURCE_ERROR_NONE, the resource path has been successfully retrieved.

              +

              You can retrieve 4 types of resources, as defined in the app_resource_e enumerator.

              + +
            4. +
            5. When you no longer need to get the resource path, call the app_resource_manager_release() function to release the resource manager instance. +

              The resource manager instance must be released only when the application is closing, so this function must be called in the app_terminate() callback function.

              + +
              +static void
              +app_terminate(void *data)
              +{
              +    app_resource_manager_release();
              +}
              +
              +
            6. +
            + + +

            Checking Resources with the Emulator Manager

            + +

            To check how the resources are shown in different device configurations, create emulator instances with different resolutions with the Emulator Manager and run the application on the instances using different language settings:

            + +
              +
            1. Open the Emulator Manager from the IDE Connection Explorer view. +

              Connection Explorer buttons

              +

              If the Connection Explorer view is not visible, open it: in the IDE menu, go to Window > Show View > Connection Explorer or Window > Show View > Other > Tizen > Connection Explorer.

              +
            2. +
            3. In the Emulator Manager window, create 2 emulator instances with different resolutions: +
              1. Click Create New Emulator > mobile, select the WVGA Mobile template, and click Confirm. +

                Create a new emulator

                +

                Confirm the emulator settings

                +
              2. +
              3. Click Create New Emulator > mobile, select the HD Mobile template, and click Confirm. +

                Create a HD emulator

              4. +
              +
            4. +
            5. Run the application on the WVGA Mobile device emulator: +
              1. In the Emulator Manager window, select the WVGA Mobile emulator and click the play button. +

                The WVGA Mobile device emulator starts.

                +

                Start the emulator Emulator running

                +
              2. +
              3. In the IDE Project Explorer view, right-click the application and select Run As > Tizen Native Application. +

                The application launches on the emulator.

                +

                Application running on the Emulator

                +
              4. +
              5. To close the emulator, right-click it and select Close. +
              6. +
              +
            6. + +
            7. Run the application on the HD Mobile device emulator: +
              1. In the Emulator Manager window, select the HD Mobile emulator and click the play button. +

                The HD Mobile device emulator starts.

                +

                Start the emulator Emulator running

                +
              2. +
              3. In the IDE Project Explorer view, right-click the application and select Run As > Tizen Native Application. +

                The application launches on the emulator, and you can see that a different image is displayed based on the device display resolution.

                +

                Application running on the Emulator

                +
              4. +
              +
            8. +
            9. If you change the emulator language settings, and run the application again, you can also see that a different image is displayed based on the device language (in this case, US English and Korean). +

              English virtual device running on Emulator Korean virtual device running on Emulator

              +
            10. +
            + + + + + + +
            + +Go to top + + + + + + + diff --git a/org.tizen.tutorials/html/native/app_framework/service_app_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/service_app_tutorial_n.htm index 88f3b45..527b4e3 100644 --- a/org.tizen.tutorials/html/native/app_framework/service_app_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/service_app_tutorial_n.htm @@ -23,6 +23,7 @@

            Content

            Related Info

            @@ -44,20 +45,24 @@

            Become familiar with the Service Application API basics by learning about:

              +
            • Prerequisites +

              Prepare your application to use the service application functionality.

            • Monitoring Events

              Register and set callbacks for application state change events and system events.

            -

            Monitoring Events

            - -

            To monitor application state change and system events:

            +

            Prerequisites

            -
              -
            1. To use the functions and data types of the Service Application API (in mobile and wearable applications), include the <service_app.h> header file in your application:

              +

              To use the functions and data types of the Service Application API (in mobile and wearable applications), include the <service_app.h> header file in your application:

               #include <service_app.h>
              -
            2. -
            3. +
            + +

            Monitoring Events

            + +

            To monitor application state change and system events:

            + +
            1. Add callbacks for application state change events:

                @@ -66,12 +71,12 @@

                This callback is called when the application is launched. Use the callback to write the necessary initialization code, such as setting up the dbus connection.

                The callback returns a Boolean value. If there is a critical error during the launch, the return is false, thereby cancelling the launch. Otherwise, the return is true.

                -bool 
                +bool
                 service_app_create(void *data)
                 {
                -   dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__);
                +    dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__);
                 
                -   return true;
                +    return true;
                 }
                 
                @@ -83,10 +88,10 @@ service_app_create(void *data) void service_app_terminate(void *data) { -   dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__); -   service_app_exit(); +    dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__); +    service_app_exit(); -   return; +    return; } @@ -97,10 +102,10 @@ service_app_terminate(void *data) void service_app_control(app_control_h app_control, void *data) { -   dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__); -   service_app_exit(); +    dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__); +    service_app_exit(); -   return; +    return; } @@ -112,13 +117,13 @@ service_app_control(app_control_h app_control, void *data)
              • Low memory callback

                This callback is called when the device is low on memory.

                -void 
                +void
                 service_app_low_memory_callback(void *data)
                 {
                -   dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__);
                -   service_app_exit();
                +    dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__);
                +    service_app_exit();
                 
                -   return;
                +    return;
                 }
                 
              • @@ -126,13 +131,13 @@ service_app_low_memory_callback(void *data)
              • Low battery callback

                This callback is called when the device is low on battery power.

                -void 
                +void
                 service_app_low_battery_callback(void *data)
                 {
                -   dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__);
                -   service_app_exit();
                +    dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__);
                +    service_app_exit();
                 
                -   return;
                +    return;
                 }
                 
              • @@ -143,21 +148,21 @@ service_app_low_battery_callback(void *data)

                Set the application state change event callbacks in the service_app_event_callback_s structure. The structure is passed to the function that starts the service application.

                You can register the system event callbacks with the service_app_add_event_handler() function.

                -int 
                +int
                 main(int argc, char* argv[])
                 {
                -   appdata_s ad = {0,};
                -   service_app_lifecycle_callback_s event_callback = {0,};
                +    appdata_s ad = {0,};
                +    service_app_lifecycle_callback_s event_callback = {0,};
                 
                -   dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__);
                +    dlog_print(DLOG_DEBUG, LOG_TAG, "%s", __func__);
                 
                -   event_callback.create = service_app_create;
                -   event_callback.terminate = service_app_terminate;
                -   event_callback.app_control = service_app_control;
                +    event_callback.create = service_app_create;
                +    event_callback.terminate = service_app_terminate;
                +    event_callback.app_control = service_app_control;
                 
                -   dlog_print(DLOG_DEBUG, LOG_TAG, "service_app_main() is called.");
                +    dlog_print(DLOG_DEBUG, LOG_TAG, "service_app_main() is called.");
                 
                -   return service_app_main(argc, argv, &event_callback, &ad);
                +    return service_app_main(argc, argv, &event_callback, &ad);
                 }
                 
                diff --git a/org.tizen.tutorials/html/native/app_framework/shortcut_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/shortcut_tutorial_n.htm index 3370fd1..2edf396 100644 --- a/org.tizen.tutorials/html/native/app_framework/shortcut_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/shortcut_tutorial_n.htm @@ -23,6 +23,7 @@

                Content

                @@ -45,23 +46,27 @@

                Warm-up

                Become familiar with the Shortcut API basics by learning about:

                + +

                Prerequisites

                + +

                To use the functions and data types of the Shortcut API, include the <shortcut_manager.h> header file in your application:

                +
                +#include <shortcut_manager.h>
                +
                +

                Adding a Shortcut

                To add a shortcut to the home screen:

                  - -
                1. To use the functions and data types of the Shortcut API, include the <shortcut_manager.h> header file in your application:

                  -
                  -#include <shortcut_manager.h>
                  -
                  -
                2. Add a shortcut using the shortcut_add_to_home() function:

                  @@ -72,17 +77,13 @@ shortcut_add_to_home("Music Player", LAUNCH_BY_APP, NULL, "/path/
                   
                   
                3. Define a callback function to track possible errors:

                  -static int 
                  +static int
                   result_cb(int ret, void *data)
                   {
                  -   if (ret < 0)
                  -   {
                  -      // Error handling
                  -   }
                  -   else
                  -   {
                  -      // No error detected
                  -   }
                  +    if (ret < 0)
                  +        /* Error handling */
                  +    else
                  +        /* No error detected */
                   }
                   
                @@ -94,7 +95,7 @@ result_cb(int ret, void *data)
              • Add a widget with the shortcut_add_to_home_widget() function:

                -shortcut_add_to_home_widget("alter_name", WIDGET_SIZE_1x1, "org.tizen.testwidget", 
                +shortcut_add_to_home_widget("alter_name", WIDGET_SIZE_1x1, "org.tizen.testwidget",
                                             "/opt/media/Pictures/alter_icon.png", -1.0f, 0, result_cb, NULL);
                 
                @@ -102,17 +103,13 @@ shortcut_add_to_home_widget("alter_name", WIDGET_SIZE_1x1, "org.t
              • Define a callback function to track possible errors:

                -static int 
                +static int
                 result_cb(int ret, void *data)
                 {
                -   if (ret < 0)
                -   {
                -      // Error handling
                -   }
                -   else
                -   {
                -      // No error detected
                -   }
                +    if (ret < 0)
                +        /* Error handling */
                +    else
                +        /* No error detected */
                 }
                 
            diff --git a/org.tizen.tutorials/html/native/app_framework/watch_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/watch_tutorial_n.htm index 1cf7b20..1e87f05 100644 --- a/org.tizen.tutorials/html/native/app_framework/watch_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/watch_tutorial_n.htm @@ -23,7 +23,7 @@

            Content

              -
            • Initializing the Watch Application
            • +
            • Prerequisites
            • Managing Life-cycle Callbacks
            • Managing System-related Callbacks
            • Drawing the Watch UI
            • @@ -50,8 +50,8 @@

              Warm-up

              Become familiar with the Watch Application API basics by learning about:

              - -

              Initializing the Watch Application

              - -

              To initialize the watch application:

              +

              Prerequisites

              + +

              To enable your application to use the watch functionality:

                -
              1. To use the functions and data types of the Watch Application API, include the <watch_app.h> header file in your application: +
              2. +

                To use the Watch Application API's watch_app_ambient_tick_cb() callback in the ambient mode, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

                -#include <watch_app.h>
                +<privileges>
                +   <privilege>http://tizen.org/privilege/alarm.set</privilege>
                +</privileges>
                 
              3. -
              4. To use the watch_app_ambient_tick_cb() callback in the ambient mode, add the http://tizen.org/privilege/alarm.set privilege to the manifest file of the application. -
              5. +
              6. To use the functions and data types of the Watch Application API, include the <watch_app.h> and <watch_app_efl.h> header files in your application: +
                +#include <watch_app.h>
                +#include <watch_app_efl.h>
                +
              7. Edit the watch application settings in the manifest file.
              @@ -87,62 +92,62 @@
              • The create event is triggered before the application main loop starts. In this callback, you can initialize the application resources, such as create windows and data structures.
                -bool 
                +bool
                 app_create(int width, int height, void* user_data)
                 {
                -   // Hook to take necessary actions before the main event loop starts
                -   // This usually means initializing the UI and application data
                +    /* Hook to take necessary actions before the main event loop starts */
                +    /* This usually means initializing the UI and application data */
                 
                -   return true;
                +    return true;
                 }
                 
              • The app_control event is triggered when another application sends a launch request to the application.
                -void 
                -app_control(app_control_h app_control, void* user_data) 
                +void
                +app_control(app_control_h app_control, void* user_data)
                 {
                -   // Handle the launch request
                -   // Show the user the task requested through the "app_control" parameter
                +    /* Handle the launch request */
                +    /* Show the user the task requested through the "app_control" parameter */
                 }
                 
              • The pause event is triggered when the application is completely obscured by another application and becomes invisible.
                -void 
                -app_pause(void* user_data) 
                +void
                +app_pause(void* user_data)
                 {
                -   // Take necessary actions when application becomes invisible 
                -   // Release the resources needed to draw the normal watch 
                +    /* Take necessary actions when application becomes invisible */
                +    /* Release the resources needed to draw the normal watch */
                 }
                 
              • The resume event is triggered when the application becomes visible.
                -void 
                +void
                 app_resume(void* user_data)
                 {
                -   // Take the necessary actions when application becomes visible
                -   // Acquire the resources needed to draw the normal watch 
                +    /* Take the necessary actions when application becomes visible */
                +    /* Acquire the resources needed to draw the normal watch */
                 }
                 
              • The terminate event is triggered when the application main loop exits.
                -void 
                +void
                 app_terminate(void* user_data)
                 {
                -   // Release all resources
                +    /* Release all resources */
                 }
                 
              • The time_tick event is triggered at least once per second. The watch applications can get the current time from the watch_time time handle to draw a normal watch.
                -void 
                +void
                 app_time_tick(watch_time_h watch_time, void* user_data)
                 {
                -   // Called at least once per second
                -   // Draw a normal watch with the hour, minute, and second
                +    /* Called at least once per second */
                +    /* Draw a normal watch with the hour, minute, and second */
                 }
                 
              • @@ -150,27 +155,25 @@ app_time_tick(watch_time_h watch_time, void* user_data)
              • Set the life-cycle callbacks in the watch_app_lifecycle_callback_s structure, and pass the structure to the watch_app_main() function that starts the watch application event loop:
                -int 
                +int
                 main(int argc, char* argv[])
                 {
                -   appdata ad = {0,};
                -   watch_app_lifecycle_callback_s callback = {0,};
                -
                -   callback.create = app_create;
                -   callback.app_control = app_control;
                -   callback.terminate = app_terminate;
                -   callback.pause = app_pause;
                -   callback.resume = app_resume;
                -   callback.time_tick = app_time_tick;
                -   // Ambient mode callbacks
                -
                -   int ret = watch_app_main(argc, argv, &callback, &ad);
                -   if (ret != APP_ERROR_NONE) 
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_main() failed. err = %d", ret);
                -   }
                -
                -   return ret;
                +    appdata ad = {0,};
                +    watch_app_lifecycle_callback_s callback = {0,};
                +
                +    callback.create = app_create;
                +    callback.app_control = app_control;
                +    callback.terminate = app_terminate;
                +    callback.pause = app_pause;
                +    callback.resume = app_resume;
                +    callback.time_tick = app_time_tick;
                +    /* Ambient mode callbacks */
                +
                +    int ret = watch_app_main(argc, argv, &callback, &ad);
                +    if (ret != APP_ERROR_NONE)
                +        dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_main() failed. err = %d", ret);
                +
                +    return ret;
                 }
                 
              • @@ -190,59 +193,51 @@ main(int argc, char* argv[])
              -void 
              +void
               lang_changed(app_event_info_h event_info, void* user_data)
               {
              -   // Take the necessary actions when the language setting changes
              +    /* Take the necessary actions when the language setting changes */
               }
              - 
              -void 
              +
              +void
               region_changed(app_event_info_h event_info, void* user_data)
               {
              -   // Take the necessary actions when the region setting changes
              +    /* Take the necessary actions when the region setting changes */
               }
              - 
              -void 
              +
              +void
               low_battery(app_event_info_h event_info, void* user_data)
               {
              -   // Take the necessary actions when the system is running low on battery
              -   watch_app_exit();
              +    /* Take the necessary actions when the system is running low on battery */
              +    watch_app_exit();
               }
              - 
              -void 
              +
              +void
               low_memory(app_event_info_h event_info, void* user_data)
               {
              -   // Take the necessary actions when the system is running low on memory
              -   watch_app_exit();
              +    /* Take the necessary actions when the system is running low on memory */
              +    watch_app_exit();
               }
               
            • Register the callback functions:

              -bool 
              +bool
               app_create(void *user_date)
               {
              -   // Register a callback for each system event
              -   if (watch_app_add_event_handler(&handler, APP_EVENT_LANGUAGE_CHANGED, lang_changed, NULL) != APP_ERROR_NONE) 
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_add_event_handler() failed");
              -   }
              -
              -   if (watch_app_add_event_handler(&handler, APP_EVENT_REGION_FORMAT_CHANGED, region_changed, NULL) != APP_ERROR_NONE) 
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_add_event_handler() failed");
              -   }
              -
              -   if (watch_app_add_event_handler(&handler, APP_EVENT_LOW_BATTERY, low_battery, NULL) != APP_ERROR_NONE) 
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_add_event_handler() failed");
              -   }
              -
              -   if (watch_app_add_event_handler(&handler, APP_EVENT_LOW_MEMORY, low_ memory, NULL) != APP_ERROR_NONE) 
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_add_event_handler() failed");
              -   }
              -
              -   return true;
              +    /* Register a callback for each system event */
              +    if (watch_app_add_event_handler(&handler, APP_EVENT_LANGUAGE_CHANGED, lang_changed, NULL) != APP_ERROR_NONE)
              +        dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_add_event_handler() failed");
              +
              +    if (watch_app_add_event_handler(&handler, APP_EVENT_REGION_FORMAT_CHANGED, region_changed, NULL) != APP_ERROR_NONE)
              +        dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_add_event_handler() failed");
              +
              +    if (watch_app_add_event_handler(&handler, APP_EVENT_LOW_BATTERY, low_battery, NULL) != APP_ERROR_NONE)
              +        dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_add_event_handler() failed");
              +
              +    if (watch_app_add_event_handler(&handler, APP_EVENT_LOW_MEMORY, low_ memory, NULL) != APP_ERROR_NONE)
              +        dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_add_event_handler() failed");
              +
              +    return true;
               }
               
            • @@ -253,59 +248,56 @@ app_create(void *user_date)
              1. Get the window object with the watch_app_get_elm_win() function:
                -#include <watch_app_efl.h>
                -
                -typedef struct 
                -{
                -   Evas *evas;
                -   Evas_Object *win;
                -   Evas_Object *conform;
                -   Evas_Object *label;
                -} appdata;
                -
                -static void 
                +struct _appdata {
                +    Evas *evas;
                +    Evas_Object *win;
                +    Evas_Object *conform;
                +    Evas_Object *label;
                +};
                +typedef struct _appdata appdata;
                +
                +static void
                 __create_base_gui(appdata *ad, int width, int height)
                 {
                -   int ret;
                -   watch_time_h watch_time = NULL;
                -   ret = watch_app_get_elm_win(&ad->win);
                -
                -   if (ret != APP_ERROR_NONE) 
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "failed to get window. err = %d", ret);
                -
                -      return;
                -   }
                -   evas_object_resize(ad->win, width, height);
                -   ad->conform = elm_conformant_add(ad->win);      
                -   evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
                -   elm_win_resize_object_add(ad->win, ad->conform);
                -   evas_object_show(ad->conform);
                -   ad->label = elm_label_add(ad->conform);
                -   evas_object_resize(ad->label, width, height / 3);
                -   evas_object_move(ad->label, 0, height / 3);
                -   evas_object_show(ad->label); 
                +    int ret;
                +    watch_time_h watch_time = NULL;
                +    ret = watch_app_get_elm_win(&ad->win);
                +
                +    if (ret != APP_ERROR_NONE) {
                +        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get window. err = %d", ret);
                +
                +        return;
                +    }
                +    evas_object_resize(ad->win, width, height);
                +    ad->conform = elm_conformant_add(ad->win);
                +    evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
                +    elm_win_resize_object_add(ad->win, ad->conform);
                +    evas_object_show(ad->conform);
                +    ad->label = elm_label_add(ad->conform);
                +    evas_object_resize(ad->label, width, height / 3);
                +    evas_object_move(ad->label, 0, height / 3);
                +    evas_object_show(ad->label);
                 
              2. Get the time handle for the current time with the watch_time_get_current_time() function:
                -   ret = watch_time_get_current_time(&watch_time);
                -   if (ret != APP_ERROR_NONE)
                -      dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current time. err = %d", ret);
                -   __update_watch(ad, watch_time);
                +    ret = watch_time_get_current_time(&watch_time);
                +    if (ret != APP_ERROR_NONE)
                +        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current time. err = %d", ret);
                +    __update_watch(ad, watch_time);
                 }
                 
                -bool 
                +bool
                 app_create(void *user_date)
                 {
                -   // Define system callbacks
                +    /* Define system callbacks */
                 
                -   appdata *ad = data;
                -   __create_base_gui(ad, width, height);
                +    appdata *ad = data;
                +    __create_base_gui(ad, width, height);
                 
                -   return true;
                -} 
                +    return true;
                +}
                 
              3. When you no longer need the watch_time_h time handle, release it with the watch_time_delete() function. @@ -316,33 +308,35 @@ app_create(void *user_date)

                You can get the current local time in various formats using the Watch Application methods and the time handle. When retrieving the current local time, the time handle parameter cannot be NULL.

                -

                For example, you can use the watch_time_get_minute() method to retrieve the current minute value.

                +

                For example, you can use the watch_time_get_minute() function to retrieve the current minute value.

                -static void 
                +static void
                 __update_watch(appdata *ad, watch_time_h watch_time)
                 {
                -   watch_text[TEXT_BUF_SIZE];
                -   int hour24, minute, second;
                -
                -   if (watch_time == NULL)
                -       return;
                -
                -   watch_time_get_hour24(watch_time, &hour24);
                -   watch_time_get_minute(watch_time, &minute);
                -   watch_time_get_second(watch_time, &second);
                -   snprintf(watch_text, TEXT_BUF_SIZE, 
                -            "<align=center>Hello Watch<br/>%02d:%02d:%02d</align>",
                -            hour24, minute, second);
                -   elm_object_text_set(ad->label, watch_text);
                -} 
                -
                -static void 
                +    watch_text[TEXT_BUF_SIZE];
                +    int hour24;
                +    int minute;
                +    int second;
                +
                +    if (watch_time == NULL)
                +        return;
                +
                +    watch_time_get_hour24(watch_time, &hour24);
                +    watch_time_get_minute(watch_time, &minute);
                +    watch_time_get_second(watch_time, &second);
                +    snprintf(watch_text, TEXT_BUF_SIZE,
                +             "<align=center>Hello Watch<br/>%02d:%02d:%02d</align>",
                +             hour24, minute, second);
                +    elm_object_text_set(ad->label, watch_text);
                +}
                +
                +static void
                 __create_base_gui(appdata *ad, int width, int height)
                 {
                -   // Get the window object and time handle
                +    /* Get the window object and time handle */
                 
                -   __update_watch(ad, watch_time);
                -} 
                +    __update_watch(ad, watch_time);
                +}
                 

                You can also get the UTC time and time zone, if needed, using the watch_time_get_utc_time(), watch_time_get_utc_timestamp(), and watch_time_get_time_zone() functions.

                @@ -355,48 +349,42 @@ __create_base_gui(appdata *ad, int width, int height)
                • The ambient_changed event is triggered when the ambient mode is enabled or disabled in the device. You can use the callback to initialize your ambient mode UI.

                • The ambient_tick event is triggered every minute while the device is in the ambient mode. You can use the callback to update the time on your watch application in the ambient mode. In this callback, do not perform time-consuming task and always update the UI as fast as possible. The platform can put the device to sleep shortly after the ambient tick expires.

                -void 
                +void
                 app_ambient_tick(watch_time_h watch_time, void* user_data)
                 {
                -   appdata *ad = user_data;
                -   __update_watch(ad, watch_time);
                +    appdata *ad = user_data;
                +    __update_watch(ad, watch_time);
                 }
                 
                -void 
                +void
                 app_ambient_changed(bool ambient_mode, void* user_data)
                 {
                -   if (ambient_mode) 
                -   {
                -      // Prepare to enter the ambient mode
                -   }
                -   else 
                -   {
                -      // Prepare to exit the ambient mode
                -   }
                +    if (ambient_mode)
                +        /* Prepare to enter the ambient mode */
                +    else
                +        /* Prepare to exit the ambient mode */
                 }
                 
              4. Register the ambient mode callbacks:
                -int 
                +int
                 main(int argc, char* argv[])
                 {
                -   appdata ad = {0,};
                -   watch_app_lifecycle_callback_s callback = {0,};
                +    appdata ad = {0,};
                +    watch_app_lifecycle_callback_s callback = {0,};
                 
                -   // Other life-cycle callbacks
                +    /* Other life-cycle callbacks */
                 
                -   callback.ambient_tick = app_ambient_tick;
                -   callback.ambient_changed = app_ambient_changed;
                +    callback.ambient_tick = app_ambient_tick;
                +    callback.ambient_changed = app_ambient_changed;
                 
                -   int ret = watch_app_main(argc, argv, &callback, &ad);
                -   if (ret != APP_ERROR_NONE) 
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_main() failed. err = %d", ret);
                -   }
                +    int ret = watch_app_main(argc, argv, &callback, &ad);
                +    if (ret != APP_ERROR_NONE)
                +        dlog_print(DLOG_ERROR, LOG_TAG, "watch_app_main() failed. err = %d", ret);
                 
                -   return ret;
                -} 
                +    return ret;
                +}
                 
              diff --git a/org.tizen.tutorials/html/native/app_framework/widget_tutorial_n.htm b/org.tizen.tutorials/html/native/app_framework/widget_tutorial_n.htm index 424c184..4e26df7 100644 --- a/org.tizen.tutorials/html/native/app_framework/widget_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/app_framework/widget_tutorial_n.htm @@ -23,7 +23,7 @@

              Content

                -
              • Initializing the Widget Application
              • +
              • Prerequisites
              • Creating the Widget Application
              • Managing Widget Instance Life-cycle Callbacks
              • Drawing the Widget UI
              • @@ -49,8 +49,8 @@

                Warm-up

                Become familiar with the Widget Application API basics by learning about:

                -

                Initializing the Widget Application

                - -

                To initialize the widget application:

                +

                Prerequisites

                + +

                To enable your application to use the widget functionality:

                  -
                1. To use the functions and data types of the Widget Application API (in mobile and wearable applications), include the <widget_app.h> header file in your application: +
                2. To use the functions and data types of the Widget Application API (in mobile and wearable applications), include the <widget_app.h> and <widget_app_efl.h> header files in your application:
                   #include <widget_app.h>
                  +#include <widget_app_efl.h>
                   
                3. Edit the widget application settings in the manifest file.
                @@ -84,48 +85,47 @@ int main(int argc, char *argv[]) { -   widget_app_lifecycle_callback_s ops = {0,}; -   int ret; +    widget_app_lifecycle_callback_s ops = {0,}; +    int ret; -   ops.create = widget_app_create; -   ops.terminate = widget_app_terminate; +    ops.create = widget_app_create; +    ops.terminate = widget_app_terminate; -   ret = widget_app_main(argc, argv, &ops, NULL); -   if (ret != WIDGET_ERROR_NONE) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "widget_app_main() failed. err = %d", ret); -   } +    ret = widget_app_main(argc, argv, &ops, NULL); +    if (ret != WIDGET_ERROR_NONE) +        dlog_print(DLOG_ERROR, LOG_TAG, "widget_app_main() failed. err = %d", ret); -   return ret; -} +    return ret; +}
              • Use the widget_app_create() life-cycle function to initialize any resources that can be shared among widget instances. This function is called before the main event loop starts.
                -widget_class_h widget_app_create(void *user_data)
                +widget_class_h
                +widget_app_create(void *user_data)
                 {
                -   // Hook to take necessary actions before main event loop starts
                -   widget_instance_lifecycle_callback_s obj_callback = {0,};
                -   app_event_handler_h handlers[5] = {NULL,};
                +    /* Hook to take necessary actions before main event loop starts */
                +    widget_instance_lifecycle_callback_s obj_callback = {0,};
                +    app_event_handler_h handlers[5] = {NULL,};
                 
                -   // Register the callback functions for the widget instance life-cycle
                +    /* Register the callback functions for the widget instance life-cycle */
                 
              • Register the callback functions for the system events.

                At the end of the widget_app_create() function, remember to create a widget instance class and return a handle for it, so that the handle can be used for making widget instances.

                -   // Register the callback functions for system events
                -   widget_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, 
                -                                widget_app_low_battery, NULL);
                -   widget_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, 
                -                                widget_app_low_memory, NULL);
                -   widget_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, 
                -                                widget_app_lang_changed, NULL);
                -   widget_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], 
                -                                APP_EVENT_REGION_FORMAT_CHANGED, widget_app_region_changed, NULL);
                -
                -   return widget_app_class_create(obj_callback, user_data);
                +    /* Register the callback functions for system events */
                +    widget_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY,
                +                                 widget_app_low_battery, NULL);
                +    widget_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY,
                +                                 widget_app_low_memory, NULL);
                +    widget_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED,
                +                                 widget_app_lang_changed, NULL);
                +    widget_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
                +                                 APP_EVENT_REGION_FORMAT_CHANGED, widget_app_region_changed, NULL);
                +
                +    return widget_app_class_create(obj_callback, user_data);
                 }
                 

                When the system-related callback are no longer needed, remove them with the widget_app_remove_event_handler() function.

                @@ -133,36 +133,36 @@ widget_class_h widget_app_create(void *user_data)
              • Define the callback functions for the system events:
                -void 
                +void
                 widget_app_lang_changed(app_event_info_h event_info, void* user_data)
                 {
                -   // Take actions when language setting changes and messages must be translated
                -   char *locale = NULL;
                -   app_event_get_language(event_info, &locale);
                -   elm_language_set(locale);
                -   free(locale);
                +    /* Take actions when language setting changes and messages must be translated */
                +    char *locale = NULL;
                +    app_event_get_language(event_info, &locale);
                +    elm_language_set(locale);
                +    free(locale);
                 }
                 
                -void 
                +void
                 widget_app_region_changed(app_event_info_h event_info, void* user_data)
                 {
                -   // Take actions when the time zone changes
                +    /* Take actions when the time zone changes */
                 }
                 
                -void 
                +void
                 widget_app_low_battery(app_event_info_h event_info, void* user_data)
                 {
                -   // Take actions when system is running low on battery (less than 5%)
                -   // Save the work and avoid battery-intensive processes
                -   widget_app_exit();
                +    /* Take actions when system is running low on battery (less than 5%) */
                +    /* Save the work and avoid battery-intensive processes */
                +    widget_app_exit();
                 }
                 
                -void 
                +void
                 widget_app_low_memory(app_event_info_h event_info, void* user_data)
                 {
                -   // Take actions when system is running on low memory
                -   // Save the work and release resources; if necessary, some apps can be killed
                -   widget_app_exit();
                +    /* Take actions when system is running on low memory */
                +    /* Save the work and release resources; if necessary, some apps can be killed */
                +    widget_app_exit();
                 }
                 
              • @@ -172,8 +172,8 @@ widget_app_low_memory(app_event_info_h event_info, void* user_data) static void widget_app_terminate(void *user_data) { -   // Release all resources -} +    /* Release all resources */ +} @@ -186,20 +186,18 @@ widget_app_terminate(void *user_data)
              • This callback is triggered when the widget instance is created.

                Initialize resources for this widget instance and draw the UI. If bundle content is not NULL, restore the previous status.

                -int 
                +int
                 widget_instance_create(widget_context_h context, bundle *content, int w, int h, void *user_data)
                 {
                -   widget_instance_data_s *wid = (widget_instance_data_s*) malloc(sizeof(widget_instance_data_s));
                -   int ret;
                +    widget_instance_data_s *wid = (widget_instance_data_s*)malloc(sizeof(widget_instance_data_s));
                +    int ret;
                 
                -   if (content != NULL) 
                -   {
                -      // Recover the previous status with the bundle object
                -   }
                +    if (content != NULL)
                +        /* Recover the previous status with the bundle object */
                 
                -   // Create the UI
                +    /* Create the UI */
                 
                -   return WIDGET_ERROR_NONE;
                +    return WIDGET_ERROR_NONE;
                 }
                 
              • @@ -207,17 +205,15 @@ widget_instance_create(widget_context_h context, bundle *content, int w, int h,
              • This callback is triggered when the widget instance is destroyed.

                Release all widget resources. If the reason for the termination is not WIDGET_APP_DESTROY_TYPE_PERMANENT, store the current status with the incoming bundle.

                -int 
                -widget_instance_destroy(widget_context_h context, widget_app_destroy_type_e reason, 
                +int
                +widget_instance_destroy(widget_context_h context, widget_app_destroy_type_e reason,
                                         bundle *content, void *user_data)
                 {
                -   if (reason != WIDGET_APP_DESTROY_TYPE_PERMANENT) 
                -   {
                -      // Save the current status at the bundle object
                -   }
                +    if (reason != WIDGET_APP_DESTROY_TYPE_PERMANENT)
                +        /* Save the current status at the bundle object */
                 
                -   return WIDGET_ERROR_NONE;
                -} 
                +    return WIDGET_ERROR_NONE;
                +}
                 
              • @@ -225,40 +221,40 @@ widget_instance_destroy(widget_context_h context, widget_app_destroy_type_e reas
              • This callback is triggered when the widget instance is paused.

                Take the necessary actions since the widget instance becomes invisible. The framework can destroy a paused widget instance.

                -int 
                +int
                 widget_instance_pause(widget_context_h context, void *user_data)
                 {
                -   return WIDGET_ERROR_NONE;
                +    return WIDGET_ERROR_NONE;
                 }
                 
              • This callback is triggered when the widget instance is resumed.

                Take the necessary actions since the widget instance becomes visible.

                -int 
                +int
                 widget_instance_resume(widget_context_h context, void *user_data)
                 {
                -   return WIDGET_ERROR_NONE;
                +    return WIDGET_ERROR_NONE;
                 }
                 
              • This callback is triggered before the widget instance is resized.

                Take the necessary actions to accommodate the new size.

                -int 
                +int
                 widget_instance_resize(widget_context_h context, int w, int h, void *user_data)
                 {
                -   return WIDGET_ERROR_NONE;
                +    return WIDGET_ERROR_NONE;
                 } 
                 
              • This callback is triggered when a widget update event is received.

                Take the necessary actions for the widget update. If the force parameter is true, the widget can be updated even in the pause state.

                -int 
                +int
                 widget_instance_update(widget_context_h context, bundle *content, int force, void *user_data)
                 {
                -   return WIDGET_ERROR_NONE;
                +    return WIDGET_ERROR_NONE;
                 }
                 
              • @@ -267,20 +263,21 @@ widget_instance_update(widget_context_h context, bundle *content, int force, voi
              • Register the callbacks in the widget_instance_lifecycle_callback_s structure during the widget application initialization:
                -widget_class_h widget_app_create(void *user_data)
                +widget_class_h
                +widget_app_create(void *user_data)
                 {
                -   widget_instance_lifecycle_callback_s obj_callback = {0,};
                -   // Register the callback functions
                -   obj_callback.create = widget_instance_create;
                -   obj_callback.destroy = widget_instance_destroy;
                -   obj_callback.pause = widget_instance_pause;
                -   obj_callback.resume = widget_instance_resume;
                -   obj_callback.resize = widget_instance_resize;
                -   obj_callback.update = widget_instance_update;
                -
                -   // Register system-related callbacks
                -
                -   return widget_app_class_create(obj_callback, user_data);
                +    widget_instance_lifecycle_callback_s obj_callback = {0,};
                +    /* Register the callback functions */
                +    obj_callback.create = widget_instance_create;
                +    obj_callback.destroy = widget_instance_destroy;
                +    obj_callback.pause = widget_instance_pause;
                +    obj_callback.resume = widget_instance_resume;
                +    obj_callback.resize = widget_instance_resize;
                +    obj_callback.update = widget_instance_update;
                +
                +    /* Register system-related callbacks */
                +
                +    return widget_app_class_create(obj_callback, user_data);
                 }
                 
              • @@ -290,77 +287,69 @@ widget_class_h widget_app_create(void *user_data)

                To draw the widget UI, you must get a window object with the widget_app_get_elm_win() function and create the UI on the home screen:

                -#include <widget_app_efl.h>
                -
                -typedef struct 
                -widget_instance_data 
                -{
                -   Evas_Object *win;
                -   Evas_Object *conform;
                -   Evas_Object *label;
                -} widget_instance_data_s;
                +struct widget_instance_data {
                +    Evas_Object *win;
                +    Evas_Object *conform;
                +    Evas_Object *label;
                +};
                +typedef struct widget_instance_data widget_instance_data_s;
                 
                 static int
                 widget_instance_create(widget_context_h context, bundle *content, int w, int h, void *user_data)
                 {
                -   widget_instance_data_s *wid = (widget_instance_data_s*) malloc(sizeof(widget_instance_data_s));
                +    widget_instance_data_s *wid = (widget_instance_data_s*)malloc(sizeof(widget_instance_data_s));
                 
                -   int ret;
                -   if (content != NULL) 
                -   {
                -      // Recover the previous status with the bundle object
                -   }
                +    int ret;
                +    if (content != NULL)
                +        /* Recover the previous status with the bundle object */
                 
                -   // Window 
                -   ret = widget_app_get_elm_win(context, &wid->win);
                -   if (ret != WIDGET_ERROR_NONE) 
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "failed to get window. err = %d", ret);
                +    /* Window */
                +    ret = widget_app_get_elm_win(context, &wid->win);
                +    if (ret != WIDGET_ERROR_NONE) {
                +        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get window. err = %d", ret);
                 
                -      return WIDGET_ERROR_FAULT;
                -   }
                +        return WIDGET_ERROR_FAULT;
                +    }
                 
                -   evas_object_resize(wid->win, w, h);
                +    evas_object_resize(wid->win, w, h);
                 
                -   // Conformant
                -   wid->conform = elm_conformant_add(wid->win);
                -   evas_object_size_hint_weight_set(wid->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
                -   elm_win_resize_object_add(wid->win, wid->conform);
                -   evas_object_show(wid->conform);
                +    /* Conformant */
                +    wid->conform = elm_conformant_add(wid->win);
                +    evas_object_size_hint_weight_set(wid->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
                +    elm_win_resize_object_add(wid->win, wid->conform);
                +    evas_object_show(wid->conform);
                 
                -   // Label
                -   wid->label = elm_label_add(wid->conform);
                -   evas_object_resize(wid->label, w, h / 3);
                -   evas_object_move(wid->label, 0, h / 3);
                -   evas_object_show(wid->label);
                -   elm_object_text_set(wid->label, "Hello widget");
                +    /* Label */
                +    wid->label = elm_label_add(wid->conform);
                +    evas_object_resize(wid->label, w, h / 3);
                +    evas_object_move(wid->label, 0, h / 3);
                +    evas_object_show(wid->label);
                +    elm_object_text_set(wid->label, "Hello widget");
                 
                -   // Show the window after the base GUI is set up
                -   evas_object_show(wid->win);
                +    /* Show the window after the base GUI is set up */
                +    evas_object_show(wid->win);
                 
                -   widget_app_context_set_tag(context, wid);
                +    widget_app_context_set_tag(context, wid);
                 
                -   return WIDGET_ERROR_NONE;
                -} 
                +    return WIDGET_ERROR_NONE;
                +}
                 
                 int
                -widget_instance_destroy(widget_context_h context, widget_app_destroy_type_e reason, 
                +widget_instance_destroy(widget_context_h context, widget_app_destroy_type_e reason,
                                         bundle *content, void *user_data)
                 {
                -   if (reason != WIDGET_APP_DESTROY_TYPE_PERMANENT)
                -   {
                -      // Save the current status at the bundle object
                -   }
                +    if (reason != WIDGET_APP_DESTROY_TYPE_PERMANENT)
                +        /* Save the current status at the bundle object */
                 
                -   widget_instance_data_s *wid = NULL;
                -   widget_app_context_get_tag(context, (void**)&wid);
                +    widget_instance_data_s *wid = NULL;
                +    widget_app_context_get_tag(context, (void**)&wid);
                 
                -   if (wid->win)
                -      evas_object_del(wid->win);
                +    if (wid->win)
                +        evas_object_del(wid->win);
                 
                -   free(wid);
                +    free(wid);
                 
                -   return WIDGET_ERROR_NONE;
                +    return WIDGET_ERROR_NONE;
                 }
                 
                @@ -370,46 +359,45 @@ widget_instance_destroy(widget_context_h context, widget_app_destroy_type_e reas
                1. You can set a customized widget instance with the widget_app_context_set_tag() function when the instance is created. To update or destroy the customized widget, get the instance with the widget_app_context_get_tag() function.
                  -typedef struct 
                  -{
                  -   int val1;
                  -} user_defined_s;
                  -
                  +struct _user_defined_s {
                  +    int val1;
                  +};
                  +typedef struct _user_defined_s user_defined_s;
                   
                  -int 
                  +int
                   widget_instance_create(widget_context_h context, bundle *content, int w, int h, void *user_data)
                   {
                  -   user_defined_s *uds = (user_defined_s*)malloc(sizeof(user_defined_s));
                  -   uds->val1 = 0;
                  -   widget_app_context_set_tag(context, uds);
                  +    user_defined_s *uds = (user_defined_s*)malloc(sizeof(user_defined_s));
                  +    uds->val1 = 0;
                  +    widget_app_context_set_tag(context, uds);
                   }
                   
                  -int 
                  -widget_instance_destroy(widget_context_h context, widget_destroy_type_e reason, 
                  +int
                  +widget_instance_destroy(widget_context_h context, widget_destroy_type_e reason,
                                           bundle *content, void *user_data)
                   {
                  -   user_defined_s *uds = NULL;
                  -   widget_app_context_get_tag(context, (void**)&uds);
                  -   free(uds);
                  +    user_defined_s *uds = NULL;
                  +    widget_app_context_get_tag(context, (void**)&uds);
                  +    free(uds);
                   }
                   
                  -int 
                  +int
                   widget_instance_update(widget_context_h context, bundle *content, int force, void *user_data)
                   {
                  -   user_defined_s *uds = NULL;
                  -   widget_app_context_get_tag(context, (void**)&uds);
                  -   uds->val1 = 1;
                  +    user_defined_s *uds = NULL;
                  +    widget_app_context_get_tag(context, (void**)&uds);
                  +    uds->val1 = 1;
                   }
                   
                2. Get the widget instance ID:
                  -int 
                  +int
                   widget_instance_update(widget_context_h context, bundle *content, int force, void *user_data)
                   {
                  -   const char *inst_id = NULL;
                  -   inst_id = widget_app_get_id(context);
                  +    const char *inst_id = NULL;
                  +    inst_id = widget_app_get_id(context);
                   }
                   
                diff --git a/org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm b/org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm index 5ba1476..664f460 100644 --- a/org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm @@ -23,6 +23,7 @@

                Content

                  +
                • Prerequisites
                • Managing Characters and Strings
                • Managing Dates and Calendar
                • Managing Locales
                • @@ -51,6 +52,8 @@

                  Become familiar with the i18n API basics by learning about:

                  +

                  Prerequisites

                  + +

                  To use the functions and data types of the i18n API (in mobile and wearable applications) and its submodules, include the <utils_i18n.h> header file in your application:

                  +
                  +#include <utils_i18n.h>
                  +
                  +

                  Managing Characters and Strings

                  Character and string management tasks include:

                  @@ -93,12 +101,8 @@ Note - -
                  • All source and destination buffers must be different.
                  • -
                  • To use the functions and data types of the i18n API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application: -
                    -#include <utils_i18n.h>
                    -
                  + All source and destination buffers must be different. + @@ -308,7 +312,7 @@ i18n_ustring_copy_ua(dest, "Destination string"); i18n_ustring_copy_ua(src, "Appended string"); i18n_ustring_cat_n(dest, src, BUF_SIZE); -// Or +/* Or */ i18n_ustring_cat(dest, src); @@ -323,13 +327,9 @@ i18n_uchar substring[BUF_SIZE]; i18n_uchar *result = i18n_ustring_string(s, substr); if (result == NULL) -{ -   dlog_print(DLOG_DEBUG, LOG_TAG, "Substring not found"); -} +    dlog_print(DLOG_DEBUG, LOG_TAG, "Substring not found"); else -{ -   dlog_print(DLOG_DEBUG, LOG_TAG, "Substring index: %d", result - s); -} +    dlog_print(DLOG_DEBUG, LOG_TAG, "Substring index: %d", result - s); @@ -338,10 +338,7 @@ else

                  To create and use a calendar:

                    -
                  1. To use the functions and data types of the Ucalendar (in mobile and wearable applications), Udate (in mobile and wearable applications), and Udatepg (in mobile and wearable applications) APIs, include the <utils_i18n.h> header file in your application:

                    -
                    -#include <utils_i18n.h>
                    -
                    +
                  2. To manage dates and calendar, the Ucalendar (in mobile and wearable applications), Udate (in mobile and wearable applications), and Udatepg (in mobile and wearable applications) APIs are used.

                    • The Ucalendar API is used for converting between an i18n_udate object and a set of integer fields, such as I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, I18N_UCALENDAR_DAY, and I18N_UCALENDAR_HOUR.
                    • The Udate API is used to convert dates and times from their internal representations to a textual form and back again in a language-independent manner.
                    • @@ -363,16 +360,19 @@ i18n_ucalendar_create(timezone, -1, I18N_ULOCALE_US, I18N_UCALENDAR_DEFAULT, &am

                      In the following example, the date is set as 1 July 2014, 9:00:00.

                      To define the month, you can use numbers (month reduced by 1, such as 0 for January and 1 for February), or to avoid mistakes, the values of the i18n_ucalendar_months_e enumeration (in mobile and wearable applications).

                      -i18n_ucalendar_set_date_time(ucalendar, 2014, I18N_UCALENDAR_JULY, 1, 9, 0, 0);
                      +i18n_ucalendar_set_date_time(ucalendar, 2014, I18N_UCALENDAR_JULY, 1, 9, 0, 0); +

                      To set a date using milliseconds from the epoch, use the i18n_ucalendar_set_milliseconds() function:

                       i18n_udate udate;
                      -// udate must be set
                      +/* udate must be set */
                       i18n_ucalendar_set_milliseconds(ucalendar, udate);
                       

                      To add a specified period to the Ucalendar, use the i18n_ucalendar_add() function.

                      Specify the date field to modify (such as year, week, or day) using the i18n_ucalendar_date_fields_e enumeration (in mobile and wearable applications) as the second parameter, and the amount to modify as the third parameter (use a negative value to subtract from the existing value).

                      -
                      i18n_ucalendar_add(ucalendar, I18N_UCALENDAR_HOUR, 3);
                      +
                      +i18n_ucalendar_add(ucalendar, I18N_UCALENDAR_HOUR, 3);
                      +
                    • To get a date from the Ucalendar, you can use various functions:
                        @@ -460,12 +460,6 @@ i18n_udate_destroy(date_format);

                        To manage the features of a specific geographical, political, or cultural region:

                        -
                          -
                        1. To use the functions and data types of the Ulocale API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application:

                          -
                          -#include <utils_i18n.h>
                          -
                        2. -
                        3. To manage locale information:
                          • To get the language code associated with a locale, use the i18n_ulocale_get_language() function:
                            @@ -524,23 +518,19 @@ i18n_ulocale_get_display_name(I18N_ULOCALE_CANADA_FRENCH, I18N_ULOCALE_GERMANY,
                             
                             
                          • To get or set the default locale, use the i18n_ulocale_get_default() or i18n_ulocale_set_default() function:
                            -// Get
                            +/* Get */
                             char *locale;
                             i18n_ulocale_get_default(&locale);
                             
                            -// Set
                            -i18n_ulocale_set_default(I18N_ULOCALE_KOREA);
                          • -
                        4. -
                        +/* Set */ +i18n_ulocale_set_default(I18N_ULOCALE_KOREA); + +

                      Managing Numbers

                      To format and parse numbers for a locale:

                        -
                      1. To use the functions and data types of the Unumber API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application:

                        -
                        -#include <utils_i18n.h>
                        -
                      2. To create a number format, use the i18n_unumber_create() function.

                        Define the style as the first parameter using the i18n_unumber_format_style_e enumeration (in mobile and wearable applications).

                        The fourth parameter sets the locale (NULL for default). Some string shortcuts for specific locales are defined in the utils_i18n_types.h header file. For example, I18N_ULOCALE_US is equal to "en_US".

                        @@ -588,11 +578,6 @@ i18n_unumber_destroy(num_format);

                        To manipulate or iterate through strings, you can use the Ubrk library. It helps you to treat strings as a set of characters, words, or sentences:

                          -
                        1. To use the functions and data types of the Ubrk API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application:

                          -
                          -#include <utils_i18n.h>
                          -
                        2. -
                        3. To create an iterator to iterate through a string, use the i18n_ubrk_create() function.

                          The first parameter defines the type of the iterator:

                            @@ -631,18 +616,7 @@ i18n_ubrk_destroy(boundary);

                        Managing Enumerations

                        -

                        To create collections of strings and iterate through them:

                        -
                          -
                        1. -

                          To use the functions and data types of the Uenumeration API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application:

                          -
                          -#include <utils_i18n.h>
                          -
                          -
                        2. -
                        3. Create an enumeration.
                        4. -
                        - -

                        You can also obtain enumerations from specific functions.

                        +

                        To create collections of strings and iterate through them, create an enumeration. You can also obtain enumerations from specific functions.

                        Creating an Enumeration

                        To create an enumeration based on existing strings:

                        @@ -651,7 +625,7 @@ i18n_ubrk_destroy(boundary);
                         const char* strings[] = {"First", "Second", "Third", "Fourth"};
                         
                        -// Length of the pointers array (the number of strings)
                        +/* Length of the pointers array (the number of strings) */
                         int32_t size = sizeof(strings) / sizeof(strings[0]);
                         
                      3. @@ -681,11 +655,10 @@ const char *element = NULL; int len; element = i18n_uenumeration_next(strings_enum, &len); -while (element != NULL) -{ -   // Use the returned string +while (element != NULL) { +    /* Use the returned string */ -   element = i18n_uenumeration_next(strings_enum, &len); +    element = i18n_uenumeration_next(strings_enum, &len); } @@ -714,11 +687,10 @@ const char *tz = NULL; int len; tz = i18n_uenumeration_next(timezones, &len); -while (tz != NULL) -{ -   // Use the time zone string +while (tz != NULL) { +    /* Use the time zone string */ -   tz = i18n_uenumeration_next(timezones, &len); +    tz = i18n_uenumeration_next(timezones, &len); } i18n_uenumeration_destroy(timezones); @@ -741,11 +713,10 @@ const char *sk = NULL; int len; sk = i18n_uenumeration_next(skeletons, &len); -while (sk != NULL) -{ -   // Use the skeleton string +while (sk != NULL) { +    /* Use the skeleton string */ -   sk = i18n_uenumeration_next(skeletons, &len); +    sk = i18n_uenumeration_next(skeletons, &len); } i18n_uenumeration_destroy(skeletons); @@ -764,11 +735,10 @@ const char *keyword = NULL; int len; keyword = i18n_uenumeration_next(keywords, &len); -while (keyword != NULL) -{ -   // Use the keyword string +while (keyword != NULL) { +    /* Use the keyword string */ -   keyword = i18n_uenumeration_next(keywords, &len); +    keyword = i18n_uenumeration_next(keywords, &len); } i18n_uenumeration_destroy(keywords); @@ -780,11 +750,7 @@ i18n_uenumeration_destroy(keywords);

                        Managing Time Zones

                        To manage time zone details, such as the time zone offset and daylight savings:

                        -
                        1. To use the functions and data types of the Timezone API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application:

                          -
                          -#include <utils_i18n.h>
                          -
                        2. - +
                          1. To retrieve time zone information:
                            • To get the default time zone based on the time zone where the program is running, use the i18n_timezone_create_default() function:

                              @@ -848,12 +814,6 @@ i18n_timezone_destroy(tmz);

                              To manage sets:

                                -
                              1. To use the functions and data types of the Uset API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application: -
                                -#include <utils_i18n.h>
                                -
                                -
                              2. -
                              3. To create a set, use various i18n_uset_create_XXX() functions.

                                The following example creates an empty set:

                                @@ -879,11 +839,9 @@ i18n_uset_add_all_code_points(set, u_input_text, -1);
                                 int chars_count = i18n_uset_size(set);
                                 int i;
                                 
                                -// Get all characters in the set
                                +/* Get all characters in the set */
                                 for (i = 0; i < chars_count; i++) 
                                -{
                                -   i18n_uchar32 uchar = i18n_uset_char_at(set, i);
                                -}
                                +    i18n_uchar32 uchar = i18n_uset_char_at(set, i);
                                 
                              4. @@ -904,7 +862,7 @@ i18n_ubool contains_character = i18n_uset_contains_range(set, 'a', '
                                 i18n_uset_h compare_set = NULL;
                                 i18n_uset_create_empty(&compare_set);
                                -// Fill the second set
                                +/* Fill the second set */
                                 
                                 i18n_ubool contains_character = i18n_uset_contains_all(set, compare_set);
                                 
                                @@ -920,7 +878,7 @@ i18n_ubool contains_character = i18n_uset_contains_all(set, compare_set); const char *text = "Example string"; i18n_uchar u_input_text[BUF_SIZE]; i18n_ustring_copy_ua(u_input_text, text); - + i18n_uset_add_string(set, u_input_text, -1); @@ -931,15 +889,12 @@ i18n_uset_add_string(set, u_input_text, -1); int strings_count = i18n_uset_get_item_count(set); int32_t len = 0; int32_t i; -for (i = 0; i < strings_count; ++i) -{ -   i18n_uchar32 start, end; -   i18n_uchar string[100]; -   len = i18n_uset_get_item(set, i, &start, &end, string, 100); -   if (len != 0) -   { -      // String was found, use the 'string' variable -   } +for (i = 0; i < strings_count; ++i) { +    i18n_uchar32 start, end; +    i18n_uchar string[100]; +    len = i18n_uset_get_item(set, i, &start, &end, string, 100); +    if (len != 0) +        /* String was found, use the 'string' variable */ } diff --git a/org.tizen.tutorials/html/native/base/sqlite_tutorial_n.htm b/org.tizen.tutorials/html/native/base/sqlite_tutorial_n.htm index fa24ba2..2a7793c 100644 --- a/org.tizen.tutorials/html/native/base/sqlite_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/base/sqlite_tutorial_n.htm @@ -23,7 +23,7 @@

                                Content

                                Related Info

                                @@ -44,13 +44,14 @@

                                Warm-up

                                Become familiar with the basics of the Sqlite API by learning about:

                                -

                                Initializing the Database

                                +

                                Preparing the Database

                                +

                                This tutorial is only a draft of encryption and database usage. For more information, see OpenSSL and SQLite Web pages.

                                @@ -63,19 +64,19 @@
                                -

                                To initialize external open source libraries:

                                +

                                To prepare the database:

                                1. Define the needed variables:
                                  -#define BUFLEN 300 // Buffer size, used in functions
                                  -const int key_len = 256; // AES key length
                                  +#define BUFLEN 300 /* Buffer size, used in functions */
                                  +const int key_len = 256; /* AES key length */
                                   
                                  -static const unsigned char password[] = {"DummyPassword"}; // Password to generate key
                                  -	
                                  -sqlite3 *db; // Database handle
                                  +static const unsigned char password[] = {"DummyPassword"}; /* Password to generate key */
                                  +
                                  +sqlite3 *db; /* Database handle */
                                   
                                  -unsigned char salt[9]; // Encryption salt
                                  -unsigned char iv[17]; // Encryption initial vector
                                  +unsigned char salt[9]; /* Encryption salt */
                                  +unsigned char iv[17]; /* Encryption initial vector */
                                   
                                2. To operate on a SQL database provided by SQLite:

                                  @@ -96,8 +97,8 @@ sqlite3_initialize();
                                   char file_path[BUFLEN];
                                   char *document_path;
                                  -// Fill the variable with the value obtained using storage_foreach_device_supported()
                                  -int internal_storage_id = 0; 
                                  +/* Fill the variable with the value obtained using storage_foreach_device_supported() */
                                  +int internal_storage_id = 0;
                                   storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_DOCUMENTS, &document_path);
                                   snprintf(file_path, size, "%s/test.db", document_path);
                                   free(document_path);
                                  @@ -114,22 +115,22 @@ CreateTable();
                                   

                                  The CreateTable() function prepares a SQL query, and uses the sqlite3_exec() function to execute the query in the defined database.

                                  The sqlite3_exec() function passes a return message to a callback function as an array of strings. It creates a database only if one does not exist already. In the following example, the created database name is EncryptedData, and it contains the DATA, ENCRYPTED, SALT, IV, PART, and KEY fields.

                                  -static int 
                                  +static int
                                   CreateTable()
                                   {
                                  -   int ret;
                                  -   char *ErrMsg;
                                  -   char *sql = "CREATE TABLE IF NOT EXISTS EncryptedData("  \
                                  -                                                         "DATA TEXT NOT NULL," \
                                  -                                                         "ENCRYPTED INT NOT NULL,"\
                                  -                                                         "SALT TEXT NOT NULL," \
                                  -                                                         "IV TEXT NOT NULL," \
                                  -                                                         "PART INTEGER," \
                                  -                                                         "KEY INTEGER PRIMARY KEY);";
                                  -
                                  -   sqlite3_exec(db, sql, callback, 0, &ErrMsg);
                                  -
                                  -   return 0;
                                  +    int ret;
                                  +    char *ErrMsg;
                                  +    char *sql = "CREATE TABLE IF NOT EXISTS EncryptedData("  \
                                  +                                                          "DATA TEXT NOT NULL," \
                                  +                                                          "ENCRYPTED INT NOT NULL,"\
                                  +                                                          "SALT TEXT NOT NULL," \
                                  +                                                          "IV TEXT NOT NULL," \
                                  +                                                          "PART INTEGER," \
                                  +                                                          "KEY INTEGER PRIMARY KEY);";
                                  +
                                  +    sqlite3_exec(db, sql, callback, 0, &ErrMsg);
                                  +
                                  +    return 0;
                                   }
                                   
                                3. @@ -153,16 +154,17 @@ PrepareToSQL(iv);

                                  In the following example, only the string delimiting characters are removed. In a real implementation, you must replace other characters too, such as the comment sequence.

                                  -void 
                                  +void
                                   PrepareToSQL(unsigned char* msg)
                                   {
                                  -   int i = 0;
                                  -   while (msg[i] != 0x00)
                                  -   {
                                  -      if (msg[i] == '\'')msg[i] = 'a';
                                  -      if (msg[i] == '\"')msg[i] = 'b';
                                  -      ++i;
                                  -   }
                                  +    int i = 0;
                                  +    while (msg[i] != 0x00) {
                                  +        if (msg[i] == '\'')
                                  +            msg[i] = 'a';
                                  +        if (msg[i] == '\"')
                                  +            msg[i] = 'b';
                                  +        ++i;
                                  +    }
                                   }
                                   
                                4. @@ -204,49 +206,48 @@ InsertRecord(decrypted_out, 1, 0, strlen(ShortMsg));
                                5. Generate a string for key generation from a password and salt using PKCS5_PBKDF2_HMAC_SHA1().

                                  An initial vector can be used in different hash functions. In this example, only the first byte of the initial vector is used as an iteration variable for a hash algorithm.

                                6. Generate the encryption key using the AES_set_encrypt_key() function. -

                                  The second parameter defines the AES key length. Check the actual recommended length and encoding type before use. This example uses AES 256 (defined in Initializing the Database).

                                7. +

                                  The second parameter defines the AES key length. Check the actual recommended length and encoding type before use. This example uses AES 256 (defined in Preparing the Database).

                                8. Encrypt the data with the AES_encrypt() function.
                                9. Encode Base64 with the base64_encode() function.

                                  The data is encoded to make it safe to insert it to the database. Base 64 does not contain any special characters. For the encoding and decoding function details, see Base64 functions.

                                10. Add a delimiting 0x00 character at the end of the byte array.
                                -static int 
                                +static int
                                 EncryptMsg(char* in, unsigned char* out, const unsigned char* password, unsigned char *localsalt, unsigned char *vector)
                                 {
                                -   AES_KEY encryption_key;
                                -   int iter = (int)vector[0];
                                -   unsigned char key[key_len + 1];
                                -   char *msgbuff;
                                -   unsigned char buf[BUFLEN];
                                -   unsigned int retlen;
                                -   int x;
                                +    AES_KEY encryption_key;
                                +    int iter = (int)vector[0];
                                +    unsigned char key[key_len + 1];
                                +    char *msgbuff;
                                +    unsigned char buf[BUFLEN];
                                +    unsigned int retlen;
                                +    int x;
                                 
                                -   memset(buf, 0x00, BUFLEN);
                                +    memset(buf, 0x00, BUFLEN);
                                 
                                -   PKCS5_PBKDF2_HMAC_SHA1((char *)password,
                                -                          sizeof(password)/sizeof(unsigned char),
                                -                          localsalt,
                                -                          sizeof(localsalt)/sizeof(unsigned char),
                                -                          iter,
                                -                          key_len,
                                -                          key);
                                +    PKCS5_PBKDF2_HMAC_SHA1((char *)password,
                                +                           sizeof(password)/sizeof(unsigned char),
                                +                           localsalt,
                                +                           sizeof(localsalt)/sizeof(unsigned char),
                                +                           iter,
                                +                           key_len,
                                +                           key);
                                 
                                +    AES_set_encrypt_key(key, key_len, &encryption_key);
                                +    AES_encrypt((unsigned char *)in, (unsigned char *)buf, &encryption_key);
                                 
                                -   AES_set_encrypt_key(key, key_len, &encryption_key);
                                -   AES_encrypt((unsigned char *)in, (unsigned char *)buf, &encryption_key);
                                +    msgbuff = base64_encode(buf, 16, &retlen);
                                 
                                -   msgbuff = base64_encode(buf, 16, &retlen);
                                +    memcpy(buf, msgbuff, retlen);
                                +    buf[retlen + 1] = 0x00;
                                +    free(msgbuff);
                                 
                                -   memcpy(buf, msgbuff, retlen);
                                -   buf[retlen + 1] = 0x00;
                                -   free(msgbuff);
                                -   
                                -   memcpy(out, buf, retlen + 1);
                                +    memcpy(out, buf, retlen + 1);
                                 
                                -   for (x = 0; buf[x] != 0x00; x++);
                                +    for (x = 0; buf[x] != 0x00; x++);
                                 
                                -   return x;
                                +    return x;
                                 }
                                 
                                @@ -254,66 +255,66 @@ EncryptMsg(char* in, unsigned char* out, const unsigned char* password, unsigned
                              5. Execute the database insertion with the InsertRecord() function.

                                To insert data to the database, use the sqlite3_exec() function. A query is prepared with common C functions. The encrypted variable is stored in the database and indicates whether the DATA field in the database is encrypted.

                                -static int 
                                +static int
                                 InsertRecord(unsigned char *msg, int encrypted,
                                              int part, int len)
                                 {
                                -   char sqlbuff[BUFLEN];
                                -   char *ErrMsg; 
                                -   snprintf(sqlbuff, BUFLEN, "INSERT INTO EncryptedData
                                -            VALUES(\'%s\', %d, \'%s\', \'%s\', %d, NULL);",
                                -            msg, encrypted, salt, iv, part);
                                -
                                -   ret = sqlite3_exec(db, sqlbuff, callback, 0, &ErrMsg);
                                -   if (ret)
                                -   {
                                -      dlog_print(DLOG_DEBUG, LOG_TAG, "Error: %s\n", ErrMsg);
                                -      sqlite3_free(ErrMsg);
                                -   }
                                -
                                -   return 0;
                                +    char sqlbuff[BUFLEN];
                                +    char *ErrMsg;
                                +    snprintf(sqlbuff, BUFLEN, "INSERT INTO EncryptedData
                                +             VALUES(\'%s\', %d, \'%s\', \'%s\', %d, NULL);",
                                +             msg, encrypted, salt, iv, part);
                                +
                                +    ret = sqlite3_exec(db, sqlbuff, callback, 0, &ErrMsg);
                                +    if (ret) {
                                +        dlog_print(DLOG_DEBUG, LOG_TAG, "Error: %s\n", ErrMsg);
                                +        sqlite3_free(ErrMsg);
                                +    }
                                +
                                +    return 0;
                                 }
                                 
                                -
                              6. +

                              To store longer messages (more than 16 characters), split them into shorter parts. In the following example, the message is divided into blocks 16 characters long. Each block is tagged by its own number with a parts variable, and the tag is stored in the database in the PART field. Each block is then stored in its own record to simplify the decoding procedure.

                              -ret = InsertMessage((unsigned char *)text);	
                              +ret = InsertMessage((unsigned char *)text);
                               
                              -static int 
                              +static int
                               InsertMessage(unsigned char* text)
                               {
                              -   unsigned char encrypted_out[BUFLEN];
                              -   int ret = 0;
                              -   int x;
                              -   int len, retlen, parts = 0, pos;
                              -   char membuf[17];
                              +    unsigned char encrypted_out[BUFLEN];
                              +    int ret = 0;
                              +    int x;
                              +    int len;
                              +    int retlen;
                              +    int parts = 0;
                              +    int pos;
                              +    char membuf[17];
                               
                              -   for (len = 0; text[len] != 0x00; len++);
                              +    for (len = 0; text[len] != 0x00; len++);
                               
                              -   for (pos = 0; (len - pos) > 16; pos += 16)
                              -   {
                              -      memcpy(membuf, &text[pos], 16);
                              -      membuf[16] = 0x00;
                              +    for (pos = 0; (len - pos) > 16; pos += 16) {
                              +        memcpy(membuf, &text[pos], 16);
                              +        membuf[16] = 0x00;
                               
                              -      EncryptMsg((char *)membuf, encrypted_out, password, salt, iv);
                              +        EncryptMsg((char *)membuf, encrypted_out, password, salt, iv);
                               
                              -      for (x = 0; encrypted_out[x] != 0x00; x++);
                              +        for (x = 0; encrypted_out[x] != 0x00; x++);
                               
                              -      InsertRecord(encrypted_out, 1, parts, x);
                              +        InsertRecord(encrypted_out, 1, parts, x);
                               
                              -      parts++;
                              -   }
                              +        parts++;
                              +    }
                               
                              -   if (len - pos > 0)
                              -   {
                              -      retlen = EncryptMsg((char *)&text[pos],
                              -               encrypted_out, password, salt, iv);
                              -      InsertRecord(encrypted_out, 1, parts, retlen);
                              -   }
                              +    if (len - pos > 0) {
                              +        retlen = EncryptMsg((char *)&text[pos],
                              +                            encrypted_out, password, salt, iv);
                              +        InsertRecord(encrypted_out, 1, parts, retlen);
                              +    }
                               
                              -   return 0;
                              +    return 0;
                               }
                               
                            • @@ -321,8 +322,8 @@ InsertMessage(unsigned char* text)
                            • List the database content.

                              After the previous step, the database contains AES-encrypted content, stored in a Base64 notation. For example:

                              -0: DATA = xPRnJYwvQTc4VJKkW4EroQ==  
                              -1: DATA = EZI+uOGxcnUseJnbH57/Bg== 
                              +0: DATA = xPRnJYwvQTc4VJKkW4EroQ==
                              +1: DATA = EZI+uOGxcnUseJnbH57/Bg==
                               

                              To list the records in the database, use the ShowRecords() function:

                                @@ -335,33 +336,34 @@ InsertMessage(unsigned char* text)
                              -static void 
                              +static void
                               ShowRecords()
                               {
                              -   char *sql = "select * from EncryptedData";
                              -   int counter = 0, ret = 0;
                              -   char *ErrMsg;
                              +    char *sql = "select * from EncryptedData";
                              +    int counter = 0;
                              +    int ret = 0;
                              +    char *ErrMsg;
                               
                              -   sqlite3_exec(db, sql, callback, &counter, &ErrMsg);
                              +    sqlite3_exec(db, sql, callback, &counter, &ErrMsg);
                               
                              -   return;
                              +    return;
                               }
                               
                              -static int 
                              +static int
                               callback(void *counter, int argc, char **argv, char **azColName)
                               {
                              -   int *localcounter = (int *)counter;
                              -   int i;
                              +    int *localcounter = (int *)counter;
                              +    int i;
                               
                              -   dlog_print(DLOG_DEBUG, LOG_TAG, "-%d: ", *localcounter);
                              +    dlog_print(DLOG_DEBUG, LOG_TAG, "-%d: ", *localcounter);
                               
                              -   for (i = 0; i < argc; i++) 
                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "%s = %s | ", azColName[i], argv[i] ? argv[i] : "NULL");
                              +    for (i = 0; i < argc; i++)
                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "%s = %s | ", azColName[i], argv[i] ? argv[i] : "NULL");
                               
                              -   (*localcounter)++;
                              -   dlog_print(DLOG_DEBUG, LOG_TAG, "\n");
                              +    (*localcounter)++;
                              +    dlog_print(DLOG_DEBUG, LOG_TAG, "\n");
                               
                              -   return 0;
                              +    return 0;
                               }
                               
                            • @@ -376,92 +378,87 @@ callback(void *counter, int argc, char **argv, char **azColName)

                              To decrypt the message, decode the data from Base 64, add a delimiting character, perform the actual decryption with the DecryptMsg() function, and list the decrypted data.

                            -static void 
                            +static void
                             DecryptRecords()
                             {
                            -   char *sql = "select * from EncryptedData where ENCRYPTED='1'";
                            -   int counter = 0;
                            -   int ret = 0;
                            -   char *ErrMsg;
                            -
                            -   ret = sqlite3_exec(db, sql, callbackdecrypt, &counter, &ErrMsg);
                            -   if (ret)
                            -   {
                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Error: %s\n", ErrMsg);
                            -      sqlite3_free(ErrMsg);
                            -   }
                            +    char *sql = "select * from EncryptedData where ENCRYPTED='1'";
                            +    int counter = 0;
                            +    int ret = 0;
                            +    char *ErrMsg;
                            +
                            +    ret = sqlite3_exec(db, sql, callbackdecrypt, &counter, &ErrMsg);
                            +    if (ret) {
                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Error: %s\n", ErrMsg);
                            +        sqlite3_free(ErrMsg);
                            +    }
                             }
                             
                            -static int 
                            +static int
                             callbackdecrypt(void *counter, int argc, char **argv, char **azColName)
                             {
                            -   unsigned char decrypted_out[BUFLEN];
                            -   int *localcounter = (int *)counter;
                            -   int i;
                            -   unsigned int olen;
                            -
                            -   dlog_print(DLOG_DEBUG, LOG_TAG, "-%d: ", *localcounter);
                            -
                            -   for (i = 0; i < argc; i++)
                            -   {
                            -      if (argv[i] && i == 0)
                            -      {
                            -         unsigned char *basebuffer = base64_decode(argv[i], strlen(argv[i]), &olen);
                            -         unsigned char *decryptbuffer = malloc(sizeof(char)* olen + 1);
                            -
                            -         memset(decryptbuffer, 0x00, olen + 1);
                            -         memcpy(decryptbuffer, basebuffer, olen);
                            -         decryptbuffer[olen] = 0x00;
                            -         free(basebuffer);
                            -
                            -         DecryptMsg((unsigned char *)decryptbuffer, decrypted_out,
                            -                    password, (unsigned char *)argv[2], (unsigned char *)argv[3]);
                            -
                            -         free(decryptbuffer);
                            -
                            -         dlog_print(DLOG_DEBUG, LOG_TAG, "%s = %s  |  ", azColName[i], 
                            -                    (char*)decrypted_out);
                            -       
                            -      }
                            -      else
                            -      {
                            -         dlog_print(DLOG_DEBUG, LOG_TAG, "%s = %s | ", azColName[i], argv[i] ? argv[i] : "NULL");
                            -      }
                            -   }
                            -
                            -   (*localcounter)++;
                            -   dlog_print(DLOG_DEBUG, LOG_TAG, "\n");
                            -
                            -   return 0;
                            +    unsigned char decrypted_out[BUFLEN];
                            +    int *localcounter = (int *)counter;
                            +    int i;
                            +    unsigned int olen;
                            +
                            +    dlog_print(DLOG_DEBUG, LOG_TAG, "-%d: ", *localcounter);
                            +
                            +    for (i = 0; i < argc; i++) {
                            +        if (argv[i] && i == 0) {
                            +            unsigned char *basebuffer = base64_decode(argv[i], strlen(argv[i]), &olen);
                            +            unsigned char *decryptbuffer = malloc(sizeof(char)* olen + 1);
                            +
                            +            memset(decryptbuffer, 0x00, olen + 1);
                            +            memcpy(decryptbuffer, basebuffer, olen);
                            +            decryptbuffer[olen] = 0x00;
                            +            free(basebuffer);
                            +
                            +            DecryptMsg((unsigned char *)decryptbuffer, decrypted_out,
                            +                       password, (unsigned char *)argv[2], (unsigned char *)argv[3]);
                            +
                            +            free(decryptbuffer);
                            +
                            +            dlog_print(DLOG_DEBUG, LOG_TAG, "%s = %s | ", azColName[i],
                            +                       (char*)decrypted_out);
                            +
                            +        } else {
                            +            dlog_print(DLOG_DEBUG, LOG_TAG, "%s = %s | ", azColName[i], argv[i] ? argv[i] : "NULL");
                            +        }
                            +    }
                            +
                            +    (*localcounter)++;
                            +    dlog_print(DLOG_DEBUG, LOG_TAG, "\n");
                            +
                            +    return 0;
                             }
                             

                            The actual decryption routine is similar to encryption:

                            -static int 
                            -DecryptMsg(unsigned char* in, unsigned char* out, const unsigned char* password, 
                            +static int
                            +DecryptMsg(unsigned char* in, unsigned char* out, const unsigned char* password,
                                        unsigned char* localsalt, unsigned char* vector)
                             {
                            -   AES_KEY decryption_key;
                            -   int iter = (int)vector[0];
                            -   unsigned char key[key_len + 1];
                            -   int x;
                            +    AES_KEY decryption_key;
                            +    int iter = (int)vector[0];
                            +    unsigned char key[key_len + 1];
                            +    int x;
                             
                            -   memset(out, 0x00, BUFLEN);
                            +    memset(out, 0x00, BUFLEN);
                             
                            -   PKCS5_PBKDF2_HMAC_SHA1((char *)password,
                            -                          sizeof(password)/sizeof(unsigned char),
                            -                          localsalt,
                            -                          sizeof(localsalt)/sizeof(unsigned char),
                            -                          iter,
                            -                          key_len,
                            -                          key);
                            +    PKCS5_PBKDF2_HMAC_SHA1((char *)password,
                            +                           sizeof(password)/sizeof(unsigned char),
                            +                           localsalt,
                            +                           sizeof(localsalt)/sizeof(unsigned char),
                            +                           iter,
                            +                           key_len,
                            +                           key);
                             
                            -   AES_set_decrypt_key(key, key_len, &decryption_key);
                            -   AES_decrypt((unsigned char *)in, out, &decryption_key);
                            +    AES_set_decrypt_key(key, key_len, &decryption_key);
                            +    AES_decrypt((unsigned char *)in, out, &decryption_key);
                             
                            -   for (x = 0; out[x] != 0x00; x++);
                            +    for (x = 0; out[x] != 0x00; x++);
                             
                            -   return x;
                            +    return x;
                             }
                             
                          2. @@ -478,7 +475,7 @@ sqlite3_shutdown();
                            • Base64 functions:
                              -static char 
                              +static char
                               encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
                                                   'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
                                                   'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
                              @@ -490,140 +487,147 @@ encoding_table[] = {'A', 'B', 'C', 'D', 'E&#
                               static char *decoding_table = NULL;
                               static int mod_table[] = {0, 2, 1};
                               
                              -void 
                              +void
                               build_decoding_table()
                               {
                              -   decoding_table = malloc(256);
                              -   int i;
                              -   for (i = 0; i < 64; i++) decoding_table[(unsigned char) encoding_table[i]] = i;
                              +    decoding_table = malloc(256);
                              +    int i;
                              +    for (i = 0; i < 64; i++)
                              +        decoding_table[(unsigned char)encoding_table[i]] = i;
                               }
                               
                              -char 
                              +char
                               *base64_encode(const unsigned char *data, size_t input_length, size_t *output_length)
                               {
                              -   *output_length = 4 * ((input_length + 2) / 3);
                              -
                              -   char *encoded_data = malloc(*output_length);
                              -   if (encoded_data == NULL) return NULL;
                              -
                              -   int i, j;
                              -   for (i = 0, j = 0; i < input_length;)
                              -   {
                              -      uint32_t octet_a = i < input_length ? (unsigned char)data[i++] : 0;
                              -      uint32_t octet_b = i < input_length ? (unsigned char)data[i++] : 0;
                              -      uint32_t octet_c = i < input_length ? (unsigned char)data[i++] : 0;
                              -      uint32_t triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
                              -
                              -      encoded_data[j++] = encoding_table[(triple >> 3 * 6) & 0x3F];
                              -      encoded_data[j++] = encoding_table[(triple >> 2 * 6) & 0x3F];
                              -      encoded_data[j++] = encoding_table[(triple >> 1 * 6) & 0x3F];
                              -      encoded_data[j++] = encoding_table[(triple >> 0 * 6) & 0x3F];
                              -   }
                              -
                              -   for (i = 0; i < mod_table[input_length % 3]; i++)
                              -      encoded_data[*output_length - 1 - i] = '=';
                              -
                              -   return encoded_data;
                              +    *output_length = 4 * ((input_length + 2) / 3);
                              +
                              +    char *encoded_data = malloc(*output_length);
                              +    if (encoded_data == NULL)
                              +        return NULL;
                              +
                              +    int i;
                              +    int j;
                              +    for (i = 0, j = 0; i < input_length;) {
                              +        uint32_t octet_a = i < input_length ? (unsigned char)data[i++] : 0;
                              +        uint32_t octet_b = i < input_length ? (unsigned char)data[i++] : 0;
                              +        uint32_t octet_c = i < input_length ? (unsigned char)data[i++] : 0;
                              +        uint32_t triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
                              +
                              +        encoded_data[j++] = encoding_table[(triple >> 3 * 6) & 0x3F];
                              +        encoded_data[j++] = encoding_table[(triple >> 2 * 6) & 0x3F];
                              +        encoded_data[j++] = encoding_table[(triple >> 1 * 6) & 0x3F];
                              +        encoded_data[j++] = encoding_table[(triple >> 0 * 6) & 0x3F];
                              +    }
                              +
                              +    for (i = 0; i < mod_table[input_length % 3]; i++)
                              +        encoded_data[*output_length - 1 - i] = '=';
                              +
                              +    return encoded_data;
                               }
                               
                              -unsigned char 
                              +unsigned char
                               *base64_decode(const char *data, size_t input_length, size_t *output_length)
                               {
                              -   if (decoding_table == NULL) build_decoding_table();
                              -
                              -   if (input_length % 4 != 0) return NULL;
                              -
                              -   *output_length = input_length / 4 * 3;
                              -   if (data[input_length - 1] == '=') (*output_length)--;
                              -   if (data[input_length - 2] == '=') (*output_length)--;
                              -
                              -   unsigned char *decoded_data = malloc(*output_length);
                              -   if (decoded_data == NULL) return NULL;
                              -
                              -   int i, j;
                              -
                              -   for (i = 0, j = 0; i < input_length;)
                              -   {
                              -      uint32_t sextet_a = data[i] == '=' ? 0 & i++ : decoding_table[(int)data[i++]];
                              -      uint32_t sextet_b = data[i] == '=' ? 0 & i++ : decoding_table[(int)data[i++]];
                              -      uint32_t sextet_c = data[i] == '=' ? 0 & i++ : decoding_table[(int)data[i++]];
                              -      uint32_t sextet_d = data[i] == '=' ? 0 & i++ : decoding_table[(int)data[i++]];
                              -
                              -      uint32_t triple = (sextet_a << 3 * 6) + (sextet_b << 2 * 6)
                              -                        + (sextet_c << 1 * 6) + (sextet_d << 0 * 6);
                              -
                              -      if (j < *output_length) decoded_data[j++] = (triple >> 2 * 8) & 0xFF;
                              -      if (j < *output_length) decoded_data[j++] = (triple >> 1 * 8) & 0xFF;
                              -      if (j < *output_length) decoded_data[j++] = (triple >> 0 * 8) & 0xFF;
                              -   }
                              -
                              -   return decoded_data;
                              +    if (decoding_table == NULL)
                              +        build_decoding_table();
                              +
                              +    if (input_length % 4 != 0)
                              +        return NULL;
                              +
                              +    *output_length = input_length / 4 * 3;
                              +    if (data[input_length - 1] == '=')
                              +        (*output_length)--;
                              +    if (data[input_length - 2] == '=')
                              +        (*output_length)--;
                              +
                              +    unsigned char *decoded_data = malloc(*output_length);
                              +    if (decoded_data == NULL)
                              +        return NULL;
                              +
                              +    int i;
                              +    int j;
                              +
                              +    for (i = 0, j = 0; i < input_length;) {
                              +        uint32_t sextet_a = data[i] == '=' ? 0 & i++ : decoding_table[(int)data[i++]];
                              +        uint32_t sextet_b = data[i] == '=' ? 0 & i++ : decoding_table[(int)data[i++]];
                              +        uint32_t sextet_c = data[i] == '=' ? 0 & i++ : decoding_table[(int)data[i++]];
                              +        uint32_t sextet_d = data[i] == '=' ? 0 & i++ : decoding_table[(int)data[i++]];
                              +
                              +        uint32_t triple = (sextet_a << 3 * 6) + (sextet_b << 2 * 6)
                              +                          + (sextet_c << 1 * 6) + (sextet_d << 0 * 6);
                              +
                              +        if (j < *output_length)
                              +            decoded_data[j++] = (triple >> 2 * 8) & 0xFF;
                              +        if (j < *output_length)
                              +            decoded_data[j++] = (triple >> 1 * 8) & 0xFF;
                              +        if (j < *output_length)
                              +            decoded_data[j++] = (triple >> 0 * 8) & 0xFF;
                              +    }
                              +
                              +    return decoded_data;
                               }
                               
                              -void 
                              -base64_cleanup() 
                              +void
                              +base64_cleanup()
                               {
                              -   free(decoding_table);
                              -   decoding_table = NULL;
                              +    free(decoding_table);
                              +    decoding_table = NULL;
                               }
                               
                            • Main function:
                              -int 
                              +int
                               OpenSQL_AES_example_1(void)
                               {
                              -   unsigned char decrypted_out[BUFLEN];
                              -   int ret;
                              -   char *hellomsg = {"Hello Tizen! SQLite OpenSSL"};
                              -   char text[BUFLEN];
                              -   time_t rawtime;
                              -   struct tm *timeinfo;
                              -
                              -   if (init_err)
                              -   {
                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "Initial error\n");
                              -
                              -      return 1;
                              -   }
                              -
                              -   time(&rawtime);
                              -   timeinfo = localtime(&rawtime);
                              -   sprintf(text, "%s %s", hellomsg, asctime(timeinfo));
                              -
                              -   // Insert long message
                              -   ret = InsertMessage((unsigned char *)text);
                              -   if (ret)
                              -   {
                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "Insert ENCRYPTED MessageError\n");
                              -
                              -      return 1;
                              -   }
                              -
                              -   // Insert message up to 16 characters
                              -   char *ShortMsg = "Short Msg.";
                              -   EncryptMsg(ShortMsg, decrypted_out, password, salt, iv);
                              -   ret = InsertRecord(decrypted_out, 1, 0, strlen(ShortMsg));
                              -   if (ret)
                              -   {
                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "Insert ENCRYPTED MessageError\n");
                              -
                              -      return 1;
                              -   }
                              -
                              -   // Show raw database
                              -   ShowRecords();
                              -
                              -   // Show decrypted database
                              -   DecryptRecords();
                              -
                              -   return 0;
                              +    unsigned char decrypted_out[BUFLEN];
                              +    int ret;
                              +    char *hellomsg = {"Hello Tizen! SQLite OpenSSL"};
                              +    char text[BUFLEN];
                              +    time_t rawtime;
                              +    struct tm *timeinfo;
                              +
                              +    if (init_err) {
                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "Initial error\n");
                              +
                              +        return 1;
                              +    }
                              +
                              +    time(&rawtime);
                              +    timeinfo = localtime(&rawtime);
                              +    sprintf(text, "%s %s", hellomsg, asctime(timeinfo));
                              +
                              +    /* Insert long message */
                              +    ret = InsertMessage((unsigned char *)text);
                              +    if (ret) {
                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "Insert ENCRYPTED MessageError\n");
                              +
                              +        return 1;
                              +    }
                              +
                              +    /* Insert message up to 16 characters */
                              +    char *ShortMsg = "Short Msg.";
                              +    EncryptMsg(ShortMsg, decrypted_out, password, salt, iv);
                              +    ret = InsertRecord(decrypted_out, 1, 0, strlen(ShortMsg));
                              +    if (ret) {
                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "Insert ENCRYPTED MessageError\n");
                              +
                              +        return 1;
                              +    }
                              +
                              +    /* Show raw database */
                              +    ShowRecords();
                              +
                              +    /* Show decrypted database */
                              +    DecryptRecords();
                              +
                              +    return 0;
                               }
                               
                            - + diff --git a/org.tizen.tutorials/html/native/content/download_tutorial_n.htm b/org.tizen.tutorials/html/native/content/download_tutorial_n.htm index e7520cf..ef330fc 100644 --- a/org.tizen.tutorials/html/native/content/download_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/content/download_tutorial_n.htm @@ -23,6 +23,7 @@

                            Content

                            Related Info

                            @@ -46,25 +47,31 @@

                            Become familiar with the Download API basics by learning about:

                            -

                            Downloading Content from a URL

                            +

                            Prerequisites

                            -

                            To download content:

                            -
                            1. To use the functions and data types of the Download API, include the <download.h> header file in your application:

                              +

                              To use the functions and data types of the Download API, include the <download.h> header file in your application:

                               #include <download.h>
                               
                              -

                              The downloading library needs no initialization prior to the API usage.

                            2. +

                              The downloading library needs no initialization prior to the API usage.

                              + +

                              Downloading Content from a URL

                              + +

                              To download content:

                              +
                              1. Create the download handle.

                                Before starting any downloading, assign a download ID with the download_create() function:

                                 download_error_e error;
                                 int download_id;
                                -	
                                +
                                 error = download_create(&download_id);
                                 
                                @@ -75,7 +82,8 @@ error = download_create(&download_id);

                                Data specified by the URL is downloaded asynchronously, and each download-related event (start, pause, stop, finish, or progress update) is propagated to the application through a callback.

                                Register the progress callback with the download_set_progress_cb() function, and the state change callback with the download_set_state_changed_cb() function:

                                -
                                error = download_set_state_changed_cb(download_id, state_changed_cb, NULL);
                                +
                                +error = download_set_state_changed_cb(download_id, state_changed_cb, NULL);
                                 
                                 error = download_set_progress_cb(download_id, progress_cb, &content_size);
                                 
                                @@ -130,17 +138,18 @@ error_code = download_get_network_type(download_id, &value); app_control_h app_control = NULL; error = app_control_create(&app_control); error = app_control_set_app_id(app_control, "org.tizen.tutorialdownload"); -error = download_set_notification_app_control(download_id, -                                              DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_FAILED, +error = download_set_notification_app_control(download_id, +                                              DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_FAILED,                                               app_control); download_notification_type_e noti_type = 0; -char *title = NULL, *desc = NULL; +char *title = NULL; +char *desc = NULL; error = download_get_notification_type(download_id, &noti_type); error = download_get_notification_title(download_id, &title); error = download_get_notification_description(download_id, &desc); error = download_get_notification_app_control(download_id, -                                              DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_FAILED, +                                              DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_FAILED,                                               &app_control); error = app_control_destroy(app_control);
                                @@ -166,30 +175,31 @@ error = download_cancel(download_id);
                                 unsigned long long content_size = 0;
                                 
                                -error = download_create(&download_id);
                              2. +error = download_create(&download_id); +
                              3. Register the progress callback and start the download:
                                 error = download_set_progress_cb(download_id, progress_cb, &content_size);
                                 
                                -error = download_start(download_id);
                              4. +error = download_start(download_id); +
                              5. When the file is being downloaded, get the total content size:
                                 download_state_e state = 0;
                                 content_size = 0;
                                 error = download_get_state(download_id, &state);
                                -if (state == DOWNLOAD_STATE_DOWNLOADING) 
                                -{
                                -   error = download_get_content_size(download_id, &content_size);
                                -}
                                +if (state == DOWNLOAD_STATE_DOWNLOADING)
                                +    error = download_get_content_size(download_id, &content_size);
                                 
                              6. The received parameter of the progress_cb() callback function contains the size of the data received in bytes. In this example, print out the value and the total download size.
                                -static void 
                                +static void
                                 progress_cb(int download_id, unsigned long long received, void *user_data)
                                 {
                                -   dlog_print(DLOG_INFO, LOG_TAG, "received: %llu of %llu", received, *((unsigned long long*)user_data));
                                -}
                              +    dlog_print(DLOG_INFO, LOG_TAG, "received: %llu of %llu", received, *((unsigned long long*)user_data)); +} +
                          3. Get error information. @@ -204,10 +214,10 @@ error = download_get_error(download_id, &error_val);

                            When the registered download is no longer needed (the downloading is finished or has been canceled), delete it using the download_destroy() function. In addition, unset all callback functions.

                             download_unset_progress_cb(download_id);
                            -download_unset_state_changed_cb(download_id);    
                            +download_unset_state_changed_cb(download_id);
                             error = download_destroy(download_id);
                             
                          - + diff --git a/org.tizen.tutorials/html/native/content/media_content_tutorial_n.htm b/org.tizen.tutorials/html/native/content/media_content_tutorial_n.htm index 2f5e472..8e8bdde 100644 --- a/org.tizen.tutorials/html/native/content/media_content_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/content/media_content_tutorial_n.htm @@ -23,7 +23,7 @@

                          Content

                            -
                          • Connecting to the Media Database
                          • +
                          • Prerequisites
                          • Media content
                            • Getting the Folder List
                            • @@ -110,8 +110,8 @@

                              Warm-up

                              Become familiar with the Media Content API basics by learning about:

                                -
                              • Connecting to the Media Database -

                                Initialize the media content for use and connect to the media database.

                              • +
                              • Prerequisites +

                                Prepare your application to use the media content functionality.

                              • Media content +

                                Prerequisites

                                -

                                Connecting to the Media Database

                                - - -

                                To use the media database:

                                +

                                To enable your application to use the media content functionality:

                                  -
                                1. Media Content functions use a SQLite database to save the metadata of the media files on the user device, along with the tags and bookmarks that the user sets. To use the functions and data types of the Media Content API (in mobile and wearable applications), include the <media_content.h> header file in your application:

                                  +
                                2. +

                                  To use the Media Content API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

                                  +
                                  +<privileges>
                                  +   <!--To insert content-->
                                  +   <privilege>http://tizen.org/privilege/content.write</privilege>
                                  +   <!--To access a storage to insert content-->
                                  +   <privilege>http://tizen.org/privilege/mediastorage</privilege>
                                  +</privileges>
                                  +
                                  +
                                3. +
                                4. Media Content functions use a SQLite database to save the metadata of the media files on the user device, along with the tags and bookmarks that the user sets. To use the functions and data types of the Media Content API, include the <media_content.h> header file in your application:

                                   #include <media_content.h>
                                   #include <glib.h>
                                   
                                  -

                                  The example application used in the other use cases also requires the <glib.h> header file.

                                  +

                                  The example application used in the use cases also requires the <glib.h> header file.

                                5. Connect to the database:
                                  @@ -236,9 +245,9 @@ int ret = MEDIA_CONTENT_ERROR_NONE;
                                   
                                   ret = media_content_connect();
                                   if (ret == MEDIA_CONTENT_ERROR_NONE)
                                  -   dlog_print(DLOG_DEBUG, LOG_TAG, "connection is success");
                                  +    dlog_print(DLOG_DEBUG, LOG_TAG, "connection is success");
                                   else
                                  -   dlog_print(DLOG_ERROR, LOG_TAG, "connection failed");
                                  +    dlog_print(DLOG_ERROR, LOG_TAG, "connection failed");
                                   
                                   return ret;
                                   
                                6. @@ -257,17 +266,17 @@ media_content_disconnect();
                                  1. Define a callback function for the media_folder_foreach_folder_from_db() function, called for each available media folder. Use the callback to create a list of folders.
                                    -bool 
                                    +bool
                                     gallery_folder_list_cb(media_folder_h folder, void *user_data)
                                     {
                                    -   media_folder_h new_folder = NULL;
                                    -   media_folder_clone(&new_folder, folder);
                                    +    media_folder_h new_folder = NULL;
                                    +    media_folder_clone(&new_folder, folder);
                                     
                                    -   GList **list = (GList**)user_data; // Include glib.h for this value 
                                    +    GList **list = (GList**)user_data; /* Include glib.h for this value */
                                     
                                    -   *list = g_list_append(*list, new_folder);
                                    +    *list = g_list_append(*list, new_folder);
                                     
                                    -   return true;
                                    +    return true;
                                     }
                                     
                                  2. To find the folders, call the media_folder_foreach_folder_from_db() function with the defined callback. After the callback has created the folder list, you can access the folder details with various media_folder_get_XXX() functions. @@ -275,64 +284,55 @@ gallery_folder_list_cb(media_folder_h folder, void *user_data) int i; int count; filter_h filter = NULL; -GList *folder_list = NULL; // Include glib.h for this value +GList *folder_list = NULL; /* Include glib.h for this value */ media_folder_h folder_handle = NULL; ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list); -if (ret != MEDIA_CONTENT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "media_folder_foreach_folder_from_db failed: %d", ret); - -   return ret; -} -else -{ -   dlog_print(DLOG_DEBUG, LOG_TAG, "media_folder_foreach_folder_from_db success!!"); - -   char *folder_id = NULL; -   char *folder_name = NULL; -   char *folder_path = NULL; - -   for (i = 0; i < g_list_length(folder_list); i++) -   { -      folder_handle = (media_folder_h)g_list_nth_data(folder_list, i); - -      ret = media_folder_get_folder_id(folder_handle, &folder_id); -      ret = media_folder_get_name(folder_handle, &folder_name); -      ret = media_folder_get_path(folder_handle, &folder_path); - -      ret = media_folder_get_media_count_from_db(folder_id, filter, &count); - -      // Release allocated strings -      free (folder_id); -      free (folder_name); -      free (folder_path); -      if (ret != MEDIA_CONTENT_ERROR_NONE) -      { -         dlog_print(DLOG_ERROR, LOG_TAG, "media_folder_get_media_count_from_db failed: %d", ret); - -         return ret; -      } -      else -      { -         dlog_print(DLOG_DEBUG, LOG_TAG, "media count [%d]: %d", i, count); -      } -   } +if (ret != MEDIA_CONTENT_ERROR_NONE) { +    dlog_print(DLOG_ERROR, LOG_TAG, "media_folder_foreach_folder_from_db failed: %d", ret); + +    return ret; +} else { +    dlog_print(DLOG_DEBUG, LOG_TAG, "media_folder_foreach_folder_from_db success!!"); + +    char *folder_id = NULL; +    char *folder_name = NULL; +    char *folder_path = NULL; + +    for (i = 0; i < g_list_length(folder_list); i++) { +        folder_handle = (media_folder_h)g_list_nth_data(folder_list, i); + +        ret = media_folder_get_folder_id(folder_handle, &folder_id); +        ret = media_folder_get_name(folder_handle, &folder_name); +        ret = media_folder_get_path(folder_handle, &folder_path); + +        ret = media_folder_get_media_count_from_db(folder_id, filter, &count); + +        /* Release allocated strings */ +        free (folder_id); +        free (folder_name); +        free (folder_path); +        if (ret != MEDIA_CONTENT_ERROR_NONE) { +            dlog_print(DLOG_ERROR, LOG_TAG, "media_folder_get_media_count_from_db failed: %d", ret); + +            return ret; +        } else { +            dlog_print(DLOG_DEBUG, LOG_TAG, "media count [%d]: %d", i, count); +        } +    } }
                                  3. When no longer needed, destroy the folder list handle:
                                    -// Remove the folder list 
                                    -if (folder_list) 
                                    -{
                                    -   for (i = 0; i < g_list_length(folder_list); i++) 
                                    -   {
                                    -      folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
                                    -      media_folder_destroy(folder_handle);
                                    -   }
                                    +/* Remove the folder list */
                                    +if (folder_list) {
                                    +    for (i = 0; i < g_list_length(folder_list); i++) {
                                    +        folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
                                    +        media_folder_destroy(folder_handle);
                                    +    }
                                     
                                    -   g_list_free(folder_list);
                                    +    g_list_free(folder_list);
                                     }
                                     
                                  4. @@ -345,24 +345,24 @@ if (folder_list)
                                    1. Define a callback function for the media_info_foreach_media_from_db() function, called for each available media item. Use the callback to create a list of media items.
                                      -bool 
                                      +bool
                                       gallery_media_item_cb(media_info_h media, void *user_data)
                                       {
                                      -   media_info_h new_media = NULL;
                                      -   media_info_clone(&new_media, media);
                                      +    media_info_h new_media = NULL;
                                      +    media_info_clone(&new_media, media);
                                       
                                      -   GList **list = (GList**)user_data; // Include glib.h for this value 
                                      -   *list = g_list_append(*list, new_media);
                                      +    GList **list = (GList**)user_data; /* Include glib.h for this value */
                                      +    *list = g_list_append(*list, new_media);
                                       
                                      -   return true;
                                      +    return true;
                                       }
                                       
                                    2. To find the items satisfying certain criteria, or modify the results in a specific way, create a filter and set its properties. For a detailed list of condition fields (such as MEDIA_TYPE) and their values (such as MEDIA_CONTENT_TYPE_IMAGE and MEDIA_CONTENT_TYPE_VIDEO), see the media_content_type.h header file.

                                      The following example filters media items so that only image and video files are included in the result. The filter is case-insensitive, and the results are sorted in a descending order based on the item display name. For more information about the filter properties, see Setting up a Filter.

                                      -#define BUFLEN 200 
                                      +#define BUFLEN 200
                                       
                                      -// Get the item list 
                                      +/* Get the item list */
                                       media_info_h media_handle = NULL;
                                       GList *all_item_list = NULL;
                                       
                                      @@ -370,24 +370,22 @@ media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
                                       media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
                                       ret = media_filter_create(&filter);
                                       
                                      -snprintf(buf, BUFLEN, "%s = %d OR %s = %d", MEDIA_TYPE, MEDIA_CONTENT_TYPE_IMAGE, 
                                      +snprintf(buf, BUFLEN, "%s = %d OR %s = %d", MEDIA_TYPE, MEDIA_CONTENT_TYPE_IMAGE,
                                                MEDIA_TYPE, MEDIA_CONTENT_TYPE_VIDEO);
                                       ret = media_filter_set_condition(filter, buf, collate_type);
                                      -if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                      -{
                                      -   media_filter_destroy(filter);
                                      -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set condition");
                                      +if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                      +    media_filter_destroy(filter);
                                      +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set condition");
                                       
                                      -   return ret;
                                      +    return ret;
                                       }
                                       
                                       ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
                                      -if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                      -{
                                      -   media_filter_destroy(filter);
                                      -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set order");
                                      +if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                      +    media_filter_destroy(filter);
                                      +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set order");
                                       
                                      -   return ret;
                                      +    return ret;
                                       }
                                       
                                    3. To find the media items, use the media_info_foreach_media_from_db() function with the defined callback. The function is synchronous, and it blocks until the callback has been called for all items or the callback returns false. @@ -398,19 +396,17 @@ ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_i
                                    4. When no longer needed, destroy the item list and the filter handle:
                                      -// Remove all items list 
                                      -if (all_item_list) 
                                      -{
                                      -   for (i = 0; i < g_list_length(all_item_list); i++) 
                                      -   {
                                      -      media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
                                      -      ret = media_info_destroy(media_handle);
                                      -   }
                                      +/* Remove all items list */
                                      +if (all_item_list) {
                                      +    for (i = 0; i < g_list_length(all_item_list); i++) {
                                      +        media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
                                      +        ret = media_info_destroy(media_handle);
                                      +    }
                                       
                                      -   g_list_free(all_item_list);
                                      +    g_list_free(all_item_list);
                                       }
                                       
                                      -// Destroy the filter handle
                                      +/* Destroy the filter handle */
                                       media_filter_destroy(filter);
                                       
                                    5. @@ -423,54 +419,44 @@ media_filter_destroy(filter);
                                      1. Define the database update callback function:
                                        -void 
                                        +void
                                         _noti_cb(media_content_error_e error, int pid,
                                                  media_content_db_update_item_type_e update_item,
                                                  media_content_db_update_type_e update_type,
                                                  media_content_type_e media_type,
                                                  char *uuid, char *path, char *mime_type, void *user_data)
                                         {
                                        -   if (error == MEDIA_CONTENT_ERROR_NONE) 
                                        -   {
                                        -      dlog_print(DLOG_DEBUG, LOG_TAG, "noti success! %d\n", error);
                                        -   } 
                                        -   else 
                                        -   {
                                        -      dlog_print(DLOG_DEBUG, LOG_TAG, "error occurred! %d\n", error);
                                        -   }
                                        -
                                        -   dlog_print(DLOG_DEBUG, LOG_TAG, "Noti from PID(%d)\n", pid);
                                        -
                                        -   if (update_item == MEDIA_ITEM_FILE) 
                                        -   {
                                        -      dlog_print(DLOG_DEBUG, LOG_TAG, "Noti item: MEDIA_ITEM_FILE\n");
                                        -   } 
                                        -   else if (update_item == MEDIA_ITEM_DIRECTORY) 
                                        -   {
                                        -      dlog_print(DLOG_DEBUG, LOG_TAG, "Noti item: MEDIA_ITEM_DIRECTORY\n");
                                        -   }
                                        -
                                        -   if (update_type == MEDIA_CONTENT_INSERT) 
                                        -   {
                                        -      dlog_print(DLOG_DEBUG, LOG_TAG, "Noti type: MEDIA_CONTENT_INSERT\n");
                                        -   } 
                                        -   else if (update_type == MEDIA_CONTENT_DELETE) 
                                        -   {
                                        -      dlog_print(DLOG_DEBUG, LOG_TAG, "Noti type: MEDIA_CONTENT_DELETE\n");
                                        -   } 
                                        -   else if (update_type == MEDIA_CONTENT_UPDATE) 
                                        -   {
                                        -      dlog_print(DLOG_DEBUG, LOG_TAG, "Noti type: MEDIA_CONTENT_UPDATE\n");
                                        -   }
                                        -
                                        -   dlog_print(DLOG_DEBUG, LOG_TAG, "content type: %d\n", media_type);
                                        -
                                        -   if (path) dlog_print(DLOG_DEBUG, LOG_TAG, "path: %s\n", path);
                                        -   if (uuid) dlog_print(DLOG_DEBUG, LOG_TAG, "uuid: %s\n", uuid);
                                        -   if (mime_type) dlog_print(DLOG_DEBUG, LOG_TAG, "mime_type: %s\n", mime_type);
                                        -   if (user_data) dlog_print(DLOG_DEBUG, LOG_TAG, "String: %s\n", (char *)user_data);
                                        -
                                        -   return;
                                        +    if (error == MEDIA_CONTENT_ERROR_NONE)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "noti success! %d\n", error);
                                        +    else
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "error occurred! %d\n", error);
                                        +
                                        +    dlog_print(DLOG_DEBUG, LOG_TAG, "Noti from PID(%d)\n", pid);
                                        +
                                        +    if (update_item == MEDIA_ITEM_FILE)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "Noti item: MEDIA_ITEM_FILE\n");
                                        +    else if (update_item == MEDIA_ITEM_DIRECTORY)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "Noti item: MEDIA_ITEM_DIRECTORY\n");
                                        +
                                        +    if (update_type == MEDIA_CONTENT_INSERT)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "Noti type: MEDIA_CONTENT_INSERT\n");
                                        +    else if (update_type == MEDIA_CONTENT_DELETE)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "Noti type: MEDIA_CONTENT_DELETE\n");
                                        +    else if (update_type == MEDIA_CONTENT_UPDATE)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "Noti type: MEDIA_CONTENT_UPDATE\n");
                                        +
                                        +    dlog_print(DLOG_DEBUG, LOG_TAG, "content type: %d\n", media_type);
                                        +
                                        +    if (path)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "path: %s\n", path);
                                        +    if (uuid)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "uuid: %s\n", uuid);
                                        +    if (mime_type)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "mime_type: %s\n", mime_type);
                                        +    if (user_data)
                                        +        dlog_print(DLOG_DEBUG, LOG_TAG, "String: %s\n", (char *)user_data);
                                        +
                                        +    return;
                                         }
                                         
                                      2. @@ -478,12 +464,12 @@ _noti_cb(media_content_error_e error, int pid,
                                         int ret = MEDIA_CONTENT_ERROR_NONE;
                                         
                                        -// Subscribe notifications 
                                        +/* Subscribe notifications */
                                         char *user_str = strdup("hi");
                                         media_content_set_db_updated_cb(_noti_cb, (void*)user_str);
                                         
                                        -
                                      3. When you no longer want to receive notifications, unregister the callback: +
                                      4. When you no longer want to receive notifications, deregister the callback:
                                         media_content_unset_db_updated_cb();
                                         
                                      5. @@ -496,7 +482,8 @@ media_content_unset_db_updated_cb();
                                        1. To find the albums satisfying certain criteria, or modify the results in a specific way, create a filter and set its properties.

                                          The following example filters media albums so that only albums with the artist named "Tizen" are included in the result. The filter is case-insensitive, and the results are sorted in a descending order based on the album display name. For more information about the filter properties, see Setting up a Filter.

                                          -
                                          #define BUFLEN 200
                                          +
                                          +#define BUFLEN 200
                                           
                                           filter_h filter = NULL;
                                           char buf[BUFLEN] = {'\0'};
                                          @@ -510,15 +497,16 @@ media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_DISPLAY_NAME, MED
                                           
                                           media_album_foreach_album_from_db(filter, media_album_list_cb, NULL);
                                           
                                          -media_filter_destroy(filter);
                                          +media_filter_destroy(filter); +
                                        2. To find the albums, use the media_album_foreach_album_from_db() function.

                                          To find only a subset of the albums, use a filter. If you want to find all albums, set the filter parameter to NULL.

                                          -// Find all albums
                                          +/* Find all albums */
                                           media_album_foreach_album_from_db(NULL, media_album_list_cb, NULL);
                                           
                                          -// Find filtered albums
                                          +/* Find filtered albums */
                                           media_album_foreach_album_from_db(filter, media_album_list_cb, NULL);
                                           
                                          @@ -539,7 +527,7 @@ media_filter_destroy(filter);
                                          1. Read the album details within the callback:
                                            -bool 
                                            +bool
                                             media_album_list_cb(media_album_h album, void *user_data)
                                             {
                                             
                                            @@ -551,46 +539,37 @@ media_album_list_cb(media_album_h album, void *user_data)
                                          2. Use the media_album_get_album_id(), media_album_get_name(), and media_album_get_artist() functions to read the album ID, name, and artist:
                                            -   media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE;
                                            -
                                            -   int id = -1; 
                                            -   char *name = NULL, *artist = NULL;
                                            -   int count = -1;
                                            -
                                            -   // Get the ID of the album
                                            -   ret = media_album_get_album_id(album, &id);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling	
                                            -   }
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Album id: %d\n", id);
                                            -   }   
                                            -
                                            -   // Get name of the album
                                            -   ret = media_album_get_name(album, &name);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling
                                            -   }
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Album name: %s\n", name);
                                            -      free(name);
                                            -   }   
                                            -
                                            -   // Get the artist name
                                            -   ret = media_album_get_artist(album, &artist);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling
                                            -   } 
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Artist: %s\n", artist);
                                            -      free(artist);
                                            -   }
                                            +    media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE;
                                            +
                                            +    int id = -1;
                                            +    char *name = NULL;
                                            +    char *artist = NULL;
                                            +    int count = -1;
                                            +
                                            +    /* Get the ID of the album */
                                            +    ret = media_album_get_album_id(album, &id);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE)
                                            +        /* Error handling */
                                            +    else
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Album id: %d\n", id);
                                            +
                                            +    /* Get name of the album */
                                            +    ret = media_album_get_name(album, &name);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                            +        /* Error handling */
                                            +    } else {
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Album name: %s\n", name);
                                            +        free(name);
                                            +    }
                                            +
                                            +    /* Get the artist name */
                                            +    ret = media_album_get_artist(album, &artist);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                            +        /* Error handling */
                                            +    } else {
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Artist: %s\n", artist);
                                            +        free(artist);
                                            +    }
                                             
                                            @@ -611,19 +590,15 @@ Get the media item count in the album with the NULL, all media is counted.

                                            -   // Get media count in the album
                                            -   // Filter is NULL - all media items are counted
                                            -   ret = media_album_get_media_count_from_db(id, NULL, &count);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling
                                            -   } 
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Media count in this album: %d\n", count);
                                            -   }
                                            +    /* Get media count in the album */
                                            +    /* Filter is NULL - all media items are counted */
                                            +    ret = media_album_get_media_count_from_db(id, NULL, &count);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE)
                                            +        /* Error handling */
                                            +    else
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Media count in this album: %d\n", count);
                                             
                                            -   return true;
                                            +    return true;
                                             }
                                            @@ -639,9 +614,11 @@ Get the media item count in the album with the
                                          3. Before you can read the album content information, acquire the album ID. If you have the album handle (media_album_h), you can call the media_album_get_album_id() function:

                                            -
                                            int id = -1;
                                            +
                                            +int id = -1;
                                             
                                            -media_album_get_album_id(album, &id);
                                            +media_album_get_album_id(album, &id); +

                                            To obtain the handle, call the media_album_foreach_album_from_db() function. The handle is provided in the callback.

                                          4. @@ -649,7 +626,9 @@ media_album_get_album_id(album, &id);

                                            The following call finds all the media items in the album (NULL filter). The album_contents_info_cb() callback is called for each item.

                                            -
                                            media_album_foreach_media_from_db(id, NULL, album_contents_info_cb, NULL);
                                            +
                                            +media_album_foreach_media_from_db(id, NULL, album_contents_info_cb, NULL);
                                            +

                                            This function is synchronous. The call blocks until the callback has been called for all the albums or the callback returns false.

                                            @@ -657,50 +636,41 @@ media_album_get_album_id(album, &id);

                                            Define the callback which you set in the media_album_foreach_media_from_db() function.

                                            The following example prints the title, MIME type, and size of the media item for which it was called.

                                            -bool 
                                            +bool
                                             album_contents_info_cb(media_info_h media, void *user_data)
                                             {
                                            -   media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE;
                                            -
                                            -   char *title = NULL, *mime_type = NULL;
                                            -   unsigned long long size = -1;
                                            -
                                            -   // Read the item title
                                            -   ret = media_info_get_title(media, &title);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling
                                            -   } 
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Title: %s\n", title);
                                            -      free(title);
                                            -   }
                                            -
                                            -   // Read the item MIME type
                                            -   ret = media_info_get_mime_type(media, &mime_type);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling
                                            -   } 
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "MIME type: %s\n", mime_type);
                                            -      free(mime_type);
                                            -   }
                                            -
                                            -   // Read the item size
                                            -   ret = media_info_get_size(media, &size);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling
                                            -   } 
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Size: %llu\n", size);
                                            -   }
                                            -
                                            -   return true;
                                            +    media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE;
                                            +
                                            +    char *title = NULL;
                                            +    char *mime_type = NULL;
                                            +    unsigned long long size = -1;
                                            +
                                            +    /* Read the item title */
                                            +    ret = media_info_get_title(media, &title);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                            +        /* Error handling */
                                            +    } else {
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Title: %s\n", title);
                                            +        free(title);
                                            +    }
                                            +
                                            +    /* Read the item MIME type */
                                            +    ret = media_info_get_mime_type(media, &mime_type);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                            +        /* Error handling */
                                            +    } else {
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "MIME type: %s\n", mime_type);
                                            +        free(mime_type);
                                            +    }
                                            +
                                            +    /* Read the item size */
                                            +    ret = media_info_get_size(media, &size);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE)
                                            +        /* Error handling */
                                            +    else
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Size: %llu\n", size);
                                            +
                                            +    return true;
                                             }
                                            @@ -719,10 +689,12 @@ album_contents_info_cb(media_info_h media, void *user_data)

                                            To set a bookmark for a video file at a given timestamp, use the media_bookmark_insert_to_db() function:

                                            -
                                            char* thumbnail_path = "path/to/image/file";
                                            +
                                            +char* thumbnail_path = "path/to/image/file";
                                             
                                             media_bookmark_insert_to_db(media_id, 220, thumbnail_path);
                                            -media_bookmark_insert_to_db(media_id, 210, thumbnail_path);
                                            +media_bookmark_insert_to_db(media_id, 210, thumbnail_path); +

                                            The parameters are the media ID of the video file, the moment (time in seconds from the beginning) in the video to bookmark, and the image used as a thumbnail for the bookmark. You can use the same thumbnail for more than 1 bookmark.

                                            @@ -746,21 +718,22 @@ snprintf(buf, BUFLEN, "%s >= 220", BOOKMARK_MARKED_TIME); media_filter_set_condition(filter, buf, MEDIA_CONTENT_COLLATE_DEFAULT); media_filter_set_offset(filter, -                        // Offset -                        0, -                        // Count +                        /* Offset */ +                        0, +                        /* Count */                         3); -media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_NOCASE); +media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_NOCASE); +
                                          5. To find the bookmarks set for a media item, use the media_info_foreach_bookmark_from_db() function.

                                            To find only a subset of the bookmarks, use a filter. If you want to find all bookmarks set for a media item, set the filter parameter to NULL.

                                            -// Find all items
                                            +/* Find all items */
                                             media_info_foreach_bookmark_from_db(media_id, NULL, get_bookmarks_cb, NULL);
                                             
                                            -// Find filtered items
                                            +/* Find filtered items */
                                             media_info_foreach_bookmark_from_db(media_id, filter, get_bookmarks_cb, NULL);
                                             
                                            @@ -772,7 +745,9 @@ media_info_foreach_bookmark_from_db(media_id, filter, get_bookmarks_cb, NULL);
                                          6. Destroy the filter:

                                            -
                                            media_filter_destroy(filter);
                                          7. +
                                            +media_filter_destroy(filter);
                                            +
                                            @@ -782,7 +757,7 @@ media_info_foreach_bookmark_from_db(media_id, filter, get_bookmarks_cb, NULL);
                                            1. Read the bookmark details within the callback:
                                              -bool 
                                              +bool
                                               get_bookmarks_cb(media_bookmark_h bookmark, void* user_data)
                                               {
                                               
                                              @@ -793,13 +768,12 @@ get_bookmarks_cb(media_bookmark_h bookmark, void* user_data)
                                              • Use the media_bookmark_get_thumbnail_path() function to get the thumbnail path of the bookmark:
                                                -   char *thumb = NULL;
                                                +    char *thumb = NULL;
                                                 
                                                -   if (bookmark != NULL) 
                                                -   {
                                                -      media_bookmark_get_thumbnail_path(bookmark, &thumb);
                                                -      dlog_print(DLOG_DEBUG, LOG_TAG, "Thumbnail path: %s\n", thumb);
                                                -      free(thumb);
                                                +    if (bookmark != NULL) {
                                                +        media_bookmark_get_thumbnail_path(bookmark, &thumb);
                                                +        dlog_print(DLOG_DEBUG, LOG_TAG, "Thumbnail path: %s\n", thumb);
                                                +        free(thumb);
                                                 
                                            @@ -816,13 +790,13 @@ get_bookmarks_cb(media_bookmark_h bookmark, void* user_data)
                                          8. Use the media_bookmark_get_marked_time() function to get the marked time of the bookmark:
                                            -      time_t time;
                                            +        time_t time;
                                             
                                            -      media_bookmark_get_marked_time(bookmark, &time);
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Marked time [s]: %d\n", (int) time);
                                            -   }
                                            +        media_bookmark_get_marked_time(bookmark, &time);
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Marked time [s]: %d\n", (int) time);
                                            +    }
                                             
                                            -   return true;
                                            +    return true;
                                             }
                                             
                                          9. @@ -837,13 +811,16 @@ get_bookmarks_cb(media_bookmark_h bookmark, void* user_data)
                                             media_bookmark_h bookmark = NULL;
                                             
                                            -// Assuming you have the bookmark handle (media_bookmark_h)
                                            +/* Assuming you have the bookmark handle (media_bookmark_h) */
                                             int bookmark_id = -1;
                                            -media_bookmark_get_bookmark_id(bookmark, &bookmark_id);
                                            +media_bookmark_get_bookmark_id(bookmark, &bookmark_id); +
                                          10. Delete the bookmark:

                                            -
                                            media_bookmark_delete_from_db(bookmark_id);
                                          11. +
                                            +media_bookmark_delete_from_db(bookmark_id);
                                            +

                                            Setting up a Filter

                                            @@ -875,10 +852,10 @@ ret = media_filter_set_condition(filter, buf, MEDIA_CONTENT_COLLATE_NOCASE);
                                          12. Condition string used for filtering the search results

                                            Queries made with the Content API (in mobile and wearable applications) are passed to a SQL database. A part of each query is a WHERE clause that determines which properties correspond to certain conditions. The condition string defines the WHERE clause and must match the following pattern:

                                            -// Basic pattern
                                            +/* Basic pattern */
                                             <property> <relation> <value>
                                             
                                            -// If the relation is =, >, >=, <, or <=, the following is also valid
                                            +/* If the relation is =, >, >=, <, or <=, the following is also valid */
                                             <value> <relation> <property>
                                             
                                            @@ -929,7 +906,9 @@ media_filter_get_order(filter, &check_order_type, &check_order_keyword,

                                            The following example sets an offset that returns results starting from the beginning (offset 0), and returns a maximum of 5 results:

                                            -
                                            media_filter_set_offset(filter, 0, 5);
                                            +
                                            +media_filter_set_offset(filter, 0, 5);
                                            +

                                            To read the offset settings of an existing filter, use the media_filter_get_offset() function:

                                            @@ -937,7 +916,8 @@ media_filter_get_order(filter, &check_order_type, &check_order_keyword, int check_offset = 0; int check_count = 0; -media_filter_get_offset(filter, &check_offset, &check_count); +media_filter_get_offset(filter, &check_offset, &check_count); +
                                          13. @@ -985,10 +965,10 @@ media_folder_foreach_folder_from_db(filter, folder_cb, NULL);

                                            To find only a subset of the folders, use a filter. If you want to find all folders, set the filter parameter to NULL.

                                            -// Find all items
                                            +/* Find all items */
                                             media_folder_foreach_folder_from_db(NULL, folder_cb, NULL);
                                             
                                            -// Find filtered items 
                                            +/* Find filtered items */
                                             media_folder_foreach_folder_from_db(filter, folder_cb, NULL);
                                             

                                            The media_folder_foreach_folder_from_db() function requires a callback, which is called for every found folder. The function is synchronous, and it blocks until the callback is called for all available folders or the callback returns false. For more information on how to implement the callback, see Reading Folder Information.

                                            @@ -1008,7 +988,7 @@ media_filter_destroy(filter);
                                          14. Read the folder details within the callback:

                                            -bool 
                                            +bool
                                             folder_cb(media_folder_h folder, void *user_data)
                                             {
                                             
                                            @@ -1020,41 +1000,33 @@ folder_cb(media_folder_h folder, void *user_data)
                                            • Use the media_folder_get_folder_id(), media_folder_get_name(), and media_folder_get_path() functions to read the folder ID, name, and path:

                                              -
                                                 char *folder_id = NULL;
                                              -   char *name = NULL;
                                              -   char *path = NULL;
                                              -
                                              -   ret = media_folder_get_folder_id(folder, &folder_id);
                                              -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                              -   {
                                              -      // Error handling
                                              -   }
                                              -   else 
                                              -   {
                                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "Folder id: %s\n", folder_id);
                                              -   }
                                              -
                                              -   ret = media_folder_get_name(folder, &name);
                                              -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                              -   {
                                              -      // Error handling
                                              -   }
                                              -   else 
                                              -   {
                                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "Folder name: %s\n", name);
                                              -      free(name);
                                              -   }
                                              -
                                              -   ret = media_folder_get_path(folder, &path);
                                              -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                              -   {
                                              -      // Error handling
                                              -   }
                                              -   else 
                                              -   {
                                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "Folder path: %s\n", path);
                                              -      free(path);
                                              -   }
                                              +
                                              +    char *folder_id = NULL;
                                              +    char *name = NULL;
                                              +    char *path = NULL;
                                              +
                                              +    ret = media_folder_get_folder_id(folder, &folder_id);
                                              +    if (ret != MEDIA_CONTENT_ERROR_NONE)
                                              +        /* Error handling */
                                              +    else
                                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "Folder id: %s\n", folder_id);
                                              +
                                              +    ret = media_folder_get_name(folder, &name);
                                              +    if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                              +        /* Error handling */
                                              +    } else {
                                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "Folder name: %s\n", name);
                                              +        free(name);
                                              +    }
                                              +
                                              +    ret = media_folder_get_path(folder, &path);
                                              +    if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                              +        /* Error handling */
                                              +    } else {
                                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "Folder path: %s\n", path);
                                              +        free(path);
                                              +    }
                                              +
                                          15. @@ -1069,61 +1041,54 @@ folder_cb(media_folder_h folder, void *user_data)
                                          16. Read the folder storage type using the media_folder_get_storage_type() function:

                                            -
                                               media_content_storage_e storage_type = MEDIA_CONTENT_STORAGE_INTERNAL;
                                            -
                                            -   ret = media_folder_get_storage_type(folder, &storage_type);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling
                                            -   }
                                            -   else 
                                            -   {
                                            -      switch (storage_type) 
                                            -      {
                                            -         case MEDIA_CONTENT_STORAGE_INTERNAL:
                                            +
                                            +    media_content_storage_e storage_type = MEDIA_CONTENT_STORAGE_INTERNAL;
                                            +
                                            +    ret = media_folder_get_storage_type(folder, &storage_type);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                            +        /* Error handling */
                                            +    } else {
                                            +        switch (storage_type) {
                                            +        case MEDIA_CONTENT_STORAGE_INTERNAL:
                                                         dlog_print(DLOG_DEBUG, LOG_TAG, "Folder storage type: Internal\n");
                                                         break;
                                            -         case MEDIA_CONTENT_STORAGE_EXTERNAL:
                                            +        case MEDIA_CONTENT_STORAGE_EXTERNAL:
                                                         dlog_print(DLOG_DEBUG, LOG_TAG, "Folder storage type: External\n");
                                                         break;
                                            -         default:
                                            +        default:
                                                         dlog_print(DLOG_DEBUG, LOG_TAG, "Folder storage type: Unknown\n");
                                                         break;
                                            -      }
                                            -   }
                                          17. +        } +    } +
                                          18. Get the last modified time:

                                            -
                                               time_t time = 0;
                                            +
                                            +    time_t time = 0;
                                             
                                            -   ret = media_folder_get_modified_time(folder, &time);
                                            -   if (MEDIA_CONTENT_ERROR_NONE != ret) 
                                            -   {
                                            -      // Error handling
                                            -   }
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Modified time: %s", ctime(&time));
                                            -   }
                                          19. +    ret = media_folder_get_modified_time(folder, &time); +    if (MEDIA_CONTENT_ERROR_NONE != ret) +        /* Error handling */ +    else +        dlog_print(DLOG_DEBUG, LOG_TAG, "Modified time: %s", ctime(&time)); +
                                          20. Get the media item count in the folder with the media_folder_get_media_count_from_db() function.

                                            The second parameter is the filter. If it is set to NULL, all media is counted.

                                            -
                                               int item_count = -1; 
                                            +
                                            +    int item_count = -1;
                                             
                                            -   ret = media_folder_get_media_count_from_db(folder_id, NULL, &item_count);
                                            -   if (MEDIA_CONTENT_ERROR_NONE != ret) 
                                            -   {
                                            -      // Error handling
                                            -   }
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Number of media contents: %d\n", item_count);
                                            -   }
                                            -   free(folder_id);
                                            +    ret = media_folder_get_media_count_from_db(folder_id, NULL, &item_count);
                                            +    if (MEDIA_CONTENT_ERROR_NONE != ret)
                                            +        /* Error handling */
                                            +    else
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Number of media contents: %d\n", item_count);
                                            +    free(folder_id);
                                             
                                            -   return true;
                                            +    return true;
                                             }
                                          21. @@ -1147,7 +1112,9 @@ folder_cb(media_folder_h folder, void *user_data)
                                          22. Request folder content.

                                            To find all media items from the folder with the given ID, use the media_folder_foreach_media_from_db() function.

                                            -
                                            media_folder_foreach_media_from_db(folder_id, NULL, media_cb, NULL);
                                            +
                                            +media_folder_foreach_media_from_db(folder_id, NULL, media_cb, NULL);
                                            +

                                            This function is synchronous. The call blocks until the callback has been called for all the items or the callback returns false.

                                          23. @@ -1159,23 +1126,20 @@ folder_cb(media_folder_h folder, void *user_data)

                                            The following example prints the title of the media item for which it was called.

                                            -bool 
                                            +bool
                                             media_cb(media_info_h media, void *user_data)
                                             {
                                            -   char *title = NULL;
                                            -
                                            -   ret = media_info_get_title(media, &title);
                                            -   if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                            -   {
                                            -      // Error handling
                                            -   } 
                                            -   else 
                                            -   {
                                            -      dlog_print(DLOG_DEBUG, LOG_TAG, "Title: %s\n", title);
                                            -      free(title);
                                            -   }   
                                            -
                                            -   return true;
                                            +    char *title = NULL;
                                            +
                                            +    ret = media_info_get_title(media, &title);
                                            +    if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                            +        /* Error handling */
                                            +    } else {
                                            +        dlog_print(DLOG_DEBUG, LOG_TAG, "Title: %s\n", title);
                                            +        free(title);
                                            +    }
                                            +
                                            +    return true;
                                             }
                                             
                                            @@ -1188,23 +1152,23 @@ media_cb(media_info_h media, void *user_data)
                                            1. Define a callback function for the media_info_foreach_media_from_db() function, called for each available media item. Use the callback to create a list of items.
                                              -bool 
                                              +bool
                                               gallery_media_item_cb(media_info_h media, void *user_data)
                                               {
                                              -   media_info_h new_media = NULL;
                                              -   media_info_clone(&new_media, media);
                                              +    media_info_h new_media = NULL;
                                              +    media_info_clone(&new_media, media);
                                               
                                              -   GList **list = (GList**)user_data;
                                              -   *list = g_list_append(*list, new_media);
                                              +    GList **list = (GList**)user_data;
                                              +    *list = g_list_append(*list, new_media);
                                               
                                              -   return true;
                                              +    return true;
                                               }
                                               
                                            2. To find the items satisfying certain criteria, or modify the results in a specific way, create a filter and set its properties.

                                              The following example filters media items so that only image and video items are included in the result. The filter is case-insensitive, and the results are sorted in a descending order based on the item display name. For more information about the filter properties, see Setting up a Filter.

                                               #define BUFLEN 200
                                              -GList *all_item_list = NULL; // Include glib.h
                                              +GList *all_item_list = NULL; /* Include glib.h */
                                               media_content_type_e media_type;
                                               media_info_h media_handle = NULL;
                                               char *media_id = NULL;
                                              @@ -1218,25 +1182,23 @@ media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
                                               
                                               media_filter_create(&filter);
                                               
                                              -// Set the condition
                                              -snprintf(buf, BUFLEN, "%s = %d OR %s = %d", MEDIA_TYPE, 
                                              +/* Set the condition */
                                              +snprintf(buf, BUFLEN, "%s = %d OR %s = %d", MEDIA_TYPE,
                                                        MEDIA_CONTENT_TYPE_IMAGE, MEDIA_TYPE, MEDIA_CONTENT_TYPE_VIDEO);
                                               
                                               ret = media_filter_set_condition(filter, buf, collate_type);
                                              -if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                              -{
                                              -   media_filter_destroy(filter);
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set condition");
                                              +if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                              +    media_filter_destroy(filter);
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set condition");
                                               
                                              -   return ret;
                                              +    return ret;
                                               }
                                               ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
                                              -if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                              -{
                                              -   media_filter_destroy(filter);
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set order");
                                              +if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                              +    media_filter_destroy(filter);
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set order");
                                               
                                              -   return ret;
                                              +    return ret;
                                               }
                                               
                                            3. @@ -1246,99 +1208,92 @@ if (ret != MEDIA_CONTENT_ERROR_NONE)

                                              After the callback has created the item list, you can access the item details with various media_info_get_XXX() functions. Note that media information is based on the media information handle, and to obtain the information (metadata), you must first retrieve the handle. The available metadata varies depending on the media type, such as image, video, or audio.

                                               ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
                                              -if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "media_info_foreach_media_from_db failed: %d", ret);
                                              -   media_filter_destroy(filter);
                                              -
                                              -   return ret;
                                              -} 
                                              -else 
                                              -{
                                              -   int i;
                                              -
                                              -   for (i = 0; i < g_list_length(all_item_list); i++) 
                                              -   {
                                              -      media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
                                              -
                                              -      media_info_get_media_id(media_handle, &media_id);
                                              -      media_info_get_media_type(media_handle, &media_type);
                                              -      media_info_get_display_name(media_handle, &media_name);
                                              -      media_info_get_file_path(media_handle, &media_path);
                                              -
                                              -      if (media_type == MEDIA_CONTENT_TYPE_IMAGE) 
                                              -      {
                                              -         image_meta_h image_handle;
                                              -         media_content_orientation_e orientation = 0;
                                              -         int width = 0, height = 0;
                                              -         char *datetaken = NULL;
                                              -         char *burst_id = NULL;
                                              -
                                              -         ret = media_info_get_image(media_handle, &image_handle);
                                              -         if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                              -         {
                                              -            // Error handling
                                              -         } 
                                              -         else 
                                              -         {
                                              -            image_meta_get_width(image_handle, &width);
                                              -            image_meta_get_height(image_handle, &height);
                                              -            image_meta_get_orientation(image_handle, &orientation);
                                              -            image_meta_get_date_taken(image_handle, &datetaken);
                                              -            image_meta_get_burst_id(image_handle, &burst_id);
                                              -
                                              -            dlog_print(DLOG_DEBUG, LOG_TAG, "This is an image");
                                              -            dlog_print(DLOG_DEBUG, LOG_TAG, "Width: %d, Height: %d, Orientation: %d, Date taken: %s", 
                                              -                       width, height, orientation, datetaken);
                                              -         }
                                              -
                                              -         if (datetaken) free(datetaken);
                                              -         if (burst_id) free(burst_id);
                                              -
                                              -         image_meta_destroy(image_handle);
                                              -      } 
                                              -      else if (media_type == MEDIA_CONTENT_TYPE_VIDEO) 
                                              -      {
                                              -         video_meta_h video_handle;
                                              -         char *title = NULL, *artist = NULL, *album = NULL, *album_artist = NULL;
                                              -         int duration = 0;
                                              -         time_t time_played = 0;
                                              -
                                              -         ret = media_info_get_video(media_handle, &video_handle);
                                              -         if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                              -         {
                                              -            // Error handling
                                              -         } 
                                              -         else 
                                              -         {
                                              -            video_meta_get_artist(video_handle, &artist);
                                              -            video_meta_get_album(video_handle, &album);
                                              -            video_meta_get_album_artist(video_handle, &album_artist);
                                              -            video_meta_get_duration(video_handle, &duration);
                                              -
                                              -            media_info_get_played_time(media_handle, &time_played);
                                              -
                                              -            dlog_print(DLOG_DEBUG, LOG_TAG, "This is a video");
                                              -            dlog_print(DLOG_DEBUG, LOG_TAG, 
                                              -                       "Title: %s, Album: %s, Artist: %s, Album_artist: %s \n Duration: %d, Played time: %d", 
                                              -                       title, album, artist, album_artist, duration, time_played);
                                              -         }
                                              -
                                              -         free(artist);
                                              -         free(album);
                                              -         free(album_artist);
                                              -
                                              -         video_meta_destroy(video_handle);
                                              -      }
                                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "media_id [%d]: %s", i, media_id);
                                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "media_name [%d]: %s", i, media_name);
                                              -      dlog_print(DLOG_DEBUG, LOG_TAG, "media_path [%d]: %s", i, media_path);
                                              -
                                              -      free(media_id);
                                              -      free(media_name);
                                              -      free(media_path);
                                              -      free(title);
                                              -   }
                                              +if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "media_info_foreach_media_from_db failed: %d", ret);
                                              +    media_filter_destroy(filter);
                                              +
                                              +    return ret;
                                              +} else {
                                              +    int i;
                                              +
                                              +    for (i = 0; i < g_list_length(all_item_list); i++) {
                                              +        media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
                                              +
                                              +        media_info_get_media_id(media_handle, &media_id);
                                              +        media_info_get_media_type(media_handle, &media_type);
                                              +        media_info_get_display_name(media_handle, &media_name);
                                              +        media_info_get_file_path(media_handle, &media_path);
                                              +
                                              +        if (media_type == MEDIA_CONTENT_TYPE_IMAGE) {
                                              +            image_meta_h image_handle;
                                              +            media_content_orientation_e orientation = 0;
                                              +            int width = 0;
                                              +            int height = 0;
                                              +            char *datetaken = NULL;
                                              +            char *burst_id = NULL;
                                              +
                                              +            ret = media_info_get_image(media_handle, &image_handle);
                                              +            if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                              +                /* Error handling */
                                              +            } else {
                                              +                image_meta_get_width(image_handle, &width);
                                              +                image_meta_get_height(image_handle, &height);
                                              +                image_meta_get_orientation(image_handle, &orientation);
                                              +                image_meta_get_date_taken(image_handle, &datetaken);
                                              +                image_meta_get_burst_id(image_handle, &burst_id);
                                              +
                                              +                dlog_print(DLOG_DEBUG, LOG_TAG, "This is an image");
                                              +                dlog_print(DLOG_DEBUG, LOG_TAG, "Width: %d, Height: %d, Orientation: %d, Date taken: %s",
                                              +                           width, height, orientation, datetaken);
                                              +            }
                                              +
                                              +            if (datetaken)
                                              +                free(datetaken);
                                              +            if (burst_id)
                                              +                free(burst_id);
                                              +
                                              +            image_meta_destroy(image_handle);
                                              +        } else if (media_type == MEDIA_CONTENT_TYPE_VIDEO) {
                                              +            video_meta_h video_handle;
                                              +            char *title = NULL;
                                              +            char *artist = NULL;
                                              +            char *album = NULL;
                                              +            char *album_artist = NULL;
                                              +            int duration = 0;
                                              +            time_t time_played = 0;
                                              +
                                              +            ret = media_info_get_video(media_handle, &video_handle);
                                              +            if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                              +                /* Error handling */
                                              +            } else {
                                              +                video_meta_get_artist(video_handle, &artist);
                                              +                video_meta_get_album(video_handle, &album);
                                              +                video_meta_get_album_artist(video_handle, &album_artist);
                                              +                video_meta_get_duration(video_handle, &duration);
                                              +
                                              +                media_info_get_played_time(media_handle, &time_played);
                                              +
                                              +                dlog_print(DLOG_DEBUG, LOG_TAG, "This is a video");
                                              +                dlog_print(DLOG_DEBUG, LOG_TAG,
                                              +                           "Title: %s, Album: %s, Artist: %s, Album_artist: %s \n Duration: %d, Played time: %d",
                                              +                           title, album, artist, album_artist, duration, time_played);
                                              +            }
                                              +
                                              +            free(artist);
                                              +            free(album);
                                              +            free(album_artist);
                                              +
                                              +            video_meta_destroy(video_handle);
                                              +        }
                                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "media_id [%d]: %s", i, media_id);
                                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "media_name [%d]: %s", i, media_name);
                                              +        dlog_print(DLOG_DEBUG, LOG_TAG, "media_path [%d]: %s", i, media_path);
                                              +
                                              +        free(media_id);
                                              +        free(media_name);
                                              +        free(media_path);
                                              +        free(title);
                                              +    }
                                               }
                                               
                                              @@ -1355,13 +1310,12 @@ filter = NULL;

                                              To use newly created media files, insert them into the database:

                                              -
                                              1. Add the http://tizen.org/privilege/content.write privilege to the manifest file of the application to use the needed APIs.

                                                -

                                                In addition, add the http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage privilege, since when you insert metadata, the Media Content APIs access content in the internal or external storage.

                                              2. - +
                                                1. To add information in the database, use one of the following options:

                                                  • media_info_insert_to_db() function:

                                                    -
                                                    int ret = MEDIA_CONTENT_ERROR_NONE;
                                                    +
                                                    +int ret = MEDIA_CONTENT_ERROR_NONE;
                                                     char *image_file = "Default.jpg";
                                                     char *directory = NULL;
                                                     char *path = NULL;
                                                    @@ -1375,26 +1329,22 @@ media_info_h media_item = NULL;
                                                     
                                                     ret = media_info_insert_to_db(path, &media_item);
                                                     
                                                    -if ((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL)) 
                                                    -{
                                                    -   dlog_print(DLOG_DEBUG, LOG_TAG, "Insertion successful");
                                                    -} 
                                                    -else 
                                                    -{
                                                    -   dlog_print(DLOG_ERROR, LOG_TAG, "Insertion failed");
                                                    -   if (media_item != NULL)
                                                    -      media_info_destroy(media_item);
                                                    +if ((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL)) {
                                                    +    dlog_print(DLOG_DEBUG, LOG_TAG, "Insertion successful");
                                                    +} else {
                                                    +    dlog_print(DLOG_ERROR, LOG_TAG, "Insertion failed");
                                                    +    if (media_item != NULL)
                                                    +        media_info_destroy(media_item);
                                                     
                                                    -   return ret;
                                                    +    return ret;
                                                     }
                                                     
                                                    -// After using the media handle, destroy it
                                                    +/* After using the media handle, destroy it */
                                                     ret = media_info_destroy(media_item);
                                                    -if (ret != MEDIA_CONTENT_ERROR_NONE) 
                                                    -{
                                                    -   // Error handling
                                                    +if (ret != MEDIA_CONTENT_ERROR_NONE) {
                                                    +    /* Error handling */
                                                     
                                                    -   return ret;
                                                    +    return ret;
                                                     }
                                                     

                                                    After using the media_info_insert_to_db() function, destroy the received media_info_h using the media_info_destroy() function.

                                                  • @@ -1413,9 +1363,7 @@ sprintf(file_path, "%s/%s", directory, image_file); ret = media_content_scan_file(file_path); if (ret != MEDIA_CONTENT_ERROR_NONE) -{ -   // Error handling -} +    /* Error handling */
                                                  @@ -1430,16 +1378,14 @@ if (ret != MEDIA_CONTENT_ERROR_NONE)

                                                  To insert a media folder, and optionally any subfolders, in the database:

                                                    -
                                                  1. Add the http://tizen.org/privilege/content.write privilege to the manifest file of the application to use these APIs.

                                                    -

                                                    In addition, add the http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage privilege, since when you insert metadata, the Media Content APIs access content in the internal or external storage.

                                                  2. Define a callback function that is called after the asynchronous insertion (scanning) process is completed:
                                                    -void 
                                                    +void
                                                     _scan_cb(media_content_error_e err, void *user_data)
                                                     {
                                                    -   dlog_print(DLOG_DEBUG, LOG_TAG, "Folder scanned\n");
                                                    +    dlog_print(DLOG_DEBUG, LOG_TAG, "Folder scanned\n");
                                                     
                                                    -   return;
                                                    +    return;
                                                     }
                                                     
                                                  3. @@ -1452,11 +1398,10 @@ char *dir_path = NULL; storage_get_directory(0, STORAGE_DIRECTORY_IMAGES, &dir_path); ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL); -if (ret != MEDIA_CONTENT_ERROR_NONE) -{ -   // Error handling +if (ret != MEDIA_CONTENT_ERROR_NONE) { +    /* Error handling */ -   return ret; +    return ret; }
                                                  @@ -1469,7 +1414,7 @@ if (ret != MEDIA_CONTENT_ERROR_NONE)

                                                  To operate on the database, it has to contain records. Add a new playlist to the database using the media_playlist_insert_to_db() function. It returns a handle to the newly created record.

                                                   media_playlist_h playlist = NULL;
                                                  -GList *media_id_list = NULL; // This requires glib.h inclusion
                                                  +GList *media_id_list = NULL; /* This requires glib.h inclusion */
                                                   int media_count;
                                                   int start_position = -1;
                                                   int count = -1;
                                                  @@ -1477,7 +1422,7 @@ int x;
                                                   int id;
                                                   int ret;
                                                   
                                                  -// Create the playlist
                                                  +/* Create the playlist */
                                                   media_playlist_insert_to_db("playlist_for_tutorial", &playlist);
                                                   

                                                  You can modify the playlist name later on using the media_playlist_set_name() function.

                                                  @@ -1485,52 +1430,49 @@ media_playlist_insert_to_db("playlist_for_tutorial", &playlist);
                                                2. Define a callback function for the media_info_foreach_media_from_db() function, called for each available media item. Use the callback to cast the user data to a proper type and copy the media ID to a list:

                                                  -bool 
                                                  +bool
                                                   _media_info_cb(media_info_h media, void *user_data)
                                                   {
                                                  -   char *data = NULL;
                                                  -   char *id = NULL;
                                                  +    char *data = NULL;
                                                  +    char *id = NULL;
                                                   
                                                  -   if (media != NULL) 
                                                  -   {
                                                  -      GList **list = (GList**)user_data;
                                                  +    if (media != NULL) {
                                                  +        GList **list = (GList**)user_data;
                                                   
                                                  -      media_info_get_media_id(media, &id);
                                                  -      dlog_print(DLOG_DEBUG, LOG_TAG, "Media found: %s\n", id);
                                                  +        media_info_get_media_id(media, &id);
                                                  +        dlog_print(DLOG_DEBUG, LOG_TAG, "Media found: %s\n", id);
                                                   
                                                  -      data = strdup(id);
                                                  -      *list = g_list_append(*list, data);
                                                  +        data = strdup(id);
                                                  +        *list = g_list_append(*list, data);
                                                   
                                                  -      free(id);
                                                  -   }
                                                  +        free(id);
                                                  +    }
                                                   
                                                  -   return true;
                                                  +    return true;
                                                   }
                                                   
                                                3. To be able to fill a playlist with data, insert existing media in the database using the media_content_scan_file() function. You can also check the media database size using the media_info_get_media_count_from_db() function and allocate the required amount of space.

                                                  -// path must be set to an audio file
                                                  -media_content_scan_file(path); 
                                                  +/* path must be set to an audio file */
                                                  +media_content_scan_file(path);
                                                   
                                                  -media_info_get_media_count_from_db(NULL, &media_count); 
                                                  +media_info_get_media_count_from_db(NULL, &media_count);
                                                   
                                                4. To find the media items to be added to the playlist, call the media_info_foreach_media_from_db() function with the defined callback. After the callback has created the media ID list, you can add the media items to the playlist with the media_playlist_add_media() function.

                                                  -media_info_foreach_media_from_db(NULL, _media_info_cb, &media_id_list); 
                                                  +media_info_foreach_media_from_db(NULL, _media_info_cb, &media_id_list);
                                                   
                                                  -if (media_count > 0) 
                                                  -{
                                                  -   for (x = 0; x < media_count; x++) 
                                                  -   {
                                                  -      char *media_id = (char*)g_list_nth_data(media_id_list, x);
                                                  +if (media_count > 0) {
                                                  +    for (x = 0; x < media_count; x++) {
                                                  +        char *media_id = (char*)g_list_nth_data(media_id_list, x);
                                                   
                                                  -      ret = media_playlist_add_media(playlist, media_id);
                                                  +        ret = media_playlist_add_media(playlist, media_id);
                                                   
                                                  -      free(media_id);
                                                  -   }
                                                  +        free(media_id);
                                                  +    }
                                                   }
                                                   
                                                   media_playlist_update_to_db(playlist);
                                                  @@ -1558,10 +1500,10 @@ media_playlist_destroy(playlist);
                                                   

                                                  To find only a subset of the playlists, use a filter. If you want to find all playlists, set the filter parameter to NULL.

                                                  -// Find all playlists
                                                  +/* Find all playlists */
                                                   media_playlist_foreach_playlist_from_db(NULL, playlist_list_cb,  NULL);
                                                   
                                                  -// Find filtered playlists
                                                  +/* Find filtered playlists */
                                                   media_playlist_foreach_playlist_from_db(filter, playlist_list_cb,  NULL);
                                                   
                                                  @@ -1582,12 +1524,12 @@ media_filter_destroy(filter);
                                                  1. Read the playlist details within the callback:

                                                    -static bool 
                                                    -playlist_list_cb(media_playlist_h playlist, void* user_data) 
                                                    +static bool
                                                    +playlist_list_cb(media_playlist_h playlist, void* user_data)
                                                     {
                                                    -   char *name = NULL;
                                                    -   int playlist_id = 0;
                                                    -   int count = 0;
                                                    +    char *name = NULL;
                                                    +    int playlist_id = 0;
                                                    +    int count = 0;
                                                     

                                                    A handle to the record is passed as a parameter. The return value determines whether the iterative calls of the callback continue (true) or are stopped (false).

                                                  2. @@ -1596,31 +1538,31 @@ playlist_list_cb(media_playlist_h playlist, void* user_data)
                                                  3. Use the media_playlist_get_name() and media_playlist_get_playlist_id() functions to read the playlist name and ID:

                                                    -   media_playlist_get_name(playlist, &name);
                                                    -   media_playlist_get_playlist_id(playlist, &playlist_id);
                                                    +    media_playlist_get_name(playlist, &name);
                                                    +    media_playlist_get_playlist_id(playlist, &playlist_id);
                                                     
                                                  4. Access the records within the playlist using the playlist ID.

                                                    In the following example, 2 searches are executed for the records. The first search operates on all records on the playlist and retrieves the record count. The second search retrieves the first 10 records. Destroy the filters after all operations.

                                                    -   filter_h temp_filter = NULL;
                                                    -   media_filter_create(&temp_filter);
                                                    +    filter_h temp_filter = NULL;
                                                    +    media_filter_create(&temp_filter);
                                                     
                                                    -   media_filter_set_offset(temp_filter, -1, -1);
                                                    +    media_filter_set_offset(temp_filter, -1, -1);
                                                     
                                                    -   media_playlist_get_media_count_from_db(playlist_id, temp_filter, &count);
                                                    -   filter_h audio_fltr;
                                                    +    media_playlist_get_media_count_from_db(playlist_id, temp_filter, &count);
                                                    +    filter_h audio_fltr;
                                                     
                                                    -   media_filter_create(&audio_fltr);
                                                    +    media_filter_create(&audio_fltr);
                                                     
                                                    -   media_filter_set_offset(audio_fltr, 0, 10);
                                                    +    media_filter_set_offset(audio_fltr, 0, 10);
                                                     
                                                    -   media_playlist_foreach_media_from_db(playlist_id, audio_fltr, audio_list_cb, NULL);
                                                    +    media_playlist_foreach_media_from_db(playlist_id, audio_fltr, audio_list_cb, NULL);
                                                     
                                                    -   media_filter_destroy(audio_fltr);
                                                    -   media_filter_destroy(temp_filter);
                                                    +    media_filter_destroy(audio_fltr);
                                                    +    media_filter_destroy(temp_filter);
                                                     
                                                    -   return true;
                                                    +    return true;
                                                     }
                                                     
                                                  5. @@ -1630,15 +1572,15 @@ playlist_list_cb(media_playlist_h playlist, void* user_data)
                                                  6. media_info_get_size()
                                                  7. -static bool 
                                                    -audio_list_cb(int playlist_member_id, media_info_h media_hndl, void *user_data) 
                                                    +static bool
                                                    +audio_list_cb(int playlist_member_id, media_info_h media_hndl, void *user_data)
                                                     {
                                                    -   char * id;
                                                    -   media_info_get_media_id(media_hndl, &id);
                                                    -   dlog_print(DLOG_DEBUG, LOG_TAG, "Media on the playlist: %s\n", id);
                                                    -   free(id);
                                                    +    char * id;
                                                    +    media_info_get_media_id(media_hndl, &id);
                                                    +    dlog_print(DLOG_DEBUG, LOG_TAG, "Media on the playlist: %s\n", id);
                                                    +    free(id);
                                                     
                                                    -   return true;
                                                    +    return true;
                                                     }
                                                     
                                                  @@ -1711,30 +1653,30 @@ media_tag_destroy(tag);
                                                  1. Define callback functions for the media_tag_foreach_tag_from_db() and media_tag_foreach_media_from_db() functions, called for each available tag and each available media item for a specific tag. Use the callbacks to create a list of tags and media items.
                                                    -// glib library is used, so include glib.h
                                                    +/* glib library is used, so include glib.h */
                                                     
                                                    -bool 
                                                    +bool
                                                     gallery_tag_item_cb(media_tag_h tag, void *user_data)
                                                     {
                                                    -   media_tag_h new_tag = NULL;
                                                    -   media_tag_clone(&new_tag, tag);
                                                    +    media_tag_h new_tag = NULL;
                                                    +    media_tag_clone(&new_tag, tag);
                                                     
                                                    -   GList **list = (GList**)user_data;
                                                    -   *list = g_list_append(*list, new_tag);
                                                    +    GList **list = (GList**)user_data;
                                                    +    *list = g_list_append(*list, new_tag);
                                                     
                                                    -   return true;
                                                    +    return true;
                                                     }
                                                     
                                                    -bool 
                                                    +bool
                                                     gallery_media_item_cb(media_info_h media, void *user_data)
                                                     {
                                                    -   media_info_h new_media = NULL;
                                                    -   media_info_clone(&new_media, media);
                                                    +    media_info_h new_media = NULL;
                                                    +    media_info_clone(&new_media, media);
                                                     
                                                    -   GList **list = (GList**)user_data;
                                                    -   *list = g_list_append(*list, new_media);
                                                    +    GList **list = (GList**)user_data;
                                                    +    *list = g_list_append(*list, new_media);
                                                     
                                                    -   return true;
                                                    +    return true;
                                                     }
                                                     
                                                  2. To find the tags and related media items, use the media_tag_foreach_tag_from_db() and media_tag_foreach_media_from_db() functions with the defined callbacks. The functions are synchronous, and they block until the callbacks have been called for all items or the callbacks return false. @@ -1748,68 +1690,60 @@ GList *media_list_in_tag = NULL; ret = media_tag_foreach_tag_from_db(NULL, gallery_tag_item_cb, &tag_list); -if (ret != MEDIA_CONTENT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "media_tag_foreach_tag_from_db() failed: %d", ret); - -   return ret; -} -else -{ -   dlog_print(DLOG_DEBUG, LOG_TAG, "media_tag_foreach_tag_from_db() successful"); -   char *tag_name = NULL; -   int tag_id; - -   for (i = 0; i < g_list_length(tag_list); i++) -   { -      tag_handle = (media_tag_h)g_list_nth_data(tag_list, i); -      media_tag_get_tag_id(tag_handle, &tag_id); -      media_tag_get_name(tag_handle, &tag_name); - -      ret = media_tag_foreach_media_from_db(tag_id, NULL, gallery_media_item_cb, &media_list_in_tag); -      if (ret != MEDIA_CONTENT_ERROR_NONE) -      { -         dlog_print(DLOG_ERROR, LOG_TAG, "media_tag_foreach_media_from_db() failed: %d", ret); - -         return ret; -      } -      else -      { -         dlog_print(DLOG_DEBUG, LOG_TAG, "media_tag_foreach_media_from_db() successful"); -         int j = 0; -         media_info_h tag_media_handle; -         char *media_id = NULL; -         char *media_name = NULL; -         char *media_path = NULL; -         media_content_type_e media_type = MEDIA_CONTENT_TYPE_IMAGE; - -         for (j = 0; j < g_list_length(media_list_in_tag); j++) -         { -            tag_media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, j); -            ret = media_info_get_media_id(tag_media_handle, &media_id); - -            ret = media_info_get_display_name(tag_media_handle, &media_name); - -            ret = media_info_get_file_path(tag_media_handle, &media_path); - -            ret = media_info_get_media_type(tag_media_handle, &media_type); - -            dlog_print(DLOG_DEBUG, LOG_TAG, "[%s] media_id [%d]: %s", tag_name, j, media_id); -            dlog_print(DLOG_DEBUG, LOG_TAG, "[%s] media_type [%d]: %d", tag_name, j, media_type); -            dlog_print(DLOG_DEBUG, LOG_TAG, "[%s] media_name [%d]: %s", tag_name, j, media_name); -            dlog_print(DLOG_DEBUG, LOG_TAG, "[%s] media_path [%d]: %s", tag_name, j, media_path); - -            free(media_name); -            free(media_path); -            media_info_destroy(tag_media_handle); -         } -      } -      free(tag_name); -      media_tag_destroy(tag_handle); -      g_list_free(media_list_in_tag); -      media_list_in_tag = NULL; -   } -   g_list_free(tag_list); +if (ret != MEDIA_CONTENT_ERROR_NONE) { +    dlog_print(DLOG_ERROR, LOG_TAG, "media_tag_foreach_tag_from_db() failed: %d", ret); + +    return ret; +} else { +    dlog_print(DLOG_DEBUG, LOG_TAG, "media_tag_foreach_tag_from_db() successful"); +    char *tag_name = NULL; +    int tag_id; + +    for (i = 0; i < g_list_length(tag_list); i++) { +        tag_handle = (media_tag_h)g_list_nth_data(tag_list, i); +        media_tag_get_tag_id(tag_handle, &tag_id); +        media_tag_get_name(tag_handle, &tag_name); + +        ret = media_tag_foreach_media_from_db(tag_id, NULL, gallery_media_item_cb, &media_list_in_tag); +        if (ret != MEDIA_CONTENT_ERROR_NONE) { +            dlog_print(DLOG_ERROR, LOG_TAG, "media_tag_foreach_media_from_db() failed: %d", ret); + +            return ret; +        } else { +            dlog_print(DLOG_DEBUG, LOG_TAG, "media_tag_foreach_media_from_db() successful"); +            int j = 0; +            media_info_h tag_media_handle; +            char *media_id = NULL; +            char *media_name = NULL; +            char *media_path = NULL; +            media_content_type_e media_type = MEDIA_CONTENT_TYPE_IMAGE; + +            for (j = 0; j < g_list_length(media_list_in_tag); j++) { +                tag_media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, j); +                ret = media_info_get_media_id(tag_media_handle, &media_id); + +                ret = media_info_get_display_name(tag_media_handle, &media_name); + +                ret = media_info_get_file_path(tag_media_handle, &media_path); + +                ret = media_info_get_media_type(tag_media_handle, &media_type); + +                dlog_print(DLOG_DEBUG, LOG_TAG, "[%s] media_id [%d]: %s", tag_name, j, media_id); +                dlog_print(DLOG_DEBUG, LOG_TAG, "[%s] media_type [%d]: %d", tag_name, j, media_type); +                dlog_print(DLOG_DEBUG, LOG_TAG, "[%s] media_name [%d]: %s", tag_name, j, media_name); +                dlog_print(DLOG_DEBUG, LOG_TAG, "[%s] media_path [%d]: %s", tag_name, j, media_path); + +                free(media_name); +                free(media_path); +                media_info_destroy(tag_media_handle); +            } +        } +        free(tag_name); +        media_tag_destroy(tag_handle); +        g_list_free(media_list_in_tag); +        media_list_in_tag = NULL; +    } +    g_list_free(tag_list); }
                                                @@ -1832,21 +1766,20 @@ media_tag_foreach_tag_from_db(NULL, gallery_tag_item_cb, &tag_list); int len = g_list_length(tag_list); int i; -for (i = 0; i < len; i++) -{ -   tag_handle = (media_tag_h) g_list_nth_data(tag_list, i); -   ret = media_tag_get_tag_id(tag_handle, &tag_id); +for (i = 0; i < len; i++) { +    tag_handle = (media_tag_h) g_list_nth_data(tag_list, i); +    ret = media_tag_get_tag_id(tag_handle, &tag_id);
                                              3. Delete the tag with the media_tag_delete_from_db() function.
                                                -   ret = media_tag_delete_from_db(tag_id);
                                                +    ret = media_tag_delete_from_db(tag_id);
                                                 
                                              4. When no longer needed, destroy the handle:
                                                -   ret = media_tag_destroy(tag_handle);
                                                +    ret = media_tag_destroy(tag_handle);
                                                 }
                                                 
                                              5. @@ -1866,14 +1799,14 @@ tag_list = NULL;
                                                1. Define a callback function for the media_storage_foreach_storage_from_db() function, called for each available storage. Use the callback to create a list of storages.
                                                  -void 
                                                  +void
                                                   storage_cb(media_storage_h storage, void *user_data)
                                                   {
                                                  -   media_storage_h new_storage = NULL;
                                                  -   media_storage_clone(&new_storage, storage);
                                                  +    media_storage_h new_storage = NULL;
                                                  +    media_storage_clone(&new_storage, storage);
                                                   
                                                  -   GList **list = (GList**)user_data;
                                                  -   *list = g_list_append(*list, new_media);
                                                  +    GList **list = (GList**)user_data;
                                                  +    *list = g_list_append(*list, new_media);
                                                   }
                                                   
                                                2. To find the storages, call the media_storage_foreach_storage_from_db() function with the defined callback. After the callback has created the storage list, you can access the storage details with various media_storage_get_XXX() functions. @@ -1881,33 +1814,29 @@ storage_cb(media_storage_h storage, void *user_data) char *id = NULL; char *name = NULL; char *path = NULL; -GList *storage_list = NULL; // Include glib.h +GList *storage_list = NULL; /* Include glib.h */ media_storage_h storage = NULL; ret = media_storage_foreach_storage_from_db(NULL, storage_cb, &storage_list); -if (ret != MEDIA_CONTENT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "media_storage_foreach_storage_from_db failed: %d", ret); +if (ret != MEDIA_CONTENT_ERROR_NONE) { +    dlog_print(DLOG_ERROR, LOG_TAG, "media_storage_foreach_storage_from_db failed: %d", ret); -   return ret; -} -else -{ -   int i; +    return ret; +} else { +    int i; -   for (i = 0; i < g_list_length(storage_list); i++) -   { -      storage = (media_storage_h)g_list_nth_data(storage_list, i); -      media_storage_get_id(new_storage, &id); -      media_storage_get_name(new_storage, &name); -      media_storage_get_path(new_storage, &path); +    for (i = 0; i < g_list_length(storage_list); i++) { +        storage = (media_storage_h)g_list_nth_data(storage_list, i); +        media_storage_get_id(new_storage, &id); +        media_storage_get_name(new_storage, &name); +        media_storage_get_path(new_storage, &path); -      dlog_print(DLOG_DEBUG, LOG_TAG, "id:[%s] name:[%s] path:[%s]", id, name, path); +        dlog_print(DLOG_DEBUG, LOG_TAG, "id:[%s] name:[%s] path:[%s]", id, name, path); -      free(id); -      free(name); -      free(storage); -   } +        free(id); +        free(name); +        free(storage); +    } }
                                                @@ -1927,7 +1856,7 @@ filter_h filter; media_filter_create(&filter); -#define BUFLEN 200 // This is just an example +#define BUFLEN 200 /* This is just an example */ char buf[BUFLEN] = {'\0'}; snprintf(buf, BUFLEN, "%s LIKE '%%.jpg'", MEDIA_DISPLAY_NAME); @@ -1940,7 +1869,7 @@ media_filter_set_condition(filter, buf, MEDIA_CONTENT_COLLATE_DEFAULT);
                                                 media_group_e group = MEDIA_CONTENT_GROUP_MIME_TYPE;
                                                -int count = -1; 
                                                +int count = -1;
                                                 
                                                 media_group_get_group_count_from_db(NULL, group, &count);
                                                 dlog_print(DLOG_DEBUG, LOG_TAG, "Group count: %d\n", count);
                                                @@ -1952,14 +1881,14 @@ dlog_print(DLOG_DEBUG, LOG_TAG, "Group count: %d\n", count);
                                                 
                                                 

                                                To find only a subset of the groups, use a filter. If you want to find all groups, set the filter parameter to NULL.

                                                -// Find all media group items
                                                -media_group_foreach_group_from_db(NULL, group, group_cb, (void *) group);
                                                +/* Find all media group items */
                                                +media_group_foreach_group_from_db(NULL, group, group_cb, (void *)group);
                                                 
                                                -// Find filtered media group items
                                                -media_group_foreach_group_from_db(filter, group, group_cb, (void *) group);
                                                +/* Find filtered media group items */
                                                +media_group_foreach_group_from_db(filter, group, group_cb, (void *)group);
                                                 
                                                -

                                                The media_group_foreach_group_from_db function requires a callback, which is called for every found media item group. The function is synchronous, and it blocks until the callback is called for all media item groups or the callback returns false. For information on how to implement the callback, see Reading Media Item Group Information.

                                                +

                                                The media_group_foreach_group_from_db() function requires a callback, which is called for every found media item group. The function is synchronous, and it blocks until the callback is called for all media item groups or the callback returns false. For information on how to implement the callback, see Reading Media Item Group Information.

                                            4. Destroy the filter: @@ -1975,7 +1904,7 @@ media_filter_destroy(filter);
                                              1. Read the media item group details within the callback:
                                                -bool 
                                                +bool
                                                 group_cb(const char *name, void *user_data)
                                                 {
                                                 
                                                @@ -1988,39 +1917,38 @@ group_cb(const char *name, void *user_data)

                                                Get the number of items in the group using the media_group_get_media_count_from_db() function.

                                                The third parameter is the filter. If it is set to NULL, all items in the group are counted.

                                                -   media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE;
                                                -   media_group_e group = (media_group_e) user_data;
                                                +    media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE;
                                                +    media_group_e group = (media_group_e) user_data;
                                                 
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "\n");
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Group name: %s\n", name);
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "\n");
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Group name: %s\n", name);
                                                 
                                                -   int count = -1; 
                                                -   media_group_get_media_count_from_db(name, group, NULL, &count);
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Media count in group: %d\n", count);
                                                +    int count = -1;
                                                +    media_group_get_media_count_from_db(name, group, NULL, &count);
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Media count in group: %d\n", count);
                                                 
                                              2. Get all items in the group using the media_group_foreach_media_from_db() function. Define a callback (media_cb()) for the function to be triggered for each found item.

                                                -   media_group_foreach_media_from_db(name, group, NULL, media_cb, NULL);
                                                +    media_group_foreach_media_from_db(name, group, NULL, media_cb, NULL);
                                                 
                                                -   return true;
                                                +    return true;
                                                 }
                                                 
                                                -bool 
                                                +bool
                                                 media_cb(media_info_h media, void *user_data)
                                                 {
                                                -   media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE;
                                                -   char *name = NULL;
                                                +    media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE;
                                                +    char *name = NULL;
                                                 
                                                -   media_info_get_display_name(media, &name);
                                                -   if (name != NULL) 
                                                -   {
                                                -      dlog_print(DLOG_DEBUG, LOG_TAG, "Name: %s\n", name);
                                                -      free(name);
                                                -   }
                                                +    media_info_get_display_name(media, &name);
                                                +    if (name != NULL) {
                                                +        dlog_print(DLOG_DEBUG, LOG_TAG, "Name: %s\n", name);
                                                +        free(name);
                                                +    }
                                                 
                                                -   return true;
                                                +    return true;
                                                 }
                                                 
                                              diff --git a/org.tizen.tutorials/html/native/content/mime_type_tutorial_n.htm b/org.tizen.tutorials/html/native/content/mime_type_tutorial_n.htm index 6ff46f4..af3f1cf 100644 --- a/org.tizen.tutorials/html/native/content/mime_type_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/content/mime_type_tutorial_n.htm @@ -23,6 +23,7 @@

                                              Content

                                              @@ -45,25 +46,25 @@

                                              Warm-up

                                              Become familiar with the MIME Type API basics by learning about:

                                              + +

                                              Prerequisites

                                              + +

                                              To use the functions and data types of the MIME Type API (in mobile and wearable applications), include the <mime_type.h> header file in your application:

                                              +
                                              +#include <mime_type.h>
                                              +

                                              Getting the MIME Type for a File Extension

                                              To get the MIME types of all files in a directory when the extensions are known:

                                              -
                                                -
                                              1. To use the functions and data types of the MIME Type API (in mobile and wearable applications), include the <mime_type.h> header file in your application:

                                                -
                                                -#include <mime_type.h>
                                                -
                                                -
                                              2. - - -
                                              3. To get a MIME type:

                                                • For an individual file extension:

                                                  Use the mime_type_get_mime_type() function. The first parameter is the file extension without the leading dot and the second parameter is the MIME type for the given file extension.

                                                  @@ -87,49 +88,37 @@ struct dirent *pDirent = NULL; DIR *dir; char *res_path = app_get_resource_path(); if (!res_path) -   // Error handling +    /* Error handling */ dir = opendir(res_path); -if (dir) -{ -   while ((pDirent = readdir(dir)) != NULL) -   { -      if (pDirent->d_type != DT_REG) // Only regular files -         continue; +if (dir) { +    while ((pDirent = readdir(dir)) != NULL) { +        if (pDirent->d_type != DT_REG) /* Only regular files */ +            continue;
                                                • Get the extension from a file name using the strrchr() function available in the <string.h> header. Incrementing the pointer address is necessary, so use the extension without a dot:

                                                  -      char *extension = strrchr(pDirent->d_name, '.');
                                                  -      if (!extension)
                                                  -         continue;
                                                  -      extension++;
                                                  +        char *extension = strrchr(pDirent->d_name, '.');
                                                  +        if (!extension)
                                                  +            continue;
                                                  +        extension++;
                                                   
                                                • Use the mime_type_get_mime_type() function to get the MIME type of each file using the extension pointer as an extension:

                                                  -      mime_type_get_mime_type(extension, &mime_type);
                                                  -      // Here you have a MIME type in its variable
                                                  -      free(mime_type);
                                                  -   }
                                                  -   closedir(dir);
                                                  +        mime_type_get_mime_type(extension, &mime_type);
                                                  +        /* Here you have a MIME type in its variable */
                                                  +        free(mime_type);
                                                  +    }
                                                  +    closedir(dir);
                                                   }
                                                   
                                            5. - -

                                            Getting Extensions for a MIME Type

                                            -

                                            To get a list of extensions associated, for example, with an image or JPEG MIME type:

                                            - -
                                              -
                                            1. To use the functions and data types of the MIME Type API (in mobile and wearable applications), include the <mime_type.h> header file in your application:

                                              -
                                              -#include <mime_type.h>
                                              -
                                              -
                                            2. -
                                            3. Use the mime_type_get_file_extension() function. +

                                              To get a list of extensions associated, for example, with an image or JPEG MIME type, use the mime_type_get_file_extension() function.

                                              The function takes the MIME type as an input parameter, and fills the array of file extensions and the array length (marked as zero if empty) as the output parameters.

                                               char **extension;
                                              @@ -138,12 +127,12 @@ int error = mime_type_get_file_extension("image/jpeg", &extension,
                                               
                                               int i;
                                               for (i = 0; i < length; i++)
                                              -   // Use extension[i]
                                              +    /* Use extension[i] */
                                               
                                               for (i = 0; i < length; i++)
                                              -   free(extension[i]);
                                              +    free(extension[i]);
                                               free(extension);
                                              -
                                            + diff --git a/org.tizen.tutorials/html/native/context/activity_tutorial_n.htm b/org.tizen.tutorials/html/native/context/activity_tutorial_n.htm index 1bfc667..563d73b 100644 --- a/org.tizen.tutorials/html/native/context/activity_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/context/activity_tutorial_n.htm @@ -21,6 +21,7 @@

                                            Content

                                            Related Info

                                            @@ -42,19 +43,25 @@

                                            Warm-up

                                            Become familiar with the Activity Recognition API basics by learning about:

                                            + +

                                            Prerequisites

                                            + +

                                            To use the functions and data types of the Activity Recognition API (in mobile and wearable applications), include the <activity_recognition.h> header file in your application:

                                            +
                                            +#include <activity_recognition.h>
                                            +
                                            +

                                            Detecting Activities

                                            To set and unset callback functions for the activity monitor and retrieve details from the received activity data:

                                            -
                                            1. To use the functions and data types of the Activity Recognition API (in mobile and wearable applications), include the <activity_recognition.h> header file in your application:

                                              -
                                              -#include <activity_recognition.h>
                                              -
                                            2. - +
                                              1. Create a handle for activity monitoring using the activity_create() function:
                                                 activity_h handle;
                                                @@ -73,24 +80,25 @@ activity_start_recognition(handle, ACTIVITY_WALK, example_activity_callback, NUL
                                                 
                                                 
                                              2. When the registered callback is invoked, the current activity is delivered as a parameter, and you can extract the accuracy of the recognized activity:
                                                -void 
                                                -example_activity_callback(activity_type_e activity, const activity_data_h data, 
                                                +void
                                                +example_activity_callback(activity_type_e activity, const activity_data_h data,
                                                                           double timestamp, activity_error_e error, void *user_data)
                                                 {
                                                -   int result;
                                                +    int result;
                                                 
                                                -   activity_accuracy_e accuracy;
                                                -   result = activity_get_accuracy(data, &accuracy);
                                                +    activity_accuracy_e accuracy;
                                                +    result = activity_get_accuracy(data, &accuracy);
                                                 
                                                -   if (result != ACTIVITY_ERROR_NONE) 
                                                -   {
                                                -      // Error handling
                                                -   }
                                                -}
                                              3. +    if (result != ACTIVITY_ERROR_NONE) +        /* Error handling */ +} +
                                              4. When activity monitoring is no longer needed, unset the callback function and destroy the handle: -
                                                activity_stop_recognition(handle);
                                                -activity_release(handle);
                                              - +
                                              +activity_stop_recognition(handle);
                                              +activity_release(handle);
                                              +
                                            + diff --git a/org.tizen.tutorials/html/native/context/gesture_tutorial_n.htm b/org.tizen.tutorials/html/native/context/gesture_tutorial_n.htm index 71b73a0..83e370d 100644 --- a/org.tizen.tutorials/html/native/context/gesture_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/context/gesture_tutorial_n.htm @@ -21,6 +21,7 @@

                                            Content

                                            @@ -44,29 +45,37 @@

                                            Warm-up

                                            Become familiar with the Gesture Recognition API basics by learning about:

                                            -

                                            Detecting Gestures

                                            - -

                                            To set and unset callback functions for user gestures:

                                            +

                                            Prerequisites

                                            -
                                            1. To use the functions and data types of the Gesture Recognition API (in mobile and wearable applications), include the <gesture_recognition.h> header file in your application:

                                              +

                                              To use the functions and data types of the Gesture Recognition API (in mobile and wearable applications), include the <gesture_recognition.h> header file in your application:

                                               #include <gesture_recognition.h>
                                              -
                                            2. + + +

                                              Detecting Gestures

                                              + +

                                              To set and unset callback functions for user gestures:

                                              +
                                              1. Create a handle for gesture detection using the gesture_create() function:
                                                 gesture_h handle;
                                                -gesture_create(&handle);
                                              2. +gesture_create(&handle); +
                                              3. To subscribe to notifications about specific gesture events, invoke the gesture_start_recognition() function to register a callback function and start gesture detection.

                                                When the registered gesture is detected, the registered callback is invoked.

                                                -
                                                gesture_start_recognition(handle, GESTURE_PICK_UP, GESTURE_OPTION_DEFAULT, gesture_cb, NULL);
                                                +
                                                +gesture_start_recognition(handle, GESTURE_PICK_UP, GESTURE_OPTION_DEFAULT, gesture_cb, NULL);
                                                +

                                                The above example starts gesture detection to receive notifications when the GESTURE_PICK_UP gesture is detected. The application can use any of the gesture_type_e enumerators (in mobile and wearable applications) in place of the GESTURE_PICK_UP value. Note that not all gestures are supported by all devices. In such cases, the function returns the GESTURE_ERROR_NOT_SUPPORTED value.

                                                @@ -75,20 +84,17 @@ gesture_create(&handle);
                                              4. When the registered callback function is invoked, you can retrieve the event data using the gesture_get_event() function:

                                                -void 
                                                +void
                                                 gesture_cb(gesture_type_e gesture, const gesture_data_h data,
                                                            double timestamp, gesture_error_e error, void *user_data)
                                                -{			
                                                -   gesture_event_e event;
                                                -   if (gesture == GESTURE_PICK_UP) 
                                                -   {
                                                -      gesture_get_event(data, &event);
                                                -
                                                -      if (event == GESTURE_EVENT_DETECTED) 
                                                -      {
                                                -         // Handle the event
                                                -      }
                                                -   }
                                                +{
                                                +    gesture_event_e event;
                                                +    if (gesture == GESTURE_PICK_UP) {
                                                +        gesture_get_event(data, &event);
                                                +
                                                +        if (event == GESTURE_EVENT_DETECTED)
                                                +            /* Handle the event */
                                                +    }
                                                 }
                                                 
                                                @@ -97,17 +103,20 @@ gesture_cb(gesture_type_e gesture, const gesture_data_h data,

                                                In case of GESTURE_TILT, the gesture_get_tilt() function can be used to extract the tilting angles.

                                                -
                                                int x, y;
                                                -if (gesture == GESTURE_TILT) 
                                                -{
                                                -   gesture_get_tilt(data, &x, &y);
                                                -}
                                              5. +
                                                +int x;
                                                +int y;
                                                +if (gesture == GESTURE_TILT)
                                                +    gesture_get_tilt(data, &x, &y);
                                                +
                                              6. When gesture detection is no longer needed, unset the callback functions with the gesture_stop_recognition() function and destroy the handle with the gesture_release() function:

                                                -
                                                gesture_stop_recognition(handle);
                                                -gesture_release(handle);
                                              - +
                                              +gesture_stop_recognition(handle);
                                              +gesture_release(handle);
                                              +
                                            + diff --git a/org.tizen.tutorials/html/native/context/history_tutorial_n.htm b/org.tizen.tutorials/html/native/context/history_tutorial_n.htm index 7d2cdda..6e7e808 100644 --- a/org.tizen.tutorials/html/native/context/history_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/context/history_tutorial_n.htm @@ -21,6 +21,7 @@

                                            Content

                                            @@ -44,41 +45,45 @@

                                            Warm-up

                                            Become familiar with the Contextual History API basics by learning about:

                                            +

                                            Prerequisites

                                            +

                                            To use the functions and data types of the Contextual History API, include the <context_history.h> header file in your application:

                                            +
                                            +#include <context_history.h>
                                            +
                                            + +

                                            Getting a Profile Data List

                                            To retrieve a contextual history profile:

                                              -
                                            1. To use the functions and data types of the Contextual History API, include the <context_history.h> header file in your application: -
                                              -#include <context_history.h>
                                              -
                                              -
                                            2. Create 2 handles: 1 for using the Contextual History API and 1 for the filter:
                                              -// Contextual History API handle
                                              +/* Contextual History API handle */
                                               context_history_h handle;
                                               context_history_create(&handle);
                                               
                                              -// Filter handle
                                              +/* Filter handle */
                                               context_history_filter_h filter;
                                               context_history_filter_create(&filter);
                                               
                                            3. Get information about the 5 applications used most frequently during the last 2 weeks (14 days) while a headphone has been connected:
                                              -// Requesting the top 5 applications
                                              +/* Requesting the top 5 applications */
                                               context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, 5);
                                               
                                              -// Limiting the time span of usage logs to 14 days
                                              +/* Limiting the time span of usage logs to 14 days */
                                               context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_TIME_SPAN, 14);
                                               
                                              -// Limiting the context to the applications used while a headphone is connected
                                              +/* Limiting the context to the applications used while a headphone is connected */
                                               context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_AUDIO_JACK, CONTEXT_HISTORY_FILTER_AUDIO_JACK_CONNECTED);
                                               
                                            4. @@ -86,10 +91,10 @@ context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_AUDIO_JACK, CONTEX
                                               context_history_list_h list;
                                               
                                              -// Getting the list of records
                                              +/* Getting the list of records */
                                               context_history_get_list(handle, CONTEXT_HISTORY_FREQUENTLY_USED_APP, filter, &list);
                                               
                                              -// Release the filter after use
                                              +/* Release the filter after use */
                                               context_history_filter_destroy(filter);
                                               
                                              @@ -108,27 +113,27 @@ context_history_list_get_count(list, &size);
                                            5. Enumerate the list using a loop:
                                              -int i, count;
                                              +int i;
                                              +int count;
                                               char* app_id;
                                               context_history_record_h record;
                                               
                                              -for (i = 0; i < size; ++i)
                                              -{
                                              -   // Getting the current record
                                              -   context_history_list_get_current(list, &record);
                                              +for (i = 0; i < size; ++i) {
                                              +    /* Getting the current record */
                                              +    context_history_list_get_current(list, &record);
                                               
                                              -   // Retrieving the application ID and the total use count from the record
                                              -   context_history_record_get_string(record, CONTEXT_HISTORY_APP_ID, &app_id);
                                              -   context_history_record_get_int(record, CONTEXT_HISTORY_TOTAL_COUNT, &count);
                                              +    /* Retrieving the application ID and the total use count from the record */
                                              +    context_history_record_get_string(record, CONTEXT_HISTORY_APP_ID, &app_id);
                                              +    context_history_record_get_int(record, CONTEXT_HISTORY_TOTAL_COUNT, &count);
                                               
                                              -   // Freeing the application ID string
                                              -   free(app_id);
                                              +    /* Freeing the application ID string */
                                              +    free(app_id);
                                               
                                              -   // Releasing the memory occupied by the record
                                              -   context_history_record_destroy(record);
                                              +    /* Releasing the memory occupied by the record */
                                              +    context_history_record_destroy(record);
                                               
                                              -   // Iterating to the next record
                                              -   context_history_list_move_next(list);
                                              +    /* Iterating to the next record */
                                              +    context_history_list_move_next(list);
                                               }
                                               
                                            6. diff --git a/org.tizen.tutorials/html/native/context/trigger_tutorial_n.htm b/org.tizen.tutorials/html/native/context/trigger_tutorial_n.htm index 849e0ca..e34bf78 100644 --- a/org.tizen.tutorials/html/native/context/trigger_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/context/trigger_tutorial_n.htm @@ -21,6 +21,7 @@

                                              Content

                                                +
                                              • Prerequisites
                                              • Rule creation
                                                • Creating a Rule
                                                • @@ -52,6 +53,8 @@

                                                  Warm-up

                                                  Become familiar with the Contextual Trigger API basics by learning about:

                                                    +
                                                  • Prerequisites +

                                                    Prepare your application to use the contextual trigger functionality.

                                                  • Rule creation + +

                                                    Prerequisites

                                                    -

                                                    Creating a Rule

                                                    - -

                                                    To compose a rule:

                                                    -
                                                      -
                                                    1. To use the functions and data types of the Contextual Trigger API, include the <context_trigger.h> header file in your application:

                                                       #include <context_trigger.h>
                                                       
                                                      -
                                                    2. + +

                                                      Creating a Rule

                                                      + +

                                                      To compose a rule:

                                                      +
                                                      1. Create a rule for "Notify if the battery is not charging and either Wi-Fi or GPS is enabled when the battery level becomes too low".

                                                        Create a rule handle using the context_trigger_rule_create() function. Because both Wi-Fi and GPS conditions need not be met at the same time, the rule must be created with the CONTEXT_TRIGGER_LOGICAL_DISJUNCTION operator.

                                                        @@ -83,7 +87,7 @@ context_trigger_rule_create(CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, &rule);
                                                         
                                                      2. Set an optional description:
                                                        -context_trigger_rule_set_description(rule, "Notify if the battery is not charging and either Wi-Fi or GPS is enabled when the battery level becomes too low");
                                                        +context_trigger_rule_set_description(rule, "Notify if the battery is not charging and either Wi-Fi or GPS is enabled when the battery level becomes too low");
                                                         
                                                      @@ -103,27 +107,27 @@ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_BATTERY, CONTEXT_TRIGGER
                                                    3. Add the attribute key with the context_trigger_rule_entry_add_key() function.

                                                      The attribute key specifies the detailed comparison terms for the event.

                                                      -// Add a CONTEXT_TRIGGER_LEVEL key
                                                      +/* Add a CONTEXT_TRIGGER_LEVEL key */
                                                       context_trigger_rule_entry_add_key(battery_event, CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, CONTEXT_TRIGGER_LEVEL);
                                                       
                                                      -// Add a CONTEXT_TRIGGER_IS_CHARGING key
                                                      +/* Add a CONTEXT_TRIGGER_IS_CHARGING key */
                                                       context_trigger_rule_entry_add_key(battery_event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CHARGING);
                                                       

                                                      The application wants to check whether the battery level becomes either low, empty, or critical. For this reason, the CONTEXT_TRIGGER_LEVEL key must be added with the CONTEXT_TRIGGER_LOGICAL_DISJUNCTION logical operator.

                                                    4. -
                                                    5. Add the comparison operators and values for the attribute key. +
                                                    6. Add the comparison operators and values for the attribute key.

                                                      Use the context_trigger_rule_entry_add_comparison_int() or context_trigger_rule_entry_add_comparison_string() function, depending on the data type.

                                                      -// Add the comparison values for the CONTEXT_TRIGGER_LEVEL key
                                                      +/* Add the comparison values for the CONTEXT_TRIGGER_LEVEL key */
                                                       context_trigger_rule_entry_add_comparison_string(battery_event, CONTEXT_TRIGGER_LEVEL, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_LOW);
                                                       context_trigger_rule_entry_add_comparison_string(battery_event, CONTEXT_TRIGGER_LEVEL, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_CRITICAL);
                                                       context_trigger_rule_entry_add_comparison_string(battery_event, CONTEXT_TRIGGER_LEVEL, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_EMPTY);
                                                       
                                                      -// Add a comparison value for the CONTEXT_TRIGGER_IS_CHARGING key
                                                      +/* Add a comparison value for the CONTEXT_TRIGGER_IS_CHARGING key */
                                                       context_trigger_rule_entry_add_comparison_int(battery_event, CONTEXT_TRIGGER_IS_CHARGING, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_FALSE);
                                                       
                                                    7. -
                                                    8. Add the event entry to the rule: +
                                                    9. Add the event entry to the rule:
                                                       context_trigger_rule_add_entry(rule, battery_event);
                                                       
                                                      @@ -143,11 +147,11 @@ context_trigger_rule_entry_destroy(battery_event);
                                                    10. Create an event handle using the context_trigger_rule_condition_create() function:

                                                      -// Create a Wi-Fi condition
                                                      +/* Create a Wi-Fi condition */
                                                       context_trigger_rule_entry_h wifi_condition = NULL;
                                                       context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_WIFI, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &wifi_condition);
                                                       
                                                      -// Create a GPS condition
                                                      +/* Create a GPS condition */
                                                       context_trigger_rule_entry_h gps_condition = NULL;
                                                       context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_GPS, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &gps_condition);
                                                       
                                                      @@ -191,7 +195,7 @@ context_trigger_rule_entry_destroy(gps_condition);

                                                      To set an application launch request:

                                                       app_control_h app;
                                                      -// Create an app control handle and set the details, such as application ID and operation
                                                      +/* Create an app control handle and set the details, such as application ID and operation */
                                                       
                                                       context_trigger_rule_set_action_app_control(rule, app);
                                                       
                                                      @@ -199,8 +203,8 @@ context_trigger_rule_set_action_app_control(rule, app);
                                                    11. To register a notification posting request:
                                                      -context_trigger_rule_set_action_notification(rule, "Battery Alert", 
                                                      -                                             "Battery is getting low. To save your battery, turn off Wi-Fi or GPS", 
                                                      +context_trigger_rule_set_action_notification(rule, "Battery Alert",
                                                      +                                             "Battery is getting low. To save your battery, turn off Wi-Fi or GPS",
                                                                                                    NULL, NULL);
                                                       

                                                      The Contextual Trigger API supports the basic notification type only.

                                                      @@ -269,12 +273,10 @@ int enabled_count; context_trigger_get_own_rule_ids(&enabled_rule_ids, &enabled_count, NULL, NULL); -// Disable the enabled rules +/* Disable the enabled rules */ int i = 0; -for (i = 0; i < enabled_count; i++) -{ -   context_trigger_disable_rule(enabled_rule_ids[i]); -} +for (i = 0; i < enabled_count; i++) +    context_trigger_disable_rule(enabled_rule_ids[i]);
                                                    12. Retrieve all the disabled rules owned by the application and remove them: @@ -284,25 +286,21 @@ int disabled_count; context_trigger_get_own_rule_ids(NULL, NULL, &disabled_rule_ids, &disabled_count); -// Remove the disabled rules -for (i = 0; i < disabled_count; i++) -{ -   context_trigger_remove_rule(disabled_rule_ids[i]); -} +/* Remove the disabled rules */ +for (i = 0; i < disabled_count; i++) +    context_trigger_remove_rule(disabled_rule_ids[i]);
                                                    13. Free the memory allocated for the enabled and disabled rules:
                                                      -if (enabled_rule_ids) 
                                                      -{
                                                      -   free(enabled_rule_ids);
                                                      -   enabled_rule_ids = NULL;
                                                      +if (enabled_rule_ids) {
                                                      +    free(enabled_rule_ids);
                                                      +    enabled_rule_ids = NULL;
                                                       }
                                                       
                                                      -if (disabled_rule_ids) 
                                                      -{
                                                      -   free(disabled_rule_ids);
                                                      -   disabled_rule_ids = NULL;
                                                      +if (disabled_rule_ids) {
                                                      +    free(disabled_rule_ids);
                                                      +    disabled_rule_ids = NULL;
                                                       }
                                                       
                                                    14. diff --git a/org.tizen.tutorials/html/native/graphics/cairo_tutorial_n.htm b/org.tizen.tutorials/html/native/graphics/cairo_tutorial_n.htm index bc49b94..7e9b3e1 100644 --- a/org.tizen.tutorials/html/native/graphics/cairo_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/graphics/cairo_tutorial_n.htm @@ -11,7 +11,7 @@ - Cairo: Linking Cairo and Evas + Cairo: Drawing 2D Graphics @@ -23,13 +23,19 @@
                                                      -

                                                      Cairo: Linking Cairo and Evas

                                                      +

                                                      Cairo: Drawing 2D Graphics

                                                      + +

                                                      Cairo is a powerful open source 2D graphics library. You can use it in Tizen to draw 2D graphics.

                                                      +

                                                      This tutorial demonstrates how you can create 2D graphics using Cairo with image and GL backends, and draw lines, paint an image, and show text in your application.

                                                      -

                                                      This tutorial demonstrates how you can use 2 different backends of Cairo and link to Evas.

                                                      -

                                                      Warm-up

                                                      Become familiar with the Cairo API basics by learning about:

                                                      -

                                                      Drawing a Polygon Using a Cairo Image

                                                      - -

                                                      This use case shows how to link Cairo to Evas and how to draw a polygon and rectangle on the screen using the Cairo API. First create a basic application that provides a basic UI application skeleton and already makes available the window object that can contain the Cairo drawing.

                                                      -

                                                      To draw a polygon:

                                                      -
                                                      1. -Build the environment. - -

                                                        Include the <cairo.h> and <math.h> header files in the sample application:

                                                        +

                                                        Prerequisites

                                                        +

                                                        To enable your application to use the Cairo functionality:

                                                        +
                                                          +
                                                        1. Before using the Cairo library in Tizen: +
                                                            +
                                                          • You must understand the basic concepts of Cairo. For more information, see the Cairo Tutorial in cairographics.org.
                                                          • +
                                                          • In the Tizen framework, Cairo can use 2 different backends: image backend and Evas GL backend. You must check which backend is suitable for your work. For more information, see the Cairo guide.
                                                          • +
                                                          • In creating native UI applications in Tizen, make sure you understand EFL and its features.
                                                          • +
                                                          +
                                                        2. +
                                                        3. To use the functions and data types of the Cairo image and GL backends, include the <cairo.h> header file in your application. For the Cairo GL backend, you also need the <cairo-evas-gl.h>, and <Evas_GL.h> header files.
                                                           #include <cairo.h>
                                                          -#include <math.h>
                                                          -
                                                        4. -
                                                        5. Create the Evas_Object image and link to Cairo. - -

                                                          Define the appdata structure that contains the pointers to the objects to be manipulated:

                                                          -
                                                          -typedef struct 
                                                          -appdata 
                                                          -{
                                                          -   Evas_Object *win;	
                                                          -   Evas_Object *img;
                                                          -
                                                          -   cairo_surface_t *surface;
                                                          -   cairo_t *cairo;
                                                          -} appdata_s;
                                                          -
                                                        6. -
                                                        7. Create the Evas_Object window and image. - -

                                                          To display the Cairo drawing on the screen, create the Evas_Object window and Evas_Object image:

                                                          -
                                                          -ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
                                                          -evas_object_show(ad->win);
                                                          -ad->img = evas_object_image_filled_add(evas_object_evas_get(ad->win));
                                                          -evas_object_show(ad->img);
                                                          -
                                                        8. - -
                                                        9. Create Cairo. -

                                                          To create the Cairo surface, you need the window size to set the Cairo surface. You can get the window size using the evas_object_geometry_get() function, after the evas_object_show() function is called:

                                                          -
                                                          -evas_object_geometry_get(ad->win, NULL, NULL, &ad->width, &ad->height);
                                                          -ad->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ad->width, ad->height);
                                                          -ad->cairo = cairo_create(ad->surface);
                                                          -
                                                        10. +/* For the Cairo GL backend */ +#include <cairo-evas-gl.h> +#include <Evas_GL.h> + + +
                                                        -
                                                      2. Draw a polygon and rectangle with Cairo. -

                                                        To draw the vector image itself:

                                                        +

                                                        Creating Cairo with the Image Backend

                                                        -
                                                          -
                                                        1. To draw Cairo with some specific vector positions, use the window size that you retrieved before. You can compare the window width and height and get the smaller length to set the square side. -
                                                          -void 
                                                          -cairo_drawing(void *data)
                                                          -{
                                                          -   appdata_s *ad = data;
                                                          -   int d = 0;
                                                          -   if (ad->width < ad->height)
                                                          -      d = ad->width;
                                                          -   else
                                                          -      d = ad->height;
                                                          -
                                                        2. - -
                                                        3. To set the background as white, set the color as white and paint the Cairo: +

                                                          To create a Cairo context and surface with the image backend:

                                                          +
                                                            +
                                                          1. Create the window and the Evas_Object image. +

                                                            Place an Evas_Object image into your application's main window. For more information about creating and placing an Evas_Object image, see Basic Manipulation of Evas Objects and the Graphic UI Component tutorial.

                                                            -   // Clear background as white
                                                            -   cairo_set_source_rgba(ad->cairo, 1, 1, 1, 1);
                                                            -   cairo_paint(ad->cairo);
                                                            -
                                                          2. - -
                                                          3. Draw the polygon and rectangle: +Evas_Object *img = evas_object_image_filled_add(evas_object_evas_get(win)); +elm_win_resize_object_add(win, img); +evas_object_image_content_hint_set(img, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); +evas_object_image_size_set(img, WIDTH, HEIGHT); +evas_object_resize(img, WIDTH, HEIGHT); +evas_object_show(img); + +
                                                          4. +
                                                          5. Create the Cairo context and surface. +

                                                            To use the Cairo API, create the Cairo context and surface using the Evas_Object image. The Evas_Object image is used in the example code as a rendering destination.

                                                            -   cairo_translate(ad->cairo, 0.1 * d, 0.1 * d);
                                                            -   cairo_set_line_width(ad->cairo, 2);
                                                            -   cairo_set_source_rgba(ad->cairo, 0.0, 0.0, 1.0, 1.0);
                                                            -
                                                            -   cairo_move_to(ad->cairo, 0.2 * d , 0.2 * d);
                                                            -   cairo_line_to(ad->cairo, 0.4 * d, 0.3 * d);
                                                            -   cairo_rel_line_to(ad->cairo, 0.2 * d, -0.1 * d);
                                                            -   cairo_arc(ad->cairo, 0.4 * d, 0.4 * d, 0.2* d * sqrt(2), -0.25 * M_PI, 0.25 * M_PI);
                                                            -   cairo_rel_curve_to(ad->cairo, -0.2* d, -0.1 * d, -0.2* d, 0.1 * d, -0.4 * d, 0);
                                                            -   cairo_close_path(ad->cairo);
                                                            -   cairo_fill(ad->cairo);
                                                            -
                                                            -   cairo_rectangle(ad->cairo, 0, 0, 0.8 * d, 0.8 * d);
                                                            -   cairo_stroke(ad->cairo);
                                                            -
                                                          6. - +int row_stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, WIDTH); +unsigned char *imageData = (unsigned char*)evas_object_image_data_get(img, EINA_TRUE); +cairo_surface = cairo_image_surface_create_for_data(imageData, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, row_stride); +cairo = cairo_create(cairo_surface); + + +
                                                          -
                                                        4. You need to use the cairo_surface_flush() function to ensure that any pending drawing is performed for the surface: -
                                                          -   cairo_surface_flush(ad->surface);
                                                          -
                                                        5. +

                                                          Creating Cairo with the GL Backend

                                                          -
                                                        6. Update the Evas_Object image on the screen: +

                                                          For the Cairo GL backend in Tizen, you must know OpenGL. For more information, see the OpenGL ES guide.

                                                          +

                                                          To create Cairo with the GL backend:

                                                          +
                                                            +
                                                          1. Create the window, Evas_Object image, and Evas GL. +

                                                            Place an Evas_Object image in the application's main window, and create and initialize Evas GL. Call the evas_object_image_pixels_get_callback_set() function to initialize the Evas GL handle. The cairo_drawing() function must be set as the input parameter. For more information about creating and initializing Evas GL, see Creating the Elm Window and EvasGL.

                                                            -   // Display Cairo drawing on screen
                                                            -   unsigned char * imageData = cairo_image_surface_get_data(cairo_get_target(ad->cairo));
                                                            -   evas_object_image_data_set(ad->img, imageData);
                                                            -   evas_object_image_data_update_add(ad->img, 0, 0, ad->width, ad->height);
                                                            -}
                                                            -
                                                          2. - -
                                                          3. The delete callback is triggered when the window is destroyed from the main loop. +Evas_Object *img = evas_object_image_filled_add(evas_object_evas_get(win)); + +Evas_Native_Surface ns; +Evas_GL *evas_gl = evas_gl_new(evas_object_evas_get(img)); +Evas_GL_Config *evas_gl_config = evas_gl_config_new(); +evas_gl_config->color_format = EVAS_GL_RGBA_8888; + +evas_gl_surface = evas_gl_surface_create(evas_gl, evas_gl_config, WIDTH, HEIGHT); +evas_gl_context = evas_gl_context_create(evas_gl, NULL); +evas_gl_native_surface_get(evas_gl, evas_gl_surface, &ns); +evas_object_image_native_surface_set(img, &ns); +evas_object_image_pixels_get_callback_set(img, cairo_drawing, 0); + +
                                                          4. +
                                                          5. Create the Cairo context and surface. +

                                                            Use the Evas_Object image and Evas GL context to create the Cairo context and surface. Cairo can be used in a multi-threaded environment. By default, Cairo switches out the current GL context after each draw finishes. If no other thread uses Cairo for rendering, Cairo can use the non-thread-aware mode with the cairo_gl_device_set_thread_aware() function's second parameter set to 0.

                                                            -static void 
                                                            -win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
                                                            -{
                                                            -   appdata_s *ad = data;
                                                            -   cairo_surface_destroy(ad->surface);
                                                            -   cairo_destroy(ad->cairo);
                                                            -   ui_app_exit();
                                                            -}
                                                            -
                                                          6. -
                                                        - -

                                                        Figure: Polygon and rectangle

                                                        -

                                                        Polygon and rectangle

                                                        - - - -

                                                        Displaying Animated Geometrical Figures Using Cairo Evas_GL

                                                        - -

                                                        The following use case shows how you can draw vector graphics using the Cairo evas-gl backend. The Cairo evas-gl backend is similar to Cairo gl backend, since it can provide an implementation of possibly hardware-accelerated Cairo rendering by targeting the OpenGL® ES API.

                                                        -

                                                        First create a basic application that provides a basic UI application skeleton and already makes available the window object that can contain the Cairo drawing.

                                                        - -

                                                        To display and animate vector graphics with Cairo and the Evas_GL surface:

                                                        +setenv("CAIRO_GL_COMPOSITOR", "msaa", 1); +cairo_device = (cairo_device_t*)cairo_evas_gl_device_create(evas_gl, evas_gl_context); +cairo_gl_device_set_thread_aware(cairo_device, 0); +cairo_surface = (cairo_surface_t*)cairo_gl_surface_create_for_evas_gl(cairo_device, evas_gl_surface, evas_gl_config, WIDTH, HEIGHT); +cairo = cairo_create(cairo_surface); + +
                                                      3. +
                                                      +

                                                      Drawing Lines

                                                      +

                                                      When drawing an image with Cairo, you must prepare the context (nouns) for each of the drawing verbs. For example, if you want to use the cairo_stroke() or cairo_fill() function, create a path first. Similarly, in case of using the cairo_show_text() function, you must position your text by its insertion point. A primary source is needed for using the cairo_paint() function and a second source pattern or surface is prepared for using the cairo_mask() function. For more information, see the Cairo Tutorial in cairographics.org.

                                                      +

                                                      The following figure shows an example of lines drawn using Cairo.

                                                      +

                                                      Figure: Lines drawn using Cairo

                                                      +

                                                      Lines drawn using Cairo

                                                      -
                                                      1. Build the environment: +

                                                        To draw lines:

                                                        +
                                                          +
                                                        1. Prepare the sources. +

                                                          Prior to drawing a line, prepare and select sources. There are 3 main sources in Cairo - colors, gradients, and images:

                                                            -
                                                          • Include the following header files to use the Cairo evas-gl backend on the Evas_GL surface: +
                                                          • Colors use a uniform hue and opacity for the entire source. You can select these without any preparation with the cairo_set_source_rgb() function and cairo_set_source_rgba() functions.
                                                            -#include <cairo.h>
                                                            -#include <Evas_GL.h>
                                                            -#include <cairo-evas-gl.h>
                                                            -#include <math.h>
                                                            -
                                                          • - -
                                                          • Define the appdata structure that contains the pointers to objects to be manipulated: +cairo_set_source_rgba(cairo, 1.0, 0.0, 0.0, 1.0); + +
                                                          • +
                                                          • Gradients describe a progression of colors by setting a start and stop reference location and a series of "stops" along the way. There are linear and radial gradients built from 2 points. Stops are added to the gradient with the cairo_add_color_stop_rgb() and cairo_add_color_stop_rgba() functions which take a color like the cairo_add_color_stop_rgb() or cairo_add_color_stop_rgba() function, as well as an offset to indicate where it lies between the reference locations.
                                                          • +
                                                          • Images include both surfaces loaded from the existing files with the cairo_image_surface_create_from_png() function and surfaces created from within Cairo as an earlier destination. For more information about these Cairo APIs, see the cairo_pattern_t in cairographics.org.
                                                          • +
                                                          +
                                                        2. +
                                                        3. Set the starting point. +

                                                          Cairo uses a connect-the-dots style system for creating paths. To draw a line from a starting point to an ending point, set the starting point of the line with the cairo_move_to() function. This sets the current reference point without making the path connect the previous point to it.

                                                          -typedef struct 
                                                          -appdata 
                                                          -{
                                                          -   Evas_Object *win;	
                                                          -   Evas_Object *img;
                                                          -
                                                          -   cairo_surface_t *surface;
                                                          -   cairo_t *cairo;
                                                          -   cairo_device_t *cairo_device;
                                                          -	
                                                          -   Evas_GL *evas_gl;
                                                          -   Evas_GL_Config *evas_gl_config;
                                                          -   Evas_GL_Surface *evas_gl_surface;
                                                          -   Evas_GL_Context *evas_gl_context;
                                                          -} appdata_s;
                                                          -
                                                  - -
                                                • Initialize Cairo and Evas_GL for Cairo evas-gl drawing. - -

                                                  Initialize the variables related to the Evas_GL within the appdata structure, and create the Evas_GL object using the Evas_Object image created before.

                                                  - +cairo_move_to(cairo, 100, 100); + +
                                                • +
                                                • Draw the shapes.
                                                    -
                                                  • By default, Cairo evas-gl backend uses an Evas_GL context and API set. Before creating the Evas_Object window for Cairo evas-gl drawing, the GL Rendering Engine is set because Evas_GL runs with the Evas_GL Render Engine: +
                                                  • Draw a straight line. +

                                                    After setting a starting point as (100, 100), you can draw a straight line to an ending point using the cairo_line_to() or cairo_rel_line_to() function. With these functions, the ending point is set as absolute coordinates and relative coordinates respectively, Here, (200, 150) is the absolute coordinates and (100, -50) is the relative coordinates.

                                                    -elm_config_accel_preference_set("opengl");
                                                    -
                                                  • - -
                                                  • The cairo_drawing callback function can be registered by the following Evas_Object image function: +cairo_line_to(cairo, 200, 150); +cairo_rel_line_to(cairo, 100, -50); + +
                                                  • +
                                                  • Draw an arc. +

                                                    Arcs are parts of the outside of a circle. The point you directly specify is the center of the circle that makes up the addition to the path. Both a starting and an ending point on the circle must be specified, and these points are connected either clockwise using the cairo_arc() or counter-clockwise using the cairo_arc_negative() function.

                                                    -evas_object_image_pixels_get_callback_set(ad->img, cairo_drawing, NULL);
                                                    -
                                                  • - -
                                                  • To use fast and optimized Cairo GLES rendering, set Cairo_GL_Compositor and Evasgl configurations: +cairo_arc(cairo, 200, 200, 100 * sqrt(2), -0.25 * M_PI, 0.25 * M_PI); + +
                                                  • +
                                                  • Draw a curve. +

                                                    Curves in Cairo are cubic Bézier splines. They start at the current reference point and smoothly follow the direction of 2 other points (without going through them) to get to a third specified point. Like lines, there are both absolute (cairo_curve_to()) and relative (cairo_rel_curve_to()) functions. Note that the relative variant specifies all points relative to the previous reference point, rather than each relative to the preceding control point of the curve.

                                                    -setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
                                                    -ad->evas_gl_config->stencil_bits = EVAS_GL_STANCIL_BIT_8;
                                                    -ad->evas_gl_config->multisample_bits = EVAS_GL_MULTISAMPLE_MED;
                                                    -
                                                  • - -
                                                  • To prevent unnecessary context switching in the Cairo evas-gl backend: +cairo_rel_curve_to(cairo, -100, -50, -100, 50, -200, 0); + +
                                                  • +
                                                  • Close the path. +

                                                    Cairo can also close the path by drawing a straight line to the beginning of the current sub-path. This straight line can be useful for the last edge of a polygon.

                                                    -cairo_gl_device_set_thread_aware(ad->cairo_device, 0);
                                                    -
                                                  +cairo_close_path(cairo); + +
                                                • +
                                                +
                                              • +
                                            + +

                                            Painting with Image Files

                                            +

                                            With images, Cairo supports the functionality only for the PNG format. These functions for PNG are experimental, so use them with care. For more information about PNG support, see PNG Support in cairographics.org.

                                            + +

                                            The following figure shows an example of painting with an image file.

                                            +

                                            Figure: Painting with image file

                                            +

                                            Lines drawn using Cairo

                                            + +

                                            To paint with image files:

                                            +
                                              +
                                            1. Get the image resource. +

                                              The following code snippet shows how to prepare image data for your application. To get an application's resource image data, use the app_get_resource_path() function. This gets a stored PNG image file path to use as a resource. For more information about the app_get_resource_path() function, see the App Common API (in mobile and wearable applications.

                                              -static void 
                                              -init_cairo_evasgl_drawing(appdata_s *ad)
                                              -{
                                              -   // Create window
                                              -   elm_config_accel_preference_set("opengl");
                                              -   ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
                                              -   elm_win_autodel_set(ad->win, EINA_TRUE);
                                              -   if (elm_win_wm_rotation_supported_get(ad->win))
                                              -   {
                                              -      int rots[4] = {0, 90, 180, 270};
                                              -      elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
                                              -   }
                                              -   evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
                                              -   eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
                                              -   evas_object_event_callback_add(ad->win, EVAS_CALLBACK_RESIZE, win_resize_cb, ad);
                                              -   evas_object_show(ad->win);
                                              -
                                              -   // Add image object; a filled one by default
                                              -   evas_object_geometry_get(ad->win, NULL, NULL, &ad->width, &ad->height);
                                              -   ad->img = evas_object_image_filled_add(evas_object_evas_get(ad->win));
                                              -   evas_object_show(ad->img);
                                              -
                                              -   // Create evasgl and init
                                              -   Evas_Native_Surface ns;
                                              -   ad->evas_gl = evas_gl_new(evas_object_evas_get(ad->img));
                                              -   ad->evas_gl_config = evas_gl_config_new();
                                              -   ad->evas_gl_config->color_format = EVAS_GL_RGBA_8888;
                                              -   ad->evas_gl_config->stencil_bits = EVAS_GL_STANCIL_BIT_8;
                                              -   ad->evas_gl_config->multisample_bits = EVAS_GL_MULTISAMPLE_MED;
                                              -
                                              -   // Create a surface and context
                                              -   ad->evas_gl_surface = evas_gl_surface_create(ad->evas_gl, ad->evas_gl_config, ad->width, ad->height);
                                              -   ad->evas_gl_context = evas_gl_context_create(ad->evas_gl, NULL);
                                              -      
                                              -   evas_gl_native_surface_get(ad->evas_gl, ad->evas_gl_surface, &ns);
                                              -   evas_object_image_native_surface_set(ad->img, &ns);
                                              -
                                              -   // Register Cairo drawing callback
                                              -   evas_object_image_pixels_get_callback_set(ad->img, (Evas_Object_Image_Pixels_Get_Cb)cairo_drawing, ad);
                                              -
                                              -   // Create cairo and cairo device with evasgl
                                              -   // Use the MSAA compositor if available
                                              -   setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
                                              -   ad->cairo_device = (cairo_device_t *)cairo_evas_gl_device_create (ad->evas_gl, ad->evas_gl_context);
                                              -   cairo_gl_device_set_thread_aware(ad->cairo_device, 0);
                                              -   ad->surface = (cairo_surface_t *)cairo_gl_surface_create_for_evas_gl(ad->cairo_device, ad->evas_gl_surface, 
                                              -                                                                        ad->evas_gl_config, ad->width, ad->height);
                                              -   ad->cairo = cairo_create(ad->surface);
                                              -
                                              -   // Register animation callback to update the output according to refresh rate
                                              -   ecore_animator_frametime_set(0.016);
                                              -   ecore_animator_add(_animate_cb, (void *)ad->img);
                                              -}
                                              +char image_filepath[256];
                                              +char *source_filename = "image.png";
                                              +char *resource_path = app_get_resource_path();
                                              +snprintf(image_filepath, 256, "%s/%s", resource_path, source_filename);
                                              +free(resource_path);
                                               
                                            2. - -
                                            3. Draw geometrical figures in the cairo_drawing() callback function. -

                                              The following code snippet shows how to draw some geometrical figures, such as a triangle, rectangle, and circle, with various styles and random positions by using the Cairo APIs.

                                              +
                                            4. Create the source surface. +

                                              To paint using the image data from the PNG file, first create a source surface. The image data is a source surface to paint on the destination surface.

                                              -void 
                                              -cairo_drawing(void *data)
                                              -{
                                              -   appdata_s *ad = data;
                                              -
                                              -   int i;
                                              -   double r, g, b, a;
                                              -
                                              -   int Renderloop = 50;
                                              -
                                              -   // Clear background as white
                                              -   cairo_set_source_rgba(ad->cairo, 1, 1, 1, 1);
                                              -   cairo_paint(ad->cairo);
                                              -
                                              -   cairo_set_operator(ad->cairo, CAIRO_OPERATOR_OVER);
                                              -
                                              -   for (i = 0; i < Renderloop; i++) 
                                              -   {
                                              -      // Random color
                                              -      r = drand48();
                                              -      g = drand48();
                                              -      b = drand48();
                                              -      a = drand48();
                                              -      cairo_set_source_rgba(ad->cairo, r, g, b, a);
                                              -
                                              -      // Random position
                                              -      float x = drand48() * ad->width;
                                              -      float y = drand48() * ad->height;
                                              -      float side = drand48() * 300;
                                              -
                                              -      // Random style
                                              -      int shape = drand48() * 3;
                                              -      float width = drand48() * 50 + 1;
                                              -      int line_cap = drand48() * 3;
                                              -
                                              -      cairo_line_cap_t line_cap_style = CAIRO_LINE_CAP_BUTT;
                                              -      if (line_cap == 1)
                                              -         line_cap_style = CAIRO_LINE_CAP_ROUND;
                                              -      else if (line_cap == 2)
                                              -         line_cap_style = CAIRO_LINE_CAP_SQUARE;
                                              -
                                              -      int line_join = drand48() * 3;
                                              -      cairo_line_join_t line_join_style = CAIRO_LINE_JOIN_MITER;
                                              -      if (line_join == 1)
                                              -         line_join_style = CAIRO_LINE_JOIN_ROUND;
                                              -      else if (line_join == 2)
                                              -         line_join_style = CAIRO_LINE_JOIN_BEVEL;
                                              -
                                              -      double dash[] = {0.0, 0.0};
                                              -      dash[0] = drand48() * 50;
                                              -      dash[1] = drand48() * 50;
                                              -
                                              -      cairo_set_dash(ad->cairo, dash, 2, 0);
                                              -      cairo_set_line_width(ad->cairo, width);
                                              -      cairo_set_line_join(ad->cairo, line_join_style);
                                              -      cairo_set_line_cap(ad->cairo, line_cap_style);
                                              -
                                              -      if (shape == 0) 
                                              -      {
                                              -         // Draw square
                                              -         cairo_rectangle(ad->cairo, x, y, side, side);
                                              -         cairo_fill(ad->cairo);
                                              -      }
                                              -      else if (shape == 1) 
                                              -      {
                                              -         // Draw circle
                                              -         cairo_arc(ad->cairo, x, y, side/2, 0.0, 2.0 * M_PI);
                                              -         cairo_stroke(ad->cairo);
                                              -      }
                                              -      else 
                                              -      {
                                              -         // Draw triangle
                                              -         cairo_move_to(ad->cairo, x, y);
                                              -         cairo_line_to(ad->cairo, x + side, y);
                                              -         cairo_line_to(ad->cairo, x, y + side);
                                              -         cairo_close_path(ad->cairo);
                                              -         cairo_stroke(ad->cairo);
                                              -      }
                                              -   }
                                              -
                                              -   cairo_surface_flush(ad->surface);
                                              -}
                                              -
                                            5. - -
                                            6. Define the callback for resizing. -

                                              In the following code snippet, when resizing occurs, Evas_GL surface is recreated and reconnected to the Evas_Object image.

                                              +cairo_surface_t *image = cairo_image_surface_create_from_png(image_filepath); +cairo_set_source_surface(cairo, image, 0, 0); + +
                                            7. +
                                            8. Paint the Cairo surface. +

                                              The cairo_paint() function uses a mask that transfers the entire source to the destination. It can be considered an infinitely large mask, or no mask, but the result is the same. To set a compositing operator, use the cairo_set_operator() and paint a Cairo surface using the source pattern obtained before. For more information about the cairo_set_operator() function, see operators in cairographics.org.

                                              -static void 
                                              -win_resize_cb(void *data, Evas *e , Evas_Object *obj , void *event_info)
                                              -{
                                              -   appdata_s *ad = data;
                                              -
                                              -   if (ad->evas_gl_surface)  
                                              -   {
                                              -      cairo_surface_destroy(ad->surface);
                                              -      cairo_destroy(ad->cairo);
                                              -      cairo_device_destroy(ad->cairo_device);
                                              -      evas_gl_surface_destroy(ad->evas_gl, ad->evas_gl_surface);
                                              -      ad->evas_gl_surface = NULL;
                                              -   }
                                              -
                                              -   evas_object_geometry_get(obj, NULL, NULL, &ad->width, &ad->height);
                                              -   evas_object_image_size_set(ad->img, &ad->width, &ad->height);
                                              -   evas_object_resize(ad->img, &ad->width, &ad->height);
                                              -   evas_object_show(ad->img);
                                              -
                                              -
                                              -   if (!ad->evas_gl_surface) 
                                              -   {
                                              -      Evas_Native_Surface ns;
                                              -
                                              -      ad->evas_gl_surface = evas_gl_surface_create(ad->evasgl, ad->evas_gl_config, &ad->width, &ad->height);
                                              -      evas_gl_native_surface_get(ad->evasgl, ad->evas_gl_surface, &ns);
                                              -      evas_object_image_native_surface_set(ad->img, &ns);
                                              -      evas_object_image_pixels_dirty_set(ad->img, EINA_TRUE);
                                              -
                                              -      ad->cairo_device = (cairo_device_t *)cairo_evas_gl_device_create(ad->evas_gl, ad->evas_gl_context);
                                              -      cairo_gl_device_set_thread_aware(ad->cairo_device, 0);
                                              -      ad->surface = (cairo_surface_t *)cairo_gl_surface_create_for_evas_gl(ad->cairo_device, ad->evas_gl_surface, 
                                              -                                                                           ad->evas_gl_config, ad->width, ad->height);
                                              -      ad->cairo = cairo_create(ad->surface);
                                              -   }
                                              -}
                                              +cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
                                              +cairo_paint(cairo);
                                               
                                            9. +
                                            + +

                                            Showing Text

                                            + +

                                            In Cairo, the cairo_font_face_t class represents a particular font at a particular weight, slant, and other characteristics. For more information for using the cairo font, see cairo_font_face_t of cairographics.org.

                                            -
                                          24. To use the animator callback for a default update refresh rate, you can add an animator. -

                                            To update the Evas_Object image which is connected to Evas_GL, use the evas_object_image_pixels_dirty_set() function. This updates the Evas_Object image whenever Evas renders.

                                            +

                                            The following figure shows an example of text shown using Cairo.

                                            +

                                            Figure: Text shown using Cairo

                                            +

                                            Text shown using Cairo

                                            +

                                            To show text:

                                            +
                                              +
                                            1. Prepare a text to use as a resource:
                                              -static Eina_Bool 
                                              -_animate_cb(void *data)
                                              -{
                                              -   Evas_Object *obj = (Evas_Object *)data;
                                              -   evas_object_image_pixels_dirty_set(obj, EINA_TRUE);
                                              -
                                              -   return EINA_TRUE;
                                              -}
                                              +const char *utf8 = "Hello, Tizen!";
                                               
                                            2. - -
                                            3. The delete callback is triggered when the window is destroyed from the main loop. +
                                            4. Set text configurations. +

                                              In this example, create a font face implicitly using the cairo_select_font_face() function. The text is a kind of "mask" you are about to work with. To use a mask, you need a font type and font size. Set the font type as "Sans", and font size as 52.

                                              +
                                              +cairo_select_font_face(cairo, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
                                              +cairo_set_font_size(cairo, 52.0);
                                              +
                                              +
                                            5. +
                                            6. Show the text. +

                                              The cairo_show_text() function forms the mask from the text. You can think of the cairo_show_text() function as a shortcut for creating a path with the cairo_text_path() and using the cairo_fill() function to transfer it.

                                              +

                                              The cairo_show_text() function caches glyphs, and it is much more efficient if you work with a lot of text. Note that this function is experimental and must be handled with care. For more information about Cairo text, see the description of cairo_text.

                                              -static void 
                                              -win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
                                              -{
                                              -   appdata_s *ad = data;
                                              -   cairo_surface_destroy(ad->surface);
                                              -   cairo_destroy(ad->cairo);
                                              -   cairo_device_destroy(ad->cairo_device);
                                              -   evas_gl_surface_destroy(ad->evas_gl, ad->evas_gl_surface);
                                              -   evas_gl_context_destroy(ad->evas_gl, ad->evas_gl_context);
                                              -   evas_gl_config_free(ad->evas_gl_config);
                                              -   evas_gl_free(ad->evas_gl);
                                              -   ui_app_exit();
                                              -}
                                              +cairo_text_extents_t extents;
                                              +cairo_text_extents(cairo, utf8, &extents);
                                              +cairo_move_to(cairo, 10, 10);
                                              +cairo_show_text(cairo, utf8);
                                               
                                            -

                                            Figure: Random geometrical figures

                                            -

                                            Random geometrical figures

                                            +

                                            Deleting Cairo

                                            + +

                                            Delete the Cairo resources when they are no longer needed.

                                            +

                                            In the cairo_destroy() function, a reference count for a Cairo context is decreased by one. If the count is to be zero, the Cairo context and all associated resources must be freed. The same steps apply for the cairo_surface_destroy() function as well.

                                            +
                                            +cairo_surface_destroy(surface);
                                            +cairo_destroy(cairo);
                                            +
                                            diff --git a/org.tizen.tutorials/html/native/graphics/graphic_comp_tutorial_n.htm b/org.tizen.tutorials/html/native/graphics/graphic_comp_tutorial_n.htm index 833791f..fa4d4cb 100644 --- a/org.tizen.tutorials/html/native/graphics/graphic_comp_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/graphics/graphic_comp_tutorial_n.htm @@ -73,62 +73,74 @@ static Evas_Object* create_main_view(appdata_s *ad) { -   Evas_Object *layout, *rect, *line; -   Evas *e; -   int i; +    Evas_Object *layout, *rect, *line; +    Evas *e; +    int i; -   layout = elm_layout_add(ad->win); -   e = evas_object_evas_get(layout); +    layout = elm_layout_add(ad->win); +    e = evas_object_evas_get(layout);
                                          25. Draw 10 rectangles with random size, location, color, and transparency.

                                            Display the rectangles on evas.

                                            -   // Draw rectangles
                                            -   for (i = 0; i <= 10; i++) 
                                            -   {
                                            -      int x, y, w, h, r, g, b, a;
                                            -      x = rand() % 480;
                                            -      y = rand() % 800;
                                            -      w = rand() % 480;
                                            -      h = rand() % 800;
                                            -      r = rand() % 255;
                                            -      g = rand() % 255;
                                            -      b = rand() % 255;
                                            -      a = rand() % 255;
                                            -
                                            -      rect = evas_object_rectangle_add(e);
                                            -      evas_object_resize(rect, w, h);
                                            -      evas_object_move(rect, x, y);
                                            -      evas_object_color_set(rect, r, g, b, a);
                                            -      evas_object_show(rect);
                                            -   }
                                            +    /* Draw rectangles */
                                            +    for (i = 0; i <= 10; i++) {
                                            +        int x;
                                            +        int y;
                                            +        int w;
                                            +        int h;
                                            +        int r;
                                            +        int g;
                                            +        int b;
                                            +        int a;
                                            +        x = rand() % 480;
                                            +        y = rand() % 800;
                                            +        w = rand() % 480;
                                            +        h = rand() % 800;
                                            +        r = rand() % 255;
                                            +        g = rand() % 255;
                                            +        b = rand() % 255;
                                            +        a = rand() % 255;
                                            +
                                            +        rect = evas_object_rectangle_add(e);
                                            +        evas_object_resize(rect, w, h);
                                            +        evas_object_move(rect, x, y);
                                            +        evas_object_color_set(rect, r, g, b, a);
                                            +        evas_object_show(rect);
                                            +    }
                                             

                                            The coordinates and sizes cannot be expanded beyond the screen size.

                                          26. Draw 10 lines with random length, location, color, and transparency.

                                            Display the lines on evas.

                                            -   // Draw lines
                                            -   for (i = 0; i <= 10; i++) 
                                            -   {
                                            -      int x1, y1, x2, y2, r, g, b, a;
                                            -      x1 = rand() % 480;
                                            -      y1 = rand() % 800;
                                            -      x2 = rand() % 480;
                                            -      y2 = rand() % 800;
                                            -      r = rand() % 255;
                                            -      g = rand() % 255;
                                            -      b = rand() % 255;
                                            -      a = rand() % 255;
                                            -
                                            -      line = evas_object_line_add(e);
                                            -      evas_object_line_xy_set(line, x1, y1, x2, y2);
                                            -      evas_object_color_set(line, r, g, b, a);
                                            -      evas_object_show(line);
                                            -   }
                                            -
                                            -   return layout;
                                            +    /* Draw lines */
                                            +    for (i = 0; i <= 10; i++) {
                                            +        int x1;
                                            +        int y1;
                                            +        int x2;
                                            +        int y2;
                                            +        int r;
                                            +        int g;
                                            +        int b;
                                            +        int a;
                                            +        x1 = rand() % 480;
                                            +        y1 = rand() % 800;
                                            +        x2 = rand() % 480;
                                            +        y2 = rand() % 800;
                                            +        r = rand() % 255;
                                            +        g = rand() % 255;
                                            +        b = rand() % 255;
                                            +        a = rand() % 255;
                                            +
                                            +        line = evas_object_line_add(e);
                                            +        evas_object_line_xy_set(line, x1, y1, x2, y2);
                                            +        evas_object_color_set(line, r, g, b, a);
                                            +        evas_object_show(line);
                                            +    }
                                            +
                                            +    return layout;
                                             }
                                             

                                            The coordinates cannot be expanded beyond the screen size.

                                            @@ -150,45 +162,51 @@ To draw a row of small rectangles on the screen starting from the bottom and dra static Evas_Object* create_main_view(appdata_s *ad) { -   Evas_Object *layout, *rect, *line; -   Evas *e; -   int i; - -   layout = elm_layout_add(ad->win); -   e = evas_object_evas_get(layout); - -   int x, y, w, h, r, g, b, a; -   x = 0; -   y = 0; -   w = 480; -   h = 10; -   r = 0; -   g = 0; -   b = 0; -   a = 255; +    Evas_Object *layout, *rect, *line; +    Evas *e; +    int i; + +    layout = elm_layout_add(ad->win); +    e = evas_object_evas_get(layout); + +    int x; +    int y; +    int w; +    int h; +    int r; +    int g; +    int b; +    int a; +    x = 0; +    y = 0; +    w = 480; +    h = 10; +    r = 0; +    g = 0; +    b = 0; +    a = 255;
                                          27. Draw 200 rectangles and display them on evas:
                                            -   // Draw rects
                                            -   for (i = 0; i < 200; i++) 
                                            -   {
                                            -      rect = evas_object_rectangle_add(e);
                                            -      evas_object_resize(rect, w, h);
                                            -      evas_object_move(rect, x, y);
                                            -      y +=4;
                                            -      evas_object_color_set(rect, r, g, b, a);
                                            -      if (r < 255)
                                            -         r +=4;
                                            -      else if (g < 255)
                                            -         g +=4;
                                            -      else
                                            -         b +=4;
                                            -
                                            -      evas_object_show(rect);
                                            -   }
                                            -
                                            -   return layout;
                                            +    /* Draw rectangles */
                                            +    for (i = 0; i < 200; i++) {
                                            +        rect = evas_object_rectangle_add(e);
                                            +        evas_object_resize(rect, w, h);
                                            +        evas_object_move(rect, x, y);
                                            +        y +=4;
                                            +        evas_object_color_set(rect, r, g, b, a);
                                            +        if (r < 255)
                                            +            r +=4;
                                            +        else if (g < 255)
                                            +            g +=4;
                                            +        else
                                            +            b +=4;
                                            +
                                            +        evas_object_show(rect);
                                            +    }
                                            +
                                            +    return layout;
                                             }
                                             
                                          28. @@ -208,33 +226,35 @@ create_main_view(appdata_s *ad) static Evas_Object* create_main_view(appdata_s *ad) { -   Evas_Object *layout, *img; -   char buf[PATH_MAX]; -   int i; +    Evas_Object *layout, *img; +    char buf[PATH_MAX]; +    int i; -   layout = elm_layout_add(ad->win); +    layout = elm_layout_add(ad->win);
                                          29. Add the same image 10 times on the screen, each time using random size and coordinates:
                                            -   for (i = 0; i <= 10; i++) 
                                            -   {
                                            -      int x, y, w, h;
                                            -      x = rand() % 480;
                                            -      y = rand() % 800;
                                            -      w = rand() % 480;
                                            -      h = rand() % 800;
                                            -
                                            -      img = elm_image_add(layout);
                                            -      snprintf(buf, sizeof(buf), "%s/image.jpg", ICON_DIR);
                                            -      elm_image_file_set(img, buf, NULL);
                                            -
                                            -      evas_object_resize(img, w, h);
                                            -      evas_object_move(img, x, y);
                                            -      evas_object_show(img);
                                            -   }
                                            -
                                            -   return layout;
                                            +    for (i = 0; i <= 10; i++) {
                                            +        int x;
                                            +        int y;
                                            +        int w;
                                            +        int h;
                                            +        x = rand() % 480;
                                            +        y = rand() % 800;
                                            +        w = rand() % 480;
                                            +        h = rand() % 800;
                                            +
                                            +        img = elm_image_add(layout);
                                            +        snprintf(buf, sizeof(buf), "%s/image.jpg", ICON_DIR);
                                            +        elm_image_file_set(img, buf, NULL);
                                            +
                                            +        evas_object_resize(img, w, h);
                                            +        evas_object_move(img, x, y);
                                            +        evas_object_show(img);
                                            +    }
                                            +
                                            +    return layout;
                                             }
                                             
                                          30. diff --git a/org.tizen.tutorials/html/native/graphics/opengl_tutorial_n.htm b/org.tizen.tutorials/html/native/graphics/opengl_tutorial_n.htm index 5d46f6d..4c00e87 100644 --- a/org.tizen.tutorials/html/native/graphics/opengl_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/graphics/opengl_tutorial_n.htm @@ -25,7 +25,7 @@
                                            • EvasGL
                                                -
                                              • Initializing EvasGL
                                              • +
                                              • Prerequisites
                                              • Declaring EvasGL Objects
                                              • Creating the Elm Window and EvasGL
                                              • Getting OpenGL ES APIs
                                              • @@ -56,8 +56,8 @@
                                                • EvasGL -

                                                  Initializing EvasGL

                                                  +

                                                  Prerequisites

                                                  The EvasGL use cases assume that the application uses EvasGL directly instead of using the GLView. (If the application uses a GLView, EvasGL is created internally.)

                                                  @@ -90,9 +90,11 @@ #include <app.h> #include <Evas_GL_GLES2_Helpers.h> -// This code is placed at the beginning of any function using GLES 2.0 APIs -// When using this macro, you can call all glFunctions without changing their code -// For details, see Evas_GL_GLES2_Helpers.h +/* + This code is placed at the beginning of any function using GLES 2.0 APIs + When using this macro, you can call all glFunctions without changing their code + For details, see Evas_GL_GLES2_Helpers.h +*/ EVAS_GL_GLOBAL_GLES2_DEFINE(); @@ -101,23 +103,23 @@ EVAS_GL_GLOBAL_GLES2_DEFINE();

                                                  To hold all the objects for your EvasGL application, define the application data structure:

                                                  -typedef struct appdata
                                                  -{
                                                  -   Evas_Object *win; // Application window
                                                  -   Evas_Object *img; // OpenGL ES canvas
                                                  -
                                                  -   Evas_GL *evasgl; // EvasGL object for rendering GL in Evas
                                                  -   Evas_GL_Context *ctx; // EvasGL context object, a GL rendering context in Evas GL
                                                  -   Evas_GL_Surface *sfc; // EvasGL surface object, a GL rendering target in Evas GL
                                                  -   Evas_GL_Config *cfg; // EvasGL surface configuration object for surface creation
                                                  -   Evas_Coord sfc_w;
                                                  -   Evas_Coord sfc_h;
                                                  -
                                                  -   unsigned int program;
                                                  -   unsigned int vtx_shader;
                                                  -   unsigned int fgmt_shader;
                                                  -   unsigned int vbo;
                                                  -} appdata_s;
                                                  +struct appdata {
                                                  +    Evas_Object *win; /* Application window */
                                                  +    Evas_Object *img; /* OpenGL ES canvas */
                                                  +
                                                  +    Evas_GL *evasgl; /* EvasGL object for rendering GL in Evas */
                                                  +    Evas_GL_Context *ctx; /* EvasGL context object, a GL rendering context in Evas GL */
                                                  +    Evas_GL_Surface *sfc; /* EvasGL surface object, a GL rendering target in Evas GL */
                                                  +    Evas_GL_Config *cfg; /* EvasGL surface configuration object for surface creation */
                                                  +    Evas_Coord sfc_w;
                                                  +    Evas_Coord sfc_h;
                                                  +
                                                  +    unsigned int program;
                                                  +    unsigned int vtx_shader;
                                                  +    unsigned int fgmt_shader;
                                                  +    unsigned int vbo;
                                                  +};
                                                  +typedef struct appdata appdata_s;
                                                   

                                                  Creating the Elm Window and EvasGL

                                                  @@ -130,12 +132,14 @@ typedef struct appdata
                                                   Evas_Object *win;
                                                   
                                                  -// To use OpenGL ES, the application must switch on hardware acceleration
                                                  -// To enable that, call elm_config_accel_preference_set() with "opengl"
                                                  -// before creating the Elm window
                                                  -// This function is supported since 2.3.
                                                  +/*
                                                  +   To use OpenGL ES, the application must switch on hardware acceleration
                                                  +   To enable that, call elm_config_accel_preference_set() with "opengl"
                                                  +   before creating the Elm window
                                                  +   This function is supported since 2.3.
                                                  +*/
                                                   elm_config_accel_preference_set("opengl");
                                                  -// Creating Elm window
                                                  +/* Creating Elm window */
                                                   ad->win = elm_win_util_standard_add("Evas_GL Example", "Evas_GL Example");
                                                   
                                                  @@ -154,10 +158,10 @@ ad->evasgl = evas_gl_new(evas_object_evas_get(ad->win));
                                                   appdata_s *ad;
                                                   ad->cfg = evas_gl_config_new();
                                                  -ad->cfg->color_format = EVAS_GL_RGBA_8888; // Surface color format
                                                  -ad->cfg->depth_bits = EVAS_GL_DEPTH_BIT_24; // Surface depth format
                                                  -ad->cfg->stencil_bits = EVAS_GL_STENCIL_NONE; // Surface stencil format
                                                  -ad->cfg->options_bits = EVAS_GL_OPTIONS_NONE; // Configuration options (here, no extra options are used)
                                                  +ad->cfg->color_format = EVAS_GL_RGBA_8888; /* Surface color format */
                                                  +ad->cfg->depth_bits = EVAS_GL_DEPTH_BIT_24; /* Surface depth format */
                                                  +ad->cfg->stencil_bits = EVAS_GL_STENCIL_NONE; /* Surface stencil format */
                                                  +ad->cfg->options_bits = EVAS_GL_OPTIONS_NONE; /* Configuration options (here, no extra options are used) */
                                                   

                                                  Once you have configured the surface behavior, you must initialize the surface using the evas_gl_surface_create() function. This function takes the given Evas_GL object as the first parameter and the pixel format, and the configuration of the rendering surface as the second parameter. The last 2 parameters are the width and height of the surface, which you can recover directly from the window.

                                                  @@ -177,10 +181,12 @@ ad->sfc = evas_gl_surface_create(ad->evasgl, ad->cfg, w, h);
                                                   ad->ctx = evas_gl_context_create(ad->evasgl, NULL);
                                                   
                                                  -// This macro sets the global variable holding the GL API,
                                                  -// so that it is available to the application
                                                  -// Use it right after setting up the GL context object
                                                  -// For details, see Evas_GL_GLES2_Helpers.h
                                                  +/*
                                                  +   This macro sets the global variable holding the GL API,
                                                  +   so that it is available to the application
                                                  +   Use it right after setting up the GL context object
                                                  +   For details, see Evas_GL_GLES2_Helpers.h
                                                  +*/
                                                   EVAS_GL_GLOBAL_GLES2_USE(ad->evasgl, ad->ctx);
                                                   
                                                  @@ -225,16 +231,16 @@ evas_object_image_pixels_get_callback_set(ad->img, img_pixels_get_cb, ad); static void img_pixels_get_cb(void *data, Evas_Object *obj) { -   appdata_s *ad = data; -   // Rendering process -   evas_gl_make_current(ad->evasgl, ad->sfc, ad->ctx); -   // Because the surface size can be changed, set the viewport in this callback -   glViewport(0, 0, ad->sfc_w, ad->sfc_h); -   // Paint it blue -   glClearColor(0.2, 0.2, 0.6, 1.0); -   glClear(GL_COLOR_BUFFER_BIT); -   // Usual OpenGL ES draw commands come here -   // draw_scene(); +    appdata_s *ad = data; +    /* Rendering process */ +    evas_gl_make_current(ad->evasgl, ad->sfc, ad->ctx); +    /* Because the surface size can be changed, set the viewport in this callback */ +    glViewport(0, 0, ad->sfc_w, ad->sfc_h); +    /* Paint it blue */ +    glClearColor(0.2, 0.2, 0.6, 1.0); +    glClear(GL_COLOR_BUFFER_BIT); +    /* Usual OpenGL ES draw commands come here */ +    /* draw_scene(); */ }

                                                  At every tick, set the given context as a current context for the given surface using the evas_gl_make_current() function.

                                                  @@ -249,10 +255,10 @@ img_pixels_get_cb(void *data, Evas_Object *obj) static Eina_Bool animate_cb(void *data) { -   Evas_Object *img = data; -   evas_object_image_pixels_dirty_set(img, EINA_TRUE); +    Evas_Object *img = data; +    evas_object_image_pixels_dirty_set(img, EINA_TRUE); -   return ECORE_CALLBACK_RENEW; +    return ECORE_CALLBACK_RENEW; } ecore_animator_add(animate_cb, ad->img); @@ -275,28 +281,26 @@ evas_object_event_callback_add(ad->win, EVAS_CALLBACK_RESIZE, win_resize_cb, static void win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { -   appdata_s *ad = data; - -   if (ad->sfc) -   { -      evas_object_image_native_surface_set(ad->img, NULL); -      evas_gl_surface_destroy(ad->evasgl, ad->sfc); -      ad->sfc = NULL; -   } - -   evas_object_geometry_get(obj, NULL, NULL, &ad->sfc_w, &ad->sfc_h); -   evas_object_image_size_set(ad->img, ad->sfc_w, ad->sfc_h); -   evas_object_resize(ad->img, ad->sfc_w, ad->sfc_h); -   evas_object_show(ad->img); - -   if (!ad->sfc) -   { -      Evas_Native_Surface ns; -      ad->sfc = evas_gl_surface_create(ad->evasgl, ad->cfg, ad->sfc_w, ad->sfc_h); -      evas_gl_native_surface_get(ad->evasgl, ad->sfc, &ns); -      evas_object_image_native_surface_set(ad->img, &ns); -      evas_object_image_pixels_dirty_set(ad->img, EINA_TRUE); -   } +    appdata_s *ad = data; + +    if (ad->sfc) { +        evas_object_image_native_surface_set(ad->img, NULL); +        evas_gl_surface_destroy(ad->evasgl, ad->sfc); +        ad->sfc = NULL; +    } + +    evas_object_geometry_get(obj, NULL, NULL, &ad->sfc_w, &ad->sfc_h); +    evas_object_image_size_set(ad->img, ad->sfc_w, ad->sfc_h); +    evas_object_resize(ad->img, ad->sfc_w, ad->sfc_h); +    evas_object_show(ad->img); + +    if (!ad->sfc) { +        Evas_Native_Surface ns; +        ad->sfc = evas_gl_surface_create(ad->evasgl, ad->cfg, ad->sfc_w, ad->sfc_h); +        evas_gl_native_surface_get(ad->evasgl, ad->sfc, &ns); +        evas_object_image_native_surface_set(ad->img, &ns); +        evas_object_image_pixels_dirty_set(ad->img, EINA_TRUE); +    } }
                                                • @@ -323,26 +327,23 @@ evas_object_image_native_surface_set(ad->img, &ns);

                                                  To detect support for the GL_OES_get_program_binary extension or equivalent, and to get the function pointer associated:

                                                  -
                                                  +
                                                   Evas_GL_API *gl = elm_glview_api_get(glview);
                                                   
                                                  -// Check for support for the Program Binary OES extension
                                                  +/* Check for support for the Program Binary OES extension */
                                                   if (gl->glGetProgramBinaryOES)
                                                  -{
                                                  -   printf("Program binary extension is supported.\n");
                                                  -}
                                                  +    printf("Program binary extension is supported.\n");
                                                   
                                                • Call an extension.

                                                  Calling an extension is similar to calling a function:

                                                  -
                                                  -if (gl->glGetProgramBinaryOES)
                                                  -{
                                                  -   char buf[4096];
                                                  -   size_t len;
                                                  -   Glenum fmt;
                                                  -   gl->glGetProgramBinaryOES(prgid, sizeof(buf), &len, &fmt, buf);
                                                  +
                                                  +if (gl->glGetProgramBinaryOES) {
                                                  +    char buf[4096];
                                                  +    size_t len;
                                                  +    Glenum fmt;
                                                  +    gl->glGetProgramBinaryOES(prgid, sizeof(buf), &len, &fmt, buf);
                                                   }
                                                   
                                                • @@ -363,19 +364,19 @@ if (gl->glGetProgramBinaryOES)
                                                • Check for support.

                                                  Before using this extension, check whether it is supported.

                                                  -
                                                  +
                                                   if (gl->evasglCreateImageForContext && gl->evasglDestroyImage)
                                                  -{
                                                  -   // Good...
                                                  -}
                                                  +    /* Good... */
                                                   
                                                • Create an image.

                                                  Create a render buffer and bind it to an EvasGL image.

                                                  -
                                                  -const int width = 64, height = 64;
                                                  -GLuint fbo, color_rb;
                                                  +
                                                  +const int width = 64;
                                                  +const int height = 64;
                                                  +GLuint fbo;
                                                  +GLuint color_rb;
                                                   EvasGLImage *image;
                                                   Evas_GL *evgl;
                                                   Evas_GL_Context *ctx;
                                                  @@ -393,7 +394,7 @@ gl->glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
                                                   evgl = elm_glview_evas_gl_get(glview);
                                                   ctx = evas_gl_current_context_get(evgl);
                                                   image = gl->evasglCreateImageForContext(evgl, ctx, EVAS_GL_TEXTURE_2D,
                                                  -                                        (void *)(intptr_t) color_rb, NULL);
                                                  +                                        (void *)(intptr_t)color_rb, NULL);
                                                   

                                                  The EvasGL image is now created and available for use from another context.

                                                  @@ -401,20 +402,21 @@ image = gl->evasglCreateImageForContext(evgl, ctx, EVAS_GL_TEXTURE_2D,
                                                • Use an image.

                                                  Draw something in the texture and render that texture to the screen. The following example shows how to skip the draw function.

                                                  -
                                                  +
                                                   gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
                                                  -draw_scene(glview);
                                                  +draw_scene(glview); +

                                                  You can also bind the image to a texture for display on the back buffer:

                                                  -
                                                  +
                                                   GLuint tex;
                                                   
                                                   gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
                                                   gl->glGenTextures(1, &tex);
                                                   gl->glBindTexture(GL_TEXTURE_2D, tex);
                                                   gl->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
                                                  -// Draw the texture content on the screen
                                                  +/* Draw the texture content on the screen */
                                                   static const GLint verts[12] = {-5, -6, -10,  5, -6, -10,  -5, 4, 10,  5, 4, 10};
                                                   static const GLint tex_coords[8] = {0, 0,  1, 0,  0, 1,  1, 1};
                                                   
                                                  @@ -443,8 +445,9 @@ gl->glDisable(GL_TEXTURE_2D);
                                                   	
                                                • Destroy an image.

                                                  After releasing all the associated resources, such as FBO and textures, release the image object itself.

                                                  -
                                                  -gl->evasglDestroyImage(image);
                                                  +
                                                  +gl->evasglDestroyImage(image);
                                                  +
                                                • @@ -458,7 +461,7 @@ gl->evasglDestroyImage(image);
                                                   if (gl->evasglCreateSync)
                                                  -   // fence_sync must be supported
                                                  +    /* fence_sync must be supported */
                                                   
                                                @@ -472,10 +475,10 @@ if (gl->evasglCreateSync)

                                                In GLView, the ELM_GLVIEW_DIRECT option is one of GLView mode's enums and the option can be enabled using the elm_glview_mode_set() function.

                                                -// Tizen 2.3
                                                -// elm_config_accel_preference_set("opengl");
                                                +/* Tizen 2.3 */
                                                +/* elm_config_accel_preference_set("opengl"); */
                                                 
                                                -// Since Tizen 2.3.1
                                                +/* Since Tizen 2.3.1 */
                                                 elm_config_accel_preference_set("opengl:depth24:stencil8:msaa_high");
                                                 Evas_Object *win = elm_win_util_standard_add("sample", "sample");
                                                 
                                                @@ -490,16 +493,16 @@ elm_glview_mode_set(glview, ELM_GLVIEW_DEPTH_24 | ELM_GLVIEW_STENCIL_8 | ELM_GLV
                                                 
                                                 

                                                In EvasGL, the EVAS_GL_OPTIONS_DIRECT is one of EvasGL's config options and the option can be enabled by setting the Evas_GL_Config option.

                                                -// Tizen 2.3
                                                -// elm_config_accel_preference_set("opengl");
                                                +/* Tizen 2.3 */
                                                +/* elm_config_accel_preference_set("opengl"); */
                                                 
                                                -// Since Tizen 2.3.1
                                                +/* Since Tizen 2.3.1 */
                                                 elm_config_accel_preference_set("opengl:depth24:stencil8:msaa_high");
                                                 Evas_Object *win = elm_win_util_standard_add("sample", "sample");
                                                 
                                                 Evas_GL_Config *cfg = evas_gl_config_new();
                                                 cfg = evas_gl_config_new();
                                                - 
                                                +
                                                 cfg->color_format = EVAS_GL_RGB_888;
                                                 cfg->depth_bits = EVAS_GL_DEPTH_BIT_24;
                                                 cfg->stencil_bits = EVAS_GL_STENCIL_BIT_8;
                                                @@ -559,8 +562,9 @@ cfg->multisample_bits = EVAS_GL_MULTISAMPLE_HIGH;
                                                 
                                                 Evas_Object *gl;
                                                 gl = elm_glview_add(win);
                                                - 
                                                -elm_glview_mode_set(gl, ELM_GLVIEW_DEPTH | ELM_GLVIEW_DIRECT | ELM_GLVIEW_CLIENT_SIDE_ROTATION);
                                                + +elm_glview_mode_set(gl, ELM_GLVIEW_DEPTH | ELM_GLVIEW_DIRECT | ELM_GLVIEW_CLIENT_SIDE_ROTATION); +
                                              • To use EvasGL rotation: @@ -569,28 +573,30 @@ elm_glview_mode_set(gl, ELM_GLVIEW_DEPTH | ELM_GLVIEW_DIRECT | ELM_GLVIEW_CLIENT
                                                 Evas_GL_Config *cfg;
                                                 cfg = evas_gl_config_new();
                                                - 
                                                -cfg->options_bits = EVAS_GL_OPTIONS_DIRECT | EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION;
                                                + +cfg->options_bits = EVAS_GL_OPTIONS_DIRECT | EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION; +
                                              • Get the current rotation value:

                                                -static void 
                                                -_draw_gl(Evas_Object *obj) 
                                                +static void
                                                +_draw_gl(Evas_Object *obj)
                                                 {
                                                -   int w, h, rotation;
                                                -   elm_glview_size_get(obj, &w, &h);
                                                -   rotation = evas_gl_rotation_get(ad->evasgl);
                                                -
                                                -   if (rotation % 180)
                                                -   {
                                                -      // Adjust gl size
                                                -   } 
                                                -}
                                                +    int w; +    int h; +    int rotation; +    elm_glview_size_get(obj, &w, &h); +    rotation = evas_gl_rotation_get(ad->evasgl); + +    if (rotation % 180) +        /* Adjust gl size */ +} + -

                                                To get the current rotation of the view, in degrees, call the evas_gl_rotation_get() function to properly handle the current rotation of the view. It always returns 0 unless the option EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION has been set. Indeed, in case of Direct Rendering to the back buffer, the client application is responsible for properly rotating its view. This can generally be done by applying a rotation to a view matrix.

                                                +

                                                To get the current rotation of the view, in degrees, call the evas_gl_rotation_get() function to properly handle the current rotation of the view. It always returns 0 unless the option EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION has been set. Indeed, in case of Direct Rendering to the back buffer, the client application is responsible for properly rotating its view. This can generally be done by applying a rotation to a view matrix.

                                                -
                                              - +
                                            + diff --git a/org.tizen.tutorials/html/native/graphics/tbm_tutorial_n.htm b/org.tizen.tutorials/html/native/graphics/tbm_tutorial_n.htm index 28f0899..a55ace9 100644 --- a/org.tizen.tutorials/html/native/graphics/tbm_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/graphics/tbm_tutorial_n.htm @@ -23,6 +23,7 @@

                                            Content

                                            Related Info

                                            @@ -43,31 +44,31 @@

                                            Warm-up

                                            Become familiar with the TBM Surface API basics by learning about:

                                            +

                                            Prerequisites

                                            + +

                                            To use the functions and data types of the TBM Surface API (in mobile and wearable applications, include the <tbm_surface.h> header file in your application:

                                            +
                                            +#include <tbm_surface.h>
                                            +

                                            Managing the TBM Surface

                                            To create the TBM surface:

                                              - -
                                            1. To use the functions and data types of the TBM Surface API (in mobile and wearable applications, include the <tbm_surface.h> header file in your application:

                                              -
                                              -#include <tbm_surface.h>
                                              -
                                            2. -
                                            3. Query the formats supported by the system using the tbm_surface_query_formats() function. Free the array of formats after viewing the formats.
                                               tbm_format *formats;
                                               uint32_t format_num;
                                               
                                               if (tbm_surface_query_formats(&formats, &format_num) != TBM_SURFACE_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get formats supported by the system\n");
                                              -}
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get formats supported by the system\n");
                                               
                                            4. @@ -77,20 +78,16 @@ if (tbm_surface_query_formats(&formats, &format_num) != TBM_SURFACE_ERRO int i; tbm_surface_h surface = NULL; -for (i = 0; i < format_num; i++) -{ -   if (formats[i] == TBM_FORMAT_ARGB8888) -   { -      surface = tbm_surface_create(128, 128, TBM_FORMAT_ARGB8888); -      if (surface == NULL) -         dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create tbm_surface\n"); -      break; -   } +for (i = 0; i < format_num; i++) { +    if (formats[i] == TBM_FORMAT_ARGB8888) { +        surface = tbm_surface_create(128, 128, TBM_FORMAT_ARGB8888); +        if (surface == NULL) +            dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create tbm_surface\n"); +        break; +    } } if (i == format_num) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "format not supported\n"); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "format not supported\n"); @@ -100,9 +97,7 @@ if (i == format_num) tbm_surface_info_s surface_info; if (tbm_surface_map(surface, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &surface_info) != TBM_SURFACE_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to map tbm_surface\n"); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to map tbm_surface\n"); @@ -110,22 +105,16 @@ if (tbm_surface_map(surface, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &su

                                              Store data at the tbm_surface instance by using a pointer of each plane:

                                               for (i = 0; i < surface_info.num_planes; i++)
                                              -{
                                              -   memset(surface_info.planes[i].ptr, 0x0, surface_info.planes[i].size);
                                              -}
                                              +    memset(surface_info.planes[i].ptr, 0x0, surface_info.planes[i].size);
                                               
                                            5. When no longer needed, unmap and destroy the tbm_surface instance:
                                               if (tbm_surface_unmap(surface) != TBM_SURFACE_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to unmap tbm_surface\n");
                                              -}
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to unmap tbm_surface\n");
                                               if (tbm_surface_destroy(surface) != TBM_SURFACE_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy tbm_surface\n");
                                              -}
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy tbm_surface\n");
                                               free(formats);
                                               
                                            6. diff --git a/org.tizen.tutorials/html/native/location/geofence_tutorial_n.htm b/org.tizen.tutorials/html/native/location/geofence_tutorial_n.htm index 1471d05..48080b4 100644 --- a/org.tizen.tutorials/html/native/location/geofence_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/location/geofence_tutorial_n.htm @@ -10,7 +10,7 @@ - Geofence: Creating and Using Geofences + Geofence Manager: Creating and Using Geofences @@ -21,49 +21,52 @@
                                            -

                                            Geofence: Creating and Using Geofences

                                            +

                                            Geofence Manager: Creating and Using Geofences

                                            This tutorial demonstrates how you can implement geofence-related information and services.

                                            This feature is supported in mobile applications only.

                                            Warm-up

                                            -

                                            Become familiar with Geofence API basics by learning about:

                                            +

                                            Become familiar with Geofence Manager API basics by learning about:

                                            +

                                            Prerequisites

                                            -

                                            Initializing the Geofence Service

                                            - -

                                            To initialize the geofence features:

                                            -
                                            1. To use the functions and data types of the Geofence Manager API, include the <geofence_manager.h> header file in your application:

                                              +

                                              To use the functions and data types of the Geofence Manager API, include the <geofence_manager.h> header file in your application:

                                               #include <geofence_manager.h>
                                              -
                                            2. + + +

                                              Starting the Geofence Service

                                              + +

                                              To start the geofence service:

                                              +
                                              1. Create a geofence manager handle using the geofence_manager_create() function:

                                                 geofence_manager_h manager;
                                                @@ -73,7 +76,7 @@ geofence_manager_create(&manager);
                                                 
                                                 
                                              2. Create a place to be used for the geofences:

                                                -int place_id = -1; // This is for creating a place
                                                +int place_id = -1; /* This is for creating a place */
                                                 geofence_manager_add_place(manager, "place_name", &place_id);
                                                 
                                            @@ -96,7 +99,7 @@ geofence_manager_add_place(manager, "place_name", &place_id); double latitude = 12.756738; double longitude = 77.386474; int radius = 100; -char* address = "India"; +char* address = "India"; geofence_h fence_h; geofence_create_geopoint(place_id, latitude, longitude, radius, address, &fence_h); @@ -148,12 +151,12 @@ geofence_manager_set_geofence_event_cb(manager, geofence_event, NULL);
                                             geofence_manage_e user_action;
                                             geofence_manager_error_e user_error;
                                            -void 
                                            -geofence_event(int place_id, int geofence_id, geofence_manager_error_e error, 
                                            +void
                                            +geofence_event(int place_id, int geofence_id, geofence_manager_error_e error,
                                                            geofence_manage_e manage, void *user_data)
                                             {
                                            -   user_action = manage;
                                            -   user_error = error;
                                            +    user_action = manage;
                                            +    user_error = error;
                                             }
                                             
                                            @@ -172,27 +175,6 @@ geofence_event(int place_id, int geofence_id, geofence_manager_error_e error, -

                                            Getting Geofence Alerts

                                            - -

                                            To get alerts of the geofence state changes, use the geofence state callback. There is no periodic call, but the callback is invoked if there is a state change. The callback is called only if the geofence service has been started.

                                            -
                                              -
                                            1. Register the callback using the geofence_manager_set_geofence_state_changed_cb() function:

                                              -
                                              -geofence_manager_set_geofence_state_changed_cb(manager, geofence_state_changed, NULL);
                                              -
                                            2. - -
                                            3. When the alert is received, you can use the callback to, for example, update the variables that store the current state:

                                              -
                                              -geofence_state_e received_state;
                                              -void 
                                              -geofence_state_changed(int geofence_id, geofence_state_e state, void *user_data)
                                              -{
                                              -   received_state = state;
                                              -}
                                              -
                                              -
                                            - -

                                            Tracking the User for Geofence Alerts

                                            @@ -206,7 +188,7 @@ geofence_manager_set_geofence_state_changed_cb(manager, geofence_state_changed,
                                          31. Define the callback function:

                                            -void 
                                            +void
                                             geofence_state_changed(int geofence_id, geofence_state_e state, void *user_data) {}
                                             
                                          32. @@ -233,7 +215,7 @@ geofence_status_get_duration(status_h, &duration);
                                             geofence_status_destroy(status_h);
                                             
                                            -

                                            The status handle should be destroyed when it is not needed.

                                            + @@ -260,9 +242,9 @@ geofence_get_longitude(fence_h, &longitude); geofence_get_radius(fence_h, &radius); geofence_get_address(fence_h, &address); -// Release the resource after use +/* Release the resource after use */ free(address); - +
                                          33. Retrieve the Wi-Fi or Bluetooth geofence information:
                                             char *bssid;
                                            @@ -270,12 +252,12 @@ char *ssid;
                                             geofence_get_bssid(fence_h, &bssid);
                                             geofence_get_ssid(fence_h, &ssid);
                                             
                                            -// Release the resources after use
                                            +/* Release the resources after use */
                                             free(bssid);
                                             free(ssid);
                                             
                                          34. - + diff --git a/org.tizen.tutorials/html/native/location/location_tutorial_n.htm b/org.tizen.tutorials/html/native/location/location_tutorial_n.htm index 1c0702c..665745a 100644 --- a/org.tizen.tutorials/html/native/location/location_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/location/location_tutorial_n.htm @@ -21,7 +21,8 @@

                                            Content

                                              -
                                            • Initializing the Location Service
                                            • +
                                            • Prerequisites
                                            • +
                                            • Starting the Location Service
                                            • Getting the Last Known Location
                                            • Getting Location Updates
                                            • Using Location Bounds
                                            • @@ -45,10 +46,12 @@

                                              Warm-up

                                              -

                                              Become familiar with the Location API basics by learning about:

                                              +

                                              Become familiar with the Location Manager API basics by learning about:

                                              Follow-up

                                              -

                                              Once we have learned the basics of the Location API, we can now move on to more advanced tasks, including:

                                              +

                                              Once we have learned the basics of the Location Manager API, we can now move on to more advanced tasks, including:

                                              -

                                              Initializing the Location Service

                                              - -
                                              1. To use the functions and data types of the Location Manager API (in mobile and wearable applications), include the <locations.h> header file in your application:

                                                + +

                                                Prerequisites

                                                + +

                                                To use the functions and data types of the Location Manager API (in mobile and wearable applications), include the <locations.h> header file in your application:

                                                 #include <locations.h>
                                                -
                                              2. + + +

                                                Starting the Location Service

                                                + +

                                                To start the location service:

                                                +
                                                1. Create a location manager handle using the location_manager_create() function before you use the location service.

                                                  In this example, the GPS is used as the source of the position data, so the first parameter is LOCATIONS_METHOD_GPS. You can use other values of the location_method_e enumeration (in mobile and wearable applications), such as LOCATIONS_METHOD_HYBRID or LOCATIONS_METHOD_WPS. LOCATIONS_METHOD_HYBRID uses both LOCATIONS_METHOD_GPS and LOCATIONS_METHOD_WPS, but the latter is less accurate.

                                                  @@ -85,10 +94,13 @@ location_manager_create(LOCATIONS_METHOD_GPS, &manager);
                                                   
                                                   
                                                2. Start the location service using the location_manager_start() function. This call is asynchronous and only initiates the process of starting the location manager service. Once the manager is started, the registered callbacks are invoked when their corresponding events take place. To know when the service becomes enabled, use the location_manager_set_service_state_changed_cb() function.

                                                  -location_manager_start(manager);
                                                3. +location_manager_start(manager); +
                                                4. Using the location service is power consuming, so if the service is not used, stop updating the location using the location_manager_stop() function. Call the location_manager_start() function again if the update position information is needed.

                                                  -
                                                  location_manager_stop(manager);
                                                5. +
                                                  +location_manager_stop(manager);
                                                  +
                                                6. At the end of the application, destroy all used resources, such as the location manager (location_manager_destroy()):

                                                  @@ -99,51 +111,64 @@ manager = NULL;
                                                   
                                                   

                                                  Getting the Last Known Location

                                                  -

                                                  To retrieve synchronously the last known location of the device:

                                                  -
                                                    +

                                                    To retrieve synchronously the last known location of the device:

                                                    +
                                                    1. Register a callback function for location service state changes and start the Location Manager: -
                                                      +
                                                       ret = location_manager_set_service_state_changed_cb(manager, __state_changed_cb, NULL);
                                                      -ret = location_manager_start(manager);
                                                      -

                                                      The __state_changed_cb function is a callback, which is called when the status of the location service state changes.

                                                      -
                                                      +ret = location_manager_start(manager);
                                                      +
                                                      +

                                                      The __state_changed_cb() function is a callback, which is called when the status of the location service state changes.

                                                      +
                                                       static location_service_state_e service_state;
                                                      -static void 
                                                      +static void
                                                       __state_changed_cb(location_service_state_e state, void *user_data)
                                                       {
                                                      -   service_state = state;
                                                      +    service_state = state;
                                                       }
                                                       
                                                    2. After starting the Location Manager, call the location_manager_get_last_location() function to get the last location information, including the altitude, latitude, and direction:
                                                      -double altitude, latitude, longitude, climb, direction, speed;
                                                      -double horizontal, vertical;
                                                      +double altitude;
                                                      +double latitude;
                                                      +double longitude;
                                                      +double climb;
                                                      +double direction;
                                                      +double speed;
                                                      +double horizontal;
                                                      +double vertical;
                                                       location_accuracy_level_e level;
                                                       time_t timestamp;
                                                       ret = location_manager_get_last_location(manager, &altitude, &latitude, &longitude,
                                                      -                                         &climb, &direction, &speed, &level, &horizontal, 
                                                      -                                         &vertical, &timestamp);
                                                      +                                         &climb, &direction, &speed, &level, &horizontal, +                                         &vertical, &timestamp); +

                                                  The function returns the last location stored in the system. When the current location is not fixed, the last location may not be the current location, but the old location.

                                                  Use this function instead of repeatedly requesting current locations to spare the Location Manager from running costly positioning systems.

                                                7. To get the current location information, call the location_manager_get_location() function after the service is enabled:
                                                  -static void 
                                                  +static void
                                                   __state_changed_cb(location_service_state_e state, void *user_data)
                                                   {
                                                  -   double altitude, latitude, longitude, climb, direction, speed;
                                                  -   double horizontal, vertical;
                                                  -   location_accuracy_level_e level;
                                                  -   time_t timestamp;
                                                  -
                                                  -   if (state == LOCATIONS_SERVICE_ENABLED) 
                                                  -   {
                                                  -      ret = location_manager_get_location(manager, &altitude, &latitude, &longitude,
                                                  -                                          &climb, &direction, &speed, &level, 
                                                  -                                          &horizontal, &vertical, &timestamp);
                                                  -   }
                                                  +    double altitude;
                                                  +    double latitude;
                                                  +    double longitude;
                                                  +    double climb;
                                                  +    double direction;
                                                  +    double speed;
                                                  +    double horizontal;
                                                  +    double vertical;
                                                  +    location_accuracy_level_e level;
                                                  +    time_t timestamp;
                                                  +
                                                  +    if (state == LOCATIONS_SERVICE_ENABLED) {
                                                  +        ret = location_manager_get_location(manager, &altitude, &latitude, &longitude,
                                                  +                                            &climb, &direction, &speed, &level,
                                                  +                                            &horizontal, &vertical, &timestamp);
                                                  +    }
                                                   }
                                                   
                                                8. @@ -157,17 +182,20 @@ location_manager_unset_service_state_changed_cb(manager);

                                                  You can get a notification of the position update using the position update callback. The callback is invoked periodically, receiving the device's current position with every call. You can use the callback to retrieve the device position (given as coordinates) and convert it to the corresponding address.

                                                  1. Register the callback using the location_manager_set_position_updated_cb() function:

                                                    -
                                                    location_manager_set_position_updated_cb(manager, position_updated, 2, NULL);
                                                    +
                                                    +location_manager_set_position_updated_cb(manager, position_updated, 2, NULL);
                                                    +

                                                    The third parameter determines the frequency of callback calls. In this example, the callback is called every 2 seconds.

                                                  2. When the update is received, you can, for example, update the variables that store the current position:

                                                    -static double user_latitude, user_longitude;
                                                    -static void 
                                                    -position_updated(double latitude, double longitude, double altitude, 
                                                    +static double user_latitude;
                                                    +static double user_longitude;
                                                    +static void
                                                    +position_updated(double latitude, double longitude, double altitude,
                                                                      time_t timestamp, void *user_data)
                                                     {
                                                    -   user_latitude = latitude;
                                                    -   user_longitude = longitude;
                                                    +    user_latitude = latitude;
                                                    +    user_longitude = longitude;
                                                     }
                                                     
                                                    @@ -190,9 +218,9 @@ position_updated(double latitude, double longitude, double altitude,
                                                    1. Create location bounds with the required area type (rectangle, circle, or polygon) needed for your application (each type has its own API sets):
                                                      -int poly_size = 3; // Triangle shaped bounds
                                                      +int poly_size = 3; /* Triangle shaped bounds */
                                                       location_coords_s coord_list[poly_size];
                                                      -coord_list[0].latitude = 37; // Temporary value
                                                      +coord_list[0].latitude = 37; /* Temporary value */
                                                       coord_list[0].longitude = 126;
                                                       coord_list[1].latitude = 38;
                                                       coord_list[1].longitude = 128;
                                                      @@ -205,39 +233,46 @@ ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
                                                       
                                                       
                                                    2. To get the generated polygon bounds, register a callback function to notify you of the polygon coordinates:
                                                      -ret = location_bounds_foreach_polygon_coords(bounds_poly, capi_poly_coords_cb, NULL);
                                                      +ret = location_bounds_foreach_polygon_coords(bounds_poly, capi_poly_coords_cb, NULL); +
                                                    3. Implement the callback function (the second parameter in the function above) separately:

                                                      -static double latitude, longitude;
                                                      -static bool 
                                                      +static double latitude;
                                                      +static double longitude;
                                                      +static bool
                                                       capi_poly_coords_cb(location_coords_s coords, void *user_data)
                                                       {
                                                      -   latitude = coords.latitude;
                                                      -   longitude = coords.longitude;
                                                      +    latitude = coords.latitude;
                                                      +    longitude = coords.longitude;
                                                       
                                                      -   return true;
                                                      +    return true;
                                                       }
                                                       
                                                    4. Register a callback, which is called when you enter or exit the defined region, using the location_bounds_set_state_changed_cb() function:

                                                      -
                                                      location_bounds_set_state_changed_cb(bounds_poly, bounds_state_changed_cb, NULL);
                                                      -

                                                      Implement the bounds_state_changed_cb callback separately:

                                                      +
                                                      +location_bounds_set_state_changed_cb(bounds_poly, bounds_state_changed_cb, NULL);
                                                      +
                                                      +

                                                      Implement the bounds_state_changed_cb() callback separately:

                                                       static location_boundary_state_e bound_state;
                                                      -static void 
                                                      +static void
                                                       bounds_state_changed_cb(location_boundary_state_e state, void *user_data)
                                                       {
                                                      -   bound_state = state;
                                                      +    bound_state = state;
                                                       }
                                                       
                                                    5. Call the location_manager_add_boundary() function to add the bounds to a location manager:

                                                      -
                                                      location_manager_add_boundary(manager, bounds_poly);
                                                      +
                                                      +location_manager_add_boundary(manager, bounds_poly);
                                                      +
                                                    6. When the bounds are no longer needed, destroy them:
                                                      -location_bounds_destroy(bounds_poly);
                                                    7. +location_bounds_destroy(bounds_poly); +

                                                    Getting Satellite Information

                                                    @@ -251,31 +286,33 @@ gps_status_set_satellite_updated_cb(manager, capi_gps_status_satellite_updated_c
                                                  3. When the update is received, the callback containing brief satellite information is called. To get the detailed satellite information in the sky, call the gps_status_foreach_satellites_in_view() function in the callback. Variables that store the current satellite information are updated.
                                                    -int cur_azimuth, cur_elevation, cur_prn, cur_snr;
                                                    +int cur_azimuth;
                                                    +int cur_elevation;
                                                    +int cur_prn;
                                                    +int cur_snr;
                                                     
                                                    -static bool 
                                                    -capi_gps_status_get_satellites_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, 
                                                    +static bool
                                                    +capi_gps_status_get_satellites_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn,
                                                                                       int snr, bool is_in_use, void *user_data)
                                                     {
                                                    -   cur_azimuth = azimuth;
                                                    -   cur_elevation = elevation;
                                                    -   cur_prn = prn;
                                                    -   cur_snr = snr;
                                                    +    cur_azimuth = azimuth;
                                                    +    cur_elevation = elevation;
                                                    +    cur_prn = prn;
                                                    +    cur_snr = snr;
                                                     
                                                    -   return true;
                                                    +    return true;
                                                     }
                                                     
                                                    -static int numofactive, numofinview;
                                                    +static int numofactive;
                                                    +static int numofinview;
                                                     
                                                    -static void 
                                                    -capi_gps_status_satellite_updated_cb(int num_of_active, int num_of_inview, 
                                                    +static void
                                                    +capi_gps_status_satellite_updated_cb(int num_of_active, int num_of_inview,
                                                                                          time_t timestamp, void *user_data)
                                                     {
                                                    -   numofinview = num_of_active;
                                                    -   if (num_of_inview > 0) 
                                                    -   {
                                                    -      gps_status_foreach_satellites_in_view(manager, capi_gps_status_get_satellites_cb, NULL);
                                                    -   }
                                                    +    numofinview = num_of_active;
                                                    +    if (num_of_inview > 0)
                                                    +        gps_status_foreach_satellites_in_view(manager, capi_gps_status_get_satellites_cb, NULL);
                                                     }
                                                     
                                                    @@ -315,12 +352,12 @@ location_manager_set_position_updated_cb(manager, velocity_updated, 2, NULL);
                                                  4. Define the position and velocity callback functions:

                                                    -void 
                                                    -position_updated(double latitude, double longitude, double altitude, 
                                                    -                      time_t timestamp, void *user_data) {}
                                                    -void 
                                                    -velocity_updated(double speed, double direction, double climb, 
                                                    -                      time_t timestamp, void *user_data) {}
                                                    +void
                                                    +position_updated(double latitude, double longitude, double altitude,
                                                    +                 time_t timestamp, void *user_data) {}
                                                    +void
                                                    +velocity_updated(double speed, double direction, double climb,
                                                    +                 time_t timestamp, void *user_data) {}
                                                     

                                                    Within the callback, you can collect obtained data to get the points you have visited, to calculate traveled distance more precisely, or to calculate the average speed or climb.

                                                  @@ -358,7 +395,7 @@ location_manager_get_accuracy(manager, &level, &horizontal, &vertica
                                                9. Use the location_manager_get_location() function to get all of the above 10 values at once:

                                                  -location_manager_get_location(manager, &altitude, &latitude, &longitude, &climb, 
                                                  +location_manager_get_location(manager, &altitude, &latitude, &longitude, &climb,
                                                                                 &direction, &speed, &level, &horizontal, &vertical, &timestamp);
                                                   
                                                10. diff --git a/org.tizen.tutorials/html/native/location/location_tutorials_n.htm b/org.tizen.tutorials/html/native/location/location_tutorials_n.htm index 41c4f03..70653d5 100644 --- a/org.tizen.tutorials/html/native/location/location_tutorials_n.htm +++ b/org.tizen.tutorials/html/native/location/location_tutorials_n.htm @@ -38,7 +38,7 @@

                                            The following tutorials apply in mobile applications only:

                                              -
                                            • Geofence: Creating and Using Geofences +
                                            • Geofence Manager: Creating and Using Geofences

                                              Demonstrates how you can create and use geofences.

                                            • Maps Service: Using the Map Service

                                              Demonstrates how you can use the map service to query geocodes and routes, and search for places.

                                            • diff --git a/org.tizen.tutorials/html/native/location/maps_tutorial_n.htm b/org.tizen.tutorials/html/native/location/maps_tutorial_n.htm index f4ea0c0..209c0be 100644 --- a/org.tizen.tutorials/html/native/location/maps_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/location/maps_tutorial_n.htm @@ -25,7 +25,8 @@

                                              Content

                                                -
                                              • Initializing the Map Service
                                              • +
                                              • Prerequisites
                                              • +
                                              • Starting the Map Service
                                              • Using Geocode and Reverse Geocode Services
                                              • Using the Place Search Service
                                              • Using the Routing Service
                                              • @@ -57,8 +58,10 @@

                                                Warm-up

                                                Become familiar with the Maps Service API basics by learning about:

                                                  -
                                                • Initializing the Map Service -

                                                  Select a map provider, check available capabilities, fulfill the prerequisites, create the Maps Service instance, and destroy it when no longer needed.

                                                • +
                                                • Prerequisites +

                                                  Prepare your application to use the map service functionality.

                                                • +
                                                • Starting the Map Service +

                                                  Select a map provider, check available capabilities, create the Maps Service instance, and destroy it when no longer needed.

                                                • Using Geocode and Reverse Geocode Services

                                                  Get the geocode of a specified place, and the reverse geocode corresponding to specified geographical coordinates.

                                                • @@ -89,42 +92,49 @@

                                                  Prepare and send a set of extra preferences through a map service request to allow the map provider to generate a more accurate result.

                                                +

                                                Prerequisites

                                                - -

                                                Initializing the Map Service

                                                - -

                                                To start using the map service:

                                                +

                                                To enable your application to use the map service functionality:

                                                  -
                                                1. To use the functions and data types of the Maps Service API, include the <maps_service.h> header file in your application:

                                                  +
                                                2. +

                                                  To use the Maps Service API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

                                                  +
                                                  +<privileges>
                                                  +   <privilege>http://tizen.org/privilege/internet</privilege>
                                                  +</privileges>
                                                  +
                                                  +
                                                3. +
                                                4. To use the functions and data types of the Maps Service API, include the <maps_service.h> header file in your application:

                                                   #include <maps_service.h>
                                                   
                                                5. +
                                                + +

                                                Starting the Map Service

                                                +

                                                To start using the map service:

                                                +
                                                1. The Maps Service instance relies on a particular map provider. To get a list of available map providers, use the maps_service_foreach_provider() function.
                                                  -static bool 
                                                  +static bool
                                                   _maps_service_provider_info_cb(char* maps_provider, void* user_data)
                                                   {
                                                  -   // Handle the map provider name, passed as maps_provider
                                                  +    /* Handle the map provider name, passed as maps_provider */
                                                   
                                                  -   return bool;
                                                  +    return bool;
                                                   }
                                                   
                                                  -void 
                                                  +void
                                                   get_available_providers()
                                                   {
                                                  -   void *user_data = NULL;
                                                  -   const int error = maps_service_foreach_provider(_maps_service_provider_info_cb, user_data);
                                                  -
                                                  -   if (error == MAPS_ERROR_NONE) 
                                                  -   {
                                                  -      // Select a provider from the available_providers vector
                                                  -   } 
                                                  -   else 
                                                  -   {
                                                  -      // Error handling
                                                  -   }
                                                  +    void *user_data = NULL;
                                                  +    const int error = maps_service_foreach_provider(_maps_service_provider_info_cb, user_data);
                                                  +
                                                  +    if (error == MAPS_ERROR_NONE)
                                                  +        /* Select a provider from the available_providers vector */
                                                  +    else
                                                  +        /* Error handling */
                                                   }
                                                   
                                                2. @@ -146,11 +156,11 @@ error = maps_service_set_provider_key(maps, "XXXYYYZZZ");
                                                   bool supported = false;
                                                   
                                                  -// Check whether routing is available 
                                                  +/* Check whether routing is available */
                                                   error = maps_service_provider_is_service_supported(maps, MAPS_SERVICE_SEARCH_ROUTE, &supported);
                                                   const bool is_routing_supported = (error == MAPS_ERROR_NONE) ? supported : false;
                                                   
                                                  -// Check whether routing through specified waypoints is available
                                                  +/* Check whether routing through specified waypoints is available */
                                                   error = maps_service_provider_is_service_supported(maps, MAPS_SERVICE_SEARCH_ROUTE_WAYPOINTS, &supported);
                                                   const bool is_routing_waypoints_supported = (error == MAPS_ERROR_NONE) ? supported : false;
                                                   
                                                  @@ -159,70 +169,54 @@ const bool is_routing_waypoints_supported = (error == MAPS_ERROR_NONE) ? support
                                                3. Optionally, check which data features are available for the desired services using the maps_service_provider_is_data_supported() function:
                                                  -// Check whether route path data is supported
                                                  +/* Check whether route path data is supported */
                                                   error = maps_service_provider_is_data_supported(maps, MAPS_ROUTE_PATH, &supported);
                                                   const bool is_route_path_supported = (error == MAPS_ERROR_NONE) ? supported : false;
                                                  -if (is_route_path_supported) 
                                                  -{
                                                  -   // Use route path
                                                  -}
                                                  +if (is_route_path_supported)
                                                  +    /* Use route path */
                                                   
                                                  -// Check whether segment path data is supported
                                                  +/* Check whether segment path data is supported */
                                                   error = maps_service_provider_is_data_supported(maps, MAPS_ROUTE_SEGMENTS_PATH, &supported);
                                                   const bool is_route_segment_path_supported = (error == MAPS_ERROR_NONE) ? supported : false;
                                                  -if (is_route_segment_path_supported) 
                                                  -{
                                                  -   // Use segment path
                                                  -}
                                                  +if (is_route_segment_path_supported)
                                                  +    /* Use segment path */
                                                   
                                                  -// Check whether segment maneuver data is supported
                                                  +/* Check whether segment maneuver data is supported */
                                                   error = maps_service_provider_is_data_supported(maps, MAPS_ROUTE_SEGMENTS_MANEUVERS, &supported);
                                                   const bool is_route_segment_maneuvers_supported = (error == MAPS_ERROR_NONE) ? supported : false;
                                                  -if (is_route_segment_maneuvers_supported) 
                                                  -{
                                                  -   // Use segment maneuvers
                                                  -}
                                                  +if (is_route_segment_maneuvers_supported)
                                                  +    /* Use segment maneuvers */
                                                   

                                                  To check the availability of other data features, follow the same approach using the keys from the maps_service_data_e enumerator.

                                                4. Set general preferences, such as language and distance units, using the maps_service_set_preference() function:

                                                  -// Create a preference set instance
                                                  +/* Create a preference set instance */
                                                   maps_preference_h preference = NULL;
                                                   int error = maps_preference_create(&preference);
                                                  -if (error != MAPS_ERROR_NONE) 
                                                  -{
                                                  -   // Error handling
                                                  -}
                                                  +if (error != MAPS_ERROR_NONE)
                                                  +    /* Error handling */
                                                   
                                                  -// Set the distance unit preference
                                                  +/* Set the distance unit preference */
                                                   error = maps_preference_set_distance_unit(preference, MAPS_DISTANCE_UNIT_M);
                                                  -if (error != MAPS_ERROR_NONE) 
                                                  -{
                                                  -   // Error handling
                                                  -}
                                                  +if (error != MAPS_ERROR_NONE)
                                                  +    /* Error handling */
                                                   
                                                  -// Set the language preference
                                                  +/* Set the language preference */
                                                   error = maps_preference_set_language(preference, "en-US");
                                                  -if (error != MAPS_ERROR_NONE) 
                                                  -{
                                                  -   // Error handling
                                                  -}
                                                  +if (error != MAPS_ERROR_NONE)
                                                  +    /* Error handling */
                                                   
                                                  -// Apply the set of preferences for the map service
                                                  +/* Apply the set of preferences for the map service */
                                                   error = maps_service_set_preference(maps, preference);
                                                  -if (error != MAPS_ERROR_NONE) 
                                                  -{
                                                  -   // Error handling
                                                  -}
                                                  +if (error != MAPS_ERROR_NONE)
                                                  +    /* Error handling */
                                                   
                                                  -// Destroy the preference set instance
                                                  +/* Destroy the preference set instance */
                                                   error = maps_preference_destroy(preference);
                                                  -if (error != MAPS_ERROR_NONE) 
                                                  -{
                                                  -   // Error handling
                                                  -}
                                                  +if (error != MAPS_ERROR_NONE)
                                                  +    /* Error handling */
                                                   

                                                  Optionally, you can set the maximum amount of search results and a default country code using the maps_preference_set_max_results() and maps_preference_set_country_code() functions.

                                                  To set specific preferences for the map provider, use the maps_preference_set_property() function with key-value pairs, defined in the appropriate map provider documentation.

                                                  @@ -246,67 +240,59 @@ if (error != MAPS_ERROR_NONE)

                                                  To retrieve a geocode:

                                                    -
                                                  1. Make sure that your application has the http://tizen.org/privilege/internet privilege. -
                                                  2. Request the geocode:
                                                    • Use the maps_service_geocode() function for a request based on a free-formed address:
                                                      -// Search for geocode of the Samsung's campus "Digital City" in Suwon
                                                      -error = maps_service_geocode(maps, "Suwon, Digital City", preference, 
                                                      +/* Search for geocode of the Samsung's campus "Digital City" in Suwon */
                                                      +error = maps_service_geocode(maps, "Suwon, Digital City", preference,
                                                                                    __maps_service_geocode_cb, user_data, &request_id);
                                                       
                                                      -if (error != MAPS_ERROR_NONE) 
                                                      -{
                                                      -   // Error handling
                                                      -}
                                                      +if (error != MAPS_ERROR_NONE)
                                                      +    /* Error handling */
                                                       
                                                    • Use the maps_service_geocode_inside_area() function for a request inside a specified area:
                                                       maps_area_h bounds = NULL;
                                                      -// Use maps_area_create_rectangle() or maps_area_create_circle() to create geographic bounds for geocoding
                                                      +/* Use maps_area_create_rectangle() or maps_area_create_circle() to create geographic bounds for geocoding */
                                                       
                                                      -// Search for geocode of the Digital City within a specified geographic area
                                                      +/* Search for geocode of the Digital City within a specified geographic area */
                                                       error = maps_service_geocode_inside_area(maps, "Digital City", bounds, preference,
                                                                                                __maps_service_geocode_cb, user_data, &request_id);
                                                       
                                                      -if (error != MAPS_ERROR_NONE) 
                                                      -{
                                                      -   // Error handling
                                                      -}
                                                      +if (error != MAPS_ERROR_NONE)
                                                      +    /* Error handling */
                                                       
                                                    • Use the maps_service_geocode_by_structured_address() function for a request for a place, specified as a structured address:
                                                       maps_address_h address = NULL;
                                                      -// Use maps_address_create() to create an instance of an address
                                                      -// Then use maps_address_set_XXX() to initialize the address with the desired values
                                                      +/* Use maps_address_create() to create an instance of an address */
                                                      +/* Then use maps_address_set_XXX() to initialize the address with the desired values */
                                                       
                                                      -// Search for a geocode of a place, specified with a structured address 
                                                      -error = maps_service_geocode_by_structured_address(maps, address, preference, __maps_service_geocode_cb, 
                                                      +/* Search for a geocode of a place, specified with a structured address */
                                                      +error = maps_service_geocode_by_structured_address(maps, address, preference, __maps_service_geocode_cb,
                                                                                                          user_data, &request_id);
                                                       
                                                      -if (error != MAPS_ERROR_NONE) 
                                                      -{
                                                      -   // Error handling
                                                      -}
                                                      +if (error != MAPS_ERROR_NONE)
                                                      +    /* Error handling */
                                                       
                                                  3. Implement the __maps_service_geocode_cb() callback to receive the service response:
                                                    -static bool 
                                                    -__maps_service_geocode_cb(maps_error_e result, int request_id, int index, int total, 
                                                    +static bool
                                                    +__maps_service_geocode_cb(maps_error_e result, int request_id, int index, int total,
                                                                               maps_coordinates_h coordinates, void* user_data)
                                                     {
                                                    -   // Handle the obtained coordinate data
                                                    +    /* Handle the obtained coordinate data */
                                                     
                                                    -   // Release the results
                                                    -   maps_coordinates_destroy(coordinates);
                                                    +    /* Release the results */
                                                    +    maps_coordinates_destroy(coordinates);
                                                     
                                                    -   return true;
                                                    +    return true;
                                                     }
                                                     
                                                  4. @@ -317,27 +303,25 @@ __maps_service_geocode_cb(maps_error_e result, int request_id, int index, int to
                                                    1. To retrieve a reverse geocode of specified geographic coordinates, use the maps_service_reverse_geocode() function:
                                                      -// Obtain the reverse geocode with specified coordinates
                                                      +/* Obtain the reverse geocode with specified coordinates */
                                                       error = maps_service_reverse_geocode(maps, 37.257865, 127.053659, preference,
                                                                                            __maps_service_reverse_geocode_cb, user_data, &request_id);
                                                       
                                                      -if (error != MAPS_ERROR_NONE) 
                                                      -{
                                                      -   // Error handling
                                                      -}
                                                      +if (error != MAPS_ERROR_NONE)
                                                      +    /* Error handling */
                                                       
                                                    2. Implement the __maps_service_reverse_geocode_cb() callback to receive the service response:
                                                      -static void 
                                                      -__maps_service_reverse_geocode_cb(maps_error_e result, int request_id, int index, int total, 
                                                      +static void
                                                      +__maps_service_reverse_geocode_cb(maps_error_e result, int request_id, int index, int total,
                                                                                         maps_address_h address, void* user_data)
                                                       {
                                                      -   // Handle the obtained address
                                                      +    /* Handle the obtained address */
                                                       
                                                      -   // Release the results
                                                      -   maps_address_destroy(address);
                                                      +    /* Release the results */
                                                      +    maps_address_destroy(address);
                                                       }
                                                       
                                                    3. @@ -350,67 +334,59 @@ __maps_service_reverse_geocode_cb(maps_error_e result, int request_id, int index

                                                      To search for a place:

                                                        -
                                                      1. Make sure that your application has the http://tizen.org/privilege/internet privilege. -
                                                      2. Search for a place:
                                                        • Use the maps_service_search_place() function for a search within a specified distance around the center coordinates:
                                                           maps_coordinates_h position = NULL;
                                                          -// Create the coordinates with maps_coordinates_create()
                                                          +/* Create the coordinates with maps_coordinates_create() */
                                                           
                                                           int distance = 500;
                                                           error = maps_service_search_place(maps, position, distance, filter, preference,
                                                                                             __maps_service_search_place_cb, user_data, &request_id);
                                                           
                                                          -if (error != MAPS_ERROR_NONE) 
                                                          -{
                                                          -   // Error handling
                                                          -}
                                                          +if (error != MAPS_ERROR_NONE)
                                                          +    /* Error handling */
                                                           
                                                        • Use the maps_service_search_place_by_area() function for a search for a place within a specified geographic boundary:
                                                           maps_area_h boundary = NULL;
                                                          -// Create the boundary with maps_area_create_rectangle() or maps_area_create_circle() 
                                                          +/* Create the boundary with maps_area_create_rectangle() or maps_area_create_circle() */
                                                           
                                                          -error = maps_service_search_place_by_area(maps, boundary, filter, preference, 
                                                          +error = maps_service_search_place_by_area(maps, boundary, filter, preference,
                                                                                                     __maps_service_search_place_cb, user_data, &request_id);
                                                           
                                                          -if (error != MAPS_ERROR_NONE) 
                                                          -{
                                                          -   // Error handling
                                                          -}
                                                          +if (error != MAPS_ERROR_NONE)
                                                          +    /* Error handling */
                                                           
                                                        • Use the maps_service_search_place_by_address() function for a search for a place based on an address within a specified geographic boundary:
                                                           maps_area_h boundary = NULL;
                                                          -// Create the boundary with maps_area_create_rectangle() or maps_area_create_circle()
                                                          +/* Create the boundary with maps_area_create_rectangle() or maps_area_create_circle() */
                                                           
                                                           error = maps_service_search_place_by_address(maps, "Digital City", boundary, filter, preference,
                                                                                                        __maps_service_search_place_cb, user_data, &request_id);
                                                           
                                                          -if (error != MAPS_ERROR_NONE) 
                                                          -{
                                                          -   // Error handling
                                                          -}
                                                          +if (error != MAPS_ERROR_NONE)
                                                          +    /* Error handling */
                                                           
                                                      3. Implement the __maps_service_search_place_cb() callback to receive the service response:
                                                        -static bool 
                                                        -__maps_service_search_place_cb(maps_error_e error, int request_id, int index, int total, 
                                                        +static bool
                                                        +__maps_service_search_place_cb(maps_error_e error, int request_id, int index, int total,
                                                                                        maps_place_h place, void* user_data)
                                                         {
                                                        -   // Handle the obtained place data
                                                        +    /* Handle the obtained place data */
                                                         
                                                        -   // Release the results
                                                        -   maps_place_destroy(place);
                                                        +    /* Release the results */
                                                        +    maps_place_destroy(place);
                                                         
                                                        -   return true;
                                                        +    return true;
                                                         }
                                                         
                                                      4. @@ -423,56 +399,50 @@ __maps_service_search_place_cb(maps_error_e error, int request_id, int index, in

                                                        To query a route:

                                                          -
                                                        1. Make sure that your application has the http://tizen.org/privilege/internet privilege. -
                                                        2. Query the route:
                                                          • Use the maps_service_search_route() function for a route from one set of geographic coordinates to another:
                                                             maps_coordinates_h origin = NULL, destination = NULL;
                                                            -// Create the coordinates with maps_coordinates_create()
                                                            +/* Create the coordinates with maps_coordinates_create() */
                                                             
                                                            -error = maps_service_search_route(maps, origin, destination, preference, 
                                                            +error = maps_service_search_route(maps, origin, destination, preference,
                                                                                               __maps_service_search_route_cb, user_data, &request_id);
                                                             
                                                            -if (error != MAPS_ERROR_NONE) 
                                                            -{
                                                            -   // Error handling
                                                            -}
                                                            +if (error != MAPS_ERROR_NONE)
                                                            +    /* Error handling */
                                                             
                                                          • Use the maps_service_search_route_waypoints() function for a route passing through a specified set of waypoints:
                                                            -// Specify the number of waypoints
                                                            +/* Specify the number of waypoints */
                                                             const int waypoint_num = 5;
                                                             
                                                            -// Create an array with the waypoint coordinates 
                                                            +/* Create an array with the waypoint coordinates */
                                                             maps_coordinates_h* waypoint_list = NULL;
                                                             
                                                             error = maps_service_search_route_waypoints(maps, waypoint_list, waypoint_num, preference,
                                                                                                         __maps_service_search_route_cb, user_data, &request_id);
                                                             
                                                            -if (error != MAPS_ERROR_NONE) 
                                                            -{
                                                            -   // Error handling
                                                            -}
                                                            +if (error != MAPS_ERROR_NONE)
                                                            +    /* Error handling */
                                                             
                                                        3. Implement the __maps_service_search_route_cb() callback to receive the service response:
                                                          -static bool 
                                                          -__maps_service_search_route_cb(maps_error_e error, int request_id, int index, int total, 
                                                          +static bool
                                                          +__maps_service_search_route_cb(maps_error_e error, int request_id, int index, int total,
                                                                                          maps_route_h route, void* user_data)
                                                           {
                                                          -   // Handle the obtained route data
                                                          +    /* Handle the obtained route data */
                                                           
                                                          -   // Release the results 
                                                          -   maps_route_destroy(route);
                                                          +    /* Release the results */
                                                          +    maps_route_destroy(route);
                                                           
                                                          -   return true;
                                                          +    return true;
                                                           }
                                                           
                                                        4. @@ -482,13 +452,11 @@ __maps_service_search_route_cb(maps_error_e error, int request_id, int index, in

                                                          To cancel a geocode, place search, or routing request, use the maps_service_cancel_request() function:

                                                          -// Cancel the request with a specified ID
                                                          +/* Cancel the request with a specified ID */
                                                           error = maps_service_cancel_request(maps, request_id);
                                                           
                                                          -if (error != MAPS_ERROR_NONE) 
                                                          -{
                                                          -   // Error handling
                                                          -}
                                                          +if (error != MAPS_ERROR_NONE)
                                                          +    /* Error handling */
                                                           

                                                          Recognizing the Address Information

                                                          @@ -496,29 +464,25 @@ if (error != MAPS_ERROR_NONE)

                                                          The result of the reverse geocode request (maps_service_reverse_geocode()) is retrieved from the map service using the maps_service_reverse_geocode_cb() callback. The result is structured address data of the specified place.

                                                          Parse the address information using the following functions:

                                                          -// Obtain the building number 
                                                          +/* Obtain the building number */
                                                           char *building_number = NULL;
                                                           error = maps_address_get_building_number(address, &building_number);
                                                           
                                                          -if (error != MAPS_ERROR_NONE) 
                                                          -{
                                                          -   // Error handling
                                                          -}
                                                          +if (error != MAPS_ERROR_NONE)
                                                          +    /* Error handling */
                                                           
                                                          -// Use the building_number
                                                          +/* Use the building_number */
                                                           
                                                           free(building_number);
                                                           
                                                          -// Obtain the street name
                                                          +/* Obtain the street name */
                                                           char *street = NULL;
                                                           error = maps_address_get_street(address, &street);
                                                           
                                                          -if (error != MAPS_ERROR_NONE) 
                                                          -{
                                                          -   // Error handling
                                                          -}
                                                          +if (error != MAPS_ERROR_NONE)
                                                          +    /* Error handling */
                                                           
                                                          -// Use the street name
                                                          +/* Use the street name */
                                                           
                                                           free(street);
                                                           
                                                          @@ -547,7 +511,7 @@ free(street);
                                            @@ -560,15 +524,13 @@ free(street);
                                            • To obtain the place name, use the maps_place_get_name() function:
                                              -// Obtain the place name
                                              +/* Obtain the place name */
                                               char *name = NULL;
                                               error = maps_place_get_name(place, &name);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                              -// Use the place name
                                              +/* Use the place name */
                                               
                                               free(name);
                                               
                                              @@ -576,15 +538,13 @@ free(name);
                                            • To obtain the place location, use the maps_place_get_location() function:
                                              -// Obtain the place location
                                              +/* Obtain the place location */
                                               maps_coordinates_h location = NULL;
                                               error = maps_place_get_location(place, &location);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                              -// Use the place location
                                              +/* Use the place location */
                                               
                                               maps_coordinates_destroy(location);
                                               
                                              @@ -592,15 +552,13 @@ maps_coordinates_destroy(location);
                                            • To obtain the place rating, use the maps_place_get_rating() function:
                                              -// Obtain the place rating
                                              +/* Obtain the place rating */
                                               maps_place_rating_h rating = NULL;
                                               error = maps_place_get_rating(place, &rating);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                              -// Use the place rating
                                              +/* Use the place rating */
                                               
                                               maps_place_rating_destroy(rating);
                                               
                                              @@ -622,26 +580,24 @@ maps_place_rating_destroy(rating);
                                              1. To obtain a list of place categories, use the maps_place_foreach_category() function:
                                                -// Obtain a list of place categories 
                                                +/* Obtain a list of place categories */
                                                 error = maps_place_foreach_category(place, __maps_place_categories_cb, user_data);
                                                -if (error != MAPS_ERROR_NONE) 
                                                -{
                                                -   // Error handling
                                                -}
                                                +if (error != MAPS_ERROR_NONE)
                                                +    /* Error handling */
                                                 
                                              2. Implement the __maps_place_categories_cb() callback:
                                                -static bool 
                                                +static bool
                                                 __maps_place_categories_cb(int index, int total, maps_place_category_h category, void* user_data)
                                                 {
                                                -   // Handle the obtained place category data
                                                +    /* Handle the obtained place category data */
                                                 
                                                -   // Release the results
                                                -   maps_place_category_destroy(category);
                                                +    /* Release the results */
                                                +    maps_place_category_destroy(category);
                                                 
                                                -   return true;
                                                +    return true;
                                                 }
                                                 
                                              3. @@ -659,29 +615,27 @@ __maps_place_categories_cb(int index, int total, maps_place_category_h category,
                                                1. To iterate through the retrieved extra properties, use the maps_place_foreach_property() function:
                                                  -// Obtain the map provider-specific place data properties
                                                  +/* Obtain the map provider-specific place data properties */
                                                   error = maps_place_foreach_property(place, __maps_place_properties_cb, user_data);
                                                  -if (error != MAPS_ERROR_NONE) 
                                                  -{
                                                  -   // Error handling
                                                  -}
                                                  +if (error != MAPS_ERROR_NONE)
                                                  +    /* Error handling */
                                                   
                                                2. Implement the __maps_place_properties_cb() callback:
                                                  -static bool 
                                                  +static bool
                                                   __maps_place_properties_cb(int index, int total, char* key, void* value, void* user_data)
                                                   {
                                                  -   // Handle the obtained property:
                                                  -   // property_name: key
                                                  -   // property_value: value
                                                  +    /* Handle the obtained property: */
                                                  +    /* property_name: key */
                                                  +    /* property_value: value */
                                                   
                                                  -   // Release the property name and value
                                                  -   free(key);
                                                  -   free(value);
                                                  +    /* Release the property name and value */
                                                  +    free(key);
                                                  +    free(value);
                                                   
                                                  -   return true;
                                                  +    return true;
                                                   }
                                                   
                                                3. @@ -700,7 +654,7 @@ __maps_place_properties_cb(int index, int total, char* key, void* value, void* u
                                            @@ -713,15 +667,13 @@ __maps_place_properties_cb(int index, int total, char* key, void* value, void* u
                                            • To obtain the route ID, use the maps_route_get_route_id() function:
                                              -// Obtain the route ID
                                              +/* Obtain the route ID */
                                               char *id = NULL;
                                               error = maps_route_get_route_id(route, &id);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                              -// Use the route ID
                                              +/* Use the route ID */
                                               
                                               free(id);
                                               
                                              @@ -729,20 +681,16 @@ free(id);
                                            • To obtain the route origin and destination, use the maps_route_get_origin() and maps_route_get_destination() functions:
                                              -// Obtain the route origin and destination
                                              +/* Obtain the route origin and destination */
                                               maps_coordinates_h origin = NULL, destination = NULL;
                                               error = maps_route_get_origin(route, &origin);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               error = maps_route_get_destination(route, &destination);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                              -// Use the route origin and destination
                                              +/* Use the route origin and destination */
                                               
                                               maps_coordinates_destroy(origin);
                                               maps_coordinates_destroy(destination);
                                              @@ -751,15 +699,13 @@ maps_coordinates_destroy(destination);
                                               
                                               
                                            • To obtain the route total distance, use the maps_route_get_total_distance() function:
                                              -// Obtain the total route distance
                                              +/* Obtain the total route distance */
                                               double total_distance = .0;
                                               error = maps_route_get_total_distance(route, &total_distance);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                              -// Use the total route distance
                                              +/* Use the total route distance */
                                               
                                            @@ -778,22 +724,20 @@ if (error != MAPS_ERROR_NONE)
                                          35. To obtain the list of geographic points defining the route, use the maps_route_foreach_path() function:
                                             error = maps_route_foreach_path(route, __maps_route_path_cb, user_data);
                                            -if (error != MAPS_ERROR_NONE) 
                                            -{
                                            -   // Error handling
                                            -}
                                            +if (error != MAPS_ERROR_NONE)
                                            +    /* Error handling */
                                             

                                            Implement the __maps_route_path_cb() callback:

                                            -static bool 
                                            +static bool
                                             __maps_route_path_cb(int index, int total, maps_coordinates_h coordinates, void* user_data)
                                             {
                                            -   // Handle the obtained route path coordinates
                                            +    /* Handle the obtained route path coordinates */
                                             
                                            -   // Release the results
                                            -   maps_coordinates_destroy(coordinates);
                                            +    /* Release the results */
                                            +    maps_coordinates_destroy(coordinates);
                                             
                                            -   return true;
                                            +    return true;
                                             }
                                             
                                          36. @@ -802,21 +746,19 @@ __maps_route_path_cb(int index, int total, maps_coordinates_h coordinates, void*
                                             error = maps_route_foreach_segment(route, __maps_route_segment_cb, user_data);
                                             if (error != MAPS_ERROR_NONE)
                                            -{
                                            -   // Error handling
                                            -}
                                            +    /* Error handling */
                                             

                                            Implement the __maps_route_segment_cb() callback:

                                            -static bool 
                                            +static bool
                                             __maps_route_segment_cb(int index, int total, maps_route_segment_h segment, void* user_data)
                                             {
                                            -   // Handle the obtained route segment
                                            +    /* Handle the obtained route segment */
                                             
                                            -   // Release the results
                                            -   maps_route_segment_destroy(segment);
                                            +    /* Release the results */
                                            +    maps_route_segment_destroy(segment);
                                             
                                            -   return true;
                                            +    return true;
                                             }
                                             
                                            @@ -827,29 +769,27 @@ __maps_route_segment_cb(int index, int total, maps_route_segment_h segment, void
                                            1. To iterate through the retrieved extra properties, use the maps_route_foreach_property() function:
                                              -// Obtain the map provider-specific route data properties
                                              +/* Obtain the map provider-specific route data properties */
                                               error = maps_route_foreach_property(route, __maps_route_properties_cb, user_data);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                            2. Implement the __maps_route_properties_cb() callback:
                                              -static bool 
                                              +static bool
                                               __maps_route_properties_cb(int index, int total, char* key, void* value, void* user_data)
                                               {
                                              -   // Handle the obtained property:
                                              -   // property_name: key
                                              -   // property_value: value
                                              +    /* Handle the obtained property: */
                                              +    /* property_name: key */
                                              +    /* property_value: value */
                                               
                                              -   // Release the property name and value
                                              -   free(key);
                                              -   free(value);
                                              +    /* Release the property name and value */
                                              +    free(key);
                                              +    free(value);
                                               
                                              -   return true;
                                              +    return true;
                                               }
                                               
                                            3. @@ -867,29 +807,23 @@ __maps_route_properties_cb(int index, int total, char* key, void* value, void* u

                                              The example from Using the Place Search Service can be modified as follows to include the customized preferences:

                                              -// Create extra preferences for the place search service
                                              +/* Create extra preferences for the place search service */
                                               error = maps_preference_create(&preference);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               error = maps_preference_set_property(preference, MAPS_PLACE_FILTER_TYPE, "restaurant");
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                               maps_coordinates_h position = NULL;
                                              -// Create the coordinates with maps_coordinates_create()
                                              +/* Create the coordinates with maps_coordinates_create() */
                                               
                                               int distance = 500;
                                              -error = maps_service_search_place(maps, position, distance, filter, preference,  
                                              +error = maps_service_search_place(maps, position, distance, filter, preference,
                                                                                 __maps_service_search_place_cb, user_data, &request_id);
                                               
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                               maps_preference_destroy(preference);
                                               
                                              @@ -918,33 +852,25 @@ maps_preference_destroy(preference);

                                              The example from Using the Routing Service can be modified as follows to include the customized preferences:

                                              -// Create extra preferences for the routing service
                                              +/* Create extra preferences for the routing service */
                                               error = maps_preference_create(&preference);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               error = maps_preference_set_property(preference, MAPS_ROUTE_FREEFORM_ADDR_TO_AVOID, "Suwon, Digital City");
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               error = maps_preference_set_route_optimization(preference, MAPS_ROUTE_TYPE_SHORTEST);
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                               maps_coordinates_h origin = NULL, destination = NULL;
                                              -// Create the coordinates with maps_coordinates_create()
                                              +/* Create the coordinates with maps_coordinates_create() */
                                               
                                              -error = maps_service_search_route(maps, origin, destination, preference, 
                                              +error = maps_service_search_route(maps, origin, destination, preference,
                                                                                 __maps_service_search_route_cb, user_data, &request_id);
                                               
                                              -if (error != MAPS_ERROR_NONE) 
                                              -{
                                              -   // Error handling 
                                              -}
                                              +if (error != MAPS_ERROR_NONE)
                                              +    /* Error handling */
                                               
                                               maps_preference_destroy(preference);
                                               
                                              diff --git a/org.tizen.tutorials/html/native/messaging/email_tutorial_n.htm b/org.tizen.tutorials/html/native/messaging/email_tutorial_n.htm index 2af2548..7c54153 100644 --- a/org.tizen.tutorials/html/native/messaging/email_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/messaging/email_tutorial_n.htm @@ -23,7 +23,7 @@

                                              Content

                                              Related Info

                                              @@ -45,30 +45,32 @@

                                              Warm-up

                                              Become familiar with the Email API basics by learning about:

                                              +

                                              Prerequisites

                                              -

                                              Prerequisites

                                              -

                                              To use the notification, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file.

                                              -
                                              +

                                              To enable your application to use the email functionality:

                                              +
                                                +
                                              1. +

                                                To use the Email API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

                                                +
                                                 <privileges>
                                                    <privilege>http://tizen.org/privilege/email</privilege>
                                                 </privileges>
                                                 
                                                -

                                                Initializing the Email Service

                                                - -

                                                To initialize the email service for use:

                                                -
                                                1. To use the functions and data types of the Email API, include the <email.h> header file in your application:

                                                  +
                                                2. +
                                                3. +

                                                  Set up at least 1 email account on your device before sending an email.

                                                4. +
                                                5. To use the functions and data types of the Email API, include the <email.h> header file in your application:

                                                   #include <email.h>
                                                   

                                                  To ensure that an Email function has been executed properly, make sure that the return value is equal to EMAILS_ERROR_NONE.

                                                6. -
                                                7. -

                                                  Set up at least 1 email account on your device before sending an email.

                                                +

                                              The email service does not need any initialization or connection opening before the API usage.

                                              @@ -82,10 +84,8 @@ email_h msg; int error_code = EMAILS_ERROR_NONE; error_code = email_create_message(&msg); -if (error_code != EMAILS_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to create email message\n"); -} +if (error_code != EMAILS_ERROR_NONE) +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to create email message\n");

                                              The function return code defines whether the message creation succeeded. The EMAIL_ERROR_ACCOUNT_NOT_FOUND error is not related to the email service as such; it occurs if no email account has been configured on the device.

                                              @@ -95,93 +95,72 @@ if (error_code != EMAILS_ERROR_NONE)

                                              Add recipients to the email message one by one. You cannot add lists of recipients in one function call. Each address must be given as a character string with the address type (TO, CC, BCC) declared.

                                               error_code = email_add_recipient(msg, EMAIL_RECIPIENT_TYPE_TO, "example@mail.com");
                                              -if (error_code != EMAILS_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to add recipient\n");
                                              -}
                                              +if (error_code != EMAILS_ERROR_NONE)
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to add recipient\n");
                                               
                                            4. Add an attachment to the email message with a full path to the attachment file. Currently, files with size up to 10 MB are supported.

                                               error_code = email_add_attach(msg, "/full/path/to/attachment");
                                              -if (error_code != EMAILS_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to add attachment\n");
                                              -}
                                              +if (error_code != EMAILS_ERROR_NONE)
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to add attachment\n");
                                               
                                            5. Remove recipients or attachments.

                                              In both cases, all recipients or attachments are removed at once. It is not possible to remove one selected item.

                                               error_code = email_remove_all_recipients(msg);
                                              -if (error_code != EMAILS_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to add remove recipients\n");
                                              -}
                                              -error_code = email_remove_all_attachments (msg);
                                              -if (error_code != EMAILS_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to remove attachments\n");
                                              -}
                                              +if (error_code != EMAILS_ERROR_NONE)
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to add remove recipients\n");
                                              +error_code = email_remove_all_attachments(msg);
                                              +if (error_code != EMAILS_ERROR_NONE)
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to remove attachments\n");
                                               
                                          37. Save the email before sending it:
                                             error_code = email_save_message(msg);
                                            -if (error_code != EMAILS_ERROR_NONE) 
                                            -{
                                            -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to save email\n");
                                            -}
                                            +if (error_code != EMAILS_ERROR_NONE)
                                            +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to save email\n");
                                             
                                          38. Define and register the email sending status callback.

                                            Email sending is an asynchronous operation, and thus the sending status cannot be checked directly in the return code from the email_send_message() function. To receive notifications about sending success or failure, use a callback function.

                                            -static void 
                                            -email_send_status(email_h email, email_sending_e result, void *user_data) 
                                            +static void
                                            +email_send_status(email_h email, email_sending_e result, void *user_data)
                                             {
                                            -   if (result == EMAIL_SENDING_FAILED) 
                                            -   {
                                            -      // Error handling
                                            -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to send email\n");
                                            -   }
                                            -   else if (result == EMAIL_SENDING_SUCCEEDED) 
                                            -   {
                                            -      // Sending was successful
                                            -      dlog_print(DLOG_INFO, LOG_TAG, "Email sending finished with success\n");
                                            -   }
                                            +    if (result == EMAIL_SENDING_FAILED) {
                                            +        /* Error handling */
                                            +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to send email\n");
                                            +    } else if (result == EMAIL_SENDING_SUCCEEDED) {
                                            +        /* Sending was successful */
                                            +        dlog_print(DLOG_INFO, LOG_TAG, "Email sending finished with success\n");
                                            +    }
                                             }
                                             
                                             error_code = email_set_message_sent_cb(msg, email_send_status, NULL);
                                            -if (error_code != EMAILS_ERROR_NONE) 
                                            -{
                                            -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to set sending status callback\n");
                                            -}
                                            +if (error_code != EMAILS_ERROR_NONE)
                                            +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to set sending status callback\n");
                                             
                                          39. Send the email:
                                             error_code = email_send_message(msg, false);
                                            -if (error_code != EMAILS_ERROR_NONE) 
                                            -{
                                            -   dlog_print(DLOG_INFO, LOG_TAG, "");
                                            -}
                                            +if (error_code != EMAILS_ERROR_NONE)
                                            +    dlog_print(DLOG_INFO, LOG_TAG, "");
                                             
                                          40. When the message is sent or if sending is canceled and the message no longer needed, delete it using the email_destroy_message() function. The registered email sending status callback must also be unset using the email_unset_message_sent_cb() function.

                                             error_code = email_unset_message_sent_cb(msg);
                                            -if (error_code != EMAILS_ERROR_NONE) 
                                            -{
                                            -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to unset status callback\n");
                                            -}
                                            +if (error_code != EMAILS_ERROR_NONE)
                                            +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to unset status callback\n");
                                             
                                             error_code = email_destroy_message(msg);
                                            -if (error_code != EMAILS_ERROR_NONE) 
                                            -{
                                            -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to delete email message\n");
                                            -}
                                            +if (error_code != EMAILS_ERROR_NONE)
                                            +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to delete email message\n");
                                             
                                          41. @@ -207,4 +186,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/messaging/push_tutorial_n.htm b/org.tizen.tutorials/html/native/messaging/push_tutorial_n.htm index 0c44479..e70303f 100644 --- a/org.tizen.tutorials/html/native/messaging/push_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/messaging/push_tutorial_n.htm @@ -24,7 +24,6 @@

                                            Content

                                            • Prerequisites
                                            • -
                                            • Initializing the Push Service
                                            • Connecting to the Push Service
                                            • Registering with the Push Server
                                            • Notification management @@ -49,12 +48,24 @@

                                              This tutorial demonstrates how you can use the Tizen push service to allow applications in a mobile device to receive notifications through the Internet even when the applications are not running.

                                              +

                                              The following figure illustrates the architecture of the Tizen push service.

                                              +

                                              Figure: Tizen push service architecture

                                              +

                                              Tizen push service architecture

                                              +

                                              The following steps illustrate a typical scenario for using the push messaging service on a Tizen device:

                                              +
                                                +
                                              1. When an application is installed and launched, it sends a registration request to Tizen push server through the push service.
                                              2. +
                                              3. If the registration request is approved, the server sends a registration ID to the application through the push service.
                                              4. +
                                              5. The application sends the registration ID to the application server. This registration ID is used to identify the application installed in that particular device.
                                              6. +
                                              7. When the application server needs to send a push notification to the application in that particular device, it sends the notification together with the registration ID to the push server.
                                              8. +
                                              9. When the push server receives the notification and the registration ID, it checks which device has the application with the particular registration ID and then sends the notification to that device.
                                              10. +
                                              11. When the push service receives the notification and the registration ID, it sends the notification to the destination application.
                                              12. +

                                              Warm-up

                                              Become familiar with the Push API basics by learning about:

                                                -
                                              • Initializing the Push Service -

                                                Initialize the push service for use.

                                              • +
                                              • Prerequisites +

                                                Prepare your application to use the push functionality.

                                              • Connecting to the Push Service

                                                Establish a socket connection to the push service.

                                              • Registering with the Push Server @@ -72,28 +83,17 @@

                                                Prerequisites

                                                -

                                                To use the Push API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

                                                +

                                                To enable your application to use the push functionality:

                                                +
                                                  +
                                                1. +

                                                  To use the Push API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

                                                   <privileges>
                                                      <privilege>http://tizen.org/privilege/push</privilege>
                                                   </privileges>
                                                   
                                                  - -

                                                  Initializing the Push Service

                                                  - -

                                                  The following figure illustrates the architecture of the Tizen push service.

                                                  -

                                                  Figure: Tizen push service architecture

                                                  -

                                                  Tizen push service architecture

                                                  -

                                                  The following steps illustrate a typical scenario for using the push messaging service on a Tizen device:

                                                  -
                                                    -
                                                  1. When an application is installed and launched, it sends a registration request to Tizen push server through the push service.
                                                  2. -
                                                  3. If the registration request is approved, the server sends a registration ID to the application through the push service.
                                                  4. -
                                                  5. The application sends the registration ID to the application server. This registration ID is used to identify the application installed in that particular device.
                                                  6. -
                                                  7. When the application server needs to send a push notification to the application in that particular device, it sends the notification together with the registration ID to the push server.
                                                  8. -
                                                  9. When the push server receives the notification and the registration ID, it checks which device has the application with the particular registration ID and then sends the notification to that device.
                                                  10. -
                                                  11. When the push service receives the notification and the registration ID, it sends the notification to the destination application.
                                                  12. -
                                                  - +
                                                2. +
                                                3. Make sure the following requirements are fulfilled:

                                                  1. Internet access @@ -167,11 +167,9 @@
                                            Different map providers are capable of providing different sets of place data features. Some map providers can extend the place data features with extra properties that are not specified in the Maps Service API. Such properties are organized as a key-value storage where the keys are the names of the properties. -

                                            If your map provider does not support a specific feature, the get function for the feature returns an error. To prevent problems, you can check which data features are available in your map provider using the maps_service_provider_is_data_supported() function.

                                            +

                                            If your map provider does not support a specific feature, the get function for the feature returns an error. To prevent problems, you can check which data features are available in your map provider using the maps_service_provider_is_data_supported() function.

                                            Different map providers are capable of providing different sets of route data features. Some map providers can extend the route data features with extra properties that are not specified in the Maps Service API. Such properties are organized as a key-value storage where the keys are the names of the properties. -

                                            If your map provider does not support a specific feature, the get function for the feature returns an error. To prevent problems, you can check which data features are available in your map provider using the maps_service_provider_is_data_supported() function.

                                            +

                                            If your map provider does not support a specific feature, the get function for the feature returns an error. To prevent problems, you can check which data features are available in your map provider using the maps_service_provider_is_data_supported() function.

                                            +
                                          42. - -

                                            To define the required library and application set-up:

                                            -
                                              -
                                            1. To use the functions and data types of the Push API (in mobile and wearable applications), include the <push-service.h> header file to your application:

                                              +
                                            2. To use the functions and data types of the Push API, include the <push-service.h> header file to your application:

                                               #include <push-service.h>
                                              diff --git a/org.tizen.tutorials/html/native/messaging/sms_mms_tutorial_n.htm b/org.tizen.tutorials/html/native/messaging/sms_mms_tutorial_n.htm
                                              index cf76fa2..6b4764e 100644
                                              --- a/org.tizen.tutorials/html/native/messaging/sms_mms_tutorial_n.htm
                                              +++ b/org.tizen.tutorials/html/native/messaging/sms_mms_tutorial_n.htm
                                              @@ -23,7 +23,7 @@
                                                   

                                              Content

                                              @@ -45,29 +45,28 @@

                                              Warm-up

                                              Become familiar with the Messages API basics by learning about:

                                              -

                                              Prerequisites

                                              -

                                              To use the messages API, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file. -There are two privileges - message.read to fetch messages and message.write to send messages respectively. -

                                              + +

                                              Prerequisites

                                              + +

                                              To enable your application to use the messages functionality:

                                              +
                                                +
                                              1. +

                                                To use the Messages API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

                                                 <privileges>
                                                -    <privilege>http://tizen.org/privilege/message.read</privilege>
                                                -    <privilege>http://tizen.org/privilege/message.write</privilege>
                                                +   <privilege>http://tizen.org/privilege/message.read</privilege>
                                                +   <privilege>http://tizen.org/privilege/message.write</privilege>
                                                 </privileges>
                                                 
                                                - -

                                                Initializing the Messages Service

                                                - -

                                                To initialize the Messages service for use:

                                                - -
                                                1. To use the functions and data types of the Messages API (in mobile and wearable applications), include the <messages.h> header file in your application:

                                                  +
                                                2. +
                                                3. To use the functions and data types of the Messages API, include the <messages.h> header file in your application:

                                                   #include <messages.h>
                                                   
                                                4. @@ -80,10 +79,8 @@ int error_code; error_code = messages_open_service(&service_handle); -if (error_code != MESSAGES_ERROR_NONE) -{ -   // Error handling -} +if (error_code != MESSAGES_ERROR_NONE) +    /* Error handling */
                                            3. When a connection with the Messages service is no longer needed (or the application is exiting), call the messages_close_service() function for proper connection closing:

                                              @@ -103,21 +100,18 @@ service_handle = NULL;
                                              1. Within the callback, to print the message content (or to show it to the user in any other way), extract the message text, address, and type:

                                                -char *message = NULL, *address = NULL;
                                                +char *message = NULL;
                                                +char *address = NULL;
                                                 messages_recipient_type_e rtype;
                                                 int error_code = MESSAGES_ERROR_NONE;
                                                 
                                                 error_code = messages_get_text(msg, &message);
                                                -if (error_code != MESSAGES_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get message content");
                                                -}
                                                +if (error_code != MESSAGES_ERROR_NONE)
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get message content");
                                                 
                                                 error_code = messages_get_address(msg, 0, &address, &rtype);
                                                -if (error_code != MESSAGES_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get recipient address");
                                                -}
                                                +if (error_code != MESSAGES_ERROR_NONE)
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get recipient address");
                                                 
                                                 messages_message_type_e mtype = MESSAGES_TYPE_UNKNOWN;
                                                 messages_get_message_type(msg, &mtype);
                                                @@ -125,16 +119,13 @@ messages_get_message_type(msg, &mtype);
                                                 
                                                 
                                              2. For MMS messages, the subject and attachments attributes exist and can be extracted from the found message:

                                                -if (MESSAGES_TYPE_MMS == mtype) 
                                                -{
                                                -   char *subject = NULL;
                                                -   error_code = messages_mms_get_subject(msg, &subject);
                                                -   if (error_code != MESSAGES_ERROR_NONE) 
                                                -   {
                                                -      dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get MMS subject");
                                                -   }
                                                -   int atcount = 0;
                                                -   messages_mms_get_attachment_count(msg, &atcount);
                                                +if (MESSAGES_TYPE_MMS == mtype) {
                                                +    char *subject = NULL;
                                                +    error_code = messages_mms_get_subject(msg, &subject);
                                                +    if (error_code != MESSAGES_ERROR_NONE)
                                                +        dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get MMS subject");
                                                +    int atcount = 0;
                                                +    messages_mms_get_attachment_count(msg, &atcount);
                                                 }
                                                 
                                              3. @@ -157,18 +148,14 @@ free(address);
                                                 int error_code;
                                                 error_code = messages_open_service(&service_handle);
                                                -if (error_code != MESSAGES_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to open connection");
                                                -}
                                                +if (error_code != MESSAGES_ERROR_NONE)
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to open connection");
                                                 
                                                 error_code = messages_foreach_message(service_handle, MESSAGES_MBOX_ALL,
                                                                                       MESSAGES_TYPE_SMS, NULL, NULL, 0, 0,
                                                                                       messages_search_callback, NULL);
                                                -if (error_code != MESSAGES_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Messages searching failed");
                                                -}
                                                +if (error_code != MESSAGES_ERROR_NONE)
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Messages searching failed");
                                                 
                                                 messages_close_service(service_handle);
                                                 
                                              @@ -183,73 +170,57 @@ messages_close_service(service_handle); int error_code; messages_message_h msg_hndl = NULL; -// Create an SMS message handle +/* Create an SMS message handle */ error_code = messages_create_message(MESSAGES_TYPE_SMS, &msg_hndl); -if (error_code != MESSAGES_ERROR_NONE) -{ -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to create message"); -} +if (error_code != MESSAGES_ERROR_NONE) +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to create message");
                                            4. Define the recipients and message body.

                                              Functions for setting the recipient address and the message body (the message text) are the same for SMS and MMS.

                                               error_code = messages_add_address(msg_hndl, "123456789", MESSAGES_RECIPIENT_TO);
                                              -if (error_code != MESSAGES_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to add recipient address");
                                              -}
                                              +if (error_code != MESSAGES_ERROR_NONE)
                                              +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to add recipient address");
                                               
                                               error_code = messages_set_text(msg_hndl, __PRETTY_FUNCTION__);
                                              -if (error_code != MESSAGES_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to set message text");
                                              -}
                                              +if (error_code != MESSAGES_ERROR_NONE)
                                              +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to set message text");
                                               
                                            5. Set a subject and add an attachment for an MMS message (note that MMS sending is not supported on the Emulator).
                                              • Set a message subject:

                                                 error_code = messages_mms_set_subject(msg_hndl, "MMS test");
                                                -if (error_code != MESSAGES_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to set MMS subject");
                                                -}
                                                +if (error_code != MESSAGES_ERROR_NONE)
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to set MMS subject");
                                                 
                                              • Add attachments with their absolute path in the device file system. When adding the attachment, give the attachment type. Possible attachment types are image, audio, and video.

                                                -error_code = messages_mms_add_attachment(g_message, MESSAGES_MEDIA_IMAGE, 
                                                +error_code = messages_mms_add_attachment(g_message, MESSAGES_MEDIA_IMAGE,
                                                                                          "/path/to/image/file");
                                                -if (error_code != MESSAGES_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to add attachment to MMS");
                                                -}
                                                +if (error_code != MESSAGES_ERROR_NONE)
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to add attachment to MMS");
                                                 
                                            6. Send the message.
                                              1. Define a callback for the messages_send_message() function. You can use the callback to let the messaging service inform you about the message sending status. Use the first parameter to determine whether the sending succeeded:

                                                -static void 
                                                +static void
                                                 sent_msg_cb(messages_sending_result_e result, void *user_data)
                                                 {
                                                -   if (MESSAGES_SENDING_SUCCEEDED == result) 
                                                -   {
                                                -      dlog_print(DLOG_DEBUG, LOG_TAG, "Message sending succeeded");
                                                -   }
                                                -   else 
                                                -   {
                                                -      dlog_print(DLOG_DEBUG, LOG_TAG, "Message sending failed");
                                                -   }
                                                +    if (MESSAGES_SENDING_SUCCEEDED == result)
                                                +        dlog_print(DLOG_DEBUG, LOG_TAG, "Message sending succeeded");
                                                +    else
                                                +        dlog_print(DLOG_DEBUG, LOG_TAG, "Message sending failed");
                                                 }
                                                 
                                              2. If the connection to the messaging service is open (you have the service_handle handle) and the message itself (msg_hndl) is successfully created, send the message using the messages_send_message() function:

                                                -error_code = messages_send_message(service_handle, msg_hndl, true, 
                                                +error_code = messages_send_message(service_handle, msg_hndl, true,
                                                                                    sent_msg_cb, NULL);
                                                -if (error_code != MESSAGES_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to send message");
                                                -}
                                                +if (error_code != MESSAGES_ERROR_NONE)
                                                +    dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to send message");
                                                 
                                            diff --git a/org.tizen.tutorials/html/native/multimedia/audio_io_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/audio_io_tutorial_n.htm index 4cb5edf..9a3621a 100644 --- a/org.tizen.tutorials/html/native/multimedia/audio_io_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/audio_io_tutorial_n.htm @@ -22,7 +22,7 @@

                                            Content

                                            @@ -48,9 +48,8 @@

                                            Become familiar with the Audio I/O and Sound Manager API basics by learning about:

                                              -
                                            • Initializing Audio Devices -

                                              Initialize the audio input and output devices for use.

                                              -
                                            • +
                                            • Prerequisites +

                                              Prepare your application to use the audio input and output functionalities.

                                            • Managing Synchronous Recording and Playback

                                              Using a synchronous API, record an audio sample from the audio input device, play the recorded audio sample through the audio output device, and modify the volume in the recorded audio sample.

                                            • @@ -59,31 +58,32 @@
                                            -

                                            Initializing Audio Devices

                                            +

                                            Prerequisites

                                            -

                                            To initialize the audio input and output devices for use:

                                            +

                                            To enable your application to use the audio input and output functionalities:

                                            1. To use the functions and data types of the Audio I/O (in mobile and wearable applications) and Sound Manager (in mobile and wearable applications) APIs, include the <audio_io.h> and <sound_manager.h> header files in your application:

                                               #include <audio_io.h>
                                               #include <sound_manager.h>
                                              -
                                            2. + +
                                            3. To initialize the audio input and output devices, use the audio_in_create() and audio_out_create() functions:

                                              -// Define the sample rate for recording audio
                                              +/* Define the sample rate for recording audio */
                                               #define SAMPLE_RATE 44100
                                               
                                              -// Declare the variable used for checking function results
                                              +/* Declare the variable used for checking function results */
                                               audio_io_error_e error_code;
                                               
                                              -// Initialize the audio input device
                                              +/* Initialize the audio input device */
                                               audio_in_h input;
                                               
                                               error_code = audio_in_create(SAMPLE_RATE, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, &input);
                                               
                                              -// Initialize the audio output device
                                              +/* Initialize the audio output device */
                                               audio_out_h output;
                                               
                                               error_code = audio_out_create(SAMPLE_RATE, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_SYSTEM, &output);
                                              @@ -170,7 +170,9 @@ error_code = audio_in_get_sample_type(input, &sample_type);
                                               
                                            4. Calculate the buffer size based on the retrieved information:

                                              -
                                              int buffer_size = SAMPLE_RATE * (channel == AUDIO_CHANNEL_STEREO ? 2 : 1) * (sample_type == AUDIO_SAMPLE_TYPE_S16_LE ? 2 : 1);
                                              +
                                              +int buffer_size = SAMPLE_RATE * (channel == AUDIO_CHANNEL_STEREO ? 2 : 1) * (sample_type == AUDIO_SAMPLE_TYPE_S16_LE ? 2 : 1);
                                              +
                                            5. @@ -184,7 +186,9 @@ buffer_size *= RECORDING_SEC;

                                              After determining the required buffer size, allocate the memory to the buffer using the malloc() function:

                                              -
                                              void *buffer = malloc(buffer_size);
                                              +
                                              +void *buffer = malloc(buffer_size);
                                              +

                                              You have created the local buffer for storing the audio data. You can now start the synchronous recording process.

                                              @@ -202,7 +206,7 @@ ecore_thread_run(synchronous_playback, NULL, NULL, NULL);

                                              Prepare the audio input device and start the recording process using the audio_in_prepare() function:

                                              -// Prepare the audio input device (starts the hardware recording process)
                                              +/* Prepare the audio input device (starts the hardware recording process) */
                                               error_code = audio_in_prepare(input);
                                               
                                            6. @@ -211,7 +215,7 @@ error_code = audio_in_prepare(input);
                                            7. Copy the audio data from the internal input buffer to the local buffer using the audio_in_read() function:

                                              -// Copy the audio data from the internal input buffer to the local buffer
                                              +/* Copy the audio data from the internal input buffer to the local buffer */
                                               int bytes_number = audio_in_read(input, buffer, buffer_size);
                                               
                                              @@ -228,19 +232,20 @@ int bytes_number = audio_in_read(input, buffer, buffer_size);
                                            8. Stop the recording process using the audio_in_unprepare() function:

                                              -// Stop the hardware recording process
                                              +/* Stop the hardware recording process */
                                               error_code = audio_in_unprepare(input);
                                               
                                            9. After you have finished working with the audio input device, deinitialize it using the audio_in_destroy() function:

                                              -
                                              // Deinitialize the audio input device
                                              +
                                              +/* Deinitialize the audio input device */
                                               error_code = audio_in_destroy(input);
                                               
                                            10. Prepare the audio output device and start the playback process using the audio_out_prepare() function:

                                              -// Prepare the audio output device (starts the hardware playback process)
                                              +/* Prepare the audio output device (starts the hardware playback process) */
                                               error_code = audio_out_prepare(output);
                                               
                                              @@ -250,7 +255,7 @@ error_code = audio_out_prepare(output);
                                            11. To start playing the recorded audio, copy the audio data from the local buffer to the internal output buffer using the audio_out_write() function:

                                              -// Copy the audio data from the local buffer to the internal output buffer
                                              +/* Copy the audio data from the local buffer to the internal output buffer */
                                               int bytes_number = audio_out_write(output, buffer, buffer_size);
                                               

                                              The returned value represents the number of bytes written to the internal output buffer. A negative value represents an error code.

                                              @@ -259,19 +264,20 @@ int bytes_number = audio_out_write(output, buffer, buffer_size);
                                            12. After all data has been copied to the internal output buffer, release the memory allocated to the local buffer using the free() function:

                                              -// Release the memory allocated to the local buffer
                                              +/* Release the memory allocated to the local buffer */
                                               free(buffer);
                                               
                                            13. Stop the playback process using the audio_out_unprepare() function:

                                              -// Stop the hardware playback process
                                              +/* Stop the hardware playback process */
                                               error_code = audio_out_unprepare(output);
                                               
                                            14. After you have finished working with the audio output device, deinitialize it using the audio_out_destroy() function:

                                              -
                                              // Deinitialize the audio output device
                                              +
                                              +/* Deinitialize the audio output device */
                                               error_code = audio_out_destroy(output);
                                               
                                            @@ -298,47 +304,45 @@ error_code = audio_out_destroy(output); void modify_sound() { -   // Retrieve the sample type of the input -   audio_sample_type_e sample_type; - -   int error_code = audio_in_get_sample_type(input, &sample_type); -   if (error_code != AUDIO_IO_ERROR_NONE) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_get_sample_type() failed! Error code = %d", error_code); - -      return; -   } - -   uint8_t *index = (uint8_t*)buffer; -   while (index < (((uint8_t*)buffer)+buffer_size)) -   { -      if (AUDIO_SAMPLE_TYPE_S16_LE == sample_type) -      { -         // Use the int16_t type, because it is 2 bytes long -         int16_t *value = (int16_t*)index; - -         // Make the sample louder -         int32_t tmp = (*value) * 8; // Why not 8 times louder? (on dB scale even much louder) -         if (tmp > MAX_2BYTES_SIGNED) tmp = MAX_2BYTES_SIGNED; -         if (tmp < MIN_2BYTES_SIGNED) tmp = MIN_2BYTES_SIGNED; -         (*value) = tmp; -      } -      else -      { -         // Use the uint8_t type, because it is 1 byte long -         uint8_t *value = (uint8_t*)index; - -         // Make the sample louder -         uint16_t tmp = (*value) * 8; // Why not 8 times louder? (on dB scale even much louder) -         if (tmp > 255) tmp = 255; -         (*value) = tmp; -      } - -      // Go to the next sample -      index += sample_type == AUDIO_SAMPLE_TYPE_S16_LE ? 2 : 1; -   } - -   dlog_print(DLOG_DEBUG, LOG_TAG, "Volume of the synchronous recording increased."); +    /* Retrieve the sample type of the input */ +    audio_sample_type_e sample_type; + +    int error_code = audio_in_get_sample_type(input, &sample_type); +    if (error_code != AUDIO_IO_ERROR_NONE) { +        dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_get_sample_type() failed! Error code = %d", error_code); + +        return; +    } + +    uint8_t *index = (uint8_t*)buffer; +    while (index < (((uint8_t*)buffer)+buffer_size)) { +        if (AUDIO_SAMPLE_TYPE_S16_LE == sample_type) { +            /* Use the int16_t type, because it is 2 bytes long */ +            int16_t *value = (int16_t*)index; + +            /* Make the sample louder */ +            int32_t tmp = (*value) * 8; /* Why not 8 times louder? (on dB scale even much louder) */ +            if (tmp > MAX_2BYTES_SIGNED) +                tmp = MAX_2BYTES_SIGNED; +            if (tmp < MIN_2BYTES_SIGNED) +                tmp = MIN_2BYTES_SIGNED; +            (*value) = tmp; +        } else { +            /* Use the uint8_t type, because it is 1 byte long */ +            uint8_t *value = (uint8_t*)index; + +            /* Make the sample louder */ +            uint16_t tmp = (*value) * 8; /* Why not 8 times louder? (on dB scale even much louder) */ +            if (tmp > 255) +                tmp = 255; +            (*value) = tmp; +        } + +        /* Go to the next sample */ +        index += sample_type == AUDIO_SAMPLE_TYPE_S16_LE ? 2 : 1; +    } + +    dlog_print(DLOG_DEBUG, LOG_TAG, "Volume of the synchronous recording increased."); } @@ -364,7 +368,7 @@ modify_sound()
                                            1. Set the callback function using the audio_in_set_stream_cb() function. Use this function before calling the audio_in_prepare() function, because otherwise the callback function is never invoked.

                                              -// Set a callback function that is invoked asynchronously for each chunk of recorded audio
                                              +/* Set a callback function that is invoked asynchronously for each chunk of recorded audio */
                                               error_code = audio_in_set_stream_cb(input, _audio_io_stream_read_cb, NULL);
                                               
                                            2. @@ -375,19 +379,17 @@ error_code = audio_in_set_stream_cb(input, _audio_io_stream_read_cb, NULL);
                                               #include <storage.h>
                                               
                                              -// Prepare the file where the recorded audio data is stored
                                              +/* Prepare the file where the recorded audio data is stored */
                                               char io_stream_w_path[200];
                                               char *storage_path;
                                              -// You can find the storage ID using the storage_foreach_device_supported() function
                                              +/* You can find the storage ID using the storage_foreach_device_supported() function */
                                               int error = storage_get_directory(storage_id, STORAGE_DIRECTORY_SOUNDS, &storage_path);
                                               snprintf(io_stream_w_path, 200, "%s/%s", storage_path, "pcm_w.raw");
                                               free(storage_path);
                                               
                                               FILE* fp_w = fopen(io_stream_w_path, "w");
                                               if (!fp_w)
                                              -{
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "fopen() function failed while opening %s file!", io_stream_w_path);
                                              -}
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "fopen() function failed while opening %s file!", io_stream_w_path);
                                               

                                              The storage_get_directory() function of the Storage API (in mobile and wearable applications) retrieves the storage path based on the storage ID. To retrieve the storage ID, use the storage_foreach_device_supported() function of the Storage API.

                                              @@ -396,7 +398,7 @@ if (!fp_w)

                                              Prepare the audio input device and start the recording process using the audio_in_prepare() function:

                                              -// Prepare the audio input device (starts the hardware recording process)
                                              +/* Prepare the audio input device (starts the hardware recording process) */
                                               error_code = audio_in_prepare(input);
                                               
                                              @@ -412,33 +414,29 @@ error_code = audio_in_prepare(input);
                                            -// Callback invoked for each chunk of recorded audio
                                            +/* Callback invoked for each chunk of recorded audio */
                                             void
                                             _audio_io_stream_read_cb(audio_in_h handle, size_t nbytes, void *userdata)
                                             {
                                            -   const void * buffer = NULL;
                                            -
                                            -   if (nbytes > 0)
                                            -   {
                                            -      // Retrieve a pointer to the internal input buffer and the number of recorded audio data bytes
                                            -      int error_code = audio_in_peek(handle, &buffer, &nbytes);
                                            -      if (error_code != AUDIO_IO_ERROR_NONE)
                                            -      {
                                            -         dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_peek() failed! Error code = %d", error_code);
                                            -
                                            -         return;
                                            -      }
                                            -
                                            -      // Store the recorded audio data in the file
                                            -      fwrite(buffer, sizeof(char), nbytes, fp_w);
                                            -
                                            -      // Remove the recorded audio data from the internal input buffer
                                            -      error_code = audio_in_drop(handle);
                                            -      if (error_code != AUDIO_IO_ERROR_NONE)
                                            -      {
                                            -         dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_drop() failed! Error code = %d", error_code);
                                            -      }
                                            -   }
                                            +    const void * buffer = NULL;
                                            +
                                            +    if (nbytes > 0) {
                                            +        /* Retrieve a pointer to the internal input buffer and the number of recorded audio data bytes */
                                            +        int error_code = audio_in_peek(handle, &buffer, &nbytes);
                                            +        if (error_code != AUDIO_IO_ERROR_NONE) {
                                            +            dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_peek() failed! Error code = %d", error_code);
                                            +
                                            +            return;
                                            +        }
                                            +
                                            +        /* Store the recorded audio data in the file */
                                            +        fwrite(buffer, sizeof(char), nbytes, fp_w);
                                            +
                                            +        /* Remove the recorded audio data from the internal input buffer */
                                            +        error_code = audio_in_drop(handle);
                                            +        if (error_code != AUDIO_IO_ERROR_NONE)
                                            +            dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_drop() failed! Error code = %d", error_code);
                                            +    }
                                             }
                                             
                                          @@ -450,7 +448,7 @@ _audio_io_stream_read_cb(audio_in_h handle, size_t nbytes, void *userdata)
                                          1. Stop the recording process using the audio_in_unprepare() function:

                                            -// Stop the hardware recording process
                                            +/* Stop the hardware recording process */
                                             error_code = audio_in_unprepare(input);
                                             

                                            The device no longer invokes the callback function.

                                            @@ -458,20 +456,21 @@ error_code = audio_in_unprepare(input);
                                          2. If you no longer need asynchronous recording, or if you want to set the callback function separately for each asynchronous recording session, unset the callback function using the audio_in_unset_stream_cb() function:

                                            -// Unset the callback function used for asynchronous recording
                                            +/* Unset the callback function used for asynchronous recording */
                                             error_code = audio_in_unset_stream_cb(input);
                                             
                                          3. After you have finished working with the audio input device, deinitialize it using the audio_in_destroy() function:

                                            -
                                            // Deinitialize the audio input device
                                            +
                                            +/* Deinitialize the audio input device */
                                             error_code = audio_in_destroy(input);
                                             
                                          4. Close the file where the recorded audio is stored using the fclose() function:

                                            -// Close the file used for asynchronous recording
                                            +/* Close the file used for asynchronous recording */
                                             error_code = fclose(fp_w);
                                             fp_w = NULL;
                                             
                                            @@ -489,7 +488,7 @@ fp_w = NULL;

                                            Set the callback function using the audio_out_set_stream_cb() function:

                                            -// Set a callback function that is invoked asynchronously for each chunk of stored (recorded) audio
                                            +/* Set a callback function that is invoked asynchronously for each chunk of stored (recorded) audio */
                                             error_code = audio_out_set_stream_cb(output, _audio_io_stream_write_cb, NULL);
                                             
                                          5. @@ -499,10 +498,10 @@ error_code = audio_out_set_stream_cb(output, _audio_io_stream_write_cb, NULL);
                                             #include <storage.h>
                                             
                                            -// Prepare the file where the recorded audio data is stored
                                            +/* Prepare the file where the recorded audio data is stored */
                                             char io_stream_r_path[200];
                                             char *storage_path;
                                            -// You can find the storage ID using the storage_foreach_device_supported() function
                                            +/* You can find the storage ID using the storage_foreach_device_supported() function */
                                             int error = storage_get_directory(storage_id, STORAGE_DIRECTORY_SOUNDS, &storage_path);
                                             snprintf(io_stream_r_path, 200, "%s/%s", storage_path, "pcm_w.raw");
                                             free(storage_path);
                                            @@ -516,7 +515,7 @@ FILE* fp_r = fopen(io_stream_r_path, "r");
                                             

                                            Prepare the audio output device and start the playback process using the audio_out_prepare() function:

                                            -// Prepare the audio output device (starts the hardware playback process)
                                            +/* Prepare the audio output device (starts the hardware playback process) */
                                             error_code = audio_out_prepare(output);
                                             

                                            The hardware device prepares its internal output buffer for playback.

                                            @@ -537,32 +536,29 @@ error_code = audio_out_prepare(output);
                                          -// Callback invoked for each chunk of stored (recorded) audio
                                          +/* Callback invoked for each chunk of stored (recorded) audio */
                                           void
                                           _audio_io_stream_write_cb(audio_out_h handle, size_t nbytes, void *userdata)
                                           {
                                          -   char * buffer = NULL;
                                          +    char * buffer = NULL;
                                           
                                          -   if (nbytes > 0)
                                          -   {
                                          -      // Allocate and reset a local buffer for reading the audio data from the file
                                          -      buffer = malloc(nbytes);
                                          -      memset(buffer, 0, nbytes);
                                          +    if (nbytes > 0) {
                                          +        /* Allocate and reset a local buffer for reading the audio data from the file */
                                          +        buffer = malloc(nbytes);
                                          +        memset(buffer, 0, nbytes);
                                           
                                          -      // Read audio data from the file and store it in the local buffer
                                          -      fread(buffer, sizeof(char), nbytes, fp_r);
                                          +        /* Read audio data from the file and store it in the local buffer */
                                          +        fread(buffer, sizeof(char), nbytes, fp_r);
                                           
                                          -      // Copy the audio data from the local buffer to the internal output buffer (starts playback)
                                          -      int data_size = audio_out_write(handle, buffer, nbytes);
                                          +        /* Copy the audio data from the local buffer to the internal output buffer (starts playback) */
                                          +        int data_size = audio_out_write(handle, buffer, nbytes);
                                           
                                          -      if (data_size < 0)
                                          -      {
                                          -         dlog_print(DLOG_ERROR, LOG_TAG, "audio_out_write() failed! Error code = %d", data_size);
                                          -      }
                                          +        if (data_size < 0)
                                          +            dlog_print(DLOG_ERROR, LOG_TAG, "audio_out_write() failed! Error code = %d", data_size);
                                           
                                          -      // Release the memory allocated to the local buffer
                                          -      free(buffer);
                                          -   }
                                          +        /* Release the memory allocated to the local buffer */
                                          +        free(buffer);
                                          +    }
                                           }
                                           
                                        @@ -573,7 +569,7 @@ _audio_io_stream_write_cb(audio_out_h handle, size_t nbytes, void *userdata)
                                        1. Stop the playback process using the audio_out_unprepare() function:

                                          -// Stop the hardware playback process
                                          +/* Stop the hardware playback process */
                                           error_code = audio_out_unprepare(output);
                                           

                                          The device no longer invokes the callback function.

                                          @@ -582,20 +578,21 @@ error_code = audio_out_unprepare(output);

                                          If you no longer need asynchronous playback, or if you want to set the callback function separately for each asynchronous playback session, unset the callback function using the audio_out_unset_stream_cb() function:

                                          -// Unset the callback function used for asynchronous playback
                                          +/* Unset the callback function used for asynchronous playback */
                                           error_code = audio_out_unset_stream_cb(output);
                                           
                                        2. After you have finished working with the audio output device, deinitialize it using the audio_out_destroy() function:

                                          -
                                          // Deinitialize the audio output device
                                          +
                                          +/* Deinitialize the audio output device */
                                           error_code = audio_out_destroy(output);
                                           
                                        3. Close the file where the recorded audio is stored using the fclose() function:

                                          -// Close the file used for asynchronous playback
                                          +/* Close the file used for asynchronous playback */
                                           error_code = fclose(fp_r);
                                           fp_r = NULL;
                                           
                                          diff --git a/org.tizen.tutorials/html/native/multimedia/camera_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/camera_tutorial_n.htm index b4b7ade..9a04455 100644 --- a/org.tizen.tutorials/html/native/multimedia/camera_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/camera_tutorial_n.htm @@ -22,7 +22,8 @@

                                          Content

                                            -
                                          • Initializing the Camera
                                          • +
                                          • Prerequisites
                                          • +
                                          • Configuring the Camera and its Callbacks
                                          • Setting the Display for the Camera Preview
                                          • Taking a Photo
                                          • Setting Camera Attributes
                                          • @@ -48,8 +49,10 @@

                                            Become familiar with the Camera API basics by learning about:

                                            -

                                            Initializing the Camera

                                            +

                                            Prerequisites

                                            -

                                            To initialize the camera for use:

                                            +

                                            To enable your application to use the camera functionality:

                                              -
                                            1. -

                                              To use the functions and data types of the Camera API (in mobile and wearable applications), include the <camera.h> header file in your application:

                                              -
                                               #include <camera.h>
                                               
                                              -
                                            2. -
                                            3. Create the camera handle.
                                            4. -
                                            5. Configure the camera.
                                            6. -
                                            7. Handle the camera preview and auto-focus callbacks.
                                            8. -
                                            - -

                                            Creating the Camera Handle

                                            - -

                                            To create the camera handle:

                                            - -
                                              -
                                            1. -

                                              Create a structure for storing the global data related to the camera handle. In this tutorial, the camdata structure is used to store the g_camera variable, which is the camera handle.

                                              -typedef struct
                                              -_camdata
                                              -{
                                              -   Evas_Object *win;
                                              -   Evas_Object *rect;
                                              -   Evas *evas;
                                              -   camera_h g_camera; // Camera handle
                                              -} camdata;
                                              +struct _camdata {
                                              +    Evas_Object *win;
                                              +    Evas_Object *rect;
                                              +    Evas *evas;
                                              +    camera_h g_camera; /* Camera handle */
                                              +};
                                              +typedef struct _camdata camdata;
                                               
                                               static camdata cam_data;
                                               
                                              -
                                            2. -
                                            3. -

                                              Create 2 auxiliary variables for controlling whether taking photos (g_enable_shot) and auto-focusing (g_enable_focus) are allowed. These variables are used in the _camera_preview_cb() and _camera_focus_cb() callbacks.

                                              -
                                               static bool g_enable_shot = false;
                                               static bool g_enable_focus = true;
                                               
                                              -
                                            4. -
                                            5. -

                                              Create the camera handle using the camera_create() function:

                                              -
                                               int error_code = 0;
                                               
                                              -// Create the camera handle
                                              +/* Create the camera handle */
                                               error_code = camera_create(CAMERA_DEVICE_CAMERA0, &cam_data.g_camera);
                                               if (error_code == CAMERA_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "error code = %d", error_code);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "error code = %d", error_code);
                                               else
                                              -{
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                              -}
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                               
                                              -

                                              The CAMERA_DEVICE_CAMERA0 parameter means that the currently activated device camera is 0, which is the primary camera. You can select between the primary (0) and secondary (1) camera. These values are defined in the camera_device_e enumeration (in mobile and wearable applications).

                                              -
                                            6. -
                                            7. -

                                              Check the current state of the camera using the camera_get_state() function:

                                              -
                                               camera_state_e state;
                                               
                                              -// Check the camera state after creating the camera
                                              +/* Check the camera state after creating the camera */
                                               error_code = camera_get_state(cam_data.g_camera, &state);
                                               
                                              - - -

                                              The returned state is one of the values defined in the camera_state_e enumeration (in mobile and wearable applications). If the state is not CAMERA_STATE_CREATED, reinitialize the camera by recreating the handle.

                                              - +

                                              The returned state is one of the values defined in the camera_state_e enumeration (in mobile and wearable applications). If the state is not CAMERA_STATE_CREATED, re-initialize the camera by recreating the handle.

                                            8. -
                                            -

                                            Configuring the Camera

                                            +

                                            Configuring the Camera and its Callbacks

                                            + +

                                            After setting up the necessary prerequisites, configure the camera and set the camera preview and auto-focus callbacks.

                                            To configure the camera:

                                            @@ -199,54 +166,50 @@ Evas_Object *g_eo = NULL; static void create_base_gui(camdata *cam_data, camera_display_type_e display_type) { -   // Window -   elm_config_accel_preference_set("opengl"); -   // PACKAGE contains the package name's character info -   cam_data->win = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC); - -   evas_object_resize(cam_data->win, 240, 320); - -   evas_object_move(cam_data->win, 0, 0); -   elm_win_autodel_set(cam_data->win, EINA_TRUE); - -   cam_data->evas = evas_object_evas_get(cam_data->win); - -   switch (display_type) -   { -      case CAMERA_DISPLAY_TYPE_EVAS: -         // Set the Evas image object for drawing -         g_eo = evas_object_image_add(cam_data->evas); -         evas_object_image_size_set(g_eo, 240, 320); -         evas_object_image_fill_set(g_eo, 0, 0, 240, 320); -         evas_object_resize(g_eo, 240, 320); -         evas_object_show(g_eo); -         evas_object_show(cam_data.win); -         break; - -      case CAMERA_DISPLAY_TYPE_OVERLAY: -         cam_data->rect = evas_object_rectangle_add(cam_data->evas); -         evas_object_resize(cam_data->rect, 240, 320); -         evas_object_move(cam_data->rect, 0, 0); -         evas_object_color_set(cam_data->rect, 0, 0, 0, 0); -         evas_object_render_op_set(cam_data->rect, EVAS_RENDER_COPY); -         evas_object_size_hint_weight_set(cam_data->rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); -         // Show the window after the base GUI is set up -         evas_object_show(cam_data->win); -         break; - -      case default: -         break; -   } +    /* Window */ +    elm_config_accel_preference_set("opengl"); +    /* PACKAGE contains the package name's character info */ +    cam_data->win = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC); + +    evas_object_resize(cam_data->win, 240, 320); + +    evas_object_move(cam_data->win, 0, 0); +    elm_win_autodel_set(cam_data->win, EINA_TRUE); + +    cam_data->evas = evas_object_evas_get(cam_data->win); + +    switch (display_type) { +    case CAMERA_DISPLAY_TYPE_EVAS: +        /* Set the Evas image object for drawing */ +        g_eo = evas_object_image_add(cam_data->evas); +        evas_object_image_size_set(g_eo, 240, 320); +        evas_object_image_fill_set(g_eo, 0, 0, 240, 320); +        evas_object_resize(g_eo, 240, 320); +        evas_object_show(g_eo); +        evas_object_show(cam_data.win); +        break; +    case CAMERA_DISPLAY_TYPE_OVERLAY: +        cam_data->rect = evas_object_rectangle_add(cam_data->evas); +        evas_object_resize(cam_data->rect, 240, 320); +        evas_object_move(cam_data->rect, 0, 0); +        evas_object_color_set(cam_data->rect, 0, 0, 0, 0); +        evas_object_render_op_set(cam_data->rect, EVAS_RENDER_COPY); +        evas_object_size_hint_weight_set(cam_data->rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); +        /* Show the window after the base GUI is set up */ +        evas_object_show(cam_data->win); +        break; +    case default: +        break; +    } } error_code = camera_set_display(cam_data.g_camera, CAMERA_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(cam_data.win)); -if (error_code != CAMERA_ERROR_NONE) -{ -   dlog_print(DLOG_DEBUG, "camera_set_display failed [0x%x]", ret); -   camera_destroy(cam_data.g_camera); -   cam_data.g_camera = 0; +if (error_code != CAMERA_ERROR_NONE) { +    dlog_print(DLOG_DEBUG, "camera_set_display failed [0x%x]", ret); +    camera_destroy(cam_data.g_camera); +    cam_data.g_camera = 0; -   return; +    return; } @@ -266,17 +229,17 @@ int resolution[2]; static bool _preview_resolution_cb(int width, int height, void *user_data) { -   int *resolution = (int*)user_data; -   resolution[0] = width; -   resolution[1] = height; +    int *resolution = (int*)user_data; +    resolution[0] = width; +    resolution[1] = height; -   return false; +    return false; } -// Find a resolution that is supported by the device +/* Find a resolution that is supported by the device */ error_code = camera_foreach_supported_preview_resolution(cam_data.g_camera, _preview_resolution_cb, resolution); -// Set the supported resolution for camera preview +/* Set the supported resolution for camera preview */ error_code = camera_set_preview_resolution(cam_data.g_camera, resolution[0], resolution[1]); @@ -294,13 +257,9 @@ error_code = camera_set_capture_format(cam_data.g_camera, CAMERA_PIXEL_FORMAT_JP -
                                        - -

                                        Handling the Camera Preview and Auto-focus Callbacks

                                        +
                                      6. To register callbacks for handling the camera preview and auto-focus: -

                                        To register callbacks for handling the camera preview and auto-focus:

                                        - -
                                          +
                                          • @@ -316,19 +275,16 @@ error_code = camera_set_preview_cb(cam_data.g_camera, _camera_preview_cb, NULL); static void _camera_preview_cb(camera_preview_data_s *frame, void *user_data) { -   int error_code = 0; +    int error_code = 0; -   if (g_enable_focus == true) -   { -      error_code = camera_start_focusing(cam_data.g_camera, true); +    if (g_enable_focus == true) { +        error_code = camera_start_focusing(cam_data.g_camera, true); -      if (error_code == CAMERA_ERROR_NOT_SUPPORTED) -      { -         error_code = camera_start_focusing(cam_data.g_camera, false); -      } +        if (error_code == CAMERA_ERROR_NOT_SUPPORTED) +            error_code = camera_start_focusing(cam_data.g_camera, false); -      g_enable_focus = false; -   } +        g_enable_focus = false; +    } } @@ -354,22 +310,22 @@ error_code = camera_set_focus_changed_cb(cam_data.g_camera, _camera_focus_cb, NU static void _camera_focus_cb(camera_focus_state_e state, void *user_data) { -   int error_code; +    int error_code; -   if (state == CAMERA_FOCUS_STATE_FOCUSED && g_enable_shot == true) -   { -      // Start capturing -      error_code = camera_start_capture(cam_data.g_camera, _camera_capturing_cb, _camera_completed_cb, NULL); +    if (state == CAMERA_FOCUS_STATE_FOCUSED && g_enable_shot == true) { +        /* Start capturing */ +        error_code = camera_start_capture(cam_data.g_camera, _camera_capturing_cb, _camera_completed_cb, NULL); -      g_enable_shot = false; -   } +        g_enable_shot = false; +    } }

                                            If the camera is in the CAMERA_FOCUS_STATE_FOCUSED state and the g_enable_shot flag is set to true, the callback starts the capturing process. The g_enable_shot flag is set to false to prevent the capturing process from restarting after the first captured frame.

                                          • - +
                                          +

                                        Setting the Display for the Camera Preview

                                        @@ -393,10 +349,10 @@ _camera_focus_cb(camera_focus_state_e state, void *user_data)

                                        To determine the active camera, check the camera_device_e enumerator:

                                        -typedef enum
                                        -{
                                        -   CAMERA_DEVICE_CAMERA0 = 0, // Primary camera
                                        -   CAMERA_DEVICE_CAMERA1 // Secondary camera
                                        +typedef 
                                        +enum {
                                        +    CAMERA_DEVICE_CAMERA0 = 0, /* Primary camera */
                                        +    CAMERA_DEVICE_CAMERA1 /* Secondary camera */
                                         } camera_device_e;
                                         
                                        @@ -439,7 +395,7 @@ error_code = camera_attr_get_lens_orientation(cam_data.g_camera, &angle); camera_rotation_e rotation = 0; int error_code = 0; -// Get the default display rotation value +/* Get the default display rotation value */ error_code = camera_get_display_rotation(cam_data.g_camera, &rotation); @@ -451,21 +407,30 @@ int error_code = 0; camera_rotation_e display_rotation = CAMERA_ROTATION_NONE; int display_rotation_angle = 0; -// Get the recommended display rotation value +/* Get the recommended display rotation value */ error_code = camera_attr_get_lens_orientation(cam_data.g_camera, &lens_orientation); display_rotation_angle = (360 - lens_orientation) % 360; -// Convert the display rotation value to an enum type -switch (display_rotation_angle) -{ -   case 0: display_rotation = CAMERA_ROTATION_NONE; break; -   case 90: display_rotation = CAMERA_ROTATION_90; break; -   case 180: display_rotation = CAMERA_ROTATION_180; break; -   case 270: display_rotation = CAMERA_ROTATION_270; break; -   default: display_rotation = CAMERA_ROTATION_NONE; break; +/* Convert the display rotation value to an enum type */ +switch (display_rotation_angle) { +case 0: +    display_rotation = CAMERA_ROTATION_NONE; +    break; +case 90: +    display_rotation = CAMERA_ROTATION_90; +    break; +case 180: +    display_rotation = CAMERA_ROTATION_180; +    break; +case 270: +    display_rotation = CAMERA_ROTATION_270; +    break; +default: +    display_rotation = CAMERA_ROTATION_NONE; +    break; } -// Set the display rotation +/* Set the display rotation */ error_code = camera_set_display_rotation(cam_data.g_camera, display_rotation); @@ -480,37 +445,33 @@ error_code = camera_set_display_rotation(cam_data.g_camera, display_rotation);

                                        Before changing the display flip value, retrieve the default value using the camera_get_display_flip() function:

                                        -camera_flip_e flip = 0
                                        +camera_flip_e flip = 0;
                                         int error_code = 0;
                                         
                                        -// Get the default display flip value
                                        +/* Get the default display flip value */
                                         error_code = camera_get_display_flip(cam_data.g_camera, &flip);
                                         

                                        Calculate and set a new display flip value based on the direction the camera is facing and the current camera orientation:

                                        -// If the camera is facing in the same direction as the display, apply flip to the front camera because of the mirror effect
                                        +/* If the camera is facing in the same direction as the display, apply flip to the front camera because of the mirror effect */
                                         
                                         int lens_orientation = 0;
                                         int error_code = 0;
                                         camera_flip_e camera_default_flip = MM_FLIP_NONE;
                                         
                                        -// Get the recommended display rotation value
                                        +/* Get the recommended display rotation value */
                                         error_code = camera_attr_get_lens_orientation(cam_data.g_camera, &lens_orientation);
                                         display_rotation_angle = (360 - lens_orientation) % 360;
                                         
                                        -// Set the mirror display
                                        +/* Set the mirror display */
                                         if (display_rotation_angle == 90 || display_rotation_angle == 270)
                                        -{
                                        -   camera_default_flip = MM_FLIP_VERTICAL;
                                        -}
                                        +    camera_default_flip = MM_FLIP_VERTICAL;
                                         else
                                        -{
                                        -   camera_default_flip = MM_FLIP_HORIZONTAL;
                                        -}
                                        +    camera_default_flip = MM_FLIP_HORIZONTAL;
                                         
                                        -// Set the display flip
                                        +/* Set the display flip */
                                         error_code = camera_set_display_flip(cam_data.g_camera, camera_default_flip);
                                         
                                        @@ -540,7 +501,7 @@ error_code = camera_set_display_flip(cam_data.g_camera, camera_default_flip);
                                      7. -

                                        After initializing the camera, start the camera preview using the camera_start_preview() function:

                                        +

                                        After configuring the camera, start the camera preview using the camera_start_preview() function:

                                         error_code = camera_start_preview(cam_data.g_camera);
                                        @@ -596,7 +557,7 @@ error_code = camera_start_preview(cam_data.g_camera);
                                         
                                         

                                        Implement the camera_capturing_cb() callback.

                                        -

                                        This callback is invoked once for each captured frame, and is used to get information about the captured image. The image is saved in the format set by the camera_set_capture_format() function.

                                        +

                                        This callback is invoked once for each captured frame, and is used to get information about the captured image. The image is saved in the format set by the camera_set_capture_format() function.

                                        The following example code implements the _camera_capturing_cb() callback, which saves the captured frame as a JPEG image:

                                        @@ -604,14 +565,12 @@ error_code = camera_start_preview(cam_data.g_camera); static void _camera_capturing_cb(camera_image_data_s* image, camera_image_data_s* postview, camera_image_data_s* thumbnail, void *user_data) { -   dlog_print(DLOG_DEBUG, LOG_TAG, "Writing image to file"); -   FILE *file = fopen(g_fname, "w+"); - -   if (image->data != NULL) -   { -      fwrite(image->data, 1, image->size, file); -   } -   fclose(file); +    dlog_print(DLOG_DEBUG, LOG_TAG, "Writing image to file"); +    FILE *file = fopen(g_fname, "w+"); + +    if (image->data != NULL) +        fwrite(image->data, 1, image->size, file); +    fclose(file); }
                                        @@ -629,14 +588,14 @@ _camera_capturing_cb(camera_image_data_s* image, camera_image_data_s* postview, static void _camera_completed_cb(void *user_data) { -   int error_code = 0; +    int error_code = 0; -   usleep(25000); // Display the captured image for 0.025 seconds +    usleep(25000); /* Display the captured image for 0.025 seconds */ -   // Restart the camera preview -   error_code = camera_start_preview(cam_data.g_camera); +    /* Restart the camera preview */ +    error_code = camera_start_preview(cam_data.g_camera); -   g_enable_focus = true; +    g_enable_focus = true; } @@ -679,7 +638,8 @@ error_code = camera_attr_set_image_quality(cam_data.g_camera, 100);

                                        Set the zoom level using the camera_attr_set_zoom() function. Retrieve the range of available zoom level values using the camera_attr_get_zoom_range() function. The following example code retrieves the available zoom level range and sets the zoom level to minimum:

                                        -int min, max;
                                        +int min;
                                        +int max;
                                         
                                         error_code = camera_attr_get_zoom_range(cam_data.g_camera, &min, &max);
                                         
                                        @@ -695,7 +655,8 @@ error_code = camera_attr_set_zoom(cam_data.g_camera, min);
                                         

                                        Retrieve the range of available brightness level values using the camera_attr_get_brightness_range() function, and the current brightness level using the camera_attr_get_brightness() function:

                                        -int min, max;
                                        +int min;
                                        +int max;
                                         static int g_bright_level;
                                         
                                         error_code = camera_attr_get_brightness_range(cam_data.g_camera, &min, &max);
                                        @@ -706,22 +667,17 @@ error_code = camera_attr_get_brightness(cam_data.g_camera, &g_bright_level);
                                         

                                        Set a new brightness level using the camera_attr_set_brightness() function:

                                        -if (g_bright_level >= LEVEL_UPPER_BOUND)
                                        -{
                                        -   dlog_print(DLOG_DEBUG, LOG_TAG, "Brightness is set to maximum level");
                                        -   g_bright_level = LEVEL_UPPER_BOUND - 1;
                                        -}
                                        -else if (g_bright_level <= LEVEL_LOWER_BOUND)
                                        -{
                                        -   dlog_print(DLOG_DEBUG, LOG_TAG, "Brightness is set to minimum level");
                                        -   g_bright_level = LEVEL_LOWER_BOUND + 1;
                                        -}
                                        -else
                                        -{
                                        -   g_bright_level++;
                                        +if (g_bright_level >= LEVEL_UPPER_BOUND) {
                                        +    dlog_print(DLOG_DEBUG, LOG_TAG, "Brightness is set to maximum level");
                                        +    g_bright_level = LEVEL_UPPER_BOUND - 1;
                                        +} else if (g_bright_level <= LEVEL_LOWER_BOUND) {
                                        +    dlog_print(DLOG_DEBUG, LOG_TAG, "Brightness is set to minimum level");
                                        +    g_bright_level = LEVEL_LOWER_BOUND + 1;
                                        +} else {
                                        +    g_bright_level++;
                                         }
                                         
                                        -// Set the brightness level
                                        +/* Set the brightness level */
                                         error_code = camera_attr_set_brightness(cam_data.g_camera, g_bright_level);
                                         
                                        @@ -757,13 +713,13 @@ error_code = camera_stop_preview(cam_data.g_camera);
                                      8. -

                                        Unregister the camera preview and auto-focus callbacks using the camera_unset_preview_cb() and camera_unset_focus_changed_cb() functions:

                                        +

                                        Deregister the camera preview and auto-focus callbacks using the camera_unset_preview_cb() and camera_unset_focus_changed_cb() functions:

                                        -// Unregister the camera preview callback
                                        +/* Deregister the camera preview callback */
                                         error_code = camera_unset_preview_cb(cam_data.g_camera);
                                         
                                        -// Unregister the auto-focus callback
                                        +/* Deregister the auto-focus callback */
                                         error_code = camera_unset_focus_changed_cb(cam_data.g_camera);
                                         
                                        diff --git a/org.tizen.tutorials/html/native/multimedia/image_util_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/image_util_tutorial_n.htm index 4ce671f..9b92af4 100644 --- a/org.tizen.tutorials/html/native/multimedia/image_util_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/image_util_tutorial_n.htm @@ -22,7 +22,7 @@

                                        Content

                                          -
                                        • Initializing Image Utilities
                                        • +
                                        • Prerequisites
                                        • Image manipulation
                                          • Converting the Color Space
                                          • @@ -54,8 +54,8 @@

                                            Become familiar with the Image Util API basics by learning about:

                                              -
                                            • Initializing Image Utilities -

                                              Initialize the image utilities for use.

                                            • +
                                            • Prerequisites +

                                              Prepare your application to use the image util functionality.

                                            • Image manipulation -

                                              Initializing Image Utilities

                                              +

                                              Prerequisites

                                              -

                                              To initialize image utilities for use:

                                              +

                                              To enable your application to use the image util functionality:

                                                -
                                              1. -

                                                To use the functions and data types of the Image Util API (in mobile and wearable applications), include the <image_util.h> header file in your application:

                                                -
                                                 #include <image_util.h>
                                                 
                                                -

                                                To ensure that an Image Util function has been executed properly, make sure that the return value is equal to IMAGE_UTIL_ERROR_NONE.

                                                -
                                              2. -
                                              3. -

                                                Declare the required variables:

                                                -
                                                 #define SAMPLE_FILENAME "sample_image.jpg"
                                                 #define OUTPUT_ROTATED_JPEG "rotated_image.jpg"
                                                @@ -110,31 +102,22 @@ const image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
                                                 unsigned char *img_rotate_target = NULL;
                                                 unsigned char *img_source = NULL;
                                                 int ret = 0;
                                                -int width = 0, height = 0;
                                                +int width = 0;
                                                +int height = 0;
                                                 unsigned int size_decode = 0;
                                                 
                                                -
                                              4. -
                                              5. -

                                                To find out which JPEG color spaces are supported on the device, use the image_util_foreach_supported_jpeg_colorspace() function:

                                                -
                                                 int image_util_foreach_supported_jpeg_colorspace(image_util_supported_jpeg_colorspace_cb callback,
                                                                                                  void * user_data);
                                                 
                                                -

                                                The possible color spaces are defined in the image_util_colorspace_e enumeration (in mobile and wearable applications).

                                                -

                                                For more information about the YUV color space, see http://www.fourcc.org/yuv.php.

                                                -
                                              6. -
                                              7. -

                                                To support the image_util_transform_run() function, which is used for all image transformations, set the source image and create a handle for it (to be used as the second parameter):

                                                -
                                                 ret = image_util_decode_jpeg(SAMPLE_FILENAME, colorspace, &img_source,
                                                                              &width, &height, &size_decode);
                                                @@ -151,9 +134,7 @@ src = malloc(size);
                                                 ret = media_packet_get_buffer_data_ptr(src, &src_ptr);
                                                 ret = memcpy(src_ptr, img_source, size);
                                                 
                                                -
                                              8. -

                                              Converting the Color Space

                                              @@ -351,7 +332,7 @@ ret = image_util_transform_set_hardware_acceleration(handle, true); ret = image_util_transform_set_rotation(handle, rotation);
                                      9. -

                                        The possible values for the rotation parameter are defined in the image_util_rotation_e enumeration (in mobile and wearable applications).

                                        +

                                        The possible values for the rotation parameter are defined in the image_util_rotation_e enumeration (in mobile and wearable applications).

                                      10. diff --git a/org.tizen.tutorials/html/native/multimedia/media_codec_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/media_codec_tutorial_n.htm index d1e18bf..6e3c08c 100644 --- a/org.tizen.tutorials/html/native/multimedia/media_codec_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/media_codec_tutorial_n.htm @@ -22,7 +22,8 @@

                                        Content

                                        @@ -46,21 +47,17 @@

                                        Become familiar with the Media Codec API basics by learning about:

                                        -

                                        Initializing Media Codecs

                                        - -

                                        To initialize a media codec for use:

                                        - -
                                          - -
                                        1. +

                                          Prerequisites

                                          To use the functions and data types of the Media Codec API (in mobile and wearable applications), include the <media_codec.h> header file in your application:

                                          @@ -68,8 +65,10 @@ #include <media_codec.h> -
                                        2. +

                                          Preparing Media Codecs

                                          +

                                          To prepare the media codecs:

                                          +
                                          1. Create a handle for the media codec using the mediacodec_create() function:

                                            @@ -100,13 +99,13 @@ ret = mediacodec_set_codec(mediacodec, (mediacodec_codec_type_e)codecid, flag);

                                            To configure the video and audio encoder and decoder:

                                            -// Video encoder
                                            +/* Video encoder */
                                             ret = mediacodec_set_venc_info(mediacodec, width, height, fps, target_bits);
                                            -// Video decoder
                                            +/* Video decoder */
                                             ret = mediacodec_set_vdec_info(mediacodec, width, height);
                                            -// Audio encoder
                                            +/* Audio encoder */
                                             ret = mediacodec_set_aenc_info(mediacodec, samplerate, channel, bit, bitrate);
                                            -// Audio decoder
                                            +/* Audio decoder */
                                             ret = mediacodec_set_adec_info(mediacodec, samplerate, channel, bit);
                                             
                                            @@ -132,9 +131,9 @@ ret = mediacodec_set_input_buffer_used_cb(mediacodec, _input_buffer_used_cb, NUL static void _input_buffer_used_cb(media_packet_h pkt, void *user_data) { -   media_packet_destroy(pkt); +    media_packet_destroy(pkt); -   return; +    return; } @@ -156,16 +155,15 @@ ret = mediacodec_set_output_buffer_available_cb(mediacodec, _output_buffer_avail static void _output_buffer_available_cb(media_packet_h pkt, void *user_data) { -   media_packet_h out_pkt; -   mediacodec_h mediacodec = (mediacodec_h)user_data; +    media_packet_h out_pkt; +    mediacodec_h mediacodec = (mediacodec_h)user_data; -   if (pkt != NULL) -   { -      mediacodec_get_output(mediacodec, &out_pkt, 0); -      media_packet_destroy(out_pkt); -   } +    if (pkt != NULL) { +        mediacodec_get_output(mediacodec, &out_pkt, 0); +        media_packet_destroy(out_pkt); +    } -   return; +    return; } @@ -219,18 +217,18 @@ ret = media_packet_set_buffer_size(pkt, 48); void _fill_buffer(media_packet_h pkt, unsigned char *yuv, int width, int height) { -   int i; +    int i; -   // Y plane -   media_packet_get_video_stride_width(pkt, 0, &stride); -   media_packet_get_video_plane_data_ptr(pkt, 0, &data); +    /* Y plane */ +    media_packet_get_video_stride_width(pkt, 0, &stride); +    media_packet_get_video_plane_data_ptr(pkt, 0, &data); -   for (i = 0; i < height; i++) -   { -      memcpy(data, yuv, width); -      data += stride; -   } -} +    for (i = 0; i < height; i++) { +        memcpy(data, yuv, width); +        data += stride; +    } +} +
                                          2. @@ -238,7 +236,7 @@ _fill_buffer(media_packet_h pkt, unsigned char *yuv, int width, int height)

                                            Running the Media Codec

                                            -

                                            After initializing the medic codec and filling the media_packet with data, run the media codec in the following loop:

                                            +

                                            After preparing the medic codec and filling the media_packet with data, run the media codec in the following loop:

                                              @@ -339,7 +337,8 @@ ret = media_packet_is_codec_config(pkt, &codec_config);

                                              After the loop is over and you have finished working with the media codec, reset the codec and destroy the codec handle using the mediacodec_unprepare() and mediacodec_destroy() functions:

                                              -
                                              ret = mediacodec_unprepare(mediacodec);
                                              +
                                              +ret = mediacodec_unprepare(mediacodec);
                                               
                                               ret = mediacodec_destroy(mediacodec);
                                               
                                              diff --git a/org.tizen.tutorials/html/native/multimedia/media_controller_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/media_controller_tutorial_n.htm index 7bf1b18..00ee6eb 100644 --- a/org.tizen.tutorials/html/native/multimedia/media_controller_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/media_controller_tutorial_n.htm @@ -22,7 +22,7 @@

                                              Content

                                              @@ -47,75 +47,58 @@

                                              Become familiar with the Media Controller API basics by learning about:

                                              -

                                              Initializing the Media Controller

                                              +

                                              Prerequisites

                                              -

                                              To initialize the media controller server for use:

                                              +

                                              To enable your application to use the media controller functionality:

                                              +
                                                +
                                              • To use the media controller server:
                                                  -
                                                1. -

                                                  To use the functions and data types of the Media Controller Server API, include the <media_controller_server.h> header file in your application:

                                                  -
                                                   #include <media_controller_server.h>
                                                   
                                                  -
                                                2. -
                                                3. -

                                                  To work with the Media Controller Server API, define a handle variable for the media controller server:

                                                  -
                                                   static mc_server_h g_server_h = NULL;
                                                   
                                                  -

                                                  The server updates the metadata and playback information, and processes the requests and commands sent by the client.

                                                  -

                                                  This tutorial uses a global variable for the handle.

                                                  -
                                                4. -
                                                - -

                                                To initialize the media controller client for use:

                                                - +
                                              • +
                                              • +

                                                To use the media controller client:

                                                  -
                                                1. -

                                                  To use the functions and data types of the Media Controller Client API, include the <media_controller_client.h> header file in your application:

                                                   #include <media_controller_client.h>
                                                   
                                                  -
                                                2. -
                                                3. -

                                                  To work with the Media Controller Client API, define a handle variable for the media controller client:

                                                  -
                                                   static mc_client_h g_client_h = NULL;
                                                   
                                                  -

                                                  The client requests metadata and playback information from the server, and sends playback commands to server.

                                                  -

                                                  This tutorial uses a global variable for the handle.

                                                  -
                                                4. -
                                                +
                                              • +

                                              Updating and Retrieving Information

                                              @@ -302,7 +285,7 @@ ret = mc_server_create(&g_server_h); void command_received_cb(const char* client_name, mc_playback_states_e state, void *user_data) { -   dlog_print(DLOG_DEBUG, LOG_TAG, "Client Name: %s, Playback state: %d\n", client_name, state); +    dlog_print(DLOG_DEBUG, LOG_TAG, "Client Name: %s, Playback state: %d\n", client_name, state); }
                                              diff --git a/org.tizen.tutorials/html/native/multimedia/media_demuxer_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/media_demuxer_tutorial_n.htm new file mode 100644 index 0000000..db0203b --- /dev/null +++ b/org.tizen.tutorials/html/native/multimedia/media_demuxer_tutorial_n.htm @@ -0,0 +1,265 @@ + + + + + + + + + + + + + + Media Demuxer: Parsing Multiplexed Media Streams + + + + + + +
                                              +

                                              Media Demuxer: Parsing Multiplexed Media Streams

                                              + +

                                              This tutorial demonstrates how you can demux multiplexed media files.

                                              + +

                                              Warm-up

                                              + +

                                              Become familiar with the Media Demuxer API basics by learning about:

                                              + + + +

                                              Prerequisites

                                              + +

                                              To use the functions and data types of the Media Demuxer API (in mobile and wearable applications), include the <mediademuxer.h> header file in your application:

                                              +
                                              +#include <mediademuxer.h>
                                              +
                                              +#include <media_format.h>
                                              +#include <media_packet.h>
                                              +
                                              +

                                              You also need the <media_format.h> and <media_packet.h> header files to identify and manage individual tracks within the media file.

                                              + +

                                              Preparing the Media Demuxer

                                              + +

                                              To prepare the media demuxer:

                                              +
                                                +
                                              1. Define a handle for the media demuxer and pass it to the mediademuxer_create() function. The same handle must be passed to the rest of the media demuxer functions. +
                                                +mediademuxer_h *demuxer;
                                                +ret = mediademuxer_create(&demuxer);
                                                +if (ret != MEDIADEMUXER_ERROR_NONE)
                                                +    return false;
                                                +
                                                +
                                              2. + +
                                              3. If the handle is created normally, set the input data source by passing the path to the mediademuxer_set_data_source() function: +
                                                +if (mediademuxer_set_data_source(demuxer, path)!= MEDIADEMUXER_ERROR_NONE)
                                                +    printf("mediademuxer_set_data_source API failed\n");
                                                +
                                                +
                                              4. + +
                                              5. Call the mediademuxer_prepare() function to move the media demuxer into the ready state: +
                                                +if (mediademuxer_prepare(demuxer) != MEDIADEMUXER_ERROR_NONE)
                                                +    printf("mediademuxer_prepare API failed\n");
                                                +
                                                +
                                              6. + +
                                              7. Once the media demuxer is in the ready state, get the total number of individual elementary streams present: +
                                                +if (mediademuxer_get_track_count(demuxer, &num_tracks) != MEDIADEMUXER_ERROR_NONE)
                                                +    printf("mediademuxer_get_track_count API failed\n");
                                                +
                                                +
                                              8. + +
                                              9. Select all the tracks to be extracted: +
                                                +for (track = 0; track < num_tracks; track++) {
                                                +    if (mediademuxer_select_track(demuxer, track))
                                                +        g_print("mediademuxer_select track %d failed\n", track);
                                                +}
                                                +
                                                +
                                              10. + +
                                              11. Start the media demuxer: +
                                                +if (mediademuxer_start(demuxer))
                                                +    g_print("mediademuxer_start failed\n");
                                                +
                                                +
                                              12. + +
                                              13. Once the total track counts are known, the media format for each track must be identified. Before calling the media_format_create() function, you must define and create a valid media_format_h handle (the format parameter in the given function). +

                                                The following example retrieves the media format for each track:

                                                +
                                                +media_format_h *g_media_format = NULL;
                                                +int track;
                                                +g_media_format = (media_format_h *)g_malloc(sizeof(media_format_h) * num_tracks);
                                                +for (track = 0; track < num_tracks; track++) {
                                                +    ret = media_format_create(&g_media_format[track]);
                                                +    if (ret == 0) {
                                                +        g_print("g_media_format[%d] is created successfully! \n", track);
                                                +        ret = mediademuxer_get_track_info(demuxer, track, g_media_format[track]);
                                                +        if (ret == 0) {
                                                +            if (media_format_get_video_info(g_media_format[track], &mime, &w, &h, NULL, NULL) == MEDIA_FORMAT_ERROR_NONE) {
                                                +                g_print("media_format_get_video_info is success!\n");
                                                +                vid_track = track;
                                                +            } else if (media_format_get_audio_info(g_media_format[track], &mime, &channel, &samplerate, NULL, NULL) == MEDIA_FORMAT_ERROR_NONE) {
                                                +                g_print("media_format_get_audio_info is success!\n");
                                                +                aud_track = track;
                                                +            } else {
                                                +                g_print("Not supported yet");
                                                +            }
                                                +        } else {
                                                +            g_print("Error while getting mediademuxer_get_track_info\n");
                                                +        }
                                                +    } else {
                                                +        g_print("Error while creating media_format_create\n");
                                                +    }
                                                +}
                                                +
                                                +
                                              14. +
                                              + + + +

                                              Managing the Media Demuxer

                                              + +

                                              To manage the media demuxer process:

                                              +
                                                +
                                              1. You can create individual threads to manage each track simultaneously, but it is not mandatory. The following sample code explains how to extract the video track in a new thread: +
                                                +int
                                                +test_mediademuxer_read_sample()
                                                +{
                                                +    pthread_t thread[1];
                                                +    pthread_attr_t attr;
                                                +    /* Initialize and set thread detached attribute */
                                                +    pthread_attr_init(&attr);
                                                +    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
                                                +    if (vid_track != -1) {
                                                +        g_print("In main: creating thread for video\n");
                                                +        pthread_create(&thread[0], &attr, _fetch_video_data, NULL);
                                                +    }
                                                +    pthread_attr_destroy(&attr);
                                                +
                                                +    return 0;
                                                +}
                                                +
                                                +void*
                                                +_fetch_video_data(void *ptr)
                                                +{
                                                +    int *status = (int *)g_malloc(sizeof(int) * 1);
                                                +    *status = -1;
                                                +    g_print("Video Data function\n");
                                                +    int count = 0;
                                                +    media_packet_h vidbuf;
                                                +    media_format_h vidfmt;
                                                +    if (media_format_create(&vidfmt)) {
                                                +        g_print("media_format_create failed\n");
                                                +
                                                +        return (void *)status;
                                                +    }
                                                +    if (media_format_set_video_mime(vidfmt, MEDIA_FORMAT_H264_SP)) {
                                                +        g_print("media_format_set_video_mime failed\n");
                                                +
                                                +        return (void *)status;
                                                +    }
                                                +    if (media_format_set_video_width(vidfmt, 760)) {
                                                +        g_print("media_format_set_video_width failed\n");
                                                +
                                                +        return (void *)status;
                                                +    }
                                                +    if (media_format_set_video_height(vidfmt, 480)) {
                                                +        g_print("media_format_set_video_height failed\n");
                                                +
                                                +        return (void *)status;
                                                +    }
                                                +    if (media_packet_create_alloc(vidfmt, NULL, NULL, &vidbuf)) {
                                                +        g_print("media_packet_create_alloc failed\n");
                                                +    }
                                                +    while (1) {
                                                +        int EOS = mediademuxer_read_sample(demuxer, vid_track, &vidbuf);
                                                +        if (EOS == MD_EOS || EOS != MD_ERROR_NONE)
                                                +            pthread_exit(NULL);
                                                +        count++;
                                                +        g_print("Read::[%d] video sample\n", count);
                                                +        /* Use the media packet and release the packet here */
                                                +        media_packet_destroy(vidbuf);
                                                +        /* Create a new packet for getting next frame of data */
                                                +        if (media_packet_create_alloc(vidfmt, NULL, NULL, &vidbuf)) {
                                                +            g_print("media_packet_create_alloc failed\n");
                                                +            break;
                                                +        }
                                                +    }
                                                +    *status = 0;
                                                +
                                                +    return (void *)status;
                                                +}
                                                +
                                                +
                                              2. + +
                                              3. After you have finished work with the media demuxer, reset the media demuxer and destroy the handle by using the mediademuxer_unprepare() and mediademuxer_destroy() functions. +

                                                The media demuxer state changes to MEDIADEMUXER_STATE_NONE.

                                                +
                                                +ret = mediademuxer_unprepare(demuxer);
                                                +if (ret != MEDIADEMUXER_ERROR_NONE)
                                                +    return false;
                                                +ret = mediademuxer_destroy(demuxer);
                                                +if (ret != MEDIADEMUXER_ERROR_NONE)
                                                +    return false;
                                                +
                                                +
                                              4. +
                                              + + + +
                                              + +Go to top + + + + + + + + diff --git a/org.tizen.tutorials/html/native/multimedia/media_key_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/media_key_tutorial_n.htm index a1429d3..4657a30 100644 --- a/org.tizen.tutorials/html/native/multimedia/media_key_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/media_key_tutorial_n.htm @@ -23,6 +23,7 @@

                                              Content

                                              @@ -43,75 +44,79 @@

                                              Warm-up

                                              Become familiar with the Media key API basics by learning about:

                                              - + + +

                                              Prerequisites

                                              + +

                                              To use the functions and data types of the Media key API (in mobile and wearable applications), include the <media_key.h> header file in your application:

                                              +
                                              +#include <media_key.h>
                                              +
                                              +

                                              Monitoring Media Key Events

                                              To monitor media key events:

                                                -
                                              1. To use the functions and data types of the Media key API (in mobile and wearable applications), include the <media_key.h> header file in your application:

                                                -
                                                -#include <media_key.h>
                                                -
                                              2. -
                                              3. Implement a callback to handle media key events.

                                                In the following example, the callback simply prints out the key from which the event originated and the state change that caused the event:

                                                -void 
                                                +void
                                                 event_cb(media_key_e key, media_key_event_e status, void* user_data)
                                                 {
                                                -   switch (key) 
                                                -   {
                                                -      case MEDIA_KEY_PLAY:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_PLAY");
                                                -         break;
                                                -      case MEDIA_KEY_STOP:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_STOP");
                                                -         break;
                                                -      case MEDIA_KEY_PAUSE:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_PAUSE");
                                                -         break;
                                                -      case MEDIA_KEY_PREVIOUS:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_PREVIOUS");
                                                -         break;
                                                -      case MEDIA_KEY_NEXT:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_NEXT");
                                                -         break;
                                                -      case MEDIA_KEY_FASTFORWARD:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_FASTFORWARD");
                                                -         break;
                                                -      case MEDIA_KEY_REWIND:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_REWIND");
                                                -         break;
                                                -      case MEDIA_KEY_PLAYPAUSE:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_PLAYPAUSE");
                                                -         break;
                                                -      case MEDIA_KEY_UNKNOWN:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_UNKNOWN");
                                                -         break;
                                                -      default:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Key: Unknown");
                                                -         break;
                                                -   }
                                                -   switch (status) 
                                                -   {
                                                -      case MEDIA_KEY_STATUS_PRESSED:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Event: MEDIA_KEY_STATUS_PRESSED");
                                                -         break;
                                                -      case MEDIA_KEY_STATUS_RELEASED:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Event: MEDIA_KEY_STATUS_RELEASED");
                                                -         break;
                                                -      case MEDIA_KEY_STATUS_UNKNOWN:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Event: MEDIA_KEY_STATUS_UNKNOWN");
                                                -         break;
                                                -      default:
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Event: Unknown");
                                                -         break;
                                                -   }
                                                +    switch (key) {
                                                +    case MEDIA_KEY_PLAY:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_PLAY");
                                                +        break;
                                                +    case MEDIA_KEY_STOP:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_STOP");
                                                +        break;
                                                +    case MEDIA_KEY_PAUSE:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_PAUSE");
                                                +        break;
                                                +    case MEDIA_KEY_PREVIOUS:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_PREVIOUS");
                                                +        break;
                                                +    case MEDIA_KEY_NEXT:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_NEXT");
                                                +        break;
                                                +    case MEDIA_KEY_FASTFORWARD:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_FASTFORWARD");
                                                +        break;
                                                +    case MEDIA_KEY_REWIND:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_REWIND");
                                                +        break;
                                                +    case MEDIA_KEY_PLAYPAUSE:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_PLAYPAUSE");
                                                +        break;
                                                +    case MEDIA_KEY_UNKNOWN:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: MEDIA_KEY_UNKNOWN");
                                                +        break;
                                                +    default:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Key: Unknown");
                                                +        break;
                                                +    }
                                                +    switch (status) {
                                                +    case MEDIA_KEY_STATUS_PRESSED:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Event: MEDIA_KEY_STATUS_PRESSED");
                                                +        break;
                                                +    case MEDIA_KEY_STATUS_RELEASED:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Event: MEDIA_KEY_STATUS_RELEASED");
                                                +        break;
                                                +    case MEDIA_KEY_STATUS_UNKNOWN:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Event: MEDIA_KEY_STATUS_UNKNOWN");
                                                +        break;
                                                +    default:
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Event: Unknown");
                                                +        break;
                                                +    }
                                                 }
                                                 
                                              4. @@ -119,48 +124,36 @@ event_cb(media_key_e key, media_key_event_e status, void* user_data)
                                              5. Register the defined callback with the media_key_reserve() function:
                                                -void 
                                                +void
                                                 media_key_api_func()
                                                 {
                                                -   int r = 0;
                                                -
                                                -   r = media_key_reserve(event_cb, NULL);
                                                -
                                                -   if (r == MEDIA_KEY_ERROR_NONE)
                                                -   {
                                                -      dlog_print(DLOG_INFO, LOG_TAG, "Reserve media key success.");
                                                -   }
                                                -   else
                                                -   {
                                                -      dlog_print(DLOG_ERROR, LOG_TAG, "Reserve media key failed.");
                                                -   }
                                                +    int r = 0;
                                                +
                                                +    r = media_key_reserve(event_cb, NULL);
                                                +
                                                +    if (r == MEDIA_KEY_ERROR_NONE)
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Reserve media key success.");
                                                +    else
                                                +        dlog_print(DLOG_ERROR, LOG_TAG, "Reserve media key failed.");
                                                 
                                              6. -

                                                When you no longer need to monitor the media key events, unregister the callback with the media_key_release() function:

                                                +

                                                When you no longer need to monitor the media key events, deregister the callback with the media_key_release() function:

                                                -   r = media_key_release();
                                                -
                                                -   if (r == MEDIA_KEY_ERROR_NONE)
                                                -   {
                                                -      dlog_print(DLOG_INFO, LOG_TAG, "Release media key success.");
                                                -   }
                                                -   else if (r == MEDIA_KEY_ERROR_INVALID_PARAMETER)
                                                -   {
                                                -      dlog_print(DLOG_ERROR, LOG_TAG, "Invalid parameter.");
                                                -   }
                                                -   else if (r == MEDIA_KEY_ERROR_OPERATION_FAILED)
                                                -   {
                                                -      dlog_print(DLOG_ERROR, LOG_TAG, "Operation failed.");
                                                -   }
                                                -   else
                                                -   {
                                                -      dlog_print(DLOG_ERROR, LOG_TAG, "Failed. Unknown reason.");
                                                -   }
                                                +    r = media_key_release();
                                                +
                                                +    if (r == MEDIA_KEY_ERROR_NONE)
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Release media key success.");
                                                +    else if (r == MEDIA_KEY_ERROR_INVALID_PARAMETER)
                                                +        dlog_print(DLOG_ERROR, LOG_TAG, "Invalid parameter.");
                                                +    else if (r == MEDIA_KEY_ERROR_OPERATION_FAILED)
                                                +        dlog_print(DLOG_ERROR, LOG_TAG, "Operation failed.");
                                                +    else
                                                +        dlog_print(DLOG_ERROR, LOG_TAG, "Failed. Unknown reason.");
                                                 }
                                                -
                                              - +
                                            + diff --git a/org.tizen.tutorials/html/native/multimedia/media_muxer_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/media_muxer_tutorial_n.htm new file mode 100644 index 0000000..3a09ff5 --- /dev/null +++ b/org.tizen.tutorials/html/native/multimedia/media_muxer_tutorial_n.htm @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + Media Muxer: Muxing Encoded Media Streams + + + + + + +
                                            +

                                            Media Muxer: Muxing Encoded Media Streams

                                            + +

                                            This tutorial demonstrates how you can mux encoded media streams into a compatible container format.

                                            + +

                                            Warm-up

                                            + +

                                            Become familiar with the Media Muxer API basics by learning about:

                                            + + + +

                                            Prerequisites

                                            + +

                                            To use the functions and data types of the Media Muxer API (in mobile and wearable applications), include the <mediamuxer.h> header file in your application:

                                            +
                                            +#include <mediamuxer.h>
                                            +
                                            + +

                                            Preparing the Media Muxer

                                            + +

                                            To prepare the media muxer:

                                            +
                                              +
                                            1. Define a handle for the media muxer and pass it to the mediamuxer_create() function. The same handle must be passed to the rest of the media muxer functions. +
                                              +mediamuxer_h *muxer;
                                              +ret = mediamuxer_create(&muxer);
                                              +if (ret != MEDIAMUXER_ERROR_NONE)
                                              +    return false;
                                              +
                                              +
                                            2. + +
                                            3. If the handle is created normally, set the output file path by passing the absolute uri path to the mediamuxer_set_data_sink() function: +
                                              +char *path = "/home/media/myfile.mp4"
                                              +mediamuxer_output_format_e format = MEDIAMUXER_CONTAINER_FORMAT_MP4;
                                              +if (mediamuxer_set_data_sink(muxer, path, format)!= MEDIAMUXER_ERROR_NONE) 
                                              +    printf("mediamuxer_set_data_sink failed\n");
                                              +
                                              +
                                            4. + +
                                            5. Add the necessary media tracks to the media muxer. The following function shows adding a video elementary track to be muxed. +

                                              A successful mediamuxer_add_track() function call returns a track_index. Whenever you have to deal with the track, the corresponding track_index must be used. Mapping a track_index to the corresponding media track is your responsibility.

                                              +
                                              +int
                                              +test_mediamuxer_add_track_video()
                                              +{
                                              +    int track_index_vid = -1;
                                              +    media_format_mimetype_e mimetype;
                                              +    int width;
                                              +    int height;
                                              +    int avg_bps;
                                              +    int max_bps;
                                              +
                                              +    media_format_create(&media_format);
                                              +    media_format_set_video_mime(media_format, MEDIA_FORMAT_H264_SP);
                                              +    media_format_set_video_width(media_format, 640);
                                              +    media_format_set_video_height(media_format, 480);
                                              +    media_format_set_video_avg_bps(media_format, 256000);
                                              +    media_format_set_video_max_bps(media_format, 256000);
                                              +
                                              +    /* Add the video track */
                                              +    mediamuxer_add_track(myMuxer, media_format, &track_index_vid);
                                              +
                                              +    return 0;
                                              +}
                                              +
                                              +
                                            6. + +
                                            7. Once all the tracks are added, start the media muxer: +
                                              +if (mediamuxer_start(muxer) != MEDIAMUXER_ERROR_NONE)
                                              +    printf("mediamuxer_start API failed\n");
                                              +
                                              +
                                            8. + +
                                            9. After a successful muxer start, call a write sample until all the samples of the respective track are written. +

                                              The write sample is a specific track. It is your responsibility to use the appropriate track_index to choose the correct track, and to add the corresponding data to the muxer through the write sample. Repeat the same for the rest of the tracks. Before calling this function, create a valid handle for the media_packet_h handle to get the input samples. For more information, see Media Tool.

                                              +
                                              +if (mediamuxer_write_sample(muxer, track_index, in_buf) != MEDIAMUXER_ERROR_NONE)
                                              +    printf("mediamuxer_write_sample API for track %d failed\n", track_index);
                                              +
                                              +
                                            10. + +
                                            11. Once the EOS (End Of Stream) of a particular track is reached, call mediamuxer_close_track() function to finalize the track: +
                                              +if (mediamuxer_close_track(muxer, track_index) != MEDIAMUXER_ERROR_NONE)
                                              +    printf("mediamuxer_close_track API failed\n");
                                              +
                                              +
                                            12. +
                                            + + + +

                                            Managing the Media Muxer

                                            + +

                                            To manage the media muxer, the mediamuxer_write_sample() function is called in a loop until the EOS is reached. You can use multi-threading, writing samples corresponding to different tracks in different threads.

                                            +
                                              +
                                            1. You can create individual threads to manage each track simultaneously, but it is not mandatory. The following sample code explains how to call the mediamuxer_write_sample() function for a video track in a unique thread: +
                                              +int
                                              +test_mediamuxer_write_sample()
                                              +{
                                              +    pthread_t thread[1];
                                              +    pthread_attr_t attr;
                                              +    /* Initialize and set thread detached attribute */
                                              +    pthread_attr_init(&attr);
                                              +    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
                                              +    pthread_create(&thread[0], &attr, _write_video_data, NULL);
                                              +    pthread_create(&thread[1], &attr, _write_audio_data, NULL);
                                              +
                                              +    /* Add audio track, which is not given in this tutorial */
                                              +
                                              +    pthread_attr_destroy(&attr);
                                              +
                                              +    return 0;
                                              +}
                                              +
                                              +void*
                                              +_write_video_data()
                                              +{
                                              +    gint is_eos = 0;
                                              +    int *status = (int *)g_malloc(sizeof(int) * 1);
                                              +    v*status = -1;
                                              +    int track_index_vid = 1; /* track_index = 1 for video */
                                              +    media_packet_h vid_pkt;
                                              +    while (!is_eos) {
                                              +        /* Read encoded video data */
                                              +        /* Get the proper video media packet from, for example, mediacodec/mediademuxer */
                                              +        user_func_get_media_packet(&vid_pkt, &is_eos);
                                              +        if (!is_eos) {
                                              +            mediamuxer_write_sample(myMuxer, track_index_vid, vid_pkt);
                                              +            media_packet_destroy(vid_pkt);
                                              +        } else {
                                              +            g_print("\nVideo while done in the test suite");
                                              +            mediamuxer_close_track(myMuxer, track_index_vid);
                                              +        }
                                              +    }
                                              +
                                              +    return (void *)status;
                                              +}
                                              +
                                              +
                                            2. + +
                                            3. After you have finished work with the media muxer handle, reset the media muxer and destroy the handle by using the mediamuxer_stop() and mediamuxer_destroy() functions. +

                                              The media muxer state changes to MEDIAMUXER_STATE_NONE.

                                              +
                                              +ret = mediamuxer_stop(muxer);
                                              +if (ret != MEDIAMUXER_ERROR_NONE)
                                              +    return false;
                                              +ret = mediamuxer_destroy(muxer);
                                              +if (ret != MEDIAMUXER_ERROR_NONE)
                                              +    return false;
                                              +
                                              +
                                            4. +
                                            + + + + + +
                                            + +Go to top + + + + + + + + diff --git a/org.tizen.tutorials/html/native/multimedia/media_streamer_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/media_streamer_tutorial_n.htm new file mode 100644 index 0000000..7016ed3 --- /dev/null +++ b/org.tizen.tutorials/html/native/multimedia/media_streamer_tutorial_n.htm @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + Media Streamer: Streaming Video Content over IP + + + + + + +
                                            +

                                            Media Streamer: Streaming Video Content over IP

                                            + +

                                            This tutorial demonstrates how you can use the media streamer functionalities to stream video content in the form of Videotestsrc in the broadcast manual mode.

                                            + +

                                            Figure: Topology scheme of the media streamer Videotestsrc streaming scenario

                                            +

                                            Media streamer scenario

                                            + +

                                            To launch streaming, you must create a server part media streamer on the 1st device and a client part media streamer on the 2nd device. While creating the server part, you must indicate the IP address of the client part in the 127.0.0.1 format to stream to.

                                            + + +

                                            Warm-up

                                            + +

                                            Become familiar with the Media Streamer API basics by learning about:

                                            + + + +

                                            Creating the Server Part

                                            + +

                                            To create the server part:

                                            +
                                              +
                                            1. Create the media streamer handle and call the media_streamer_create() function: +
                                              +media_streamer_h ms_streamer;
                                              +int media_streamer_create(&ms_streamer);
                                              +
                                              +

                                              Memory is allocated for the given handle.

                                              +
                                            2. +
                                            3. Create a source node of the video data stream to transfer to the client part. +

                                              For example, the Videotest node is a checkerboard pattern of colors at the edge of the YCbCr gamut and nearby colors that are out of gamut.

                                              +
                                                +
                                              1. Create the Videotestsrc source node: +
                                                +media_streamer_node_h video_src = NULL;
                                                +media_streamer_node_create_src(MEDIA_STREAMER_NODE_SRC_TYPE_VIDEO_TEST, &video_src);
                                                +
                                                +
                                              2. +
                                              3. Add the Videotestsrc source node to the media streamer: +
                                                +media_streamer_node_add(ms_streamer, video_src);
                                                +
                                                +
                                              4. +
                                              +
                                            4. +
                                            5. To transfer data over an IP connection, create the final sending node on the server part and the first receiving node on the client part. The creation of the client part is described in Creating the Client Part. +

                                              The Real Time Protocol (RTP) node is universal and unique at the same time, and capable of performing enormous work on the RTP packets for their truthful and confident transmission, such as RTP packet validation, maintenance of the SSRC participant database, scheduling of RR/SR RTCP packets, and parsing codec streams transmitted in the same RTP session.

                                              +
                                                +
                                              1. Create the rtp_bin RTP node: +
                                                +media_streamer_node_h rtp_bin = NULL;
                                                +media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_RTP, NULL, NULL, &rtp_bin);
                                                +
                                                +
                                              2. +
                                              3. Create a bundle and add the RTP node parameters to it: +
                                                +bundle *params = bundle_create();
                                                +bundle_add_str(params, MEDIA_STREAMER_PARAM_VIDEO_OUT_PORT, "5000");
                                                +bundle_add_str(params, MEDIA_STREAMER_PARAM_HOST, "127.0.0.1");
                                                +media_streamer_node_set_params(rtp_bin, params);
                                                +
                                                +
                                              4. +
                                              5. Add the RTP node to the media streamer: +
                                                +media_streamer_node_add(ms_streamer, rtp_bin);
                                                +
                                                +
                                              6. +
                                              +
                                            6. +
                                            7. Create the encoding format. +

                                              To turn raw video from Videotestsrc or captured video data into encoded video data, an encoder is needed. The conversion of raw video streams (scaling, frame rate conversion, colorspace conversion, and samplerate conversion) is one of the main tasks to conform to the profile output format. The encoding format can be H263 or H264, for example.

                                              +
                                              +media_format_h vfmt_encoded = NULL;
                                              +/* Define encoded video format */
                                              +media_format_create(&vfmt_encoded);
                                              +if (media_format_set_video_mime(vfmt_encoded, MEDIA_FORMAT_H263) != MEDIA_FORMAT_ERROR_NONE)
                                              +    g_print("media_format_set_video_mime failed!");
                                              +
                                              +media_format_set_video_width(vfmt_encoded, 800);
                                              +media_format_set_video_height(vfmt_encoded, 600);
                                              +media_format_set_video_avg_bps(vfmt_encoded, 10000);
                                              +media_format_set_video_max_bps(vfmt_encoded, 30000);
                                              +
                                              +
                                            8. +
                                            9. Create the video encoder node. +

                                              The video converter, video scale, video encoder, video filter, and video parser elements are logically connected inside the video encoder node. They are all initially predefined in the .ini file.

                                              +
                                              +media_streamer_node_h video_enc = NULL;
                                              +media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_ENCODER, NULL, vfmt_encoded, &video_enc);
                                              +
                                              +

                                              Add the video encoder node to the media streamer:

                                              +
                                              +media_streamer_node_add(ms_streamer, video_enc);
                                              +
                                              +
                                            10. +
                                            11. An encoded video from the encoder must be loaded in RTP packets for further transmission through the RTP protocol connection. It is used right before the RTP node, which sends the received RTP packets into the network source or before the UDP sink that pushes the UDP packets into the network. +
                                                +
                                              1. Create the video pay node: +
                                                +media_streamer_node_h video_pay = NULL;
                                                +media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_PAY, NULL, vfmt_encoded, &video_pay);
                                                +
                                                +
                                              2. +
                                              3. Add the video pay node to the media streamer: +
                                                +media_streamer_node_add(ms_streamer, video_pay);
                                                +
                                                +
                                              4. +
                                              +
                                            12. +
                                            13. To have a proper functionality for streaming nodes, link the nodes between each other into a logic chain. +
                                                +
                                              1. Find out the pad names of the nodes to be linked: +
                                                +char **src_pad_name = NULL;
                                                +int src_pad_num = 0;
                                                +char **sink_pad_name = NULL;
                                                +int sink_pad_num = 0;
                                                +media_streamer_node_get_pad_name(video_pay, &src_pad_name, src_pad_num, &sink_pad_name, &sink_pad_num);
                                                +
                                                +
                                              2. +
                                              3. Link the nodes consequently into a line: +
                                                +media_streamer_node_link(video_src, "src", video_enc, "sink");
                                                +media_streamer_node_link(video_enc, "src", video_pay, "sink");
                                                +media_streamer_node_link(video_pay, "src", rtp_bin, "video_in");
                                                +
                                                +
                                              4. +
                                              +
                                            14. +
                                            + + +

                                            Preparing the Server Part

                                            + +

                                            To prepare the server part of the media streamer, transfer the nodes from the MEDIA_STREAMER_STATE_IDLE state to the MEDIA_STREAMER_STATE_READY state.

                                            +

                                            Call the media_streamer_prepare() function to change the state:

                                            +
                                            +int media_streamer_prepare(ms_streamer);
                                            +
                                            + +

                                            Playing the Server Part

                                            + +

                                            To play the server part of the Media Streamer, transfer the nodes from the MEDIA_STREAMER_STATE_READY state to the MEDIA_STREAMER_STATE_PLAYING state.

                                            +

                                            Call the media_streamer_play() function to change the state and start playing:

                                            +
                                            +int media_streamer_play(ms_streamer);
                                            +
                                            + +

                                            Creating the Client Part

                                            + +

                                            To create the client part on the 2nd device on which the server part device is intended to stream to through an IP:

                                            +
                                              +
                                            1. Create the media streamer handle and call the media_streamer_create() function: +
                                              +media_streamer_h ms_streamer;
                                              +int media_streamer_create(&ms_streamer);
                                              +
                                              +

                                              Memory is allocated for the given handle.

                                              +
                                            2. +
                                            3. To enable video output, a proper video sink node must be present. +
                                                +
                                              1. Create the video sink node: +
                                                +media_streamer_node_h video_sink = NULL;
                                                +media_streamer_node_create_sink(MEDIA_STREAMER_NODE_SINK_TYPE_OVERLAY, &video_src);
                                                +
                                                +
                                              2. +
                                              3. Add the video sink node to the media streamer: +
                                                +media_streamer_node_add(ms_streamer, video_sink);
                                                +
                                                +
                                              4. +
                                              +
                                            4. +
                                            5. Create the encoding format. +

                                              To receive video in a proper format, set it initially to have a proper video stream frame on the client part.

                                              +
                                              +media_format_h vfmt_encoded = NULL;
                                              +/* Define the encoded video format */
                                              +media_format_create(&vfmt_encoded);
                                              +if (media_format_set_video_mime(vfmt_encoded, MEDIA_FORMAT_H263) != MEDIA_FORMAT_ERROR_NONE)
                                              +    g_print("media_format_set_video_mime failed!");
                                              +
                                              +media_format_set_video_width(vfmt_encoded, 800);
                                              +media_format_set_video_height(vfmt_encoded, 600);
                                              +media_format_set_video_avg_bps(vfmt_encoded, 10000);
                                              +media_format_set_video_max_bps(vfmt_encoded, 30000);
                                              +
                                              +
                                            6. +
                                            7. To receive data over an IP connection, first create the receiving node on the client part to be able to receive RTP packets for their further decoding into a video stream. +

                                              The RTP node is universal and unique at the same time, and capable of performing enormous work on RTP packets for their truthful and confident receiving, such as keeping per participant statistics based on received RTCP packets, allowing an application to easily receive and decode an RTP stream with multiple SSRCs, and reordering and removing duplicate RTP packets as they are received from a network source.

                                              +
                                                +
                                              1. Create the rtp_bin RTP node: +
                                                +media_streamer_node_h rtp_bin = NULL;
                                                +media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_RTP, NULL, NULL, &rtp_bin);
                                                +
                                                +
                                              2. +
                                              3. Create a bundle and add the RTP node parameters to it: +
                                                +bundle *params = bundle_create();
                                                +bundle_add_str(params, MEDIA_STREAMER_PARAM_VIDEO_IN_PORT, "5005");
                                                +media_streamer_node_set_params(rtp_bin, params);
                                                +
                                                +
                                              4. +
                                              5. Set the incoming format for the RTP node: +
                                                +media_streamer_node_set_pad_format(rtp_node, "video_in_rtp", vfmt_encoded);
                                                +
                                                +
                                              6. +
                                              7. Add the RTP node to the media streamer: +
                                                +media_streamer_node_add(ms_streamer, rtp_bin);
                                                +
                                                +
                                              8. +
                                              +
                                            8. +
                                            9. To extract raw video from RTP packets, depayload them for further decoding to get a valid video data stream. It is used right after the RTP node, which supplies the received RTP packets from the network source, or after the UDP source that reads the UDP packets from the network. +
                                                +
                                              1. Create the video depay node: +
                                                +media_streamer_node_h video_depay= NULL;
                                                +media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_DEPAY, NULL, vfmt_encoded, &video_depay);
                                                +
                                                +
                                              2. +
                                              3. Add the video depay node to the media streamer: +
                                                +media_streamer_node_add(ms_streamer, video_depay);
                                                +
                                                +
                                              4. +
                                              +
                                            10. +
                                            11. Create the video decoder node. +

                                              The video decoder, video parser, video converter, and video scale elements are logically connected inside the video decider node. They are all initially predefined in the .ini file.

                                              +
                                              +media_streamer_node_h video_dec = NULL;
                                              +media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_DECODER, NULL, vfmt_encoded, &video_dec);
                                              +
                                              +

                                              Add the video decoder node to the media streamer:

                                              +
                                              +media_streamer_node_add(ms_streamer, video_dec);
                                              +
                                              +
                                            12. +
                                            13. Create the video queue node: +
                                              +media_streamer_node_h video_queue= NULL;
                                              +media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_QUEUE, NULL, vfmt_encoded, &video_queue);
                                              +
                                              +

                                              Add the video queue node to the media streamer:

                                              +
                                              +media_streamer_node_add(ms_streamer, video_queue);
                                              +
                                              +
                                            14. +
                                            15. To have a proper receiving node functionality, link the client nodes between each other into a logic chain: +
                                              +media_streamer_node_link(video_depay, "src", video_dec, "sink");
                                              +media_streamer_node_link(video_dec, "src", video_queue, "sink");
                                              +media_streamer_node_link(video_queue, "src", video_sink, "sink");
                                              +
                                              +
                                            16. +
                                            + +

                                            Preparing the Client Part

                                            + +

                                            To prepare the client part of the media streamer, transfer the nodes from the MEDIA_STREAMER_STATE_IDLE state to the MEDIA_STREAMER_STATE_READY state.

                                            +

                                            Call the media_streamer_prepare() function to change the state:

                                            +
                                            +int media_streamer_prepare(ms_streamer);
                                            +
                                            + +

                                            Playing the Client Part

                                            + +

                                            To play the client part of the media streamer, transfer the nodes from the MEDIA_STREAMER_STATE_READY state to the MEDIA_STREAMER_STATE_PLAYING state.

                                            +

                                            Call the media_streamer_play() function to change the state and start playing:

                                            +
                                            +int media_streamer_play(ms_streamer);
                                            +
                                            +

                                            At this point, the VideoTest Streaming is shown on the client part device.

                                            +

                                            Figure: Media streamer client part device receiving Videotestsrc streamed in the streaming scenario

                                            +

                                            Media streamer streaming media

                                            + + + + +
                                            + +Go to top + + + + + + + + diff --git a/org.tizen.tutorials/html/native/multimedia/media_tools_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/media_tools_tutorial_n.htm index 6372251..81f2af6 100644 --- a/org.tizen.tutorials/html/native/multimedia/media_tools_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/media_tools_tutorial_n.htm @@ -22,6 +22,7 @@

                                            Content

                                            @@ -45,47 +46,54 @@

                                            Become familiar with the Media Tool API basics by learning about:

                                            -

                                            Managing the Media Format Handle

                                            -

                                            To manage the media format handle:

                                            - -
                                              +

                                              Prerequisites

                                              +

                                              To enable your application to use the media tool functionality:

                                              +
                                              • -

                                                To use the media format handle of the Media Tool API (in mobile and wearable applications), include the <media_format.h> header file in your application:

                                                 #include <media_format.h>
                                                 
                                                -
                                              • -
                                              • +

                                                To use the media packet handle of the Media Tool API, include the <media_packet.h> header file in your application:

                                                +
                                                +#include <media_packet.h>
                                                +
                                                +
                                              • +
                                              + +

                                              Managing the Media Format Handle

                                              +

                                              To manage the media format handle:

                                              + +
                                                +
                                              1. Define a media_format_h variable for the media format handle, and pass the variable to the media_format_create() function, which returns the handle.

                                                To set the video information when creating the handle:

                                                 media_format_h format;
                                                -if (media_format_create(&format) == MEDIA_FORMAT_ERROR_NONE)
                                                -{
                                                -   media_format_set_video_mime(format, MEDIA_FORMAT_H264_HP);
                                                -   media_format_set_video_width(format, 640);
                                                -   media_format_set_video_height(format, 480);
                                                -   media_format_set_video_avg_bps(format, 10000000);
                                                -   media_format_set_video_max_bps(format, 15000000);
                                                -}
                                                -else
                                                -{
                                                -   printf("media_format_create() failed!");
                                                +if (media_format_create(&format) == MEDIA_FORMAT_ERROR_NONE) {
                                                +    media_format_set_video_mime(format, MEDIA_FORMAT_H264_HP);
                                                +    media_format_set_video_width(format, 640);
                                                +    media_format_set_video_height(format, 480);
                                                +    media_format_set_video_avg_bps(format, 10000000);
                                                +    media_format_set_video_max_bps(format, 15000000);
                                                +} else {
                                                +    printf("media_format_create() failed!");
                                                 }
                                                 
                                                @@ -107,13 +115,9 @@ int avg_bps; int max_bps; if (media_format_get_video_info(fmt, &mimetype, &w, &h, &avg_bps, &max_bps) == MEDIA_PACKET_ERROR_NONE) -{ -   printf("media_format_get_video_info success! width = %d, height = %d", w, h); -} +    printf("media_format_get_video_info success! width = %d, height = %d", w, h); else -{ -   print("media_format_get_video failed..."); -} +    print("media_format_get_video failed...");

                                                To retrieve the audio format information, use the media_format_get_audio_info() function.

                                                @@ -130,16 +134,6 @@ else
                                              2. -

                                                To use the media packet handle of the Media Tool API (in mobile and wearable applications), include the <media_packet.h> header file in your application:

                                                - -
                                                -#include <media_packet.h>
                                                -
                                                - -
                                              3. - -
                                              4. -

                                                Define a media_packet_h variable for the media packet handle, and pass the variable to the appropriate media_packet_create_XXX() function (as the last parameter) with an existing media format handle (as the first parameter).

                                                After creating the media packet handle, call the media_format_unref() function for the media format handle. Because all functions that create a media packet handle increase the reference count of the media format handle, you must decrease the count.

                                                @@ -156,29 +150,28 @@ else
                                                 {
                                                -   media_format_h fmt;
                                                -   media_packet_h packet;
                                                -
                                                -   media_format_create(&fmt);
                                                -   media_format_set_video_mime(format, MEDIA_FORMAT_H264_HP);
                                                -   media_format_set_video_width(format, 640);
                                                -   media_format_set_video_height(format, 480);
                                                -   media_format_set_video_avg_bps(format, 10000000);
                                                -   media_format_set_video_max_bps(format, 15000000);
                                                -
                                                -   // MEDIA_FORMAT_H264_HP data type is MEDIA_FORMAT_ENCODED and the buffer is allocated into the heap
                                                -   // If the data type is MEDIA_FORMAT_RAW, the buffer is allocated into the TBM surface
                                                -
                                                -   media_packet_create_alloc(fmt, _finalize_callback, fcb_data, &packet);
                                                -   media_format_unref(fmt);
                                                -
                                                -   media_packet_destroy(packet);
                                                +    media_format_h fmt;
                                                +    media_packet_h packet;
                                                +
                                                +    media_format_create(&fmt);
                                                +    media_format_set_video_mime(format, MEDIA_FORMAT_H264_HP);
                                                +    media_format_set_video_width(format, 640);
                                                +    media_format_set_video_height(format, 480);
                                                +    media_format_set_video_avg_bps(format, 10000000);
                                                +    media_format_set_video_max_bps(format, 15000000);
                                                +
                                                +    /* MEDIA_FORMAT_H264_HP data type is MEDIA_FORMAT_ENCODED and the buffer is allocated into the heap */
                                                +    /* If the data type is MEDIA_FORMAT_RAW, the buffer is allocated into the TBM surface */
                                                +    media_packet_create_alloc(fmt, _finalize_callback, fcb_data, &packet);
                                                +    media_format_unref(fmt);
                                                +
                                                +    media_packet_destroy(packet);
                                                 }
                                                 
                                                 int
                                                 _finalize_callback(media_packet_h packet, int err, void* userdata)
                                                 {
                                                -   return MEDIA_PACKET_REUSE;
                                                +    return MEDIA_PACKET_REUSE;
                                                 }
                                                 
                                                @@ -190,25 +183,25 @@ _finalize_callback(media_packet_h packet, int err, void* userdata)
                                                 {
                                                -   media_format_h fmt;
                                                -   media_packet_h packet;
                                                -
                                                -   media_format_create(&fmt);
                                                -   media_format_set_video_mime(format, MEDIA_FORMAT_H264_HP);
                                                -   media_format_set_video_width(format, 640);
                                                -   media_format_set_video_height(format, 480);
                                                -   media_format_set_video_avg_bps(format, 10000000);
                                                -   media_format_set_video_max_bps(format, 15000000);
                                                -
                                                -   // Only create the handle, do not allocate a buffer
                                                -   media_packet_create(fmt, _finalize_callback, fcb_data, &packet);
                                                -   media_format_unref(fmt);
                                                +    media_format_h fmt;
                                                +    media_packet_h packet;
                                                +
                                                +    media_format_create(&fmt);
                                                +    media_format_set_video_mime(format, MEDIA_FORMAT_H264_HP);
                                                +    media_format_set_video_width(format, 640);
                                                +    media_format_set_video_height(format, 480);
                                                +    media_format_set_video_avg_bps(format, 10000000);
                                                +    media_format_set_video_max_bps(format, 15000000);
                                                +
                                                +    /* Only create the handle, do not allocate a buffer */
                                                +    media_packet_create(fmt, _finalize_callback, fcb_data, &packet);
                                                +    media_format_unref(fmt);
                                                 }
                                                 
                                                 int
                                                 _finalize_callback(media_packet_h packet, int err, void* userdata)
                                                 {
                                                -   return MEDIA_PACKET_FINALIZE;
                                                +    return MEDIA_PACKET_FINALIZE;
                                                 }
                                                 
                                                @@ -220,24 +213,24 @@ _finalize_callback(media_packet_h packet, int err, void* userdata)
                                                 {
                                                -   media_format_h fmt;
                                                -   media_packet_h packet;
                                                -
                                                -   media_format_create(&fmt);
                                                -   media_format_set_video_mime(format, MEDIA_FORMAT_RGBA);
                                                -   media_format_set_video_width(format, 128);
                                                -   media_format_set_video_height(format, 128);
                                                -   media_format_set_video_avg_bps(format, 10000000);
                                                -   media_format_set_video_avg_bps(format, 15000000);
                                                -
                                                -   media_packet_create_from_tbm_surface(fmt, surface, _finalize_callback, fcb_data, &packet);
                                                -   media_format_unref(fmt);
                                                +    media_format_h fmt;
                                                +    media_packet_h packet;
                                                +
                                                +    media_format_create(&fmt);
                                                +    media_format_set_video_mime(format, MEDIA_FORMAT_RGBA);
                                                +    media_format_set_video_width(format, 128);
                                                +    media_format_set_video_height(format, 128);
                                                +    media_format_set_video_avg_bps(format, 10000000);
                                                +    media_format_set_video_avg_bps(format, 15000000);
                                                +
                                                +    media_packet_create_from_tbm_surface(fmt, surface, _finalize_callback, fcb_data, &packet);
                                                +    media_format_unref(fmt);
                                                 }
                                                 
                                                 int
                                                 _finalize_callback(media_packet_h packet, int err, void* userdata)
                                                 {
                                                -   return MEDIA_PACKET_FINALIZE;
                                                +    return MEDIA_PACKET_FINALIZE;
                                                 }
                                                 
                                                @@ -249,26 +242,26 @@ _finalize_callback(media_packet_h packet, int err, void* userdata)
                                                 {
                                                -   media_format_h fmt;
                                                -   media_packet_h packet;
                                                -
                                                -   media_format_create(&fmt);
                                                -   media_format_set_video_mime(format, MEDIA_FORMAT_H264_HP);
                                                -   media_format_set_video_width(format, 640);
                                                -   media_format_set_video_height(format, 480);
                                                -   media_format_set_video_avg_bps(format, 10000000);
                                                -   media_format_set_video_avg_bps(format, 15000000);
                                                -
                                                -   media_packet_create_from_external_memory(fmt, mem_ptr, size, _finalize_callback, fcb_data, &packet);
                                                -   media_format_unref(fmt);
                                                +    media_format_h fmt;
                                                +    media_packet_h packet;
                                                +
                                                +    media_format_create(&fmt);
                                                +    media_format_set_video_mime(format, MEDIA_FORMAT_H264_HP);
                                                +    media_format_set_video_width(format, 640);
                                                +    media_format_set_video_height(format, 480);
                                                +    media_format_set_video_avg_bps(format, 10000000);
                                                +    media_format_set_video_avg_bps(format, 15000000);
                                                +
                                                +    media_packet_create_from_external_memory(fmt, mem_ptr, size, _finalize_callback, fcb_data, &packet);
                                                +    media_format_unref(fmt);
                                                 }
                                                 
                                                 int
                                                 _finalize_callback(media_packet_h packet, int err, void* userdata)
                                                 {
                                                -   // Do something
                                                +    /* Do something */
                                                 
                                                -   return MEDIA_PACKET_FINALIZE;
                                                +    return MEDIA_PACKET_FINALIZE;
                                                 }
                                                 
                                                @@ -285,24 +278,26 @@ _finalize_callback(media_packet_h packet, int err, void* userdata)
                                                 int ret = MEDIA_PACKET_ERROR_NONE;
                                                 
                                                -// format1 already exists
                                                +/* format1 already exists */
                                                 
                                                 media_packet_create_alloc(format1, NULL, NULL, &packet);
                                                 
                                                 ret = media_packet_set_duration(packet, duration);
                                                 
                                                -// After media_packet_get_format(), use media_format_unref()
                                                +/* After media_packet_get_format(), use media_format_unref() */
                                                 media_format_h tmp;
                                                 media_packet_get_format(packet, &tmp);
                                                 media_format_unref(tmp);
                                                 
                                                -// Set previously created format2 to packet
                                                -// After media_packet_set_format(), use media_format_unref()
                                                +/* Set previously created format2 to packet */
                                                +/* After media_packet_set_format(), use media_format_unref() */
                                                 media_packet_set_format(packet, format2);
                                                 
                                                -// Packet format is format2
                                                -// If format2 ref_count is 1, format2 is free
                                                -// If format2 ref_count is bigger than 1, it is not free
                                                +/*
                                                +   Packet format is format2
                                                +   If format2 ref_count is 1, format2 is free
                                                +   If format2 ref_count is bigger than 1, it is not free
                                                +*/
                                                 media_packet_destroy(packet);
                                                 
                                                diff --git a/org.tizen.tutorials/html/native/multimedia/media_vision_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/media_vision_tutorial_n.htm index fa37154..57eb32f 100644 --- a/org.tizen.tutorials/html/native/multimedia/media_vision_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/media_vision_tutorial_n.htm @@ -82,25 +82,24 @@

                                                Create a structure for storing the data required for barcode generation engine configuration:

                                                -typedef struct
                                                -_bargendata_s
                                                -{
                                                -   // Barcode information variables
                                                -   mv_barcode_type_e type;
                                                -   mv_barcode_qr_ecc_e ecc;
                                                -   mv_barcode_qr_mode_e mode;
                                                -   int version;
                                                +struct _bargendata_s {
                                                +    /* Barcode information variables */
                                                +    mv_barcode_type_e type;
                                                +    mv_barcode_qr_ecc_e ecc;
                                                +    mv_barcode_qr_mode_e mode;
                                                +    int version;
                                                 
                                                -   size_t width;
                                                -   size_t height;
                                                +    size_t width;
                                                +    size_t height;
                                                 
                                                -   mv_barcode_image_format_e image_format;
                                                +    mv_barcode_image_format_e image_format;
                                                 
                                                -   // Media source handle
                                                -   mv_source_h g_source;
                                                -   // Barcode generation engine handle
                                                -   mv_engine_config_h g_engine_cfg;
                                                -} bargendata_s;
                                                +    /* Media source handle */
                                                +    mv_source_h g_source;
                                                +    /* Barcode generation engine handle */
                                                +    mv_engine_config_h g_engine_cfg;
                                                +};
                                                +typedef struct _bargendata_s bargendata_s;
                                                 
                                                 static bargendata_s bargendata;
                                                 
                                                @@ -116,9 +115,7 @@ int error_code = 0; error_code = mv_create_engine_config(&bargendata.g_engine_cfg); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);

                                                For example, to define whether the barcode is generated with text, use the mv_engine_config_set_int_attribute() function with the MV_BARCODE_GENERATE_ATTR_TEXT attribute. The possible values for the attribute are defined in the mv_barcode_generate_attr_text_e enumeration. The default value is MV_BARCODE_GENERATE_ATTR_TEXT_INVISIBLE.

                                                @@ -150,25 +147,24 @@ if (error_code != MEDIA_VISION_ERROR_NONE)

                                                Create a structure for storing the data required for barcode detection engine configuration:

                                                -typedef struct
                                                -_bardetdata_s
                                                -{
                                                -   // Camera display variables
                                                -   Evas_Object *win;
                                                -   Evas_Object *rect;
                                                -   Evas *evas;
                                                +struct _bardetdata_s {
                                                +    /* Camera display variables */
                                                +    Evas_Object *win;
                                                +    Evas_Object *rect;
                                                +    Evas *evas;
                                                 
                                                -   int preview_width;
                                                -   int preview_height;
                                                +    int preview_width;
                                                +    int preview_height;
                                                 
                                                -   // Media source handle
                                                -   mv_source_h g_source;
                                                -   // Barcode detection engine handle
                                                -   mv_engine_config_h g_engine_cfg;
                                                +    /* Media source handle */
                                                +    mv_source_h g_source;
                                                +    /* Barcode detection engine handle */
                                                +    mv_engine_config_h g_engine_cfg;
                                                 
                                                -   // Camera handle
                                                -   camera_h g_camera;
                                                -} bargendata_s;
                                                +    /* Camera handle */
                                                +    camera_h g_camera;
                                                +};
                                                +typedef struct _bardetdata_s bargendata_s;
                                                 
                                                 static bardetdata_s bardetdata;
                                                 
                                                @@ -184,9 +180,7 @@ int error_code = 0; error_code = mv_create_source(&bardetdata.g_source); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);

                                                The source stores the barcode to be detected and all related data. You manage the source through the source handle.

                                                @@ -202,9 +196,7 @@ int error_code = 0; error_code = mv_create_engine_config(&bardetdata.g_engine_cfg); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);

                                                For example, to define the detection target, use the mv_engine_config_set_int_attribute() function with the MV_BARCODE_DETECT_ATTR_TARGET attribute. The possible values are defined in the mv_barcode_detect_attr_target_e enumeration. The default value is MV_BARCODE_DETECT_ATTR_TARGET_ALL.

                                                @@ -216,47 +208,37 @@ if (error_code != MEDIA_VISION_ERROR_NONE)

                                                To provide camera preview images, create the camera handle, set the camera display and the camera preview callback, and start the camera preview:

                                                -// Create the camera handle
                                                +/* Create the camera handle */
                                                 error_code = camera_create(CAMERA_DEVICE_CAMERA0, &bardetdata.g_camera);
                                                 if (error_code != CAMERA_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                -// Set the camera display
                                                +/* Set the camera display */
                                                 error_code = camera_set_display(bardetdata.g_camera, CAMERA_DISPLAY_TYPE_OVERLAY,
                                                                                 GET_DISPLAY(bardetdata.win));
                                                 if (error_code != CAMERA_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                -// Get the camera preview resolution
                                                +/* Get the camera preview resolution */
                                                 error_code = camera_get_preview_resolution(bardetdata.g_camera, &bardetdata.width,
                                                                                            &bardetdata.height);
                                                 if (error_code != CAMERA_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code %d", error_code);
                                                 
                                                -// Set the camera preview callback
                                                +/* Set the camera preview callback */
                                                 error_code = camera_set_media_packet_preview_cb(bardetdata.g_camera,
                                                                                                 _camera_media_packet_preview_cb,
                                                                                                 NULL);
                                                 if (error_code != CAMERA_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                -// Start the camera preview
                                                +/* Start the camera preview */
                                                 error_code = camera_start_preview(barcodeAppData.g_camera);
                                                 if (error_code != CAMERA_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                -

                                                For more information about the camera_set_display() function, see Initializing the Camera in the Camera tutorial.

                                                +

                                                For more information about the camera_set_display() function, see Configuring the Camera and its Callbacks in the Camera tutorial.

                                              5. @@ -300,9 +282,7 @@ int error_code = 0; error_code = mv_create_source(&bargendata.g_source); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code= %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code= %d", error_code);

                                                The source handle is used to save the generated barcode and related data into the source, and to access the barcode and related data from the source.

                                                @@ -321,9 +301,7 @@ error_code = mv_barcode_generate_source(bargendata.g_engine_cfg,                                         bargendata.g_source); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); @@ -341,28 +319,20 @@ unsigned int image_buffer_size = 0; error_code = mv_source_get_width(bargendata.g_source, &image_width); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); error_code = mv_source_get_height(bargendata.g_source, &image_height); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); error_code = mv_source_get_colorspace(bargendata.g_source, &image_colorspace); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); error_code = mv_source_get_buffer(bargendata.g_source, &image_buffer_ptr,                                   &image_buffer_size); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); @@ -374,9 +344,7 @@ if (error_code != MEDIA_VISION_ERROR_NONE)
                                                 error_code = mv_destroy_source(bargendata.g_source);
                                                 if (error_code != MEDIA_VISION_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                @@ -420,9 +388,7 @@ error_code = mv_barcode_generate_image(bargendata.g_engine_cfg,                                        bargendata.image_format); if (error_code != MEDIA_VISION_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); @@ -438,9 +404,7 @@ if (error_code != MEDIA_VISION_ERROR_NONE)
                                                 error_code = mv_destroy_engine_config(bargendata.g_engine_cfg);
                                                 if (error_code != MEDIA_VISION_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                @@ -479,24 +443,19 @@ if (error_code != MEDIA_VISION_ERROR_NONE) static void _camera_media_packet_preview_cb(media_packet_h pkt, void *user_data) { -   mv_rectangle_s mv_roi = {{0,0}, bardetdata.width, bardetdata.height}; - -   if (pkt == NULL) -   { -      return; -   } - -   error_code = mv_source_fill_by_media_packet(bardetdata.g_source, pkt); -   if (error_code != MEDIA_VISION_ERROR_NONE) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error code); -   } - -   if (pkt) -   { -      error_code = media_packet_destroy(pkt); -      pkt = NULL; -   } +    mv_rectangle_s mv_roi = {{0,0}, bardetdata.width, bardetdata.height}; + +    if (pkt == NULL) +        return; + +    error_code = mv_source_fill_by_media_packet(bardetdata.g_source, pkt); +    if (error_code != MEDIA_VISION_ERROR_NONE) +        dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error code); + +    if (pkt) { +        error_code = media_packet_destroy(pkt); +        pkt = NULL; +    } @@ -506,12 +465,10 @@ _camera_media_packet_preview_cb(media_packet_h pkt, void *user_data)

                                                In the _camera_media_packet_preview_cb() callback, detect barcodes in the image using the mv_barcode_detect() function:

                                                -   error_code = mv_barcode_detect(bardetdata.g_source, bardetdata.g_engine_cfg,
                                                -                                  mv_roi, _barcode_detected_cb, NULL);
                                                -   if (error_code != MEDIA_VISION_ERROR_NONE)
                                                -   {
                                                -      dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -   }
                                                +    error_code = mv_barcode_detect(bardetdata.g_source, bardetdata.g_engine_cfg,
                                                +                                   mv_roi, _barcode_detected_cb, NULL);
                                                +    if (error_code != MEDIA_VISION_ERROR_NONE)
                                                +        dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 }
                                                 
                                                @@ -533,20 +490,17 @@ _barcode_detected_cb(mv_source_h source, mv_engine_config_h engine_cfg,                      const mv_quadrangle_s *barcode_locations, const char *message[],                      const mv_barcode_type_e *types, int number_of_barcodes, void *user_data) { -   int i = 0; -   char type[50] = {‘\0}; - -   // Clear the source for the next preview image -   mv_source_clear(mv_source); - -   if (number_of_barcode > 0) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "the number of barcodes: %d", number_of barcode); -      for (i = 0; i < number_of_barcodes; i++) -      { -         dlog_print(DLOG_INFO, LOG_TAG, "%d >> message: %s\n", I, messages[i]); -      } -   } +    int i = 0; +    char type[50] = {'\0'}; + +    /* Clear the source for the next preview image */ +    mv_source_clear(mv_source); + +    if (number_of_barcode > 0) { +        dlog_print(DLOG_INFO, LOG_TAG, "the number of barcodes: %d", number_of barcode); +        for (i = 0; i < number_of_barcodes; i++) +            dlog_print(DLOG_INFO, LOG_TAG, "%d >> message: %s\n", I, messages[i]); +    } } @@ -559,21 +513,15 @@ _barcode_detected_cb(mv_source_h source, mv_engine_config_h engine_cfg,
                                                 error_code = camera_unset_media_packet_preview_cb(bardetdata.g_camera);
                                                 if (error_code != CAMERA_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                 error_code = camera_stop_preview(bardetdata.g_camera);
                                                 if (error_code != CAMERA_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                 error_code = camera_destroy(bardetdata.g_camera);
                                                 if (error_code != CAMERA_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 

                                                For more information, see Releasing Resources in the Camera tutorial.

                                                @@ -587,15 +535,11 @@ if (error_code != CAMERA_ERROR_NONE)
                                                 error_code = mv_destroy_engine_config(bardetdata.g_engine_cfg);
                                                 if (error_code != MEDIA_VISION_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                 error_code = mv_destroy_source(bardetdata.g_source)
                                                 if (error_code != MEDIA_VISION_ERROR_NONE)
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                diff --git a/org.tizen.tutorials/html/native/multimedia/metadata_editor_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/metadata_editor_tutorial_n.htm index c9bb1d8..2e0f2d9 100644 --- a/org.tizen.tutorials/html/native/multimedia/metadata_editor_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/metadata_editor_tutorial_n.htm @@ -107,41 +107,39 @@ static bool storage_cb(int storage_id, storage_type_e type, storage_state_e state,            const char *path, void *user_data) { -   if (type == STORAGE_TYPE_INTERNAL) -   { -      internal_storage_id = storage_id; +    if (type == STORAGE_TYPE_INTERNAL) { +        internal_storage_id = storage_id; -      return false; -   } +        return false; +    } -   return true; +    return true; } void _get_internal_storage_path() { -   int error; -   char *path = NULL; - -   error = storage_foreach_device_supported(storage_cb, NULL); -   error = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_MUSIC, &path); -   if (error == STORAGE_ERROR_NONE) -   { -      internal_music_storage_path = strdup(path); -      free(path); -   } +    int error; +    char *path = NULL; + +    error = storage_foreach_device_supported(storage_cb, NULL); +    error = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_MUSIC, &path); +    if (error == STORAGE_ERROR_NONE) { +        internal_music_storage_path = strdup(path); +        free(path); +    } } void _make_test_path() { -   int path_len = 0; +    int path_len = 0; -   path_len = strlen(internal_music_storage_path) + strlen(music_file_name) + 2; -   music_test_path = malloc(path_len); -   memset(music_test_path, 0x0, path_len); +    path_len = strlen(internal_music_storage_path) + strlen(music_file_name) + 2; +    music_test_path = malloc(path_len); +    memset(music_test_path, 0x0, path_len); -   snprintf(music_test_path, path_len, "%s/%s", internal_music_storage_path, music_file_name); +    snprintf(music_test_path, path_len, "%s/%s", internal_music_storage_path, music_file_name); } diff --git a/org.tizen.tutorials/html/native/multimedia/metadata_extractor_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/metadata_extractor_tutorial_n.htm index 3f46e26..db25e77 100644 --- a/org.tizen.tutorials/html/native/multimedia/metadata_extractor_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/metadata_extractor_tutorial_n.htm @@ -111,56 +111,53 @@ static bool storage_cb(int storage_id, storage_type_e type, storage_state_e state,            const char *path, void *user_data) { -   if (type == STORAGE_TYPE_INTERNAL) -   { -      internal_storage_id = storage_id; +    if (type == STORAGE_TYPE_INTERNAL) { +        internal_storage_id = storage_id; -      return false; -   } +        return false; +    } -   return true; +    return true; } void _get_internal_storage_path() { -   int error; -   char *path = NULL; - -   error = storage_foreach_device_supported(storage_cb, NULL); -   error = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_MUSIC, &path); -   if (error != STORAGE_ERROR_NONE) -   { -      internal_music_storage_path = strdup(path); -      free(path); -   } - -   error = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_VIDEOS, &path); -   if (error != STORAGE_ERROR_NONE) -   { -      internal_video_storage_path = strdup(path); -      free(path); -   } +    int error; +    char *path = NULL; + +    error = storage_foreach_device_supported(storage_cb, NULL); +    error = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_MUSIC, &path); +    if (error != STORAGE_ERROR_NONE) { +        internal_music_storage_path = strdup(path); +        free(path); +    } + +    error = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_VIDEOS, &path); +    if (error != STORAGE_ERROR_NONE) { +        internal_video_storage_path = strdup(path); +        free(path); +    } } -void +void _make_test_path() { -   int path_len = 0; +    int path_len = 0; -   path_len = strlen(internal_music_storage_path) + strlen(music_file_name) + 1; -   music_test_path = malloc(path_len); -   memset(music_test_path, 0x0, path_len); +    path_len = strlen(internal_music_storage_path) + strlen(music_file_name) + 1; +    music_test_path = malloc(path_len); +    memset(music_test_path, 0x0, path_len); -   strncat(music_test_path, internal_music_storage_path, strlen(internal_music_storage_path)); -   strncat(music_test_path, music_file_name, strlen(music_file_name)); +    strncat(music_test_path, internal_music_storage_path, strlen(internal_music_storage_path)); +    strncat(music_test_path, music_file_name, strlen(music_file_name)); -   path_len = strlen(internal_video_storage_path) + strlen(video_file_name) + 1; -   video_test_path = malloc(path_len); -   memset(video_test_path, 0x0, path_len); +    path_len = strlen(internal_video_storage_path) + strlen(video_file_name) + 1; +    video_test_path = malloc(path_len); +    memset(video_test_path, 0x0, path_len); -   strncat(video_test_path, internal_video_storage_path, strlen(internal_video_storage_path)); -   strncat(video_test_path, video_file_name, strlen(video_file_name)); +    strncat(video_test_path, internal_video_storage_path, strlen(internal_video_storage_path)); +    strncat(video_test_path, video_file_name, strlen(video_file_name)); } @@ -202,7 +199,7 @@ ret = metadata_extractor_create(&g_metadata_h);
                                                 ret = metadata_extractor_set_path(g_metadata_h, video_test_path);
                                                 
                                                -// Or
                                                +/* Or */
                                                 
                                                 ret = metadata_extractor_set_path(g_metadata_h, music_test_path);
                                                 
                                                @@ -224,10 +221,9 @@ char *value = NULL; ret = metadata_extractor_get_metadata(g_metadata_h, METADATA_DURATION, &value); dlog_print(DLOG_DEBUG, LOG_TAG, "METADATA_DURATION: %s\n", value); -if (value != NULL) -{ -   free(value); -   value = NULL; +if (value != NULL) { +    free(value); +    value = NULL; } @@ -250,16 +246,14 @@ char *artwork_mime = NULL; ret = metadata_extractor_get_artwork(g_metadata_h, &artwork, &artwork_size, &artwork_mime); dlog_print(DLOG_DEBUG, LOG_TAG, "Artwork: size: %d, mime type: %s\n", artwork_size, artwork_mime); -if (artwork != NULL) -{ -   free(artwork); -   artwork = NULL; +if (artwork != NULL) { +    free(artwork); +    artwork = NULL; } -if (artwork_mime != NULL) -{ -   free(artwork_mime); -   artwork_mime = NULL; +if (artwork_mime != NULL) { +    free(artwork_mime); +    artwork_mime = NULL; } @@ -278,11 +272,10 @@ unsigned long time_info = 0; char *lyrics = NULL; ret = metadata_extractor_get_synclyrics(g_metadata_h, 1, &time_info, &lyrics); -if (lyrics != NULL) -{ -   dlog_print(DLOG_DEBUG, LOG_TAG, "Synclyrics: time_info: %d, lyrics: %s\n", time_info, lyrics); -   free(lyrics); -   lyrics = NULL; +if (lyrics != NULL) { +    dlog_print(DLOG_DEBUG, LOG_TAG, "Synclyrics: time_info: %d, lyrics: %s\n", time_info, lyrics); +    free(lyrics); +    lyrics = NULL; } @@ -303,27 +296,25 @@ if (lyrics != NULL)

                                                The following example code first retrieves a frame at an unspecified time and prints the frame size, and then retrieves another frame at a specified time and prints its size:

                                                -// Use metadata_extractor_get_frame()
                                                +/* Use metadata_extractor_get_frame() */
                                                 int frame_size = 0;
                                                 void *frame = NULL;
                                                 
                                                 ret = metadata_extractor_get_frame(g_metadata_h, &frame, &frame_size);
                                                 dlog_print(DLOG_DEBUG, LOG_TAG, "Frame: size: %d\n", frame_size);
                                                -if (frame != NULL)
                                                -{
                                                -   free(frame);
                                                -   frame = NULL;
                                                +if (frame != NULL) {
                                                +    free(frame);
                                                +    frame = NULL;
                                                 }
                                                 
                                                -// Use metadata_extractor_get_frame_at_time()
                                                +/* Use metadata_extractor_get_frame_at_time() */
                                                 unsigned long timestamp = 500;
                                                 
                                                 ret = metadata_extractor_get_frame_at_time(g_metadata_h, timestamp, true, &frame, &frame_size);
                                                 dlog_print(DLOG_DEBUG, LOG_TAG, "Frame at %d: size: %d\n", timestamp, frame_size);
                                                -if (frame != NULL)
                                                -{
                                                -   free(frame);
                                                -   frame = NULL;
                                                +if (frame != NULL) {
                                                +    free(frame);
                                                +    frame = NULL;
                                                 }
                                                 
                                                diff --git a/org.tizen.tutorials/html/native/multimedia/multimedia_tutorials_n.htm b/org.tizen.tutorials/html/native/multimedia/multimedia_tutorials_n.htm index 0bf2d8e..6fb549a 100644 --- a/org.tizen.tutorials/html/native/multimedia/multimedia_tutorials_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/multimedia_tutorials_n.htm @@ -39,7 +39,10 @@
                                              6. Camera: Controlling a Camera Device

                                                Demonstrates how you can start a camera preview, configure various attributes, and take a photo.

                                              7. Image Util: Encoding, Decoding, and Transforming Images

                                                Demonstrates how you can convert, resize, rotate, and crop an image, and decode and encode a JPEG image.

                                              8. Media Codec: Encoding and Decoding Media Files

                                                Demonstrates how you can encode and decode media files using media codecs.

                                              9. +
                                              10. Media Demuxer: Parsing Multiplexed Media Streams

                                                Demonstrates how you can demux multiplexed media files.

                                              11. Media key: Managing Callbacks from Media Key Events

                                                Demonstrates how you can manage callbacks for media key events.

                                              12. +
                                              13. Media Muxer: Muxing Encoded Media Streams

                                                Demonstrates how you can mux encoded media streams into a compatible container format.

                                              14. +
                                              15. Media Streamer: Streaming Video Content over IP

                                                Demonstrates how you can stream video content in the broadcast manual mode.

                                              16. Media Tool: Managing Media Handles

                                                Demonstrates how you can create, set, and get media handles.

                                              17. Metadata Extractor: Extracting Metadata from an Input Media File

                                                Demonstrates how you can extract metadata from media files.

                                              18. OpenAL: Managing Playback Streams

                                                Demonstrates how you can manage a playback stream using OpenAL.

                                              19. diff --git a/org.tizen.tutorials/html/native/multimedia/openal_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/openal_tutorial_n.htm index 9b4b02f..572ee66 100644 --- a/org.tizen.tutorials/html/native/multimedia/openal_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/openal_tutorial_n.htm @@ -75,28 +75,27 @@

                                                Retrieve the default device name, and open the default device.

                                                The following example code verifies that a given extension is available, retrieves the names of all available devices and the name of the default device using the alcGetString() function, and opens the default device using the alcOpenDevice() function:

                                                -// Verify that a given extension is available for the current context
                                                +/* Verify that a given extension is available for the current context */
                                                 enumeration = alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT");
                                                 if (enumeration == AL_FALSE)
                                                -{
                                                -   LOGI("[%s] enumeration extension not available", __func__);
                                                -}
                                                +    LOGI("[%s] enumeration extension not available", __func__);
                                                 
                                                -// Retrieve a list of available devices
                                                -// Each device name is separated by a single NULL character
                                                -// and the list is terminated with 2 NULL characters
                                                +/*
                                                +   Retrieve a list of available devices
                                                +   Each device name is separated by a single NULL character
                                                +   and the list is terminated with 2 NULL characters
                                                +*/
                                                 deviceNameList = alcGetString(NULL, ALC_DEVICE_SPECIFIER));
                                                 
                                                -// Retrieve the default device name
                                                +/* Retrieve the default device name */
                                                 defaultDeviceName = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
                                                 
                                                -// Open the default device
                                                +/* Open the default device */
                                                 device = alcOpenDevice(defaultDeviceName);
                                                -if (!device)
                                                -{
                                                -   LOGI("[%s] unable to open default device", __func__);
                                                +if (!device) {
                                                +    LOGI("[%s] unable to open default device", __func__);
                                                 
                                                -   return;
                                                +    return;
                                                 }
                                                 
                                                 LOGI("[%s] Device: %s ", __func__, alcGetString(device, ALC_DEVICE_SPECIFIER));
                                                @@ -108,24 +107,22 @@ LOGI("[%s] Device: %s ", __func__, alcGetString(device, ALC_DEVICE_SPE
                                                 

                                                If the device is opened successfully, create a context for the device using the alcCreateContext() function, and set the context as active using the alcMakeContextCurrent() function:

                                                -// Create context
                                                +/* Create context */
                                                 context = alcCreateContext(device, NULL);
                                                -if (context == NULL)
                                                -{
                                                -   alcCloseDevice(device);
                                                -   LOGI("[%s] failed to create context", __func__);
                                                +if (context == NULL) {
                                                +    alcCloseDevice(device);
                                                +    LOGI("[%s] failed to create context", __func__);
                                                 
                                                -   return;
                                                +    return;
                                                 }
                                                 
                                                -// Set active context
                                                -if (!alcMakeContextCurrent(context))
                                                -{
                                                -   alcDestroyContext(context);
                                                -   alcCloseDevice(device);
                                                -   LOGI("[%s] failed to make default context", __func__);
                                                +/* Set active context */
                                                +if (!alcMakeContextCurrent(context)) {
                                                +    alcDestroyContext(context);
                                                +    alcCloseDevice(device);
                                                +    LOGI("[%s] failed to make default context", __func__);
                                                 
                                                -   return;
                                                +    return;
                                                 }
                                                 

                                                Once the device is associated with an active context, the AL commands are applied to that context.

                                                @@ -142,13 +139,13 @@ if (!alcMakeContextCurrent(context))

                                                Request the source using the alSources() function, and update the source attributes, such as the default gain and sound position:

                                                -// Request a source name
                                                +/* Request a source name */
                                                 alGenSources((ALuint)1, &source);
                                                 
                                                -// Set the default volume
                                                +/* Set the default volume */
                                                 alSourcef(source, AL_GAIN, 1);
                                                 
                                                -// Set the default position of the sound
                                                +/* Set the default position of the sound */
                                                 alSource3f(source, AL_POSITION, 0, 0, 0);
                                                 
                                                @@ -157,13 +154,13 @@ alSource3f(source, AL_POSITION, 0, 0, 0);

                                                Request the audio buffer, and specify the allocated PCM buffer and size:

                                                -// Request a buffer name
                                                +/* Request a buffer name */
                                                 alGenBuffers(1, &buffer);
                                                 
                                                 ALuint frequency = 22050;
                                                 ALenum format = AL_FORMAT_MONO8;
                                                 
                                                -// Specify sample data using alBufferData
                                                +/* Specify sample data using alBufferData */
                                                 alBufferData(buffer, format, _data_buffer, dataSize, frequency);
                                                 
                                                @@ -215,11 +212,11 @@ alBufferData(buffer, format, _data_buffer, dataSize, frequency);

                                                In the following example code, the whole audio buffer is allocated and filled before the playback starts using the alSourcei() function. The second parameter specifies the source type as static. Start the playback after changing the state to play.

                                                -// Function: _on_click1()
                                                -// Source specifies the current buffer object
                                                +/* Function: _on_click1() */
                                                +/* Source specifies the current buffer object */
                                                 alSourcei(source, AL_BUFFER, buffer);
                                                 
                                                -// Change the state to play
                                                +/* Change the state to play */
                                                 alSourcePlay(source);
                                                 
                                                @@ -228,8 +225,8 @@ alSourcePlay(source);

                                                When a stop event is triggered, change the playback state to stop to end the playback:

                                                -// Function: _on_click2()
                                                -// Change the state to stop
                                                +/* Function: _on_click2() */
                                                +/* Change the state to stop */
                                                 alSourceStop(source);
                                                 
                                                @@ -261,17 +258,16 @@ alcCloseDevice(device);
                                                 #define DATA_CHUNK_SIZE (1024)
                                                 
                                                -// This example uses 4 buffers and 1 source
                                                +/* This example uses 4 buffers and 1 source */
                                                 static ALuint buffer[4], source;
                                                 
                                                 alGenSources((ALuint)1, &source);
                                                 alGenBuffers(4, buffer);
                                                 
                                                -// Fill all the buffers with audio data from the wave file
                                                -for (iLoop = 0; iLoop < 4; iLoop++)
                                                -{
                                                -   alBufferData(buffer[iLoop], AL_FORMAT_MONO8, pData, DATA_CHUNK_SIZE, 22050);
                                                -   alSourceQueueBuffers(source, 1, &buffer[iLoop]);
                                                +/* Fill all the buffers with audio data from the wave file */
                                                +for (iLoop = 0; iLoop < 4; iLoop++) {
                                                +    alBufferData(buffer[iLoop], AL_FORMAT_MONO8, pData, DATA_CHUNK_SIZE, 22050);
                                                +    alSourceQueueBuffers(source, 1, &buffer[iLoop]);
                                                 }
                                                 
                                                @@ -281,38 +277,38 @@ for (iLoop = 0; iLoop < 4; iLoop++)

                                                If a loop detects a consumed buffer (iBuffersProcessed) by querying AL_BUFFERS_PROCESSED, dequeue the consumed buffer using the alSourceUnqueueBuffers() function. To continue the playback, fill and queue the buffer again using the alSourceQueueBuffers() function. Run the loop in a thread separate from the application main thread.

                                                -// Start playing the streamed audio
                                                +/* Start playing the streamed audio */
                                                 alSourcePlay(source);
                                                 LOGI("[%s] alSourcePlay", __func__);
                                                 
                                                -// Buffer queuing loop must operate in a new thread
                                                +/* Buffer queuing loop must operate in a new thread */
                                                 iBuffersProcessed = 0;
                                                -while (!thread_finish)
                                                -{
                                                -   usleep(10 * 1000); // Sleep 10 msec periodically
                                                +while (!thread_finish) {
                                                +    usleep(10 * 1000); /* Sleep 10 msec periodically */
                                                 
                                                -   alGetSourcei(source, AL_BUFFERS_PROCESSED, &iBuffersProcessed);
                                                +    alGetSourcei(source, AL_BUFFERS_PROCESSED, &iBuffersProcessed);
                                                 
                                                -   iTotalBuffersProcessed += iBuffersProcessed;
                                                -   LOGI("Buffers Processed %d", iTotalBuffersProcessed);
                                                +    iTotalBuffersProcessed += iBuffersProcessed;
                                                +    LOGI("Buffers Processed %d", iTotalBuffersProcessed);
                                                 
                                                -   // For each processed buffer, remove it from the source queue, read the next chunk of
                                                -   // audio data from the file, fill the buffer with new data, and add it to the source queue
                                                -   while (iBuffersProcessed)
                                                -   {
                                                -      // Remove the buffer from the queue (uiBuffer contains the buffer ID for the dequeued buffer)
                                                -      uiBuffer = 0;
                                                -      alSourceUnqueueBuffers(source, 1, &uiBuffer);
                                                +    /*
                                                +       For each processed buffer, remove it from the source queue, read the next chunk of
                                                +       audio data from the file, fill the buffer with new data, and add it to the source queue
                                                +    */
                                                +    while (iBuffersProcessed) {
                                                +        /* Remove the buffer from the queue (uiBuffer contains the buffer ID for the dequeued buffer) */
                                                +        uiBuffer = 0;
                                                +        alSourceUnqueueBuffers(source, 1, &uiBuffer);
                                                 
                                                -      // Read more pData audio data (if there is any)
                                                +        /* Read more pData audio data (if there is any) */
                                                 
                                                -      // Copy audio data to buffer
                                                -      alBufferData(uiBuffer, AL_FORMAT_MONO8, pData, DATA_CHUNK_SIZE, 22050);
                                                -      // Insert the audio buffer to the source queue
                                                -      alSourceQueueBuffers(source, 1, &uiBuffer);
                                                +        /* Copy audio data to buffer */
                                                +        alBufferData(uiBuffer, AL_FORMAT_MONO8, pData, DATA_CHUNK_SIZE, 22050);
                                                +        /* Insert the audio buffer to the source queue */
                                                +        alSourceQueueBuffers(source, 1, &uiBuffer);
                                                 
                                                -      iBuffersProcessed--;
                                                -   }
                                                +        iBuffersProcessed--;
                                                +    }
                                                 }
                                                 
                                                diff --git a/org.tizen.tutorials/html/native/multimedia/player_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/player_tutorial_n.htm index b196328..037460d 100644 --- a/org.tizen.tutorials/html/native/multimedia/player_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/player_tutorial_n.htm @@ -135,56 +135,53 @@ static bool storage_cb(int storage_id, storage_type_e type, storage_state_e state,            const char *path, void *user_data) { -   if (type == STORAGE_TYPE_INTERNAL) -   { -      internal_storage_id = storage_id; +    if (type == STORAGE_TYPE_INTERNAL) { +        internal_storage_id = storage_id; -      return false; -   } +        return false; +    } -   return true; +    return true; } void _get_storage_path() { -   int error_code = 0; -   char *path = NULL; - -   error_code = storage_foreach_device_supported(storage_cb, NULL); -   error_code = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_MUSIC, &path); -   if (error_code != STORAGE_ERROR_NONE) -   { -      audio_storage_path = strdup(path); -      free(path); -   } - -   error_code = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_VIDEOS, &path); -   if (error_code != STORAGE_ERROR_NONE) -   { -      video_storage_path = strdup(path); -      free(path); -   } +    int error_code = 0; +    char *path = NULL; + +    error_code = storage_foreach_device_supported(storage_cb, NULL); +    error_code = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_MUSIC, &path); +    if (error_code != STORAGE_ERROR_NONE) { +        audio_storage_path = strdup(path); +        free(path); +    } + +    error_code = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_VIDEOS, &path); +    if (error_code != STORAGE_ERROR_NONE) { +        video_storage_path = strdup(path); +        free(path); +    } } void _set_test_path() { -   int path_len = 0; +    int path_len = 0; -   path_len = strlen(audio_storage_path) + strlen(MP3_SAMPLE) + 1; -   audio_path = malloc(path_len); -   memset(audio_path, 0x0, path_len); +    path_len = strlen(audio_storage_path) + strlen(MP3_SAMPLE) + 1; +    audio_path = malloc(path_len); +    memset(audio_path, 0x0, path_len); -   strncat(audio_path, audio_storage_path, strlen(audio_storage_path)); -   strncat(audio_path, MP3_SAMPLE, strlen(MP3_SAMPLE)); +    strncat(audio_path, audio_storage_path, strlen(audio_storage_path)); +    strncat(audio_path, MP3_SAMPLE, strlen(MP3_SAMPLE)); -   path_len = strlen(video_storage_path) + strlen(MP4_SAMPLE) + 1; -   video_path = malloc(path_len); -   memset(video_path, 0x0, path_len); +    path_len = strlen(video_storage_path) + strlen(MP4_SAMPLE) + 1; +    video_path = malloc(path_len); +    memset(video_path, 0x0, path_len); -   strncat(video_path, video_storage_path, strlen(video_storage_path)); -   strncat(video_path, MP4_SAMPLE, strlen(MP4_SAMPLE)); +    strncat(video_path, video_storage_path, strlen(video_storage_path)); +    strncat(video_path, MP4_SAMPLE, strlen(MP4_SAMPLE)); }
                                                @@ -192,43 +189,41 @@ _set_test_path()
                                              20. Define a variable for the player handle, and create the handle by passing the variable to the player_create() function. You need the handle for defining which file to play and with what playback settings. The following example code also creates buttons for the UI to control the playback.

                                                -typedef struct
                                                -appdata
                                                -{
                                                -   player_h player;
                                                -}
                                                +struct appdata {
                                                +    player_h player;
                                                +};
                                                 
                                                 static void
                                                 init_base_player(appdata_s *ad)
                                                 {
                                                -   int error_code = 0;
                                                -   error_code = player_create(&ad->player);
                                                -   if (error_code != PLAYER_ERROR_NONE)
                                                -   {
                                                -      dlog_print(DLOG_ERROR, LOG_TAG, "failed to create");
                                                -   }
                                                -   // Perform more playback configuration, such as setting callbacks,
                                                -   // setting the source file URI, and preparing the player
                                                +    int error_code = 0;
                                                +    error_code = player_create(&ad->player);
                                                +    if (error_code != PLAYER_ERROR_NONE)
                                                +        dlog_print(DLOG_ERROR, LOG_TAG, "failed to create");
                                                +    /*
                                                +       Perform more playback configuration, such as setting callbacks,
                                                +       setting the source file URI, and preparing the player
                                                +    */
                                                 }
                                                 
                                                 static void
                                                 create_base_gui(appdata_s *ad)
                                                 {
                                                -   // Create a window
                                                -   // Create a button
                                                -   // Add a callback to the button
                                                -   evas_object_smart_callback_add(button_init, "clicked", init_base_player, ad);
                                                -   evas_object_smart_callback_add(button_end, "clicked", release_base_player, ad);
                                                -   // Create an Evas image object for the video surface
                                                +    /* Create a window */
                                                +    /* Create a button */
                                                +    /* Add a callback to the button */
                                                +    evas_object_smart_callback_add(button_init, "clicked", init_base_player, ad);
                                                +    evas_object_smart_callback_add(button_end, "clicked", release_base_player, ad);
                                                +    /* Create an Evas image object for the video surface */
                                                 }
                                                 
                                                 static void
                                                 app_create(void *data)
                                                 {
                                                -   appdata_s *ad = data;
                                                -   create_base_gui(ad);
                                                +    appdata_s *ad = data;
                                                +    create_base_gui(ad);
                                                 
                                                -   return true;
                                                +    return true;
                                                 }
                                                 
                                              21. @@ -245,21 +240,21 @@ app_create(void *data) static void _player_interrupted_cb(player_interrupted_coded_e code, void *data) { -   appdata_s *ad = data; -   player_state_e state; +    appdata_s *ad = data; +    player_state_e state; -   player_get_state(ad->player, &state); -   log_print(DLOG_INFO, LOG_TAG, "current player state = %d", state); -   // If the state is PLAYER_STATE_PAUSED, update UI (for example, button) +    player_get_state(ad->player, &state); +    log_print(DLOG_INFO, LOG_TAG, "current player state = %d", state); +    /* If the state is PLAYER_STATE_PAUSED, update UI (for example, button) */ } static void init_base_player(appdata_s *ad) { -   // Set an interruption callback if the application wants to know the reason -   error_code = player_set_interrupted_cb(g_player, _player_interrupted_cb, ad); -   if (error_code != PLAYER_ERROR_NONE) -      dlog_print(DLOG_ERROR, LOG_TAG, "failed to create"); +    /* Set an interruption callback if the application wants to know the reason */ +    error_code = player_set_interrupted_cb(g_player, _player_interrupted_cb, ad); +    if (error_code != PLAYER_ERROR_NONE) +        dlog_print(DLOG_ERROR, LOG_TAG, "failed to create"); }

                                                The playback is interrupted and the callback triggered when, for example, another multimedia application is run. The player state automatically changes to PLAYER_STATE_PAUSED or PLAYER_STATE_IDLE according to the session policy. To get the current state, use the player_get_state() function.

                                                @@ -277,11 +272,11 @@ _player_completed_cb(void *data) static void init_base_player(appdata_s *ad) { -   // Set a completed callback if the application wants to know when the playback ends -   error_code = player_set_completed_cb(g_player, _player_completed_cb, ad); +    /* Set a completed callback if the application wants to know when the playback ends */ +    error_code = player_set_completed_cb(g_player, _player_completed_cb, ad); -   if (error_code != PLAYER_ERROR_NONE) -      dlog_print(DLOG_ERROR, LOG_TAG, "failed to set completed cb"); +    if (error_code != PLAYER_ERROR_NONE) +        dlog_print(DLOG_ERROR, LOG_TAG, "failed to set completed cb"); } @@ -292,15 +287,15 @@ init_base_player(appdata_s *ad) static void _player_error_cb(int error_code, void *user_data) { -   dlog_print(DLOG_ERROR, LOG_TAG, "playback failed, error = %x", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "playback failed, error = %x", error_code); } static void init_base_player(appdata_s *ad) { -   error_code = player_set_error_cb(g_player, _player_error_cb, NULL); -   if (error_code != PLAYER_ERROR_NONE) -      dlog_print(DLOG_ERROR, LOG_TAG, "failed to set error cb"); +    error_code = player_set_error_cb(g_player, _player_error_cb, NULL); +    if (error_code != PLAYER_ERROR_NONE) +        dlog_print(DLOG_ERROR, LOG_TAG, "failed to set error cb"); }

                                                The player error callback is triggered when the player stops working due to an error. You can use the callback to try to recover from the error. For example, try to change the player state to PLAYER_STATE_READY by calling the player_stop() function. Then remove all other callbacks and reset the player by calling the player_unprepare() function. At the end, the player is in the PLAYER_STATE_IDLE state, so you can release the resources allocated to the player.

                                                @@ -404,12 +399,11 @@ error_code = player_prepare_async(ad->player, _prepared_cb, ad);

                                                Ensure that the player state has changed to PLAYER_STATE_READY. To check the state, use the player_get_state() function in a waiting loop:

                                                 player_state_e state;
                                                -do
                                                -{
                                                -   error_code = player_get_state(ad->player, &state);
                                                -   if (error_code != PLAYER_ERROR_NONE)
                                                -      break;
                                                -   usleep(1000);
                                                +do {
                                                +    error_code = player_get_state(ad->player, &state);
                                                +    if (error_code != PLAYER_ERROR_NONE)
                                                +        break;
                                                +    usleep(1000);
                                                 } while (state != PLAYER_STATE_READY);
                                                 
                                                @@ -417,18 +411,16 @@ do

                                                Start playing the video file using the player_start() function:

                                                 if (error_code == PLAYER_ERROR_NONE)
                                                -{
                                                -   error_code = player_start(g_player);
                                                -}
                                                +    error_code = player_start(g_player);
                                                 

                                                If you used the player_prepare_async() function to prepare the player, use the following callback function to handle the playback:

                                                 static void
                                                 _prepared_cb(void *data)
                                                 {
                                                -   appdata_s *ad = data;
                                                -   int error_code = 0;
                                                -   error_code = player_start(ad->player);
                                                +    appdata_s *ad = data;
                                                +    int error_code = 0;
                                                +    error_code = player_start(ad->player);
                                                 }
                                                 

                                                The player_start() function changes the player state from PLAYER_STATE_READY to PLAYER_STATE_PLAYING. The video file plays until you call the player_stop() or player_pause() function.

                                                @@ -491,8 +483,12 @@ dlog_print(DLOG_ERROR, LOG_TAG, "player_destroy = %d", error_code);
                                              22. Define the variables for player handlers, player states, file paths, playback time, and return value:

                                                -static player_h player_1, player_2, player_3;
                                                -static player_state_e state_1, state_2, state_3;
                                                +static player_h player_1;
                                                +static player_h player_2;
                                                +static player_h player_3;
                                                +static player_state_e state_1;
                                                +static player_state_e state_2;
                                                +static player_state_e state_3;
                                                 static int ret =0;
                                                 static char *path_1 = NULL;
                                                 static char *path_2 = NULL;
                                                @@ -557,34 +553,31 @@ ret = player_prepare(player_3);
                                                 
                                              23. Ensure that the player states have changed to PLAYER_STATE_READY. To check the states, use the player_get_state() function in a waiting loop:

                                                -// Wait to prepare player_1
                                                +/* Wait to prepare player_1 */
                                                 ret = player_get_state(player_1, &state_1);
                                                 
                                                -while (state_1 != PLAYER_STATE_READY)
                                                -{
                                                -   ret = player_get_state(player_1, &state_1);
                                                +while (state_1 != PLAYER_STATE_READY) {
                                                +    ret = player_get_state(player_1, &state_1);
                                                 
                                                -   usleep(1000);
                                                +    usleep(1000);
                                                 }
                                                 
                                                -// Wait to prepare player_2
                                                +/* Wait to prepare player_2 */
                                                 ret = player_get_state(player_2, &state_2);
                                                 
                                                -while (state_2 != PLAYER_STATE_READY)
                                                -{
                                                -   ret = player_get_state(player_2, &state_2);
                                                +while (state_2 != PLAYER_STATE_READY) {
                                                +    ret = player_get_state(player_2, &state_2);
                                                 
                                                -   usleep(1000);
                                                +    usleep(1000);
                                                 }
                                                 
                                                -// Wait to prepare player_3
                                                +/* Wait to prepare player_3 */
                                                 ret = player_get_state(player_3, &state_3);
                                                 
                                                -while (state_3 != PLAYER_STATE_READY)
                                                -{
                                                -   ret = player_get_state(player_3, &state_3);
                                                +while (state_3 != PLAYER_STATE_READY) {
                                                +    ret = player_get_state(player_3, &state_3);
                                                 
                                                -   usleep(1000);
                                                +    usleep(1000);
                                                 }
                                                 
                                              24. @@ -646,10 +639,9 @@ dlog_print(DLOG_ERROR, LOG_TAG, "player_is_display_visible = %d", erro
                                              25. If the display is not visible, make it visible using the player_set_display_visible() function with the second parameter set to true:

                                                -if (!is_visible)
                                                -{
                                                -   error_code = player_set_display_visible(player, true);
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "player_set_display_visible = %d", error_code);
                                                +if (!is_visible) {
                                                +    error_code = player_set_display_visible(player, true);
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "player_set_display_visible = %d", error_code);
                                                 }
                                                 
                                              26. @@ -707,7 +699,8 @@ dlog_print(DLOG_ERROR, LOG_TAG, "player_set_display_mode = %d", error_

                                                Video display size

                                                Retrieve the width and height of the video display using the player_get_video_size() function:

                                                -int width, height;
                                                +int width;
                                                +int height;
                                                 
                                                 error_code = player_get_video_size(player, &width, &height);
                                                 dlog_print(DLOG_ERROR, LOG_TAG, "player_is_display_visible = %d", error_code);
                                                @@ -727,7 +720,9 @@ dlog_print(DLOG_INFO, LOG_TAG, "player_get_duration = %d", error_code)
                                                 

                                                Audio stream details

                                                Retrieve the audio stream details using the player_get_audio_stream_info() function. The function returns the audio sample rate (in Hz), number of audio channels (1 for mono or 2 for stereo), and audio bit rate (in Hz).

                                                -int sample_rate, channels, bit_rate;
                                                +int sample_rate;
                                                +int channels;
                                                +int bit_rate;
                                                 
                                                 error_code = player_get_audio_stream_info(player, &sample_rate, &channels, &bit_rate);
                                                 dlog_print(DLOG_INFO, LOG_TAG, "player_get_audio_stream_info = %d", error_code);
                                                @@ -737,7 +732,8 @@ dlog_print(DLOG_INFO, LOG_TAG, "player_get_audio_stream_info = %d", er
                                                 

                                                Video stream details

                                                Retrieve the video stream details using the player_get_video_stream_info() function. The function returns the number of frames per second and the video bit rate (in Hz).

                                                -int fps, bit_rate;
                                                +int fps;
                                                +int bit_rate;
                                                 
                                                 error_code = player_get_video_stream_info(player, &fps, &bit_rate);
                                                 dlog_print(DLOG_INFO, LOG_TAG, "player_get_video_stream_info = %d", error_code);
                                                @@ -759,7 +755,12 @@ dlog_print(DLOG_INFO, LOG_TAG, "player_get_codec_info = %d", error_cod
                                                 

                                                Retrieve information about the album, artist, author, genre, title, and year using the player_get_content_info() function. The available metadata attributes are defined in the player_content_info_e enumeration (in mobile and wearable applications).

                                                -char *album, *artist, *author, *genre, *title, *year;
                                                +char *album;
                                                +char *artist;
                                                +char *author;
                                                +char *genre;
                                                +char *title;
                                                +char *year;
                                                 
                                                 error_code = player_get_content_info(player, PLAYER_CONTENT_INFO_ALBUM, &album);
                                                 dlog_print(DLOG_INFO, LOG_TAG, "player_get_content_info album = %d", album);
                                                diff --git a/org.tizen.tutorials/html/native/multimedia/radio_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/radio_tutorial_n.htm
                                                index 1679220..c679a4c 100644
                                                --- a/org.tizen.tutorials/html/native/multimedia/radio_tutorial_n.htm
                                                +++ b/org.tizen.tutorials/html/native/multimedia/radio_tutorial_n.htm
                                                @@ -68,31 +68,27 @@
                                                 
                                              27. Define a handle for the radio using the radio_create() function:

                                                 #define MAX_FREQUENCIES 10
                                                -typedef struct
                                                -radioInfo
                                                -{
                                                -   radio_h radio;
                                                -   int frequencies[MAX_FREQUENCIES];
                                                -   int num_freq;
                                                -   int selected_channel;
                                                -} mRadioInfo;
                                                +struct radioInfo {
                                                +    radio_h radio;
                                                +    int frequencies[MAX_FREQUENCIES];
                                                +    int num_freq;
                                                +    int selected_channel;
                                                +};
                                                +typedef struct radioInfo mRadioInfo;
                                                 
                                                 mRadioInfo mRadio;
                                                 ret = radio_create(&mRadio.radio);
                                                 if (ret != RADIO_ERROR_NONE)
                                                -{
                                                -   return false;
                                                -}
                                                +    return false;
                                                 
                                              28. To receive notifications when the radio playback is interrupted, register a callback function using the radio_set_interrupted_cb() function:

                                                 ret = radio_set_interrupted_cb(mRadio.radio, on_radio_interrupted, &mRadio);
                                                -if (ret != RADIO_ERROR_NONE)
                                                -{
                                                -   // Delete the radio handle before closing the application
                                                +if (ret != RADIO_ERROR_NONE) {
                                                +    /* Delete the radio handle before closing the application */
                                                 
                                                -   return false;
                                                +    return false;
                                                 }
                                                 

                                                Radio playback is interrupted, for example, when the application moves to the background.

                                                @@ -102,21 +98,19 @@ if (ret != RADIO_ERROR_NONE) static void on_radio_interrupted(radio_interrupted_code_e code, void* userdata) { -   // Search the radio handle from userdata -   mRadioInfo* mRadio = (mRadioInfo *)userdata; - -   switch (code) -   { -      case RADIO_INTERRUPTED_COMPLETED: -         // Application, which was the source of the conflict, is now closed -         // Restart the radio playback here -      break; - -      default: -         // Radio listening is interrupted -         // Release the application resources or save the current state here -      break; -   } +    /* Search the radio handle from userdata */ +    mRadioInfo* mRadio = (mRadioInfo *)userdata; + +    switch (code) { +    case RADIO_INTERRUPTED_COMPLETED: +        /* Application, which was the source of the conflict, is now closed */ +        /* Restart the radio playback here */ +        break; +    default: +        /* Radio listening is interrupted */ +        /* Release the application resources or save the current state here */ +        break; +    } }
                                              29. @@ -131,17 +125,16 @@ on_radio_interrupted(radio_interrupted_code_e code, void* userdata)
                                                 ret = radio_set_scan_completed_cb(mRadio.radio, on_scan_finished, &mRadio);
                                                 if (ret != RADIO_ERROR_NONE)
                                                -{
                                                -   return false;
                                                -}
                                                +    return false;
                                                 
                                              30. Implement the scan complete callback:

                                                -
                                                void
                                                +
                                                +void
                                                 on_scan_finished(void* userdata)
                                                 {
                                                -   // Frequency scanning is completed
                                                -   // Tune in to one of the scanned frequencies and start listening
                                                +    /* Frequency scanning is completed */
                                                +    /* Tune in to one of the scanned frequencies and start listening */
                                                 }
                                                 
                                              31. @@ -157,10 +150,10 @@ radio_scan_start(mRadio.radio, on_scan_updated, &mRadio); void on_scan_updated(int frequency, void* userdata) { -   mRadioInfo* mRadio = (mRadioInfo *)userdata; -   // Store the radio channels in the array -   // Frequency values represent the kHz of the channel -   mRadio->frequencies[mRadio->num_freq++] = frequency; +    mRadioInfo* mRadio = (mRadioInfo *)userdata; +    /* Store the radio channels in the array */ +    /* Frequency values represent the kHz of the channel */ +    mRadio->frequencies[mRadio->num_freq++] = frequency; } @@ -185,18 +178,14 @@ on_scan_updated(int frequency, void* userdata)
                                                 ret = radio_set_frequency(mRadio.radio, mRadio.frequencies[mRadio.selected_channel]);
                                                 if (ret != RADIO_ERROR_NONE)
                                                -{
                                                -   return false;
                                                -}
                                                +    return false;
                                                 
                                              32. Start playing the frequency using the radio_start() function:

                                                 ret = radio_start(mRadio.radio);
                                                 if (ret != RADIO_ERROR_NONE)
                                                -{
                                                -   return false;
                                                -}
                                                +    return false;
                                                 

                                                If the radio emits no sound, check the signal strength with the radio_get_signal_strength() function, which returns the current signal strength as a dBuV value.

                                              33. @@ -212,22 +201,21 @@ if (ret != RADIO_ERROR_NONE)
                                                 ret = radio_seek_down(mRadio.radio, on_seek_completed, &mRadio);
                                                 if (ret != RADIO_ERROR_NONE)
                                                -{
                                                -   return false;
                                                -}
                                                +    return false;
                                                 

                                                To seek up, use the radio_seek_up() function in the same way.

                                              34. Implement the search complete callback that returns the adjacent frequency:

                                                -void on_seek_completed(int frequency, void* userdata)
                                                +void
                                                +on_seek_completed(int frequency, void* userdata)
                                                 {
                                                -   mRadioInfo *mRadio = (mRadioInfo *)userdata;
                                                -   int new_frequency = 0;
                                                +    mRadioInfo *mRadio = (mRadioInfo *)userdata;
                                                +    int new_frequency = 0;
                                                 
                                                -   // Search is complete, and the radio is tuned in to the new frequency
                                                -   // Application sets the new frequency and updates the user interface
                                                -   radio_get_frequency(mRadio->radio, &new_frequency);
                                                +    /* Search is complete, and the radio is tuned in to the new frequency */
                                                +    /* Application sets the new frequency and updates the user interface */
                                                +    radio_get_frequency(mRadio->radio, &new_frequency);
                                                 }
                                                 
                                              35. diff --git a/org.tizen.tutorials/html/native/multimedia/recorder_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/recorder_tutorial_n.htm index 7b5f846..546425c 100644 --- a/org.tizen.tutorials/html/native/multimedia/recorder_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/recorder_tutorial_n.htm @@ -93,16 +93,12 @@
                                                 static recorder_h g_recorder;
                                                 
                                                -// Create the audio recorder handle
                                                +/* Create the audio recorder handle */
                                                 int error_code = recorder_create_audiorecorder(&g_recorder);
                                                 if (error_code == RECORDER_ERROR_NONE)
                                                -{
                                                     dlog_print(DLOG_INFO, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                 else
                                                -{
                                                     dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                 

                                                The function sets the audio recorder state to RECORDER_STATE_CREATED.

                                                @@ -123,7 +119,7 @@ error_code = recorder_set_state_changed_cb(g_recorder, _state_changed_cb, NULL); static void _state_changed_cb(recorder_state_e previous, recorder_state_e current, bool by_policy, void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "_recorder_state_changed_cb (prev: %d, curr: %d)\n", previous, current); +    dlog_print(DLOG_INFO, LOG_TAG, "_recorder_state_changed_cb (prev: %d, curr: %d)\n", previous, current); } @@ -142,10 +138,10 @@ time_t rawtime = time(NULL); char filename[256] = {'\0'}; size_t size; -// Set the audio encoder +/* Set the audio encoder */ error_code = recorder_set_audio_encoder(g_recorder, RECORDER_AUDIO_CODEC_AAC); -// Set the audio sample rate +/* Set the audio sample rate */ error_code = recorder_attr_set_audio_samplerate(rec_data.recorder, 44100);

                                                The possible audio codec values are defined in the recorder_audio_codec_e enumeration (in mobile and wearable applications).

                                                @@ -163,7 +159,7 @@ error_code = recorder_attr_set_audio_samplerate(rec_data.recorder, 44100);
                                              36. Based on the audio codec, set the correct file format using the recorder_set_file_format() function. For example, if you set the codec to AAC, set the file format to 3GP.

                                                -// Set the file format according to the audio encoder
                                                +/* Set the file format according to the audio encoder */
                                                 error_code = recorder_set_file_format(g_recorder, RECORDER_FILE_FORMAT_3GP);
                                                 

                                                The possible file format values are defined in the recorder_file_format_e enumeration (in mobile and wearable applications).

                                                @@ -171,37 +167,34 @@ error_code = recorder_set_file_format(g_recorder, RECORDER_FILE_FORMAT_3GP);
                                              37. Based on the file format, define the correct file name, and set it using the recorder_set_filename() function. The function takes as a parameter the full path and name of the file to which the recorded audio data is to be stored.

                                                -// Create the file name
                                                -if (localtime_r(&rawtime, &localtime) != NULL)
                                                -{
                                                -   size = snprintf(filename, sizeof(filename), "%s/%s-%04i-%02i-%02i_%02i:%02i:%02i.3gp",
                                                -                   app_get_data_path(), FILENAME_PREFIX,
                                                -                   localtime.tm_year + 1900, localtime.tm_mon + 1, localtime.tm_mday,
                                                -                   localtime.tm_hour, localtime.tm_min, localtime.tm_sec);
                                                -}
                                                -else
                                                -{
                                                -   // Error handling
                                                +/* Create the file name */
                                                +if (localtime_r(&rawtime, &localtime) != NULL) {
                                                +    size = snprintf(filename, sizeof(filename), "%s/%s-%04i-%02i-%02i_%02i:%02i:%02i.3gp",
                                                +                    app_get_data_path(), FILENAME_PREFIX,
                                                +                    localtime.tm_year + 1900, localtime.tm_mon + 1, localtime.tm_mday,
                                                +                    localtime.tm_hour, localtime.tm_min, localtime.tm_sec);
                                                +} else {
                                                +    /* Error handling */
                                                 }
                                                 
                                                -// Set the full path and file name
                                                -// Set the file name according to the file format
                                                +/* Set the full path and file name */
                                                +/* Set the file name according to the file format */
                                                 error_code = recorder_set_filename(g_recorder, filename);
                                                 
                                              38. Set the file size limit, encoder bitrate, audio device, and sample rate:

                                                -// Set the maximum file size to 1024 (kB)
                                                +/* Set the maximum file size to 1024 (kB) */
                                                 error_code = recorder_attr_set_size_limit(g_recorder, 1024);
                                                 
                                                -// Set the audio encoder bitrate
                                                +/* Set the audio encoder bitrate */
                                                 error_code = recorder_attr_set_audio_encoder_bitrate(g_recorder, 28800);
                                                 
                                                -// Set the audio device to microphone
                                                +/* Set the audio device to microphone */
                                                 error_code = recorder_attr_set_audio_device(g_recorder, RECORDER_AUDIO_DEVICE_MIC);
                                                 
                                                -// Set the audio sample rate
                                                +/* Set the audio sample rate */
                                                 error_code = recorder_attr_set_audio_samplerate(g_recorder, 44100);
                                                 

                                                The possible audio device values are defined in the recorder_audio_device_e enumeration (in mobile and wearable applications).

                                                @@ -226,7 +219,7 @@ error_code = recorder_set_recording_limit_reached_cb(g_recorder, _recorder_recor static void _recorder_recording_limit_reached_cb(recorder_recording_limit_type_e type, void *user_data) { -   dlog_print(DLOG_DEBUG, LOG_TAG, "Recording limit reached: %d\n", type); +    dlog_print(DLOG_DEBUG, LOG_TAG, "Recording limit reached: %d\n", type); }
                                              39. @@ -290,32 +283,28 @@ error_code = recorder_pause(g_recorder);

                                                Both functions set the audio recorder state to RECORDER_STATE_READY.

                                                The following example code first checks the audio recorder state, and then stops the recorder and saves the recorded data to a file:

                                                -// Check the audio recorder state
                                                +/* Check the audio recorder state */
                                                 static bool
                                                 _recorder_expect_state(recorder_h recorder, recorder_state_e expected_state)
                                                 {
                                                -   recorder_state_e state;
                                                -   int error_code = recorder_get_state(recorder, &state);
                                                +    recorder_state_e state;
                                                +    int error_code = recorder_get_state(recorder, &state);
                                                 
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "recorder state = %d, expected recorder state = %d", state, expected_state);
                                                -   if (state == expected_state)
                                                -   {
                                                -      return TRUE;
                                                -   }
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "recorder state = %d, expected recorder state = %d", state, expected_state);
                                                +    if (state == expected_state)
                                                +        return TRUE;
                                                 
                                                -   return FALSE;
                                                +    return FALSE;
                                                 }
                                                 
                                                -// Stop the recorder and save the recorded data to a file
                                                -if (_recorder_expect_state(g_recorder, RECORDER_STATE_RECORDING) || _recorder_expect_state(g_recorder, RECORDER_STATE_PAUSED))
                                                -{
                                                -   error_code = recorder_commit(g_recorder);
                                                -   if (error_code != RECORDER_ERROR_NONE)
                                                -   {
                                                -      dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                +/* Stop the recorder and save the recorded data to a file */
                                                +if (_recorder_expect_state(g_recorder, RECORDER_STATE_RECORDING) || _recorder_expect_state(g_recorder, RECORDER_STATE_PAUSED)) {
                                                +    error_code = recorder_commit(g_recorder);
                                                +    if (error_code != RECORDER_ERROR_NONE) {
                                                +        dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                 
                                                -      return true;
                                                -   }
                                                +        return true;
                                                +    }
                                                 }
                                                 
                                                @@ -326,7 +315,7 @@ if (_recorder_expect_state(g_recorder, RECORDER_STATE_RECORDING) || _recorder_ex

                                                After you have finished recording, release all resources allocated to the audio recorder:

                                                1. -

                                                  Unregister the recording limit callback using the recorder_unset_recording_limit_reached_cb() function:

                                                  +

                                                  Deregister the recording limit callback using the recorder_unset_recording_limit_reached_cb() function:

                                                   error_code = recorder_unset_recording_limit_reached_cb(g_recorder);
                                                   
                                                  @@ -339,7 +328,7 @@ error_code = recorder_unprepare(g_recorder);

                                                  The function changes the audio recorder state from RECORDER_STATE_READY to RECORDER_STATE_CREATED.

                                                2. -

                                                  Unregister the state change callback using the recorder_unset_state_changed_cb() function:

                                                  +

                                                  Deregister the state change callback using the recorder_unset_state_changed_cb() function:

                                                   error_code = recorder_unset_state_changed_cb(g_recorder);
                                                   
                                                  @@ -376,12 +365,10 @@ error_code = recorder_destroy(g_recorder);
                                                3. Define a structure for storing the camera and video recorder handles and a Boolean variable specifying whether the video recorder is switched off:

                                                  -struct
                                                  -recdata
                                                  -{
                                                  -   bool shutdown;
                                                  -   recorder_h recorder;
                                                  -   camera_h camera;
                                                  +struct recdata {
                                                  +    bool shutdown;
                                                  +    recorder_h recorder;
                                                  +    camera_h camera;
                                                   };
                                                   
                                                4. @@ -430,21 +417,17 @@ rec_data.shutdown = FALSE; rec_data.camera = NULL; rec_data.recorder = NULL; -// Create the camera handle +/* Create the camera handle */ error_code = camera_create(CAMERA_DEVICE_CAMERA0, &rec_data.camera); if (error_code == CAMERA_ERROR_NONE) -{     dlog_print(DLOG_INFO, LOG_TAG, "error code = %d", error_code); -} else -{     dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); -}

                                                  The function sets the camera state to CAMERA_STATE_CREATED. To query the state, use the camera_get_state() function.

                                                  -
                                                5. Set the display for the camera preview using the camera_set_display() function. For more information, see Configuring the Camera in the Camera tutorial.

                                                6. +
                                                7. Set the display for the camera preview using the camera_set_display() function. For more information, see Configuring the Camera and its Callbacks in the Camera tutorial.

                                                @@ -468,7 +451,7 @@ ret = recorder_set_recording_limit_reached_cb(rec_data.recorder, _recorder_recor static void _recorder_recording_limit_reached_cb(recorder_recording_limit_type_e type, void *user_data) { -   dlog_print(DLOG_DEBUG, "Video Recorder", "Recording limit reached: %d\n", type); +    dlog_print(DLOG_DEBUG, "Video Recorder", "Recording limit reached: %d\n", type); } @@ -478,7 +461,7 @@ _recorder_recording_limit_reached_cb(recorder_recording_limit_type_e type, void
                                                 ret = recorder_start(rec_data.recorder);
                                                 
                                                -sleep(RECORD_LIMIT + 1); // Waits longer than the recording limit
                                                +sleep(RECORD_LIMIT + 1); /* Waits longer than the recording limit */
                                                 ret = recorder_pause(rec_data.recorder);
                                                 
                                                @@ -494,16 +477,12 @@ ret = recorder_pause(rec_data.recorder);
                                              40. To create the video recorder handle, use the recorder_create_videorecorder() function. The function takes as parameters the camera handle and the video recorder handle.

                                                -// Create the video recorder handle
                                                +/* Create the video recorder handle */
                                                 error_code = recorder_create_videorecorder(rec_data.camera, &rec_data.recorder);
                                                 if (error_code == RECORDER_ERROR_NONE)
                                                -{
                                                     dlog_print(DLOG_INFO, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                 else
                                                -{
                                                     dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                 

                                                The function sets the video recorder state to RECORDER_STATE_CREATED. To query the state, use the recorder_get_state() function.

                                              41. @@ -514,23 +493,19 @@ else
                                              42. Register a callback using the recorder_set_state_changed_cb() function:

                                                -// Set the state change callback for the video recorder
                                                +/* Set the state change callback for the video recorder */
                                                 error_code = recorder_set_state_changed_cb(rec_data.recorder, on_state_changed_cb, NULL);
                                                 if (error_code == RECORDER_ERROR_NONE)
                                                -{
                                                     dlog_print(DLOG_INFO, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                 else
                                                -{
                                                     dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code);
                                                -}
                                                 
                                              43. Define the state change callback.

                                                The following example code implements a simple callback that prints the previous and current video recorder states:

                                                -// State change callback for the video recorder
                                                +/* State change callback for the video recorder */
                                                 static void
                                                 on_state_changed_cb(recorder_state_e previous, recorder_state_e current, bool by_asm, void *data)
                                                 {
                                                @@ -558,10 +533,10 @@ recorder_video_codec_e supported_codec;
                                                 static bool
                                                 _video_encoder_cb(recorder_video_codec_e codec, void *user_data)
                                                 {
                                                -   recorder_video_codec_e * supported_codec = (recorder_video_codec_e*)user_data;
                                                -   *supported_codec = codec;
                                                +    recorder_video_codec_e * supported_codec = (recorder_video_codec_e*)user_data;
                                                +    *supported_codec = codec;
                                                 
                                                -   return false;
                                                +    return false;
                                                 }
                                                 
                                                 error_code = recorder_foreach_supported_video_encoder(rec_data.recorder, _video_encoder_cb, &supported_codec);
                                                @@ -571,7 +546,7 @@ error_code = recorder_foreach_supported_video_encoder(rec_data.recorder, _video_
                                                 
                                              44. Set the video codec using the recorder_set_video_encoder() function:

                                                -// Set the video encoder for the video recorder
                                                +/* Set the video encoder for the video recorder */
                                                 error_code = recorder_set_video_encoder(rec_data.recorder, supported_codec);
                                                 
                                              45. @@ -580,7 +555,7 @@ error_code = recorder_set_video_encoder(rec_data.recorder, supported_codec);
                                              46. To set the video encoder bitrate, use the recorder_attr_set_video_encoder_bitrate() function:

                                                -// Set the video encoder bitrate
                                                +/* Set the video encoder bitrate */
                                                 error_code = recorder_attr_set_video_encoder_bitrate(rec_data.recorder, g_bitrate);
                                                 
                                              47. @@ -594,7 +569,7 @@ error_code = recorder_attr_set_video_encoder_bitrate(rec_data.recorder, g_bitrat
                                              48. Set the file format using the recorder_set_file_format() function. Make sure the file format matches the video codec.

                                                -// Set the file format
                                                +/* Set the file format */
                                                 error_code = recorder_set_file_format(rec_data.recorder, RECORDER_FILE_FORMAT_MP4);
                                                 

                                                The possible file format values are defined in the recorder_file_format_e enumeration (in mobile and wearable applications).

                                                @@ -609,19 +584,16 @@ time_t rawtime = time(NULL); char filename[256] = {'\0'}; size_t size; -// Create the file name -if (localtime_r(&rawtime, &localtime) != NULL) -{ -   size = snprintf(filename, sizeof(filename), "%s/%s-%04i-%02i-%02i_%02i:%02i:%02i.mp4", -                   app_get_data_path(), FILENAME_PREFIX, -                   localtime.tm_year + 1900, localtime.tm_mon + 1, localtime.tm_mday, -                   localtime.tm_hour, localtime.tm_min, localtime.tm_sec); -} -else -{ -   // Error handling +/* Create the file name */ +if (localtime_r(&rawtime, &localtime) != NULL) { +    size = snprintf(filename, sizeof(filename), "%s/%s-%04i-%02i-%02i_%02i:%02i:%02i.mp4", +                    app_get_data_path(), FILENAME_PREFIX, +                    localtime.tm_year + 1900, localtime.tm_mon + 1, localtime.tm_mday, +                    localtime.tm_hour, localtime.tm_min, localtime.tm_sec); +} else { +    /* Error handling */ } -// Set the full path and file name +/* Set the full path and file name */ error_code = recorder_set_filename(rec_data.recorder, filename);
                                              49. @@ -643,7 +615,7 @@ error_code = recorder_set_filename(rec_data.recorder, filename);
                                              50. Prepare the video recorder using the recorder_prepare() function:

                                                -// Prepare the recorder
                                                +/* Prepare the recorder */
                                                 error_code = recorder_prepare(rec_data.recorder);
                                                 

                                                The function changes the video recorder state from RECORDER_STATE_CREATED to RECORDER_STATE_READY.

                                                @@ -652,7 +624,7 @@ error_code = recorder_prepare(rec_data.recorder);
                                              51. Start recording using the recorder_start() function. If the target file path and name have been set to an existing file, the existing file is replaced with a new file.

                                                -// Start the recorder
                                                +/* Start the recorder */
                                                 error_code = recorder_start(rec_data.recorder);
                                                 

                                                The function changes the video recorder state from RECORDER_STATE_READY to RECORDER_STATE_RECORDING.

                                                @@ -664,7 +636,7 @@ error_code = recorder_start(rec_data.recorder);
                                              52. Pause recording using the recorder_pause() function:

                                                -// Pause the recorder
                                                +/* Pause the recorder */
                                                 error_code = recorder_pause(rec_data.recorder);
                                                 

                                                The function changes the video recorder state from RECORDER_STATE_RECORDING to RECORDER_STATE_PAUSED.

                                                @@ -679,7 +651,7 @@ error_code = recorder_pause(rec_data.recorder);
                                              53. To stop recording without saving the recorded data, use the recorder_cancel() function. No data is saved to the target file.

                                                -// Stop the recorder without saving the recorded data
                                                +/* Stop the recorder without saving the recorded data */
                                                 error_code = recorder_cancel(rec_data.recorder);
                                                 
                                              54. @@ -687,7 +659,7 @@ error_code = recorder_cancel(rec_data.recorder);
                                              55. To stop recording and save the recorded data, use the recorder_commit() function. The data is saved to the target file.

                                                -// Stop the recorder and save the recorded data to a file
                                                +/* Stop the recorder and save the recorded data to a file */
                                                 error_code = recorder_commit(rec_data.recorder);
                                                 
                                              56. @@ -699,31 +671,31 @@ error_code = recorder_commit(rec_data.recorder);

                                                After you have finished recording, release all resources allocated to the video recorder:

                                                1. -

                                                  Unregister the recording limit callback using the recorder_unset_recording_limit_reached_cb() function:

                                                  +

                                                  Deregister the recording limit callback using the recorder_unset_recording_limit_reached_cb() function:

                                                  -// Unregister the recording limit callback
                                                  +/* Deregister the recording limit callback */
                                                   ret = recorder_unset_recording_limit_reached_cb(rec_data.recorder);
                                                   
                                                2. Reset the video recorder using the recorder_unprepare() function:

                                                  -// Unprepare the recorder
                                                  +/* Unprepare the recorder */
                                                   error_code = recorder_unprepare(rec_data->recorder);
                                                   

                                                  The function changes the video recorder state from RECORDER_STATE_READY to RECORDER_STATE_CREATED.

                                                3. -

                                                  Unregister the state change callback using the recorder_unset_state_changed_cb() function:

                                                  +

                                                  Deregister the state change callback using the recorder_unset_state_changed_cb() function:

                                                  -// Unregister the state change callback
                                                  +/* Deregister the state change callback */
                                                   error_code = recorder_unset_state_changed_cb(rec_data.recorder);
                                                   
                                                4. Release the video recorder resources using the recorder_destroy() function:

                                                  -// Destroy the recorder handle
                                                  +/* Destroy the recorder handle */
                                                   error_code = recorder_destroy(rec_data.recorder);
                                                   

                                                  The function changes the video recorder state from RECORDER_STATE_CREATED to RECORDER_STATE_NONE.

                                                  diff --git a/org.tizen.tutorials/html/native/multimedia/screen_mirroring_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/screen_mirroring_tutorial_n.htm index 8df8d5e..319f285 100644 --- a/org.tizen.tutorials/html/native/multimedia/screen_mirroring_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/screen_mirroring_tutorial_n.htm @@ -83,16 +83,15 @@ static scmirroring_sink_h g_scmirroring; static int init_scmirroring_sink() { -   int ret = SCMIRRORING_ERROR_NONE; -   ret = scmirroring_sink_create(&g_scmirroring); -   if (ret != SCMIRRORING_ERROR_NONE) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_create failed [%d]", ret); +    int ret = SCMIRRORING_ERROR_NONE; +    ret = scmirroring_sink_create(&g_scmirroring); +    if (ret != SCMIRRORING_ERROR_NONE) { +        dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_create failed [%d]", ret); -      return FALSE; -   } +        return FALSE; +    } -   return TRUE; +    return TRUE; }
                                                5. @@ -111,89 +110,82 @@ init_scmirroring_sink() static void scmirroring_state_callback(scmirroring_error_e error_code, scmirroring_state_e state, void *user_data) { -   dlog_print(DLOG_ERROR, LOG_TAG, "Received Callback error code[%d], state[%d]", error_code, state); - -   switch (state) -   { -      case SCMIRRORING_STATE_NULL: -         break; -      case SCMIRRORING_STATE_PREPARED: -         break; -      case SCMIRRORING_STATE_CONNECTED: -         break; -      case SCMIRRORING_STATE_PLAYING: -         break; -      case SCMIRRORING_STATE_PAUSED: -         break; -      case SCMIRRORING_STATE_DISCONNECTED: -         break; -      case SCMIRRORING_STATE_NONE: -         break; -      default: -         dlog_print(DLOG_ERROR, LOG_TAG, "state[%d] Invalid State", state); -         break; -   } - -   return; +    dlog_print(DLOG_ERROR, LOG_TAG, "Received Callback error code[%d], state[%d]", error_code, state); + +    switch (state) { +    case SCMIRRORING_STATE_NULL: +        break; +    case SCMIRRORING_STATE_PREPARED: +        break; +    case SCMIRRORING_STATE_CONNECTED: +        break; +    case SCMIRRORING_STATE_PLAYING: +        break; +    case SCMIRRORING_STATE_PAUSED: +        break; +    case SCMIRRORING_STATE_DISCONNECTED: +        break; +    case SCMIRRORING_STATE_NONE: +        break; +    default: +        dlog_print(DLOG_ERROR, LOG_TAG, "state[%d] Invalid State", state); +        break; +    } + +    return; } static int prepare_scmirroring_sink(scmirroring_display_type_e display_type) { -   ret = scmirroring_sink_set_state_changed_cb(g_scmirroring, scmirroring_state_callback, NULL); -   if (ret != SCMIRRORING_ERROR_NONE) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_set_state_changed_cb failed [%d]", ret); +    ret = scmirroring_sink_set_state_changed_cb(g_scmirroring, scmirroring_state_callback, NULL); +    if (ret != SCMIRRORING_ERROR_NONE) { +        dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_set_state_changed_cb failed [%d]", ret); -      return FALSE; -   } +        return FALSE; +    }
                                                6. Set a display object using the scmirroring_sink_set_display() function:

                                                  -   switch (display_type)
                                                  -   {
                                                  -      case SCMIRRORING_DISPLAY_TYPE_EVAS:
                                                  -         if (g_eo == NULL)
                                                  -         {
                                                  +    switch (display_type) {
                                                  +    case SCMIRRORING_DISPLAY_TYPE_EVAS:
                                                  +        if (g_eo == NULL) {
                                                               dlog_print(DLOG_ERROR, LOG_TAG, "g_eo is NULL");
                                                   
                                                               return FALSE;
                                                  -         }
                                                  -         ret = scmirroring_sink_set_display(g_scmirroring, SCMIRRORING_DISPLAY_TYPE_EVAS, (void*)g_eo);
                                                  -         if (ret != SCMIRRORING_ERROR_NONE)
                                                  -         {
                                                  -            dlog_print(DLOG_ERROR, LOG_TAG, 
                                                  -                       "scmirroring_sink_set_display failed [%d], display type [%d]", 
                                                  +        }
                                                  +        ret = scmirroring_sink_set_display(g_scmirroring, SCMIRRORING_DISPLAY_TYPE_EVAS, (void*)g_eo);
                                                  +        if (ret != SCMIRRORING_ERROR_NONE) {
                                                  +            dlog_print(DLOG_ERROR, LOG_TAG,
                                                  +                       "scmirroring_sink_set_display failed [%d], display type [%d]",
                                                                          ret, display_type);
                                                   
                                                               return FALSE;
                                                  -         }
                                                  -         break;
                                                  -      case SCMIRRORING_DISPLAY_TYPE_OVERLAY:
                                                  -         if (g_win == NULL)
                                                  -         {
                                                  +        }
                                                  +        break;
                                                  +    case SCMIRRORING_DISPLAY_TYPE_OVERLAY:
                                                  +        if (g_win == NULL) {
                                                               dlog_print(DLOG_ERROR, LOG_TAG, "g_win is NULL");
                                                   
                                                               return FALSE;
                                                  -         }
                                                  -         ret = scmirroring_sink_set_display(g_scmirroring, SCMIRRORING_DISPLAY_TYPE_OVERLAY, (void*)g_win);
                                                  -         if (ret != SCMIRRORING_ERROR_NONE)
                                                  -         {
                                                  -            dlog_print(DLOG_ERROR, LOG_TAG, 
                                                  -                       "scmirroring_sink_set_display failed [%d], display type [%d]", 
                                                  +        }
                                                  +        ret = scmirroring_sink_set_display(g_scmirroring, SCMIRRORING_DISPLAY_TYPE_OVERLAY, (void*)g_win);
                                                  +        if (ret != SCMIRRORING_ERROR_NONE) {
                                                  +            dlog_print(DLOG_ERROR, LOG_TAG,
                                                  +                       "scmirroring_sink_set_display failed [%d], display type [%d]",
                                                                          ret, display_type);
                                                   
                                                               return FALSE;
                                                  -         }
                                                  -         break;
                                                  -      default:
                                                  -         dlog_print(DLOG_ERROR, LOG_TAG, "Invalid display type [%d].", display_type);
                                                  +        }
                                                  +        break;
                                                  +    default:
                                                  +        dlog_print(DLOG_ERROR, LOG_TAG, "Invalid display type [%d].", display_type);
                                                   
                                                  -         return FALSE;
                                                  -   }
                                                  +        return FALSE;
                                                  +    }
                                                   }
                                                   
                                                7. @@ -213,38 +205,37 @@ static Evas_Object *g_rect = NULL; static void create_base_gui(scmirroring_display_type_e display_type) { -   g_win = elm_win_add(NULL, PACKAGE_NAME, ELM_WIN_BASIC); - -   evas_object_resize(g_win, WINDOW_WIDTH, WINDOW_HEIGHT); -   evas_object_move(g_win, 0, 0); -   elm_win_autodel_set(g_win, EINA_TRUE); - -   switch (display_type) -   { -      case SCMIRRORING_DISPLAY_TYPE_EVAS: -         g_evas = evas_object_evas_get(g_win); -         // Set an Evas image object for drawing -         g_eo = evas_object_image_add(g_evas); -         evas_object_image_size_set(g_eo, WINDOW_WIDTH, WINDOW_HEIGHT); -         evas_object_image_fill_set(g_eo, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); -         evas_object_resize(g_eo, WINDOW_WIDTH, WINDOW_HEIGHT); -         // Show the window after the base GUI is set up -         evas_object_show(g_eo); -         evas_object_show(g_win); -         break; -      case SCMIRRORING_DISPLAY_TYPE_OVERLAY: -         g_rect = evas_object_rectangle_add(g_evas); -         evas_object_resize(g_rect, WINDOW_WIDTH, WINDOW_HEIGHT); -         evas_object_move(g_rect, 0, 0); -         evas_object_color_set(g_rect, 0, 0, 0, 0); -         evas_object_render_op_set(g_rect, EVAS_RENDER_COPY); -         evas_object_size_hint_weight_set(g_rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); -         // Show the window after the base GUI is set up -         evas_object_show(g_win); -         break; -      default: -         break; -   } +    g_win = elm_win_add(NULL, PACKAGE_NAME, ELM_WIN_BASIC); + +    evas_object_resize(g_win, WINDOW_WIDTH, WINDOW_HEIGHT); +    evas_object_move(g_win, 0, 0); +    elm_win_autodel_set(g_win, EINA_TRUE); + +    switch (display_type) { +    case SCMIRRORING_DISPLAY_TYPE_EVAS: +        g_evas = evas_object_evas_get(g_win); +        /* Set an Evas image object for drawing */ +        g_eo = evas_object_image_add(g_evas); +        evas_object_image_size_set(g_eo, WINDOW_WIDTH, WINDOW_HEIGHT); +        evas_object_image_fill_set(g_eo, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); +        evas_object_resize(g_eo, WINDOW_WIDTH, WINDOW_HEIGHT); +        /* Show the window after the base GUI is set up */ +        evas_object_show(g_eo); +        evas_object_show(g_win); +        break; +    case SCMIRRORING_DISPLAY_TYPE_OVERLAY: +        g_rect = evas_object_rectangle_add(g_evas); +        evas_object_resize(g_rect, WINDOW_WIDTH, WINDOW_HEIGHT); +        evas_object_move(g_rect, 0, 0); +        evas_object_color_set(g_rect, 0, 0, 0, 0); +        evas_object_render_op_set(g_rect, EVAS_RENDER_COPY); +        evas_object_size_hint_weight_set(g_rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); +        /* Show the window after the base GUI is set up */ +        evas_object_show(g_win); +        break; +    default: +        break; +    } } @@ -254,11 +245,10 @@ create_base_gui(scmirroring_display_type_e display_type)

                                                  The function sets the screen mirroring state to SCMIRRORING_STATE_PREPARED.

                                                   ret = scmirroring_sink_prepare(g_scmirroring);
                                                  -if (ret != SCMIRRORING_ERROR_NONE)
                                                  -{
                                                  -   dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_prepare failed [%d]", ret);
                                                  +if (ret != SCMIRRORING_ERROR_NONE) {
                                                  +    dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_prepare failed [%d]", ret);
                                                   
                                                  -   return FALSE;
                                                  +    return FALSE;
                                                   }
                                                   
                                                   return TRUE;
                                                  @@ -279,14 +269,13 @@ return TRUE;
                                                   static int
                                                   start_scmirroring_sink(const char* peer_ip, const char* peer_port)
                                                   {
                                                  -   int ret;
                                                  -   ret = scmirroring_sink_set_ip_and_port(g_scmirroring, peer_ip, peer_port);
                                                  -   if (ret != SCMIRRORING_ERROR_NONE)
                                                  -   {
                                                  -      dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_set_ip_and_port failed [%d]", ret);
                                                  -
                                                  -      return FALSE;
                                                  -   }
                                                  +    int ret;
                                                  +    ret = scmirroring_sink_set_ip_and_port(g_scmirroring, peer_ip, peer_port);
                                                  +    if (ret != SCMIRRORING_ERROR_NONE) {
                                                  +        dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_set_ip_and_port failed [%d]", ret);
                                                  +
                                                  +        return FALSE;
                                                  +    }
                                                   
                                                  @@ -294,15 +283,14 @@ start_scmirroring_sink(const char* peer_ip, const char* peer_port)

                                                  Connect the screen mirroring sink to the screen mirroring source using the scmirroring_sink_connect() function.

                                                  The function sets the screen mirroring state to SCMIRRORING_STATE_CONNECTED asynchronously. Monitor the state changes using the state callback.

                                                  -   ret = scmirroring_sink_connect(g_scmirroring);
                                                  -   if (ret != SCMIRRORING_ERROR_NONE)
                                                  -   {
                                                  -      dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_connect failed [%d]", ret);
                                                  +    ret = scmirroring_sink_connect(g_scmirroring);
                                                  +    if (ret != SCMIRRORING_ERROR_NONE) {
                                                  +        dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_connect failed [%d]", ret);
                                                   
                                                  -      return FALSE;
                                                  -   }
                                                  +        return FALSE;
                                                  +    }
                                                   
                                                  -   return TRUE;
                                                  +    return TRUE;
                                                   }
                                                   
                                                  @@ -314,25 +302,23 @@ start_scmirroring_sink(const char* peer_ip, const char* peer_port) static void scmirroring_state_callback(scmirroring_error_e error_code, scmirroring_state_e state, void *user_data) { -   int ret; -   dlog_print(DLOG_ERROR, LOG_TAG, "Received Callback error code[%d], state[%d]", error_code, state); - -   switch (state) -   { -      // Other cases -      case SCMIRRORING_STATE_CONNECTED: -         ret = scmirroring_sink_start(g_scmirroring); -         if (ret != SCMIRRORING_ERROR_NONE) -         { +    int ret; +    dlog_print(DLOG_ERROR, LOG_TAG, "Received Callback error code[%d], state[%d]", error_code, state); + +    switch (state) { +    /* Other cases */ +    case SCMIRRORING_STATE_CONNECTED: +        ret = scmirroring_sink_start(g_scmirroring); +        if (ret != SCMIRRORING_ERROR_NONE) {             dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_start failed [%d]", ret);             return; -         } -         break; -      // Other cases -   } +        } +        break; +    /* Other cases */ +    } -   return; +    return; } @@ -352,13 +338,12 @@ scmirroring_state_callback(scmirroring_error_e error_code, scmirroring_state_e s static int destroy_scmirroring_sink() { -   ret = scmirroring_sink_disconnect(g_scmirroring); -   if (ret != SCMIRRORING_ERROR_NONE) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_disconnect failed [%d]", ret); +    ret = scmirroring_sink_disconnect(g_scmirroring); +    if (ret != SCMIRRORING_ERROR_NONE) { +        dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_disconnect failed [%d]", ret); -      return FALSE; -   } +        return FALSE; +    } @@ -366,13 +351,12 @@ destroy_scmirroring_sink()

                                                  Unprepare the screen mirroring sink using the scmirroring_sink_unprepare() function.

                                                  The function sets the screen mirroring state to SCMIRRORING_STATE_NULL.

                                                  -   ret = scmirroring_sink_unprepare(g_scmirroring);
                                                  -   if (ret != SCMIRRORING_ERROR_NONE)
                                                  -   {
                                                  -      dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_unprepare failed [%d]", ret);
                                                  +    ret = scmirroring_sink_unprepare(g_scmirroring);
                                                  +    if (ret != SCMIRRORING_ERROR_NONE) {
                                                  +        dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_unprepare failed [%d]", ret);
                                                   
                                                  -      return FALSE;
                                                  -   }
                                                  +        return FALSE;
                                                  +    }
                                                   
                                                  @@ -380,15 +364,14 @@ destroy_scmirroring_sink()

                                                  Release the screen mirroring sink resources using the scmirroring_sink_destroy() function.

                                                  The function sets the screen mirroring state to SCMIRRORING_STATE_NONE.

                                                  -   ret = scmirroring_sink_destroy(g_scmirroring);
                                                  -   if (ret != SCMIRRORING_ERROR_NONE)
                                                  -   {
                                                  -      dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_destroy failed [%d]", ret);
                                                  +    ret = scmirroring_sink_destroy(g_scmirroring);
                                                  +    if (ret != SCMIRRORING_ERROR_NONE) {
                                                  +        dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_destroy failed [%d]", ret);
                                                   
                                                  -      return FALSE;
                                                  -   }
                                                  +        return FALSE;
                                                  +    }
                                                   
                                                  -   return TRUE;
                                                  +    return TRUE;
                                                   }
                                                   
                                                  @@ -402,37 +385,33 @@ destroy_scmirroring_sink() static void scmirroring_state_callback(scmirroring_error_e error_code, scmirroring_state_e state, void *user_data) { -   int ret; -   dlog_print(DLOG_ERROR, LOG_TAG, "Received Callback error code[%d], state[%d]", error_code, state); - -   if (error_code != SCMIRRORING_ERROR_NONE) -   { -      ret = destroy_scmirroring_sink(); -      if (ret != TRUE) -      { -         dlog_print(DLOG_ERROR, LOG_TAG, "destroy_scmirroring_sink failed"); - -         return; -      } -   } - -   switch (state) -   { -      // Other cases -      case SCMIRRORING_STATE_DISCONNECTED: -         ret = scmirroring_sink_unprepare(g_scmirroring); -         if (ret != SCMIRRORING_ERROR_NONE) -         { +    int ret; +    dlog_print(DLOG_ERROR, LOG_TAG, "Received Callback error code[%d], state[%d]", error_code, state); + +    if (error_code != SCMIRRORING_ERROR_NONE) { +        ret = destroy_scmirroring_sink(); +        if (ret != TRUE) { +            dlog_print(DLOG_ERROR, LOG_TAG, "destroy_scmirroring_sink failed"); + +            return; +        } +    } + +    switch (state) { +    /* Other cases */ +    case SCMIRRORING_STATE_DISCONNECTED: +        ret = scmirroring_sink_unprepare(g_scmirroring); +        if (ret != SCMIRRORING_ERROR_NONE) {             dlog_print(DLOG_ERROR, LOG_TAG, "scmirroring_sink_unprepare failed [%d]", ret);             return; -         } -         // Do something -         break; -      // Other cases -   } +        } +        /* Do something */ +        break; +    /* Other cases */ +    } -   return; +    return; } diff --git a/org.tizen.tutorials/html/native/multimedia/sound_manager_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/sound_manager_tutorial_n.htm index b1edb45..c82e182 100644 --- a/org.tizen.tutorials/html/native/multimedia/sound_manager_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/sound_manager_tutorial_n.htm @@ -100,14 +100,14 @@ error_code = sound_manager_set_session_interrupted_cb(_sound_session_interrupted static void sound_session_interrupted_cb(sound_session_interrupted_code_e code, void *user_data) { -   if (code == SOUND_SESSION_INTERRUPTED_BY_MEDIA) -      // Session has been interrupted by media application, handle accordingly -   if (code == SOUND_SESSION_INTERRUPTED_COMPLETED) -      // Interruption completed, handle accordingly +    if (code == SOUND_SESSION_INTERRUPTED_BY_MEDIA) +        /* Session has been interrupted by media application, handle accordingly */ +    if (code == SOUND_SESSION_INTERRUPTED_COMPLETED) +        /* Interruption completed, handle accordingly */ } -
                                                8. When no longer needed, unregister the callback:

                                                  +
                                                9. When no longer needed, deregister the callback:

                                                   error_code = sound_manager_unset_session_interrupted_cb();
                                                   
                                                10. @@ -148,10 +148,10 @@ int error_code; static void _sound_manager_volume_changed_cb(sound_type_e type, unsigned int volume, void* user_data) { -   char buf[MBUF] = {0,}; +    char buf[MBUF] = {0,}; -   snprintf(buf, MBUF, "(%d) type volume changed to (%d)", type, volume); -   dlog_print(DLOG_INFO, "Sound Manager", "Volume Changed: %s", buf); +    snprintf(buf, MBUF, "(%d) type volume changed to (%d)", type, volume); +    dlog_print(DLOG_INFO, "Sound Manager", "Volume Changed: %s", buf); } @@ -186,8 +186,10 @@ int ret; sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA; int value; -// Make sure the value is within the system maximum volume -// by using the sound_manager_get_max_volume() function +/* + Make sure the value is within the system maximum volume + by using the sound_manager_get_max_volume() function +*/ ret = sound_manager_set_volume(type, value); @@ -238,31 +240,20 @@ ret = sound_manager_get_current_device_list(mask, &list);

                                                  You can query sound device information with a sound device handle. The Sound Manager API provides a dedicated function for each information type: device type, IO direction, ID, name, and state. When calling the query functions, use the sound device handle as the first parameter (input) and the device information type enumerator as the second parameter (output).

                                                  The following example code shows how to retrieve information about sound device type and IO direction:

                                                  -while ((_ret = sound_manager_get_next_device(list, &device)) == SOUND_MANAGER_ERROR_NONE)
                                                  -{
                                                  -   ret = sound_manager_get_device_type(device, &type);
                                                  -
                                                  -   if (type == SOUND_DEVICE_BLUETOOTH)
                                                  -   {
                                                  -      // Sound device type is Bluetooth, handle accordingly
                                                  -   }
                                                  -   else if (type == SOUND_DEVICE_AUDIO_JACK)
                                                  -   {
                                                  -      ret = sound_manager_get_device_io_direction(device, &direction);
                                                  -   }
                                                  -   if (direction == BOTH)
                                                  -   {
                                                  -      // Sound device has both headphone and mic, handle accordingly
                                                  -   }
                                                  -   else
                                                  -   {
                                                  -      // Handle accordingly
                                                  -   }
                                                  +while ((_ret = sound_manager_get_next_device(list, &device)) == SOUND_MANAGER_ERROR_NONE) {
                                                  +    ret = sound_manager_get_device_type(device, &type);
                                                  +
                                                  +    if (type == SOUND_DEVICE_BLUETOOTH)
                                                  +        /* Sound device type is Bluetooth, handle accordingly */
                                                  +    else if (type == SOUND_DEVICE_AUDIO_JACK)
                                                  +        ret = sound_manager_get_device_io_direction(device, &direction);
                                                  +    if (direction == BOTH)
                                                  +        /* Sound device has both headphone and mic, handle accordingly */
                                                  +    else
                                                  +        /* Handle accordingly */
                                                   }
                                                   if (_ret == SOUND_MANAGER_ERROR_NO_DATA)
                                                  -{
                                                  -   // End of the available devices, handle accordingly
                                                  -}
                                                  +    /* End of the available devices, handle accordingly */
                                                   
                                                @@ -295,33 +286,22 @@ ret = sound_manager_set_device_connected_cb(mask, _sound_device_connected_cb, NU static void _sound_device_connected_cb(sound_device_h device, bool is_connected, void* user_data) { -   int ret; -   sound_device_type_e type; - -   if (is_connected) -   { -      ret = sound_manager_get_device_type(device, &type); -      if (type == SOUND_DEVICE_BLUETOOTH) -      { -         // Connected sound device type is Bluetooth, handle accordingly -      } -      else -      { -         // Handle accordingly -      } -   } -   else -   { -      ret = sound_manager_get_device_type(device, &type); -      if (type == SOUND_DEVICE_BLUETOOTH) -      { -         // Disconnected sound device type is Bluetooth, handle accordingly -      } -      else -      { -         // Handle accordingly -      } -   } +    int ret; +    sound_device_type_e type; + +    if (is_connected) { +        ret = sound_manager_get_device_type(device, &type); +        if (type == SOUND_DEVICE_BLUETOOTH) +            /* Connected sound device type is Bluetooth, handle accordingly */ +        else +            /* Handle accordingly */ +    } else { +        ret = sound_manager_get_device_type(device, &type); +        if (type == SOUND_DEVICE_BLUETOOTH) +            /* Disconnected sound device type is Bluetooth, handle accordingly */ +        else +            /* Handle accordingly */ +    } } @@ -349,43 +329,29 @@ _sound_device_information_changed_cb(sound_device_h device,                                      sound_device_changed_info_e changed_info,                                      void* user_data) { -   int ret; -   sound_device_type_e type; -   sound_device_state_e state; -   sound_device_io_direction_e direction; - -   ret = sound_manager_get_device_type(device, &type); -   if (type == SOUND_DEVICE_BLUETOOTH) -   { -      if (changed_info == SOUND_DEVICE_CHANGED_INFO_STATE) -      { -         ret = sound_manager_get_device_state(device, &state); -         if (state == SOUND_DEVICE_STATE_DEACTIVATED) -         { -            // Bluetooth device has been deactivated, handle accordingly -         } -         else -         { -            // Handle accordingly -         } -      } -      else -      { -         ret = sound_manager_get_device_io_direction(device, &direction); -         if (direction == SOUND_DEVICE_IO_DIRECTION_OUT) -         { -            // IO direction of the Bluetooth device is now out, handle accordingly -         } -         else -         { -            // Handle accordingly -         } -      } -   } -   else -   { -      // Handle accordingly -   } +    int ret; +    sound_device_type_e type; +    sound_device_state_e state; +    sound_device_io_direction_e direction; + +    ret = sound_manager_get_device_type(device, &type); +    if (type == SOUND_DEVICE_BLUETOOTH) { +        if (changed_info == SOUND_DEVICE_CHANGED_INFO_STATE) { +            ret = sound_manager_get_device_state(device, &state); +            if (state == SOUND_DEVICE_STATE_DEACTIVATED) +                /* Bluetooth device has been deactivated, handle accordingly */ +            else +                /* Handle accordingly */ +        } else { +            ret = sound_manager_get_device_io_direction(device, &direction); +            if (direction == SOUND_DEVICE_IO_DIRECTION_OUT) +                /* IO direction of the Bluetooth device is now out, handle accordingly */ +            else +                /* Handle accordingly */ +        } +    } else { +        /* Handle accordingly */ +    } } @@ -422,26 +388,26 @@ sound_manager_set_session_interrupted_cb(_sound_session_interrupted_cb, NULL); void _sound_session_interrupted_cb(sound_session_interrupted_code_e code, void * userdata) { -   dlog_print(DLOG_INFO, LOG_TAG, "Interrupt code: %d\n", code); - -   dlog_print(DLOG_INFO, LOG_TAG, -              "SOUND_SESSION_INTERRUPTED_COMPLETED %d | "\ -              "SOUND_SESSION_INTERRUPTED_BY_MEDIA %d | "\ -              "SOUND_SESSION_INTERRUPTED_BY_CALL %d | "\ -              "SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG %d | "\ -              "SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT %d | "\ -              "SOUND_SESSION_INTERRUPTED_BY_ALARM %d | "\ -              "SOUND_SESSION_INTERRUPTED_BY_EMERGENCY %d | "\ -              "SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION %d\n\n", - -              SOUND_SESSION_INTERRUPTED_COMPLETED, -              SOUND_SESSION_INTERRUPTED_BY_MEDIA, -              SOUND_SESSION_INTERRUPTED_BY_CALL, -              SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, -              SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT, -              SOUND_SESSION_INTERRUPTED_BY_ALARM, -              SOUND_SESSION_INTERRUPTED_BY_EMERGENCY, -              SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION); +    dlog_print(DLOG_INFO, LOG_TAG, "Interrupt code: %d\n", code); + +    dlog_print(DLOG_INFO, LOG_TAG, +               "SOUND_SESSION_INTERRUPTED_COMPLETED %d | "\ +               "SOUND_SESSION_INTERRUPTED_BY_MEDIA %d | "\ +               "SOUND_SESSION_INTERRUPTED_BY_CALL %d | "\ +               "SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG %d | "\ +               "SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT %d | "\ +               "SOUND_SESSION_INTERRUPTED_BY_ALARM %d | "\ +               "SOUND_SESSION_INTERRUPTED_BY_EMERGENCY %d | "\ +               "SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION %d\n\n", + +               SOUND_SESSION_INTERRUPTED_COMPLETED, +               SOUND_SESSION_INTERRUPTED_BY_MEDIA, +               SOUND_SESSION_INTERRUPTED_BY_CALL, +               SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, +               SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT, +               SOUND_SESSION_INTERRUPTED_BY_ALARM, +               SOUND_SESSION_INTERRUPTED_BY_EMERGENCY, +               SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION); } @@ -496,7 +462,7 @@ sound_manager_set_media_session_resumption_option(SOUND_SESSION_OPTION_RESUMPTIO
                                              57. -

                                                After you no longer need the session interrupt callback, unregister it:

                                                +

                                                After you no longer need the session interrupt callback, deregister it:

                                                 sound_manager_unset_session_interrupted_cb();
                                                 
                                                diff --git a/org.tizen.tutorials/html/native/multimedia/thumbnail_util_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/thumbnail_util_tutorial_n.htm index f87ec21..00dcc58 100644 --- a/org.tizen.tutorials/html/native/multimedia/thumbnail_util_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/thumbnail_util_tutorial_n.htm @@ -86,42 +86,40 @@ static bool storage_cb(int storage_id, storage_type_e type, storage_state_e state,            const char *path, void *user_data) { -   if (type == STORAGE_TYPE_INTERNAL) -   { -      internal_storage_id = storage_id; +    if (type == STORAGE_TYPE_INTERNAL) { +        internal_storage_id = storage_id; -      return false; -   } +        return false; +    } -   return true; +    return true; } void _get_internal_storage_path() { -   int error; -   char *path = NULL; - -   error = storage_foreach_device_supported(storage_cb, NULL); -   error = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_IMAGES, &path); -   if (error != STORAGE_ERROR_NONE) -   { -      internal_image_storage_path = strdup(path); -      free(path); -   } +    int error; +    char *path = NULL; + +    error = storage_foreach_device_supported(storage_cb, NULL); +    error = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_IMAGES, &path); +    if (error != STORAGE_ERROR_NONE) { +        internal_image_storage_path = strdup(path); +        free(path); +    } } void _make_test_path() { -   int path_len = 0; +    int path_len = 0; -   path_len = strlen(internal_image_storage_path) + strlen(image_file_name) + 1; -   image_test_path = malloc(path_len); -   memset(image_test_path, 0x0, path_len); +    path_len = strlen(internal_image_storage_path) + strlen(image_file_name) + 1; +    image_test_path = malloc(path_len); +    memset(image_test_path, 0x0, path_len); -   strncat(image_test_path, internal_image_storage_path, strlen(internal_image_storage_path)); -   strncat(image_test_path, image_file_name, strlen(image_file_name)); +    strncat(image_test_path, internal_image_storage_path, strlen(internal_image_storage_path)); +    strncat(image_test_path, image_file_name, strlen(image_file_name)); }
                                              58. @@ -179,16 +177,16 @@ thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id,                        int raw_width, int raw_height, unsigned char *raw_data,                        int raw_size, void *user_data) { -   dlog_print(DLOG_DEBUG, LOG_TAG, "REQUEST ID: %s\n", request_id); -   dlog_print(DLOG_DEBUG, LOG_TAG, "WIDTH: %d, HEIGHT: %d\n", raw_width, raw_height); +    dlog_print(DLOG_DEBUG, LOG_TAG, "REQUEST ID: %s\n", request_id); +    dlog_print(DLOG_DEBUG, LOG_TAG, "WIDTH: %d, HEIGHT: %d\n", raw_width, raw_height); } void extract() { -   char *request_id = NULL; +    char *request_id = NULL; -   ret = thumbnail_util_extract(g_thumb_h, thumbnail_completed_cb, NULL, &request_id); +    ret = thumbnail_util_extract(g_thumb_h, thumbnail_completed_cb, NULL, &request_id); }

                                                After calling the function, check whether the return value is THUMBNAIL_UTIL_ERROR_NONE. If it is, the function extracted the thumbnail successfully and stored it in the raw_data parameter returned by the callback. Otherwise, the function failed because of an error, which you need to handle.

                                                diff --git a/org.tizen.tutorials/html/native/multimedia/video_util_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/video_util_tutorial_n.htm index 4bd409f..84129ac 100644 --- a/org.tizen.tutorials/html/native/multimedia/video_util_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/video_util_tutorial_n.htm @@ -225,12 +225,12 @@ error_code = video_util_foreach_supported_file_format(handle, video_util_file_su static bool video_util_file_supported(video_util_file_format_e format, void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "format %s\n", -              format == VIDEO_UTIL_FILE_FORMAT_3GP? "VIDEO_UTIL_FILE_FORMAT_3GP": -              format == VIDEO_UTIL_FILE_FORMAT_MP4? "VIDEO_UTIL_FILE_FORMAT_MP4": -              "VIDEO_UTIL_FILE_FORMAT_MAX"); +    dlog_print(DLOG_INFO, LOG_TAG, "format %s\n", +               format == VIDEO_UTIL_FILE_FORMAT_3GP? "VIDEO_UTIL_FILE_FORMAT_3GP": +               format == VIDEO_UTIL_FILE_FORMAT_MP4? "VIDEO_UTIL_FILE_FORMAT_MP4": +               "VIDEO_UTIL_FILE_FORMAT_MAX"); -   return 0; +    return 0; }

                                                The video_util_file_format_e enumeration defines the available file formats.

                                                @@ -264,24 +264,24 @@ video_util_foreach_supported_video_codec(handle, video_util_video_supported, NUL static bool video_util_audio_supported(video_util_audio_codec_e codec, void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "audio codec %s\n", -              codec==VIDEO_UTIL_AUDIO_CODEC_AAC? "VIDEO_UTIL_AUDIO_CODEC_AAC": -              codec==VIDEO_UTIL_AUDIO_CODEC_AMRNB? "VIDEO_UTIL_AUDIO_CODEC_AMRNB": -              "VIDEO_UTIL_AUDIO_CODEC_NONE"); +    dlog_print(DLOG_INFO, LOG_TAG, "audio codec %s\n", +               codec==VIDEO_UTIL_AUDIO_CODEC_AAC? "VIDEO_UTIL_AUDIO_CODEC_AAC": +               codec==VIDEO_UTIL_AUDIO_CODEC_AMRNB? "VIDEO_UTIL_AUDIO_CODEC_AMRNB": +               "VIDEO_UTIL_AUDIO_CODEC_NONE"); -   return 0; +    return 0; } static bool video_util_video_supported(video_util_video_codec_e codec, void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "video codec %s\n", -              codec == VIDEO_UTIL_VIDEO_CODEC_MPEG4? "VIDEO_UTIL_VIDEO_CODEC_MPEG4": -              codec == VIDEO_UTIL_VIDEO_CODEC_H263? "VIDEO_UTIL_VIDEO_CODEC_H263": -              codec == VIDEO_UTIL_VIDEO_CODEC_H264? "VIDEO_UTIL_VIDEO_CODEC_H264": -              "VIDEO_UTIL_VIDEO_CODEC_NONE"); +    dlog_print(DLOG_INFO, LOG_TAG, "video codec %s\n", +               codec == VIDEO_UTIL_VIDEO_CODEC_MPEG4? "VIDEO_UTIL_VIDEO_CODEC_MPEG4": +               codec == VIDEO_UTIL_VIDEO_CODEC_H263? "VIDEO_UTIL_VIDEO_CODEC_H263": +               codec == VIDEO_UTIL_VIDEO_CODEC_H264? "VIDEO_UTIL_VIDEO_CODEC_H264": +               "VIDEO_UTIL_VIDEO_CODEC_NONE"); -   return 0; +    return 0; }

                                                The video_util_audio_codec_e and video_util_video_codec_e enumerations define the available audio and video codecs.

                                                @@ -292,12 +292,10 @@ video_util_video_supported(video_util_video_codec_e codec, void *user_data) static bool video_util_video_supported(video_util_video_codec_e codec, void *user_data) { -   if (codec == VIDEO_UTIL_VIDEO_CODEC_MPEG4) -   { -      user_data = true; -   } +    if (codec == VIDEO_UTIL_VIDEO_CODEC_MPEG4) +        user_data = true; -   return 0; +    return 0; } bool supported = false; diff --git a/org.tizen.tutorials/html/native/multimedia/wav_player_tutorial_n.htm b/org.tizen.tutorials/html/native/multimedia/wav_player_tutorial_n.htm index 3b4512f..20e437c 100644 --- a/org.tizen.tutorials/html/native/multimedia/wav_player_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/multimedia/wav_player_tutorial_n.htm @@ -72,18 +72,18 @@ static void _playback_completed_cb(int id, void *user_data) { -   const char* path = (const char*)user_data; -   dlog_print(DLOG_INFO, "WAV Player", "Completed! [id:%d, path:%s]", id, path); +    const char* path = (const char*)user_data; +    dlog_print(DLOG_INFO, "WAV Player", "Completed! [id:%d, path:%s]", id, path); } void main() { -   int wav_player_id; -   wav_player_error_e ret; -   const char* wav_path = "PATH OF YOUR WAV FILE"; +    int wav_player_id; +    wav_player_error_e ret; +    const char* wav_path = "PATH OF YOUR WAV FILE"; -   ret = wav_player_start(wav_path, SOUND_TYPE_MEDIA, _playback_completed_cb, (void*)wav_path, &wav_player_id); +    ret = wav_player_start(wav_path, SOUND_TYPE_MEDIA, _playback_completed_cb, (void*)wav_path, &wav_player_id); }

                                                To set the path of your WAV file, you may need to retrieve the default path for audio files. For more information, see the Storage Tutorial.

                                                @@ -95,8 +95,8 @@ main() void my_stop() { -   wav_player_error_e ret; -   ret = wav_player_stop(wav_player_id); +    wav_player_error_e ret; +    ret = wav_player_stop(wav_player_id); } diff --git a/org.tizen.tutorials/html/native/network/bluetooth_tutorial_n.htm b/org.tizen.tutorials/html/native/network/bluetooth_tutorial_n.htm index 1d404e6..03959b2 100755 --- a/org.tizen.tutorials/html/native/network/bluetooth_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/network/bluetooth_tutorial_n.htm @@ -23,7 +23,7 @@

                                                Content

                                                  -
                                                • Prerequisites
                                                • +
                                                • Prerequisites
                                                • Initializing Bluetooth
                                                • Enabling and Disabling Bluetooth
                                                • Checking the Bluetooth Adapter State
                                                • @@ -78,7 +78,8 @@

                                                  Warm-up

                                                  Become familiar with the Bluetooth API basics by learning about:

                                                  -

                                                  Prerequisites

                                                  +

                                                  Prerequisites

                                                  -

                                                  The applications intending to use the Tiizen SDK APIs will have to follow the basic prerequisites of setting privilege in the Tizen manifest file in order to access the APIs.

                                                  - -

                                                  To use the Tizen Bluetooth SDK APIs, the application has to request permission by adding the below privilege settings in the tizen-manifest.xml file.

                                                  +

                                                  To use the Bluetooth API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

                                                   <privileges>
                                                  -<privilege>http://tizen.org/privilege/bluetooth</privilege>
                                                  +   <privilege>http://tizen.org/privilege/bluetooth</privilege>
                                                   </privileges>
                                                  -
                                                  -
                                                  +

                                                  Initializing Bluetooth

                                                  @@ -152,8 +150,8 @@

                                                  To use the functions and data types of the Bluetooth API (in mobile and wearable applications), include the <bluetooth.h> header file in your application:

                                                   #include <bluetooth.h>
                                                  -
                                                  -
                                                • +
                                                • +
                                                • Initialize Bluetooth:

                                                   #include <dlog.h>
                                                  @@ -161,11 +159,10 @@
                                                   bt_error_e ret;
                                                   
                                                   ret = bt_initialize();
                                                  -if (ret != BT_ERROR_NONE) 
                                                  -{
                                                  -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_initialize] failed.");
                                                  +if (ret != BT_ERROR_NONE) {
                                                  +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_initialize] failed.");
                                                   
                                                  -   return;
                                                  +    return;
                                                   }
                                                   
                                                • @@ -181,36 +178,32 @@ if (ret != BT_ERROR_NONE) #include <app_control.h> #include <dlog.h> -int +int bt_onoff_operation(void) { -   int ret = 0; -   app_control_h service = NULL; -   app_control_create(&service); -   if (service == NULL) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "service_create failed!\n"); - -      return 0; -   } -   app_control_set_operation(service, "APP_CONTROL_OPERATION_SETTING_BT_ENABLE"); -   ret = app_control_send_launch_request(service, NULL, NULL); - -   app_control_destroy(service); -   if (ret == APP_CONTROL_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to Bluetooth On/Off app!\n"); - -      return 0; -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to relaunch Bluetooth On/Off app!\n"); - -      return -1; -   } - -   return 0; +    int ret = 0; +    app_control_h service = NULL; +    app_control_create(&service); +    if (service == NULL) { +        dlog_print(DLOG_INFO, LOG_TAG, "service_create failed!\n"); + +        return 0; +    } +    app_control_set_operation(service, "APP_CONTROL_OPERATION_SETTING_BT_ENABLE"); +    ret = app_control_send_launch_request(service, NULL, NULL); + +    app_control_destroy(service); +    if (ret == APP_CONTROL_ERROR_NONE) { +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to Bluetooth On/Off app!\n"); + +        return 0; +    } else { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to relaunch Bluetooth On/Off app!\n"); + +        return -1; +    } + +    return 0; } @@ -221,88 +214,80 @@ bt_onoff_operation(void)
                                                  1. Check whether the Bluetooth adapter is enabled on your device:
                                                     bt_adapter_state_e adapter_state;
                                                    - 
                                                    -// Check whether the Bluetooth adapter is enabled
                                                    +
                                                    +/* Check whether the Bluetooth adapter is enabled */
                                                     ret = bt_adapter_get_state(&adapter_state);
                                                    -if (ret != BT_ERROR_NONE) 
                                                    -{
                                                    -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_get_state] failed");
                                                    +if (ret != BT_ERROR_NONE) {
                                                    +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_get_state] failed");
                                                     
                                                    -   return;
                                                    -}
                                                    -// If the Bluetooth adapter is not enabled
                                                    -if (adapter_state == BT_ADAPTER_DISABLED) 
                                                    -{
                                                    -   dlog_print(DLOG_ERROR, LOG_TAG, "Bluetooth adapter is not enabled. You should enable Bluetooth!!");
                                                    +    return;
                                                     }
                                                    +/* If the Bluetooth adapter is not enabled */
                                                    +if (adapter_state == BT_ADAPTER_DISABLED)
                                                    +    dlog_print(DLOG_ERROR, LOG_TAG, "Bluetooth adapter is not enabled. You should enable Bluetooth!!");
                                                     
                                                  2. To monitor changes in the Bluetooth adapter state, define and register the Bluetooth adapter state callback function:
                                                     #include <bluetooth.h>
                                                    -#include <dlog.h> 
                                                    +#include <dlog.h>
                                                     
                                                     bt_error_e ret;
                                                     
                                                    -void 
                                                    -adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void* user_data) 
                                                    -{
                                                    -   if (result != BT_ERROR_NONE) 
                                                    -   {
                                                    -      dlog_print(DLOG_ERROR, LOG_TAG, "[adapter_state_changed_cb] failed! result=%d", result);
                                                    -
                                                    -      return;
                                                    -   }
                                                    -   if (adapter_state == BT_ADAPTER_ENABLED) 
                                                    -   {
                                                    -      dlog_print(DLOG_INFO, LOG_TAG, "[adapter_state_changed_cb] Bluetooth is enabled!");
                                                    - 
                                                    -      // Get information about Bluetooth adapter
                                                    -      char *local_address = NULL;
                                                    -      bt_adapter_get_address(&local_address);
                                                    -      dlog_print(DLOG_INFO, LOG_TAG, "[adapter_state_changed_cb] Adapter address: %s.", local_address);
                                                    -      if (local_address)
                                                    -         free(local_address); 
                                                    -      char *local_name;
                                                    -      bt_adapter_get_name(&local_name);
                                                    -      dlog_print(DLOG_INFO, LOG_TAG, "[adapter_state_changed_cb] Adapter name: %s.", local_name);
                                                    -      if (local_name)
                                                    -         free(local_name); 
                                                    -      // Visibility mode of the Bluetooth device
                                                    -      bt_adapter_visibility_mode_e mode;
                                                    -      // Duration until the visibility mode is changed so that other devices cannot find your device
                                                    -      int duration = 1;
                                                    -      bt_adapter_get_visibility(&mode, &duration);
                                                    -      switch (mode) 
                                                    -      {
                                                    -         case BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE:
                                                    -            dlog_print(DLOG_INFO, LOG_TAG, 
                                                    +void
                                                    +adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void* user_data)
                                                    +{
                                                    +    if (result != BT_ERROR_NONE) {
                                                    +        dlog_print(DLOG_ERROR, LOG_TAG, "[adapter_state_changed_cb] failed! result=%d", result);
                                                    +
                                                    +        return;
                                                    +    }
                                                    +    if (adapter_state == BT_ADAPTER_ENABLED) {
                                                    +        dlog_print(DLOG_INFO, LOG_TAG, "[adapter_state_changed_cb] Bluetooth is enabled!");
                                                    +
                                                    +        /* Get information about Bluetooth adapter */
                                                    +        char *local_address = NULL;
                                                    +        bt_adapter_get_address(&local_address);
                                                    +        dlog_print(DLOG_INFO, LOG_TAG, "[adapter_state_changed_cb] Adapter address: %s.", local_address);
                                                    +        if (local_address)
                                                    +            free(local_address);
                                                    +        char *local_name;
                                                    +        bt_adapter_get_name(&local_name);
                                                    +        dlog_print(DLOG_INFO, LOG_TAG, "[adapter_state_changed_cb] Adapter name: %s.", local_name);
                                                    +        if (local_name)
                                                    +            free(local_name);
                                                    +        /* Visibility mode of the Bluetooth device */
                                                    +        bt_adapter_visibility_mode_e mode;
                                                    +        /* Duration until the visibility mode is changed so that other devices cannot find your device */
                                                    +        int duration = 1;
                                                    +        bt_adapter_get_visibility(&mode, &duration);
                                                    +        switch (mode) {
                                                    +        case BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE:
                                                    +            dlog_print(DLOG_INFO, LOG_TAG,
                                                                            "[adapter_state_changed_cb] Visibility: NON_DISCOVERABLE");
                                                                 break;
                                                    -         case BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE:
                                                    -            dlog_print(DLOG_INFO, LOG_TAG, 
                                                    +        case BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE:
                                                    +            dlog_print(DLOG_INFO, LOG_TAG,
                                                                            "[adapter_state_changed_cb] Visibility: GENERAL_DISCOVERABLE");
                                                                 break;
                                                    -         case BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE:
                                                    -            dlog_print(DLOG_INFO, LOG_TAG, 
                                                    +        case BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE:
                                                    +            dlog_print(DLOG_INFO, LOG_TAG,
                                                                            "[adapter_state_changed_cb] Visibility: LIMITED_DISCOVERABLE");
                                                                 break;
                                                    -      } 
                                                    -   } 
                                                    -   else 
                                                    -   {
                                                    -      dlog_print(DLOG_INFO, LOG_TAG, "[adapter_state_changed_cb] Bluetooth is disabled!");
                                                    -      // When you try to get device information
                                                    -      // by invoking bt_adapter_get_name(), bt_adapter_get_address(), or bt_adapter_get_visibility(), 
                                                    -      // BT_ERROR_NOT_ENABLED occurs
                                                    -   }
                                                    +        }
                                                    +    } else {
                                                    +        dlog_print(DLOG_INFO, LOG_TAG, "[adapter_state_changed_cb] Bluetooth is disabled!");
                                                    +        /*
                                                    +           When you try to get device information
                                                    +           by invoking bt_adapter_get_name(), bt_adapter_get_address(), or bt_adapter_get_visibility(),
                                                    +           BT_ERROR_NOT_ENABLED occurs
                                                    +        */
                                                    +    }
                                                     }
                                                     ret = bt_adapter_set_state_changed_cb(adapter_state_changed_cb, NULL);
                                                    -if (ret != BT_ERROR_NONE) 
                                                    -{
                                                    -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_set_state_changed_cb()] failed.");
                                                    -}
                                                    +if (ret != BT_ERROR_NONE)
                                                    +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_set_state_changed_cb()] failed.");
                                                     
                                                  @@ -324,67 +309,59 @@ if (ret != BT_ERROR_NONE)

                                                  The following example shows the callback implementation for classic Bluetooth. Bluetooth LE is implemented in the same way.

                                                  -#include <glib.h> // For GList
                                                  -void 
                                                  -adapter_device_discovery_state_changed_cb(int result, bt_adapter_device_discovery_state_e discovery_state, 
                                                  -                                          bt_adapter_device_discovery_info_s *discovery_info, void* user_data) 
                                                  -{
                                                  -   if (result != BT_ERROR_NONE) 
                                                  -   {
                                                  -      dlog_print(DLOG_ERROR, LOG_TAG, "[adapter_device_discovery_state_changed_cb] failed! result(%d).", result);
                                                  -
                                                  -      return;
                                                  -   }
                                                  -   GList** searched_device_list = (GList**)user_data;
                                                  -   switch (discovery_state) 
                                                  -   {
                                                  -      case BT_ADAPTER_DEVICE_DISCOVERY_STARTED:
                                                  -         dlog_print(DLOG_INFO, LOG_TAG, "BT_ADAPTER_DEVICE_DISCOVERY_STARTED");
                                                  -         break;
                                                  -      case BT_ADAPTER_DEVICE_DISCOVERY_FINISHED:
                                                  -         dlog_print(DLOG_INFO, LOG_TAG, "BT_ADAPTER_DEVICE_DISCOVERY_FINISHED");
                                                  -         break;
                                                  -      case BT_ADAPTER_DEVICE_DISCOVERY_FOUND:
                                                  -         dlog_print(DLOG_INFO, LOG_TAG, "BT_ADAPTER_DEVICE_DISCOVERY_FOUND");
                                                  -         if (discovery_info != NULL) 
                                                  -         {
                                                  +#include <glib.h> /* For GList */
                                                  +void
                                                  +adapter_device_discovery_state_changed_cb(int result, bt_adapter_device_discovery_state_e discovery_state,
                                                  +                                          bt_adapter_device_discovery_info_s *discovery_info, void* user_data)
                                                  +{
                                                  +    if (result != BT_ERROR_NONE) {
                                                  +        dlog_print(DLOG_ERROR, LOG_TAG, "[adapter_device_discovery_state_changed_cb] failed! result(%d).", result);
                                                  +
                                                  +        return;
                                                  +    }
                                                  +    GList** searched_device_list = (GList**)user_data;
                                                  +    switch (discovery_state) {
                                                  +    case BT_ADAPTER_DEVICE_DISCOVERY_STARTED:
                                                  +        dlog_print(DLOG_INFO, LOG_TAG, "BT_ADAPTER_DEVICE_DISCOVERY_STARTED");
                                                  +        break;
                                                  +    case BT_ADAPTER_DEVICE_DISCOVERY_FINISHED:
                                                  +        dlog_print(DLOG_INFO, LOG_TAG, "BT_ADAPTER_DEVICE_DISCOVERY_FINISHED");
                                                  +        break;
                                                  +    case BT_ADAPTER_DEVICE_DISCOVERY_FOUND:
                                                  +        dlog_print(DLOG_INFO, LOG_TAG, "BT_ADAPTER_DEVICE_DISCOVERY_FOUND");
                                                  +        if (discovery_info != NULL) {
                                                               dlog_print(DLOG_INFO, LOG_TAG, "Device Address: %s", discovery_info->remote_address);
                                                               dlog_print(DLOG_INFO, LOG_TAG, "Device Name is: %s", discovery_info->remote_name);
                                                               bt_adapter_device_discovery_info_s * new_device_info = malloc(sizeof(bt_adapter_device_discovery_info_s));
                                                  -            if (new_device_info != NULL) 
                                                  -            {
                                                  -               memcpy(new_device_info, discovery_info, sizeof(bt_adapter_device_discovery_info_s));
                                                  -               new_device_info->remote_address = strdup(discovery_info->remote_address);
                                                  -               new_device_info->remote_name = strdup(discovery_info->remote_name);
                                                  -               *searched_device_list = g_list_append(*searched_device_list, (gpointer)new_device_info);
                                                  +            if (new_device_info != NULL) {
                                                  +                memcpy(new_device_info, discovery_info, sizeof(bt_adapter_device_discovery_info_s));
                                                  +                new_device_info->remote_address = strdup(discovery_info->remote_address);
                                                  +                new_device_info->remote_name = strdup(discovery_info->remote_name);
                                                  +                *searched_device_list = g_list_append(*searched_device_list, (gpointer)new_device_info);
                                                               }
                                                  -         }
                                                  -         break;
                                                  -   }
                                                  +        }
                                                  +        break;
                                                  +    }
                                                   }
                                                   
                                                   GList *devices_list = NULL;
                                                   ret = bt_adapter_set_device_discovery_state_changed_cb(adapter_device_discovery_state_changed_cb,
                                                                                                          (void*)&devices_list);
                                                   
                                                  -if (ret != BT_ERROR_NONE) 
                                                  -{
                                                  -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_set_device_discovery_state_changed_cb] failed.");
                                                  -}
                                                  +if (ret != BT_ERROR_NONE)
                                                  +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_set_device_discovery_state_changed_cb] failed.");
                                                   
                                                • Start the discovery process:
                                                  -// Classic Bluetooth
                                                  +/* Classic Bluetooth */
                                                   ret = bt_adapter_start_device_discovery();
                                                   
                                                  -// Bluetooth LE
                                                  +/* Bluetooth LE */
                                                   int bt_adapter_le_start_device_discovery(void);
                                                   
                                                  -if (ret != BT_ERROR_NONE) 
                                                  -{
                                                  -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_start_device_discovery] failed.");
                                                  -}
                                                  +if (ret != BT_ERROR_NONE)
                                                  +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_start_device_discovery] failed.");
                                                   

                                                  You can discover a nearby remote Bluetooth device, if the remote device Bluetooth is enabled and in a discovery mode.

                                                  @@ -395,54 +372,49 @@ if (ret != BT_ERROR_NONE)
                                                   ret = bt_device_create_bond(bt_server_address);
                                                  -if (ret != BT_ERROR_NONE) 
                                                  -{
                                                  -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_device_create_bond] failed.");
                                                  +if (ret != BT_ERROR_NONE) {
                                                  +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_device_create_bond] failed.");
                                                   
                                                  -   return;
                                                  -} 
                                                  -else 
                                                  -{
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "[bt_device_create_bond] succeeded. device_bond_created_cb callback will be called.");
                                                  -}
                                                  +    return; +} else { +    dlog_print(DLOG_INFO, LOG_TAG, "[bt_device_create_bond] succeeded. device_bond_created_cb callback will be called."); +} +

                                                  To get notified when the bonding process has finished, register a bond created callback using the bt_device_set_bond_created_cb() function. From the callback, you can get the service UUID and the list of services provided by the remote Bluetooth device.

                                                  -void 
                                                  -device_bond_created_cb(int result, bt_device_info_s *device_info, void *user_data) 
                                                  +void
                                                  +device_bond_created_cb(int result, bt_device_info_s *device_info, void *user_data)
                                                   {
                                                  -   if (result != BT_ERROR_NONE) 
                                                  -   {
                                                  -      dlog_print(DLOG_ERROR, LOG_TAG, "[bt_device_bond_created_cb] failed. result(%d).", result);
                                                  -
                                                  -      return;
                                                  -   }
                                                  - 
                                                  -   if (device_info != NULL && !strcmp(device_info->remote_address, remote_server_address)) 
                                                  -   {
                                                  -      dlog_print(DLOG_INFO, LOG_TAG, "Callback: A bond with chat_server is created.");
                                                  -      dlog_print(DLOG_INFO, LOG_TAG, "Callback: The number of service - %d.", device_info->service_count);
                                                  -      int i = 0;
                                                  -      dlog_print(DLOG_INFO, LOG_TAG, "Callback: is_bonded - %d.", device_info->is_bonded);
                                                  -      dlog_print(DLOG_INFO, LOG_TAG, "Callback: is_connected - %d.", device_info->is_connected);
                                                  -   } 
                                                  -   else 
                                                  -   {
                                                  -      dlog_print(DLOG_ERROR, LOG_TAG, "Callback: A bond with another device is created.");
                                                  -   }
                                                  -}
                                                  -
                                                  -// You can get bt_server_address from bt_adapter_bonded_device_cb() or bt_device_service_searched_cb()
                                                  -// device_info->remote_address in bt_adapter_bonded_device_cb()
                                                  -// sdp_info->remote_address in bt_device_service_searched_cb()
                                                  - 
                                                  +    if (result != BT_ERROR_NONE) {
                                                  +        dlog_print(DLOG_ERROR, LOG_TAG, "[bt_device_bond_created_cb] failed. result(%d).", result);
                                                  +
                                                  +        return;
                                                  +    }
                                                  +
                                                  +    if (device_info != NULL && !strcmp(device_info->remote_address, remote_server_address)) {
                                                  +        dlog_print(DLOG_INFO, LOG_TAG, "Callback: A bond with chat_server is created.");
                                                  +        dlog_print(DLOG_INFO, LOG_TAG, "Callback: The number of service - %d.", device_info->service_count);
                                                  +        int i = 0;
                                                  +        dlog_print(DLOG_INFO, LOG_TAG, "Callback: is_bonded - %d.", device_info->is_bonded);
                                                  +        dlog_print(DLOG_INFO, LOG_TAG, "Callback: is_connected - %d.", device_info->is_connected);
                                                  +    } else {
                                                  +        dlog_print(DLOG_ERROR, LOG_TAG, "Callback: A bond with another device is created.");
                                                  +    }
                                                  +}
                                                  +
                                                  +/*
                                                  +   You can get bt_server_address from bt_adapter_bonded_device_cb() or bt_device_service_searched_cb()
                                                  +   device_info->remote_address in bt_adapter_bonded_device_cb()
                                                  +   sdp_info->remote_address in bt_device_service_searched_cb()
                                                  +*/
                                                  +
                                                   ret = bt_device_set_bond_created_cb(device_bond_created_cb, bt_server_address);
                                                  -if (ret != BT_ERROR_NONE) 
                                                  -{
                                                  -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_device_set_bond_created_cb] failed.");
                                                  +if (ret != BT_ERROR_NONE) {
                                                  +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_device_set_bond_created_cb] failed.");
                                                   
                                                  -   return;
                                                  +    return;
                                                   }
                                                   
                                                  @@ -453,52 +425,48 @@ if (ret != BT_ERROR_NONE)
                                                • Query the bonded device list.

                                                  To query the list of previously bonded devices, use the bt_adapter_foreach_bonded_device() function. The function triggers a callback for each bonded device, and the callback provides you information about the bonded device (such as name, MAC address, and service list) that you need to connect to the device.

                                                  Make sure that the callback returns true until you have found the device you want. When the callback returns false, the iterations stop and no more callbacks are called even if there are more devices in the bonded list.

                                                  -
                                                  // Server address for connecting
                                                  +
                                                  +/* Server address for connecting */
                                                   char *bt_server_address = NULL;
                                                   const char *remote_server_name = "server device";
                                                  - 
                                                  -bool 
                                                  -adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data) 
                                                  -{
                                                  -   if (device_info == NULL) 
                                                  -   {
                                                  -      return true;
                                                  -   }
                                                  -   if (!strcmp(device_info->remote_name, (char*)user_data)) 
                                                  -   {
                                                  -      dlog_print(DLOG_INFO, LOG_TAG, "The server device is found in bonded device list. address(%s)", 
                                                  -                 device_info->remote_address);
                                                  -      bt_server_address = strdup(device_info->remote_address);
                                                  -      // If you want to stop iterating, you can return "false"
                                                  -   } 
                                                  -   // Get information about bonded device
                                                  -   int count_of_bonded_device = 1;
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "Get information about the bonded device(%d)", count_of_bonded_device);
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "remote address = %s.", device_info->remote_address);
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "remote name = %s.", device_info->remote_name);
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "service count = %d.", device_info->service_count);
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "bonded?? %d.", device_info->is_bonded);
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "connected?? %d.", device_info->is_connected);
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "authorized?? %d.", device_info->is_authorized);
                                                  - 
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "major_device_class %d.", device_info->bt_class.major_device_class);
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "minor_device_class %d.", device_info->bt_class.minor_device_class);
                                                  -   dlog_print(DLOG_INFO, LOG_TAG, "major_service_class_mask %d.", device_info->bt_class.major_service_class_mask);
                                                  -   count_of_bonded_device++;
                                                  -
                                                  -   // Keep iterating
                                                  -
                                                  -   return true;
                                                  +
                                                  +bool
                                                  +adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data)
                                                  +{
                                                  +    if (device_info == NULL)
                                                  +        return true;
                                                  +    if (!strcmp(device_info->remote_name, (char*)user_data)) {
                                                  +        dlog_print(DLOG_INFO, LOG_TAG, "The server device is found in bonded device list. address(%s)",
                                                  +                   device_info->remote_address);
                                                  +        bt_server_address = strdup(device_info->remote_address);
                                                  +        /* If you want to stop iterating, you can return "false" */
                                                  +    }
                                                  +    /* Get information about bonded device */
                                                  +    int count_of_bonded_device = 1;
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "Get information about the bonded device(%d)", count_of_bonded_device);
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "remote address = %s.", device_info->remote_address);
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "remote name = %s.", device_info->remote_name);
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "service count = %d.", device_info->service_count);
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "bonded?? %d.", device_info->is_bonded);
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "connected?? %d.", device_info->is_connected);
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "authorized?? %d.", device_info->is_authorized);
                                                  +
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "major_device_class %d.", device_info->bt_class.major_device_class);
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "minor_device_class %d.", device_info->bt_class.minor_device_class);
                                                  +    dlog_print(DLOG_INFO, LOG_TAG, "major_service_class_mask %d.", device_info->bt_class.major_service_class_mask);
                                                  +    count_of_bonded_device++;
                                                  +
                                                  +    /* Keep iterating */
                                                  +
                                                  +    return true;
                                                   }
                                                   
                                                   ret = bt_adapter_foreach_bonded_device(adapter_bonded_device_cb, remote_server_name);
                                                  -if (ret != BT_ERROR_NONE) 
                                                  -{
                                                  -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_foreach_bonded_device] failed!");
                                                  -}
                                                  +if (ret != BT_ERROR_NONE)
                                                  +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_foreach_bonded_device] failed!");
                                                   
                                                   if (bt_server_address != NULL)
                                                  -   free(bt_server_address);
                                                  +    free(bt_server_address);
                                                   

                                                  To remove a device from the bonded list, call the bt_device_destroy_bond() function.

                                                @@ -520,23 +488,17 @@ if (bt_server_address != NULL)
                                              59. Check the current visibility of your device:

                                                -// Visibility mode of the Bluetooth device
                                                +/* Visibility mode of the Bluetooth device */
                                                 bt_adapter_visibility_mode_e mode;
                                                -// Duration until the visibility mode is changed so that other devices cannot find your device
                                                +/* Duration until the visibility mode is changed so that other devices cannot find your device */
                                                 int duration = 1;
                                                 bt_adapter_get_visibility(&mode, &duration);
                                                -if (mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) 
                                                -{
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "The device is not discoverable.");
                                                -} 
                                                -else if (mode == BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE) 
                                                -{
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "The device is discoverable. No time limit.");
                                                -} 
                                                -else 
                                                -{
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "The device is discoverable for a set period of time.");
                                                -}
                                                +if (mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE)
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "The device is not discoverable.");
                                                +else if (mode == BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE)
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "The device is discoverable. No time limit.");
                                                +else
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "The device is discoverable for a set period of time.");
                                                 
                                              60. @@ -548,69 +510,57 @@ else #include <app_control.h> #include <dlog.h> -int +int bt_set_visibility_operation(void) { -   int ret = 0; -   app_control_h service = NULL; -   app_control_create(&service); -   if (service == NULL) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "service_create failed!\n"); - -      return 0; -   } -   app_control_set_operation(service, "APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY"); -   ret = app_control_send_launch_request(service, NULL, NULL); - -   app_control_destroy(service); -   if (ret == APP_CONTROL_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to Bluetooth On/Off app!\n"); - -      return 0; -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to relaunch Bluetooth On/Off app!\n"); - -      return -1; -   } - -   return 0; +    int ret = 0; +    app_control_h service = NULL; +    app_control_create(&service); +    if (service == NULL) { +        dlog_print(DLOG_INFO, LOG_TAG, "service_create failed!\n"); + +        return 0; +    } +    app_control_set_operation(service, "APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY"); +    ret = app_control_send_launch_request(service, NULL, NULL); + +    app_control_destroy(service); +    if (ret == APP_CONTROL_ERROR_NONE) { +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to Bluetooth On/Off app!\n"); + +        return 0; +    } else { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to relaunch Bluetooth On/Off app!\n"); + +        return -1; +    } + +    return 0; }
                                              61. To get a notification when the visibility mode changes, define and register a visibility mode change callback:

                                                -void 
                                                -adapter_visibility_mode_changed_cb(int result, bt_adapter_visibility_mode_e visibility_mode, void* user_data) 
                                                +void
                                                +adapter_visibility_mode_changed_cb(int result, bt_adapter_visibility_mode_e visibility_mode, void* user_data)
                                                 {
                                                -   if (result != BT_ERROR_NONE) 
                                                -   {
                                                -      // Error handling
                                                -      return;
                                                -   }
                                                -   if (visibility_mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) 
                                                -   {
                                                -      dlog_print(DLOG_INFO, LOG_TAG, "[visibility_mode_changed_cb] None discoverable mode!");
                                                -   } 
                                                -   else if (visibility_mode == BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE) 
                                                -   {
                                                -      dlog_print(DLOG_INFO, LOG_TAG, "[visibility_mode_changed_cb] General discoverable mode!");
                                                -   } 
                                                -   else 
                                                -   {
                                                -      dlog_print(DLOG_INFO, LOG_TAG, "[visibility_mode_changed_cb] Limited discoverable mode!");
                                                -   }
                                                +    if (result != BT_ERROR_NONE) {
                                                +        /* Error handling */
                                                +
                                                +        return;
                                                +    }
                                                +    if (visibility_mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE)
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "[visibility_mode_changed_cb] None discoverable mode!");
                                                +    else if (visibility_mode == BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE)
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "[visibility_mode_changed_cb] General discoverable mode!");
                                                +    else
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "[visibility_mode_changed_cb] Limited discoverable mode!");
                                                 }
                                                 
                                                 ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb, NULL);
                                                -if (ret != BT_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_set_visibility_mode_changed_cb] failed.");
                                                -}
                                                +if (ret != BT_ERROR_NONE)
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_set_visibility_mode_changed_cb] failed.");
                                                 
                                              62. @@ -628,28 +578,23 @@ if (ret != BT_ERROR_NONE) const char* my_uuid="00001101-0000-1000-8000-00805F9B34FB"; int server_socket_fd = -1; bt_error_e ret; - + ret = bt_socket_create_rfcomm(my_uuid, &server_socket_fd); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "bt_socket_create_rfcomm() failed."); -} +if (ret != BT_ERROR_NONE) +    dlog_print(DLOG_ERROR, LOG_TAG, "bt_socket_create_rfcomm() failed.");
                                              63. To listen for an incoming connection from a client, call the bt_socket_listen_and_accept_rfcomm() function. The first parameter is the socket file descriptor passed from bt_socket_create_rfcomm(), defining the socket that starts listening. The second parameter is the maximum number of pending connections that a Bluetooth server can store.

                                                 ret = bt_socket_listen_and_accept_rfcomm(server_socket_fd, 5);
                                                -if (ret != BT_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_listen_and_accept_rfcomm] failed.");
                                                +if (ret != BT_ERROR_NONE) {
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_listen_and_accept_rfcomm] failed.");
                                                 
                                                -   return;
                                                -} 
                                                -else 
                                                -{
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_listen_and_accept_rfcomm] Succeeded. bt_socket_connection_state_changed_cb will be called.");
                                                -   // Waiting for incoming connections
                                                +    return;
                                                +} else {
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_listen_and_accept_rfcomm] Succeeded. bt_socket_connection_state_changed_cb will be called.");
                                                +    /* Waiting for incoming connections */
                                                 }
                                                 
                                              64. @@ -657,55 +602,44 @@ else

                                                Register the socket connection state change callback using the bt_socket_set_connection_state_changed_cb() function.

                                                The callback in invoked whenever the connection state changes (for example, when a client connects to your service). In its parameters, the callback provides the result of the connection state change, the new connection state, and a pointer to the bt_socket_connection_s structure (in mobile and wearable applications) that specifies the details of the connection, including the client device MAC address.

                                                -void 
                                                +void
                                                 socket_connection_state_changed(int result, bt_socket_connection_state_e connection_state,
                                                -                                bt_socket_connection_s *connection, void *user_data) 
                                                -{
                                                -   if (result != BT_ERROR_NONE) 
                                                -   {
                                                -      dlog_print(DLOG_ERROR, LOG_TAG, "[socket_connection_state_changed_cb] failed. result =%d.", result);
                                                -
                                                -      return;
                                                -   }
                                                - 
                                                -   if (connection_state == BT_SOCKET_CONNECTED) 
                                                -   {
                                                -      dlog_print(DLOG_INFO, LOG_TAG, "Callback: Connected.");
                                                -      if (connection != NULL) 
                                                -      {
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Callback: Socket of connection - %d.", connection->socket_fd);
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Callback: Role of connection - %d.", connection->local_role);
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Callback: Address of connection - %s.", connection->remote_address);
                                                -         // socket_fd is used for sending data and disconnecting a device
                                                -         server_socket_fd = connection->socket_fd;
                                                -      } 
                                                -      else 
                                                -      {
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Callback: No connection data");
                                                -      }
                                                -   } 
                                                -   else 
                                                -   {
                                                -      dlog_print(DLOG_INFO, LOG_TAG, "Callback: Disconnected.");
                                                -      if (connection != NULL) 
                                                -      {
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Callback: Socket of disconnection - %d.", connection->socket_fd);
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Callback: Address of connection - %s.", connection->remote_address);
                                                -      } 
                                                -      else 
                                                -      {
                                                -         dlog_print(DLOG_INFO, LOG_TAG, "Callback: No connection data");
                                                -      }
                                                -   }
                                                -}
                                                - 
                                                +                                bt_socket_connection_s *connection, void *user_data)
                                                +{
                                                +    if (result != BT_ERROR_NONE) {
                                                +        dlog_print(DLOG_ERROR, LOG_TAG, "[socket_connection_state_changed_cb] failed. result =%d.", result);
                                                +
                                                +        return;
                                                +    }
                                                +
                                                +    if (connection_state == BT_SOCKET_CONNECTED) {
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Callback: Connected.");
                                                +        if (connection != NULL) {
                                                +            dlog_print(DLOG_INFO, LOG_TAG, "Callback: Socket of connection - %d.", connection->socket_fd);
                                                +            dlog_print(DLOG_INFO, LOG_TAG, "Callback: Role of connection - %d.", connection->local_role);
                                                +            dlog_print(DLOG_INFO, LOG_TAG, "Callback: Address of connection - %s.", connection->remote_address);
                                                +            /* socket_fd is used for sending data and disconnecting a device */
                                                +            server_socket_fd = connection->socket_fd;
                                                +        } else {
                                                +            dlog_print(DLOG_INFO, LOG_TAG, "Callback: No connection data");
                                                +        }
                                                +    } else {
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "Callback: Disconnected.");
                                                +        if (connection != NULL) {
                                                +            dlog_print(DLOG_INFO, LOG_TAG, "Callback: Socket of disconnection - %d.", connection->socket_fd);
                                                +            dlog_print(DLOG_INFO, LOG_TAG, "Callback: Address of connection - %s.", connection->remote_address);
                                                +        } else {
                                                +            dlog_print(DLOG_INFO, LOG_TAG, "Callback: No connection data");
                                                +        }
                                                +    }
                                                +}
                                                +
                                                 bt_error_e ret;
                                                 ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed, NULL);
                                                -if (ret != BT_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_set_connection_state_changed_cb] failed.");
                                                +if (ret != BT_ERROR_NONE) {
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_set_connection_state_changed_cb] failed.");
                                                 
                                                -   return;
                                                +    return;
                                                 }
                                                 
                                                @@ -720,11 +654,10 @@ if (ret != BT_ERROR_NONE)

                                                The callback is invoked whenever the connection state changes (for example, when you connect to the server device).

                                                 ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed, NULL);
                                                -if (ret != BT_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_set_connection_state_changed_cb] failed.");
                                                +if (ret != BT_ERROR_NONE) {
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_set_connection_state_changed_cb] failed.");
                                                 
                                                -   return;
                                                +    return;
                                                 }
                                                 
                                                @@ -734,7 +667,7 @@ if (ret != BT_ERROR_NONE)
                                                - +
                                                Note
                                                When you connect to a Bluetooth server device, retrieve the server socket file descriptor (bt_socket_connection_s->socket_fd) in the callback and store it for later use. You need the file descriptor when sending data or disconnecting from the service.When you connect to a Bluetooth server device, retrieve the server socket file descriptor (bt_socket_connection_s->socket_fd) in the callback and store it for later use. You need the file descriptor when sending data or disconnecting from the service.
                                                @@ -744,17 +677,14 @@ if (ret != BT_ERROR_NONE)

                                                The first parameter is the address of the remote device. You can get it from the bt_device_info_s structure (in mobile and wearable applications), which is returned in a callback after you bond with the server device or query a previously bonded device. The second parameter is the UUID for the specific RFCOMM-based service on a remote device. The UUID must match the UUID used by the server device in the bt_socket_create_rfcomm() function.

                                                 const char *service_uuid="00001101-0000-1000-8000-00805F9B34FB";
                                                - 
                                                +
                                                 ret = bt_socket_connect_rfcomm(bt_server_address, service_uuid);
                                                -if (ret != BT_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_connect_rfcomm] failed.");
                                                +if (ret != BT_ERROR_NONE) {
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_connect_rfcomm] failed.");
                                                 
                                                -   return;
                                                -} 
                                                -else 
                                                -{
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_connect_rfcomm] Succeeded. bt_socket_connection_state_changed_cb will be called.");
                                                +    return;
                                                +} else {
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_connect_rfcomm] Succeeded. bt_socket_connection_state_changed_cb will be called.");
                                                 }
                                                 
                                                @@ -772,10 +702,8 @@ char data[] = "Sending test"; int client_socket_fd = 0; ret = bt_socket_send_data(client_socket_fd, data, sizeof(data)); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_send_data] failed."); -} +if (ret != BT_ERROR_NONE) +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_send_data] failed.");
                                              65. To read data from other devices, you must set up the data received callback, which is invoked when your device receives data from other Bluetooth devices.

                                                @@ -784,25 +712,22 @@ if (ret != BT_ERROR_NONE)
                                                 bt_error_e ret;
                                                 
                                                -void 
                                                +void
                                                 bt_socket_data_received_cb(bt_socket_received_data_s* data, void* user_data)
                                                 {
                                                -   if (data == NULL) 
                                                -   {
                                                -      dlog_print(DLOG_INFO, LOG_TAG, "No received data!");
                                                +    if (data == NULL) {
                                                +        dlog_print(DLOG_INFO, LOG_TAG, "No received data!");
                                                 
                                                -      return;
                                                -   }
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "Socket fd: %d", data->socket_fd);
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "Data: %s", data->data);
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "Size: %d", data->data_size);
                                                +        return;
                                                +    }
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "Socket fd: %d", data->socket_fd);
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "Data: %s", data->data);
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "Size: %d", data->data_size);
                                                 }
                                                 
                                                 ret = bt_socket_set_data_received_cb(bt_socket_data_received_cb, NULL);
                                                -if (ret != BT_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_data_received_cb] regist failed.");
                                                -}
                                                +if (ret != BT_ERROR_NONE)
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_data_received_cb] regist failed.");
                                                 
                                              @@ -814,33 +739,25 @@ if (ret != BT_ERROR_NONE)
                                              • If your device is a Bluetooth server, disconnect from the client with the bt_socket_destroy_rfcomm() function:
                                                 bt_error_e ret;
                                                - 
                                                -// You can get "server_socket_fd" from output of bt_socket_create_rfcomm()
                                                +
                                                +/* You can get "server_socket_fd" from output of bt_socket_create_rfcomm() */
                                                 ret = bt_socket_destroy_rfcomm(server_socket_fd);
                                                -if (ret != BT_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_destroy_rfcomm] failed.");
                                                -} 
                                                -else 
                                                -{
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_destroy_rfcomm] succeeded. socket_fd = %d", server_socket_fd);
                                                -}
                                                +if (ret != BT_ERROR_NONE)
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_destroy_rfcomm] failed.");
                                                +else
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_destroy_rfcomm] succeeded. socket_fd = %d", server_socket_fd);
                                                 
                                              • If your device is a Bluetooth client, disconnect from the server with the bt_socket_disconnect_rfcomm() function:
                                                 bt_error_e ret;
                                                - 
                                                -// You can get "server_socket_fd" from bt_socket_connection_state_changed_cb()
                                                +
                                                +/* You can get "server_socket_fd" from bt_socket_connection_state_changed_cb() */
                                                 ret = bt_socket_disconnect_rfcomm(server_socket_fd);
                                                -if (ret != BT_ERROR_NONE) 
                                                -{
                                                -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_destroy_rfcomm] failed. server_socket_fd = %d.", server_socket_fd);
                                                -} 
                                                -else 
                                                -{
                                                -   dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_destroy_rfcomm] succeeded. server_socket_fd = %d.", server_socket_fd);
                                                -}
                                                +if (ret != BT_ERROR_NONE)
                                                +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_destroy_rfcomm] failed. server_socket_fd = %d.", server_socket_fd);
                                                +else
                                                +    dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_destroy_rfcomm] succeeded. server_socket_fd = %d.", server_socket_fd);
                                                 

                                              Handling GATT Operation Preconditions

                                              @@ -849,21 +766,17 @@ else

                                              To connect to the BLE target:

                                               int ret = BT_ERROR_NONE;
                                              -// For information on the callback, see Managing Bluetooth LE Scans
                                              +/* For information on the callback, see Managing Bluetooth LE Scans */
                                               ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL);
                                              -if (ret != BT_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_start_scan] failed.");
                                              -}
                                              -// Wait while the system searches for the LE target you want to connect to
                                              -// If you find the LE target you want, stop the scan
                                              +if (ret != BT_ERROR_NONE)
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_start_scan] failed.");
                                              +/* Wait while the system searches for the LE target you want to connect to */
                                              +/* If you find the LE target you want, stop the scan */
                                               ret = bt_adapter_le_stop_scan();
                                               
                                               ret = bt_gatt_connect(ADDRESS_BLE_DEVICE_YOU_WANT, false);
                                              -if (ret != BT_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to connect LE device.");
                                              -}
                                              +if (ret != BT_ERROR_NONE)
                                              +    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to connect LE device.");
                                               

                                              Managing the GATT Client Operations

                                              @@ -872,15 +785,15 @@ if (ret != BT_ERROR_NONE)
                                            1. Register a callback for connection state changes:
                                               int ret = 0;
                                              -// Register for GATT connection callback
                                              +/* Register for GATT connection callback */
                                               void
                                              -__bt_gatt_connection_state_changed_cb(int result, bool connected, 
                                              -                                      const char *remote_address, void *user_data) 
                                              +__bt_gatt_connection_state_changed_cb(int result, bool connected,
                                              +                                      const char *remote_address, void *user_data)
                                               {
                                              -   if (connected)
                                              -      dlog_print(DLOG_INFO, LOG_TAG, "LE connected");
                                              -   else
                                              -      dlog_print(DLOG_INFO, LOG_TAG, "LE disconnected");
                                              +    if (connected)
                                              +        dlog_print(DLOG_INFO, LOG_TAG, "LE connected");
                                              +    else
                                              +        dlog_print(DLOG_INFO, LOG_TAG, "LE disconnected");
                                               }
                                               
                                               ret = bt_gatt_set_connection_state_changed_cb(__bt_gatt_connection_state_changed_cb, NULL);
                                              @@ -892,7 +805,7 @@ int ret = 0;
                                               
                                               ret = bt_gatt_client_create(remote_addr, &client);
                                               if (ret == BT_ERROR_NONE)
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Success");
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Success");
                                               
                                               return;
                                               
                                              @@ -905,7 +818,7 @@ char *addr = NULL; ret = bt_gatt_client_get_remote_address(client, &addr); if (ret == BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "Success"); +    dlog_print(DLOG_INFO, LOG_TAG, "Success"); return; @@ -917,75 +830,71 @@ return; int ret = 0; ret = bt_gatt_client_foreach_services(client, __bt_gatt_client_foreach_svc_cb, NULL); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "failed"); -} +if (ret != BT_ERROR_NONE) +    dlog_print(DLOG_INFO, LOG_TAG, "failed"); return;
                                            2. Use the bt_gatt_client_foreach_svc_cb() callback to initiate the service characteristics discovery:
                                              -bool 
                                              +bool
                                               __bt_gatt_client_foreach_svc_cb(int total, int index, bt_gatt_h svc_handle, void *data)
                                               {
                                              -   int ret;
                                              -   char *uuid = NULL;
                                              +    int ret;
                                              +    char *uuid = NULL;
                                               
                                              -   bt_gatt_get_uuid(svc_handle, &uuid);
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "[%d / %d] uuid: (%s)", index, total, uuid);
                                              +    bt_gatt_get_uuid(svc_handle, &uuid);
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "[%d / %d] uuid: (%s)", index, total, uuid);
                                               
                                              -   g_free(uuid);
                                              +    g_free(uuid);
                                               
                                              -   ret = bt_gatt_service_foreach_characteristics(svc_handle,
                                              -                                                 __bt_gatt_client_foreach_chr_cb, NULL);
                                              -   if (ret != BT_ERROR_NONE)
                                              -   {
                                              -      dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_foreach_characteristics failed: %d", ret);
                                              -   }
                                              +    ret = bt_gatt_service_foreach_characteristics(svc_handle,
                                              +                                                  __bt_gatt_client_foreach_chr_cb, NULL);
                                              +    if (ret != BT_ERROR_NONE)
                                              +        dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_foreach_characteristics failed: %d", ret);
                                               
                                              -   return true;
                                              +    return true;
                                               }
                                               
                                            3. Use the bt_gatt_client_foreach_chr_cb() callback to discover the characteristic descriptors:
                                              -bool 
                                              +bool
                                               __bt_gatt_client_foreach_chr_cb(int total, int index, bt_gatt_h chr_handle, void *data)
                                               {
                                              -   int ret;
                                              -   char *uuid = NULL;
                                              +    int ret;
                                              +    char *uuid = NULL;
                                               
                                              -   bt_gatt_get_uuid(chr_handle, &uuid);
                                              +    bt_gatt_get_uuid(chr_handle, &uuid);
                                               
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "\t[%d / %d] uuid: (%s)", index, total, uuid);
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "\t[%d / %d] uuid: (%s)", index, total, uuid);
                                               
                                              -   g_free(uuid);
                                              +    g_free(uuid);
                                               
                                              -   ret = bt_gatt_characteristic_foreach_descriptors(chr_handle,
                                              -                                                    __bt_gatt_client_foreach_desc_cb, NULL);
                                              -   if (ret != BT_ERROR_NONE)
                                              -      dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_foreach_descriptors failed: %d", ret);
                                              +    ret = bt_gatt_characteristic_foreach_descriptors(chr_handle,
                                              +                                                     __bt_gatt_client_foreach_desc_cb, NULL);
                                              +    if (ret != BT_ERROR_NONE)
                                              +        dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_foreach_descriptors failed: %d", ret);
                                               
                                              -   return true;
                                              +    return true;
                                               }
                                               
                                            4. Use the bt_gatt_client_foreach_desc_cb() callback to get the descriptor data:
                                              -bool 
                                              +bool
                                               __bt_gatt_client_foreach_desc_cb(int total, int index, bt_gatt_h desc_handle, void *data)
                                               {
                                              -   char *uuid = NULL;
                                              +    char *uuid = NULL;
                                               
                                              -   bt_gatt_get_uuid(desc_handle, &uuid);
                                              +    bt_gatt_get_uuid(desc_handle, &uuid);
                                               
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "\t\t[%d / %d] uuid: (%s)", index, total, uuid);
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "\t\t[%d / %d] uuid: (%s)", index, total, uuid);
                                               
                                              -   g_free(uuid);
                                              +    g_free(uuid);
                                               
                                              -   return true;
                                              +    return true;
                                               }
                                               
                                            5. @@ -993,194 +902,172 @@ __bt_gatt_client_foreach_desc_cb(int total, int index, bt_gatt_h desc_handle, vo
                                            6. Read the value of the given attribute handle:
                                              -char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; // Battery service
                                              -char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; // Battery level
                                              -char *desc_uuid = "00002902-0000-1000-8000-00805f9b34fb"; // Client characteristic configuration
                                              +char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; /* Battery service */
                                              +char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; /* Battery level */
                                              +char *desc_uuid = "00002902-0000-1000-8000-00805f9b34fb"; /* Client characteristic configuration */
                                               bt_gatt_h svc = NULL;
                                               bt_gatt_h chr = NULL;
                                               bt_gatt_h desc = NULL;
                                               
                                               ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = bt_gatt_characteristic_get_descriptor(chr, desc_uuid, &desc);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_descriptor failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_descriptor failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = bt_gatt_client_read_value(desc, __bt_gatt_client_read_complete_cb, NULL);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_read_value failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_read_value failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               

                                              After the reading operation is complete, use the bt_gatt_client_read_complete_cb() callback to handle values:

                                              -void 
                                              +void
                                               __bt_gatt_client_read_complete_cb(int result, bt_gatt_h gatt_handle, void *data)
                                               {
                                              -   char *uuid = NULL;
                                              +    char *uuid = NULL;
                                               
                                              -   bt_gatt_get_uuid(gatt_handle, &uuid);
                                              +    bt_gatt_get_uuid(gatt_handle, &uuid);
                                               
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Read %s for uuid: (%s)", 
                                              -              result == BT_ERROR_NONE ? "Success" : "Fail", uuid);
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Read %s for uuid: (%s)",
                                              +               result == BT_ERROR_NONE ? "Success" : "Fail", uuid);
                                               
                                              -   g_free(uuid);
                                              +    g_free(uuid);
                                               
                                              -   if (result != BT_ERROR_NONE)
                                              -      return;
                                              +    if (result != BT_ERROR_NONE)
                                              +        return;
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                            7. Set a value for the given attribute handle:
                                              -char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; // Battery service
                                              -char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; // Battery level
                                              -char *desc_uuid = "00002902-0000-1000-8000-00805f9b34fb"; // Client characteristic configuration
                                              +char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; /* Battery service */
                                              +char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; /* Battery level */
                                              +char *desc_uuid = "00002902-0000-1000-8000-00805f9b34fb"; /* Client characteristic configuration */
                                               bt_gatt_h svc = NULL;
                                               bt_gatt_h chr = NULL;
                                               bt_gatt_h desc = NULL;
                                               
                                               ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
                                              -if (ret != BT_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
                                              -if (ret != BT_ERROR_NONE) 
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = bt_gatt_characteristic_get_descriptor(chr, desc_uuid, &desc);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_descriptor failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_descriptor failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = __bt_gatt_client_set_value("int32", "1234", desc);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_set_value failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_set_value failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = bt_gatt_client_write_value(desc, __bt_gatt_client_write_complete_cb, NULL);
                                               
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_write_value failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_write_value failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               

                                              The __bt_gatt_client_set_value() function is defined below:

                                              -int 
                                              +int
                                               __bt_gatt_client_set_value(char *type, char *value, bt_gatt_h h)
                                               {
                                              -   int ret;
                                              -   int s_val;
                                              -   unsigned int u_val;
                                              -   char *buf;
                                              -   int len;
                                              -
                                              -   if (strcasecmp(type, "int8") == 0) 
                                              -   {
                                              -      s_val = atoi(value);
                                              -      buf = (char *)&s_val;
                                              -      len = 1;
                                              -   } 
                                              -   else if (strcasecmp(type, "int16") == 0) 
                                              -   {
                                              -      s_val = atoi(value);
                                              -      buf = (char *)&s_val;
                                              -      len = 2;
                                              -   } 
                                              -   else if (strcasecmp(type, "int32") == 0) 
                                              -   {
                                              -      s_val = atoi(value);
                                              -      buf = (char *)&s_val;
                                              -      len = 4;
                                              -   } 
                                              -   else if (strcasecmp(type, "uint8") == 0) 
                                              -   {
                                              -      u_val = strtoul(value, NULL, 10);
                                              -      buf = (char *)&u_val;
                                              -      len = 1;
                                              -   } 
                                              -   else if (strcasecmp(type, "uint16") == 0) 
                                              -   {
                                              -      u_val = strtoul(value, NULL, 10);
                                              -      buf = (char *)&u_val;
                                              -      len = 2;
                                              -   } 
                                              -   else if (strcasecmp(type, "uint32") == 0) 
                                              -   {
                                              -      u_val = strtoul(value, NULL, 10);
                                              -      buf = (char *)&u_val;
                                              -      len = 4;
                                              -   } 
                                              -   else if (strcasecmp(type, "str") == 0) 
                                              -   {
                                              -      buf = value;
                                              -      len = strlen(buf);
                                              -   } 
                                              -   else
                                              -      return BT_ERROR_INVALID_PARAMETER;
                                              -
                                              -   ret = bt_gatt_set_value(h, buf, len);
                                              -   if (ret != BT_ERROR_NONE)
                                              -      TC_PRT("bt_gatt_set_value failed: %d", ret);
                                              -
                                              -   return ret;
                                              +    int ret;
                                              +    int s_val;
                                              +    unsigned int u_val;
                                              +    char *buf;
                                              +    int len;
                                              +
                                              +    if (strcasecmp(type, "int8") == 0) {
                                              +        s_val = atoi(value);
                                              +        buf = (char *)&s_val;
                                              +        len = 1;
                                              +    } else if (strcasecmp(type, "int16") == 0) {
                                              +        s_val = atoi(value);
                                              +        buf = (char *)&s_val;
                                              +        len = 2;
                                              +    } else if (strcasecmp(type, "int32") == 0) {
                                              +        s_val = atoi(value);
                                              +        buf = (char *)&s_val;
                                              +        len = 4;
                                              +    } else if (strcasecmp(type, "uint8") == 0) {
                                              +        u_val = strtoul(value, NULL, 10);
                                              +        buf = (char *)&u_val;
                                              +        len = 1;
                                              +    } else if (strcasecmp(type, "uint16") == 0) {
                                              +        u_val = strtoul(value, NULL, 10);
                                              +        buf = (char *)&u_val;
                                              +        len = 2;
                                              +    } else if (strcasecmp(type, "uint32") == 0) {
                                              +        u_val = strtoul(value, NULL, 10);
                                              +        buf = (char *)&u_val;
                                              +        len = 4;
                                              +    } else if (strcasecmp(type, "str") == 0) {
                                              +        buf = value;
                                              +        len = strlen(buf);
                                              +    } else {
                                              +        return BT_ERROR_INVALID_PARAMETER;
                                              +    }
                                              +
                                              +    ret = bt_gatt_set_value(h, buf, len);
                                              +    if (ret != BT_ERROR_NONE)
                                              +        TC_PRT("bt_gatt_set_value failed: %d", ret);
                                              +
                                              +    return ret;
                                               }
                                               

                                              After the writing operation is complete, use the bt_gatt_client_write_complete_cb() callback to finish the task:

                                              -void 
                                              +void
                                               __bt_gatt_client_write_complete_cb(int result, bt_gatt_h gatt_handle, void *data)
                                               {
                                              -   char *uuid = NULL;
                                              +    char *uuid = NULL;
                                               
                                              -   bt_gatt_get_uuid(gatt_handle, &uuid);
                                              +    bt_gatt_get_uuid(gatt_handle, &uuid);
                                               
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Write %s for uuid: (%s)", 
                                              -              result == BT_ERROR_NONE ? "Success" : "Fail", uuid);
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Write %s for uuid: (%s)",
                                              +               result == BT_ERROR_NONE ? "Success" : "Fail", uuid);
                                               
                                              -   g_free(uuid);
                                              +    g_free(uuid);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                            8. @@ -1193,95 +1080,87 @@ bt_gatt_h svc = NULL; bt_gatt_h chr = NULL; ret = bt_gatt_client_get_service(client, svc_uuid, &svc); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret); +if (ret != BT_ERROR_NONE) { +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret); -   return; +    return; } ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret); +if (ret != BT_ERROR_NONE) { +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret); -   return; +    return; } ret = bt_gatt_client_set_characteristic_value_changed_cb(chr, __bt_gatt_client_value_changed_cb, NULL); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_set_characteristic_value_changed_cb failed: %d", ret); +if (ret != BT_ERROR_NONE) { +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_set_characteristic_value_changed_cb failed: %d", ret); -   return; +    return; }

                                              After registering the callback operation, use the __bt_gatt_client_value_changed_cb() callback to display the changed value:

                                              -void 
                                              +void
                                               __bt_gatt_client_value_changed_cb(bt_gatt_h chr, char *value, int len, void *user_data)
                                               {
                                              -   char *uuid = NULL;
                                              -   int i;
                                              +    char *uuid = NULL;
                                              +    int i;
                                               
                                              -   bt_gatt_get_uuid(chr, &uuid);
                                              +    bt_gatt_get_uuid(chr, &uuid);
                                               
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Value changed for [%s]", uuid);
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "len [%d]", len);
                                              -   for (i = 0; i < len; i++)
                                              -   {
                                              -      dlog_print(DLOG_INFO, LOG_TAG, "value %u", value[i]);
                                              -   }
                                              -   g_free(uuid);
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Value changed for [%s]", uuid);
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "len [%d]", len);
                                              +    for (i = 0; i < len; i++)
                                              +        dlog_print(DLOG_INFO, LOG_TAG, "value %u", value[i]);
                                              +    g_free(uuid);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                              -

                                              When you no longer need the value change notifications, unregister the callback.

                                              +

                                              When you no longer need the value change notifications, deregister the callback.

                                              -char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; // Battery service
                                              -char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; // Battery level
                                              +char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; /* Battery service */
                                              +char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; /* Battery level */
                                               bt_gatt_h svc = NULL;
                                               bt_gatt_h chr = NULL;
                                               
                                               ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                               ret = bt_gatt_client_unset_characteristic_value_changed_cb(chr);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_unset_characteristic_value_changed_cb failed: %d", ret);
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_unset_characteristic_value_changed_cb failed: %d", ret);
                                               
                                              -   return;
                                              +    return;
                                               }
                                               
                                              -
                                            9. When you no longer need the client, unregister the connection state change callback, disconnect from the remote service, and destroy the client: +
                                            10. When you no longer need the client, deregister the connection state change callback, disconnect from the remote service, and destroy the client:
                                               int ret = 0;
                                               
                                              -// Unregister the GATT connection callback
                                              +/* Deregister the GATT connection callback */
                                               ret = bt_gatt_unset_connection_state_changed_cb();
                                               
                                              -// Destroy the client
                                              +/* Destroy the client */
                                               ret = bt_gatt_client_destroy(client);
                                               if (ret == BT_ERROR_NONE)
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "Success");
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "Success");
                                               client = NULL;
                                               
                                               return;
                                              @@ -1300,13 +1179,11 @@ int ret = 0;
                                               bt_gatt_h gatt_handle = NULL;
                                               bt_gatt_type_e gatt_type;
                                               
                                              -// Handle is already created for service/characteristic/descriptor
                                              +/* Handle is already created for service/characteristic/descriptor */
                                               
                                               ret = bt_gatt_get_type(gatt_handle, &gatt_type);
                                               if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_type failed: %d", ret);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_type failed: %d", ret);
                                               
                                            11. Get the UUID of a service, characteristic, or descriptor handle: @@ -1315,13 +1192,11 @@ int ret = 0; bt_gatt_h gatt_handle = NULL; char *uuid = NULL; -// Handle is already created for service/characteristic/descriptor +/* Handle is already created for service/characteristic/descriptor */ ret = bt_gatt_get_uuid(gatt_handle, &uuid); if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_uuid failed: %d", ret); -} +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_uuid failed: %d", ret);
                                            12. Get the value of a characteristic or descriptor handle: @@ -1331,13 +1206,11 @@ int len = 0; bt_gatt_h gatt_handle = NULL; char *value = NULL; -// Handle is already created for characteristic/descriptor +/* Handle is already created for characteristic/descriptor */ ret = bt_gatt_get_value(gatt_handle, &value, &len); if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_value failed: %d", ret); -} +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_value failed: %d", ret);
                                            13. Get the value of a characteristic or descriptor handle as an integer type: @@ -1348,13 +1221,11 @@ bt_data_type_int_e type; bt_gatt_h gatt_handle = NULL; int value; -// Assuming all the input parameters (gatt_handle, type, and offset) are available +/* Assuming all the input parameters (gatt_handle, type, and offset) are available */ ret = bt_gatt_get_int_value(gatt_handle, type, offset, &value); if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_int_value failed: %d", ret); -} +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_int_value failed: %d", ret);
                                            14. Get the value of a characteristic or descriptor handle as a float type: @@ -1365,76 +1236,65 @@ bt_data_type_float_e type; bt_gatt_h gatt_handle = NULL; float value; -// Assuming all the input parameters (gatt_handle, type, and offset) are available +/* Assuming all the input parameters (gatt_handle, type, and offset) are available */ ret = bt_gatt_get_float_value(gatt_handle, type, offset, &value); if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_float_value failed: %d", ret); -} +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_get_float_value failed: %d", ret);
                                            15. Get a service handle with a specific UUID:
                                              -char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; // Battery service
                                              +char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; /* Battery service */
                                               bt_gatt_h svc = NULL;
                                               
                                               ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
                                               if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                               
                                            16. Get a characteristic handle with a specific UUID:
                                              -char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; // Battery service
                                              -char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; // Battery level
                                              +char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; /* Battery service */
                                              +char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; /* Battery level */
                                               bt_gatt_h svc = NULL;
                                               bt_gatt_h chr = NULL;
                                               
                                               ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                              -   break;
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                              +    break;
                                               }
                                               
                                               ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
                                               if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                               
                                            17. Get a descriptor handle with a specific UUID:
                                              -char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; // Battery service
                                              -char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; // Battery level
                                              -char *desc_uuid = "00002902-0000-1000-8000-00805f9b34fb"; // Client characteristic configuration
                                              +char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; /* Battery service */
                                              +char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; /* Battery level */
                                              +char *desc_uuid = "00002902-0000-1000-8000-00805f9b34fb"; /* Client characteristic configuration */
                                               bt_gatt_h svc = NULL;
                                               bt_gatt_h chr = NULL;
                                               bt_gatt_h desc = NULL;
                                               
                                               ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                              -   break;
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);
                                              +    break;
                                               }
                                               
                                               ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
                                              -if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                              -   break;
                                              +if (ret != BT_ERROR_NONE) {
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);
                                              +    break;
                                               }
                                               
                                               ret = bt_gatt_characteristic_get_descriptor(chr, desc_uuid, &desc);
                                               if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_descriptor failed: %d", ret);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_descriptor failed: %d", ret);
                                               
                                            18. Get the properties using the characteristic handle: @@ -1442,65 +1302,55 @@ if (ret != BT_ERROR_NONE) bt_gatt_h chr = NULL; int properties; -// Get the characteristic handle using bt_gatt_service_get_characteristic() +/* Get the characteristic handle using bt_gatt_service_get_characteristic() */ ret = bt_gatt_characteristic_get_properties(chr, &properties); if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_properties failed: %d", ret); -} +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_properties failed: %d", ret);
                                            19. Get the service handle to which the specified characteristic belongs:
                                               bt_gatt_h svc = NULL;
                                               bt_gatt_h chr = NULL;
                                              -// chr = Assuming characteristic handle is already available
                                              +/* chr = Assuming characteristic handle is already available */
                                               
                                               ret = bt_gatt_characteristic_get_service(chr, &svc);
                                               if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_service failed: %d", ret);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_service failed: %d", ret);
                                               
                                            20. Get the characteristic handle to which the specified descriptor belongs:
                                               bt_gatt_h chr = NULL;
                                               bt_gatt_h dsc = NULL;
                                              -// dsc = Assuming descriptor handle is already available
                                              +/* dsc = Assuming descriptor handle is already available */
                                               
                                               ret = bt_gatt_descriptor_get_characteristic(dsc, &chr);
                                               if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_descriptor_get_characteristic failed: %d", ret);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_descriptor_get_characteristic failed: %d", ret);
                                               
                                            21. Get the client handle to which the specified service belongs:
                                               bt_gatt_h svc = NULL;
                                               bt_gatt_client_h client = NULL;
                                              -// svc = Assuming service handle is already available
                                              +/* svc = Assuming service handle is already available */
                                               
                                               ret = bt_gatt_service_get_client(svc, &client);
                                               if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_client failed: %d", ret);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_client failed: %d", ret);
                                               
                                            22. Get the write type of the specified characteristic:
                                               bt_gatt_h chr = NULL;
                                               bt_gatt_write_type_e write_type;
                                              -// svc = Assuming characteristic handle is already available
                                              +/* svc = Assuming characteristic handle is already available */
                                               
                                               ret = bt_gatt_characteristic_get_write_type(chr, &write_type);
                                               if (ret != BT_ERROR_NONE)
                                              -{
                                              -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_write_type failed: %d", ret);
                                              -}
                                              +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_write_type failed: %d", ret);
                                               
                                            23. Get an included service's handle with a specific UUID: @@ -1509,13 +1359,11 @@ bt_gatt_h svc = NULL; bt_gatt_h included_svc = NULL; char *uuid = NULL; bt_gatt_write_type_e write_type = NULL; -// svc = Assuming service handle and UUID are already available +/* svc = Assuming service handle and UUID are already available */ ret = bt_gatt_service_get_included_service(svc, uuid, &included_svc); if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_included_service failed: %d", ret); -} +    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_included_service failed: %d", ret);
                              @@ -1532,12 +1380,14 @@ int ret = 0; char char_value[1] = {1 + (rand()%100)}; bt_gatt_h characteristic_handle = NULL; -// For client, the characteristic handle is retrieved from the client created using gatt_client_create() -// by using bt_gatt_service_get_characteristic() +/* + For client, the characteristic handle is retrieved from the client created using gatt_client_create() + by using bt_gatt_service_get_characteristic() +*/ ret = bt_gatt_set_value(characteristic_handle, char_value, 1); if (ret == BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "Success"); +    dlog_print(DLOG_INFO, LOG_TAG, "Success");
                            • Set or update the characteristic value (integer type value): @@ -1546,12 +1396,14 @@ int ret = 0; int char_value = 60 + (rand()%60); bt_gatt_h characteristic_handle = NULL; -// For client, the characteristic handle is retrieved from the client created using gatt_client_create() -// by using bt_gatt_service_get_characteristic() +/* + For client, the characteristic handle is retrieved from the client created using gatt_client_create() + by using bt_gatt_service_get_characteristic() +*/ ret = bt_gatt_set_int_value(characteristic_handle, BT_DATA_TYPE_UINT16, char_value, 1); if (ret == BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "Success"); +    dlog_print(DLOG_INFO, LOG_TAG, "Success");
                            • Set or update the characteristic value (float type value): @@ -1559,55 +1411,56 @@ if (ret == BT_ERROR_NONE) int ret = 0; bt_gatt_h characteristic_handle = NULL; -// For client, the characteristic handle is retrieved from the client created using gatt_client_create() -// by using bt_gatt_service_get_characteristic() - -// Here the char value is, value: 123 exponent -2 +/* + For client, the characteristic handle is retrieved from the client created using gatt_client_create() + by using bt_gatt_service_get_characteristic() + Here the char value is, value: 123 exponent -2 +*/ ret = bt_gatt_set_float_value(characteristic_handle, BT_DATA_TYPE_FLOAT, 123, -2, 1); if (ret == BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "Success"); +    dlog_print(DLOG_INFO, LOG_TAG, "Success");
                            • Set the characteristic write type:
                              -void 
                              -__write_completed_cb(int result, bt_gatt_h request_handle, void *user_data) 
                              +void
                              +__write_completed_cb(int result, bt_gatt_h request_handle, void *user_data)
                               {
                              -  if (result != BT_ERROR_NONE)
                              +    if (result != BT_ERROR_NONE)
                                   dlog_print(DLOG_INFO, LOG_TAG, "Write request failed");
                               }
                               
                              -int 
                              +int
                               main()
                               {
                              -   int ret = 0;
                              -   bt_gatt_h svc = NULL;
                              -   bt_gatt_h battery_svc = NULL;
                              -   bt_gatt_h control_point = NULL;
                              -   char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; // Battery service
                              -   char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; // Battery level
                              +    int ret = 0;
                              +    bt_gatt_h svc = NULL;
                              +    bt_gatt_h battery_svc = NULL;
                              +    bt_gatt_h control_point = NULL;
                              +    char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; /* Battery service */
                              +    char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; /* Battery level */
                               
                              -   ret = bt_gatt_client_get_service(client, svc_uuid, &battery_svc);
                              -   if (ret == BT_ERROR_NONE)
                              -      dlog_print(DLOG_INFO, LOG_TAG, "Success");
                              +    ret = bt_gatt_client_get_service(client, svc_uuid, &battery_svc);
                              +    if (ret == BT_ERROR_NONE)
                              +        dlog_print(DLOG_INFO, LOG_TAG, "Success");
                               
                              -   ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &control_point);
                              -   if (ret == BT_ERROR_NONE)
                              -      dlog_print(DLOG_INFO, LOG_TAG, "Success");
                              +    ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &control_point);
                              +    if (ret == BT_ERROR_NONE)
                              +        dlog_print(DLOG_INFO, LOG_TAG, "Success");
                               
                              -   ret = bt_gatt_characteristic_set_write_type(control_point, BT_GATT_WRITE_TYPE_WRITE);
                              -   if (ret == BT_ERROR_NONE)
                              -      dlog_print(DLOG_INFO, LOG_TAG, "Success");
                              +    ret = bt_gatt_characteristic_set_write_type(control_point, BT_GATT_WRITE_TYPE_WRITE);
                              +    if (ret == BT_ERROR_NONE)
                              +        dlog_print(DLOG_INFO, LOG_TAG, "Success");
                               
                              -   ret = bt_gatt_set_value(control_point, value, len);
                              -   if (ret == BT_ERROR_NONE)
                              -      dlog_print(DLOG_INFO, LOG_TAG, "Success");
                              +    ret = bt_gatt_set_value(control_point, value, len);
                              +    if (ret == BT_ERROR_NONE)
                              +        dlog_print(DLOG_INFO, LOG_TAG, "Success");
                               
                              -   ret = bt_gatt_client_write_value(control_point, __write_completed_cb, NULL);
                              -   if (ret == BT_ERROR_NONE)
                              -      dlog_print(DLOG_INFO, LOG_TAG, "Success");
                              +    ret = bt_gatt_client_write_value(control_point, __write_completed_cb, NULL);
                              +    if (ret == BT_ERROR_NONE)
                              +        dlog_print(DLOG_INFO, LOG_TAG, "Success");
                               
                              -   return ret;
                              +    return ret;
                               }
                               
                            @@ -1629,17 +1482,15 @@ bt_error_e ret; char *directory = NULL; storage_get_directory(0, STORAGE_DIRECTORY_DOWNLOADS, &directory); -void +void connection_requested_cb_for_opp_server(const char *remote_address, void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "remote_address: %s", remote_address); +    dlog_print(DLOG_INFO, LOG_TAG, "remote_address: %s", remote_address); } ret = bt_opp_server_initialize_by_connection_request(directory, connection_requested_cb_for_opp_server, NULL); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_opp_server_initialize_by_connection_request] failed."); -} +if (ret != BT_ERROR_NONE) +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_opp_server_initialize_by_connection_request] failed."); free(directory);
                          • @@ -1649,35 +1500,31 @@ free(directory); bt_error_e ret; const char file_name [18] = "tempfile"; -void +void bt_opp_server_transfer_progress_cb_for_opp(const char *file, long long size, int percent, void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "file: %s", file); -   dlog_print(DLOG_INFO, LOG_TAG, "size: %ld", size); -   dlog_print(DLOG_INFO, LOG_TAG, "percent: %d", percent); +    dlog_print(DLOG_INFO, LOG_TAG, "file: %s", file); +    dlog_print(DLOG_INFO, LOG_TAG, "size: %ld", size); +    dlog_print(DLOG_INFO, LOG_TAG, "percent: %d", percent); } -void +void bt_opp_server_transfer_finished_cb_for_opp(int result, const char *file, long long size, void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "result: %d", result); -   dlog_print(DLOG_INFO, LOG_TAG, "file: %s", file); -   dlog_print(DLOG_INFO, LOG_TAG, "size: %ld", size); +    dlog_print(DLOG_INFO, LOG_TAG, "result: %d", result); +    dlog_print(DLOG_INFO, LOG_TAG, "file: %s", file); +    dlog_print(DLOG_INFO, LOG_TAG, "size: %ld", size); } -ret = bt_opp_server_accept(bt_opp_server_transfer_progress_cb_for_opp, -                           bt_opp_server_transfer_finished_cb_for_opp, +ret = bt_opp_server_accept(bt_opp_server_transfer_progress_cb_for_opp, +                           bt_opp_server_transfer_finished_cb_for_opp,                            file_name, NULL, NULL); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_opp_server_accept] failed."); -} +if (ret != BT_ERROR_NONE) +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_opp_server_accept] failed."); ret = bt_opp_server_reject(); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_opp_server_reject] failed."); -} +if (ret != BT_ERROR_NONE) +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_opp_server_reject] failed.");
                        @@ -1690,11 +1537,10 @@ if (ret != BT_ERROR_NONE) bt_error_e ret; ret = bt_opp_client_initialize(); -if (ret != BLUETOOTH_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "bt_opp_client_initialize() failed"); +if (ret != BLUETOOTH_ERROR_NONE) { +    dlog_print(DLOG_ERROR, LOG_TAG, "bt_opp_client_initialize() failed"); -   return -1; +    return -1; } @@ -1711,11 +1557,10 @@ free(resource_path); ret = bt_opp_client_add_file(caller_id_path); -if (ret != BLUETOOTH_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "bt_opp_client_add_file() failed"); +if (ret != BLUETOOTH_ERROR_NONE) { +    dlog_print(DLOG_ERROR, LOG_TAG, "bt_opp_client_add_file() failed"); -   return -1; +    return -1; } @@ -1725,46 +1570,42 @@ if (ret != BLUETOOTH_ERROR_NONE) bt_error_e ret; char remote_addr[18] = REMOTE_DEVICE_MAC_ADDRESS; -void +void __bt_opp_client_push_responded_cb(int result,                                   const char *remote_address,                                   void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "result: %d", result); -   dlog_print(DLOG_INFO, LOG_TAG, "remote_address: %s", remote_address); +    dlog_print(DLOG_INFO, LOG_TAG, "result: %d", result); +    dlog_print(DLOG_INFO, LOG_TAG, "remote_address: %s", remote_address); } -void +void __bt_opp_client_push_progress_cb(const char *file,                                  long long size,                                  int percent,                                  void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "size: %ld", (long)size); -   dlog_print(DLOG_INFO, LOG_TAG, "percent: %d", percent); -   dlog_print(DLOG_INFO, LOG_TAG, "file: %s", file); +    dlog_print(DLOG_INFO, LOG_TAG, "size: %ld", (long)size); +    dlog_print(DLOG_INFO, LOG_TAG, "percent: %d", percent); +    dlog_print(DLOG_INFO, LOG_TAG, "file: %s", file); } -void +void __bt_opp_client_push_finished_cb(int result,                                  const char *remote_address,                                  void *user_data) { -   dlog_print(DLOG_INFO, LOG_TAG, "result: %d", result); -   dlog_print(DLOG_INFO, LOG_TAG, "remote_address: %s", remote_address); +    dlog_print(DLOG_INFO, LOG_TAG, "result: %d", result); +    dlog_print(DLOG_INFO, LOG_TAG, "remote_address: %s", remote_address); } ret = bt_opp_client_push_files(remote_addr, __bt_opp_client_push_responded_cb,                                __bt_opp_client_push_progress_cb,                                __bt_opp_client_push_finished_cb, NULL); -if (ret != BT_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_opp_client_push_files] failed."); -} -else -{ -   dlog_print(DLOG_INFO, LOG_TAG, "[bt_opp_client_push_files] succeeded."); -} +if (ret != BT_ERROR_NONE) +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_opp_client_push_files] failed."); +else +    dlog_print(DLOG_INFO, LOG_TAG, "[bt_opp_client_push_files] succeeded.");
                      4. @@ -1772,22 +1613,20 @@ else
                         bt_error_e ret;
                         
                        -// Delete file info
                        +/* Delete file info */
                         ret = bt_opp_client_clear_files();
                        -if (ret != BLUETOOTH_ERROR_NONE) 
                        -{
                        -   dlog_print(DLOG_ERROR, LOG_TAG, "bt_opp_client_clear_files() failed");
                        +if (ret != BLUETOOTH_ERROR_NONE) {
                        +    dlog_print(DLOG_ERROR, LOG_TAG, "bt_opp_client_clear_files() failed");
                         
                        -   return -1;
                        +    return -1;
                         }
                         
                         ret = bt_opp_client_deinitialize();
                        -if (ret != BLUETOOTH_ERROR_NONE) 
                        -{
                        -   ERR("bt_opp_client_initialize ");
                        -   dlog_print(DLOG_ERROR, LOG_TAG, "bt_opp_client_initialize failed.");
                        +if (ret != BLUETOOTH_ERROR_NONE) {
                        +    ERR("bt_opp_client_initialize ");
                        +    dlog_print(DLOG_ERROR, LOG_TAG, "bt_opp_client_initialize failed.");
                         
                        -   return -1;
                        +    return -1;
                         }
                         
                      5. @@ -1804,31 +1643,29 @@ if (ret != BLUETOOTH_ERROR_NONE)

                        To start the BLE scan:

                        -int 
                        +int
                         main()
                         {
                        -   int ret = BT_ERROR_NONE;
                        -   ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL);
                        +    int ret = BT_ERROR_NONE;
                        +    ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL);
                         
                        -   if (ret != BT_ERROR_NONE) 
                        -   {
                        -      dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_start_scan] failed.");
                        -   }
                        +    if (ret != BT_ERROR_NONE)
                        +        dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_start_scan] failed.");
                         
                        -   // Wait while the system searches for the LE target you want to connect to
                        -   // When you find the LE target you want, stop the LE scan
                        +    /*
                        +       Wait while the system searches for the LE target you want to connect to
                        +       When you find the LE target you want, stop the LE scan
                         
                        -   // bt_adapter_le_start_scan() operates continually until you call bt_adapter_le_stop_scan()
                        -   // If you do not call bt_adapter_le_stop_scan() after calling bt_adapter_le_start_scan(),
                        -   // calling bt_adapter_le_start_scan() again can cause an in-progress error
                        +       bt_adapter_le_start_scan() operates continually until you call bt_adapter_le_stop_scan()
                        +       If you do not call bt_adapter_le_stop_scan() after calling bt_adapter_le_start_scan(),
                        +       calling bt_adapter_le_start_scan() again can cause an in-progress error
                        +    */
                         
                        -   ret = bt_adapter_le_stop_scan();
                        -   if (ret != BT_ERROR_NONE)
                        -   {
                        -      dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_stop_scan] failed.");
                        -   }
                        +    ret = bt_adapter_le_stop_scan();
                        +    if (ret != BT_ERROR_NONE)
                        +        dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_stop_scan] failed.");
                         
                        -   return;
                        +    return;
                         }
                         
                        @@ -1836,125 +1673,96 @@ main()
                      6. Use the callback defined in the bt_adapter_le_start_scan() function to retrieve the scan results. The callback contains information of all the LE scanned devices, such as the device names, scanned devices' transmission level, service data list, appearance of the devices, and manufacture data of the devices.

                        To handle the scan result:

                        -
                        -int ret, i;
                        +
                        +int ret;
                        +int i;
                         
                        -void 
                        +void
                         __bt_adapter_le_scan_result_cb(int result,
                        -                               bt_adapter_le_device_scan_result_info_s *info, 
                        +                               bt_adapter_le_device_scan_result_info_s *info,
                                                        void *user_data)
                         {
                        -   bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING;
                        -
                        -   if (info == NULL) 
                        -   {
                        -      dlog_print(DLOG_INFO, LOG_TAG, "No discovery_info!");
                        -
                        -      return;
                        -   }
                        -
                        -   if (info->adv_data_len > 31 || info->scan_data_len > 31) 
                        -   {
                        -      dlog_print(DLOG_INFO, LOG_TAG, "###################");
                        -      bt_adapter_le_stop_scan();
                        -      dlog_print(DLOG_INFO, LOG_TAG, "###################");
                        -
                        -      return;
                        -   }
                        -
                        -   for (i = 0; i < 2; i++) 
                        -   {
                        -      char **uuids;
                        -      char *device_name;
                        -      int tx_power_level;
                        -      bt_adapter_le_service_data_s *data_list;
                        -      int appearance;
                        -      int manufacturer_id;
                        -      char *manufacturer_data;
                        -      int manufacturer_data_len;
                        -      int count;
                        -
                        -      pkt_type += i;
                        -      if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING && info->adv_data == NULL) continue;
                        -      if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE && info->scan_data == NULL) break;
                        -
                        -      if (bt_adapter_le_get_scan_result_service_uuids(info, pkt_type, &uuids, &count) == BT_ERROR_NONE) 
                        -      {
                        -         int i;
                        -         for (i = 0; i < count; i++) 
                        -         {
                        -            dlog_print(DLOG_INFO, LOG_TAG, "UUID[%d] = %s", i + 1, uuids[i]);
                        -            g_free(uuids[i]);
                        -         }
                        -         g_free(uuids);
                        -      }
                        -      if (bt_adapter_le_get_scan_result_device_name(info, pkt_type, &device_name) == BT_ERROR_NONE) 
                        -      {
                        -         dlog_print(DLOG_INFO, LOG_TAG, "Device name = %s", device_name);
                        -         g_free(device_name);
                        -      }
                        -      if (bt_adapter_le_get_scan_result_tx_power_level(info, pkt_type, &tx_power_level) == BT_ERROR_NONE) 
                        -      {
                        -         dlog_print(DLOG_INFO, LOG_TAG, "TX Power level = %d", tx_power_level);
                        -      }
                        -      if (bt_adapter_le_get_scan_result_service_solicitation_uuids(info, pkt_type, &uuids, &count) == BT_ERROR_NONE) 
                        -      {
                        -         int i;
                        -         for (i = 0; i < count; i++) 
                        -         {
                        -            dlog_print(DLOG_INFO, LOG_TAG, "Solicitation UUID[%d] = %s", i + 1, uuids[i]);
                        -            g_free(uuids[i]);
                        -         }
                        -         g_free(uuids);
                        -      }
                        -      if (bt_adapter_le_get_scan_result_service_data_list(info, pkt_type, &data_list, &count) == BT_ERROR_NONE) 
                        -      {
                        -         int i;
                        -         for (i = 0; i < count; i++)
                        -         dlog_print(DLOG_INFO, LOG_TAG, "Service Data[%d] = [0x%2.2X%2.2X:0x%.2X...]", i + 1, 
                        -                    data_list[i].service_uuid[0], data_list[i].service_uuid[1], data_list[i].service_data[0]);
                        -         bt_adapter_le_free_service_data_list(data_list, count);
                        -      }
                        -      if (bt_adapter_le_get_scan_result_appearance(info, pkt_type, &appearance) == BT_ERROR_NONE) 
                        -      {
                        -         dlog_print(DLOG_INFO, LOG_TAG, "Appearance = %d", appearance);
                        -      }
                        -      if (bt_adapter_le_get_scan_result_manufacturer_data(info, pkt_type, &manufacturer_id, 
                        -                                                          &manufacturer_data, &manufacturer_data_len) == BT_ERROR_NONE) 
                        -      {
                        -         dlog_print(DLOG_INFO, LOG_TAG, "Manufacturer data[ID:%.4X, 0x%.2X%.2X...(len:%d)]", 
                        -                    manufacturer_id, manufacturer_data[0], manufacturer_data[1], manufacturer_data_len);
                        -         g_free(manufacturer_data);
                        -      }
                        -   }
                        +    bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING;
                        +
                        +    if (info == NULL) {
                        +        dlog_print(DLOG_INFO, LOG_TAG, "No discovery_info!");
                        +
                        +        return;
                        +    }
                        +
                        +    if (info->adv_data_len > 31 || info->scan_data_len > 31) {
                        +        dlog_print(DLOG_INFO, LOG_TAG, "###################");
                        +        bt_adapter_le_stop_scan();
                        +        dlog_print(DLOG_INFO, LOG_TAG, "###################");
                        +
                        +        return;
                        +    }
                        +
                        +    for (i = 0; i < 2; i++) {
                        +        char **uuids;
                        +        char *device_name;
                        +        int tx_power_level;
                        +        bt_adapter_le_service_data_s *data_list;
                        +        int appearance;
                        +        int manufacturer_id;
                        +        char *manufacturer_data;
                        +        int manufacturer_data_len;
                        +        int count;
                        +
                        +        pkt_type += i;
                        +        if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING && info->adv_data == NULL)
                        +            continue;
                        +        if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE && info->scan_data == NULL)
                        +            break;
                        +
                        +        if (bt_adapter_le_get_scan_result_service_uuids(info, pkt_type, &uuids, &count) == BT_ERROR_NONE) {
                        +            int i;
                        +            for (i = 0; i < count; i++) {
                        +                dlog_print(DLOG_INFO, LOG_TAG, "UUID[%d] = %s", i + 1, uuids[i]);
                        +                g_free(uuids[i]);
                        +            }
                        +            g_free(uuids);
                        +        }
                        +        if (bt_adapter_le_get_scan_result_device_name(info, pkt_type, &device_name) == BT_ERROR_NONE) {
                        +            dlog_print(DLOG_INFO, LOG_TAG, "Device name = %s", device_name);
                        +            g_free(device_name);
                        +        }
                        +        if (bt_adapter_le_get_scan_result_tx_power_level(info, pkt_type, &tx_power_level) == BT_ERROR_NONE)
                        +            dlog_print(DLOG_INFO, LOG_TAG, "TX Power level = %d", tx_power_level);
                        +        if (bt_adapter_le_get_scan_result_service_solicitation_uuids(info, pkt_type, &uuids, &count) == BT_ERROR_NONE) {
                        +            int i;
                        +            for (i = 0; i < count; i++) {
                        +                dlog_print(DLOG_INFO, LOG_TAG, "Solicitation UUID[%d] = %s", i + 1, uuids[i]);
                        +                g_free(uuids[i]);
                        +            }
                        +            g_free(uuids);
                        +        }
                        +        if (bt_adapter_le_get_scan_result_service_data_list(info, pkt_type, &data_list, &count) == BT_ERROR_NONE) {
                        +            int i;
                        +            for (i = 0; i < count; i++) {
                        +                dlog_print(DLOG_INFO, LOG_TAG, "Service Data[%d] = [0x%2.2X%2.2X:0x%.2X...]", i + 1,
                        +                           data_list[i].service_uuid[0], data_list[i].service_uuid[1], data_list[i].service_data[0]);
                        +            }
                        +            bt_adapter_le_free_service_data_list(data_list, count);
                        +        }
                        +        if (bt_adapter_le_get_scan_result_appearance(info, pkt_type, &appearance) == BT_ERROR_NONE)
                        +            dlog_print(DLOG_INFO, LOG_TAG, "Appearance = %d", appearance);
                        +        if (bt_adapter_le_get_scan_result_manufacturer_data(info, pkt_type, &manufacturer_id,
                        +                                                            &manufacturer_data, &manufacturer_data_len) == BT_ERROR_NONE) {
                        +            dlog_print(DLOG_INFO, LOG_TAG, "Manufacturer data[ID:%.4X, 0x%.2X%.2X...(len:%d)]",
                        +                       manufacturer_id, manufacturer_data[0], manufacturer_data[1], manufacturer_data_len);
                        +            g_free(manufacturer_data);
                        +        }
                        +    }
                         }
                         
                      7. - -
                      8. -

                        To stop the BLE scan operation:

                        -
                        -int 
                        -main()
                        -{
                        -   int ret = BT_ERROR_NONE;
                        -   ret = bt_adapter_le_stop_scan();
                        -
                        -   if (ret != BT_ERROR_NONE)
                        -   {
                        -      dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_stop_scan] failed.");
                        -   }
                        -
                        -   return;
                        -}
                        -
                        -

                      Discovering Bluetooth LE Devices

                      -

                      Perform the LE discovery operation to discover nearby Bluetooth LE devices. You can register and unregister a callback for the LE discovery operation through the set and unset callback functions. The registered device discovery callback provides details of the discovered devices and the state of the discovery (started, finished, found).

                      +

                      Perform the LE discovery operation to discover nearby Bluetooth LE devices. You can register and deregister a callback for the LE discovery operation through the set and unset callback functions. The registered device discovery callback provides details of the discovered devices and the state of the discovery (started, finished, found).

                      @@ -1970,50 +1778,45 @@ main()

                      To start the BLE discovery operation:

                      -static void 
                      -__bt_adapter_le_device_discovery_state_changed_cb(int result, 
                      -                                                  bt_adapter_le_device_discovery_state_e discovery_state, 
                      -                                                  bt_adapter_le_device_discovery_info_s *discovery_info, 
                      -                                                  void *user_data) 
                      +static void
                      +__bt_adapter_le_device_discovery_state_changed_cb(int result,
                      +                                                  bt_adapter_le_device_discovery_state_e discovery_state,
                      +                                                  bt_adapter_le_device_discovery_info_s *discovery_info,
                      +                                                  void *user_data)
                       {
                      -   if (discovery_info == NULL && discovery_state == BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND)
                      -      dlog_print(DLOG_ERROR, LOG_TAG, "No discovery_info!");
                      -
                      -   return;
                      -
                      -   if (discovery_state != BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND) 
                      -   {
                      -      dlog_print(DLOG_INFO, LOG_TAG, "LE discovery %s", 
                      -                 discovery_state == BT_ADAPTER_LE_DEVICE_DISCOVERY_STARTED ? "Started" : "Finished");
                      -   }
                      -   else
                      -   {
                      -      dlog_print(DLOG_INFO, LOG_TAG, "%s Adv %d Scan resp %d RSSI %d Addr_type %d", 
                      -                 discovery_info->remote_address, discovery_info->adv_data_len, discovery_info->scan_data_len, 
                      -                 discovery_info->rssi, discovery_info->address_type);
                      - 
                      -      if (discovery_info->adv_data_len > 31 || discovery_info->scan_data_len > 31)
                      -         bt_adapter_le_stop_device_discovery();
                      -   }
                      -}
                      -
                      -int 
                      +    if (discovery_info == NULL && discovery_state == BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND)
                      +        dlog_print(DLOG_ERROR, LOG_TAG, "No discovery_info!");
                      +
                      +    return;
                      +
                      +    if (discovery_state != BT_ADAPTER_LE_DEVICE_DISCOVERY_FOUND) {
                      +        dlog_print(DLOG_INFO, LOG_TAG, "LE discovery %s",
                      +                   discovery_state == BT_ADAPTER_LE_DEVICE_DISCOVERY_STARTED ? "Started" : "Finished");
                      +    } else {
                      +        dlog_print(DLOG_INFO, LOG_TAG, "%s Adv %d Scan resp %d RSSI %d Addr_type %d",
                      +                   discovery_info->remote_address, discovery_info->adv_data_len, discovery_info->scan_data_len,
                      +                   discovery_info->rssi, discovery_info->address_type);
                      +
                      +        if (discovery_info->adv_data_len > 31 || discovery_info->scan_data_len > 31)
                      +            bt_adapter_le_stop_device_discovery();
                      +    }
                      +}
                      +
                      +int
                       main()
                       {
                      -   int ret = BT_ERROR_NONE;
                      +    int ret = BT_ERROR_NONE;
                       
                      -   ret = bt_adapter_le_set_device_discovery_state_changed_cb(__bt_adapter_le_device_discovery_state_changed_cb, NULL);
                      +    ret = bt_adapter_le_set_device_discovery_state_changed_cb(__bt_adapter_le_device_discovery_state_changed_cb, NULL);
                       
                      -   ret = bt_adapter_le_start_device_discovery();
                      +    ret = bt_adapter_le_start_device_discovery();
                       
                      -   if (ret != BT_ERROR_NONE)
                      -   {
                      -      dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_start_device_discovery] failed.");
                      -   }
                      -   // To unset the LE device discovery state change callback
                      -   ret = bt_adapter_le_unset_device_discovery_state_changed_cb();
                      +    if (ret != BT_ERROR_NONE)
                      +        dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_start_device_discovery] failed.");
                      +    /* To unset the LE device discovery state change callback */
                      +    ret = bt_adapter_le_unset_device_discovery_state_changed_cb();
                       
                      -   return;
                      +    return;
                       }
                       
                      @@ -2042,72 +1845,69 @@ const char *battery_svc_uuid_16 = "180f"; const char *heart_rate_svc_uuid_16 = "180d"; const char *immediate_alert_svc_uuid_16 = "1802"; const char *ancs_uuid_128 = "7905F431-B5CE-4E99-A40F-4B1E122D00D0"; -int appearance = 192; // 192 is a generic watch +int appearance = 192; /* 192 is a generic watch */ advertiser = advertiser_list[advertiser_index]; -if (advertiser == NULL) -{ -   ret = bt_adapter_le_create_advertiser(&advertiser); -   dlog_print(DLOG_INFO, LOG_TAG, "created le advertiser(%d)", ret); -   advertiser_list[advertiser_index] = advertiser; -} -else -{ -   ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING); -   if (ret != BT_ERROR_NONE) -      dlog_print(DLOG_INFO, LOG_TAG, "clear advertising data [0x%04x]", ret); -   ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE); -   if (ret != BT_ERROR_NONE) -      dlog_print(DLOG_INFO, LOG_TAG, "clear scan response data [0x%04x]", ret); +if (advertiser == NULL) { +    ret = bt_adapter_le_create_advertiser(&advertiser); +    dlog_print(DLOG_INFO, LOG_TAG, "created le advertiser(%d)", ret); +    advertiser_list[advertiser_index] = advertiser; +} else { +    ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING); +    if (ret != BT_ERROR_NONE) +        dlog_print(DLOG_INFO, LOG_TAG, "clear advertising data [0x%04x]", ret); +    ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE); +    if (ret != BT_ERROR_NONE) +        dlog_print(DLOG_INFO, LOG_TAG, "clear scan response data [0x%04x]", ret); } ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING,                                                  time_svc_uuid_16); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add service_uuid [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add service_uuid [0x%04x]", ret); ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING,                                                  battery_svc_uuid_16); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add service_uuid [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add service_uuid [0x%04x]", ret); -ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, +ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,                                                               BT_ADAPTER_LE_PACKET_ADVERTISING,                                                               heart_rate_svc_uuid_16); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add service_solicitation_uuid [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add service_solicitation_uuid [0x%04x]", ret); -ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, +ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,                                                               BT_ADAPTER_LE_PACKET_ADVERTISING,                                                               immediate_alert_svc_uuid_16); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add service_solicitation_uuid [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add service_solicitation_uuid [0x%04x]", ret); ret = bt_adapter_le_set_advertising_appearance(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, appearance); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add appearance data [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add appearance data [0x%04x]", ret); ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, true); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add tx_power_level [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add tx_power_level [0x%04x]", ret); manufacture = manufacture_3; -// Default scan response data -ret = bt_adapter_le_add_advertising_service_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, +/* Default scan response data */ +ret = bt_adapter_le_add_advertising_service_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE,                                                  time_svc_uuid_16, service_data, sizeof(service_data)); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add service_data [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add service_data [0x%04x]", ret); ret = bt_adapter_le_set_advertising_device_name(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "set device name [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "set device name [0x%04x]", ret); -ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, +ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE,                                                       manufacturer_id, manufacture, sizeof(manufacture_0)); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add manufacturer data [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add manufacturer data [0x%04x]", ret);
                    • @@ -2115,11 +1915,9 @@ if (ret != BT_ERROR_NONE)
                       int ret = BT_ERROR_NONE;
                       ret = bt_adapter_le_destroy_advertiser(advertiser);
                      - 
                      +
                       if (ret != BT_ERROR_NONE)
                      -{
                      -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_destroy_advertiser] failed.");
                      -}
                      +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_adapter_le_destroy_advertiser] failed.");
                       
                       return;
                       
                      @@ -2138,16 +1936,15 @@ int type = BT_ADAPTER_LE_ADVERTISING_CONNECTABLE; advertiser = advertiser_list[advertiser_index]; -if (advertiser == NULL) -{ -   ret = bt_adapter_le_create_advertiser(&advertiser); -   dlog_print(DLOG_INFO, LOG_TAG, "created le advertiser(%d)", ret); -   advertiser_list[advertiser_index] = advertiser; +if (advertiser == NULL) { +    ret = bt_adapter_le_create_advertiser(&advertiser); +    dlog_print(DLOG_INFO, LOG_TAG, "created le advertiser(%d)", ret); +    advertiser_list[advertiser_index] = advertiser; } ret = bt_adapter_le_set_advertising_connectable(advertiser, type); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add scan response data [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add scan response data [0x%04x]", ret);

                      Setting the LE Advertising Mode

                      @@ -2166,16 +1963,15 @@ int mode = BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED; advertiser = advertiser_list[advertiser_index]; -if (advertiser == NULL) -{ -   ret = bt_adapter_le_create_advertiser(&advertiser); -   dlog_print(DLOG_INFO, LOG_TAG, "created le advertiser(%d)", ret); -   advertiser_list[advertiser_index] = advertiser; +if (advertiser == NULL) { +    ret = bt_adapter_le_create_advertiser(&advertiser); +    dlog_print(DLOG_INFO, LOG_TAG, "created le advertiser(%d)", ret); +    advertiser_list[advertiser_index] = advertiser; } ret = bt_adapter_le_set_advertising_mode(advertiser, mode); if (ret != BT_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "add scan response data [0x%04x]", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "add scan response data [0x%04x]", ret);

                      Starting and Stopping LE Advertising

                      @@ -2185,70 +1981,71 @@ if (ret != BT_ERROR_NONE)

                      To start advertising with the given advertiser and advertising parameters information, use the bt_adapter_le_start_advertising_new() function:

                      -static void 
                      -__bt_adapter_le_advertising_state_changed_cb(int result, bt_advertiser_h advertiser, 
                      -                                             bt_adapter_le_advertising_state_e adv_state, 
                      +static void
                      +__bt_adapter_le_advertising_state_changed_cb(int result, bt_advertiser_h advertiser,
                      +                                             bt_adapter_le_advertising_state_e adv_state,
                                                                    void *user_data)
                       {
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result);
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Advertiser: %p", advertiser);
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Advertising %s [%d]", 
                      -              adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? "started" : "stopped", adv_state);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Advertiser: %p", advertiser);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Advertising %s [%d]",
                      +               adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? "started" : "stopped", adv_state);
                       }
                       
                      -static void 
                      -__bt_adapter_le_advertising_state_changed_cb_2(int result, bt_advertiser_h advertiser, 
                      -                                               bt_adapter_le_advertising_state_e adv_state, 
                      +static void
                      +__bt_adapter_le_advertising_state_changed_cb_2(int result, bt_advertiser_h advertiser,
                      +                                               bt_adapter_le_advertising_state_e adv_state,
                                                                      void *user_data)
                       {
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result);
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Advertiser: %p", advertiser);
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Advertising %s [%d]", 
                      -              adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? "started" : "stopped", adv_state);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Advertiser: %p", advertiser);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Advertising %s [%d]",
                      +               adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? "started" : "stopped", adv_state);
                       }
                       
                      -static void 
                      -__bt_adapter_le_advertising_state_changed_cb_3(int result, bt_advertiser_h advertiser, 
                      -                                               bt_adapter_le_advertising_state_e adv_state, 
                      +static void
                      +__bt_adapter_le_advertising_state_changed_cb_3(int result, bt_advertiser_h advertiser,
                      +                                               bt_adapter_le_advertising_state_e adv_state,
                                                                      void *user_data)
                       {
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result);
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Advertiser: %p", advertiser);
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Advertising %s [%d]", 
                      -              adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? "started" : "stopped", adv_state);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Advertiser: %p", advertiser);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Advertising %s [%d]",
                      +               adv_state == BT_ADAPTER_LE_ADVERTISING_STARTED ? "started" : "stopped", adv_state);
                       }
                       
                       bt_adapter_le_advertising_state_changed_cb cb;
                       
                      -if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb;
                      -else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2;
                      -else cb = __bt_adapter_le_advertising_state_changed_cb_3;
                      +if (advertiser_index == 0)
                      +    cb = __bt_adapter_le_advertising_state_changed_cb;
                      +else if
                      +    (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2;
                      +else
                      +    cb = __bt_adapter_le_advertising_state_changed_cb_3;
                       
                       advertiser = advertiser_list[advertiser_index];
                       advertiser_index++;
                       advertiser_index %= 3;
                       
                      -if (advertiser == NULL) 
                      -{
                      -   ret = bt_adapter_le_create_advertiser(&advertiser);
                      -   dlog_print(DLOG_INFO, LOG_TAG, "created le advertiser(%d)", ret);
                      -   advertiser_list[advertiser_index] = advertiser;
                      +if (advertiser == NULL) {
                      +    ret = bt_adapter_le_create_advertiser(&advertiser);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "created le advertiser(%d)", ret);
                      +    advertiser_list[advertiser_index] = advertiser;
                       }
                       
                       ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL);
                       if (ret < BT_ERROR_NONE)
                      -   dlog_print(DLOG_INFO, LOG_TAG, "failed with [0x%04x]", ret);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "failed with [0x%04x]", ret);
                       
                    • To stop advertising with the given advertiser, use the bt_adapter_le_stop_advertising() function:

                      -if (advertiser != NULL)
                      -{
                      -   ret = bt_adapter_le_stop_advertising(advertiser);
                      -   if (ret < BT_ERROR_NONE)
                      -      dlog_print(DLOG_INFO, LOG_TAG, "failed with [0x%04x]", ret);
                      +if (advertiser != NULL) {
                      +    ret = bt_adapter_le_stop_advertising(advertiser);
                      +    if (ret < BT_ERROR_NONE)
                      +        dlog_print(DLOG_INFO, LOG_TAG, "failed with [0x%04x]", ret);
                       }
                       
                    • @@ -2258,21 +2055,20 @@ if (advertiser != NULL)

                      To release all Bluetooth resources, call the bt_deinitialize() function:

                      -// Unregister callbacks
                      +/* Deregister callbacks */
                       bt_adapter_unset_state_changed_cb();
                       bt_adapter_unset_device_discovery_state_changed_cb();
                       bt_device_unset_service_searched_cb();
                       bt_socket_unset_data_received_cb();
                       bt_socket_unset_connection_state_changed_cb();
                      - 
                      -// Release resources
                       
                      -// Deinitialize Bluetooth
                      +/* Release resources */
                      +
                      +/* Deinitialize Bluetooth */
                       ret = bt_deinitialize();
                      -if (ret != BT_ERROR_NONE) 
                      -{
                      -   dlog_print(DLOG_ERROR, LOG_TAG, "[bt_deinitialize] failed.");
                      -}
                      +if (ret != BT_ERROR_NONE) +    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_deinitialize] failed."); + diff --git a/org.tizen.tutorials/html/native/network/connection_tutorial_n.htm b/org.tizen.tutorials/html/native/network/connection_tutorial_n.htm index 65b447a..90c7f6b 100644 --- a/org.tizen.tutorials/html/native/network/connection_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/network/connection_tutorial_n.htm @@ -23,7 +23,7 @@

                      Content

                      - -

                      Prerequisites

                      -

                      To use connection APIs, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file.
                      You can modify it for your own needs

                      -
                      - <privileges>
                      -    <privilege>http://tizen.org/privilege/network.get</privilege>
                      -    <privilege>http://tizen.org/privilege/network.set</privilege>
                      -    <privilege>http://tizen.org/privilege/network.profile</privilege>
                      - </privileges> 
                      + +

                      Prerequisites

                      + +

                      To use the Connection API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

                      +
                      +<privileges>
                      +   <privilege>http://tizen.org/privilege/network.get</privilege>
                      +   <privilege>http://tizen.org/privilege/network.set</privilege>
                      +   <privilege>http://tizen.org/privilege/network.profile</privilege>
                      +</privileges>
                      +

                      Initializing Connections

                      @@ -114,7 +117,8 @@ int error_code; error_code = connection_create(&connection); if (error_code != CONNECTION_ERROR_NONE) -   return; +    return; +
                    • When no longer needed, destroy the created connection handle:

                      @@ -135,19 +139,17 @@ int error_code; connection_type_e net_state; error_code = connection_get_type(connection, &net_state); if (error_code == CONNECTION_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "Network connection type : %d", net_state); -} +    dlog_print(DLOG_INFO, LOG_TAG, "Network connection type : %d", net_state);

                      To monitor changes in the connection type, register and define a callback:

                       connection_set_type_changed_cb(connection, __connection_changed_cb, NULL);
                       
                      -static void 
                      +static void
                       __connection_changed_cb(connection_type_e type, void* user_data)
                       {
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Type changed callback, connection type : %d", type);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Type changed callback, connection type : %d", type);
                       }
                       
                    • @@ -157,10 +159,9 @@ __connection_changed_cb(connection_type_e type, void* user_data)
                       char *ip_addr = NULL;
                       error_code = connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
                      -if (error_code == CONNECTION_ERROR_NONE)
                      -{
                      -   dlog_print(DLOG_INFO, LOG_TAG, "IP address : %s", ip_addr);
                      -   free(ip_addr);
                      +if (error_code == CONNECTION_ERROR_NONE) {
                      +    dlog_print(DLOG_INFO, LOG_TAG, "IP address : %s", ip_addr);
                      +    free(ip_addr);
                       }
                       
                      @@ -169,10 +170,9 @@ if (error_code == CONNECTION_ERROR_NONE)
                       error_code = connection_get_proxy(connection, address_family, &proxy_addr);
                      -if (error_code == CONNECTION_ERROR_NONE) 
                      -{
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Proxy address : %s", proxy_addr);
                      -   free(proxy_addr); 
                      +if (error_code == CONNECTION_ERROR_NONE) {
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Proxy address : %s", proxy_addr);
                      +    free(proxy_addr);
                       }
                       
                      @@ -187,29 +187,28 @@ if (error_code == CONNECTION_ERROR_NONE)
                       connection_cellular_state_e cellular_state;
                       connection_get_cellular_state(connection, &cellular_state);
                      -switch (cellular_state) 
                      -{
                      -   case CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE: 
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Out of service"); 
                      -      break;
                      -   case CONNECTION_CELLULAR_STATE_FLIGHT_MODE: 
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Flight mode");   
                      -      break;
                      -   case CONNECTION_CELLULAR_STATE_ROAMING_OFF: 
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Roaming is turned off"); 
                      -      break;
                      -   case CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE: 
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Call only"); 
                      -      break;
                      -   case CONNECTION_CELLULAR_STATE_AVAILABLE: 
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Available"); 
                      -      break;
                      -   case CONNECTION_CELLULAR_STATE_CONNECTED: 
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Connected"); 
                      -      break;
                      -   default: 
                      -      dlog_print(DLOG_INFO, LOG_TAG, "error");
                      -      break;
                      +switch (cellular_state) {
                      +case CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Out of service");
                      +    break;
                      +case CONNECTION_CELLULAR_STATE_FLIGHT_MODE:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Flight mode");
                      +    break;
                      +case CONNECTION_CELLULAR_STATE_ROAMING_OFF:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Roaming is turned off");
                      +    break;
                      +case CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Call only");
                      +    break;
                      +case CONNECTION_CELLULAR_STATE_AVAILABLE:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Available");
                      +    break;
                      +case CONNECTION_CELLULAR_STATE_CONNECTED:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Connected");
                      +    break;
                      +default:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "error");
                      +    break;
                       }
                       
                      @@ -220,20 +219,19 @@ switch (cellular_state)
                       connection_wifi_state_e wifi_state;
                       connection_get_wifi_state(connection, &wifi_state);
                      -switch (wifi_state) 
                      -{
                      -   case CONNECTION_WIFI_STATE_DEACTIVATED:
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Deactivated state");
                      -      break;
                      -   case CONNECTION_WIFI_STATE_DISCONNECTED:
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Disconnected state");
                      -      break;
                      -   case CONNECTION_WIFI_STATE_CONNECTED:
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Connected state");
                      -      break;
                      -   default:
                      -      dlog_print(DLOG_INFO, LOG_TAG, "error"); 
                      -      break;
                      +switch (wifi_state) {
                      +case CONNECTION_WIFI_STATE_DEACTIVATED:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Deactivated state");
                      +    break;
                      +case CONNECTION_WIFI_STATE_DISCONNECTED:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Disconnected state");
                      +    break;
                      +case CONNECTION_WIFI_STATE_CONNECTED:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Connected state");
                      +    break;
                      +default:
                      +    dlog_print(DLOG_INFO, LOG_TAG, "error");
                      +    break;
                       }
                       
                      @@ -249,48 +247,48 @@ switch (wifi_state)
                       long long last_received_size;
                      -error_code = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, 
                      -                                       CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, 
                      +error_code = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR,
                      +                                       CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA,
                                                              &last_received_size);
                      -// Handle statistics
                      - 
                      +/* Handle statistics */
                      +
                       long long last_sent_size;
                      -error_code = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, 
                      -                                       CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, 
                      +error_code = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR,
                      +                                       CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA,
                                                              &last_sent_size);
                      -// Handle statistics
                      - 
                      +/* Handle statistics */
                      +
                       long long total_received_size;
                      -error_code = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, 
                      -                                       CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, 
                      +error_code = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR,
                      +                                       CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA,
                                                              &total_received_size);
                      -// Handle statistics
                      - 
                      +/* Handle statistics */
                      +
                       long long total_sent_size;
                      -error_code = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, 
                      -                                       CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, 
                      +error_code = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR,
                      +                                       CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA,
                                                              &total_sent_size);
                      -// Handle statistics
                      - 
                      -error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, 
                      -                                       CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, 
                      +/* Handle statistics */
                      +
                      +error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI,
                      +                                       CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA,
                                                              &last_received_size);
                      -// Handle statistics
                      - 
                      -error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, 
                      -                                       CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, 
                      +/* Handle statistics */
                      +
                      +error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI,
                      +                                       CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA,
                                                              &last_sent_size);
                      -// Handle statistics
                      - 
                      -error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, 
                      -                                       CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, 
                      +/* Handle statistics */
                      +
                      +error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI,
                      +                                       CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA,
                                                              &total_received_size);
                      -// Handle statistics
                      - 
                      -error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, 
                      -                                       CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, 
                      +/* Handle statistics */
                      +
                      +error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI,
                      +                                       CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA,
                                                              &total_sent_size);
                      -// Handle statistics
                      +/* Handle statistics */
                       

                      Registering Property Change Callbacks

                      @@ -302,18 +300,18 @@ error_code = connection_get_statistics(connection, CONNECTION_TYPE_WIFI,

                      In this use case, the registered callbacks are the __ip_changed_cb() and __proxy_changed_cb() functions, used for address changes. When an address changes, an information message is printed in the file (or shown to the user in another way). The message contains information on which address has been changed and what the new value is.

                      -static void 
                      -__ip_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data) 
                      +static void
                      +__ip_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data)
                       {
                      -   dlog_print(DLOG_INFO, LOG_TAG, "%s callback, IPv4 address : %s, IPv6 address : %s", 
                      -              (char *)user_data, ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
                      +    dlog_print(DLOG_INFO, LOG_TAG, "%s callback, IPv4 address : %s, IPv6 address : %s",
                      +               (char *)user_data, ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
                       }
                      - 
                      -static void 
                      -__proxy_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data) 
                      +
                      +static void
                      +__proxy_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data)
                       {
                      -   dlog_print(DLOG_INFO, LOG_TAG, "%s callback, IPv4 address : %s, IPv6 address : %s", 
                      -              (char *)user_data, ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
                      +    dlog_print(DLOG_INFO, LOG_TAG, "%s callback, IPv4 address : %s, IPv6 address : %s",
                      +               (char *)user_data, ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
                       }
                       
                      @@ -323,33 +321,25 @@ __proxy_changed_cb(const char* ipv4_address, const char* ipv6_address, void* use
                       error_code = connection_set_ip_address_changed_cb(connection, __ip_changed_cb, "IP addr changed:");
                      -if (error_code != CONNECTION_ERROR_NONE) 
                      -{
                      -   // Error handling
                      -}
                      +if (error_code != CONNECTION_ERROR_NONE)
                      +    /* Error handling */
                       error_code = connection_set_proxy_address_changed_cb(connection, __proxy_changed_cb, "Proxy IP addr changed:");
                      -if (error_code != CONNECTION_ERROR_NONE) 
                      -{
                      -   // Error handling
                      -}
                      +if (error_code != CONNECTION_ERROR_NONE)
                      +    /* Error handling */
                       
                      -
                    • Unregister the callback functions. +
                    • Deregister the callback functions. -

                      When the callbacks are no longer needed, unregister them with the applicable unset functions:

                      +

                      When the callbacks are no longer needed, deregister them with the applicable unset functions:

                       error_code = connection_unset_ip_address_changed_cb(connection);
                      -if (error_code != CONNECTION_ERROR_NONE) 
                      -{
                      -   // Error handling
                      -}
                      -  
                      +if (error_code != CONNECTION_ERROR_NONE)
                      +    /* Error handling */
                      +
                       error_code = connection_unset_proxy_address_changed_cb(connection);
                      -if (error_code != CONNECTION_ERROR_NONE) 
                      -{
                      -   // Error handling
                      -}
                      +if (error_code != CONNECTION_ERROR_NONE)
                      +    /* Error handling */
                       
                    • Initializing a Socket

                      @@ -367,78 +357,73 @@ if (error_code != CONNECTION_ERROR_NONE)
                    • Declare the necessary variables:
                      -int 
                      +int
                       main(int argc, char **argv)
                       {
                      -   int rv = 0;
                      -   int ip_type = -1;
                      -   char user_url[100] = {0,};
                      -   char user_port[10] = {0,};
                      -   char user_msg[200] = {0,};
                      -   char *local_ipv4 = NULL;
                      -   char *local_ipv6 = NULL;
                      -   char *interface_name = NULL;
                      -
                      -   connection_type_e net_state;
                      -   connection_h connection = NULL;
                      -   connection_profile_h profile_h = NULL;
                      +    int rv = 0;
                      +    int ip_type = -1;
                      +    char user_url[100] = {0,};
                      +    char user_port[10] = {0,};
                      +    char user_msg[200] = {0,};
                      +    char *local_ipv4 = NULL;
                      +    char *local_ipv6 = NULL;
                      +    char *interface_name = NULL;
                      +
                      +    connection_type_e net_state;
                      +    connection_h connection = NULL;
                      +    connection_profile_h profile_h = NULL;
                       
                    • Include the required header file and create a connection handle.
                    • Check whether the default connection is available:
                      -   connection_type_e net_state;
                      +    connection_type_e net_state;
                       
                      -   rv = connection_get_type(connection, &net_state);
                      -   if (rv != CONNECTION_ERROR_NONE || net_state == CONNECTION_TYPE_DISCONNECTED) 
                      -   {
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Not connected %d\n", rv);
                      -      connection_destroy(connection);
                      +    rv = connection_get_type(connection, &net_state);
                      +    if (rv != CONNECTION_ERROR_NONE || net_state == CONNECTION_TYPE_DISCONNECTED) {
                      +        dlog_print(DLOG_INFO, LOG_TAG, "Not connected %d\n", rv);
                      +        connection_destroy(connection);
                       
                      -      return -1;
                      -   }
                      +        return -1;
                      +    }
                       
                    • -
                    • Check the address type of the default connection. +
                    • Check the address type of the default connection.

                      The address type can be IPv4 or IPv6.

                      -   int ip_type = -1;
                      -   char *local_ipv4 = NULL;
                      -   char *local_ipv6 = NULL;
                      -   connection_profile_h profile_h = NULL;
                      -
                      -   rv = connection_get_current_profile(connection, &profile_h);
                      -   if (rv != CONNECTION_ERROR_NONE) 
                      -   {
                      -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to get profile handle %d\n", rv);
                      -      connection_destroy(connection);
                      -
                      -      return -1;
                      -   }
                      -
                      -   rv = connection_profile_get_ip_address(profile_h, CONNECTION_ADDRESS_FAMILY_IPV6, &local_ipv6);
                      -   if (rv == CONNECTION_ERROR_NONE && g_strcmp0(local_ipv6, "::") != 0) 
                      -   {
                      -      ip_type = CONNECTION_ADDRESS_FAMILY_IPV6;
                      -      dlog_print(DLOG_INFO, LOG_TAG, "IPv6 address : %s\n", local_ipv6);
                      -   }
                      -
                      -   // If both IPv4 and IPv6 types are set, the IPv4 type is used as default here
                      -   rv = connection_profile_get_ip_address(profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &local_ipv4);
                      -   if (rv == CONNECTION_ERROR_NONE && g_strcmp0(local_ipv4, &0.0.0.0&) != 0) 
                      -   {
                      -      ip_type = CONNECTION_ADDRESS_FAMILY_IPV4;
                      -      dlog_print(DLOG_INFO, LOG_TAG, "IPv4 address : %s\n", local_ipv4);
                      -   }
                      -
                      -   if (ip_type != CONNECTION_ADDRESS_FAMILY_IPV6 && ip_type != CONNECTION_ADDRESS_FAMILY_IPV4) 
                      -   {
                      -      dlog_print(DLOG_INFO, LOG_TAG, "No IP address!\n");
                      -      // Error handling
                      -   }
                      -
                      -   connection_profile_get_network_interface_name(profile_h, &interface_name);
                      -   dlog_print(DLOG_INFO, LOG_TAG, "Interface Name: %s\n", interface_name);
                      +    int ip_type = -1;
                      +    char *local_ipv4 = NULL;
                      +    char *local_ipv6 = NULL;
                      +    connection_profile_h profile_h = NULL;
                      +
                      +    rv = connection_get_current_profile(connection, &profile_h);
                      +    if (rv != CONNECTION_ERROR_NONE) {
                      +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to get profile handle %d\n", rv);
                      +        connection_destroy(connection);
                      +
                      +        return -1;
                      +    }
                      +
                      +    rv = connection_profile_get_ip_address(profile_h, CONNECTION_ADDRESS_FAMILY_IPV6, &local_ipv6);
                      +    if (rv == CONNECTION_ERROR_NONE && g_strcmp0(local_ipv6, "::") != 0) {
                      +        ip_type = CONNECTION_ADDRESS_FAMILY_IPV6;
                      +        dlog_print(DLOG_INFO, LOG_TAG, "IPv6 address : %s\n", local_ipv6);
                      +    }
                      +
                      +    /* If both IPv4 and IPv6 types are set, the IPv4 type is used as default here */
                      +    rv = connection_profile_get_ip_address(profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &local_ipv4);
                      +    if (rv == CONNECTION_ERROR_NONE && g_strcmp0(local_ipv4, &0.0.0.0&) != 0) {
                      +        ip_type = CONNECTION_ADDRESS_FAMILY_IPV4;
                      +        dlog_print(DLOG_INFO, LOG_TAG, "IPv4 address : %s\n", local_ipv4);
                      +    }
                      +
                      +    if (ip_type != CONNECTION_ADDRESS_FAMILY_IPV6 && ip_type != CONNECTION_ADDRESS_FAMILY_IPV4) {
                      +        dlog_print(DLOG_INFO, LOG_TAG, "No IP address!\n");
                      +        /* Error handling */
                      +    }
                      +
                      +    connection_profile_get_network_interface_name(profile_h, &interface_name);
                      +    dlog_print(DLOG_INFO, LOG_TAG, "Interface Name: %s\n", interface_name);
                       }
                       
                    • @@ -452,23 +437,22 @@ main(int argc, char **argv)
                    • Retrieve the IP addresses:
                       {
                      -   struct sockaddr_in6 *addr6;
                      -   struct addrinfo hints;
                      -   struct addrinfo *result;
                      -   char user_url[100] = {0,};
                      -   char user_port[10] = {0,};
                      -
                      -   memset(&hints, 0x00, sizeof(struct addrinfo));
                      -
                      -   hints.ai_family = PF_UNSPEC;
                      -   hints.ai_socktype = SOCK_STREAM;
                      -   hints.ai_protocol = IPPROTO_TCP;
                      -
                      -   if (getaddrinfo(user_url, user_port, &hints, &result) != 0) 
                      -   {
                      -      dlog_print(DLOG_INFO, LOG_TAG, "getaddrinfo() error\n");
                      -      // Error handling
                      -   }
                      +    struct sockaddr_in6 *addr6;
                      +    struct addrinfo hints;
                      +    struct addrinfo *result;
                      +    char user_url[100] = {0,};
                      +    char user_port[10] = {0,};
                      +
                      +    memset(&hints, 0x00, sizeof(struct addrinfo));
                      +
                      +    hints.ai_family = PF_UNSPEC;
                      +    hints.ai_socktype = SOCK_STREAM;
                      +    hints.ai_protocol = IPPROTO_TCP;
                      +
                      +    if (getaddrinfo(user_url, user_port, &hints, &result) != 0) {
                      +        dlog_print(DLOG_INFO, LOG_TAG, "getaddrinfo() error\n");
                      +        /* Error handling */
                      +    }
                       }
                       
                    • @@ -479,7 +463,8 @@ main(int argc, char **argv)

                      To get the hostname IP addresses to connect:

                       struct addrinfo hints;
                      -struct addrinfo *result, *rp;
                      +struct addrinfo *result;
                      +struct addrinfo *rp;
                       
                       char buf[257];
                       int sockfd = -1;
                      @@ -493,10 +478,9 @@ hints.ai_flags = AI_PASSIVE;
                       hints.ai_family = PF_UNSPEC;
                       hints.ai_socktype = SOCK_STREAM;
                       
                      -if (getaddrinfo(default_ip, argv[1], &hints, &result) != 0) 
                      -{
                      -   printf("getaddrinfo() error\n");
                      -   goto done;
                      +if (getaddrinfo(default_ip, argv[1], &hints, &result) != 0) {
                      +    printf("getaddrinfo() error\n");
                      +    goto done;
                       }
                       
                      @@ -511,27 +495,20 @@ struct addrinfo *rp; rp = result; -for (rp = result; rp != NULL; rp = rp->ai_next) -{ -   if (rp->ai_family == AF_INET && ip_type == CONNECTION_ADDRESS_FAMILY_IPV4) -   { -      if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) -      { -         dlog_print(DLOG_INFO, LOG_TAG, "socket error\n"); -         freeaddrinfo(result); -      } -      dlog_print(DLOG_INFO, LOG_TAG, "IPv4\n"); - -   } -   else if (rp->ai_family == AF_INET6 && ip_type == CONNECTION_ADDRESS_FAMILY_IPV6) -   { -      if ((sockfd = socket(AF_INET6, SOCK_STREAM, 0)) < 0) -      { -         dlog_print(DLOG_INFO, LOG_TAG, "socket error\n"); -         freeaddrinfo(result); -      } -      dlog_print(DLOG_INFO, LOG_TAG, "IPv6\n"); -   } +for (rp = result; rp != NULL; rp = rp->ai_next) { +    if (rp->ai_family == AF_INET && ip_type == CONNECTION_ADDRESS_FAMILY_IPV4) { +        if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { +            dlog_print(DLOG_INFO, LOG_TAG, "socket error\n"); +            freeaddrinfo(result); +        } +        dlog_print(DLOG_INFO, LOG_TAG, "IPv4\n"); +    } else if (rp->ai_family == AF_INET6 && ip_type == CONNECTION_ADDRESS_FAMILY_IPV6) { +        if ((sockfd = socket(AF_INET6, SOCK_STREAM, 0)) < 0) { +            dlog_print(DLOG_INFO, LOG_TAG, "socket error\n"); +            freeaddrinfo(result); +        } +        dlog_print(DLOG_INFO, LOG_TAG, "IPv6\n"); +    } } @@ -539,11 +516,10 @@ for (rp = result; rp != NULL; rp = rp->ai_next)
                      • Use the IPv4 socket:
                        -if (connect(sockfd, rp->ai_addr, rp->ai_addrlen) < 0) 
                        -{
                        -   dlog_print(DLOG_INFO, LOG_TAG, "connect() error: %s\n", strerror(errno));
                        -   freeaddrinfo(result);
                        -   close(sockfd);
                        +if (connect(sockfd, rp->ai_addr, rp->ai_addrlen) < 0) {
                        +    dlog_print(DLOG_INFO, LOG_TAG, "connect() error: %s\n", strerror(errno));
                        +    freeaddrinfo(result);
                        +    close(sockfd);
                         }
                         
                      • @@ -558,11 +534,10 @@ dlog_print(DLOG_INFO, LOG_TAG, "Interface Name: %s\n", interface_name) addr6 = (struct sockaddr_in6 *)rp->ai_addr; addr6->sin6_scope_id = if_nametoindex(interface_name); -if ((sockfd = connect(sockfd, (struct sockaddr *)addr6, rp->ai_addrlen)) < 0) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "connect() error: %s\n", strerror(errno)); -   freeaddrinfo(result); -   close(sockfd); +if ((sockfd = connect(sockfd, (struct sockaddr *)addr6, rp->ai_addrlen)) < 0) { +    dlog_print(DLOG_INFO, LOG_TAG, "connect() error: %s\n", strerror(errno)); +    freeaddrinfo(result); +    close(sockfd); } @@ -571,12 +546,11 @@ if ((sockfd = connect(sockfd, (struct sockaddr *)addr6, rp->ai_addrlen)) <
                      • Manage messages:
                        • Send a message to the remote host:
                          -if ((count = write(sockfd, user_msg, 200)) < 0) 
                          -{
                          -   dlog_print(DLOG_INFO, LOG_TAG, "write() error: %s\n", strerror(errno));
                          +if ((count = write(sockfd, user_msg, 200)) < 0) {
                          +    dlog_print(DLOG_INFO, LOG_TAG, "write() error: %s\n", strerror(errno));
                           
                          -   freeaddrinfo(result);
                          -   close(sockfd);
                          +    freeaddrinfo(result);
                          +    close(sockfd);
                           }
                           dlog_print(DLOG_INFO, LOG_TAG, "Sent count: %d, msg: %s\n", count, user_msg);
                           
                          @@ -586,12 +560,11 @@ dlog_print(DLOG_INFO, LOG_TAG, "Sent count: %d, msg: %s\n", count, use char buf[257]; memset(buf, 0x00, 257); -if ((count = read(sockfd, buf, 256)) < 0) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "read() error: %s\n", strerror(errno)); +if ((count = read(sockfd, buf, 256)) < 0) { +    dlog_print(DLOG_INFO, LOG_TAG, "read() error: %s\n", strerror(errno)); -   freeaddrinfo(result); -   close(sockfd); +    freeaddrinfo(result); +    close(sockfd); } buf[count] = '\0'; dlog_print(DLOG_INFO, LOG_TAG, "\nRead: %s\n", buf); @@ -609,57 +582,49 @@ struct addrinfo *rp; rp = result; -for (rp = result; rp != NULL; rp = rp->ai_next) -{ -   if (rp->ai_family == AF_INET && -       ip_type == CONNECTION_ADDRESS_FAMILY_IPV4) -   { -      if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) -      { -         printf("socket error\n"); -         freeaddrinfo(result); -         goto done; -      } -      printf("IPv4\n"); -   } -   else if (rp->ai_family == AF_INET6 && -            ip_type == CONNECTION_ADDRESS_FAMILY_IPV6) -   { -      if ((sockfd = socket(AF_INET6, SOCK_STREAM, 0)) < 0) -      { -         printf("socket error\n"); -         freeaddrinfo(result); -         goto done; -      } -      printf("IPv6\n"); -   } +for (rp = result; rp != NULL; rp = rp->ai_next) { +    if (rp->ai_family == AF_INET && +        ip_type == CONNECTION_ADDRESS_FAMILY_IPV4) { +        if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { +            printf("socket error\n"); +            freeaddrinfo(result); +            goto done; +        } +        printf("IPv4\n"); +    } else if (rp->ai_family == AF_INET6 && +             ip_type == CONNECTION_ADDRESS_FAMILY_IPV6) { +        if ((sockfd = socket(AF_INET6, SOCK_STREAM, 0)) < 0) { +            printf("socket error\n"); +            freeaddrinfo(result); +            goto done; +        } +        printf("IPv6\n"); +    } }
                        • Bind the found address:
                          -if (bind(sockfd, rp->ai_addr, rp->ai_addrlen) != 0) 
                          -{ 
                          -   printf("bind() error: %s\n", strerror(errno));
                          +if (bind(sockfd, rp->ai_addr, rp->ai_addrlen) != 0) {
                          +    printf("bind() error: %s\n", strerror(errno));
                           
                          -   freeaddrinfo(result);
                          -   close(sockfd);
                          +    freeaddrinfo(result);
                          +    close(sockfd);
                           
                          -   goto done;
                          +    goto done;
                           }
                           
                        • Listen for client-side connections.

                          Mark the sockfd socket as a passive socket.

                          -if (listen(sockfd, 5) != 0) 
                          -{ 
                          -   printf("listen() error: %s\n", strerror(errno));
                          +if (listen(sockfd, 5) != 0) {
                          +    printf("listen() error: %s\n", strerror(errno));
                           
                          -   freeaddrinfo(result);
                          -   close(sockfd);
                          +    freeaddrinfo(result);
                          +    close(sockfd);
                           
                          -   goto done;
                          +    goto done;
                           }
                           
                        • @@ -670,14 +635,13 @@ if (listen(sockfd, 5) != 0) char buf[257]; memset(buf, 0x00, 257); -if ((count = read(csockfd, buf, 256)) < 0) -{ -   printf("read() error: %s\n", strerror(errno)); +if ((count = read(csockfd, buf, 256)) < 0) { +    printf("read() error: %s\n", strerror(errno)); -   freeaddrinfo(result); -   close(sockfd); -   close(csockfd); -   goto done; +    freeaddrinfo(result); +    close(sockfd); +    close(csockfd); +    goto done; } buf[count] = '\0'; printf("\nRead: %s\n", buf); @@ -685,15 +649,14 @@ printf("\nRead: %s\n", buf);
                        • Echo the received message back to the client:
                          -if ((count = write(csockfd, buf, 256)) < 0) 
                          -{
                          -   printf("write() error: %s\n", strerror(errno));
                          -	
                          -   freeaddrinfo(result);
                          -   close(sockfd);
                          -   close(csockfd);
                          +if ((count = write(csockfd, buf, 256)) < 0) {
                          +    printf("write() error: %s\n", strerror(errno));
                          +
                          +    freeaddrinfo(result);
                          +    close(sockfd);
                          +    close(csockfd);
                           
                          -   goto done;
                          +    goto done;
                           }
                           
                           printf("sent count: %d, msg: %s\n", count, buf);
                          @@ -710,14 +673,14 @@ freeaddrinfo(result);
                           close(sockfd);
                           
                           done:
                          -   connection_profile_destroy(profile_h);
                          -   connection_destroy(connection);
                          +    connection_profile_destroy(profile_h);
                          +    connection_destroy(connection);
                           
                          -   free(local_ipv6);
                          -   free(local_ipv4);
                          -   free(interface_name);
                          +    free(local_ipv6);
                          +    free(local_ipv4);
                          +    free(interface_name);
                           
                          -   return 0;
                          +    return 0;
                           
                          @@ -745,4 +708,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/network/curl_tutorial_n.htm b/org.tizen.tutorials/html/native/network/curl_tutorial_n.htm new file mode 100644 index 0000000..7e06e79 --- /dev/null +++ b/org.tizen.tutorials/html/native/network/curl_tutorial_n.htm @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + Curl: Setting the Proxy Address + + + + + + +
                          +

                          Curl: Setting the Proxy Address

                          + +

                          This tutorial demonstrates how you can manage the proxy address for HTTP and HTTPS requests and transfer the requests. Tizen supports the open source libcurl library through the Curl API.

                          + + +

                          Warm-up

                          +

                          Become familiar with the Curl API basics by learning about:

                          + + +

                          Prerequisites

                          + +

                          To use the Curl API and the libcurl library, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

                          +
                          +<privileges>
                          +   <privilege>http://tizen.org/privilege/internet</privilege>
                          +</privileges>
                          +
                          + +

                          Initializing Curl

                          +

                          To initialize Curl for use:

                          +
                            +
                          1. +

                            To use the functions and data types of the Curl API (in mobile and wearable applications), include the <curl.h> header file in your application. You must also add the <net_connection.h> header file to get the proxy address.

                            +
                            +#include <curl.h>
                            +#include <net_connection.h>
                            +
                            +
                          2. +
                          3. +

                            Initialize the Curl library and the Curl handle using the curl_easy_init() function:

                            +
                            +CURL *curl;
                            +CURLcode curl_err;
                            +curl = curl_easy_init();
                            +
                            +
                          4. +
                          5. +

                            Create and initialize a connection handle by calling the connection_create() function:

                            +
                            +connection_h connection;
                            +int conn_err;
                            +conn_err = connection_create(&connection);
                            +if (conn_err != CONNECTION_ERROR_NONE) {
                            +    /* Error handling */
                            +
                            +    return;
                            +}
                            +
                            +
                          6. +
                          7. When no longer needed, clear the Curl and connection handle to finish the HTTP transaction: +
                            +curl_easy_cleanup(curl);
                            +connection_unset_proxy_address_changed_cb(connection);
                            +connection_destroy(connection);
                            +
                            +
                          8. +
                          + +

                          Managing the Proxy Address

                          + +

                          There are 2 ways for getting and setting the proxy address:

                          + +
                          • To get the proxy address directly, use the connection_get_proxy() function of the Connection Manager API (in mobile and wearable applications): +
                            +char *proxy_address;
                            +conn_err = connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_address);
                            +
                            +

                            To set the proxy address, use the curl_easy_setopt() function with the CURLOPT_PROXY parameter:

                            +
                            +if (conn_err == CONNECTION_ERROR_NONE && proxy_address)
                            +    curl_easy_setopt(curl, CURLOPT_PROXY, proxy_address);
                            +
                            +
                          • +
                          • To be notified whenever the proxy address changes, register a callback with the connection_set_proxy_address_changed_cb() function of the Connection Manager API: +
                            +conn_err = connection_set_proxy_address_changed_cb(connection,
                            +                                                   __proxy_address_changed_cb, NULL);
                            +if (conn_err != CONNECTION_ERROR_NONE) {
                            +    /* Error handling */
                            +
                            +    return;
                            +}
                            +
                            +

                            The new proxy address is passed in the callback parameters. To set the proxy address, use the curl_easy_setopt() function with the CURLOPT_PROXY parameter:

                            +
                            +static void
                            +__proxy_address_changed_cb(const char *ipv4_address,
                            +                           const char *ipv6_address, void *user_data)
                            +{
                            +    curl_easy_setopt(curl, CURLOPT_PROXY, ipv4_address);
                            +}
                            +
                            +
                          • +
                          + +

                          Transferring HTTP Requests

                          + +

                          To transfer HTTP requests, set the URL with the curl_easy_setopt() function and start the transfer with the curl_easy_perform() function:

                          +
                          +curl_easy_setopt(curl, CURLOPT_URL, "https://www.tizen.org/");
                          +curl_err = curl_easy_perform(curl);
                          +if (curl_err != CURLE_OK)
                          +    /* Error handling */
                          +
                          + + + + + + +
                          + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/network/iotcon_tutorial_n.htm b/org.tizen.tutorials/html/native/network/iotcon_tutorial_n.htm new file mode 100644 index 0000000..1993fa7 --- /dev/null +++ b/org.tizen.tutorials/html/native/network/iotcon_tutorial_n.htm @@ -0,0 +1,652 @@ + + + + + + + + + + + + + + Iotcon: Registering and Querying Resources + + + + + + +
                          + +

                          Iotcon: Registering and Querying Resources

                          + +

                          This tutorial demonstrates how you can provide resources and control remote resources in your application.

                          + +

                          Warm-up

                          + +

                          Become familiar with the Iotcon API basics by learning about:

                          + + + +

                          Prerequisites

                          + +

                          To use the Iotcon API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

                          +
                          +<privileges>
                          +   <privilege>http://tizen.org/privilege/network.get</privilege>
                          +   <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
                          +</privileges>
                          +
                          + +

                          Initializing IoT Connectivity

                          + +

                          To initialize IoT connectivity for use:

                          +
                            +
                          1. To use the functions and data types of the Iotcon API (in mobile and wearable applications), include the <iotcon.h> header file in your application: +
                            +#include <iotcon.h>
                            +
                            +

                            To ensure that an iotcon function has been executed properly, make sure that the return is equal to IOTCON_ERROR_NONE.

                            +
                          2. +
                          3. To connect the application with the IoT, use the iotcon_connect() function: +
                            +int ret;
                            +ret = iotcon_connect();
                            +
                            +
                          4. +
                          5. When the resources are no longer needed, close the connection using the iotcon_disconnect() function: +
                            +iotcon_disconnect();
                            +
                            +
                          6. +
                          + +

                          Registering Resources

                          + +

                          To create and register resources:

                          + +
                            +
                          1. Create the resource types using the iotcon_resource_types_create() function. The resource type string can be added using the iotcon_resource_types_add() function. +
                            +int ret;
                            +const char *res_type = "org.tizen.light";
                            +iotcon_resource_types_h res_types = NULL;
                            +
                            +ret = iotcon_resource_types_create(&res_types);
                            +if (IOTCON_ERROR_NONE != ret)
                            +    /* Error handling */
                            +
                            +ret = iotcon_resource_types_add(res_types, res_type);
                            +if (IOTCON_ERROR_NONE != ret)
                            +    /* Error handling */
                            +
                            +
                          2. +
                          3. Register the resource by calling the iotcon_resource_create() function. +

                            In the function, set the URI path, resource types, interfaces (iotcon_resource_interfaces_h resource interface handle in mobile and wearable applications), properties (one or more iotcon_resource_property_e enumeration values in mobile and wearable applications), and the request handler callback function called when a request arrives from a client.

                            +

                            The URI path must be unique. The iotcon_resource_create() function fails, if you use an existing URI to register another resource.

                            + +
                            +int res_interfaces = IOTCON_INTERFACE_DEFAULT;
                            +int res_properties = IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE;
                            +const char *res_uri = "/light/1";
                            +iotcon_resource_h resource = NULL;
                            +
                            +ret = iotcon_resource_create(res_uri, res_types, res_interfaces, res_properties,
                            +                             _request_handler, NULL, &resource);
                            +if (IOTCON_ERROR_NONE != ret)
                            +    /* Error handling */
                            +
                            +
                          4. +
                          5. When no longer needed, destroy the resource types handle using the iotcon_resource_types_destroy() function: +
                            +iotcon_resource_types_destroy(resource_types);
                            +
                            +
                          6. +
                          + +

                          Finding Resources

                          + +

                          To find resources:

                          +
                            +
                          1. To find a resource, call the iotcon_find_resource() function. +

                            In the function, set the host address, connectivity type (an iotcon_connectivity_type_e enumeration value in mobile and wearable applications), resource type, secure flag, and the found callback function called when the resource is found during the timeout.

                            +

                            The host address can be an IP address or Bluetooth MAC address. The host address can also be IOTCON_MULTICAST_ADDRESS for multicast.

                            +
                            +int ret;
                            +const char *res_type = "org.tizen.light";
                            +ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
                            +                           res_type, false, _found_cb, NULL);
                            +if (IOTCON_ERROR_NONE != ret)
                            +    /* Error handling */
                            +
                            +
                          2. +
                          3. To get the remote resource handle information, use the found callback registered in the iotcon_find_resource() function: +
                            +static void
                            +_found_cb(iotcon_remote_resource_h resource, iotcon_error_e err, void *user_data)
                            +{
                            +    int ret;
                            +    char *address;
                            +    char *uri_path;
                            +
                            +    if (IOTCON_ERROR_NONE != err)
                            +        /* Error handling */
                            +
                            +    ret = iotcon_remote_resource_get_host_address(resource, &address);
                            +    if (IOTCON_ERROR_NONE != ret)
                            +        /* Error handling */
                            +    dlog_print(DLOG_DEBUG, LOG_TAG, "host_address: %s", address);
                            +
                            +    ret = iotcon_remote_resource_get_uri_path(resource, &uri_path);
                            +    if (IOTCON_ERROR_NONE != ret)
                            +        /* Error handling */
                            +    dlog_print(DLOG_DEBUG, LOG_TAG, "uri_path: %s", uri_path);
                            +}
                            +
                            + +
                      + + + + + + + + +
                      Note
                      The callback parameters are valid only within the callback function. Use the clone handle, if you want to use a parameter after the callback function.
                      +
                    • +
                    • To set the timeout interval (in seconds) for the asynchronous functions of the Client (in mobile and wearable applications) and Remote Resource (in mobile and wearable applications) APIs, use the iotcon_set_timeout() function: +
                      +int ret;
                      +ret = iotcon_set_timeout(10);
                      +if (IOTCON_ERROR_NONE != ret)
                      +    /* Error handling */
                      +
                      + + + + + + + + + +
                      Note
                      + The iotcon_set_timeout() function has an effect on the following asynchronous functions: +
                        +
                      • iotcon_get_device_info()
                      • +
                      • iotcon_get_platform_info()
                      • +
                      • iotcon_find_resource()
                      • +
                      • iotcon_remote_resource_get()
                      • +
                      • iotcon_remote_resource_put()
                      • +
                      • iotcon_remote_resource_post()
                      • +
                      • iotcon_remote_resource_delete()
                      • +
                      +
                      +
                    • +
                  + +

                  Sending GET Requests

                  + +

                  To send GET requests to a server:

                  + +
                    +
                  1. On the client side, clone the remote resource handle using the found callback registered in the iotcon_find_resource() function: +
                    +static iotcon_remote_resource_h _light_resource = NULL;
                    +
                    +static void
                    +_found_cb(iotcon_remote_resource_h resource, iotcon_error_e err, void *user_data)
                    +{
                    +    int ret;
                    +    if (IOTCON_ERROR_NONE != err)
                    +        /* Error handling */
                    +    ret = iotcon_remote_resource_clone(resource, &_light_resource);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +}
                    +
                    +
                  2. +
                  3. Send the GET request to the server using the iotcon_remote_resource_get() function. +

                    In the function, set the remote resource, query, and the response callback function called when receiving a response from the resource.

                    +
                    +int ret;
                    +ret = iotcon_remote_resource_get(_light_resource, NULL, _on_get, NULL);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +
                    +
                  4. +
                  5. On the server side, the _request_handler() callback function is called when a request arrives from the client. The resource and request handles are passed to the callback. +

                    Use the callback to get the request information from the request handle, create a representation handle (with the _get_repr() function), and sent a response back to the client (with the _send_response() function):

                    +
                    +static void
                    +_request_handler(iotcon_resource_h resource, iotcon_request_h request, void *data)
                    +{
                    +    int ret;
                    +    iotcon_request_type_e req_type;
                    +    iotcon_response_result_e result = IOTCON_RESPONSE_ERROR;
                    +    iotcon_representation_h repr = NULL;
                    +
                    +    ret = iotcon_request_get_type(request, &req_type);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    switch (req_type) {
                    +    case IOTCON_REQUEST_GET:
                    +        ret = _get_repr(resource, &repr);
                    +        if (0 == ret)
                    +            result = IOTCON_RESPONSE_OK;
                    +        break;
                    +    default:
                    +        dlog_print(DLOG_DEBUG, LOG_TAG, "type: %d", req_type);
                    +    }
                    +    _send_response(request, result, repr);
                    +    if (repr)
                    +        iotcon_representation_destroy(repr);
                    +}
                    +
                    +
                  6. +
                  7. To process the GET request, the server must create the representation handle, which can include resource properties, such as the URI path, types, interfaces, and the state handle. Create the handle with the iotcon_representation_create() function: +
                    +static int _light_brightness;
                    +
                    +int
                    +_get_repr(iotcon_resource_h resource, iotcon_representation_h *representation)
                    +{
                    +    int ret;
                    +    char *uri_path;
                    +    int interfaces;
                    +    iotcon_resource_types_h res_types;
                    +    iotcon_representation_h repr;
                    +    iotcon_state_h state;
                    +
                    +    ret = iotcon_representation_create(&repr);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_resource_get_types(resource, &res_types);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_representation_set_resource_types(repr, res_types);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_resource_get_uri_path(resource, &uri_path);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_representation_set_uri_path(repr, uri_path);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_resource_get_interfaces(resource, &interfaces);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_representation_set_resource_interfaces (repr, interfaces);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_state_create(&state);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_state_add_int(state, "brightness", _light_brightness);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    ret = iotcon_representation_set_state(repr, state);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    iotcon_state_destroy(state);
                    +
                    +    *representation = repr;
                    +
                    +    return 0;
                    +}
                    +
                    +
                  8. +
                  9. To send a response to the client, use the iotcon_response_send() function. +

                    In the function, set the response handle that can include the mandatory response result and optional representation.

                    +
                    +void
                    +_send_response(iotcon_request_h request, iotcon_response_result_e result, iotcon_representation_h repr)
                    +{
                    +    int ret;
                    +    iotcon_response_h resp;
                    +    ret = iotcon_response_create(request, &resp);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    ret = iotcon_response_set_result(resp, result);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +
                    +    if (repr) {
                    +        ret = iotcon_response_set_representation(resp, IOTCON_INTERFACE_DEFAULT, repr);
                    +        if (IOTCON_ERROR_NONE != ret)
                    +            /* Error handling */
                    +    }
                    +    ret = iotcon_response_send(resp);
                    +    if (IOTCON_ERROR_NONE != ret) 
                    +        /* Error handling */
                    +
                    +    iotcon_response_destroy(resp);
                    +}
                    +
                    +
                  10. +
                  11. On the client side, the response callback is called when the response arrives from the server. Handle the response appropriately. If the response is a success, the resource information can be included in it. +
                    +static void
                    +_parse_representation(iotcon_representation_h repr)
                    +{
                    +    int ret;
                    +    int brightness;
                    +    iotcon_state_h state;
                    +
                    +    ret = iotcon_representation_get_state(repr, &state);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    ret = iotcon_state_get_int(state, "brightness", &brightness);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    dlog_print(DLOG_DEBUG, LOG_TAG, "Brightness: %d", brightness);
                    +}
                    +
                    +static void
                    +_on_get(iotcon_remote_resource_h resource, iotcon_error_e err,
                    +        iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
                    +{
                    +    int ret;
                    +    iotcon_representation_h repr;
                    +    iotcon_response_result_e result;
                    +    if (IOTCON_ERROR_NONE != err)
                    +        /* Error handling */
                    +    ret = iotcon_response_get_result(response, &result);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    if (IOTCON_RESPONSE_OK != result)
                    +        /* Error handling */
                    +    ret = iotcon_response_get_representation(response, &repr);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    _parse_representation(repr);
                    +}
                    +
                    +
                  12. +
                  + +

                  Sending PUT Requests

                  + +

                  To send PUT requests to a server:

                  +
                    +
                  1. To send a PUT request to the server, use the iotcon_remote_resource_put() function. +

                    In the function, set the remote resource, representation, query, and the response callback function called when a response arrives from the resource.

                    +
                    +int ret;
                    +iotcon_representation_h repr;
                    +iotcon_state_h state;
                    +ret = iotcon_representation_create(&repr);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +ret = iotcon_state_create(&state);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +ret = iotcon_state_add_int(state, "brightness", 20);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +ret = iotcon_representation_set_state(repr, state);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +iotcon_state_destroy(state);
                    +
                    +ret = iotcon_remote_resource_put(_light_resource, repr, NULL, _on_put, NULL);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +iotcon_representation_destroy(repr);
                    +
                    +
                  2. +
                  3. On the server side, the request handler function is called when a request arrives from the client. The resource and request handles are passed to the handler callback. +

                    You can get the request information from the request handle.

                    +
                    +static void
                    +_handle_put(iotcon_request_h request)
                    +{
                    +    int ret;
                    +    iotcon_representation_h repr;
                    +    iotcon_state_h state;
                    +    ret = iotcon_request_get_representation(request, &repr);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    ret = iotcon_representation_get_state(repr, &state);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    ret = iotcon_state_get_int(state, "brightness", &_light_brightness);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +}
                    +
                    +static void
                    +_request_handler(iotcon_resource_h resource, iotcon_request_h request, void *data)
                    +{
                    +    int ret;
                    +    iotcon_request_type_e req_type;
                    +    iotcon_response_result_e result = IOTCON_RESPONSE_ERROR;
                    +    iotcon_representation_h repr = NULL;
                    +
                    +    ret = iotcon_request_get_request_type(request, &req_type);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    switch (req_type) {
                    +    case IOTCON_REQUEST_PUT:
                    +        _handle_put(request);
                    +        ret = _get_repr(resource, &repr);
                    +        if (0 == ret)
                    +            result = IOTCON_RESPONSE_OK;
                    +        break;
                    +    default:
                    +        dlog_print(DLOG_DEBUG, LOG_TAG, "type: %d", req_type);
                    +    }
                    +    _send_response(request, result, repr);
                    +    if (repr)
                    +        iotcon_representation_destroy(repr);
                    +}
                    +
                    +
                  4. +
                  5. On the client side, the response callback is called when the response arrives from the server. If the response is a success, the resource information can be included in it. +
                    +static void
                    +_on_put(iotcon_remote_resource_h resource, iotcon_error_e err,
                    +        iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
                    +{
                    +    int ret;
                    +    iotcon_representation_h repr;
                    +    iotcon_response_result_e result;
                    +    if (IOTCON_ERROR_NONE != err)
                    +        /* Error handling */
                    +    ret = iotcon_response_get_result(response, &result);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    if (IOTCON_RESPONSE_OK != result)
                    +        /* Error handling */
                    +    ret = iotcon_response_get_representation(response, &repr);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    _parse_representation(repr);
                    +}
                    +
                    +
                  6. +
                  + +

                  Observing Resources

                  + +

                  To monitor the changes in a resource:

                  +
                    +
                  1. If the resource is observable, the client can register a callback to observe the resource using the iotcon_remote_resource_observe_register() function: +
                    +int ret;
                    +int properties;
                    +ret = iotcon_remote_resource_get_properties(_light_resource, &properties);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +if (IOTCON_RESOURCE_OBSERVABLE & properties) {
                    +    ret = iotcon_remote_resource_observe_register(_light_resource, IOTCON_OBSERVE_IGNORE_OUT_OF_ORDER,
                    +                                                  NULL, _observe_cb, NULL);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +}
                    +
                    +
                  2. +
                  3. On the server side, the request handler callback is called when the observe request arrives from the client. To manage the observers, use the iotcon_observers_h handle. +
                    +static iotcon_observers_h _observers;
                    +
                    +static void
                    +_handle_observe(iotcon_request_h request, bool is_register)
                    +{
                    +    int ret;
                    +    int observe_id;
                    +    ret = iotcon_request_get_observe_id(request, &observe_id);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    if (is_register) {
                    +        if (NULL == _observers) {
                    +            ret = iotcon_observers_create(&_observers);
                    +            if (IOTCON_ERROR_NONE != ret)
                    +                /* Error handling */
                    +        }
                    +        ret = iotcon_observers_add(_observers, observe_id);
                    +        if (IOTCON_ERROR_NONE != ret)
                    +            /* Error handling */
                    +    } else {
                    +        ret = iotcon_observers_remove(_observers, observe_id);
                    +        if (IOTCON_ERROR_NONE != ret)
                    +            /* Error handling */
                    +    }
                    +}
                    +
                    +static void
                    +_request_handler(iotcon_resource_h resource, iotcon_request_h request, void *data)
                    +{
                    +    int ret;
                    +    iotcon_observe_type_e observe_type;
                    +
                    +    ret = iotcon_request_get_observe_type(request, &observe_type);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    switch (observe_type) {
                    +    case IOTCON_OBSERVE_REGISTER:
                    +        _handle_observe(request, true);
                    +        break;
                    +    case IOTCON_OBSERVE_DEREGISTER:
                    +        _handle_observe(request, false);
                    +        break;
                    +    case IOTCON_OBSERVE_NO_TYPE:
                    +    default:
                    +        dlog_print(DLOG_DEBUG, LOG_TAG, "type: %d", observe_type);
                    +    }
                    +}
                    +
                    +
                  4. +
                  5. When a resource changes, notify the observing client using the iotcon_resource_notify() function. The second parameter can be NULL to notify all observers. +
                    +int ret;
                    +iotcon_representation_h repr = NULL;
                    +ret = _get_repr(resource, &repr);
                    +if (0 != ret)
                    +    /* Error handling */
                    +ret = iotcon_resource_notify(resource, _observers, repr, IOTCON_QOS_HIGH);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +if (repr)
                    +    iotcon_representation_destroy(repr);
                    +
                    +
                  6. +
                  7. On the client side, the _observe_cb() callback is called when the notify function is called from the server side. The remote resource handle, sequence number, and response handle are passed to the callback. +
                    +static void
                    +_observe_cb(iotcon_remote_resource_h resource, iotcon_error_e err,
                    +            int sequence_number, iotcon_response_h response, void *user_data)
                    +{
                    +    int ret;
                    +    iotcon_representation_h repr;
                    +    if (IOTCON_ERROR_NONE != err)
                    +        /* Error handling */
                    +    dlog_print(DLOG_DEBUG, LOG_TAG, "sequence: %d", sequence_number);
                    +    ret = iotcon_response_get_representation(response, &repr);
                    +    if (IOTCON_ERROR_NONE != ret)
                    +        /* Error handling */
                    +    _parse_representation(repr);
                    +}
                    +
                    +
                  8. +
                  9. When the client no longer needs to monitor the resource, deregister the observation callback with the iotcon_remote_resource_observe_deregister() function: +
                    +int ret;
                    +ret = iotcon_remote_resource_observe_deregister(_light_resource);
                    +if (IOTCON_ERROR_NONE != ret)
                    +    /* Error handling */
                    +
                    +
                  10. +
                  + + + + +
              + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/network/mtp_tutorial_n.htm b/org.tizen.tutorials/html/native/network/mtp_tutorial_n.htm new file mode 100644 index 0000000..8f897fa --- /dev/null +++ b/org.tizen.tutorials/html/native/network/mtp_tutorial_n.htm @@ -0,0 +1,486 @@ + + + + + + + + + + + + + + MTP: Transferring Files with Media Transfer Protocol + + + + + + +
              + +

              MTP: Transferring Files with Media Transfer Protocol

              + +

              This tutorial demonstrates how you can manage the Media Transfer Protocol (MTP) and get files from the MTP responder.

              + +

              Warm-up

              + +

              Become familiar with the MTP API basics by learning about:

              + + + +

              Prerequisites

              + +

              To use the MTP API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

              +
              +<privileges>
              +   <privilege>http://tizen.org/privilege/mtp</privilege>
              +   <!--To store a file if the input or output path leads to a media storage-->
              +   <privilege>http://tizen.org/privilege/mediastorage</privilege>
              +   <!--To store a file if the input or output path leads to an external storage-->
              +   <privilege>http://tizen.org/privilege/externalstorage</privilege>
              +</privileges>
              +
              + +

              Initializing the MTP

              + +

              To initialize the MTP for use:

              + +
                +
              1. +

                To use the functions and data types of the MTP API (in mobile and wearable applications), include the <mtp.h> header file in your application:

                +
                +#include <mtp.h>
                +
                +
              2. +
              3. Make sure that MTP is supported in your target device.

              4. +
              5. +

                To initialize the MTP connection, call the mtp_initialize() function. If the function does not return an error, the MTP is ready for use.

                +
                +int
                +manager_test_initialize(void)
                +{
                +    int ret = 0;
                +
                +    ret = mtp_initialize();
                +    if (ret == MTP_ERROR_NONE)
                +        dlog_print("Initialize successful");
                +    else
                +        dlog_print("Initialize failed, ret [%d]", ret);
                +
                +    return ret;
                +}
                +
                +
              6. +
              7. +

                When the MTP is no longer needed, free all resources and deinitialize it:

                +
                +int
                +manager_test_deinitialize(void)
                +{
                +    int ret = 0;
                +
                +    ret = mtp_deinitialize();
                +    dlog_print("ret[%d] : deinitialize", ret);
                +
                +    return ret;
                +}
                +
                +
              8. +
              + +

              Getting the MTP Device List

              + +

              To get the MTP devices connected to the MTP initiator, retrieve the MTP device list with the mtp_get_devices() function.

              + +

              To select the device you want, retrieve information about the devices in the device list with the mtp_deviceinfo_get_XXX() functions. The following example retrieves the manufacturer (for example, "Samsung Electronics Co., Ltd.") and model name (for example, "SM-A700L") for each device in the list.

              + +
              +int
              +manager_test_get_devices(void)
              +{
              +    int i;
              +    int ret = 0;
              +    int bus_location = 0;
              +    int device_number = 0;
              +    int device_count;
              +    mtp_device_h *mtp_devices = NULL;
              +    char *name = NULL;
              +
              +    ret = mtp_get_devices(&mtp_devices, &device_count);
              +
              +    if (ret != MTP_ERROR_NONE) {
              +        dlog_print("mtp_get_devices failed!!!");
              +
              +        return -1;
              +    }
              +
              +    if (device_count == 0) {
              +        dlog_print("device does not exist!!!");
              +        END();
              +
              +        return -1;
              +    }
              +
              +    for (i = 0; i < device_count; i++) {
              +        dlog_print("mtp_device[%d] handle - %d", i, mtp_devices[i]);
              +        ret = mtp_deviceinfo_get_manufacturer_name(mtp_devices[i], &name);
              +        g_free(name);
              +        ret = mtp_deviceinfo_get_model_name(mtp_devices[i], &name);
              +        g_free(name);
              +    }
              +
              +    dlog_print("Select first device");
              +
              +    mtp_device = mtp_devices[0];
              +
              +    dlog_print("ret[%d]: 1st mtp device [%d]", ret, mtp_device);
              +
              +    END();
              +
              +    return ret;
              +}
              +
              + +

              Getting MTP Device Information

              + +

              To obtain information on the MTP device, use the mtp_deviceinfo_get_XXX() functions. To avoid memory leaks, free the character array variable with the free() function when no longer needed.

              + +

              The following example retrieves the device serial number:

              + +
              +mtp_device_h mtp_device; /* Get this variable using mtp_get_devices() */
              +
              +int
              +deviceinfo_test_get_serialnumber(void)
              +{
              +    int ret = 0;
              +    char *serial_number = NULL;
              +
              +    ret = mtp_deviceinfo_get_serial_number(mtp_device, &serial_number);
              +    dlog_print("ret[%d]: serialnumber[%s]", ret, serial_number);
              +
              +    if (serial_number == NULL)
              +        free(serial_number);
              +
              +    return ret;
              +}
              +
              + +

              Getting the MTP Storages

              + +

              To obtain a list of MTP storages in an MTP device, use the mtp_get_storages() function. To avoid memory leaks, free the storage array variable with the free() function when no longer needed.

              + + + + + + + + + + +
              Note
              The storage variable is used in all storage-related functions. Manage it with care.
              + +
              +mtp_device_h mtp_device; /* Get this variable using mtp_get_devices() */
              +
              +int
              +manager_test_get_storages(void)
              +{
              +    mtp_storage_h *mtp_storages = NULL;
              +
              +    ret = mtp_get_storages(mtp_device, &mtp_storages, &storage_count);
              +    dlog_print("ret[%d]: storage_count[%d]", ret, storage_count);
              +
              +    if (storage_count == 0) {
              +        dlog_print("storage does not exist!!!");
              +
              +        return -1;
              +    }
              +
              +    for (i = 0; i < storage_count; i++)
              +        dlog_print("mtp storage %d [%d]", i, mtp_storages[i]);
              +
              +    if (mtp_storages != NULL)
              +        free(mtp_storages);
              +
              +    return ret;
              +}
              +
              + +

              Getting MTP Storage Information

              + +

              To obtain information on the MTP storage, use the mtp_storageinfo_get_XXX() functions. To avoid memory leaks, free the character array variable with the free() function when no longer needed.

              + +

              The following example retrieves the storage description:

              + +
              +mtp_device_h mtp_device; /* Get this variable using mtp_get_devices() */
              +mtp_storage_h mtp_storage; /* Get this variable using mtp_get_storages() */
              +
              +int
              +storageinfo_test_get_description(void)
              +{
              +    int ret = 0;
              +    char *description = NULL;
              +
              +    ret = mtp_storageinfo_get_description(mtp_device, mtp_storage, &description);
              +    dlog_print("ret[%d]: description[%s]", ret, description);
              +
              +    if (description != NULL)
              +        free(description);
              +
              +    return ret;
              +}
              +
              + +

              Getting the Object Handle

              + +

              To obtain the object handle, get the unique ID value of the object handles from the MTP responder.

              + +

              When first using the mtp_get_object_handles() function, set the parent object handle to 0 to search the root folder of the storage.

              + + + + + + + + + + +
              Note
              Because the object handle uses a value from another function as a parameter, manage the variable with care.
              + +
              +mtp_device_h mtp_device;
              +mtp_storage_h mtp_storage;
              +
              +int
              +manager_test_get_object_handles(void)
              +{
              +    mtp_object_h *folder_list;
              +    mtp_object_h *file_list;
              +    int folder_count;
              +    int file_count;
              +
              +    ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_FOLDER, 0, &folder_list, &folder_count);
              +    dlog_print("ret[%d]: folder_count in root [%d]", ret, folder_count);
              +
              +    for (i = 0; i < folder_count; i++) {
              +        ret = mtp_objectinfo_get_file_name(mtp_device, folder_list[i], &folder_name);
              +        dlog_print("ret[%d]: object handle [%d], folder name [%s]", ret, folder_list[i], folder_name);
              +    }
              +
              +    ret = mtp_get_object_handles(mtp_device, mtp_storage, MTP_FILETYPE_JPEG, mtp_object, &file_list, &file_count);
              +    dlog_print("ret[%d]: file_count in root [%d]", ret, file_count);
              +
              +    for (i = 0; i < file_count; i++) {
              +        ret = mtp_objectinfo_get_file_name(mtp_device, file_list[i], &file_name);
              +        dlog_print("ret[%d]: object handle [%d] file name [%s]", ret, file_list[i], file_name);
              +    }
              +
              +    return ret;
              +}
              +
              + + + + + + + + + + +
              Note
              Depending on how you use this API, the performance of the application varies greatly. Typically, MTP transfer through the USB layer is not fast. In addition, larger files on the MTP device take a longer time for the function to handle. +

              Rather than getting the object handles inside the device all at once, consider gradually obtaining them through user input. (It is easier to understand the MTP device when it is plugged into the computer.)

              +
              + +

              Getting MTP Object Information

              + +

              To obtain information on the MTP object, use the mtp_objectinfo_get_XXX() functions. To avoid memory leaks, free the character array variable with the free() function when no longer needed.

              + +

              The following example retrieves the object file name:

              + +
              +mtp_device_h mtp_device; /* Get this variable using mtp_get_devices() */
              +mtp_object_h mtp_object; /* Get this variable using mtp_get_object_handles() */
              +
              +int
              +objectinfo_test_get_filename(void)
              +{
              +    int ret = 0;
              +    char *name = NULL;
              +
              +    ret = mtp_objectinfo_get_file_name(mtp_device, mtp_object, &name);
              +    dlog_print("ret[%d]: object id[%d] filename[%s]", ret, mtp_object, name);
              +
              +    if (name != NULL)
              +        free(name);
              +
              +    return ret;
              +}
              +
              + +

              Getting the Object and Thumbnail

              + +

              To get the object and thumbnail:

              + +
                +
              1. +

                Get the object data from the MTP responder using the mtp_get_object() function:

                +
                +mtp_device_h mtp_device;
                +mtp_object_h mtp_object_handle;
                +
                +int
                +manager_test_get_object(void)
                +{
                +    char filepath[100] = {0,};
                +    snprintf(filepath, 100, "/opt/usr/media/Downloads/JpegObject_%d.jpg", mtp_object_handle);
                +
                +    ret = mtp_get_object(mtp_device, mtp_object_handle, filepath);
                +    dlog_print("ret[%d]: input id[%d]", ret, mtp_object_handle);
                +
                +    return ret;
                +}
                +
                +
              2. +
              3. +

                If the file is an image file and has a thumbnail, import the thumbnail using the mtp_get_thumbnail() function:

                +
                +mtp_device_h mtp_device;
                +mtp_object_h mtp_object_handle;
                +
                +int
                +manager_test_get_object(void)
                +{
                +    char filepath[100] = {0,};
                +    snprintf(filepath, 100, "/opt/usr/media/Downloads/JpegObject_%d.jpg", mtp_object_handle);
                +
                +    ret = mtp_get_thumbnail(mtp_device, mtp_object_handle, filepath);
                +    dlog_print("ret[%d]: input id[%d]", ret, mtp_object_handle);
                +
                +    return ret;
                +}
                +
                +
              4. +
              + +

              Managing MTP Events

              + +

              To receive an event that occurred in the MTP initiator, add the event callback with the mtp_add_mtp_event_cb() function and define the callback.

              + +

              The event_parameter parameter defines the type of the event:

              + +
                +
              • Device event type is mtp_device_h.

              • +
              • Storage event type is mtp_storage_h.

              • +
              • Object event type is mtp_object_h.

              • +
              + +

              If the received event is MTP_EVENT_TURNED_OFF, the event_parameter parameter has no meaning. When this event occurs, free all MTP-related resources.

              + +
              +void
              +__test_mtp_event_cb(mtp_event_e state, int event_parameter, void *user_data)
              +{
              +    int ret = 0;
              +    dlog_print("state [%d] : %d", state, event_parameter);
              +    if (state == MTP_EVENT_DEVICE_ADDED || state == MTP_EVENT_DEVICE_REMOVED) {
              +        mtp_device_h mtp_device = (mtp_device_h) event_parameter;
              +        /* Do something */
              +    } else if (state == MTP_EVENT_STORAGE_ADDED || state == MTP_EVENT_STORAGE_REMOVED) {
              +        mtp_storage_h mtp_storage = (mtp_storage_h) event_parameter;
              +        /* Do something */
              +    } else if (state == MTP_EVENT_OBJECT_ADDED || state == MTP_EVENT_OBJECT_ADDED) {
              +        mtp_object_h mtp_object = (mtp_object_h) event_parameter;
              +        /* Do something */
              +    } else if (state == MTP_EVENT_TURNED_OFF) {
              +        ret = mtp_deinitialize();
              +        dlog_print("ret[%d] : Terminated daemon", ret);
              +    } else {
              +        /* Error handling */
              +    }
              +}
              +
              +int
              +application_test_event_callback(void)
              +{
              +    int ret;
              +
              +    ret = mtp_add_mtp_event_cb(__test_mtp_event_cb, NULL);
              +
              +    return ret;
              +}
              +
              + + + +
              + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/network/network_tutorials_n.htm b/org.tizen.tutorials/html/native/network/network_tutorials_n.htm index d546470..bd33eee 100644 --- a/org.tizen.tutorials/html/native/network/network_tutorials_n.htm +++ b/org.tizen.tutorials/html/native/network/network_tutorials_n.htm @@ -39,6 +39,9 @@

              The following tutorials apply in mobile applications only:

              diff --git a/org.tizen.tutorials/html/native/network/nfc_tutorial_n.htm b/org.tizen.tutorials/html/native/network/nfc_tutorial_n.htm index cc1266e..70190a5 100644 --- a/org.tizen.tutorials/html/native/network/nfc_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/network/nfc_tutorial_n.htm @@ -23,6 +23,7 @@

              Content

              + +

              Prerequisites

              + +

              To use the NFC API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

              +
              +<privileges>
              +   <privilege>http://tizen.org/privilege/nfc</privilege>
              +   <!--To create a host-based card emulation (HCE) application-->
              +   <privilege>http://tizen.org/privilege/nfc.cardemulation</privilege>
              +</privileges>
              +

              Initializing NFC

              @@ -96,13 +108,13 @@
            • Check whether the device you want to work with supports NFC. This can be done by calling the nfc_manager_is_supported() function. It takes no parameters and returns true if NFC is supported on the device.

              -void 
              +void
               Network_NFC_startup(void)
               {
              -   gmainloop = g_main_loop_new(NULL, FALSE);
              -   bool is_nfc_supported = nfc_manager_is_supported();
              -   if (!is_nfc_supported)
              -      dlog_print(DLOG_INFO, LOG_TAG, "is_nfc_supported NOT SUPPORTED");
              +    gmainloop = g_main_loop_new(NULL, FALSE);
              +    bool is_nfc_supported = nfc_manager_is_supported();
              +    if (!is_nfc_supported)
              +        dlog_print(DLOG_INFO, LOG_TAG, "is_nfc_supported NOT SUPPORTED");
               }
               
              @@ -113,8 +125,8 @@ Network_NFC_startup(void) int error_code = NFC_ERROR_NONE; error_code = nfc_manager_initialize(); -if (NFC_ERROR_NONE != error_code) -   // Error occurred +if (NFC_ERROR_NONE != error_code) +    /* Error occurred */ g_timeout_add(1000, timeout_func, gmainloop); g_main_loop_run(gmainloop); @@ -125,11 +137,11 @@ g_main_loop_run(gmainloop);
            • When the work with NFC is finished, the nfc_manager_deinitialize() function must be called to clear the environment:

              -void 
              +void
               Network_NFC_cleanup(void)
               {
              -   g_main_loop_unref(gmainloop);
              -   nfc_manager_deinitialize();
              +    g_main_loop_unref(gmainloop);
              +    nfc_manager_deinitialize();
               }
               
            • @@ -144,36 +156,32 @@ Network_NFC_cleanup(void) #include <app_control.h> #include <dlog.h> -int +int nfc_onoff_operation(void) { -   int ret = 0; -   app_control_h service = NULL; -   app_control_create(&service); -   if (service == NULL) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "service_create failed!\n"); - -      return 0; -   } -   app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_NFC); -   ret = app_control_send_launch_request(service, NULL, NULL); - -   app_control_destroy(service); -   if (ret == APP_CONTROL_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to NFC On/Off app!\n"); - -      return 0; -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to relaunch NFC On/Off app!\n"); - -      return -1; -   } - -   return 0; +    int ret = 0; +    app_control_h service = NULL; +    app_control_create(&service); +    if (service == NULL) { +        dlog_print(DLOG_INFO, LOG_TAG, "service_create failed!\n"); + +        return 0; +    } +    app_control_set_operation(service, APP_CONTROL_OPERATION_SETTING_NFC); +    ret = app_control_send_launch_request(service, NULL, NULL); + +    app_control_destroy(service); +    if (ret == APP_CONTROL_ERROR_NONE) { +        dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to NFC On/Off app!\n"); + +        return 0; +    } else { +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to relaunch NFC On/Off app!\n"); + +        return -1; +    } + +    return 0; } @@ -193,13 +201,13 @@ error_code = nfc_manager_set_activation_changed_cb(on_nfc_activation_changed, NU

              Define the callback. In this example, it only informs the user that the activation state has changed.

              -static void 
              +static void
               on_nfc_activation_changed(bool activated, void *user_data)
               {
              -   if (activated)
              -      dlog_print(DLOG_INFO, LOG_TAG, "NFC activated");
              -   else
              -      dlog_print(DLOG_INFO, LOG_TAG, "NFC deactivated");
              +    if (activated)
              +        dlog_print(DLOG_INFO, LOG_TAG, "NFC activated");
              +    else
              +        dlog_print(DLOG_INFO, LOG_TAG, "NFC deactivated");
               }
               
              @@ -214,32 +222,37 @@ nfc_manager_set_tag_filter(NFC_TAG_FILTER_ALL_ENABLE);
            • Use the nfc_manager_set_tag_discovered_cb() function to register a tag discovery callback:
               error_code = nfc_manager_set_tag_discovered_cb(on_nfc_tag_discovered, NULL);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            • Use the nfc_manager_set_ndef_discovered_cb() function to register an NDEF event callback:
               error_code = nfc_manager_set_ndef_discovered_cb(on_nfc_ndef_discovered, NULL);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            • Use the nfc_manager_set_p2p_target_discovered_cb() function to register a peer-to-peer event callback:
              -error_code = nfc_manager_set_p2p_target_discovered_cb(on_nfc_p2p_target_discovered, 
              +error_code = nfc_manager_set_p2p_target_discovered_cb(on_nfc_p2p_target_discovered,
                                                                     NULL);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            • Use the nfc_manager_set_se_event_cb() function to register a secure element event callback:
               error_code = nfc_manager_set_se_event_cb(on_nfc_se_event, NULL);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            • Use the nfc_manager_set_se_transaction_event_cb() function to register a secure element transaction event callback:
              -error_code = nfc_manager_set_se_transaction_event_cb(NFC_SE_TYPE_ESE, 
              -                                                     on_nfc_se_transaction_event, 
              +error_code = nfc_manager_set_se_transaction_event_cb(NFC_SE_TYPE_ESE,
              +                                                     on_nfc_se_transaction_event,
                                                                    NULL);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
          • @@ -247,7 +260,7 @@ if (NFC_ERROR_NONE != error_code) // Error occurred

            By default, the system handling is enabled. If the function returns FALSE, enable system handling using the nfc_manager_set_system_handler_enable() function and pass TRUE as an input parameter.

             if (nfc_manager_is_system_handler_enabled() != true)
            -   nfc_manager_set_system_handler_enable(true);
            +    nfc_manager_set_system_handler_enable(true);
             

            After registering the callbacks, you can start using NFC on the device. You can connect to other devices, resulting in launching the code from the registered callbacks.

            @@ -280,17 +293,18 @@ nfc_tag_get_maximum_ndef_size(tag, &maximum_ndef_bytes_size);
             error_code = nfc_tag_foreach_information(tag, on_nfc_tag_information_event, NULL);
             
            -if (NFC_ERROR_NONE != error_code) // Error occurred
            +if (NFC_ERROR_NONE != error_code)
            +    /* Error occurred */
             

            The on_nfc_tag_information_event() callback prints out the found keys and their values.

            -on_nfc_tag_information_event(const char *key, const unsigned char *value, 
            +on_nfc_tag_information_event(const char *key, const unsigned char *value,
                                          int value_size, void *user_data)
             {
            -   dlog_print(DLOG_INFO, LOG_TAG, "Title: %s, Value: %s", key, (char*)value);
            +    dlog_print(DLOG_INFO, LOG_TAG, "Title: %s, Value: %s", key, (char*)value);
             
            -   return true;
            +    return true;
             }
             

            The iteration over the key and value pairs continues while the callback returns true.

            @@ -307,15 +321,16 @@ filter = nfc_manager_get_tag_filter();

            Read the tag data with the nfc_tag_read_ndef() function. The parameters are the tag handle, the callback evoked when the reading is completed, and user data passed to the callback.

             error_code = nfc_tag_read_ndef(tag, on_nfc_tag_read_completed, NULL);
            -if (NFC_ERROR_NONE != error_code) // Error occurred
            +if (NFC_ERROR_NONE != error_code)
            +    /* Error occurred */
             

            After the tag message has been read, the on_nfc_tag_read_completed() callback is called. The parameters are the status of reading the message, the message read from the tag, and data passed to the callback. The last one can be NULL if no data need to be passed.

            -static void 
            +static void
             on_nfc_tag_read_completed(int error_code, nfc_ndef_message_h message, void *user_data)
             {
            -   nfc_ndef_message_read_cb(clone_message(message));
            +    nfc_ndef_message_read_cb(clone_message(message));
             }
          • @@ -332,29 +347,29 @@ nfc_ndef_message_read_cb(clone_message(message));
          • Clone the message by calling the clone_message() function:

            -static 
            +static
             nfc_ndef_message_h clone_message(nfc_ndef_message_h msg)
             {
            -   unsigned char *rawdata;
            -   unsigned int rawdata_size;
            -   nfc_ndef_message_h msg_cp;
            +    unsigned char *rawdata;
            +    unsigned int rawdata_size;
            +    nfc_ndef_message_h msg_cp;
             
          • Get the copy of the bytes array of the NDEF message with the nfc_ndef_message_get_rawdata() function. The parameters are the handle to the NDEF message, the 2-dimensional bytes array, and the size of the bytes array.

            The parameters are variables that must be passed to be fulfilled inside the called function.

            -   nfc_ndef_message_get_rawdata(msg, &rawdata, &rawdata_size);
            +    nfc_ndef_message_get_rawdata(msg, &rawdata, &rawdata_size);
             
          • Create an NDEF handle from raw serial bytes with the nfc_ndef_message_create_from_rawdata() function. Use it to create a copy of the message retrieved from the tag to make it possible to read information from the copy. The parameters are the message handle, rawdata, and rawdata_size.

            In the end, rawdata must be released with the free() function.

            -   nfc_ndef_message_create_from_rawdata(&msg_cp, rawdata, rawdata_size);
            -   free(rawdata);
            +    nfc_ndef_message_create_from_rawdata(&msg_cp, rawdata, rawdata_size);
            +    free(rawdata);
             
            -   return msg_cp;
            +    return msg_cp;
             }
             
          • @@ -364,14 +379,16 @@ nfc_ndef_message_h clone_message(nfc_ndef_message_h msg)

            Get the number of records stored in the tag message with the nfc_ndef_message_get_record_count() function. It needs the handle to the message that is operated on and the pointer to an integer which is fulfilled by the function with the number of records in the message.

             error_code = nfc_ndef_message_get_record_count(message, &count);
            -if (NFC_ERROR_NONE != error_code) // Error occurred
            +if (NFC_ERROR_NONE != error_code)
            +    /* Error occurred */
             
          • Iterate through all the records in the message and get all information stored in each record. Call the nfc_ndef_message_get_record() function first. The parameters are the handle of the NDEF message, index of the record, and handle to the record. This function gets a record from the message by index. It returns a pointer to the record, so if you change the record, it directly affects the NDEF message.

             error_code = nfc_ndef_message_get_record(message, i, &rec);
            -if (NFC_ERROR_NONE != error_code) // Error occurred
            +if (NFC_ERROR_NONE != error_code)
            +    /* Error occurred */
             

            Now, when the pointer to the specific record exists, get the record data:

            @@ -379,24 +396,29 @@ if (NFC_ERROR_NONE != error_code) // Error occurred
            • Get the record ID by calling the nfc_ndef_record_get_id() function:
               error_code = nfc_ndef_record_get_id(rec, &id, &id_len);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            • Get the record type using the nfc_ndef_record_get_type() function:
               error_code = nfc_ndef_record_get_type(rec, &type_str, &type_len);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
            • +if (NFC_ERROR_NONE != error_code) +    /* Error occurred */ +
            • Get the record TNF (Type Name Format) with the nfc_ndef_record_get_tnf() function:
               error_code = nfc_ndef_record_get_tnf(rec, &tnf);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            • Get the record payload by calling the nfc_ndef_record_get_payload() function:
               error_code = nfc_ndef_record_get_payload(record, &payload, &payload_len);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
          • @@ -404,17 +426,20 @@ if (NFC_ERROR_NONE != error_code) // Error occurred
            • If there is a message with Type = "T" and the TNF is NFC_RECORD_TNF_WELL_KNOWN, it is possible to get the following data:
              -// Get the record text
              +/* Get the record text */
               error_code = nfc_ndef_record_get_text(record, &text);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
              -// Get the record text language code
              +/* Get the record text language code */
               error_code = nfc_ndef_record_get_langcode(record, &language);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
              -// Get the record text encoding type
              +/* Get the record text encoding type */
               error_code = nfc_ndef_record_get_encode_type(record, &encode);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            • @@ -422,14 +447,16 @@ if (NFC_ERROR_NONE != error_code) // Error occurred
               error_code = nfc_ndef_record_get_uri(record, &uri);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            • If the TNF of the record is NFC_RECORD_TNF_MIME_MEDIA, it is possible to get the record mime type:

               error_code = nfc_ndef_record_get_mime_type(record, &mime);
              -if (NFC_ERROR_NONE != error_code) // Error occurred
              +if (NFC_ERROR_NONE != error_code)
              +    /* Error occurred */
               
            @@ -447,23 +474,23 @@ if (NFC_ERROR_NONE != error_code) // Error occurred

            In the registered on_nfc_ndef_discovered() callback, get the number of records in the message and then iterate through those records.

            Retrieve the record handles, and then the record payloads.

            -static void 
            +static void
             on_nfc_ndef_discovered(nfc_ndef_message_h message, void *user_data)
             {
            -   int count, i;
            -   unsigned int size;
            -   unsigned char * payload;
            -   nfc_ndef_record_h record;
            -
            -   nfc_ndef_message_get_record_count(message, &count);
            -   dlog_print(DLOG_INFO, LOG_TAG, "on_nfc_ndef_discovered %d", count);
            -
            -   for (i = 0; i < count; i++)
            -   {
            -      nfc_ndef_message_get_record(message, i, &record);
            -      nfc_ndef_record_get_payload(record, &payload, &size);
            -      dlog_print(DLOG_INFO, LOG_TAG, "Record Number: %d, Payload: %s", i, payload);
            -   }
            +    int count;
            +    int i;
            +    unsigned int size;
            +    unsigned char * payload;
            +    nfc_ndef_record_h record;
            +
            +    nfc_ndef_message_get_record_count(message, &count);
            +    dlog_print(DLOG_INFO, LOG_TAG, "on_nfc_ndef_discovered %d", count);
            +
            +    for (i = 0; i < count; i++) {
            +        nfc_ndef_message_get_record(message, i, &record);
            +        nfc_ndef_record_get_payload(record, &payload, &size);
            +        dlog_print(DLOG_INFO, LOG_TAG, "Record Number: %d, Payload: %s", i, payload);
            +    }
             }
             
          • @@ -475,29 +502,28 @@ on_nfc_ndef_discovered(nfc_ndef_message_h message, void *user_data)

            In the registered on_nfc_p2p_target_discovered() callback, check the value of the first parameter, which defines the type of the NFC discovery using the nfc_discovered_type_e enumerator (in mobile and wearable applications). If the type is NFC_DISCOVERED_TYPE_ATTACHED, the remote device is attached to the device:

             if (type == NFC_DISCOVERED_TYPE_ATTACHED)
            -{
            -   // Remote device is attached; execute code
            -}
            +    /* Remote device is attached; execute code */
             
          • Use the nfc_p2p_set_data_received_cb() function to register a callback that is invoked when any data from the connected target is received:

             error_code = nfc_p2p_set_data_received_cb(target, on_nfc_p2p_read_completed, 0);
            -if (NFC_ERROR_NONE != error_code) // Error occurred
            +if (NFC_ERROR_NONE != error_code)
            +    /* Error occurred */
             

            Use the callback to read the received message. You can check its number of records using the nfc_ndef_message_get_record_count() function and get more detailed info about the message itself by calling the nfc_ndef_message_read_cb() function, similarly as with the NFC tag messages described earlier.

            -static void 
            -on_nfc_p2p_read_completed(nfc_p2p_target_h target, nfc_ndef_message_h message, 
            +static void
            +on_nfc_p2p_read_completed(nfc_p2p_target_h target, nfc_ndef_message_h message,
                                       void *user_data)
             {
            -   int count;
            -   dlog_print(DLOG_INFO, LOG_TAG, "on_nfc_p2p_read_completed");
            +    int count;
            +    dlog_print(DLOG_INFO, LOG_TAG, "on_nfc_p2p_read_completed");
             
            -   nfc_ndef_message_get_record_count(message, &count);
            -   nfc_ndef_message_read_cb(clone_message(message));
            +    nfc_ndef_message_get_record_count(message, &count);
            +    nfc_ndef_message_read_cb(clone_message(message));
             }
             
          • @@ -509,67 +535,78 @@ on_nfc_p2p_read_completed(nfc_p2p_target_h target, nfc_ndef_message_h message,
          • The secure element event notification is received through the on_nfc_se_event() callback. The first parameter defines the event type, which determines the additional actions you can take.

            -static void 
            +static void
             on_nfc_se_event(nfc_se_event_e event, void *user_data)
             {
            -   switch (event)
            -   {
            -      case NFC_SE_EVENT_START_TRANSACTION:
            -         // This event notifies the terminal host that it launches
            -         // an application associated with an NFC application in a
            -         // UICC (Universal Integrated Circuit Card) host
            -         dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Start Transaction");
            -         break;
            -      case NFC_SE_EVENT_END_TRANSACTION:
            -         // This event notifies the terminal host that the current transaction
            -         // in process was ended
            -         dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: End Transaction");
            -         break;
            -      case NFC_SE_EVENT_CONNECTIVITY:
            -         // This event is a ready signal for UICC (Universal Integrated Circuit
            -         // Card) to communicate with terminal host. UICC 
            -         // creates a pipe and opens the pipe channel. Then it sends the signal
            -         // to terminal host or host controller
            -         dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Connectivity");
            -         break;
            -      case NFC_SE_EVENT_FIELD_ON:
            -         // When the CLF (Contactless Front-end) detects a 5ra RF field, the card
            -         // RF gate sends the event #NFC_SE_EVENT_FIELD_ON to the card
            -         // application gate. When there are multiple open card RF gates,
            -         // the CLF sends the #NFC_SE_EVENT_FIELD_ON on all open pipes
            -         // to these gates. Next the CLF starts the initialization
            -         // and anti-collision process as defined in ISO/IEC 14443-3 [6]
            -         dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Field ON");
            -         break;
            -      case NFC_SE_EVENT_FIELD_OFF:
            -         // When the CLF (Contactless Front-end) detects that the RF field
            -         // is off, the card RF gate sends the event #NFC_SE_EVENT_FIELD_OFF to
            -         // the card application gate. When there are multiple open card RF
            -         // gates the CLF sends the #NFC_SE_EVENT_FIELD_OFF to one gate
            -         // only
            -         dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Field OFF");
            -         break;
            -      case NFC_SE_EVENT_TRANSACTION:
            -         // This event signals that an external reader is trying to access a secure
            -         // element
            -         dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Remote Start Transaction");
            -         break;
            -      default:
            -         dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: DEFAULT:OTHER");
            -         break;
            -   }
            -} 
            +    switch (event) {
            +    case NFC_SE_EVENT_START_TRANSACTION:
            +        /*
            +           This event notifies the terminal host that it launches
            +           an application associated with an NFC application in a
            +           UICC (Universal Integrated Circuit Card) host
            +        */
            +        dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Start Transaction");
            +        break;
            +    case NFC_SE_EVENT_END_TRANSACTION:
            +        /*
            +           This event notifies the terminal host that the current transaction
            +           in process was ended
            +        */
            +        dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: End Transaction");
            +        break;
            +    case NFC_SE_EVENT_CONNECTIVITY:
            +        /*
            +           This event is a ready signal for UICC (Universal Integrated Circuit
            +           Card) to communicate with terminal host. UICC
            +           creates a pipe and opens the pipe channel. Then it sends the signal
            +           to terminal host or host controller
            +        */
            +        dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Connectivity");
            +        break;
            +    case NFC_SE_EVENT_FIELD_ON:
            +        /*
            +           When the CLF (Contactless Front-end) detects a 5ra RF field, the card
            +           RF gate sends the event #NFC_SE_EVENT_FIELD_ON to the card
            +           application gate. When there are multiple open card RF gates,
            +           the CLF sends the #NFC_SE_EVENT_FIELD_ON on all open pipes
            +           to these gates. Next the CLF starts the initialization
            +           and anti-collision process as defined in ISO/IEC 14443-3 [6]
            +        */
            +        dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Field ON");
            +        break;
            +    case NFC_SE_EVENT_FIELD_OFF:
            +        /*
            +           When the CLF (Contactless Front-end) detects that the RF field
            +           is off, the card RF gate sends the event #NFC_SE_EVENT_FIELD_OFF to
            +           the card application gate. When there are multiple open card RF
            +           gates the CLF sends the #NFC_SE_EVENT_FIELD_OFF to one gate
            +           only
            +        */
            +        dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Field OFF");
            +        break;
            +    case NFC_SE_EVENT_TRANSACTION:
            +        /*
            +           This event signals that an external reader is trying to access a secure
            +           element
            +        */
            +        dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: Remote Start Transaction");
            +        break;
            +    default:
            +        dlog_print(DLOG_INFO, LOG_TAG, "NFC EVENT: DEFAULT:OTHER");
            +        break;
            +    }
            +}
             
          • The secure element transaction event gives you 4 information parameters and user data. You can get the application ID (specified in ISO/IEC 7816-4), the size of aid, the parameter list (specified in ISO/IEC 8825-1), and the size of the parameter.

            -static void 
            -on_nfc_se_transaction_event(nfc_se_type_e se_type, unsigned char *aid, int aid_size, 
            +static void
            +on_nfc_se_transaction_event(nfc_se_type_e se_type, unsigned char *aid, int aid_size,
                                         unsigned char *param, int param_size, void *user_data)
             {
            -   dlog_print(DLOG_INFO, LOG_TAG, 
            -              "Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event data");
            +    dlog_print(DLOG_INFO, LOG_TAG,
            +               "Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event data");
             }
             
          • @@ -589,21 +626,20 @@ nfc_manager_set_tag_filter(NFC_TAG_FILTER_ALL_ENABLE);
          • Enable the NFC system handler:
             if (nfc_manager_is_system_handler_enabled() != true)
            -   nfc_manager_set_system_handler_enable(true);
            +    nfc_manager_set_system_handler_enable(true);
             
          • Get the cached message by calling the nfc_manager_get_cached_message() function. Pass a variable of the nfc_ndef_message_h type, which is fulfilled with the cached message by the function.
             nfc_ndef_message_h message = NULL;
             
             error_code = nfc_manager_get_cached_message(&message);
            -if (NFC_ERROR_NONE != error_code) // Error occurred
            +if (NFC_ERROR_NONE != error_code)
            +    /* Error occurred */
             

            After getting the message, get the detailed information from the message as described in Working with NFC Connections and Messages. First check whether there are any errors and that the message is not NULL:

             if (message != NULL)
            -{
            -   on_nfc_ndef_discovered(clone_message(message), NULL);
            -}
            +    on_nfc_ndef_discovered(clone_message(message), NULL);
             
          • Clean up at the application end.
          • @@ -621,11 +657,10 @@ int ret = NFC_ERROR_NONE; ret = nfc_manager_initialize(); -if (ret != NFC_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_initialize failed: %d", ret); +if (ret != NFC_ERROR_NONE) { +    dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_initialize failed: %d", ret); -   return false; +    return false; } @@ -636,21 +671,17 @@ nfc_se_card_emulation_mode_type_e ce_type; ret = nfc_se_get_card_emulation_mode(&ce_type); -if (ret == NFC_ERROR_NONE && ce_type != true) -{ -   ret = nfc_se_enable_card_emulation(); -   if (ret != NFC_ERROR_NONE) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_enable_card_emulation failed: %d", ret); +if (ret == NFC_ERROR_NONE && ce_type != true) { +    ret = nfc_se_enable_card_emulation(); +    if (ret != NFC_ERROR_NONE) { +        dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_enable_card_emulation failed: %d", ret); -      return false; -   } -} -else -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_get_card_emulation_mode failed: %d", ret); +        return false; +    } +} else { +    dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_get_card_emulation_mode failed: %d", ret); -   return false; +    return false; }
          • Specify an AID value for the application:

            @@ -659,14 +690,14 @@ else

            To tell the platform which AID groups are requested by the application, a metadata element must be included in the manifest file:

             <?xml version="1.0" encoding="utf-8"?>
            -<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.1" 
            +<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.1"
                       package="org.tizen.basicuiapplication" version="1.0.0">
                <profile name="wearable" />
            -   <ui-application appid="org.tizen.basicuiapplication" exec="basicuiapplication" 
            +   <ui-application appid="org.tizen.basicuiapplication" exec="basicuiapplication"
                                type="capp" multiple="false" taskmanage="true" nodisplay="false">
                   <icon>basicuiapplication.png</icon>
                   <label>basicuiapplication</label>
            -      <metadata key="http://tizen.org/metadata/nfc_cardemulation" 
            +      <metadata key="http://tizen.org/metadata/nfc_cardemulation"
                             value="/shared/res/wallet.xml"/>
                </ui-application>
             </manifest>
            @@ -683,7 +714,7 @@ else
             <application name="org.tizen.basicuiapplication">
                <wallet>
                   <aid-group category="payment">
            -         <aid aid="325041592E5359532E4444463031" 
            +         <aid aid="325041592E5359532E4444463031"
                           se_type="hce" unlock="false" power="sleep"/>
                   </aid-group>
                </wallet>
            @@ -704,8 +735,7 @@ else
             
          • sleep: The card can work when the device is in the sleep mode.
        - -
      • The http://tizen.org/privilege/nfc.cardemulation privilege is required for the HCE API. Add the privilege to the tizen-manifest.xml file.
      • +
      • To create a host-based card emulation (HCE) application:
          @@ -715,141 +745,127 @@ else

          Use the nfc_hce_send_apdu_response() function to send a response to the NFC reader. The actual data moving between the NFC reader and the application can be anything. The APDU protocol only defines a promise between the application producer and NFC reader.

          -static void 
          +static void
           _hce_event_cb(nfc_se_h handle, nfc_hce_event_type_e event,
                         unsigned char *apdu, unsigned int apdu_len, void *user_data)
           {
          -   switch (event)
          -   {
          -      case NFC_HCE_EVENT_DEACTIVATED:
          -         // Do something when NFC_HCE_EVENT_DEACTIVATED event arrives
          -         // When the event arrives, apdu and apdu len is NULL and 0
          -         break;
          -
          -      case NFC_HCE_EVENT_ACTIVATED:
          -         // Do something when NFC_HCE_EVENT_ACTIVATED event arrives
          -         // When the event arrives, apdu and apdu len is NULL and 0
          -         break;
          -
          -      case NFC_HCE_EVENT_APDU_RECEIVED:
          -      {
          -         unsigned char resp[] = {0x00, 0x01, 0x02, 0x03};
          -
          -         // Do something when NFC_HCE_EVENT_APDU_RECEIVED event arrives
          -         // You can use the arrival apdu and apdu_len
          -         // and send a response to the NFC reader
          -
          -         nfc_hce_send_apdu_response(handle, NULL, 4);
          -      }
          -         break;
          -
          -      default:
          -         // Error handling
          -         break;
          -   }
          +    switch (event) {
          +    case NFC_HCE_EVENT_DEACTIVATED:
          +        /*
          +           Do something when NFC_HCE_EVENT_DEACTIVATED event arrives
          +           When the event arrives, apdu and apdu len is NULL and 0
          +        */
          +        break;
          +    case NFC_HCE_EVENT_ACTIVATED:
          +        /*
          +           Do something when NFC_HCE_EVENT_ACTIVATED event arrives
          +           When the event arrives, apdu and apdu len is NULL and 0
          +        */
          +        break;
          +    case NFC_HCE_EVENT_APDU_RECEIVED:
          +        unsigned char resp[] = {0x00, 0x01, 0x02, 0x03};
          +
          +        /*
          +           Do something when NFC_HCE_EVENT_APDU_RECEIVED event arrives
          +           You can use the arrival apdu and apdu_len
          +           and send a response to the NFC reader
          +        */
          +
          +        nfc_hce_send_apdu_response(handle, NULL, 4);
          +        break;
          +    default:
          +        /* Error handling */
          +        break;
          +    }
           }
           
           ret = nfc_manager_set_hce_event_cb(_hce_event_cb, NULL);
           
          -if (ret != NFC_ERROR_NONE)
          -{
          -   dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_set_hce_event_cb failed: %d", ret);
          +if (ret != NFC_ERROR_NONE) {
          +    dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_set_hce_event_cb failed: %d", ret);
           
          -   return false;
          +    return false;
           }
           
        1. Implement optional HCE features:
          • To determine whether the application is an active handler for a specific AID or category, use the nfc_se_is_activated_handler_for_aid() and nfc_se_is_activated_handler_for_category() functions: -
            int ret = NFC_ERROR_NONE;
            +
            +int ret = NFC_ERROR_NONE;
             const char aid[] = {0x00, 0x01, 0x02, 0x03};
             bool is_activated_handler = false;
             
             ret = nfc_se_is_activated_handler_for_aid(NFC_SE_TYPE_HCE, aid, &is_activated_handler);
             
            -if (ret != NFC_ERROR_NONE)
            -{
            -   if (is_activated_handler == true)
            -   {
            -      dlog_print(DLOG_INFO, LOG_TAG, "is_activate_handler is true");
            -      // Do something 
            -   }
            -   else
            -   {
            -      dlog_print(DLOG_INFO, LOG_TAG, "is_activate_handler is false");
            -      // Do something 
            -   }
            -}
            -else
            -{
            -   dlog_print(DLOG_ERROR, LOG_TAG, 
            -              "nfc_se_is_activated_handler_for_aid failed: %d", ret);
            +if (ret != NFC_ERROR_NONE) {
            +    if (is_activated_handler == true) {
            +        dlog_print(DLOG_INFO, LOG_TAG, "is_activate_handler is true");
            +        /* Do something */
            +    } else {
            +        dlog_print(DLOG_INFO, LOG_TAG, "is_activate_handler is false");
            +        /* Do something */
            +    }
            +} else {
            +    dlog_print(DLOG_ERROR, LOG_TAG,
            +               "nfc_se_is_activated_handler_for_aid failed: %d", ret);
             }
             
            -ret = nfc_se_is_activated_handler_for_category(NFC_SE_TYPE_HCE, 
            +ret = nfc_se_is_activated_handler_for_category(NFC_SE_TYPE_HCE,
                                                            NFC_CARD_EMULATION_CATEGORY_PAYMENT,
                                                            &is_activated_handler);
             
            -if (ret != NFC_ERROR_NONE)
            -{
            -   if (is_activated_handler == true)
            -   {
            -      dlog_print(DLOG_INFO, LOG_TAG, "is_activate_handler is true");
            -      // Do something 
            -   }
            -   else
            -   {
            -      dlog_print(DLOG_INFO, LOG_TAG, "is_activate_handler is false");
            -      // Do something 
            -   }
            -}
            -else
            -{
            -   dlog_print(DLOG_ERROR, LOG_TAG, 
            -              "nfc_se_is_activated_handler_for_category failed: %d", ret);
            +if (ret != NFC_ERROR_NONE) {
            +    if (is_activated_handler == true) {
            +        dlog_print(DLOG_INFO, LOG_TAG, "is_activate_handler is true");
            +        /* Do something */
            +    } else {
            +        dlog_print(DLOG_INFO, LOG_TAG, "is_activate_handler is false");
            +        /* Do something */
            +    }
            +} else {
            +    dlog_print(DLOG_ERROR, LOG_TAG,
            +               "nfc_se_is_activated_handler_for_category failed: %d", ret);
             }
             
          • -
          • To register or unregister the AID at application runtime, use the nfc_se_register_aid() and nfc_se_unregister_aid() functions: -
            int ret = NFC_ERROR_NONE;
            +
          • To register or deregister the AID at application runtime, use the nfc_se_register_aid() and nfc_se_unregister_aid() functions: +
            +int ret = NFC_ERROR_NONE;
             const char aid[] = {0x0A, 0x0B, 0x0C, 0x0D};
             
             ret = nfc_se_register_aid(NFC_SE_TYPE_HCE, NFC_CARD_EMULATION_CATEGORY_OTHER, aid);
             
            -if (ret != NFC_ERROR_NONE)
            -{
            -   dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_register_aid failed: %d", ret);
            +if (ret != NFC_ERROR_NONE) {
            +    dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_register_aid failed: %d", ret);
             
            -   return false;
            +    return false;
             }
             
             ret = nfc_se_unregister_aid(NFC_SE_TYPE_HCE, NFC_CARD_EMULATION_CATEGORY_OTHER, aid);
             
            -if (ret != NFC_ERROR_NONE)
            -{
            -   dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_unregister_aid failed: %d", ret);
            +if (ret != NFC_ERROR_NONE) {
            +    dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_unregister_aid failed: %d", ret);
             
            -   return false;
            +    return false;
             }
             
          • To check whether the application has a registered AID (including a registered AID at the install time), use the nfc_se_foreach_registered_aids() function (the callback is called for each AID value separately):
            -static void 
            -_registered_aid_cb(nfc_se_type_e se_type, const char *aid, 
            +static void
            +_registered_aid_cb(nfc_se_type_e se_type, const char *aid,
                                bool read_only, void *user_data)
             {
            -   dlog_print(DLOG_INFO, LOG_TAG, "registered_aids callback is called");
            -   // Do something
            +    dlog_print(DLOG_INFO, LOG_TAG, "registered_aids callback is called");
            +    /* Do something */
             }
             
            -ret = nfc_se_foreach_registered_aids(NFC_SE_TYPE_HCE, NFC_CARD_EMULATION_CATEGORY_OTHER, 
            +ret = nfc_se_foreach_registered_aids(NFC_SE_TYPE_HCE, NFC_CARD_EMULATION_CATEGORY_OTHER,
                                                  _registered_aid_cb, NULL);
             
            -if (ret != NFC_ERROR_NONE)
            -{
            -   dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_foreach_registered_aids failed: %d", ret);
            -  
            -   return false;
            +if (ret != NFC_ERROR_NONE) {
            +    dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_foreach_registered_aids failed: %d", ret);
            + 
            +    return false;
             }
             

            When an application receives an app control event, the application can receive the AID value using the data app control extra key.

          • @@ -862,16 +878,11 @@ nfc_manager_unset_hce_event_cb(); ret = nfc_manager_deinitialize(); if (ret != NFC_ERROR_NONE) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_deinitialize failed: %d", ret); -} +    dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_deinitialize failed: %d", ret);
          • -
        -
      • - - +

        The following example shows the entire HCE application sample code:

        @@ -879,145 +890,198 @@ if (ret != NFC_ERROR_NONE)
         #include <nfc.h>
         #include <dlog.h>
         
        -static void 
        +static void
         _hce_event_cb(nfc_se_h handle, nfc_hce_event_type_e event,
                       unsigned char *apdu, unsigned int apdu_len, void *user_data)
         {
        -   switch (event)
        -   {
        -      case NFC_HCE_EVENT_DEACTIVATED:
        -         // Do something when NFC_HCE_EVENT_DEACTIVATED event arrives
        -         // When the event arrives, apdu and apdu len is NULL and 0
        -         break;
        -
        -      case NFC_HCE_EVENT_ACTIVATED:
        -         // Do something when NFC_HCE_EVENT_ACTIVATED event arrives
        -         // When the event arrives, apdu and apdu len is NULL and 0
        -         break;
        -
        -      case NFC_HCE_EVENT_APDU_RECEIVED:
        -      {
        -         unsigned char resp[] = {0x00, 0x01, 0x02, 0x03};
        -
        -         // Do something when NFC_HCE_EVENT_APDU_RECEIVED event arrives
        -         // You can use the arrival apdu and apdu_len
        -         // and send a response to the NFC reader
        -
        -         nfc_hce_send_apdu_response(handle, resp, 4);
        -      }
        -         break;
        -
        -      default:
        -         // Error handling
        -         break;
        -   }
        +    switch (event) {
        +    case NFC_HCE_EVENT_DEACTIVATED:
        +        /*
        +           Do something when NFC_HCE_EVENT_DEACTIVATED event arrives
        +           When the event arrives, apdu and apdu len is NULL and 0
        +        */
        +        break;
        +    case NFC_HCE_EVENT_ACTIVATED:
        +        /*
        +           Do something when NFC_HCE_EVENT_ACTIVATED event arrives
        +           When the event arrives, apdu and apdu len is NULL and 0
        +        */
        +        break;
        +    case NFC_HCE_EVENT_APDU_RECEIVED:
        +        unsigned char resp[] = {0x00, 0x01, 0x02, 0x03};
        +
        +        /*
        +           Do something when NFC_HCE_EVENT_APDU_RECEIVED event arrives
        +           You can use the arrival apdu and apdu_len
        +           and send a response to the NFC reader
        +        */
        +
        +        nfc_hce_send_apdu_response(handle, resp, 4);
        +        break;
        +    default:
        +        /* Error handling */
        +        break;
        +    }
         }
         
        -bool 
        +bool
         service_app_create(void *data)
         {
        -   int ret = NFC_ERROR_NONE;
        -   nfc_se_card_emulation_mode_type_e ce_type;
        +    int ret = NFC_ERROR_NONE;
        +    nfc_se_card_emulation_mode_type_e ce_type;
         
        -   ret = nfc_manager_initialize();
        +    ret = nfc_manager_initialize();
         
        -   if (ret != NFC_ERROR_NONE)
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_initialize failed: %d", ret);
        +    if (ret != NFC_ERROR_NONE) {
        +        dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_initialize failed: %d", ret);
         
        -      return false;
        -   }
        +        return false;
        +    }
         
        -   // App control
        +    /* App control */
         
        -   ret = nfc_se_get_card_emulation_mode(&ce_type);
        +    ret = nfc_se_get_card_emulation_mode(&ce_type);
         
        -   if (ret == NFC_ERROR_NONE && ce_type != true)
        -   {
        -      nfc_se_enable_card_emulation();
        -      if (ret != NFC_ERROR_NONE)
        -      {
        -         dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_enable_card_emulation failed: %d", ret);
        +    if (ret == NFC_ERROR_NONE && ce_type != true) {
        +        nfc_se_enable_card_emulation();
        +        if (ret != NFC_ERROR_NONE) {
        +            dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_enable_card_emulation failed: %d", ret);
         
        -         return false;
        -      }
        -   }
        -   else
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_get_card_emulation_mode failed: %d", ret);
        +            return false;
        +        }
        +    } else {
        +        dlog_print(DLOG_ERROR, LOG_TAG, "nfc_se_get_card_emulation_mode failed: %d", ret);
         
        -      return false;
        -   }
        +        return false;
        +    }
         
        -   ret = nfc_manager_set_hce_event_cb(_hce_event_cb, NULL);
        +    ret = nfc_manager_set_hce_event_cb(_hce_event_cb, NULL);
         
        -   if (ret != NFC_ERROR_NONE)
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_set_hce_event_cb failed: %d", ret);
        +    if (ret != NFC_ERROR_NONE) {
        +        dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_set_hce_event_cb failed: %d", ret);
         
        -      return false;
        -   }
        +        return false;
        +    }
         
        -   return true;
        +    return true;
         }
         
        -void 
        +void
         service_app_terminate(void *data)
         {
        -   int ret = NFC_ERROR_NONE;
        +    int ret = NFC_ERROR_NONE;
         
        -   nfc_manager_unset_hce_event_cb();
        +    nfc_manager_unset_hce_event_cb();
         
        -   ret = nfc_manager_deinitialize();
        -   if (ret != NFC_ERROR_NONE)
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_deinitialize failed: %d", ret);
        -   }
        +    ret = nfc_manager_deinitialize();
        +    if (ret != NFC_ERROR_NONE)
        +        dlog_print(DLOG_ERROR, LOG_TAG, "nfc_manager_deinitialize failed: %d", ret);
         
        -   return;
        +    return;
         }
         
        -void 
        +void
         service_app_control(app_control_h app_control, void *data)
         {
        -   // Todo: add your code here
        -	
        -   return;
        +    /* Todo: add your code here */
        +
        +    return;
         }
         
        -void 
        +void
         service_app_low_memory_callback(void *data)
         {
        -   // Todo: add your code here
        -   service_app_exit();
        +    /* Todo: add your code here */
        +    service_app_exit();
         
        -   return;
        +    return;
         }
         
        -void 
        +void
         service_app_low_battery_callback(void *data)
         {
        -   // Todo: add your code here
        -   service_app_exit();
        +    /* Todo: add your code here */
        +    service_app_exit();
         
        -   return;
        +    return;
         }
         
        -int 
        +int
         main(int argc, char* argv[])
         {
        -   char ad[50] = {0,};
        -   service_app_event_callback_s event_callback;
        +    char ad[50] = {0,};
        +    service_app_event_callback_s event_callback;
         
        -   event_callback.create = service_app_create;
        -   event_callback.terminate = service_app_terminate;
        -   event_callback.app_control = service_app_control;
        -   event_callback.low_memory = service_app_low_memory_callback;
        -   event_callback.low_battery = service_app_low_battery_callback;
        +    event_callback.create = service_app_create;
        +    event_callback.terminate = service_app_terminate;
        +    event_callback.app_control = service_app_control;
        +    event_callback.low_memory = service_app_low_memory_callback;
        +    event_callback.low_battery = service_app_low_battery_callback;
         
        -   return service_app_main(argc, argv, &event_callback, ad);
        +    return service_app_main(argc, argv, &event_callback, ad);
         }
         
        + +
      • To create a preferred application: +

        You can register your application as a preferred handler through the Preferred API. Instead of the default handler selected in the NFC settings (the wallet application), the preferred handler receives a card emulation event.

        + +

        The Preferred API has 2 functions, which can be called when the application is on the foreground:

        + +
          +
        • Call the nfc_se_set_preferred_handler() function when the application is resumed from the paused state.
        • +
        • Call the nfc_se_unset_preferred_handler() function when the application is paused.
        • +
        + + + + + + + + + + +
        Note
        The Preferred API is available since Tizen 3.0. +

        Because of security issues, the API usage policy is different for each Tizen device. For example, if the application is in the payment category, using this API can be prohibited depending on the device.

        +
        +

        The following example shows the entire preferred application sample code:

        +
        +static void
        +_on_resume_cb(void *user_data)
        +{
        +    int ret;
        +    ret = nfc_se_set_preferred_handler();
        +    if (ret != NFC_ERROR_NONE)
        +        dlog_print("Set preferred handler failed! %s", get_error_message(ret));
        +}
        +
        +static void
        +_on_pause_cb(void *user_data)
        +{
        +    int ret;
        +    ret = nfc_se_unset_preferred_handler();
        +    if (ret != NFC_ERROR_NONE)
        +        dlog_print("Unset preferred handler failed! %s", get_error_message(ret));
        +}
        +
        +int
        +app_run(app_data *user_data, int argc, char **argv)
        +{
        +    ui_app_lifecycle_callback_s cbs =
        +    {
        +        .create = _on_create_cb,
        +        .terminate = _on_terminate_cb,
        +        .pause = _on_pause_cb,
        +        .resume = _on_resume_cb,
        +        .app_control = _on_app_control_cb,
        +    };
        +
        +    return ui_app_main(argc, argv, &cbs, user_data);
        +}
        +
        + +
      • +

        Using the NFC Application Control

        @@ -1050,10 +1114,10 @@ main(int argc, char* argv[])

        To tell the platform that your application is registered for the operation, add the applicable operations to the manifest file:

         <?xml version="1.0" encoding="utf-8"?>
        -<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.1" 
        +<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.1"
                   package="org.tizen.basicuiapplication" version="1.0.0">
            <profile name="wearable" />
        -   <ui-application appid="org.tizen.basicuiapplication" exec="basicuiapplication" 
        +   <ui-application appid="org.tizen.basicuiapplication" exec="basicuiapplication"
                            type="capp" multiple="false" taskmanage="true" nodisplay="false">
               <icon>basicuiapplication.png</icon>
               <label>basicuiapplication</label>
        @@ -1071,35 +1135,35 @@ main(int argc, char* argv[])
         
         #define NFC_APPCONTROL_STRING "http://tizen.org/appcontrol/operation/nfc/card_emulation/host_apdu_service"
         
        -bool 
        +bool
         service_app_control(app_control_h service, void *data)
         {
        -   struct _appdata *ad = data;
        -   char *operation, *aid;
        -   int ret = 0;
        -
        -   app_control_get_operation(service, &operation);
        -   if ((strncmp(operation, NFC_APPCONTROL_STRING, strlen(NFC_APPCONTROL_STRING)) == 0)) 
        -   {
        -      dlog_print(DLOG_INFO, "HCETESTAPP", "nfc appcontrol operation: [%s]", operation);
        -      app_control_get_extra_data(service, "data", &aid);
        -      dlog_print(DLOG_INFO, "HCETESTAPP", "nfc appcontrol uri: [%s]", aid);
        -   }
        +    struct _appdata *ad = data;
        +    char *operation;
        +    char *aid;
        +    int ret = 0;
        +
        +    app_control_get_operation(service, &operation);
        +    if ((strncmp(operation, NFC_APPCONTROL_STRING, strlen(NFC_APPCONTROL_STRING)) == 0)) {
        +        dlog_print(DLOG_INFO, "HCETESTAPP", "nfc appcontrol operation: [%s]", operation);
        +        app_control_get_extra_data(service, "data", &aid);
        +        dlog_print(DLOG_INFO, "HCETESTAPP", "nfc appcontrol uri: [%s]", aid);
        +    }
         }
         
        -int 
        +int
         main(int argc, char* argv[])
         {
        -   char ad[50] = {0,};
        -   service_app_event_callback_s event_callback;
        - 
        -   event_callback.create = service_app_create;
        -   event_callback.terminate = service_app_terminate;
        -   event_callback.app_control = service_app_control;
        -   event_callback.low_memory = service_app_low_memory_callback;
        -   event_callback.low_battery = service_app_low_battery_callback;
        +    char ad[50] = {0,};
        +    service_app_event_callback_s event_callback;
         
        -   return service_app_main(argc, argv, &event_callback, ad);
        +    event_callback.create = service_app_create;
        +    event_callback.terminate = service_app_terminate;
        +    event_callback.app_control = service_app_control;
        +    event_callback.low_memory = service_app_low_memory_callback;
        +    event_callback.low_battery = service_app_low_battery_callback;
        +
        +    return service_app_main(argc, argv, &event_callback, ad);
         }
         
        @@ -1133,14 +1197,10 @@ nfc_manager_initialize();
      • After the initialization of the NFC manager, ensure that NFC is supported and activated on the device. The nfc_manager_is_supported() function checks whether NFC is supported. The nfc_manager_is_activated() function gets the NFC activation state.

        -if (!nfc_manager_is_supported()) 
        -{
        -   // Report error, end the application
        -}
        -if (!nfc_manager_is_activated()) 
        -{
        -   // Report error, ask the user to switch on NFC
        -}
        +if (!nfc_manager_is_supported())
        +    /* Report error, end the application */
        +if (!nfc_manager_is_activated())
        +    /* Report error, ask the user to switch on NFC */
         
      • At the end of the application life-cycle, call the nfc_manager_deinitialize() function. It releases all resources of the NFC manager and disconnects the session between it and your application.

        diff --git a/org.tizen.tutorials/html/native/network/smartcard_tutorial_n.htm b/org.tizen.tutorials/html/native/network/smartcard_tutorial_n.htm index fd665d2..dc6df36 100644 --- a/org.tizen.tutorials/html/native/network/smartcard_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/network/smartcard_tutorial_n.htm @@ -23,6 +23,7 @@

        Content

        - + +

        Prerequisites

        + +

        To use the Smartcard API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

        +
        +<privileges>
        +   <privilege>http://tizen.org/privilege/secureelement</privilege>
        +</privileges>
        +
        +

        Using the SE Service

        To use the SE service:

        @@ -72,8 +82,6 @@
         #include <smartcard.h>
         
      • -
      • Add the http://tizen.org/privilege/secureelement privilege to the manifest file of the application.

        -
      • Initialize the smart card service for use:

        @@ -81,18 +89,18 @@ int ret;
         ret = smartcard_initialize();
         
         if (ret == SMARTCARD_ERROR_NONE)
        -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard initialize successful");
        +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard initialize successful");
         else
        -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard initialize failed");
        +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard initialize failed");
         

        When the service is no longer needed, deinitialize it:

         ret = smartcard_deinitialize();
         
         if (ret == SMARTCARD_ERROR_NONE)
        -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard deinitialize successful");
        +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard deinitialize successful");
         else
        -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard deinitialize failed");
        +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard deinitialize failed");
         
      • @@ -103,18 +111,15 @@ int *phReaders = NULL; ret = smartcard_get_readers(&phReaders, &pLength); -if (ret == SMARTCARD_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_get_readers successful"); -   dlog_print(DLOG_INFO, LOG_TAG, "readers length: %d", pLength); -} -else -{ -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_get_readers failed: %d", ret); +if (ret == SMARTCARD_ERROR_NONE) { +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_get_readers successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "readers length: %d", pLength); +} else { +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_get_readers failed: %d", ret); } -if(phReaders != NULL) -   free(phReaders); +if (phReaders != NULL) +    free(phReaders); @@ -126,18 +131,15 @@ if(phReaders != NULL)

        Retrieve the name of the reader with the smartcard_reader_get_name() function:

         int ret;
        -int reader = phReaders[0]; // Get the reader using smartcard_get_readers()
        +int reader = phReaders[0]; /* Get the reader using smartcard_get_readers() */
         char * pReader = NULL;
         
         ret = smartcard_reader_get_name(reader, &pReader);
        -if (ret == SMARTCARD_ERROR_NONE)
        -{
        -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_get_name successful");
        -   dlog_print(DLOG_INFO, LOG_TAG, "reader name: %s", pReader);
        -}
        -else
        -{
        -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_get_name failed: %d", ret);
        +if (ret == SMARTCARD_ERROR_NONE) {
        +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_get_name successful");
        +    dlog_print(DLOG_INFO, LOG_TAG, "reader name: %s", pReader);
        +} else {
        +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_get_name failed: %d", ret);
         }
         
        @@ -148,14 +150,11 @@ else bool is_present = false; ret = smartcard_reader_is_secure_element_present(reader, &is_present); -if (ret == SMARTCARD_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_is_secure_element_present successful"); -   dlog_print(DLOG_INFO, LOG_TAG, "reader secure element present: %d", is_present); -} -else -{ -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_is_secure_element_present failed: %d", ret); +if (ret == SMARTCARD_ERROR_NONE) { +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_is_secure_element_present successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "reader secure element present: %d", is_present); +} else { +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_is_secure_element_present failed: %d", ret); } @@ -167,21 +166,14 @@ else int session; ret = smartcard_reader_open_session(reader, &session); -if (ret == SMARTCARD_ERROR_NONE) -{ -   ret = smartcard_reader_close_sessions(reader); -   if (ret == SMARTCARD_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_close_sessions successful"); -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_close_sessions failed: %d", ret); -   } -} -else -{ -   dlog_print(DLOG_INFO, LOG_TAG, "open session failed: %d", ret); +if (ret == SMARTCARD_ERROR_NONE) { +    ret = smartcard_reader_close_sessions(reader); +    if (ret == SMARTCARD_ERROR_NONE) +        dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_close_sessions successful"); +    else +        dlog_print(DLOG_INFO, LOG_TAG, "smartcard_reader_close_sessions failed: %d", ret); +} else { +    dlog_print(DLOG_INFO, LOG_TAG, "open session failed: %d", ret); } @@ -194,19 +186,17 @@ else

        To manage sessions:

        • Retrieve the reader that provides the session: -
          int ret;
          +
          +int ret;
           int reader;
           
           ret = smartcard_session_get_reader(session, &reader);
           ret = smartcard_reader_get_name(reader, &pReader);
          -if (ret == SMARTCARD_ERROR_NONE)
          -{
          -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_get_reader successful");
          -   dlog_print(DLOG_INFO, LOG_TAG, "reader name: %s", pReader);
          -}
          -else
          -{
          -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_get_reader failed");
          +if (ret == SMARTCARD_ERROR_NONE) {
          +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_get_reader successful");
          +    dlog_print(DLOG_INFO, LOG_TAG, "reader name: %s", pReader);
          +} else {
          +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_get_reader failed");
           }
           
        • Retrieve the answer to reset (ATR) of the SE: @@ -218,15 +208,12 @@ int pLength; ret = smartcard_session_get_atr(session, &pAtr, &pLength); -if (ret == SMARTCARD_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_get_atr successful: %d", pLength); -   for (i = 0; i < pLength; i++) -      dlog_print(DLOG_INFO, LOG_TAG, "%x ", (int)pAtr[i]); -} -else -{ -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_get_atr failed"); +if (ret == SMARTCARD_ERROR_NONE) { +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_get_atr successful: %d", pLength); +    for (i = 0; i < pLength; i++) +        dlog_print(DLOG_INFO, LOG_TAG, "%x ", (int)pAtr[i]); +} else { +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_get_atr failed"); }
        • Open a basic or logical channel. @@ -236,21 +223,21 @@ int ret; unsigned char aid[] = {0x00, 0x01, 0x02, 0x03}; int channel; -// Open basic channel +/* Open basic channel */ ret = smartcard_session_open_basic_channel(session, aid, 4, 0x00, &channel); if (ret == SMARTCARD_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_open_basic_channel successful: %d", channel); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_open_basic_channel successful: %d", channel); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_open_basic_channel failed"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_open_basic_channel failed"); -// Open logical channel +/* Open logical channel */ ret = smartcard_session_open_logical_channel(session, aid, 12, 0x04, &channel); if (ret == SMARTCARD_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_open_logical_channel successful: %d", (channel); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_open_logical_channel successful: %d", (channel); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_open_logical_channel failed: %d", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_open_logical_channel failed: %d", ret);
        • Close all channels opened for a specific session: @@ -260,9 +247,9 @@ int ret; ret = smartcard_session_close_channels(session); if (ret == SMARTCARD_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_close_channels successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_close_channels successful"); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_close_channels failed"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_close_channels failed");
        • Close a session and check that it is truly closed: @@ -274,16 +261,16 @@ bool is_closed; ret = smartcard_session_close(session); if (ret == SMARTCARD_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_close successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_close successful"); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_close failed"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_close failed"); ret = smartcard_session_is_closed(session, &is_closed); if (ret == SMARTCARD_ERROR_NONE && is_closed == true) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_is_closed successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_is_closed successful"); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_is_closed failed"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_session_is_closed failed");
        @@ -295,18 +282,18 @@ else
        • Retrieve the session that has opened the specific channel: -
          int ret;
          +
          +int ret;
           int session_handle;
           
           ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel);
          -if (ret == SMARTCARD_ERROR_NONE)
          -{
          -   ret = smartcard_channel_get_session(channel, &session_handle);
          +if (ret == SMARTCARD_ERROR_NONE) {
          +    ret = smartcard_channel_get_session(channel, &session_handle);
           
          -   if (ret == SMARTCARD_ERROR_NONE)
          -      dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_get_session successful: %d", session_handle);
          -   else
          -      dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_get_session failed");
          +    if (ret == SMARTCARD_ERROR_NONE)
          +        dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_get_session successful: %d", session_handle);
          +    else
          +        dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_get_session failed");
           }
           
        • @@ -318,41 +305,38 @@ bool is_basic; ret = smartcard_channel_is_basic_channel(channel, &is_basic); if (ret == SMARTCARD_ERROR_NONE && is_basic == false) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_is_basic_channel successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_is_basic_channel successful"); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_is_basic_channel failed"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_is_basic_channel failed");
        • Select the next applet on the specific channel that matches to the partial Application ID (AID):
           ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel);
          -if (ret == SMARTCARD_ERROR_NONE)
          -{
          -   bool is_next = true;
          -   ret = smartcard_channel_select_next(channel, &is_next);
          -   if (ret == SMARTCARD_ERROR_NONE && is_next == false)
          -      dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_select_next successful");
          -   else
          -      dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_select_next failed");
          +if (ret == SMARTCARD_ERROR_NONE) {
          +    bool is_next = true;
          +    ret = smartcard_channel_select_next(channel, &is_next);
          +    if (ret == SMARTCARD_ERROR_NONE && is_next == false)
          +        dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_select_next successful");
          +    else
          +        dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_select_next failed");
           }
           

          To get a response for the selection command, use the smartcard_channel_get_select_response() function:

          -int i, ret;
          +int i;
          +int ret;
           unsigned char* pSelectResponse;
           int pLength;
           
           ret = smartcard_channel_get_select_response(channel, &pSelectResponse, &pLength);
           
          -if (ret == SMARTCARD_ERROR_NONE)
          -{
          -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_get_select_response successful");
          -   for (i = 0; i < pLength; i++)
          -      g_print("%x ", (int)pSelectResponse[i]);
          -}
          -else
          -{
          -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_get_select_response failed");
          +if (ret == SMARTCARD_ERROR_NONE) {
          +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_get_select_response successful");
          +    for (i = 0; i < pLength; i++)
          +        g_print("%x ", (int)pSelectResponse[i]);
          +} else {
          +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_get_select_response failed");
           }
           
        • @@ -367,9 +351,9 @@ ret = smartcard_channel_close(channel); ret = smartcard_channel_is_closed(channel, &is_close); if (ret == SMARTCARD_ERROR_NONE && is_close == true) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_is_closed successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_is_closed successful"); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_is_closed failed"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_is_closed failed");
        • Close the channel opened for a specific SE: @@ -378,11 +362,11 @@ else int ret; ret = smartcard_channel_close(channel); - + if (ret == SMARTCARD_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_close successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_close successful"); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_close failed: %d", ret); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_close failed: %d", ret);
        • Transmit an APDU command (as per ISO/IEC 7816-4) to the SE: @@ -396,17 +380,14 @@ unsigned char command[] = {0x00, 0x01, 0x02, 0x03}; ret = smartcard_channel_transmit(channel, command, 4, &response, &resp_len); -if (ret == SMARTCARD_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit successful"); -   dlog_print(DLOG_INFO, LOG_TAG, "response is "); -   for (i = 0; i < resp_len; i++) -      dlog_print(DLOG_INFO, LOG_TAG, "%x ", (int)response[i]); -   dlog_print(DLOG_INFO, LOG_TAG, "\n"); -} -else -{ -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit failed"); +if (ret == SMARTCARD_ERROR_NONE) { +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "response is "); +    for (i = 0; i < resp_len; i++) +        dlog_print(DLOG_INFO, LOG_TAG, "%x ", (int)response[i]); +    dlog_print(DLOG_INFO, LOG_TAG, "\n"); +} else { +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit failed"); }

          To get a response for the transmission, use the smartcard_channel_transmit_retrieve_response() function:

          @@ -415,23 +396,19 @@ int i; unsigned char * ptransmitResponse; ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); -if (ret == SMARTCARD_ERROR_NONE) -{ -   ret = smartcard_channel_transmit(channel, command, 11, &response, &resp_len); -   ret = smartcard_channel_transmit_retrieve_response(channel, &ptransmitResponse, &pLength); - -   if (ret == SMARTCARD_ERROR_NONE) -   { -      dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit_get_response successful"); -      dlog_print(DLOG_INFO, LOG_TAG, "response is "); -      for (i = 0; i < pLength; i++) -         dlog_print(DLOG_INFO, LOG_TAG, "%x ", (int)ptransmitResponse[i]); -      dlog_print(DLOG_INFO, LOG_TAG, "\n"); -   } -   else -   { -      dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit_get_response failed"); -   } +if (ret == SMARTCARD_ERROR_NONE) { +    ret = smartcard_channel_transmit(channel, command, 11, &response, &resp_len); +    ret = smartcard_channel_transmit_retrieve_response(channel, &ptransmitResponse, &pLength); + +    if (ret == SMARTCARD_ERROR_NONE) { +        dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit_get_response successful"); +        dlog_print(DLOG_INFO, LOG_TAG, "response is "); +        for (i = 0; i < pLength; i++) +            dlog_print(DLOG_INFO, LOG_TAG, "%x ", (int)ptransmitResponse[i]); +        dlog_print(DLOG_INFO, LOG_TAG, "\n"); +    } else { +        dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit_get_response failed"); +    } }
        @@ -456,53 +433,52 @@ int resp_len = 50; ret = smartcard_initialize(); if (ret == SMARTCARD_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard initialize successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard initialize successful"); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard initialize failed"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard initialize failed"); +
      • Get the available readers:
        -ret = smartcard_get_readers(&phReaders, &pLength);
        +ret = smartcard_get_readers(&phReaders, &pLength); +
      • Open a session:
        -if (ret == SMARTCARD_ERROR_NONE && pLength != 0)
        -{
        -   ret = smartcard_reader_open_session(phReaders[0], &session);
        +if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { +    ret = smartcard_reader_open_session(phReaders[0], &session); +
      • Open a logical channel:
        -   if (ret == SMARTCARD_ERROR_NONE && session != 0)
        -   {
        -      ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel);
        +    if (ret == SMARTCARD_ERROR_NONE && session != 0) { +        ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); +
      • Transmit the command:
        -      if (ret == SMARTCARD_ERROR_NONE)
        -      {
        -         ret = smartcard_channel_transmit(channel, command, 4, &response, &resp_len);
        -         if (ret == SMARTCARD_ERROR_NONE)
        -         {
        -            dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit successful");
        -            dlog_print(DLOG_INFO, LOG_TAG, "response is ");
        -            for (i = 0; i < resp_len; i++)
        -               dlog_print(DLOG_INFO, LOG_TAG, "%x ", (int)response[i]);
        -            dlog_print(DLOG_INFO, LOG_TAG, "\n");
        -         }
        -         else
        -         {
        -            dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit failed");
        -         }
        -      }
        -   }
        +        if (ret == SMARTCARD_ERROR_NONE) { +            ret = smartcard_channel_transmit(channel, command, 4, &response, &resp_len); +            if (ret == SMARTCARD_ERROR_NONE) { +                dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit successful"); +                dlog_print(DLOG_INFO, LOG_TAG, "response is "); +                for (i = 0; i < resp_len; i++) +                    dlog_print(DLOG_INFO, LOG_TAG, "%x ", (int)response[i]); +                dlog_print(DLOG_INFO, LOG_TAG, "\n"); +            } else { +                dlog_print(DLOG_INFO, LOG_TAG, "smartcard_channel_transmit failed"); +            } +        } +    } +
      • Close the session:
        -   ret = smartcard_session_close(session);
        +    ret = smartcard_session_close(session);
         }
         
      • @@ -511,9 +487,9 @@ if (ret == SMARTCARD_ERROR_NONE && pLength != 0) ret = smartcard_deinitialize(); if (ret == SMARTCARD_ERROR_NONE) -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard deinitialize successful"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard deinitialize successful"); else -   dlog_print(DLOG_INFO, LOG_TAG, "smartcard deinitialize failed"); +    dlog_print(DLOG_INFO, LOG_TAG, "smartcard deinitialize failed"); diff --git a/org.tizen.tutorials/html/native/network/vpn_tutorial_n.htm b/org.tizen.tutorials/html/native/network/vpn_tutorial_n.htm new file mode 100644 index 0000000..a43ebd6 --- /dev/null +++ b/org.tizen.tutorials/html/native/network/vpn_tutorial_n.htm @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + VPN Service: Using Virtual Private Networks + + + + + + +
        + +

        VPN Service: Using Virtual Private Networks

        + +

        This tutorial demonstrates how you can create and configure the tunnel interface, and get and set the tunnel parameters and data transfer statistics.

        + +

        This feature is supported in mobile applications only.

        + +

        Warm-up

        + +

        Become familiar with the VPN Service API basics by learning about:

        + + + +

        Initializing the VPN Connection

        + +

        To initialize the VPN service for use:

        + +
          +
        1. To use the functions and data types of the VPN Service API, include the <vpn_service.h> header file in your application: +
          +#include <vpn_service.h>
          +
          +
        2. +
        3. To be able to use all VPN functions, you must create a handle that contains information about the VPN. At the beginning, create a vpnsvc_h type variable, which is a void* that stores the VPN handle. +
          +vpnsvc_h handle = NULL;
          +
          +
        4. +
        5. Create the VPN handle using the vpnsvc_init() function that allows you to obtain the VPN state and data transfer information: +
          +char *name = TEST_VPN_IF_NAME;
          +int ret = VPNSVC_ERROR_NONE;
          +
          +ret = vpnsvc_init(name, &handle);
          +
          +if (ret != VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_init failed: %d\n", ret);
          +
          +
        6. +
        7. When the VPN handle is no longer needed, destroy it using the vpnsvc_deinit() function: +
          +if (handle)
          +    vpnsvc_deinit(handle);
          +
          +handle = NULL;
          +
          +
        8. +
        + + +

        Getting Interface Parameters

        + +

        To get the interface parameters after successfully initializing the VPN service:

        +
          +
        • Get the tunnel file descriptor using the vpnsvc_get_tun_fd() function: +
          +int int_value;
          +
          +if (vpnsvc_get_tun_fd(handle, &int_value) == VPNSVC_ERROR_NONE)
          +    printf("tun_fd: %d\n", int_value);
          +
          +
        • +
        • Get the tunnel index using the vpnsvc_get_tun_index() function: +
          +int int_value;
          +
          +if (vpnsvc_get_tun_index(handle, &int_value) == VPNSVC_ERROR_NONE)
          +    printf("tun_index: %d\n", int_value);
          +
          +
        • +
        • Get the tunnel name using the vpnsvc_get_tun_name() function: +
          +char* result_name = NULL;
          +int ret = VPNSVC_ERROR_NONE;
          +
          +ret = vpnsvc_get_tun_name(handle, &result_name);
          +if (ret == VPNSVC_ERROR_NONE)
          +    printf("tun_name: %s\n", result_name);
          +
          +
        • +
        • Get the session for the tunnel interface using the vpnsvc_get_session() function: +
          +int ret = VPNSVC_ERROR_NONE;
          +char *get_session = NULL;
          +
          +ret = vpnsvc_get_session(handle, &get_session);
          +printf("Session Name = %s\n", get_session);
          +printf("vpnsvc_set_session succeeded!\n");
          +
          +
        • +
        + +

        Setting Interface Parameters

        + +

        To set the interface parameters:

        +
          +
        • Set the MTU configuration for the tunnel interface using the vpnsvc_set_mtu() function. The MTU value is used when the user brings up the VPN interface using the VPN UP API. +
          +int ret;
          +
          +ret = vpnsvc_set_mtu(handle, 9000);
          +if (ret != VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_set_mtu failed!\n");
          +else
          +    printf("vpnsvc_set_mtu succeeded!\n");
          +
          +
        • +
        • Set the session name for the tunnel interface using the vpnsvc_set_session() function: +
          +char *set_session = "vpnsvc_test VPN Session";
          +int ret;
          +
          +ret = vpnsvc_set_session(handle, set_session);
          +if (ret != VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_set_session failed!\n");
          +
          +
        • +
        + +

        Configuring the Interface

        + +

        To configure the interface:

        +
          +
        1. Protect the underlying VPN traffic to be routed to the VPN itself by binding the socket to the underlying network interface, such as wlan0: +
          +int sock;
          +int ret;
          +
          +ret = vpnsvc_protect(handle, sock, "wlan0");
          +if (ret != VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_protect failed!\n");
          +else
          +    printf("vpnsvc_protect succeeded!\n");
          +
          +
        2. +
        3. Set up the tunnel interface. +

          The vpnsvc_up() function configures the VPN tunnel interface based on the configured parameters passed by the client application.

          +

          To change the MTU parameter of the configured interface, the client application must invoke the vpnsvc_set_mtu() function that is used to set the MTU value. The client application must invoke the function before the vpnsvc_up() function call.

          +
          +int ret;
          +char local[VPNSVC_IP4_STRING_LEN] = {'\0',};
          +char remote[VPNSVC_IP4_STRING_LEN] = {'\0',};
          +char *routes[2];
          +int prefix[2];
          +int nr_routes = 2;
          +const char *dns_server[2];
          +int nr_dns = 2;
          +char dns_suffix[100] = "tizen.org";
          +
          +if (!handle) {
          +    printf("invalid handle\n");
          +
          +    return -1;
          +}
          +
          +strncpy(local, "192.168.0.82", VPNSVC_IP4_STRING_LEN);
          +strncpy(remote, "192.168.0.1", VPNSVC_IP4_STRING_LEN);
          +
          +routes[0] = malloc(sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +routes[1] = malloc(sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +
          +memset(routes[0], 0, sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +memset(routes[1], 0, sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +
          +strncpy(routes[0], "192.168.0.10", VPNSVC_IP4_STRING_LEN);
          +prefix[0] = 32;
          +
          +strncpy(routes[1], "192.168.0.11", VPNSVC_IP4_STRING_LEN);
          +prefix[1] = 32;
          +
          +char *dns1 = "1.1.1.1";
          +char *dns2 = "2.2.2.2";
          +
          +dns_server[0] = dns1;
          +dns_server[1] = dns2;
          +
          +ret = vpnsvc_up(handle, local, remote, routes, prefix, nr_routes,
          +                dns_server, nr_dns, dns_suffix);
          +
          +if (ret != VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_up failed!\n");
          +else
          +    printf("vpnsvc_up succeeded!\n");
          +
          +
        4. +
        5. Set down the tunnel interface, and remove it using the vpnsvc_down() function: +
          +int ret;
          +
          +if (!handle) {
          +    printf("invalid handle\n");
          +
          +    return -1;
          +}
          +
          +ret = vpnsvc_down(handle);
          +
          +if (ret != VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_down failed!\n");
          +else
          +    printf("vpnsvc_down succeeded!\n");
          +
          +
        6. +
        + +

        Blocking and Unblocking Networks

        + +

        To block or unblock the network:

        +
          +
        • Block all traffic, except specified allowed networks, and send the specified UP addresses to a specified interface: +
          +char* block_nets[2];
          +int block_prefix[2];
          +int block_nr_nets = 2;
          +char* allow_nets[2];
          +int allow_prefix[2];
          +int allow_nr_nets = 2;
          +int ret;
          +
          +if (!handle) {
          +    printf("invalid handle\n");
          +
          +    return -1;
          +}
          +
          +block_nets[0] = malloc(sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +block_nets[1] = malloc(sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +memset(block_nets[0], 0, sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +memset(block_nets[1], 0, sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +strncpy(block_nets[0], "125.209.222.141", VPNSVC_IP4_STRING_LEN);
          +block_prefix[0] = 32;
          +strncpy(block_nets[1], "180.70.134.19", VPNSVC_IP4_STRING_LEN);
          +block_prefix[1] = 32;
          +
          +allow_nets[0] = malloc(sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +allow_nets[1] = malloc(sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +memset(allow_nets[0], 0, sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +memset(allow_nets[1], 0, sizeof(char) * VPNSVC_IP4_STRING_LEN);
          +strncpy(allow_nets[0], "216.58.221.142", VPNSVC_IP4_STRING_LEN);
          +allow_prefix[0] = 32;
          +strncpy(allow_nets[1], "206.190.36.45", VPNSVC_IP4_STRING_LEN);
          +allow_prefix[1] = 32;
          +
          +ret = vpnsvc_block_networks(handle, block_nets, block_prefix, block_nr_nets,
          +                            allow_nets, allow_prefix, allow_nr_nets);
          +
          +if (ret != VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_block_networks failed!\n");
          +else
          +    printf("vpnsvc_block_networks succeeded!\n");
          +
          +
        • +
        • Remove any restrictions from the VPN network: +
          +int ret;
          +
          +if (!handle) {
          +    printf("invalid handle\n");
          +
          +    return -1;
          +}
          +
          +ret = vpnsvc_unblock_networks(handle);
          +
          +if (ret != VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_unblock_networks failed!\n");
          +else
          +    printf("vpnsvc_unblock_networks succeeded!\n");
          +
          +
        • +
        + +

        Reading and Writing Data

        + +

        To read or write data:

        +
          +
        • Check whether there is data to read within a specified time period: +
          +int ret;
          +int timeout_ms = 20;
          +
          +ret = vpnsvc_read(handle, timeout_ms);
          +
          +if (ret == VPNSVC_ERROR_NONE)
          +    printf("vpnsvc_read: Data available to read!\n");
          +
          +
        • +
        • Write data directly to the underlying socket using a system call for performance. The number of bytes written is returned on success (the same as the system write call). +
          +int ret;
          +char *message = "test message";
          +
          +ret = vpnsvc_write(handle, message, strlen(message));
          +
          +if (ret < 0)
          +    printf("vpnsvc_write: failed!\n");
          +else if (ret == 0)
          +    printf("vpnsvc_write: Nothing written!\n");
          +else
          +    printf("vpnsvc_read: %d bytes written!\n", ret);
          +
          +
        • +
        + + + +
        + +Go to top + + + + + + + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/network/wifi_direct_tutorial_n.htm b/org.tizen.tutorials/html/native/network/wifi_direct_tutorial_n.htm index 56baed9..adb2f3a 100644 --- a/org.tizen.tutorials/html/native/network/wifi_direct_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/network/wifi_direct_tutorial_n.htm @@ -23,7 +23,7 @@

        Content

          -
        • Prerequisites +
        • Prerequisites
        • Initializing Wi-Fi Direct™
        • Activating Wi-Fi Direct™
        • Peers and groups @@ -53,7 +53,8 @@

          Warm-up

          Become familiar with the Wi-Fi Direct API basics by learning about:

          - -

          Prerequisites

          -

          To use Wi-Fi Direct™ APIs, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file.

          -
          - <privileges>
          -    <privilege>http://tizen.org/privilege/wifidirect</privilege>
          - </privileges> 
          + +

          Prerequisites

          + +

          To use the Wi-Fi Direct API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

          +
          +<privileges>
          +   <privilege>http://tizen.org/privilege/wifidirect</privilege>
          +</privileges>
          +

          Initializing Wi-Fi Direct™

          @@ -100,9 +103,9 @@ error_code = wifi_direct_initialize();
        • To get the Wi-Fi Direct™ activation and deactivation events, set up the wifi_direct_device_state_changed_cb() callback:

          -void 
          -device_state_changed_cb(wifi_direct_error_e error_code, 
          -                        wifi_direct_device_state_e device_state, 
          +void
          +device_state_changed_cb(wifi_direct_error_e error_code,
          +                        wifi_direct_device_state_e device_state,
                                   void *user_data);
           
           error_code = wifi_direct_set_device_state_changed_cb(device_state_changed_cb, NULL);
          @@ -112,9 +115,9 @@ error_code = wifi_direct_set_device_state_changed_cb(device_state_changed_cb, NU
           
        • To get the Wi-Fi Direct™ discovery events, set up the wifi_direct_discovery_state_changed_cb() callback:

          -void 
          +void
           discovery_state_changed_cb(wifi_direct_error_e error_code,
          -                           wifi_direct_discovery_state_e discovery_state, 
          +                           wifi_direct_discovery_state_e discovery_state,
                                      void *user_data);
           
           error_code = wifi_direct_set_discovery_state_changed_cb(discovery_state_changed_cb, NULL);
          @@ -124,9 +127,9 @@ error_code = wifi_direct_set_discovery_state_changed_cb(discovery_state_changed_
           
        • To get Wi-Fi Direct™ connection events, set up the wifi_direct_connection_state_changed_cb() callback:

          -void 
          -connection_state_changed_cb(wifi_direct_error_e error_code, 
          -                            wifi_direct_connection_state_e connection_state, 
          +void
          +connection_state_changed_cb(wifi_direct_error_e error_code,
          +                            wifi_direct_connection_state_e connection_state,
                                       void *user_data);
           
           error_code = wifi_direct_set_connection_state_changed_cb(connection_state_changed_cb, NULL);
          @@ -142,21 +145,18 @@ error_code = wifi_direct_set_connection_state_changed_cb(connection_state_change
           

          Define the device_state_changed_cb() callback function, which is invoked whenever a Wi-Fi Direct™ local device activates or deactivates. In the following example, an information message is printed in the console.

          -static void 
          -device_state_changed_cb(wifi_direct_error_e error_code, 
          -                        wifi_direct_discovery_state_e discovery_state, 
          +static void
          +device_state_changed_cb(wifi_direct_error_e error_code,
          +                        wifi_direct_discovery_state_e discovery_state,
                                   void *user_data)
           {
          -   if (device_state == WIFI_DIRECT_DEVICE_STATE_ACTIVATED) 
          -   {
          -      printf("Activate Wi-Fi Direct™ device!\n");
          -      // Handle the event
          -   } 
          -   else if (device_state == WIFI_DIRECT_DEVICE_STATE_DEACTIVATED) 
          -   {
          -      printf("Deactivate Wi-Fi Direct™ device!\n");
          -      // Handle the event
          -   }
          +    if (device_state == WIFI_DIRECT_DEVICE_STATE_ACTIVATED) {
          +        printf("Activate Wi-Fi Direct™ device!\n");
          +        /* Handle the event */
          +    } else if (device_state == WIFI_DIRECT_DEVICE_STATE_DEACTIVATED) {
          +        printf("Deactivate Wi-Fi Direct™ device!\n");
          +        /* Handle the event */
          +    }
           }
           
        • @@ -183,34 +183,33 @@ printf("Wi-Fi Direct™ state: %d.\n", state);
          1. Define a callback function for the discovery, to be called when the discovery state is changed:
            -void 
            -discovery_state_changed_cb(wifi_direct_error_e error_code, 
            -                           wifi_direct_discovery_state_e discovery_state, 
            +void
            +discovery_state_changed_cb(wifi_direct_error_e error_code,
            +                           wifi_direct_discovery_state_e discovery_state,
                                        void *user_data)
             {
            -   switch (discovery_state) 
            -   {
            -      case WIFI_DIRECT_ONLY_LISTEN_STARTED:
            -         // Handle the event
            +    switch (discovery_state) {
            +    case WIFI_DIRECT_ONLY_LISTEN_STARTED:
            +        /* Handle the event */
             
            -         return "DISCOVERY_STATE: ONLY_LISTEN_STARTED";
            -      case WIFI_DIRECT_DISCOVERY_STARTED:
            -         // Handle the event
            +        return "DISCOVERY_STATE: ONLY_LISTEN_STARTED";
            +    case WIFI_DIRECT_DISCOVERY_STARTED:
            +        /* Handle the event */
             
            -         return "DISCOVERY_STATE: DISCOVERY_STARTED";
            -      case WIFI_DIRECT_DISCOVERY_FOUND:
            -         // Handle the event
            +        return "DISCOVERY_STATE: DISCOVERY_STARTED";
            +    case WIFI_DIRECT_DISCOVERY_FOUND:
            +        /* Handle the event */
             
            -         return "DISCOVERY_STATE: DISCOVERY_FOUND";
            -      case WIFI_DIRECT_DISCOVERY_FINISHED:
            -         // Handle the event
            +        return "DISCOVERY_STATE: DISCOVERY_FOUND";
            +    case WIFI_DIRECT_DISCOVERY_FINISHED:
            +        /* Handle the event */
             
            -         return "DISCOVERY_STATE: DISCOVERY_FINISHED";
            -      default:
            -         return "UNKNOWN_DISCOVERY_STATE";
            -   }
            +        return "DISCOVERY_STATE: DISCOVERY_FINISHED";
            +    default:
            +        return "UNKNOWN_DISCOVERY_STATE";
            +    }
             
            -   return "UNKNOWN_DISCOVERY_STATE";
            +    return "UNKNOWN_DISCOVERY_STATE";
             }
             
          2. @@ -226,21 +225,18 @@ wifi_direct_start_discovery(false, 0);

            Show the discovery result using the wifi_direct_discovered_peer_cb() callback, which is invoked by the wifi_direct_foreach_discovered_peers() function. In the following example, the Wi-Fi Direct™ peer device information is printed.

            -bool 
            -discovered_peer_cb(wifi_direct_discovered_peer_info_s *peer, void *user_data) 
            +bool
            +discovered_peer_cb(wifi_direct_discovered_peer_info_s *peer, void *user_data)
             {
            -   if (NULL != peer) 
            -   { 
            -      printf("\nDevice Name: %s", peer->device_name);
            -      printf("\nMac Address: %s", peer->mac_address);
            -      // Handle the event
            -
            -      return 1;
            -   } 
            -   else 
            -   {
            -      return false;
            -   }
            +    if (NULL != peer) {
            +        printf("\nDevice Name: %s", peer->device_name);
            +        printf("\nMac Address: %s", peer->mac_address);
            +        /* Handle the event */
            +
            +        return 1;
            +    } else {
            +        return false;
            +    }
             }
             
             int rv = wifi_direct_foreach_discovered_peers(discovered_peer_cb, NULL);
            @@ -257,72 +253,60 @@ int rv = wifi_direct_foreach_discovered_peers(discovered_peer_cb, NULL);
             

            The connection event received from the Wi-Fi Direct™ framework invokes a callback. The following example defines a connection_state_changed_cb() callback to handle all Wi-Fi Direct™ connection events.

            -static void 
            -connection_state_changed_cb(wifi_direct_error_e error_code, 
            -                            wifi_direct_connection_state_e connection_state, 
            -                            const char *mac_address, void *user_data) 
            +static void
            +connection_state_changed_cb(wifi_direct_error_e error_code,
            +                            wifi_direct_connection_state_e connection_state,
            +                            const char *mac_address, void *user_data)
             {
            -   printf("Connection state changed to: [%d] [%s]\n", connection_state, 
            -          test_wfd_convert_connection_state_to_string(connection_state));
            -
            -   bool accept_connection = false;
            -   int rv = 0;
            -
            -   switch (connection_state)
            -   {
            -      case WIFI_DIRECT_CONNECTION_WPS_REQ:
            -      {	
            -         // Outgoing requests
            -         wifi_direct_wps_type_e wps_mode;
            -         wifi_direct_get_local_wps_type(&wps_mode);
            -         // Handle the event	
            -      }
            -         break;
            -      case WIFI_DIRECT_CONNECTION_REQ:
            -      {
            -         // Incoming requests
            -         wifi_direct_wps_type_e wps_mode;
            -         wifi_direct_get_local_wps_type(&wps_mode);
            -         // Handle the event	
            -      }
            -         break;
            -      case WIFI_DIRECT_INVITATION_REQ:
            -      {
            -         // Invitation request from peer
            -         // Handle the event
            -      }
            -         break;
            -      case WIFI_DIRECT_DISASSOCIATION_IND:
            -      case WIFI_DIRECT_DISCONNECTION_IND:
            -         printf("Peer: [%s] disconnected.\n" , mac_address);
            -         // Handle the event
            -         break;
            -      case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
            -         printf("Connection in progress\n");
            -         // Handle the event
            -      case WIFI_DIRECT_CONNECTION_RSP:
            -      {
            -         if (error_code == WIFI_DIRECT_ERROR_CONNECTION_FAILED) 
            -         {
            +    printf("Connection state changed to: [%d] [%s]\n", connection_state,
            +           test_wfd_convert_connection_state_to_string(connection_state));
            +
            +    bool accept_connection = false;
            +    int rv = 0;
            +
            +    switch (connection_state) {
            +    case WIFI_DIRECT_CONNECTION_WPS_REQ:
            +        /* Outgoing requests */
            +        wifi_direct_wps_type_e wps_mode;
            +        wifi_direct_get_local_wps_type(&wps_mode);
            +        /* Handle the event */
            +        break;
            +    case WIFI_DIRECT_CONNECTION_REQ:
            +        /* Incoming requests */
            +        wifi_direct_wps_type_e wps_mode;
            +        wifi_direct_get_local_wps_type(&wps_mode);
            +        /* Handle the event */
            +        break;
            +    case WIFI_DIRECT_INVITATION_REQ:
            +        /* Invitation request from peer */
            +        /* Handle the event */
            +        break;
            +    case WIFI_DIRECT_DISASSOCIATION_IND:
            +    case WIFI_DIRECT_DISCONNECTION_IND:
            +        printf("Peer: [%s] disconnected.\n", mac_address);
            +        /* Handle the event */
            +        break;
            +    case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
            +        printf("Connection in progress\n");
            +        /* Handle the event */
            +    case WIFI_DIRECT_CONNECTION_RSP:
            +        if (error_code == WIFI_DIRECT_ERROR_CONNECTION_FAILED) {
                         printf(MAKE_RED"Time Out or connection failed"RESET_COLOR"\n");
            -            // Handle the event
            -         }
            -      }
            -         break;
            -      case WIFI_DIRECT_GROUP_CREATED:
            -         // Handle the event
            -         break;
            -      case WIFI_DIRECT_GROUP_DESTROYED:
            -         // Handle the event
            -         break;
            -      case WIFI_DIRECT_DISCONNECTION_RSP:
            -         // Handle the event
            -         break;
            -      default:
            -      {
            -         printf("Unknown State Received\n");
            -      }
            -   }
            +            /* Handle the event */
            +        }
            +        break;
            +    case WIFI_DIRECT_GROUP_CREATED:
            +        /* Handle the event */
            +        break;
            +    case WIFI_DIRECT_GROUP_DESTROYED:
            +        /* Handle the event */
            +        break;
            +    case WIFI_DIRECT_DISCONNECTION_RSP:
            +        /* Handle the event */
            +        break;
            +    default:
            +        printf("Unknown State Received\n");
            +    }
             }
             
            @@ -338,34 +322,29 @@ int error_code; wifi_direct_get_state(&state); if (state < WIFI_DIRECT_STATE_ACTIVATED) -   return -1; - +    return -1; + mac_address = calloc(1, 32*sizeof(char)); -if (!mac_address) -{ -   printf("cannot allocate memory"); +if (!mac_address) { +    printf("cannot allocate memory"); -   return -1; +    return -1; } printf("\nEnter Mac_address: "); -if (scanf(" %s", mac_address) < 1) -{ -   free(mac_address); +if (scanf(" %s", mac_address) < 1) { +    free(mac_address); -   return -1; +    return -1; } if (strlen(mac_address) > 23) -{ -   printf("\nWrong Mac_address"); -} +    printf("\nWrong Mac_address"); error_code = wifi_direct_connect(mac_address); -if (error_code != WIFI_DIRECT_ERROR_NONE) -{ -   printf("Failed to connect\n"); +if (error_code != WIFI_DIRECT_ERROR_NONE) { +    printf("Failed to connect\n"); -   return -1; +    return -1; } printf("Connection step finished\n"); @@ -380,34 +359,29 @@ int error_code; wifi_direct_get_state(&state); if (state < WIFI_DIRECT_STATE_ACTIVATED) -   return -1; - +    return -1; + mac_address = calloc(1, 32*sizeof(char)); -if (!mac_address) -{ -   printf("cannot allocate memory"); +if (!mac_address) { +    printf("cannot allocate memory"); -   return -1; +    return -1; } printf("\nEnter Mac_address: "); -if (scanf(" %s", mac_address) < 1) -{ -   free(mac_address); +if (scanf(" %s", mac_address) < 1) { +    free(mac_address); -   return -1; +    return -1; } if (strlen(mac_address) > 23) -{ -   printf("\nWrong Mac_address"); -} +    printf("\nWrong Mac_address"); error_code = wifi_direct_disconnect(mac_address); -if (error_code != WIFI_DIRECT_ERROR_NONE) -{ -   printf("Failed to disconnect\n"); +if (error_code != WIFI_DIRECT_ERROR_NONE) { +    printf("Failed to disconnect\n"); -   return -1; +    return -1; } printf("Disconnection step finished\n"); @@ -424,17 +398,14 @@ wifi_direct_state_e state; int error_code; wifi_direct_get_state(&state); -if (state < WIFI_DIRECT_STATE_ACTIVATED || state > WIFI_DIRECT_STATE_DISCOVERING) -{ -   return -1; -} +if (state < WIFI_DIRECT_STATE_ACTIVATED || state > WIFI_DIRECT_STATE_DISCOVERING) +    return -1; error_code = wifi_direct_create_group(); -if (error_code != WIFI_DIRECT_ERROR_NONE) -{ -   printf("Failed to create wifi direct group\n"); +if (error_code != WIFI_DIRECT_ERROR_NONE) { +    printf("Failed to create wifi direct group\n"); -   return -1; +    return -1; } printf("Connection step finished\n"); @@ -447,17 +418,14 @@ wifi_direct_state_e state; int error_code; wifi_direct_get_state(&state); -if (state < WIFI_DIRECT_STATE_CONNECTED) -{ -   return -1; -} +if (state < WIFI_DIRECT_STATE_CONNECTED) +    return -1; error_code = wifi_direct_destroy_group(); -if (error_code != WIFI_DIRECT_ERROR_NONE) -{ -   printf("Failed to destroy wifi direct group\n"); +if (error_code != WIFI_DIRECT_ERROR_NONE) { +    printf("Failed to destroy wifi direct group\n"); -   return -1; +    return -1; } printf("Disconnection step finished\n"); @@ -476,13 +444,13 @@ wifi_direct_deactivate(NULL);
          3. Unset the callbacks:
            -// Unset the activation or deactivation event callback
            +/* Unset the activation or deactivation event callback */
             wifi_direct_unset_device_state_changed_cb(NULL);
             
            -// Unset the discovery event callback 
            +/* Unset the discovery event callback */
             wifi_direct_unset_discovery_state_changed_cb(NULL);
             
            -// Unset the connection event callback
            +/* Unset the connection event callback */
             wifi_direct_unset_connection_state_changed_cb(NULL);
             
          4. @@ -518,4 +486,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/network/wifi_tutorial_n.htm b/org.tizen.tutorials/html/native/network/wifi_tutorial_n.htm index 5ee8f63..fa4f037 100644 --- a/org.tizen.tutorials/html/native/network/wifi_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/network/wifi_tutorial_n.htm @@ -23,7 +23,7 @@

            Content

              -
            • Prerequisites
            • +
            • Prerequisites
            • Initializing Wi-Fi
            • Activating a Wi-Fi Device
            • Scanning for Access Points
            • @@ -47,22 +47,24 @@

              Warm-up

              Become familiar with the Wi-Fi API basics by learning about:

              -

              Prerequisites

              -

              To use Wi-Fi APIs, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file.
              You can modify it for your own needs

              -
              - <privileges>
              -    <privilege>http://tizen.org/privilege/network.get</privilege>
              -    <privilege>http://tizen.org/privilege/network.set</privilege>
              -    <privilege>http://tizen.org/privilege/network.profile</privilege>
              - </privileges> 
              +

              Prerequisites

              +

              To use the Wi-Fi API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

              +
              +<privileges>
              +   <privilege>http://tizen.org/privilege/network.get</privilege>
              +   <privilege>http://tizen.org/privilege/network.set</privilege>
              +   <privilege>http://tizen.org/privilege/network.profile</privilege>
              +</privileges>
              +
              +

              Initializing Wi-Fi

              To initialize Wi-Fi:

                @@ -80,7 +82,7 @@ int error_code; error_code = wifi_initialize(); if (error_code != WIFI_ERROR_NONE) -   return; +    return;
          5. @@ -105,11 +107,11 @@ error_code = wifi_activate(__wifi_activated_cb, NULL);

            In the following example, the callback prints an information message using the dlogutil tool:

            -static void 
            -__wifi_activated_cb(wifi_error_e result, void *user_data) 
            +static void
            +__wifi_activated_cb(wifi_error_e result, void *user_data)
             {
            -   if (result == WIFI_ERROR_NONE)
            -      dlog_print(DLOG_INFO, LOG_TAG, "Success to activate Wi-Fi device!");
            +    if (result == WIFI_ERROR_NONE)
            +        dlog_print(DLOG_INFO, LOG_TAG, "Success to activate Wi-Fi device!");
             }
             
          6. @@ -119,13 +121,9 @@ __wifi_activated_cb(wifi_error_e result, void *user_data) bool wifi_activated = false; wifi_is_activated(&wifi_activated); if (wifi_activated) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "Success to get Wi-Fi device state."); -} -else -{ -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to get Wi-Fi device state."); -} +    dlog_print(DLOG_INFO, LOG_TAG, "Success to get Wi-Fi device state."); +else +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to get Wi-Fi device state.");
        • To deactivate the Wi-Fi device when Wi-Fi is no longer needed (or the application is exiting), use the wifi_deactivate() function:

          @@ -149,12 +147,12 @@ wifi_scan(__scan_request_cb, NULL);

          In the following example, the callback calls the wifi_foreach_found_aps() function for getting information on the found AP. The wifi_foreach_found_aps() function gets the result of the scan, and the __wifi_found_ap_cb() callback is called for each found access point.

          -void 
          +void
           __scan_request_cb(wifi_error_e error_code, void *user_data)
           {
          -   error_code = wifi_foreach_found_aps(__wifi_found_ap_cb, NULL);
          -   if (error_code != WIFI_ERROR_NONE) 
          -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to scan");
          +    error_code = wifi_foreach_found_aps(__wifi_found_ap_cb, NULL);
          +    if (error_code != WIFI_ERROR_NONE)
          +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to scan");
           }
           
        • @@ -162,47 +160,43 @@ __scan_request_cb(wifi_error_e error_code, void *user_data)

          In the following example, the callback prints the AP name and connection state:

          -bool 
          -__wifi_found_ap_cb(wifi_ap_h ap, void *user_data) 
          +bool
          +__wifi_found_ap_cb(wifi_ap_h ap, void *user_data)
           {
          -   int error_code = 0;
          -   char *ap_name = NULL;
          -   wifi_connection_state_e state;
          -
          +    int error_code = 0;
          +    char *ap_name = NULL;
          +    wifi_connection_state_e state;
           
          -   error_code = wifi_ap_get_essid(ap, &ap_name);
          -   if (error_code != WIFI_ERROR_NONE) 
          -   {
          -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to get AP name.");
          +    error_code = wifi_ap_get_essid(ap, &ap_name);
          +    if (error_code != WIFI_ERROR_NONE) {
          +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to get AP name.");
           
          -      return false;
          -   }
          -   error_code = wifi_ap_get_connection_state(ap, &state);
          -   if (error_code != WIFI_ERROR_NONE) 
          -   {
          -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to get state.");
          +        return false;
          +    }
          +    error_code = wifi_ap_get_connection_state(ap, &state);
          +    if (error_code != WIFI_ERROR_NONE) {
          +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to get state.");
           
          -      return false;
          -   }
          -   dlog_print(DLOG_INFO, LOG_TAG, "AP name : %s, state : %s", ap_name, print_state(state));
          +        return false;
          +    }
          +    dlog_print(DLOG_INFO, LOG_TAG, "AP name : %s, state : %s", ap_name, print_state(state));
           
          -   return true;
          +    return true;
           }
           
          -static const char* 
          -print_state(wifi_connection_state_e state) 
          +static const char*
          +print_state(wifi_connection_state_e state)
           {
          -   switch (state) 
          -   {
          -      case WIFI_CONNECTION_STATE_DISCONNECTED:
          -         return "Disconnected";
          -      case WIFI_CONNECTION_STATE_ASSOCIATION:
          -         return "Association";
          -      case WIFI_CONNECTION_STATE_CONNECTED:
          -         return "Connected";
          -      case WIFI_CONNECTION_STATE_CONFIGURATION:
          -         return "Configuration";
          -   }
          +    switch (state) {
          +    case WIFI_CONNECTION_STATE_DISCONNECTED:
          +        return "Disconnected";
          +    case WIFI_CONNECTION_STATE_ASSOCIATION:
          +        return "Association";
          +    case WIFI_CONNECTION_STATE_CONNECTED:
          +        return "Connected";
          +    case WIFI_CONNECTION_STATE_CONFIGURATION:
          +        return "Configuration";
          +    }
           }
           
          @@ -221,17 +215,16 @@ bool state = false; wifi_is_activated(&state); if (state == false) -   return -1; +    return -1; dlog_print(DLOG_INFO, LOG_TAG, "Input a part of AP name to connect : "); error_code = scanf("%32s", ap_name); error_code = wifi_foreach_found_aps(__found_connect_ap_cb, ap_name); -if (error_code != WIFI_ERROR_NONE) -{ -   dlog_print(DLOG_INFO, LOG_TAG, "Failed to connect (can't get AP list)"); +if (error_code != WIFI_ERROR_NONE) { +    dlog_print(DLOG_INFO, LOG_TAG, "Failed to connect (can't get AP list)"); -   return -1; +    return -1; } dlog_print(DLOG_INFO, LOG_TAG, "Connection step finished"); @@ -243,59 +236,55 @@ dlog_print(DLOG_INFO, LOG_TAG, "Connection step finished");

          Finally, connect to a specific AP using the wifi_connect() function.

          -static bool 
          -__found_connect_ap_cb(wifi_ap_h ap, void *user_data) 
          +static bool
          +__found_connect_ap_cb(wifi_ap_h ap, void *user_data)
           {
          -   int error_code = 0;
          -   char *ap_name = NULL;
          -   char *ap_name_part = (char*)user_data;
          +    int error_code = 0;
          +    char *ap_name = NULL;
          +    char *ap_name_part = (char*)user_data;
           
          -   error_code = wifi_ap_get_essid(ap, &ap_name);
          -   if (error_code != WIFI_ERROR_NONE) 
          -   {
          -      dlog_print(DLOG_INFO, LOG_TAG, "Failed to get AP name");
          +    error_code = wifi_ap_get_essid(ap, &ap_name);
          +    if (error_code != WIFI_ERROR_NONE) {
          +        dlog_print(DLOG_INFO, LOG_TAG, "Failed to get AP name");
           
          -      return false;
          -   }
          +        return false;
          +    }
           
          -   if (strstr(ap_name, ap_name_part) != NULL) 
          -   {
          -      bool required = false;
          +    if (strstr(ap_name, ap_name_part) != NULL) {
          +        bool required = false;
           
          -      if (wifi_ap_is_passphrase_required(ap, &required) == WIFI_ERROR_NONE)
          -         dlog_print(DLOG_INFO, LOG_TAG, "Passphrase required: %s", required ? "True" : "False");
          -      else
          -         dlog_print(DLOG_INFO, LOG_TAG, "Failed to get Passphrase required");
          +        if (wifi_ap_is_passphrase_required(ap, &required) == WIFI_ERROR_NONE)
          +            dlog_print(DLOG_INFO, LOG_TAG, "Passphrase required: %s", required ? "True" : "False");
          +        else
          +            dlog_print(DLOG_INFO, LOG_TAG, "Failed to get Passphrase required");
           
          -      if (required) 
          -      {
          -         char passphrase[100];
          -         dlog_print(DLOG_INFO, LOG_TAG, "Input passphrase for %s :", passphrase);
          -         error_code = scanf("99%s", passphrase);
          +        if (required) {
          +            char passphrase[100];
          +            dlog_print(DLOG_INFO, LOG_TAG, "Input passphrase for %s :", passphrase);
          +            error_code = scanf("99%s", passphrase);
           
          -         error_code = wifi_ap_set_passphrase(ap, passphrase);
          -         if (error_code != WIFI_ERROR_NONE) 
          -         {
          -            dlog_print(DLOG_INFO, LOG_TAG, "Failed to set passphrase");
          +            error_code = wifi_ap_set_passphrase(ap, passphrase);
          +            if (error_code != WIFI_ERROR_NONE) {
          +                dlog_print(DLOG_INFO, LOG_TAG, "Failed to set passphrase");
           
          -            return false;
          -         }
          -      }
          +                return false;
          +            }
          +        }
           
          -      error_code = wifi_connect(ap, __connected_cb, NULL);
          -      if (error_code != WIFI_ERROR_NONE)
          -         dlog_print(DLOG_INFO, LOG_TAG, "Failed in connection request");
          -      else
          -         dlog_print(DLOG_INFO, LOG_TAG, "Success in connection request");
          +        error_code = wifi_connect(ap, __connected_cb, NULL);
          +        if (error_code != WIFI_ERROR_NONE)
          +            dlog_print(DLOG_INFO, LOG_TAG, "Failed in connection request");
          +        else
          +            dlog_print(DLOG_INFO, LOG_TAG, "Success in connection request");
           
          -      free(ap_name);
          +        free(ap_name);
           
          -      return false;
          -   }
          +        return false;
          +    }
           
          -   free(ap_name);
          +    free(ap_name);
           
          -   return true;
          +    return true;
           }
           
        • @@ -303,13 +292,13 @@ __found_connect_ap_cb(wifi_ap_h ap, void *user_data)

          The wifi_connect() function called within the __found_connect_ap_cb() callback invokes the __connected_cb() function, which you can use to notify the user of the connection result:

          -static void 
          -__connected_cb(wifi_error_e result, void* user_data) 
          +static void
          +__connected_cb(wifi_error_e result, void* user_data)
           {
          -   if (result == WIFI_ERROR_NONE)
          -      dlog_print(DLOG_INFO, LOG_TAG, "Wi-Fi Connection Succeeded");
          -   else
          -      dlog_print(DLOG_INFO, LOG_TAG, "Wi-Fi Connection Failed!");
          +    if (result == WIFI_ERROR_NONE)
          +        dlog_print(DLOG_INFO, LOG_TAG, "Wi-Fi Connection Succeeded");
          +    else
          +        dlog_print(DLOG_INFO, LOG_TAG, "Wi-Fi Connection Failed!");
           }
           
          @@ -338,4 +327,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/security/key_tutorial_n.htm b/org.tizen.tutorials/html/native/security/key_tutorial_n.htm index 0dedfcd..59575e0 100644 --- a/org.tizen.tutorials/html/native/security/key_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/security/key_tutorial_n.htm @@ -22,6 +22,7 @@

          Content

            +
          • Prerequisites
          • Initializing the Key Manager
          • Repository management
              @@ -56,7 +57,7 @@

              Become familiar with the Key Manager API basics by learning about:

              • Initializing the Key Manager -

                Define the header file and privileges required to use the key manager.

              • +

                Define the header file required to use the key manager.

              • Repository management - + +

                Prerequisites

                + +

                To use the Key Manager API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

                +
                +<privileges>
                +   <privilege>http://tizen.org/privilege/keymanager</privilege>
                +</privileges>
                +
                +

                Initializing the Key Manager

                -

                To define the header file and privileges required to use the key manager:

                +

                To define the header file required to use the key manager:

                  -
                1. To use the Key Manager privileged API, add the http://tizen.org/privilege/keymanager privilege in the manifest file of the application.

                2. To use the functions and data types of the Key Manager API (in mobile and wearable applications), include the <ckmc/ckmc-manager.h> header file in your application:

                   #include <ckmc/ckmc-manager.h>
                  @@ -110,28 +119,26 @@ char* alias= "mykey";
                   char* key_password = NULL;
                   
                   char* binary_key = "-----BEGIN PUBLIC KEY-----\n"
                  -   "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2b1bXDa+S8/MGWnMkru4\n"
                  -   "T4tUddtZNi0NVjQn9RFH1NMa220GsRhRO56F77FlSVFKfSfVZKIiWg6C+DVCkcLf\n"
                  -   "zXJ/Z0pvwOQYBAqVMFjV6efQGN0JzJ1Unu7pPRiZl7RKGEI+cyzzrcDyrLLrQ2W7\n"
                  -   "0ZySkNEOv6Frx9JgC5NExuYY4lk2fQQa38JXiZkfyzif2em0px7mXbyf5LjccsKq\n"
                  -   "v1e+XLtMsL0ZefRcqsP++NzQAI8fKX7WBT+qK0HJDLiHrKOTWYzx6CwJ66LD/vvf\n"
                  -   "j55xtsKDLVDbsotvf8/m6VLMab+vqKk11TP4tq6yo0mwyTADvgl1zowQEO9I1W6o\n"
                  -   "zQIDAQAB\n"
                  -   "-----END PUBLIC KEY-----";
                  -
                  -test_key.raw_key =  (unsigned char *) binary_key;
                  +    "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2b1bXDa+S8/MGWnMkru4\n"
                  +    "T4tUddtZNi0NVjQn9RFH1NMa220GsRhRO56F77FlSVFKfSfVZKIiWg6C+DVCkcLf\n"
                  +    "zXJ/Z0pvwOQYBAqVMFjV6efQGN0JzJ1Unu7pPRiZl7RKGEI+cyzzrcDyrLLrQ2W7\n"
                  +    "0ZySkNEOv6Frx9JgC5NExuYY4lk2fQQa38JXiZkfyzif2em0px7mXbyf5LjccsKq\n"
                  +    "v1e+XLtMsL0ZefRcqsP++NzQAI8fKX7WBT+qK0HJDLiHrKOTWYzx6CwJ66LD/vvf\n"
                  +    "j55xtsKDLVDbsotvf8/m6VLMab+vqKk11TP4tq6yo0mwyTADvgl1zowQEO9I1W6o\n"
                  +    "zQIDAQAB\n"
                  +    "-----END PUBLIC KEY-----";
                  +
                  +test_key.raw_key = (unsigned char *)binary_key;
                   test_key.key_size = strlen(binary_key);
                  -test_key.key_type = CKMC_KEY_NONE; // Real key type is determined by the key manager
                  -test_key.password = NULL; // binary_key is not encrypted with a password
                  +test_key.key_type = CKMC_KEY_NONE; /* Real key type is determined by the key manager */
                  +test_key.password = NULL; /* binary_key is not encrypted with a password */
                   
                  -store_policy.password = key_password; // NULL means that the test_key is not encrypted with a per key password
                  -store_policy.extractable = true; // Key value is extractable
                  +store_policy.password = key_password; /* NULL means that the test_key is not encrypted with a per key password */
                  +store_policy.extractable = true; /* Key value is extractable */
                   
                   ret = ckmc_save_key(alias, test_key, store_policy);
                   if (CKMC_ERROR_NONE != ret)
                  -{
                  -   // Error handling
                  -}
                  +    /* Error handling */
                   
                3. Get the key from the key manager: @@ -144,13 +151,11 @@ char* key_password = NULL; ret = ckmc_get_key(alias, key_password, &test_key); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ dlog_print(DLOG_INFO, LOG_TAG, "key size =%d\n", test_key->key_size); -ckmc_key_free(test_key); // Called when the key is no longer needed +ckmc_key_free(test_key); /* Called when the key is no longer needed */
                4. Get the key alias list: @@ -165,22 +170,18 @@ int count_list = 0; ret = ckmc_get_key_alias_list(&alias_list); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ plist = alias_list; -do -{ -   ckmc_get_key(plist->alias, key_password, &test_key); -   dlog_print(DLOG_INFO, LOG_TAG, "%d th key: key size =%d\n", -              ++count_list, test_key->key_size); -   ckmc_key_free(test_key); -   plist = plist->next; -} -while(plist != NULL); - -ckmc_alias_list_all_free(alias_list); // Called when the list is no longer needed +do { +    ckmc_get_key(plist->alias, key_password, &test_key); +    dlog_print(DLOG_INFO, LOG_TAG, "%d th key: key size =%d\n", +               ++count_list, test_key->key_size); +    ckmc_key_free(test_key); +    plist = plist->next; +} while (plist != NULL); + +ckmc_alias_list_all_free(alias_list); /* Called when the list is no longer needed */
                5. Remove the key:
                  @@ -189,10 +190,8 @@ int ret = CKMC_ERROR_NONE;
                   const char* alias= "mykey";
                   
                   ret = ckmc_remove_alias(alias);
                  -if (CKMC_ERROR_NONE != ret) 
                  -{
                  -   // Error handling
                  -}
                  +if (CKMC_ERROR_NONE != ret)
                  +    /* Error handling */
                   
                @@ -242,15 +241,13 @@ const char *certPem = "-----BEGIN CERTIFICATE-----\n" test_policy.password = password; test_policy.extractable = true; -cert.raw_cert = (unsigned char *) certPem; +cert.raw_cert = (unsigned char *)certPem; cert.cert_size = strlen(certPem); cert.data_format = CKMC_FORM_PEM; ret = ckmc_save_cert(alias, cert, test_policy); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */
              • Get the certificate from the key manager: @@ -263,13 +260,11 @@ char* password = NULL; ret = ckmc_get_cert(alias, password, &test_cert); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ dlog_print(DLOG_INFO, LOG_TAG, "cert size =%d\n", test_cert->cert_size); -ckmc_cert_free(test_cert); // Called when the certificate is no longer needed +ckmc_cert_free(test_cert); /* Called when the certificate is no longer needed */
              • Get the certificate alias list:
                @@ -283,22 +278,18 @@ int count_list = 0;
                 
                 ret = ckmc_get_cert_alias_list(&alias_list);
                 if (CKMC_ERROR_NONE != ret)
                -{
                -   // Error handling
                -}
                +    /* Error handling */
                 
                 plist = alias_list;
                -do
                -{
                -   ckmc_get_cert(plist->alias, password, &test_cert);
                -   dlog_print(DLOG_INFO, LOG_TAG, "%d th cert: cert size =%d\n", 
                -              ++count_list, test_cert->cert_size);
                -   ckmc_cert_free(test_cert);
                -   plist = plist->next;
                -}
                -while(plist != NULL);
                -
                -ckmc_alias_list_all_free(alias_list); // Called when the list is no longer needed
                +do {
                +    ckmc_get_cert(plist->alias, password, &test_cert);
                +    dlog_print(DLOG_INFO, LOG_TAG, "%d th cert: cert size =%d\n",
                +               ++count_list, test_cert->cert_size);
                +    ckmc_cert_free(test_cert);
                +    plist = plist->next;
                +} while (plist != NULL);
                +
                +ckmc_alias_list_all_free(alias_list); /* Called when the list is no longer needed */
                 
              • Remove the certificate: @@ -309,9 +300,7 @@ const char* alias= "myCert"; ret = ckmc_remove_alias(alias); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */
              • @@ -333,13 +322,11 @@ const char *char_bin_data = "My Binary Data"; test_policy.password = password; test_policy.extractable = true; -test_data.data = (unsigned char *) char_bin_data; +test_data.data = (unsigned char *)char_bin_data; test_data.size = strlen(char_bin_data); ret = ckmc_save_data(alias, test_data, test_policy); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */
              • Get data from the key manager: @@ -352,13 +339,11 @@ const char *alias = "myData"; ret = ckmc_get_data(alias, password, &test_data); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ -dlog_print(DLOG_INFO, LOG_TAG, "data size =%d\n", test_data-> size); +dlog_print(DLOG_INFO, LOG_TAG, "data size =%d\n", test_data->size); -ckmc_buffer_free(test_data); // Called when the buffer is no longer needed +ckmc_buffer_free(test_data); /* Called when the buffer is no longer needed */
              • Get the data alias list: @@ -373,22 +358,18 @@ int count_list = 0; ret = ckmc_get_data_alias_list(&alias_list); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ plist = alias_list; -do -{ -   ckmc_get_data(plist->alias, password, &test_data); -   dlog_print(DLOG_INFO, LOG_TAG, "%d th data: data size =%d\n", -              ++count_list, test_data->size); -   ckmc_buffer_free(test_data); -   plist = plist->next; -} -while(plist != NULL); - -ckmc_alias_list_all_free(alias_list); // Called when the list is no longer needed +do { +    ckmc_get_data(plist->alias, password, &test_data); +    dlog_print(DLOG_INFO, LOG_TAG, "%d th data: data size =%d\n", +               ++count_list, test_data->size); +    ckmc_buffer_free(test_data); +    plist = plist->next; +} while (plist != NULL); + +ckmc_alias_list_all_free(alias_list); /* Called when the list is no longer needed */
              • Remove data:
                @@ -398,9 +379,7 @@ const char* alias= "myData";
                 
                 ret = ckmc_remove_alias(alias);
                 if (CKMC_ERROR_NONE != ret)
                -{
                -   // Error handling
                -}
                +    /* Error handling */
                 
              • Creating Key Pairs

                @@ -411,15 +390,15 @@ if (CKMC_ERROR_NONE != ret)
                 int ret = CKMC_ERROR_NONE;
                 
                -size_t size = 2048; // Key manager supports 1024, 2048, 4096
                +size_t size = 2048; /* Key manager supports 1024, 2048, 4096 */
                 const char *private_key_alias = "PRV_RSA1";
                 const char *public_key_alias = "PUB_RSA1";
                 ckmc_policy_s policy_private_key;
                 ckmc_policy_s policy_public_key;
                 
                -// Private key is encrypted with an additional password
                +/* Private key is encrypted with an additional password */
                 policy_private_key.password = (char *)"pri_password";
                -policy_private_key.extractable = false; // Key cannot be extracted from the key manager
                +policy_private_key.extractable = false; /* Key cannot be extracted from the key manager */
                 
                 policy_public_key.password = NULL;
                 policy_public_key.extractable = true;
                @@ -427,9 +406,7 @@ policy_public_key.extractable = true;
                 ret = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias,
                                                policy_private_key, policy_public_key);
                 if (CKMC_ERROR_NONE != ret)
                -{
                -   // Error handling
                -}
                +    /* Error handling */
                 
              • Create the ECDSA key pair:

                @@ -442,19 +419,17 @@ const char *public_key_alias = "PUB_ECDSA1"; ckmc_policy_s policy_private_key; ckmc_policy_s policy_public_key; -// Private key is encrypted with an additional password +/* Private key is encrypted with an additional password */ policy_private_key.password = (char *)"pri_password"; -policy_private_key.extractable = false; // Key cannot be extracted from the key manager +policy_private_key.extractable = false; /* Key cannot be extracted from the key manager */ policy_public_key.password = NULL; policy_public_key.extractable = true; -ret = ckmc_create_key_pair_ecdsa(ectype, private_key_alias, public_key_alias, +ret = ckmc_create_key_pair_ecdsa(ectype, private_key_alias, public_key_alias,                                  policy_private_key, policy_public_key); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */
              • Create the DSA key pair:

                @@ -467,31 +442,29 @@ const char *public_key_alias = "PUB-DSA1"; ckmc_policy_s policy_private_key; ckmc_policy_s policy_public_key; -// This private key is encrypted with an additional password +/* This private key is encrypted with an additional password */ policy_private_key.password = (char *)"pri_password"; policy_private_key.extractable = false; policy_public_key.password = NULL; policy_public_key.extractable = true; -ret = ckmc_create_key_pair_dsa(size, private_key_alias, public_key_alias, +ret = ckmc_create_key_pair_dsa(size, private_key_alias, public_key_alias,                                policy_private_key, policy_public_key); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */

              Creating or Verifying Signatures

              -

              To create or verify signatures:

              +

              To create or verify signatures:

              1. Store a private and public key:
                 int ret = CKMC_ERROR_NONE;
                 
                 const char *pub_alias = "pub1";
                 const char *pri_alias = "prv1";
                -char *key_passwd = (char *) "1234";
                +char *key_passwd = (char *)"1234";
                 char *pri_passwd = NULL;
                 char *pub_passwd = NULL;
                 ckmc_hash_algo_e hash_algo = CKMC_HASH_SHA256;
                @@ -504,45 +477,45 @@ ckmc_key_s prikey;
                 ckmc_policy_s pripolicy;
                 
                 const char *prv = "-----BEGIN RSA PRIVATE KEY-----\n"
                -   "Proc-Type: 4,ENCRYPTED\n"
                -   "DEK-Info: DES-EDE3-CBC,6C6507B11671DABC\n"
                -   "\n"
                -   "YiKNviNqc/V/i241CKtAVsNckesE0kcaka3VrY7ApXR+Va93YoEwVQ8gB9cE/eHH\n"
                -   "S0j3ZS1PAVFM/qo4ZnPdMzaSLvTQw0GAL90wWgF3XQ+feMnWyBObEoQdGXE828TB\n"
                -   "SLz4UOIQ55Dx6JSWTfEhwAlPs2cEWD14xvuxPzAEzBIYmWmBBsCN94YgFeRTzjH0\n"
                -   "TImoYVMN60GgOfZWw6rXq9RaV5dY0Y6F1piypCLGD35VaXAutdHIDvwUGECPm7SN\n"
                -   "w05jRro53E1vb4mYlZEY/bs4q7XEOI5+ZKT76Xn0oEJNX1KRL1h2q8fgUkm5j40M\n"
                -   "uQj71aLR9KyIoQARwGLeRy09tLVjH3fj66CCMqaPcxcIRIyWi5yYBB0s53ipm6A9\n"
                -   "CYuyc7MS2C0pOdWKsDvYsHR/36KUiIdPuhF4AbaTqqO0eWeuP7Na7dGK56Fl+ooi\n"
                -   "cUpJr7cIqMl2vL25B0jW7d4TB3zwCEkVVD1fBPeNoZWo30z4bILcBqjjPkQfHZ2e\n"
                -   "xNraG3qI4FHjoPT8JEE8p+PgwaMoINlICyIMKiCdvwz9yEnsHPy7FkmatpS+jFoS\n"
                -   "mg8R9vMwgK/HGEm0dmb/7/a0XsG2jCDm6cOmJdZJFQ8JW7hFs3eOHpNlQYDChG2D\n"
                -   "A1ExslqBtbpicywTZhzFdYU/hxeCr4UqcY27Zmhr4JlBPMyvadWKeOqCamWepjbT\n"
                -   "T/MhWJbmWgZbI5s5sbpu7cOYubQcUIEsTaQXGx/KEzGo1HLn9tzSeQfP/nqjAD/L\n"
                -   "T5t1Mb8o4LuV/fGIT33Q3i2FospJMqp2JINNzG18I6Fjo08PTvJ3row40Rb76+lJ\n"
                -   "wN1IBthgBgsgsOdB6XNc56sV+uq2TACsNNWw+JnFRCkCQgfF/KUrvN+WireWq88B\n"
                -   "9UPG+Hbans5A6K+y1a+bzfdYnKws7x8wNRyPxb7Vb2t9ZTl5PBorPLVGsjgf9N5X\n"
                -   "tCdBlfJsUdXot+EOxrIczV5zx0JIB1Y9hrDG07RYkzPuJKxkW7skqeLo8oWGVpaQ\n"
                -   "LGWvuebky1R75hcSuL3e4QHfjBHPdQ31fScB884tqkbhBAWr2nT9bYEmyT170bno\n"
                -   "8QkyOSb99xZBX55sLDHs9p61sTJr2C9Lz/KaWQs+3hTkpwSjSRyjEMH2n491qiQX\n"
                -   "G+kvLEnvtR8sl9zinorj/RfsxyPntAxudfY3qaYUu2QkLvVdfTVUVbxS/Fg8f7B3\n"
                -   "hEjCtpKgFjPxQuHE3didNOr5xM7mkmLN/QA7yHVgdpE64T5mFgC3JcVRpcR7zBPH\n"
                -   "3OeXHgjrhDfN8UIX/cq6gNgD8w7O0rhHa3mEXI1xP14ykPcJ7wlRuLm9P3fwx5A2\n"
                -   "jQrVKJKw1Nzummmspn4VOpJY3LkH4Sxo4e7Soo1l1cxJpzmERwgMF+vGz1L70+DG\n"
                -   "M0hVrz1PxlOsBBFgcdS4TB91DIs/RcFDqrJ4gOPNKCgBP+rgTXXLFcxUwJfE3lKg\n"
                -   "Kmpwdne6FuQYX3eyRVAmPgOHbJuRQCh/V4fYo51UxCcEKeKy6UgOPEJlXksWGbH5\n"
                -   "VFmlytYW6dFKJvjltSmK6L2r+TlyEQoXwTqe4bkfhB2LniDEq28hKQ==\n"
                -   "-----END RSA PRIVATE KEY-----\n";
                +    "Proc-Type: 4,ENCRYPTED\n"
                +    "DEK-Info: DES-EDE3-CBC,6C6507B11671DABC\n"
                +    "\n"
                +    "YiKNviNqc/V/i241CKtAVsNckesE0kcaka3VrY7ApXR+Va93YoEwVQ8gB9cE/eHH\n"
                +    "S0j3ZS1PAVFM/qo4ZnPdMzaSLvTQw0GAL90wWgF3XQ+feMnWyBObEoQdGXE828TB\n"
                +    "SLz4UOIQ55Dx6JSWTfEhwAlPs2cEWD14xvuxPzAEzBIYmWmBBsCN94YgFeRTzjH0\n"
                +    "TImoYVMN60GgOfZWw6rXq9RaV5dY0Y6F1piypCLGD35VaXAutdHIDvwUGECPm7SN\n"
                +    "w05jRro53E1vb4mYlZEY/bs4q7XEOI5+ZKT76Xn0oEJNX1KRL1h2q8fgUkm5j40M\n"
                +    "uQj71aLR9KyIoQARwGLeRy09tLVjH3fj66CCMqaPcxcIRIyWi5yYBB0s53ipm6A9\n"
                +    "CYuyc7MS2C0pOdWKsDvYsHR/36KUiIdPuhF4AbaTqqO0eWeuP7Na7dGK56Fl+ooi\n"
                +    "cUpJr7cIqMl2vL25B0jW7d4TB3zwCEkVVD1fBPeNoZWo30z4bILcBqjjPkQfHZ2e\n"
                +    "xNraG3qI4FHjoPT8JEE8p+PgwaMoINlICyIMKiCdvwz9yEnsHPy7FkmatpS+jFoS\n"
                +    "mg8R9vMwgK/HGEm0dmb/7/a0XsG2jCDm6cOmJdZJFQ8JW7hFs3eOHpNlQYDChG2D\n"
                +    "A1ExslqBtbpicywTZhzFdYU/hxeCr4UqcY27Zmhr4JlBPMyvadWKeOqCamWepjbT\n"
                +    "T/MhWJbmWgZbI5s5sbpu7cOYubQcUIEsTaQXGx/KEzGo1HLn9tzSeQfP/nqjAD/L\n"
                +    "T5t1Mb8o4LuV/fGIT33Q3i2FospJMqp2JINNzG18I6Fjo08PTvJ3row40Rb76+lJ\n"
                +    "wN1IBthgBgsgsOdB6XNc56sV+uq2TACsNNWw+JnFRCkCQgfF/KUrvN+WireWq88B\n"
                +    "9UPG+Hbans5A6K+y1a+bzfdYnKws7x8wNRyPxb7Vb2t9ZTl5PBorPLVGsjgf9N5X\n"
                +    "tCdBlfJsUdXot+EOxrIczV5zx0JIB1Y9hrDG07RYkzPuJKxkW7skqeLo8oWGVpaQ\n"
                +    "LGWvuebky1R75hcSuL3e4QHfjBHPdQ31fScB884tqkbhBAWr2nT9bYEmyT170bno\n"
                +    "8QkyOSb99xZBX55sLDHs9p61sTJr2C9Lz/KaWQs+3hTkpwSjSRyjEMH2n491qiQX\n"
                +    "G+kvLEnvtR8sl9zinorj/RfsxyPntAxudfY3qaYUu2QkLvVdfTVUVbxS/Fg8f7B3\n"
                +    "hEjCtpKgFjPxQuHE3didNOr5xM7mkmLN/QA7yHVgdpE64T5mFgC3JcVRpcR7zBPH\n"
                +    "3OeXHgjrhDfN8UIX/cq6gNgD8w7O0rhHa3mEXI1xP14ykPcJ7wlRuLm9P3fwx5A2\n"
                +    "jQrVKJKw1Nzummmspn4VOpJY3LkH4Sxo4e7Soo1l1cxJpzmERwgMF+vGz1L70+DG\n"
                +    "M0hVrz1PxlOsBBFgcdS4TB91DIs/RcFDqrJ4gOPNKCgBP+rgTXXLFcxUwJfE3lKg\n"
                +    "Kmpwdne6FuQYX3eyRVAmPgOHbJuRQCh/V4fYo51UxCcEKeKy6UgOPEJlXksWGbH5\n"
                +    "VFmlytYW6dFKJvjltSmK6L2r+TlyEQoXwTqe4bkfhB2LniDEq28hKQ==\n"
                +    "-----END RSA PRIVATE KEY-----\n";
                 
                 const char *pub = "-----BEGIN PUBLIC KEY-----\n"
                -   "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2b1bXDa+S8/MGWnMkru4\n"
                -   "T4tUddtZNi0NVjQn9RFH1NMa220GsRhRO56F77FlSVFKfSfVZKIiWg6C+DVCkcLf\n"
                -   "zXJ/Z0pvwOQYBAqVMFjV6efQGN0JzJ1Unu7pPRiZl7RKGEI+cyzzrcDyrLLrQ2W7\n"
                -   "0ZySkNEOv6Frx9JgC5NExuYY4lk2fQQa38JXiZkfyzif2em0px7mXbyf5LjccsKq\n"
                -   "v1e+XLtMsL0ZefRcqsP++NzQAI8fKX7WBT+qK0HJDLiHrKOTWYzx6CwJ66LD/vvf\n"
                -   "j55xtsKDLVDbsotvf8/m6VLMab+vqKk11TP4tq6yo0mwyTADvgl1zowQEO9I1W6o\n"
                -   "zQIDAQAB\n"
                -   "-----END PUBLIC KEY-----\n";
                +    "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2b1bXDa+S8/MGWnMkru4\n"
                +    "T4tUddtZNi0NVjQn9RFH1NMa220GsRhRO56F77FlSVFKfSfVZKIiWg6C+DVCkcLf\n"
                +    "zXJ/Z0pvwOQYBAqVMFjV6efQGN0JzJ1Unu7pPRiZl7RKGEI+cyzzrcDyrLLrQ2W7\n"
                +    "0ZySkNEOv6Frx9JgC5NExuYY4lk2fQQa38JXiZkfyzif2em0px7mXbyf5LjccsKq\n"
                +    "v1e+XLtMsL0ZefRcqsP++NzQAI8fKX7WBT+qK0HJDLiHrKOTWYzx6CwJ66LD/vvf\n"
                +    "j55xtsKDLVDbsotvf8/m6VLMab+vqKk11TP4tq6yo0mwyTADvgl1zowQEO9I1W6o\n"
                +    "zQIDAQAB\n"
                +    "-----END PUBLIC KEY-----\n";
                 pubkey.raw_key = (unsigned char *)pub;
                 pubkey.key_size = strlen(pub);
                 pubkey.key_type = CKMC_KEY_NONE;
                @@ -557,19 +530,15 @@ pripolicy.extractable = true;
                 prikey.raw_key = (unsigned char *)prv;
                 prikey.key_size = strlen(prv);
                 prikey.key_type = CKMC_KEY_NONE;
                -prikey.password = key_passwd; // prv private key is encrypted with the key_password
                +prikey.password = key_passwd; /* prv private key is encrypted with the key_password */
                 
                 ret = ckmc_save_key(pri_alias, prikey, pripolicy);
                 if (CKMC_ERROR_NONE != ret)
                -{
                -   // Error handling
                -}
                +    /* Error handling */
                 
                 ret = ckmc_save_key(pub_alias, pubkey, pubpolicy);
                 if (CKMC_ERROR_NONE != ret)
                -{
                -   // Error handling
                -}
                +    /* Error handling */
                 
              2. Create and verify the signature: @@ -592,19 +561,15 @@ char *pub_passwd = NULL; msg_buff.data = (unsigned char *)message; msg_buff.size = strlen(message); -ret = ckmc_create_signature(pri_alias, pri_passwd, msg_buff, hash_algo, +ret = ckmc_create_signature(pri_alias, pri_passwd, msg_buff, hash_algo,                             pad_algo, &signature); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ -ret = ckmc_verify_signature(pub_alias, pub_passwd, msg_buff, *signature, +ret = ckmc_verify_signature(pub_alias, pub_passwd, msg_buff, *signature,                             hash_algo, pad_algo); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */
              3. Create and verify without a hash algorithm: @@ -614,7 +579,7 @@ int ret = CKMC_ERROR_NONE; const char *message = "message test"; ckmc_raw_buffer_s msg_buff; ckmc_raw_buffer_s *signature; -ckmc_hash_algo_e hash_algo = CKMC_HASH_NONE; // Do not use a hash algorithm +ckmc_hash_algo_e hash_algo = CKMC_HASH_NONE; /* Do not use a hash algorithm */ ckmc_rsa_padding_algo_e pad_algo = CKMC_PKCS1_PADDING; const char *pub_alias = "pub1"; @@ -625,19 +590,15 @@ char *pub_passwd = NULL; msg_buff.data = (unsigned char *)message; msg_buff.size = strlen(message); -ret = ckmc_create_signature(pri_alias, pri_passwd, msg_buff, +ret = ckmc_create_signature(pri_alias, pri_passwd, msg_buff,                             hash_algo, pad_algo, &signature); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ -ret = ckmc_verify_signature(pub_alias, pub_passwd, msg_buff, +ret = ckmc_verify_signature(pub_alias, pub_passwd, msg_buff,                             *signature, hash_algo, pad_algo); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */
          • @@ -650,10 +611,10 @@ if (CKMC_ERROR_NONE != ret)
             int ret = CKMC_ERROR_NONE;
             
            -ckmc_cert_s c_cert; // For a user certificate
            -ckmc_cert_s c_cert1; // For an intermediate untrusted CA certificate
            -ckmc_cert_list_s untrustedcerts; // Linked list of untrusted CA certificates
            -ckmc_cert_list_s *cert_chain_list; // Linked list of a certificate chain
            +ckmc_cert_s c_cert; /* For a user certificate */
            +ckmc_cert_s c_cert1; /* For an intermediate untrusted CA certificate */
            +ckmc_cert_list_s untrustedcerts; /* Linked list of untrusted CA certificates */
            +ckmc_cert_list_s *cert_chain_list; /* Linked list of a certificate chain */
             
             int cnt = 0;
             ckmc_cert_list_s *current;
            @@ -731,11 +692,11 @@ const char *im =
             "qQ2mRHNQ3XBb7a1+Srwi1agm5MKFIA3Z\n"
             "-----END CERTIFICATE-----\n";
             
            -c_cert.raw_cert = (unsigned char *) ee;
            +c_cert.raw_cert = (unsigned char *)ee;
             c_cert.cert_size = strlen(ee);
             c_cert.data_format = CKMC_FORM_PEM;
             
            -c_cert1.raw_cert = (unsigned char *) im;
            +c_cert1.raw_cert = (unsigned char *)im;
             c_cert1.cert_size = strlen(im);
             c_cert1.data_format = CKMC_FORM_PEM;
             
            @@ -744,19 +705,15 @@ untrustedcerts.next = NULL;
             
             ret = ckmc_get_cert_chain(&c_cert, &untrustedcerts, &cert_chain_list);
             if (CKMC_ERROR_NONE != ret)
            -{
            -   // Error handling
            -}
            +    /* Error handling */
             
             next=cert_chain_list;
            -do
            -{
            -   current = next;
            -   next = current->next;
            -}
            -while(next != NULL);
            +do {
            +    current = next;
            +    next = current->next;
            +} while (next != NULL);
             
            -ckmc_cert_list_all_free(cert_chain_list); // Called when the list is no longer needed
            +ckmc_cert_list_all_free(cert_chain_list); /* Called when the list is no longer needed */
             
          • Get a certificate chain with aliases of untrusted CA certificates.

            @@ -768,10 +725,10 @@ char* password = NULL; const char *ca_alias = "untrusted_ca_cert1"; ckmc_policy_s test_policy; -ckmc_cert_s c_cert; // For a user certificate -ckmc_cert_s c_cert1; // For an intermediate untrusted CA certificate -ckmc_alias_list_s untrustedcerts; // Linked list of untrusted CA certificate's aliases -ckmc_cert_list_s *cert_chain_list; // Linked list of a certificate chain +ckmc_cert_s c_cert; /* For a user certificate */ +ckmc_cert_s c_cert1; /* For an intermediate untrusted CA certificate */ +ckmc_alias_list_s untrustedcerts; /* Linked list of untrusted CA certificate's aliases */ +ckmc_cert_list_s *cert_chain_list; /* Linked list of a certificate chain */ int cnt = 0; ckmc_cert_list_s *current; @@ -849,11 +806,11 @@ const char *im = "qQ2mRHNQ3XBb7a1+Srwi1agm5MKFIA3Z\n" "-----END CERTIFICATE-----\n"; -c_cert.raw_cert = (unsigned char *) ee; +c_cert.raw_cert = (unsigned char *)ee; c_cert.cert_size = strlen(ee); c_cert.data_format = CKMC_FORM_PEM; -c_cert1.raw_cert = (unsigned char *) im; +c_cert1.raw_cert = (unsigned char *)im; c_cert1.cert_size = strlen(im); c_cert1.data_format = CKMC_FORM_PEM; @@ -862,28 +819,22 @@ test_policy.extractable = true; ret = ckmc_save_cert(ca_alias, c_cert1, test_policy); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ untrustedcerts.alias = (char *)ca_alias; untrustedcerts.next = NULL; ret = ckmc_get_cert_chain_with_alias(&c_cert, &untrustedcerts, &cert_chain_list); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ next=cert_chain_list; -do -{ -   current = next; -   next = current->next; -} -while(next != NULL); +do { +    current = next; +    next = current->next; +} while (next != NULL); -ckmc_cert_list_all_free(cert_chain_list); // Called when the list is no longer needed +ckmc_cert_list_all_free(cert_chain_list); /* Called when the list is no longer needed */

          Loading a Certificate or a PKCS#12 File

          @@ -895,18 +846,16 @@ ckmc_cert_list_all_free(cert_chain_list); // Called when the list is no longer n int ret = CKMC_ERROR_NONE; ckmc_cert_s *pcert; -// defined_media_storage_directory can be obtained with the storage_get_directory() function -const char *file_name = "<defined_media_storage_directory>/ckmc_test_cert.pem"; +/* defined_media_storage_directory can be obtained with the storage_get_directory() function */ +const char *file_name = "<defined_media_storage_directory>/ckmc_test_cert.pem"; ret = ckmc_load_cert_from_file(file_name, &pcert); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ dlog_print(DLOG_INFO, LOG_TAG, "cert size =%d\n", pcert->cert_size); -ckmc_cert_free(pcert); // Called when the certificate is no longer needed +ckmc_cert_free(pcert); /* Called when the certificate is no longer needed */
        • Load from a PKCS#12 file:

          @@ -914,36 +863,28 @@ ckmc_cert_free(pcert); // Called when the certificate is no longer needed int ret = CKMC_ERROR_NONE; ckmc_pkcs12_s *ppkcs12 = NULL; -// defined_media_storage_directory can be obtained with the storage_get_directory() function -const char *p12file = "<defined_media_storage_directory>/ckmc_p12_test.p12"; -const char *password = "password"; // PKCS#12 file can be protected by a password +/* defined_media_storage_directory can be obtained with the storage_get_directory() function */ +const char *p12file = "<defined_media_storage_directory>/ckmc_p12_test.p12"; +const char *password = "password"; /* PKCS#12 file can be protected by a password */ ret = ckmc_pkcs12_load(p12file, password, &ppkcs12); if (CKMC_ERROR_NONE != ret || ppkcs12 == NULL) - -{ -   // Error handling -} +    /* Error handling */ if (ppkcs12->priv_key != NULL) -{ -   // Check a private key -} +    /* Check a private key */ if (ppkcs12->cert != NULL) -{ -   // Check a certificate -} +    /* Check a certificate */ int cnt = 0; ckmc_cert_list_s *tmp_list = ppkcs12->ca_chain; -while(tmp_list!= NULL) -{ -   // Check a certificate list +while (tmp_list!= NULL) { +    /* Check a certificate list */ -   tmp_list = tmp_list->next; +    tmp_list = tmp_list->next; } -ckmc_pkcs12_free(ppkcs12); // Called when the pkcs12 data is no longer needed +ckmc_pkcs12_free(ppkcs12); /* Called when the pkcs12 data is no longer needed */
        @@ -965,14 +906,11 @@ const char *char_bin_data = "Access control test Data"; test_policy.password = password; test_policy.extractable = true; -test_data.data = (unsigned char *) char_bin_data; +test_data.data = (unsigned char *)char_bin_data; test_data.size = strlen(char_bin_data); ret = ckmc_save_data(alias, test_data, test_policy); if (CKMC_ERROR_NONE != ret) - -{ -   // Error handling -} +    /* Error handling */
      • Set a rule to allow access:

        @@ -983,19 +921,15 @@ const char *target1 = "accessor-allow-1"; const char *target2 = "accessor-allow-2"; const char *alias = "targetData"; -// Only allow reading data -ret = ckmc_set_permission(alias, target1, CKMC_PERMISSION_READ); +/* Only allow reading data */ +ret = ckmc_set_permission(alias, target1, CKMC_PERMISSION_READ); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ -// Allow reading and deleting data -ret = ckmc_set_permission(alias, target2, CKMC_PERMISSION_READ | CKMC_PERMISSION_REMOVE); +/* Allow reading and deleting data */ +ret = ckmc_set_permission(alias, target2, CKMC_PERMISSION_READ | CKMC_PERMISSION_REMOVE); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */
      • Set a rule to deny access:

        @@ -1005,20 +939,15 @@ int ret = CKMC_ERROR_NONE; const char *target = "denied-accessor"; const char *alias = "targetData"; -// Allow the target user to a read (alias) -ret = ckmc_set_permission(alias, target, CKMC_PERMISSION_READ); +/* Allow the target user to a read (alias) */ +ret = ckmc_set_permission(alias, target, CKMC_PERMISSION_READ); if (CKMC_ERROR_NONE != ret) -{ -   // Error handling -} +    /* Error handling */ -// Deny the target user access to data (alias) -ret = ckmc_set_permission(alias, target, CKMC_PERMISSION_NONE); +/* Deny the target user access to data (alias) */ +ret = ckmc_set_permission(alias, target, CKMC_PERMISSION_NONE); if (CKMC_ERROR_NONE != ret) - -{ -   // Error handling -} +    /* Error handling */
      • diff --git a/org.tizen.tutorials/html/native/security/privilege_tutorial_n.htm b/org.tizen.tutorials/html/native/security/privilege_tutorial_n.htm index 5eb0bfc..b64818f 100644 --- a/org.tizen.tutorials/html/native/security/privilege_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/security/privilege_tutorial_n.htm @@ -62,36 +62,40 @@
      • Get the privilege display name using the privilege_info_get_display_name() function:
         char* displayName = NULL;
        -int retVal = privilege_info_get_display_name("2.2", 
        +int retVal = privilege_info_get_display_name("2.2",
                                                      "http://tizen.org/privilege/application.launch",
        -                                             &displayName);
        +                                             &displayName); +
      • Get the privilege display name by package type using the privilege_info_get_display_name_by_pkgtype() function:
         char* displayName = NULL;
        -int retVal = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", 
        -                                                        "2.2", 
        -                                                        "http://tizen.org/privilege/application.launch", 
        -                                                        &displayName);
        +int retVal = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", +                                                        "2.2", +                                                        "http://tizen.org/privilege/application.launch", +                                                        &displayName); +
      • Get the privilege description using the privilege_info_get_description() function:
         char* description = NULL;
        -int retVal = privilege_info_get_description("2.2", 
        -                                            "http://tizen.org/privilege/application.launch", 
        -                                            &description);
        +int retVal = privilege_info_get_description("2.2", +                                            "http://tizen.org/privilege/application.launch", +                                            &description); +
      • Get the privilege description by package type using the privilege_info_get_description_by_pkgtype() function:
         char* description = NULL;
        -int retVal = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", 
        -                                                       "2.2", 
        -                                                       "http://tizen.org/privilege/application.launch", 
        -                                                       &description);
        +int retVal = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", +                                                       "2.2", +                                                       "http://tizen.org/privilege/application.launch", +                                                       &description); +
      diff --git a/org.tizen.tutorials/html/native/social/calendar_tutorial_n.htm b/org.tizen.tutorials/html/native/social/calendar_tutorial_n.htm index 9d8385f..37f33c9 100644 --- a/org.tizen.tutorials/html/native/social/calendar_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/social/calendar_tutorial_n.htm @@ -21,7 +21,8 @@

      Content

        -
      • Initializing the Calendar
      • +
      • Prerequisites
      • +
      • Initializing the Calendar
      • Events
        • Creating an Event
        • @@ -65,20 +66,14 @@

          This feature is supported in mobile applications only.

          -

          Prerequisites

          -

          To use the contacts API, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file.

          -
          -<privileges>
          -    <privilege>http://tizen.org/privilege/calendar.read</privilege>
          -    <privilege>http://tizen.org/privilege/calendar.write</privilege>
          -</privileges>
          -

          Warm-up

          Become familiar with the Calendar API basics by learning about:

          +

          Prerequisites

          + +

          To use the Calendar API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

          +
          +<privileges>
          +   <privilege>http://tizen.org/privilege/calendar.read</privilege>
          +   <privilege>http://tizen.org/privilege/calendar.write</privilege>
          +</privileges>
          +
          +

          Initializing the Calendar

          To initialize the calendar service for use:

          @@ -139,7 +144,7 @@ int error_code; error_code = calendar_connect(); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_connect failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_connect failed: %x\n", error_code); @@ -148,7 +153,7 @@ if (error_code != CALENDAR_ERROR_NONE)
           error_code = calendar_disconnect();
           if (error_code != CALENDAR_ERROR_NONE)
          -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_disconnect failed: %x\n", error_code);
          +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_disconnect failed: %x\n", error_code);
           
          @@ -158,6 +163,8 @@ if (error_code != CALENDAR_ERROR_NONE)

          Creating a new event involves creating an event handle, setting the event properties, and inserting the event into the calendar database.

          +

          Some event properties are defined as child records that are associated with the parent record. For a detailed list of the event properties, see the _calendar_event view description in the Calendar API. If the property type is child list, the property is defined as a child record.

          +

          To create a new event:

            @@ -168,20 +175,32 @@ if (error_code != CALENDAR_ERROR_NONE) calendar_record_h event = NULL; error_code = calendar_record_create(_calendar_event._uri, &event); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_record_create failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_record_create failed: %x\n", error_code); + + + + + + + + + + +
            Note
            Records created with the calendar_record_create() function are memory objects, with calendar_record_h type variables as their handles. If you changes these objects, the changes are not reflected in the calendar database until you explicitly insert or update the objects to the database using the calendar_db_insert_record() or calendar_db_update_record() function.
            +
          1. Set the event properties:

            -
              +
              • Set the subject.

                To set the subject for the event, use the calendar_record_set_str() function with the _calendar_event.summary property as the second parameter:

                 error_code = calendar_record_set_str(event, _calendar_event.summary, "summary");
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set summary failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set summary failed: %x\n", error_code);
                 
              • @@ -190,7 +209,7 @@ if (error_code != CALENDAR_ERROR_NONE)
                 error_code = calendar_record_set_str(event, _calendar_event.description, "description");
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set description failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set description failed: %x\n", error_code);
                 
              • @@ -199,11 +218,11 @@ if (error_code != CALENDAR_ERROR_NONE)
                 error_code = calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set start_tzid failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set start_tzid failed: %x\n", error_code);
                 
                 error_code = calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set end_tzid failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set end_tzid failed: %x\n", error_code);
                 
              • @@ -212,17 +231,17 @@ if (error_code != CALENDAR_ERROR_NONE)
                 calendar_time_s starttime = {0};
                 starttime.type = CALENDAR_TIME_UTIME;
                -starttime.time.utime = 1404036000; // 2014/06/29 10:00:00 UTC
                +starttime.time.utime = 1404036000; /* 2014/06/29 10:00:00 UTC */
                 error_code = calendar_record_set_caltime(event, _calendar_event.start_time, starttime);
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set start_time failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set start_time failed: %x\n", error_code);
                 
                 calendar_time_s endtime = {0};
                 endtime.type = CALENDAR_TIME_UTIME;
                -endtime.time.utime = 1404036000 + 3600; // 2014/06/29 11:00:00 UTC
                +endtime.time.utime = 1404036000 + 3600; /* 2014/06/29 11:00:00 UTC */
                 error_code = calendar_record_set_caltime(event, _calendar_event.end_time, endtime);
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set end_time failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set end_time failed: %x\n", error_code);
                 

                The calendar_time_s structure has 2 types. For more information about the structure, see the Time Structure guide.

              • @@ -236,15 +255,15 @@ if (error_code != CALENDAR_ERROR_NONE) error_code = calendar_record_set_int(event, _calendar_event.freq,                                      CALENDAR_RECURRENCE_MONTHLY); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "set freq failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "set freq failed: %x\n", error_code); error_code = calendar_record_set_int(event, _calendar_event.interval, 1); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "set interval failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "set interval failed: %x\n", error_code); error_code = calendar_record_set_str(event, _calendar_event.bymonthday, "3,4,5"); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "set bymonthday failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "set bymonthday failed: %x\n", error_code);
              • @@ -254,11 +273,11 @@ if (error_code != CALENDAR_ERROR_NONE) error_code = calendar_record_set_int(event, _calendar_event.range_type,                                      CALENDAR_RANGE_COUNT); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "set range_type failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "set range_type failed: %x\n", error_code); error_code = calendar_record_set_int(event, _calendar_event.count, 8); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "set count failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "set count failed: %x\n", error_code);
            @@ -273,23 +292,23 @@ calendar_record_h alarm = NULL; calendar_time_s ct; error_code = CALENDAR_ERROR_NONE; -// Create the alarm record +/* Create the alarm record */ error_code += calendar_record_create(_calendar_alarm._uri, &alarm); -// Set the properties +/* Set the properties */ error_code += calendar_record_set_int(alarm, _calendar_alarm.tick_unit,                                       CALENDAR_ALARM_TIME_UNIT_SPECIFIC); ct.type = CALENDAR_TIME_UTIME; -ct.time.utime = 1404036000 - 60; // 60 sec before starttime (1404036000) +ct.time.utime = 1404036000 - 60; /* 60 sec before starttime (1404036000) */ error_code += calendar_record_set_caltime(alarm, _calendar_alarm.alarm_time, ct); -// Add to the event as a child record +/* Add to the event as a child record */ error_code += calendar_record_add_child_record(event,                                                _calendar_event.calendar_alarm,                                                alarm); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "adding the alarm failed \n"); +    dlog_print(DLOG_ERROR, LOG_TAG, "adding the alarm failed \n");

            The calendar_alarm_time_unit_type_e enumeration defines the available alarm tick units.

            @@ -311,57 +330,71 @@ if (error_code != CALENDAR_ERROR_NONE) calendar_record_h attendee = NULL; error_code = CALENDAR_ERROR_NONE; -// Create the attendee record +/* Create the attendee record */ error_code += calendar_record_create(_calendar_attendee._uri, &attendee); -// Set the attendee properties +/* Set the attendee properties */ error_code += calendar_record_set_str(attendee, _calendar_attendee.name, "John"); -// Add to the event as a child record +/* Add to the event as a child record */ error_code += calendar_record_add_child_record(event,                                                _calendar_event.calendar_attendee,                                                attendee); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "adding the attendee failed \n"); +    dlog_print(DLOG_ERROR, LOG_TAG, "adding the attendee failed \n"); - +

            Set other event properties similarly, as needed.

          2. -

            Insert the event into the calendar database using the calendar_db_insert_record() function.

            +

            Insert the event into the calendar database using the calendar_db_insert_record() function. All child records added to the event using the calendar_record_add_child_record() function are inserted automatically along with the parent.

            The system assigns a unique ID to the event, and the function returns it as its second parameter.

             int id = -1;
             error_code = calendar_db_insert_record(event, &id);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code);
             
             dlog_print(DLOG_ERROR, LOG_TAG, "id: %d\n", id);
             
          3. -

            Destroy the event handle and release all its resources using the calendar_record_destroy() function:

            +

            When no longer needed, destroy the event handle and release all its resources using the calendar_record_destroy() function:

             calendar_record_destroy(event, true);
             
            +

            If you set the second parameter to true, all child records of the given record are also destroyed, irrespective of how the child records were added (individually or along with their parent record).

          4. Retrieving Events

            -

            To retrieve a single event, use the calendar_db_get_record() function with the event ID as the second parameter:

            +

            To retrieve a single event:

            + +
              +
            1. +

              Retrieve an event record using the calendar_db_get_record() function with the event ID as the second parameter:

               calendar_record_h record;
              -const int event_id = ... // Get the event ID
              +const int event_id = ...; /* Get the event ID */
               error_code = calendar_db_get_record(_calendar_event._uri, event_id, &record);
               if (error_code != CALENDAR_ERROR_NONE)
              -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
              +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
              +
              +
            2. + +
            3. +

              When no longer needed, destroy the event handle and release all its resources using the calendar_record_destroy() function:

              +
              +calendar_record_destroy(record, true);
               
              +
            4. +

            To retrieve multiple events:

            @@ -376,7 +409,7 @@ if (error_code != CALENDAR_ERROR_NONE) calendar_list_h list = NULL; error_code = calendar_db_get_all_records(_calendar_event._uri, 0, 0, &list); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_all_records failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_all_records failed: %x\n", error_code);
          5. @@ -390,7 +423,7 @@ calendar_query_h query = NULL; error_code = calendar_query_create(_calendar_event._uri, &query); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_query_create failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_query_create failed: %x\n", error_code);
          6. @@ -400,32 +433,32 @@ calendar_filter_h filter = NULL; error_code = calendar_filter_create(_calendar_event._uri, &filter); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_filter_create failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_filter_create failed: %x\n", error_code);
          7. -

            Add a filtering condition using the calendar_filter_add_str() function.

            -

            The following example adds a filtering condition that retrieves the events whose summary field contains the string "summary to find":

            +

            Add a filtering condition using the calendar_filter_add_XXX() function.

            +

            The following example adds a string-based filtering condition that retrieves the events whose summary field contains the string "summary to find":

             error_code = calendar_filter_add_str(filter, _calendar_event.summary,
                                                  CALENDAR_MATCH_CONTAINS, "summary to find");
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
             
          8. To add more conditions, define an operator between the conditions.

            -

            The following example first adds an AND operator and then a filtering condition that retrieves the events whose description field contains the string "description to find".

            +

            The following example first adds an AND operator and then a string-based filtering condition that retrieves the events whose description field contains the string "description to find".

            The combination of the AND operator and the 2 conditions means that the filter only retrieves the events that contain "summary to find" in their summary and "description to find" in their description.

             error_code = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_filter_add_operator failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_filter_add_operator failed: %x\n", error_code);
             
             error_code = calendar_filter_add_str(filter, _calendar_event.description,
                                                  CALENDAR_MATCH_CONTAINS, "description to find");
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
             

            You can also create a filter with integer and time conditions. For example, to filter all-day events that start after January 1st, 2016:

            @@ -437,7 +470,7 @@ time_to_compare.time.date.year = 2016;
             error_code = calendar_filter_add_caltime(filter, _calendar_event.start_time,
                                                      CALENDAR_MATCH_GREATER_THAN, time_to_compare);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
             

            The calendar_time_s structure's type parameter determines whether the event is an all-day event (CALENDAR_TIME_LOCALTIME) or a non-all-day event (CALENDAR_TIME_UTIME).

            To retrieve the specified time period, use 2 conditions using CALENDAR_MATCH_GREATER_THAN and CALENDAR_MATCH_LESS_THAN with the operator CALENDAR_FILTER_OPERATOR_AND. You can also use CALENDAR_MATCH_EQUAL to set an equality condition.

            @@ -447,7 +480,7 @@ if (error_code != CALENDAR_ERROR_NONE)
             error_code = calendar_query_set_filter(query, filter);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_query_set_filter failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_query_set_filter failed: %x\n", error_code);
             
          9. @@ -455,12 +488,12 @@ if (error_code != CALENDAR_ERROR_NONE)
             error_code = calendar_db_get_records_with_query(query, 0, 0, &list);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_records_with_query failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_records_with_query failed: %x\n", error_code);
             

            The third parameter defines a limit for the number of results. If you set it to 0, the list returns all events matching the query.

          10. -

            Destroy the filter and query handles and release all their resources using the calendar_filter_destroy() and calendar_query_destroy() functions:

            +

            When no longer needed, destroy the filter and query handles and release all their resources using the calendar_filter_destroy() and calendar_query_destroy() functions:

             calendar_filter_destroy(filter);
             calendar_query_destroy(query);
            @@ -490,15 +523,14 @@ calendar_query_destroy(query);
             

            The following example iterates through the list and retrieves the summary of each event:

             calendar_record_h record;
            -while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
            -{
            -   char* summary;
            -   calendar_record_get_str_p(record, _calendar_event.summary, &summary);
            -   dlog_print(DLOG_ERROR, LOG_TAG, "summary: %s\n", summary);
            -
            -   error_code = calendar_list_next(list);
            -   if (error_code != CALENDAR_ERROR_NONE)
            -      break;
            +while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
            +    char* summary;
            +    calendar_record_get_str_p(record, _calendar_event.summary, &summary);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "summary: %s\n", summary);
            +
            +    error_code = calendar_list_next(list);
            +    if (error_code != CALENDAR_ERROR_NONE)
            +        break;
             }
             
          11. @@ -507,92 +539,86 @@ while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_N
             calendar_gl_event_data_t *gl_event_data = NULL;
             calendar_record_h record = NULL;
            -while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
            -{
            -   gl_event_data = _create_gl_event_data(record);
            -   // You can get, for example, summary:
            -   // gl_event_data->summary
            +while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
            +    gl_event_data = _create_gl_event_data(record);
            +    /* You can get, for example, summary: */
            +    /* gl_event_data->summary */
             
            -   _free_gl_event_data(gl_event_data);
            +    _free_gl_event_data(gl_event_data);
             
            -   error_code = calendar_list_next(list);
            -   if (error_code != CALENDAR_ERROR_NONE)
            -      break;
            +    error_code = calendar_list_next(list);
            +    if (error_code != CALENDAR_ERROR_NONE)
            +        break;
             }
             

            Define the calendar_gl_event_data_t structure and the functions for using the structure:

            -typedef struct
            -_calendar_gl_event_data
            -{
            -   int id;
            -   char *summary;
            -   char *description;
            -   calendar_time_s start_time;
            -} calendar_gl_event_data_t;
            +struct _calendar_gl_event_data {
            +    int id;
            +    char *summary;
            +    char *description;
            +    calendar_time_s start_time;
            +};
            +typedef struct _calendar_gl_event_data calendar_gl_event_data_t;
             
            -// Release the resources allocated to the structure
            +/* Release the resources allocated to the structure */
             static void
             _free_gl_event_data(calendar_gl_event_data_t *gl_event_data)
             {
            -   if (NULL == gl_event_data)
            -      return;
            +    if (NULL == gl_event_data)
            +        return;
             
            -   free(gl_event_data->summary);
            -   free(gl_event_data->description);
            -   free(gl_event_data);
            +    free(gl_event_data->summary);
            +    free(gl_event_data->description);
            +    free(gl_event_data);
             }
             
            -// Create the structure for an event
            +/* Create the structure for an event */
             static calendar_gl_event_data_t*
             _create_gl_event_data(calendar_record_h record)
             {
            -   calendar_gl_event_data_t *gl_event_data;
            -   int error_code;
            -
            -   gl_event_data = malloc(sizeof(calendar_gl_event_data_t));
            -   memset(gl_event_data, 0x0, sizeof(calendar_gl_event_data_t));
            -
            -   error_code = calendar_record_get_str(record, _calendar_event.summary,
            -                                        &gl_event_data->summary);
            -   if (error_code != CALENDAR_ERROR_NONE)
            -   {
            -      dlog_print(DLOG_ERROR, LOG_TAG, "get summary failed: %i\n", error_code);
            -      _free_gl_event_data(gl_event_data);
            -
            -      return NULL;
            -   }
            -
            -   error_code = calendar_record_get_str(record, _calendar_event.description,
            -                                        &gl_event_data->description);
            -   if (error_code != CALENDAR_ERROR_NONE)
            -   {
            -      dlog_print(DLOG_ERROR, LOG_TAG, "get description failed: %i\n", error_code);
            -      _free_gl_event_data(gl_event_data);
            -
            -      return NULL;
            -   }
            -
            -   error_code = calendar_record_get_int(record, _calendar_event.id, &gl_event_data->id);
            -   if (error_code != CALENDAR_ERROR_NONE)
            -   {
            -      dlog_print(DLOG_ERROR, LOG_TAG, "get id failed: %i\n", error_code);
            -      _free_gl_event_data(gl_event_data);
            -
            -      return NULL;
            -   }
            -
            -   error_code = calendar_record_get_caltime(record, _calendar_event.start_time,
            -                                            &gl_event_data->start_time);
            -   if (error_code != CALENDAR_ERROR_NONE)
            -   {
            -      dlog_print(DLOG_ERROR, LOG_TAG, "get start_time failed: %i\n", error_code);
            -      _free_gl_event_data(gl_event_data);
            -
            -      return NULL;
            -   }
            -
            -   return gl_event_data;
            +    calendar_gl_event_data_t *gl_event_data;
            +    int error_code;
            +
            +    gl_event_data = malloc(sizeof(calendar_gl_event_data_t));
            +    memset(gl_event_data, 0x0, sizeof(calendar_gl_event_data_t));
            +
            +    error_code = calendar_record_get_str(record, _calendar_event.summary,
            +                                         &gl_event_data->summary);
            +    if (error_code != CALENDAR_ERROR_NONE) {
            +        dlog_print(DLOG_ERROR, LOG_TAG, "get summary failed: %i\n", error_code);
            +        _free_gl_event_data(gl_event_data);
            +
            +        return NULL;
            +    }
            +
            +    error_code = calendar_record_get_str(record, _calendar_event.description,
            +                                         &gl_event_data->description);
            +    if (error_code != CALENDAR_ERROR_NONE) {
            +        dlog_print(DLOG_ERROR, LOG_TAG, "get description failed: %i\n", error_code);
            +        _free_gl_event_data(gl_event_data);
            +
            +        return NULL;
            +    }
            +
            +    error_code = calendar_record_get_int(record, _calendar_event.id, &gl_event_data->id);
            +    if (error_code != CALENDAR_ERROR_NONE) {
            +        dlog_print(DLOG_ERROR, LOG_TAG, "get id failed: %i\n", error_code);
            +        _free_gl_event_data(gl_event_data);
            +
            +        return NULL;
            +    }
            +
            +    error_code = calendar_record_get_caltime(record, _calendar_event.start_time,
            +                                             &gl_event_data->start_time);
            +    if (error_code != CALENDAR_ERROR_NONE) {
            +        dlog_print(DLOG_ERROR, LOG_TAG, "get start_time failed: %i\n", error_code);
            +        _free_gl_event_data(gl_event_data);
            +
            +        return NULL;
            +    }
            +
            +    return gl_event_data;
             }
             

            To access a specific event detail in a child record, retrieve the child record.

            @@ -601,7 +627,7 @@ _create_gl_event_data(calendar_record_h record)
          12. -

            Destroy the list handle and release all its resources using the calendar_list_destroy() function:

            +

            When no longer needed, destroy the list handle and release all its resources using the calendar_list_destroy() function:

             calendar_list_destroy(list, true);
             
            @@ -619,11 +645,14 @@ calendar_list_destroy(list, true);

            Retrieve the event you want to update using the calendar_db_get_record() function with the event ID as the second parameter:

             calendar_record_h record;
            -const int event_id = ... // Get the event ID
            +const int event_id = ...; /* Get the event ID */
             error_code = calendar_db_get_record(_calendar_event._uri, event_id, &record);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
             
            + +

            You can also retrieve the event using a search function, such as calendar_db_get_records_with_query().

            +
          13. @@ -632,11 +661,11 @@ if (error_code != CALENDAR_ERROR_NONE)
             error_code = calendar_record_set_str(record, _calendar_event.summary, "summary updated");
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "set summary failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "set summary failed: %x\n", error_code);
             
             error_code = calendar_record_set_str(record, _calendar_event.description, "description updated");
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "set description failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "set description failed: %x\n", error_code);
             
          14. @@ -645,12 +674,12 @@ if (error_code != CALENDAR_ERROR_NONE)
             error_code = calendar_db_update_record(record);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_update_record failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_update_record failed: %x\n", error_code);
             
          15. -

            Destroy the event handle and release all its resources using the calendar_record_destroy() function:

            +

            When no longer needed, destroy the event handle and release all its resources using the calendar_record_destroy() function:

             calendar_record_destroy(record, true);
             
            @@ -663,10 +692,10 @@ calendar_record_destroy(record, true);

            To delete an event, use the calendar_db_delete_record() function with the event ID as the second parameter:

            -int event_id = ... // Get the event ID
            +int event_id = ...; /* Get the event ID */
             error_code = calendar_db_delete_record(_calendar_event._uri, event_id);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_delete_record failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_delete_record failed: %x\n", error_code);
             

            Removing an Instance from a Recurring Event

            @@ -712,7 +741,7 @@ error_code += calendar_record_set_int(event, _calendar_event.range_type, CALENDA error_code += calendar_record_set_int(event, _calendar_event.count, 8); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "creating the event failed: \n"); +    dlog_print(DLOG_ERROR, LOG_TAG, "creating the event failed: \n");

            The event has 8 instances:

          16. @@ -750,7 +779,7 @@ if (error_code != CALENDAR_ERROR_NONE)
             error_code = calendar_record_set_str(event, _calendar_event.exdate, "20121104T010000Z");
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "set exdate failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "set exdate failed: %x\n", error_code);
             
            @@ -760,7 +789,7 @@ if (error_code != CALENDAR_ERROR_NONE) int event_id; error_code = calendar_db_insert_record(event, &event_id); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code); calendar_record_destroy(event, true); @@ -788,7 +817,7 @@ error_code += calendar_record_set_int(clone, _calendar_event.original_event_id, error_code += calendar_record_set_str(clone, _calendar_event.recurrence_id, "20121005T010000Z"); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "cloning the event failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "cloning the event failed: %x\n", error_code); @@ -802,7 +831,7 @@ if (error_code != CALENDAR_ERROR_NONE) int exdate_event_id = 0; error_code = calendar_db_insert_record(clone, &exdate_event_id); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code); calendar_record_destroy(clone, true); calendar_record_destroy(event, true); @@ -822,7 +851,7 @@ calendar_record_destroy(event, true);
             error_code = calendar_db_add_changed_cb(_calendar_event._uri, _event_changed_callback, NULL);
             if (error_code != CALENDAR_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_add_changed_cb failed: %x\n", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_add_changed_cb failed: %x\n", error_code);
             
            @@ -830,30 +859,31 @@ if (error_code != CALENDAR_ERROR_NONE)

            Define the event change callback.

            The following example shows how to retrieve the new event details in the callback:

            -static calendar_gl_event_data_t *_gl_event_data = ...
            +static calendar_gl_event_data_t *_gl_event_data = ...;
            +
             static void
             _event_changed_callback(const char *view_uri, void *user_data)
             {
            -   if (0 != strcmp(view_uri, _calendar_event._uri))
            -      return;
            +    if (0 != strcmp(view_uri, _calendar_event._uri))
            +        return;
             
            -   if (NULL == _gl_event_data)
            -      return;
            +    if (NULL == _gl_event_data)
            +        return;
             
            -   int event_id = _gl_event_data->id;
            -   _free_gl_event_data(_gl_event_data);
            -   _gl_event_data = NULL;
            +    int event_id = _gl_event_data->id;
            +    _free_gl_event_data(_gl_event_data);
            +    _gl_event_data = NULL;
             
            -   calendar_record_h record = NULL;
            -   int error_code;
            -   error_code = calendar_db_get_record(_calendar_event._uri, event_id, &record);
            -   if (error_code != CALENDAR_ERROR_NONE)
            -      return;
            +    calendar_record_h record = NULL;
            +    int error_code;
            +    error_code = calendar_db_get_record(_calendar_event._uri, event_id, &record);
            +    if (error_code != CALENDAR_ERROR_NONE)
            +        return;
             
            -   _gl_event_data = _create_gl_event_data(record);
            -   // Use _gl_event_data
            +    _gl_event_data = _create_gl_event_data(record);
            +    /* Use _gl_event_data */
             
            -   calendar_record_destroy(record, true);
            +    calendar_record_destroy(record, true);
             }
             
            @@ -864,6 +894,8 @@ _event_changed_callback(const char *view_uri, void *user_data)

            Creating a new todo involves creating a todo handle, setting the todo properties, and inserting the todo into the calendar database.

            +

            Some todo properties are defined as child records that are associated with the parent record. For a detailed list of the todo properties, see the _calendar_todo view description in the Calendar API. If the property type is child list, the property is defined as a child record.

            +

            To create a new todo:

              @@ -874,20 +906,32 @@ _event_changed_callback(const char *view_uri, void *user_data) calendar_record_h todo = NULL; error_code = calendar_record_create(_calendar_todo._uri, &todo); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_record_create failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_record_create failed: %x\n", error_code); + +
            + + + + + + + + +
            Note
            Records created with the calendar_record_create() function are memory objects, with calendar_record_h type variables as their handles. If you changes these objects, the changes are not reflected in the calendar database until you explicitly insert or update the objects to the database using the calendar_db_insert_record() or calendar_db_update_record() function.
            +
          17. Set the todo properties:

            -
              +
              • Set the subject.

                To set the subject for the todo, use the calendar_record_set_str() function with the _calendar_todo.summary property as the second parameter:

                 error_code = calendar_record_set_str(todo, _calendar_todo.summary, "summary");
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set summary failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set summary failed: %x\n", error_code);
                 
              • @@ -896,7 +940,7 @@ if (error_code != CALENDAR_ERROR_NONE)
                 error_code = calendar_record_set_str(todo, _calendar_todo.description, "description");
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set description failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set description failed: %x\n", error_code);
                 
              • @@ -905,11 +949,11 @@ if (error_code != CALENDAR_ERROR_NONE)
                 calendar_time_s duetime = {0};
                 duetime.type = CALENDAR_TIME_UTIME;
                -duetime.time.utime = 1404036000; // 2014/06/29 11:00:00 UTC
                +duetime.time.utime = 1404036000; /* 2014/06/29 11:00:00 UTC */
                 
                 error_code = calendar_record_set_caltime(todo, _calendar_todo.due_time, duetime);
                 if (error_code != CALENDAR_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "set due_time failed: %x\n", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "set due_time failed: %x\n", error_code);
                 
              • @@ -919,43 +963,58 @@ if (error_code != CALENDAR_ERROR_NONE) error_code = calendar_record_set_int(todo, _calendar_todo.todo_status,                                      CALENDAR_TODO_STATUS_COMPLETED); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "set todo_status failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "set todo_status failed: %x\n", error_code);
              • -
            +

        Set other todo properties similarly, as needed.

      • -

        Insert the todo into the calendar database using the calendar_db_insert_record() function.

        +

        Insert the todo into the calendar database using the calendar_db_insert_record() function. All child records added to the todo using the calendar_record_add_child_record() function are inserted automatically along with the parent.

        The system assigns a unique ID to the todo, and the function returns it as its second parameter.

         int id;
         error_code = calendar_db_insert_record(todo, &id);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code);
         
      • -

        Destroy the todo handle and release all its resources using the calendar_record_destroy() function:

        +

        When no longer needed, destroy the todo handle and release all its resources using the calendar_record_destroy() function:

         calendar_record_destroy(todo, true);
         
        +

        If you set the second parameter to true, all child records of the given record are also destroyed, irrespective of how the child records were added (individually or along with their parent record).

      • Retrieving Todos

        -

        To retrieve a single todo, use the calendar_db_get_record() function with the todo ID as the second parameter:

        +

        To retrieve a single todo:

        + +
          +
        1. +

          Retrieve an todo record using the calendar_db_get_record() function with the todo ID as the second parameter:

           calendar_record_h record;
          -const int todo_id = ... // Get the todo ID
          +const int todo_id = ...; /* Get the todo ID */
           error_code = calendar_db_get_record(_calendar_todo._uri, todo_id, &record);
           if (error_code != CALENDAR_ERROR_NONE)
          -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
          +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
          +
          +
        2. + +
        3. +

          When no longer needed, destroy the todo handle and release all its resources using the calendar_record_destroy() function:

          +
          +calendar_record_destroy(record, true);
           
          +
        4. +
        +

        To retrieve multiple todos:

        @@ -970,7 +1029,7 @@ if (error_code != CALENDAR_ERROR_NONE) calendar_list_h list = NULL; error_code = calendar_db_get_all_records(_calendar_todo._uri, 0, 0, &list); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_all_records failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_all_records failed: %x\n", error_code);
      • @@ -984,7 +1043,7 @@ calendar_query_h query = NULL; error_code = calendar_query_create(_calendar_todo._uri, &query); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_query_create failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_query_create failed: %x\n", error_code);
      • @@ -994,39 +1053,39 @@ calendar_filter_h filter = NULL; error_code = calendar_filter_create(_calendar_todo._uri, &filter); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_filter_create failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_filter_create failed: %x\n", error_code);
      • -

        Add a filtering condition using the calendar_filter_add_str() function.

        -

        The following example adds a filtering condition that retrieves the todos whose summary field contains the string "summary to find":

        +

        Add a filtering condition using the calendar_filter_add_XXX() function.

        +

        The following example adds a string-based filtering condition that retrieves the todos whose summary field contains the string "summary to find":

         error_code = calendar_filter_add_str(filter, _calendar_todo.summary,
                                              CALENDAR_MATCH_CONTAINS, "summary to find");
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
         
      • To add more conditions, define an operator between the conditions.

        -

        The following example first adds an AND operator and then a filtering condition that retrieves the todos whose description field contains the string "description to find".

        -

        The combination of the AND operator and the 2 conditions means that the filter only retrieves the todos that contain "summary to find" in their summary and "description to find" in their description.

        +

        The following example first adds an AND operator and then a string-based filtering condition that retrieves the todos whose description field contains the string "description to find".

        +

        The combination of the AND operator and the 2 conditions means that the filter only retrieves the todos that contain "summary to find" in their summary and "description to find" in their description.

         error_code = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_filter_add_operator failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_filter_add_operator failed: %x\n", error_code);
         
         error_code = calendar_filter_add_str(filter, _calendar_todo.description,
                                              CALENDAR_MATCH_CONTAINS, "description to find");
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
         

        You can also create a filter with integer and time conditions. For example, to filter all completed todos:

         error_code = calendar_filter_add_int(filter, _calendar_todo.todo_status,
                                              CALENDAR_MATCH_EQUAL, CALENDAR_TODO_STATUS_COMPLETED);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x\n", error_code);
         
      • @@ -1034,7 +1093,7 @@ if (error_code != CALENDAR_ERROR_NONE)
         error_code = calendar_query_set_filter(query, filter);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_query_set_filter failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_query_set_filter failed: %x\n", error_code);
         
      • @@ -1042,12 +1101,12 @@ if (error_code != CALENDAR_ERROR_NONE)
         error_code = calendar_db_get_records_with_query(query, 0, 0, &list);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_records_with_query failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_records_with_query failed: %x\n", error_code);
         

        The third parameter defines a limit for the number of results. If you set it to 0, the list returns all todos matching the query.

      • -

        Destroy the filter and query handles and release all their resources using the calendar_filter_destroy() and calendar_query_destroy() functions:

        +

        When no longer needed, destroy the filter and query handles and release all their resources using the calendar_filter_destroy() and calendar_query_destroy() functions:

         calendar_filter_destroy(filter);
         calendar_query_destroy(query);
        @@ -1077,15 +1136,14 @@ calendar_query_destroy(query);
         

        The following example iterates through the list and retrieves the summary of each todo:

         calendar_record_h record;
        -while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
        -{
        -   char* summary;
        -   calendar_record_get_str_p(record, _calendar_todo.summary, &summary);
        -   dlog_print(DLOG_ERROR, LOG_TAG, "summary: %s\n", summary);
        -
        -   error_code = calendar_list_next(list);
        -   if (error_code != CALENDAR_ERROR_NONE)
        -      break;
        +while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
        +    char* summary;
        +    calendar_record_get_str_p(record, _calendar_todo.summary, &summary);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "summary: %s\n", summary);
        +
        +    error_code = calendar_list_next(list);
        +    if (error_code != CALENDAR_ERROR_NONE)
        +        break;
         }
         
      • @@ -1094,92 +1152,86 @@ while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_N
         calendar_gl_todo_data_t *gl_todo_data = NULL;
         calendar_record_h record = NULL;
        -while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
        -{
        -   gl_todo_data = _create_gl_todo_data(record);
        -   // You can get, for example, summary:
        -   // gl_todo_data->summary
        +while (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
        +    gl_todo_data = _create_gl_todo_data(record);
        +    /* You can get, for example, summary: */
        +    /* gl_todo_data->summary */
         
        -   _free_gl_todo_data(gl_todo_data);
        +    _free_gl_todo_data(gl_todo_data);
         
        -   error_code = calendar_list_next(list);
        -   if (error_code != CALENDAR_ERROR_NONE)
        -      break;
        +    error_code = calendar_list_next(list);
        +    if (error_code != CALENDAR_ERROR_NONE)
        +        break;
         }
         

        Define the calendar_gl_todo_data_t structure and the functions for using the structure:

        -typedef struct
        -_calendar_gl_todo_data
        -{
        -   int id;
        -   char *summary;
        -   char *description;
        -   calendar_time_s due_time;
        -} calendar_gl_todo_data_t;
        +struct _calendar_gl_todo_data {
        +    int id;
        +    char *summary;
        +    char *description;
        +    calendar_time_s due_time;
        +};
        +typedef struct _calendar_gl_todo_data calendar_gl_todo_data_t;
         
        -// Release the resources allocated to the structure
        +/* Release the resources allocated to the structure */
         static void
         _free_gl_todo_data(calendar_gl_todo_data_t *gl_todo_data)
         {
        -   if (NULL == gl_todo_data)
        -      return;
        +    if (NULL == gl_todo_data)
        +        return;
         
        -   free(gl_todo_data->summary);
        -   free(gl_todo_data->description);
        -   free(gl_todo_data);
        +    free(gl_todo_data->summary);
        +    free(gl_todo_data->description);
        +    free(gl_todo_data);
         }
         
        -// Create the structure for a todo
        +/* Create the structure for a todo */
         static calendar_gl_todo_data_t*
         _create_gl_todo_data(calendar_record_h record)
         {
        -   calendar_gl_todo_data_t *gl_todo_data;
        -   int error_code;
        -
        -   gl_todo_data = malloc(sizeof(calendar_gl_todo_data_t));
        -   memset(gl_todo_data, 0x0, sizeof(calendar_gl_todo_data_t));
        -
        -   error_code = calendar_record_get_str(record, _calendar_todo.summary,
        -                                        &gl_todo_data->summary);
        -   if (error_code != CALENDAR_ERROR_NONE)
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "get summary failed: %x\n", error_code);
        -      _free_gl_todo_data(gl_todo_data);
        -
        -      return NULL;
        -   }
        -
        -   error_code = calendar_record_get_str(record, _calendar_todo.description,
        -                                        &gl_todo_data->description);
        -   if (error_code != CALENDAR_ERROR_NONE)
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "get description failed: %x\n", error_code);
        -      _free_gl_todo_data(gl_todo_data);
        -
        -      return NULL;
        -   }
        -
        -   error_code = calendar_record_get_int(record, _calendar_todo.id, &gl_todo_data->id);
        -   if (error_code != CALENDAR_ERROR_NONE)
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "get id failed: %x\n", error_code);
        -      _free_gl_todo_data(gl_todo_data);
        -
        -      return NULL;
        -   }
        -
        -   error_code = calendar_record_get_caltime(record, _calendar_todo.due_time,
        -                                            &gl_todo_data->due_time);
        -   if (error_code != CALENDAR_ERROR_NONE)
        -   {
        -      dlog_print(DLOG_ERROR, LOG_TAG, "get due_time failed: %x\n", error_code);
        -      _free_gl_todo_data(gl_todo_data);
        -
        -      return NULL;
        -   }
        -
        -   return gl_todo_data;
        +    calendar_gl_todo_data_t *gl_todo_data;
        +    int error_code;
        +
        +    gl_todo_data = malloc(sizeof(calendar_gl_todo_data_t));
        +    memset(gl_todo_data, 0x0, sizeof(calendar_gl_todo_data_t));
        +
        +    error_code = calendar_record_get_str(record, _calendar_todo.summary,
        +                                         &gl_todo_data->summary);
        +    if (error_code != CALENDAR_ERROR_NONE) {
        +        dlog_print(DLOG_ERROR, LOG_TAG, "get summary failed: %x\n", error_code);
        +        _free_gl_todo_data(gl_todo_data);
        +
        +        return NULL;
        +    }
        +
        +    error_code = calendar_record_get_str(record, _calendar_todo.description,
        +                                         &gl_todo_data->description);
        +    if (error_code != CALENDAR_ERROR_NONE) {
        +        dlog_print(DLOG_ERROR, LOG_TAG, "get description failed: %x\n", error_code);
        +        _free_gl_todo_data(gl_todo_data);
        +
        +        return NULL;
        +    }
        +
        +    error_code = calendar_record_get_int(record, _calendar_todo.id, &gl_todo_data->id);
        +    if (error_code != CALENDAR_ERROR_NONE) {
        +        dlog_print(DLOG_ERROR, LOG_TAG, "get id failed: %x\n", error_code);
        +        _free_gl_todo_data(gl_todo_data);
        +
        +        return NULL;
        +    }
        +
        +    error_code = calendar_record_get_caltime(record, _calendar_todo.due_time,
        +                                             &gl_todo_data->due_time);
        +    if (error_code != CALENDAR_ERROR_NONE) {
        +        dlog_print(DLOG_ERROR, LOG_TAG, "get due_time failed: %x\n", error_code);
        +        _free_gl_todo_data(gl_todo_data);
        +
        +        return NULL;
        +    }
        +
        +    return gl_todo_data;
         }
         

        To access a specific todo detail in a child record, retrieve the child record.

        @@ -1188,7 +1240,7 @@ _create_gl_todo_data(calendar_record_h record)
      • -

        Destroy the list handle and release all its resources using the calendar_list_destroy() function:

        +

        When no longer needed, destroy the list handle and release all its resources using the calendar_list_destroy() function:

         calendar_list_destroy(list, true);
         
        @@ -1206,11 +1258,14 @@ calendar_list_destroy(list, true);

        Retrieve the todo you want to update using the calendar_db_get_record() function with the todo ID as the second parameter:

         calendar_record_h record;
        -const int todo_id = ... // Get the todo ID
        +const int todo_id = ...; /* Get the todo ID */
         error_code = calendar_db_get_record(_calendar_todo._uri, todo_id, &record);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
         
        + +

        You can also retrieve the todo using a search function, such as calendar_db_get_records_with_query().

        +
      • @@ -1219,11 +1274,11 @@ if (error_code != CALENDAR_ERROR_NONE)
         error_code = calendar_record_set_str(record, _calendar_todo.summary, "summary updated");
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "set summary failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "set summary failed: %x\n", error_code);
         
         error_code = calendar_record_set_str(record, _calendar_todo.description, "description updated");
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "set description failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "set description failed: %x\n", error_code);
         
      • @@ -1232,12 +1287,12 @@ if (error_code != CALENDAR_ERROR_NONE)
         error_code = calendar_db_update_record(record);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_update_record failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_update_record failed: %x\n", error_code);
         
      • -

        Destroy the todo handle and release all its resources using the calendar_record_destroy() function:

        +

        When no longer needed, destroy the todo handle and release all its resources using the calendar_record_destroy() function:

         calendar_record_destroy(record, true);
         
        @@ -1250,10 +1305,10 @@ calendar_record_destroy(record, true);

        To delete a todo, use the calendar_db_delete_record() function with the todo ID as the second parameter:

        -int todo_id = ... // Get the todo ID
        +int todo_id = ...; /* Get the todo ID */
         error_code = calendar_db_delete_record(_calendar_todo._uri, todo_id);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_delete_record failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_delete_record failed: %x\n", error_code);
         

        Monitoring Todo Changes

        @@ -1267,7 +1322,7 @@ if (error_code != CALENDAR_ERROR_NONE)
         error_code = calendar_db_add_changed_cb(_calendar_todo._uri, _todo_changed_callback, NULL);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_add_changed_cb failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_add_changed_cb failed: %x\n", error_code);
         
      • @@ -1275,30 +1330,31 @@ if (error_code != CALENDAR_ERROR_NONE)

        Define the todo change callback.

        The following example shows how to retrieve the new todo details in the callback:

        -static calendar_gl_todo_data_t *_gl_todo_data = ...
        +static calendar_gl_todo_data_t *_gl_todo_data = ...;
        +
         static void
         _todo_changed_callback(const char *view_uri, void *user_data)
         {
        -   if (0 != strcmp(view_uri, _calendar_todo._uri))
        -      return;
        +    if (0 != strcmp(view_uri, _calendar_todo._uri))
        +        return;
         
        -   if (NULL == _gl_todo_data)
        -      return;
        +    if (NULL == _gl_todo_data)
        +        return;
         
        -   int todo_id = _gl_todo_data->id;
        -   _free_gl_todo_data(_gl_todo_data);
        -   _gl_todo_data = NULL;
        +    int todo_id = _gl_todo_data->id;
        +    _free_gl_todo_data(_gl_todo_data);
        +    _gl_todo_data = NULL;
         
        -   calendar_record_h record = NULL;
        -   calendar_error_e error_code;
        -   error_code = calendar_db_get_record(_calendar_todo._uri, todo_id, &record);
        -   if (error_code != CALENDAR_ERROR_NONE)
        -      return;
        +    calendar_record_h record = NULL;
        +    calendar_error_e error_code;
        +    error_code = calendar_db_get_record(_calendar_todo._uri, todo_id, &record);
        +    if (error_code != CALENDAR_ERROR_NONE)
        +        return;
         
        -   _gl_todo_data = _create_gl_todo_data(record);
        -   // Use _gl_todo_data
        +    _gl_todo_data = _create_gl_todo_data(record);
        +    /* Use _gl_todo_data */
         
        -   calendar_record_destroy(record, true);
        +    calendar_record_destroy(record, true);
         }
         
        @@ -1314,11 +1370,11 @@ _todo_changed_callback(const char *view_uri, void *user_data)
      • Retrieve the event:

        -int event_id = ... // Get the event ID
        +int event_id = ...; /* Get the event ID */
         calendar_record_h record = NULL;
         error_code = calendar_db_get_record(_calendar_event._uri, event_id, &record);
         if (error_code != CALENDAR_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_get_record failed: %x\n", error_code);
         
      • @@ -1330,20 +1386,20 @@ calendar_list_h list = NULL; error_code = calendar_list_create(&list); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_list_create failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_list_create failed: %x\n", error_code); error_code = calendar_list_add(list, record); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_list_add failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_list_add failed: %x\n", error_code); error_code = calendar_vcalendar_make_from_records(list, &vcalendar_stream); if (error_code != CALENDAR_ERROR_NONE) -   dlog_print(DLOG_ERROR, LOG_TAG, "calendar_vcalendar_make_from_records failed: %x\n", error_code); +    dlog_print(DLOG_ERROR, LOG_TAG, "calendar_vcalendar_make_from_records failed: %x\n", error_code);
      • -

        Free the vCalendar stream, and destroy the list handle and release all its resources:

        +

        When no longer needed, free the vCalendar stream, destroy the list handle, and release all its resources:

         free(vcalendar_stream);
         calendar_list_destroy(list, true);
        @@ -1366,9 +1422,9 @@ char *resource_path = app_get_resource_path();
         snprintf(vcalendar_file_path, sizeof(vcalendar_file_path), "%s/%s", resource_path, "vcalendar.ics");
         free(resource_path);
         
        -error_code = calendar_vcalendar_parse_to_calendar_foreach(vcalendar_file_path, // File path of vCalendar
        -                                                          _vcalendar_parse_cb, // Callback to invoke
        -                                                          NULL); // User data passed to the callback
        +error_code = calendar_vcalendar_parse_to_calendar_foreach(vcalendar_file_path, /* File path of vCalendar */
        +                                                          _vcalendar_parse_cb, /* Callback to invoke */
        +                                                          NULL); /* User data passed to the callback */
         
      • @@ -1379,21 +1435,20 @@ error_code = calendar_vcalendar_parse_to_calendar_foreach(vcalendar_file_path, / static bool _vcalendar_parse_cb(calendar_record_h record, void *user_data) { -   if (NULL == record) -      return false; +    if (NULL == record) +        return false; -   int id = -1; -   error_code = calendar_db_insert_record(record, &id); -   if (error_code != CALENDAR_ERROR_NONE) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code); +    int id = -1; +    error_code = calendar_db_insert_record(record, &id); +    if (error_code != CALENDAR_ERROR_NONE) { +        dlog_print(DLOG_ERROR, LOG_TAG, "calendar_db_insert_record failed: %x\n", error_code); -      return false; -   } -   dlog_print(DLOG_ERROR, LOG_TAG, "inserted id: %d\n", id); -   // Use record +        return false; +    } +    dlog_print(DLOG_ERROR, LOG_TAG, "inserted id: %d\n", id); +    /* Use record */ -   return true; +    return true; } @@ -1423,4 +1478,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/social/contact_tutorial_n.htm b/org.tizen.tutorials/html/native/social/contact_tutorial_n.htm index 5db7694..32bdd43 100644 --- a/org.tizen.tutorials/html/native/social/contact_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/social/contact_tutorial_n.htm @@ -10,783 +10,990 @@ - Contacts: Managing Contacts and Groups, and Accessing the Contact Database - + Contacts: Managing Contacts and Groups, and Accessing the Contact Database +
        -

        Mobile native

        +

        Mobile native Wearable native

        -

        Content

        -

        Related Info

        -

        Contacts: Managing Contacts and Groups, and Accessing the Contact Database

        - - -

        This tutorial demonstrates how you can manage contacts and groups, and import them to or export them from the vCard format.

        - -

        Prerequisites

        -

        To use the contacts API, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file.

        -
        -  <privileges>
        -      <privilege>http://tizen.org/privilege/contact.read</privilege>
        -      <privilege>http://tizen.org/privilege/contact.write</privilege>
        -      <privilege>http://tizen.org/privilege/callhistory.read</privilege>
        -      <privilege>http://tizen.org/privilege/callhistory.write</privilege>
        -  </privileges>
        - -

        Warm-up

        -

        Become familiar with the Contacts API basics by learning about:

        - -

        Follow-up

        -

        Once we have learned the basics of the Contacts API, we can now move on to more advanced tasks, including:

        - - - -

        Initializing Contacts

        - -

        To start with the Contact Service:

        -
        1. -

          To use the functions and data types of the Contacts API, include the <contacts.h> header file in your application:

          +

          Contacts: Managing Contacts and Groups, and Accessing the Contact Database

          + +

          This tutorial demonstrates how you can manage contacts and groups, and import and export them to and from the vCard format.

          + +

          Warm-up

          + +

          Become familiar with the Contacts API basics by learning about:

          + + + +

          Follow-up

          + +

          Once we have learned the basics of the Contacts API, we can now move on to more advanced tasks, including:

          + + + +

          Prerequisites

          + +

          To use the Contacts API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

          +
          +<privileges>
          +   <privilege>http://tizen.org/privilege/contact.read</privilege>
          +   <privilege>http://tizen.org/privilege/contact.write</privilege>
          +   <privilege>http://tizen.org/privilege/callhistory.read</privilege>
          +   <privilege>http://tizen.org/privilege/callhistory.write</privilege>
          +</privileges>
          +
          + +

          Initializing Contacts

          + +

          To initialize the contacts service for use:

          + +
            + +
          1. +

            To use the functions and data types of the Contacts API (in mobile and wearable applications), include the <contacts.h> header file in your application:

             #include <contacts.h>
            -
          2. -
          3. Most of the API functions return error codes, therefore define at the beginning of your code the int type, which is used to store error codes. Each time when a function returns error codes, verify the result of the operation.
          4. -
          5. Call the contacts_connect() function, which connects your application with the Contact Service. Without this function, you cannot get access to the contacts database.

            -
            int error_code;
            +
            +

            To ensure that a Contacts function has been executed properly, make sure that the return value is equal to CONTACTS_ERROR_NONE. If the function returns an error, handle it accordingly.

            +
          6. + +
          7. +

            To access the contact database, connect to the contacts service using the contacts_connect() function:

            +
            +int error_code;
             error_code = contacts_connect();
            -
          8. -
          9. When the Contacts APIs are not needed anymore, disconnect from the service using the contacts_disconnect() function: -
            error_code = contacts_disconnect();
            -
          + +
        2. + +
        3. +

          After you have finished working with the contacts service, disconnect from the service using the contacts_disconnect() function:

          +
          +error_code = contacts_disconnect();
          +
          +
        4. -

          Creating a Contact

          +
        -

        Before you insert a record, you need to create a record handle with the contacts_record_create() function. The first parameter determines the type of the created record. Use _contacts_contact._uri to create contact type records.

        -
        contacts_record_h contact;
        +

        Creating a Contact

        + +

        Creating a new contact involves creating a contact handle, setting the contact properties, and inserting the contact into the contact database.

        + +

        Some contact properties are defined as child records that are associated with the parent record. For a detailed list of the contact properties, see the _contacts_contact view description in the Contacts API (in mobile and wearable applications). If the property type is record, the property is defined as a child record. The property description defines whether a single or multiple child records are allowed for a specific property.

        + +

        When you create a new contact, the system automatically creates a new person associated with that contact. A person is an aggregation of one or more contacts associated with the same individual. A contact is always associated with a person.

        + +

        To create a new contact:

        + +
          + +
        1. +

          Create a contact handle using the contacts_record_create() function with the _contacts_contact._uri property as the first parameter and the contact handle variable as the second parameter:

          +
          +contacts_record_h contact;
           
           error_code = contacts_record_create(_contacts_contact._uri, &contact);
           
          -

          This record contains no additional information, such as a name or phone number. To add them, you must set contact properties by creating additional records and setting them as child records of the contact record. Note that records created this way are objects in the memory, with contacts_record_h type variables as their handles. Changes made to these objects are not reflected in the database until your explicit request using the contacts_db_insert_record() or contacts_db_update_record() function.

          - -

          Setting Contact Properties

          + + + + + + + + + +
          Note
          Records created with the contacts_record_create() function are memory objects, with contacts_record_h type variables as their handles. If you changes these objects, the changes are not reflected in the contact database until you explicitly insert or update the objects to the database using the contacts_db_insert_record() or contacts_db_update_record() function.
          +
        2. -

          To set the contact name, birthday, and phone number:

          -
          1. Add the contact name. -
            1. Create a name record: -
              contacts_record_h name;
              +
            2. +

              Set the contact properties:

              +
                +
              • +

                To set the contact's name:

                +
                  +
                1. +

                  Create a name record using the contacts_record_create() function with the _contacts_name._uri property as the first parameter:

                  +
                  +contacts_record_h name;
                   
                   error_code = contacts_record_create(_contacts_name._uri, &name);
                  -
                2. -
                3. To set the first name, set the value of a string type property identified by _contacts_name.first. The name variable is the record handle created above. The second parameter is the property identifier, and the third parameter is the value to be assigned. -
                  error_code = contacts_record_set_str(name, _contacts_name.first, "John");
                   
                  -

                  The contacts_record_set_str() function is used to set string field values. There are other similar functions for other types, such as integer and double.

                4. -
                5. Set the last name similarly: -
                  error_code = contacts_record_set_str(name, _contacts_name.last, "Smith");
                  +
                6. +
                7. +

                  Set the contact's first name using the contacts_record_set_str() function with the _contacts_name.first property as the second parameter:

                  +
                  +error_code = contacts_record_set_str(name, _contacts_name.first, "John");
                  +
                  +
                8. +
                9. +

                  Set the contact's last name using the contacts_record_set_str() function with the _contacts_name.last property as the second parameter:

                  +
                  +error_code = contacts_record_set_str(name, _contacts_name.last, "Smith");
                   
                10. -
                11. Associate the name record with the contact record, by setting the name as the contact's child record. In this example, it is achieved using the contacts_record_add_child_record() function. -

                  The second parameter is the parent property to which the child record is assigned. See the _contacts_contact view description in the Contacts API. In the API, the name property is listed as one of the record type properties, which means that other records can be assigned to this property as child records ("single" means that only 1 _contacts_name type child record is allowed). The required type of the child record is specified in the API.

                  -
                  error_code = contacts_record_add_child_record(contact, _contacts_contact.name, name);
                  +
                12. +

                  Set the name record as a child record of the contact record using the contacts_record_add_child_record() function with the _contacts_contact.name property as the second parameter:

                  +
                  +error_code = contacts_record_add_child_record(contact, _contacts_contact.name, name);
                   
                  -
              • -
              • Add an image. -
                1. Create an image record: -
                  contacts_record_h image;
                  +
                2. +
                +
              • +
              • +

                To set an image for the contact:

                +
                  +
                1. +

                  Create an image record using the contacts_record_create() function with the _contacts_image._uri property as the first parameter:

                  +
                  +contacts_record_h image;
                   
                   error_code = contacts_record_create(_contacts_image._uri, &image);
                  -
                2. -
                3. To set the image, set the value of a string type property identified by _contacts_image.path: +
            3. +
            4. +
            5. +

              Define the image, and set the image using the contacts_record_set_str() function with the _contacts_image.path property as the second parameter:

               char *resource_path = app_get_resource_path();
               char caller_id_path[1024];
               snprintf(caller_id_path, sizeof(caller_id_path), "%s/caller_id.jpg", resource_path);
               free(resource_path);
               error_code = contacts_record_set_str(image, _contacts_image.path, caller_id_path);
              -
            6. -
            7. Set the image record as the contact's child record: -
              error_code = contacts_record_add_child_record(contact, _contacts_contact.image, image);
               
              - +
            8. +
            9. +

              Set the image record as a child record of the contact record using the contacts_record_add_child_record() function with the _contacts_contact.image property as the second parameter:

              +
              +error_code = contacts_record_add_child_record(contact, _contacts_contact.image, image);
              +
              +
            10. +
            - - - - - - - - + + + + + + + +
            Note
            For an application to insert private images in contacts, the following conditions apply: -
            • The application must have the http://tizen.org/privilege/contact.write privilege to use the APIs, such as contacts_db_insert_record().
            • -
            • The application's private directory and files must have the read permission of others, such as 644. SMACK protects the read permission from the other applications.
            • -
            • The application can erase the image after destroying the contact record (using the contacts_record_destroy() function).
            -
            Note
            +

            To set private images for contacts, the application must meet the following conditions:

            +
              +
            • The application's private directory and files must have the read permission for others, such as 644. SMACK protects the read permission from other applications.

            • +
            • The application must delete the image after destroying the contact record (using the contacts_record_destroy() function).

            • +
            +
            +
          2. +
          3. +

            To set an event for the contact:

            + +

            An event consists of an event type, date, and other properties. You can set various types of events for the contact, as defined in the contacts_event_type_e enumeration (in mobile and wearable applications). If the event type is CONTACTS_EVENT_TYPE_CUSTOM, you can set a custom label for the event using the contacts_record_set_str() function with the _contacts_event.label property as the second parameter.

            -
          -
        3. Add an event. -

          You can add a birthday event associated with the contact. An event contains the date and the event type, among other properties.

          -
          1. Create an event record: -
            contacts_record_h event;
            +

            To set a birthday event:

            + +
              +
            1. +

              Create an event record using the contacts_record_create() function with the _contacts_event._uri property as the first parameter:

              +
              +contacts_record_h event;
               
               error_code = contacts_record_create(_contacts_event._uri, &event);
              -
            2. -
            3. Set the event date. The date is an integer, equal to year * 10000 + month * 100 + day. -
              int year = 1990;
              +
              +
            4. +
            5. +

              Set the event date using the contacts_record_set_int() function with the _contacts_event.date property as the second parameter. The date is an integer calculated as year * 10000 + month * 100 + day.

              +
              +int year = 1990;
               int month = 5;
               int day = 21;
               int int_date = year * 10000 + month * 100 + day;
               
               error_code = contacts_record_set_int(event, _contacts_event.date, int_date);
              -
            6. -
            7. Set the event type to birthday. For the available types, see the contacts_event_type_e enumeration. -
              error_code = contacts_record_set_int(event, _contacts_event.type, CONTACTS_EVENT_TYPE_BIRTH);
              -
            8. -
            9. If the type is CONTACTS_EVENT_TYPE_CUSTOM, you can set a custom label (see the _contacts_event view). -
              error_code = contacts_record_set_int(event, _contacts_event.type, CONTACTS_EVENT_TYPE_CUSTOM);
              -
              -error_code = contacts_record_set_str(event, _contacts_event.label, "Event description");
              -
            10. -
            11. Set the event record as the contact's child record: -
              error_code = contacts_record_add_child_record(contact, _contacts_contact.event, event);
              -
          2. -
          3. Add a phone number. -

            The phone number is added to a parent record using an alternative method.

            -
            1. Create a phone number record and set the number property: -
              contacts_record_h number;
              +
              +
            2. +
            3. +

              Set the event type to birthday using the contacts_record_set_int() function with the _contacts_event.type property as the second parameter and the CONTACTS_EVENT_TYPE_BIRTH enumerator as the third parameter:

              +
              +error_code = contacts_record_set_int(event, _contacts_event.type, CONTACTS_EVENT_TYPE_BIRTH);
              +
              +
            4. +
            5. +

              Set the event record as a child record of the contact record using the contacts_record_add_child_record() function with the _contacts_contact.event property as the second parameter:

              +
              +error_code = contacts_record_add_child_record(contact, _contacts_contact.event, event);
              +
              +
            6. +
            +
          4. +
          5. +

            To set the contact's phone number:

            +
              +
            1. +

              Create a phone number record using the contacts_record_create() function with the _contacts_number._uri property as the first parameter:

              +
              +contacts_record_h number;
               
               error_code = contacts_record_create(_contacts_number._uri, &number);
              -
              +
              +
            2. +
            3. +

              Set the phone number using the contacts_record_set_str() function with the _contacts_number.number property as the second parameter:

              +
               error_code = contacts_record_set_str(number, _contacts_number.number, "+8210-1234-5678");
              -
            4. -
            5. Set the number record as the contact's child record: -
              error_code = contacts_record_add_child_record(contact, _contacts_contact.number, number);
              -
          - -

          Inserting a Contact to the Database

          +
        + +
      • +

        Set the phone number record as a child record of the contact record using the contacts_record_add_child_record() function with the _contacts_contact.number property as the second parameter:

        +
        +error_code = contacts_record_add_child_record(contact, _contacts_contact.number, number);
        +
        +
      • + + +
      +

      Set other contact properties similarly, as needed.

      +
    • -

      To insert a contact:

      +
    • +

      Insert the contact into the contact database using the contacts_db_insert_record() function. All child records added to the contact using the contacts_record_add_child_record() function are inserted automatically along with the parent.

      -
      1. When the data is set for the contact and name records, you can insert them into the database. When you insert a parent record, all child records added to it using the contacts_record_add_child_record() function are inserted automatically.

        -
        int id = -1;
        +

        The system assigns a unique ID to the contact, and the function returns it as its second parameter

        +
        +int id = -1;
         
         error_code = contacts_db_insert_record(contact, &id);
        -
      2. -
      3. When the records are in the database, the objects representing them in the memory are no longer needed and must be destroyed. -
        contacts_record_destroy(contact, true);
        -

        If the second parameter is true, child records of the given record (objects representing them in the memory) are also destroyed. This does not depend on the way the child records were added.

      + +
    • -

      Getting Contacts

      +
    • +

      Destroy the contact handle and release all its resources using the contacts_record_destroy() function:

      +
      +contacts_record_destroy(contact, true);
      +
      +

      If you set the second parameter to true, all child records of the given record are also destroyed, irrespective of how the child records were added (individually or along with their parent record).

      +
    • + + + +

      Retrieving Persons

      + +

      You can access contact details through persons.

      -

      To retrieve contact records:

      +

      To retrieve a single person:

      -
      1. A person is an aggregation of one or more contacts associated with the same person. The person is created automatically when inserting a contact record. To use the contact information in your application, you must learn to print basic person information.

        +
          -

          Get a single person record:

          -
          1. -

            Use the contacts_db_get_record() function with the appropriate person_id:

            -
            contacts_record_h person  = NULL;
            -const int person_id = ... // Acquire person ID
            +
          2. +

            Retrieve a person record using the contacts_db_get_record() function with the person ID as the second parameter:

            +
            +contacts_record_h person = NULL;
            +const int person_id = ...; /* Get the person ID */
             int error_code;
             
             error_code = contacts_db_get_record(_contacts_person._uri, person_id, &person);
            -
          3. -
          4. When you no longer need the person record, destroy the used structures: +
          5. +
          6. + +
          7. +

            When no longer needed, destroy the person handle and release all its resources using the contacts_record_destroy() function:

            -contacts_record_destroy(speeddial, true);
            -
          +contacts_record_destroy(person, true); + -
        1. Get the total person record list: -
          1. Use the contacts_db_get_all_records() function:

            -
            contacts_list_h list = NULL;
            +
          2. + +
          + +

          To retrieve multiple persons:

          + +
            + +
          1. +

            Retrieve a list of all persons, or a list limited with a filter or search keyword:

            + +
              +
            • +

              To retrieve a list of all persons, use the contacts_db_get_all_records() function:

              +
              +contacts_list_h list = NULL;
               
               error_code = contacts_db_get_all_records(_contacts_person._uri, 0, 0, &list);
              -
            • -
            • Iterate the list and read the records:

              - - - - - - - - - - -
              Note
              Some functions have the _p postfix. It means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
              - -
              1. To get the records from the list, use the contacts_list_get_current_record_p(), and contacts_list_next() or contacts_list_prev() functions. Get the details of each record in the loop.

                - -
                contacts_record_h record;
                -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
                -{
                -   char* display_name;
                -   error_code = contacts_record_get_str_p(record, _contacts_person.display_name, &display_name);
                -   dlog_print(DLOG_DEBUG, LOG_TAG, "display_name: %s", display_name);
                -
                -   error_code = contacts_list_next(list);
                -}
              2. -
              3. If you want to get more details of each record, use the contacts_gl_person_data_t structure: -
                contacts_gl_person_data_t *gl_person_data = NULL;
                +
                +
              4. +
              5. +

                To retrieve a filtered list of persons:

                +
                  +
                1. +

                  Define a list handle variable, and create a query handle using the contacts_query_create() function:

                  +
                  +contacts_list_h list = NULL;
                  +contacts_query_h query = NULL;
                  +
                  +error_code = contacts_query_create(_contacts_person._uri, &query);
                  +
                  +
                2. +
                3. +

                  Create a filter handle using the contacts_filter_create() function:

                  +
                  +contacts_filter_h filter = NULL;
                  +
                  +error_code = contacts_filter_create(_contacts_person._uri, &filter);
                  +
                  +
                4. +
                5. +

                  Add a filtering condition using a contacts_filter_add_XXX() function.

                  +

                  The following example adds a string-based filtering condition that retrieves the persons whose display name contains the string "John":

                  +
                  +error_code = contacts_filter_add_str(filter, _contacts_person.display_name,
                  +                                     CONTACTS_MATCH_CONTAINS, "John");
                  +
                  +
                6. +
                7. +

                  To add more conditions, define an operator between the conditions.

                  +

                  The following example first adds an AND operator and then a bool-based filtering condition that retrieves the persons who are set as favorites.

                  +

                  The combination of the AND operator and the 2 conditions means that the filter only retrieves the persons whose display name contains the string "John" and who are set as favorites.

                  +
                  +error_code = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
                  +
                  +error_code = contacts_filter_add_bool(filter, _contacts_person.is_favorite, true);
                  +
                  +
                8. +
                9. +

                  Set the filter to the query using the contacts_query_set_filter() function:

                  +
                  +error_code = contacts_query_set_filter(query, filter);
                  +
                  +
                10. +
                11. +

                  Retrieve the filtered list of persons using the contacts_db_get_records_with_query() function:

                  +
                  +error_code = contacts_db_get_records_with_query(query, 0, 0, &list);
                  +
                  +

                  The third parameter defines a limit for the number of results. If you set it to 0, the list returns all persons matching the query.

                  +
                12. +
                13. +

                  When no longer needed, destroy the filter and query handles and release all their resources using the contacts_filter_destroy() and contacts_query_destroy() functions:

                  +
                  +contacts_filter_destroy(filter);
                  +contacts_query_destroy(query);
                  +
                  +
                14. +
                +
              6. +
              7. +

                To retrieve a list of persons matching a search keyword, use the contacts_db_search_records() function with the search keyword as the second parameter.

                +

                The following example shows how to find all person records that contain the keyword "John":

                +
                +contacts_list_h list = NULL;
                +
                +error_code = contacts_db_search_records(_contacts_person._uri, "John", 0, 0, &list);
                +
                +
              8. +
            +
          2. + +
          3. +

            Iterate through the list of found persons, and retrieve person details:

            +
              +
            1. +

              Use a loop to iterate through the list and retrieve the person details.

              +

              Move forward and backward within the list using the contacts_list_next() and contacts_list_prev() functions, and retrieve the current person using the contacts_list_get_current_record_p() function.

              + + + + + + + + + +
              Note
              Some functions have the _p postfix. The postfix means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
              +

              The following example iterates through the list and retrieves the display name of each person:

              +
               contacts_record_h record;
              -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
              -{
              -   gl_person_data = _create_gl_person_data(record);
              -   // You can get, for example, display name:
              -   // gl_person_data->display_name
              +while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) {
              +    char *display_name;
              +    error_code = contacts_record_get_str_p(record, _contacts_person.display_name, &display_name);
              +    dlog_print(DLOG_DEBUG, LOG_TAG, "display_name: %s", display_name);
               
              -   _free_gl_person_data(gl_person_data);
              -   error_code = contacts_list_next(list);
              -}
            2. -
            3. The memory for the record data is allocated, and the data is copied from the record by the functions listed further on in this tutorial: +    error_code = contacts_list_next(list); +} + +
            4. +
            5. +

              Optionally, retrieve more details of each person using the contacts_gl_person_data_t structure:

              -typedef struct
              -_contacts_gl_person_data
              -{
              -   int id;
              -   char *display_name;
              -   char *default_phone_number;
              -   contacts_list_h associated_contacts;
              -} contacts_gl_person_data_t;
              +contacts_gl_person_data_t *gl_person_data = NULL;
              +contacts_record_h record;
              +while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) {
              +    gl_person_data = _create_gl_person_data(record);
              +    /* You can get, for example, display name: */
              +    /* gl_person_data->display_name */
              +
              +    _free_gl_person_data(gl_person_data);
               
              +    error_code = contacts_list_next(list);
              +}
              +
              +

              Define the contacts_gl_person_data_t structure and the functions for using the structure:

              +
              +struct _contacts_gl_person_data {
              +    int id;
              +    char *display_name;
              +    char *default_phone_number;
              +    contacts_list_h associated_contacts;
              +};
              +typedef struct _contacts_gl_person_data contacts_gl_person_data_t;
              +
              +/* Release the resources allocated to the structure */
               static void
               _free_gl_person_data(contacts_gl_person_data_t *gl_person_data)
               {
              -   if (NULL == gl_person_data)
              -      return;
              +    if (NULL == gl_person_data)
              +        return;
               
              -   free(gl_person_data->display_name);
              -   free(gl_person_data->default_phone_number);
              -   contacts_list_destroy(gl_person_data->associated_contacts, true);
              -   free(gl_person_data);
              +    free(gl_person_data->display_name);
              +    free(gl_person_data->default_phone_number);
              +    contacts_list_destroy(gl_person_data->associated_contacts, true);
              +    free(gl_person_data);
               }
               
              +/* Create the structure for a person */
               static contacts_gl_person_data_t*
               _create_gl_person_data(contacts_record_h record)
               {
              -   contacts_gl_person_data_t *gl_person_data;
              -
              -   gl_person_data = malloc(sizeof(contacts_gl_person_data_t));
              -   memset(gl_person_data, 0x0, sizeof(contacts_gl_person_data_t));
              -   if (contacts_record_get_int(record, _contacts_person.id, &gl_person_data->id) != CONTACTS_ERROR_NONE)
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "get person id failed ");
              -      _free_gl_person_data(gl_person_data);
              -
              -      return NULL;
              -   }
              -   if (false == _get_display_name(record, &gl_person_data->display_name))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "_get_display_name() failed ");
              -      _free_gl_person_data(gl_person_data);
              -
              -      return NULL;
              -   }
              -   if (false == _get_default_phone_number(record, &gl_person_data->default_phone_number))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "_get_default_phone_number() failed ");
              -      _free_gl_person_data(gl_person_data);
              -
              -      return NULL;
              -   }
              -   if (false == _get_associated_contacts(record, &gl_person_data->associated_contacts))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "_get_associated_contacts() failed ");
              -      _free_gl_person_data(gl_person_data);
              -
              -      return NULL;
              -   }
              -   _print_phone_numbers(gl_person_data->associated_contacts);
              -   _print_events(gl_person_data->associated_contacts);
              -
              -   return gl_person_data;
              -}
            6. -
            7. Get person details: +    contacts_gl_person_data_t *gl_person_data; + +    gl_person_data = malloc(sizeof(contacts_gl_person_data_t)); +    memset(gl_person_data, 0x0, sizeof(contacts_gl_person_data_t)); +    if (contacts_record_get_int(record, _contacts_person.id, &gl_person_data->id) != CONTACTS_ERROR_NONE) { +        dlog_print(DLOG_ERROR, LOG_TAG, "get person id failed "); +        _free_gl_person_data(gl_person_data); + +        return NULL; +    } +    if (false == _get_display_name(record, &gl_person_data->display_name)) { +        dlog_print(DLOG_ERROR, LOG_TAG, "_get_display_name() failed "); +        _free_gl_person_data(gl_person_data); + +        return NULL; +    } +    if (false == _get_default_phone_number(record, &gl_person_data->default_phone_number)) { +        dlog_print(DLOG_ERROR, LOG_TAG, "_get_default_phone_number() failed "); +        _free_gl_person_data(gl_person_data); + +        return NULL; +    } +    if (false == _get_associated_contacts(record, &gl_person_data->associated_contacts)) { +        dlog_print(DLOG_ERROR, LOG_TAG, "_get_associated_contacts() failed "); +        _free_gl_person_data(gl_person_data); + +        return NULL; +    } +    _print_phone_numbers(gl_person_data->associated_contacts); +    _print_events(gl_person_data->associated_contacts); + +    return gl_person_data; +} + + +

              Define the functions for retrieving the person details:

                -
              • Get the display name. -

                Assuming that you have the person record handle (contacts_record_h), you can access the display_name property. You can read the display name property and print it.

                +
              • +

                Retrieve the person's display name using the contacts_record_get_str() function with the _contacts_person.display_name property as the second parameter:

                 static bool
                 _get_display_name(contacts_record_h record, char **display_name)
                 {
                -   int error_code;
                +    int error_code;
                 
                -   error_code = contacts_record_get_str(record, _contacts_person.display_name, display_name);
                -   dlog_print(DLOG_DEBUG, LOG_TAG, "display name: %s", *display_name);
                -   if (error_code != CONTACTS_ERROR_NONE)
                -      return false;
                +    error_code = contacts_record_get_str(record, _contacts_person.display_name, display_name);
                +    dlog_print(DLOG_DEBUG, LOG_TAG, "display name: %s", *display_name);
                +    if (error_code != CONTACTS_ERROR_NONE)
                +        return false;
                 
                -   return true;
                -}
              • -
              • Get associated contacts of a person by query: +    return true; +} + +
              • +
              • +

                Retrieve the contacts associated with the person using a query:

                 static bool
                 _get_associated_contacts(contacts_record_h record, contacts_list_h *associated_contacts)
                 {
                -   int error_code;
                -   int person_id;
                -   contacts_query_h query = NULL;
                -   contacts_filter_h filter = NULL;
                +    int error_code;
                +    int person_id;
                +    contacts_query_h query = NULL;
                +    contacts_filter_h filter = NULL;
                 
                -   error_code = contacts_record_get_int(record, _contacts_person.id, &person_id);
                +    /* Retrieve the person ID from the person record */
                +    error_code = contacts_record_get_int(record, _contacts_person.id, &person_id);
                 
                -   error_code = CONTACTS_ERROR_NONE;
                -   error_code += contacts_query_create(_contacts_contact._uri, &query);
                -   error_code += contacts_filter_create(_contacts_contact._uri, &filter);
                -   error_code += contacts_filter_add_int(filter, _contacts_contact.person_id, CONTACTS_MATCH_EQUAL, person_id);
                -   error_code += contacts_query_set_filter(query, filter);
                +    /* Create a contact query with a filter for the person ID */
                +    error_code = CONTACTS_ERROR_NONE;
                +    error_code += contacts_query_create(_contacts_contact._uri, &query);
                +    error_code += contacts_filter_create(_contacts_contact._uri, &filter);
                +    error_code += contacts_filter_add_int(filter, _contacts_contact.person_id,
                +                                          CONTACTS_MATCH_EQUAL, person_id);
                +    error_code += contacts_query_set_filter(query, filter);
                 
                -   error_code += contacts_db_get_records_with_query(query, 0, 0, associated_contacts);
                +    /* Run the query: Retrieve a list of all contacts associated with the person ID */
                +    error_code += contacts_db_get_records_with_query(query, 0, 0, associated_contacts);
                 
                -   contacts_filter_destroy(filter);
                -   contacts_query_destroy(query);
                +    /* Destroy the filter and query handles and release all their resources */
                +    contacts_filter_destroy(filter);
                +    contacts_query_destroy(query);
                 
                -   if (error_code != CONTACTS_ERROR_NONE)
                -      return false;
                +    if (error_code != CONTACTS_ERROR_NONE)
                +        return false;
                 
                -   return true;
                -}
              • -
              • Get phone numbers by iterating the contacts list. The following example shows how to get all the number records and print them. +    return true; +} + +
              • +
              • +

                Retrieve the phone numbers of the associated contacts by iterating through the contacts list retrieved in the previous step.

                 static void
                 _print_phone_numbers(contacts_list_h associated_contacts)
                 {
                -   int error_code;
                -   contacts_record_h contact;
                -   if (NULL == associated_contacts)
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "associated_contacts is NULL");
                -
                -      return;
                -   }
                -   while (contacts_list_get_current_record_p(associated_contacts, &contact) == CONTACTS_ERROR_NONE)
                -   {
                -      int i;
                -      unsigned int count = 0;
                -
                -      error_code = contacts_record_get_child_record_count(contact, _contacts_contact.number, &count);
                -      if (CONTACTS_ERROR_NONE != error_code)
                -      {
                -         dlog_print(DLOG_ERROR, LOG_TAG, "contacts_record_get_child_record_count(%d)", error_code);
                -
                -         return;
                -      }
                -      for (i = 0; i < count; i++)
                -      {
                -         contacts_record_h number = NULL;
                -         error_code = contacts_record_get_child_record_at_p(contact, _contacts_contact.number, i, &number);
                -         if (error_code != CONTACTS_ERROR_NONE)
                -            continue;
                -
                -         int number_id;
                -         contacts_record_get_int(number, _contacts_number.id, &number_id);
                -         dlog_print(DLOG_DEBUG, LOG_TAG, "number id: %d", number_id);
                -
                -         char *number_str = NULL;
                -         contacts_record_get_str_p(number, _contacts_number.number, &number_str);
                -         dlog_print(DLOG_DEBUG, LOG_TAG, "number: %s", number_str);
                -      }
                -      error_code = contacts_list_next(associated_contacts);
                -   }
                -}
              • -
              • Get the default phone number. -

                If a contact has multiple phone numbers, one of them is defined as the default phone number. A person also has a default phone number. The Contact Service provides the _contacts_person_number view for getting the default phone number of a person. In the default phone number record, the is_primary_default property value is true. The following example shows how to get the default phone number of a person by query.

                +    int error_code; +    contacts_record_h contact; +    if (NULL == associated_contacts) { +        dlog_print(DLOG_ERROR, LOG_TAG, "associated_contacts is NULL"); + +        return; +    } +    /* Iterate through the list of associated contacts */ +    while (contacts_list_get_current_record_p(associated_contacts, &contact) == CONTACTS_ERROR_NONE) { +        int i; +        unsigned int count = 0; + +        /* Determine the number of phone number records associated with the contact (as child records) */ +        error_code = contacts_record_get_child_record_count(contact, _contacts_contact.number, &count); +        if (CONTACTS_ERROR_NONE != error_code) { +            dlog_print(DLOG_ERROR, LOG_TAG, "contacts_record_get_child_record_count(%d)", error_code); + +            return; +        } +        /* Iterate through the contact's phone number records and retrieve the phone number details */ +        for (i = 0; i < count; i++) { +            contacts_record_h number = NULL; +            error_code = contacts_record_get_child_record_at_p(contact, _contacts_contact.number, +                                                               i, &number); +            if (error_code != CONTACTS_ERROR_NONE) +                continue; + +            /* Retrieve the phone number ID */ +            int number_id; +            contacts_record_get_int(number, _contacts_number.id, &number_id); +            dlog_print(DLOG_DEBUG, LOG_TAG, "number id: %d", number_id); + +            /* Retrieve the actual phone number */ +            char *number_str = NULL; +            contacts_record_get_str_p(number, _contacts_number.number, &number_str); +            dlog_print(DLOG_DEBUG, LOG_TAG, "number: %s", number_str); +        } +        error_code = contacts_list_next(associated_contacts); +    } +} + +
              • +
              • +

                Retrieve the person's default phone number.

                +

                If a person is associated with multiple phone numbers, one of them is defined as the person's default phone number. To determine the default phone number, check the is_primary_default property of the _contacts_person_number view for the person's phone numbers. For the default phone number, the property is set to true.

                +

                The following example shows how to retrieve a person's default phone number using a query:

                 static bool
                 _get_default_phone_number(contacts_record_h record, char **default_phone_number)
                 {
                -   contacts_query_h query = NULL;
                -   contacts_filter_h filter = NULL;
                -   contacts_list_h list = NULL;
                -   contacts_record_h record_person_number = NULL;
                -   int person_id;
                -   int error_code = CONTACTS_ERROR_NONE;
                -
                -   error_code += contacts_record_get_int(record, _contacts_person.id, &person_id);
                -
                -   error_code += contacts_query_create(_contacts_person_number._uri, &query);
                -   error_code += contacts_filter_create(_contacts_person_number._uri, &filter);
                -   error_code += contacts_filter_add_bool(filter, _contacts_person_number.is_primary_default, true);
                -   error_code += contacts_query_set_filter(query, filter);
                -   error_code += contacts_db_get_records_with_query(query, 0, 0, &list);
                -   error_code += contacts_list_get_current_record_p(list, &record_person_number);
                -
                -   error_code += contacts_record_get_str(record_person_number, _contacts_person_number.number, default_phone_number);
                -
                -   contacts_list_destroy(list, true);
                -   contacts_filter_destroy(filter);
                -   contacts_query_destroy(query);
                -
                -   if (error_code != CONTACTS_ERROR_NONE)
                -      return false;
                -
                -   return true;
                -}
              • -
              • Get events by iterating the contacts list: +    contacts_query_h query = NULL; +    contacts_filter_h filter = NULL; +    contacts_list_h list = NULL; +    contacts_record_h record_person_number = NULL; +    int person_id; +    int error_code = CONTACTS_ERROR_NONE; + +    /* Retrieve the person ID from the person record */ +    error_code += contacts_record_get_int(record, _contacts_person.id, &person_id); + +    /* Create a phone number query with filters for the person ID and default phone number */ +    error_code += contacts_query_create(_contacts_person_number._uri, &query); +    error_code += contacts_filter_create(_contacts_person_number._uri, &filter); +    error_code += contacts_filter_add_int(filter, _contacts_person_number.person_id, +                                          CONTACTS_MATCH_EQUAL, person_id); +    error_code += contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); +    error_code += contacts_filter_add_bool(filter, _contacts_person_number.is_primary_default, +                                           true); +    error_code += contacts_query_set_filter(query, filter); + +    /* Run the query: Retrieve the phone number records containing the default phone number */ +    error_code += contacts_db_get_records_with_query(query, 0, 0, &list); + +    /* Retrieve the current record from the query list */ +    error_code += contacts_list_get_current_record_p(list, &record_person_number); + +    /* Retrieve the phone number from the phone number record */ +    error_code += contacts_record_get_str(record_person_number, _contacts_person_number.number, +                                          default_phone_number); + +    /* Destroy the list, filter, and query handles and release all their resources */ +    contacts_list_destroy(list, true); +    contacts_filter_destroy(filter); +    contacts_query_destroy(query); + +    if (error_code != CONTACTS_ERROR_NONE) +        return false; + +    return true; +} + +
              • +
              • +

                Retrieve the events associated with the person (events of the associated contacts) by iterating through the contacts list:

                 static void
                 _print_events(contacts_list_h associated_contacts)
                 {
                -   int error_code;
                -   contacts_record_h contact;
                -   if (NULL == associated_contacts)
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "associated_contacts is NULL");
                -
                -      return;
                -   }
                -   while (contacts_list_get_current_record_p(associated_contacts, &contact) == CONTACTS_ERROR_NONE)
                -   {
                -      int i;
                -      unsigned int count = 0;
                -
                -      error_code = contacts_record_get_child_record_count(contact, _contacts_contact.event, &count);
                -      if (CONTACTS_ERROR_NONE != error_code)
                -      {
                -         dlog_print(DLOG_ERROR, LOG_TAG, "contacts_record_get_child_record_count(%d)", error_code);
                -
                -         return;
                -      }
                -      for (i = 0; i < count; i++)
                -      {
                -         contacts_record_h event = NULL;
                -         error_code = contacts_record_get_child_record_at_p(contact, _contacts_contact.event, i, &event);
                -         if (error_code != CONTACTS_ERROR_NONE)
                -            continue;
                -
                -         int event_id;
                -         contacts_record_get_int(event, _contacts_event.id, &event_id);
                -         dlog_print(DLOG_DEBUG, LOG_TAG, "event id: %d", event_id);
                -
                -         int date;
                -         contacts_record_get_int(event, _contacts_event.date, &date);
                -         dlog_print(DLOG_DEBUG, LOG_TAG, "event: %d", date);
                -      }
                -      error_code = contacts_list_next(associated_contacts);
                -   }
                -}
          4. -
          5. When you no longer need the person record, destroy the used structures: -
            -contacts_list_destroy(list, true);
            -
        2. -
        3. Get the filtered person record list: -
            -
          1. Use the contacts_db_get_records_with_query() function to filter the list with parameters: -
              -
            1. To get a person list with filtering, create a record list and a query: -
              -contacts_list_h list = NULL;
              -contacts_query_h query = NULL;
              -
              -error_code = contacts_query_create(_contacts_person._uri, &query);
              -
              -
            2. -
            3. Create a filter: -
              -contacts_filter_h filter = NULL;
              -
              -error_code = contacts_filter_create(_contacts_person._uri, &filter);
              -
              -
            4. -
            5. Add a condition, such as display_name: -
              -error_code = contacts_filter_add_str(filter, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, "John");
              -
              -
            6. -
            7. To add multiple conditions, you must define an operator between the conditions: -
              -error_code = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
              -
              -error_code = contacts_filter_add_bool(filter, _contacts_person.is_favorite, true);
              +    int error_code;
              +    contacts_record_h contact;
              +    if (NULL == associated_contacts) {
              +        dlog_print(DLOG_ERROR, LOG_TAG, "associated_contacts is NULL");
              +
              +        return;
              +    }
              +    /* Iterate through the list of associated contacts */
              +    while (contacts_list_get_current_record_p(associated_contacts, &contact) == CONTACTS_ERROR_NONE) {
              +        int i;
              +        unsigned int count = 0;
              +
              +        /* Determine the number of event records associated with the contact (as child records) */
              +        error_code = contacts_record_get_child_record_count(contact, _contacts_contact.event, &count);
              +        if (CONTACTS_ERROR_NONE != error_code) {
              +            dlog_print(DLOG_ERROR, LOG_TAG, "contacts_record_get_child_record_count(%d)", error_code);
              +
              +            return;
              +        }
              +        /* Iterate through the contact's event records and retrieve the event details */
              +        for (i = 0; i < count; i++) {
              +            contacts_record_h event = NULL;
              +            error_code = contacts_record_get_child_record_at_p(contact, _contacts_contact.event,
              +                                                               i, &event);
              +            if (error_code != CONTACTS_ERROR_NONE)
              +                continue;
              +
              +            /* Retrieve the event ID */
              +            int event_id;
              +            contacts_record_get_int(event, _contacts_event.id, &event_id);
              +            dlog_print(DLOG_DEBUG, LOG_TAG, "event id: %d", event_id);
              +
              +            /* Retrieve the event date */
              +            int date;
              +            contacts_record_get_int(event, _contacts_event.date, &date);
              +            dlog_print(DLOG_DEBUG, LOG_TAG, "event: %d", date);
              +        }
              +        error_code = contacts_list_next(associated_contacts);
              +    }
              +}
               
              -
            8. -
            9. Connect the query with the list. -

              The third parameter refers to a limit of the results. If 0 is passed, there are no limits. Remember that after all operations, the list must be released.

              -
              -error_code = contacts_query_set_filter(query, filter);
              +
            10. +
    + + + -error_code = contacts_db_get_records_with_query(query, 0, 0, &list); - - -
  • Free the filter and query: -
    -contacts_filter_destroy(filter);
    -contacts_query_destroy(query);
    -
    -
  • - - -
  • Iterate the list and read the records.
  • -
  • When you no longer need the person record, destroy the used structures: -
    +
  • +

    When no longer needed, destroy the list handle and release all its resources using the contacts_list_destroy() function:

    +
     contacts_list_destroy(list, true);
     
    -
  • - -
  • -
  • Get the searched person record list: -
      -
    1. Use the contacts_db_search_records() function to find records based on a given keyword. The following example shows how to find the contact records which contain the "John" keyword. - -
      -contacts_list_h list = NULL;
      +
    2. -error_code = contacts_db_search_records(_contacts_person._uri, "John", 0, 0, &list); - - -
    3. Iterate the list and read the records.
    4. -
    5. When you no longer need the person record, destroy the used structures: -
      -contacts_list_destroy(list, true);
      -
      -
    6. -
    -
  • -

    Updating a Contact

    +

    Updating a Contact

    -

    To change the name, birthday, and phone number of an existing contact:

    -
    1. Get the contact. -

      To modify a record, you need to have a handle (contacts_record_h type variable) to a memory object representing the record in the database. One of the ways to acquire it is to use the contact ID.

      -
      int contact_id = ... // Acquire contact ID
      +

      To update contact details:

      + +
        + +
      1. +

        Retrieve the contact you want to update using the contacts_db_get_record() function with the contact ID as the second parameter:

        +
        +int contact_id = ...; /* Get the contact ID */
         contacts_record_h contact = NULL;
         
         error_code = contacts_db_get_record(_contacts_contact._uri, contact_id, &contact);
         
        -

        Such handles are also provided by search functions, such as contacts_db_get_records_with_query().

      2. -
      3. Change the name: -
        1. To modify the contact name, get the name record with the contacts_record_get_child_record_at_p() function, which provides a list of the child records of a given type. The function parameters are the parent record, the child record type, a child record index, and the resulting child record. Since there can be only one child record of the _contacts_contact.name type, the index is set to 0 to get the first (and only) child record.

          -
          contacts_record_h name = NULL;
          +

          You can also retrieve the contact using a search function, such as contacts_db_get_records_with_query().

          +
        2. +
        3. +

          Set the properties you want to update.

          +

          The following example sets a new first name for the contact:

          +
          +contacts_record_h name = NULL;
          +/* Retrieve the contact's name record */
          +/* Record index is set to 0, since there is only 1 child record of type "name" */
           error_code = contacts_record_get_child_record_at_p(contact, _contacts_contact.name, 0, &name);
          +/* Change the first name in the name record */
          +error_code = contacts_record_set_str(name, _contacts_name.first, "Mark");
          +
          +

          The following example sets a new birthday event for the contact:

          +
          +contacts_record_h event = NULL;
          +/* Retrieve the contact's birthday event record */
          +error_code = contacts_record_get_child_record_at_p(contact, _contacts_contact.event, 0, &event);
          +/* Change the date in the event record */
          +int new_date = 1990 * 10000 + 6 * 100 + 21;
          +error_code = contacts_record_set_int(event, _contacts_event.date, new_date);
           
          +

          The example assumes the birthday event is the only event defined for the contact, meaning you can retrieve the event record using the contacts_record_get_child_record_at_p() function with the record index set to 0. If the contact has multiple events defined, you must iterate through them.

          + + + + + + + + + +
          Note
          The contacts_record_set_XXX() functions only change the data in the memory object, not in the contact database. Normally, to update the database, you need to update each record separately using the contacts_db_update_record() function. However, if you retrieve a child record using the contacts_record_get_child_record_at_p() function, you only need to update the parent record to the database; the child record is updated automatically with the parent record.
        4. -
        5. Change the first name: -
          error_code = contacts_record_set_str(name, _contacts_name.first, "Mark");
          +
        6. +

          Update the contact using the contacts_db_update_record() function:

          +
          +error_code = contacts_db_update_record(contact);
           
          -

          This only changes the data in the memory object, not in the database. To insert a new value, the name record must be inserted. However, if you acquire this record using the contacts_record_get_child_record_at_p() function (as in this example), you only need to update the parent record.

      4. -
      5. Change the birthday event: -
        1. If only 1 event is set for the contact, you can call the contacts_record_get_child_record_at_p() function to get the event record. If there are more events, you must iterate over the child records. -
          contacts_record_h event = NULL;
          -error_code = contacts_record_get_child_record_at_p(contact, _contacts_contact.event, 0, &event);
          -
        2. + -
        3. Update the record: -
          int new_date = 1990 * 10000 + 6 * 100 + 21;
          +
        4. +

          When no longer needed, destroy the contact handle and release all its resources using the contacts_record_destroy() function:

          +
          +contacts_record_destroy(contact, true);
          +
          +
        5. -error_code = contacts_record_set_int(event, _contacts_event.date, new_date); -
      6. -
      7. Update the contact record. Any changes in the child records (such as name and birthday) are also inserted. -
        error_code = contacts_db_update_record(contact);
        -
      8. -
      9. When the record handle is no more needed, use the contacts_record_destroy() function to destroy the record handle and free the allocated memory: -
        contacts_record_destroy(contact, true);
      +
    -

    Deleting a Person

    +

    Deleting a Person

    -

    To delete a person, call the contacts_db_delete_record() function with _contacts_person._uri as the first parameter and the person ID as the second one:

    -
    int person_id = ... // Acquire person ID
    +

    To delete a person, use the contacts_db_delete_record() function with the person ID as the second parameter:

    + +
    +int person_id = ...; /* Get the person ID */
     
     error_code = contacts_db_delete_record(_contacts_person._uri, person_id);
     
    - + + +

    Linking a contact to a person associates the contact with that person. Unlinking the contact from the person removes the association.

    + +

    To link and unlink persons and contacts:

    + +
      -

      To link and unlink contacts (manually and automatically):

      -
      • Link a person to another person manually with the contacts_person_link_person() function with base person ID as the first parameter and another person ID as the second one. -
        int person_id1 = ... // Acquire base person ID
        -int person_id2 = ... // Acquire another person ID
        +
      • +

        To manually link a person to another person, use the contacts_person_link_person() function. The function links the contacts of the other person (second parameter) to the base person (first parameter) and deletes the former from the contact database. The base person is left with both their original contacts and the other person's contacts.

        +
        +int person_id1 = ...; /* Get the base person ID */
        +int person_id2 = ...; /* Get another person ID */
         
         error_code = contacts_person_link_person(person_id1, person_id2);
        -
      • -
      • Link a contact automatically to a person when creating by setting the link_mode property to CONTACTS_CONTACT_LINK_MODE_NONE when inserting. -

        The Contact Service determines the link based on the number and email properties. If the links leads to a contact in the same address book, the link does not work.

        -
        contacts_record_h contact = NULL;
        +
        +
      • + +
      • +

        To automatically link a new contact to an existing person, set the _contacts_contact.link_mode property of the contact to CONTACTS_CONTACT_LINK_MODE_NONE when creating the contact.

        +

        The contacts service determines the link based on the _contacts_number.number and _contacts_email.email properties of the contact. If an existing person has the same phone number or email address, but in a different address book, the contact is automatically linked to the person. If the phone number or email address lead to an existing contact in the same address book, the link does not work.

        +
        +contacts_record_h contact = NULL;
         
         error_code = CONTACTS_ERROR_NONE;
         error_code += contacts_record_create(_contacts_contact._uri, &contact);
        @@ -802,35 +1009,53 @@ error_code += contacts_record_create(_contacts_number._uri, &number);
         error_code += contacts_record_set_str(number, _contacts_number.number, "+8210-1234-5678");
         error_code += contacts_record_add_child_record(contact, _contacts_contact.number, number);
         
        -// Contact is linked automatically if an existing person has the same number in a different address book
        +/* Contact is linked automatically if an existing person has the same number in a different address book */
         error_code += contacts_db_insert_record(contact, NULL);
         
        -contacts_record_destroy(contact, true);
      • -
      • Unlink a contact from a person by calling the contacts_person_unlink_contact() function with the base person ID as the first parameter and the contact ID as the second one. A new person is created when unlinking. You can get the new person ID as the third parameter. -
        int person_id = ... // Acquire base person ID
        -int contact_id = ... // Acquire contact ID
        +contacts_record_destroy(contact, true);
        +
        +
      • + +
      • +

        To unlink a contact from a person, use the contacts_person_unlink_contact() function. The function removes the contact (second parameter) from the person (first parameter), creates a new person (third parameter), and links the contact to the new person.

        +
        +int person_id = ...; /* Get the person ID */
        +int contact_id = ...; /* Get the contact ID */
         int unlinked_person_id;
         
         error_code = contacts_person_unlink_contact(person_id, contact_id, &unlinked_person_id);
        -
      +
    + -

    Managing Favorites

    + -

    To manage person favorites:

    -
    • Set a person as favorite when creating a contact using the is_favorite property of the person record. If the property is set to true when creating a contact, the person is set as favorite. -
      contacts_record_h contact = NULL;
      +

      Managing Favorites

      + +

      To set or unset a person as a favorite:

      + +
        + +
      • +

        To set a new person as a favorite when creating the corresponding new contact, set the _contacts_contact.is_favorite property of the contact to true. When you insert the contact into the contact database, the new person that is created for the contact is automatically set as a favorite.

        +
        +contacts_record_h contact = NULL;
         
         error_code = CONTACTS_ERROR_NONE;
         error_code += contacts_record_create(_contacts_contact._uri, &contact);
         error_code += contacts_record_set_bool(contact, _contacts_contact.is_favorite, true);
        -// Set other properties
        +/* Set other properties */
         
        -// New person is set as favorite
        +/* New person is set as a favorite */
         error_code += contacts_db_insert_record(contact, NULL);
         
        -contacts_record_destroy(contact, true);
      • -
      • Set an existing person as favorite by updating the person record: -
        int person_id = ... // Acquire person ID
        +contacts_record_destroy(contact, true);
        +
        +
      • + +
      • +

        To set an existing person as a favorite, update the person record by setting its _contacts_person.is_favorite property to true:

        +
        +int person_id = ...; /* Get the person ID */
         contacts_record_h person = NULL;
         
         error_code = contacts_db_get_record(_contacts_person._uri, person_id, &person);
        @@ -839,9 +1064,14 @@ error_code = contacts_record_set_bool(person, _contacts_person.is_favorite, true
         
         error_code = contacts_db_update_record(person);
         
        -contacts_record_destroy(person, true);
      • -
      • Unset a favorite: -
        int person_id = ... // Acquire person ID
        +contacts_record_destroy(person, true);
        +
        +
      • + +
      • +

        To unset an existing person as a favorite, update the person record by setting its _contacts_person.is_favorite property to false:

        +
        +int person_id = ...; /* Get the person ID */
         contacts_record_h person = NULL;
         
         error_code = contacts_db_get_record(_contacts_person._uri, person_id, &person);
        @@ -850,576 +1080,669 @@ error_code = contacts_record_set_bool(person, _contacts_person.is_favorite, fals
         
         error_code = contacts_db_update_record(person);
         
        -contacts_record_destroy(person, true);
      +contacts_record_destroy(person, true); +
      +
    • + +
    -

    Monitoring Person Changes

    +

    Monitoring Person Changes

    -

    To register a callback function to listen for person changes:

    -
    1. Register the callback function: -
      error_code = contacts_db_add_changed_cb(_contacts_person._uri, _person_changed_callback, NULL);
      -
    2. -
    3. Define the callback function. -

      The callback function is called when the person data changes. The following example shows how to update person details in the callback function.

      +

      To receive a notification whenever the person details change:

      + +
        + +
      1. +

        Register a callback using the contacts_db_add_changed_cb() function:

        -static contacts_gl_person_data_t *_gl_person_data = ...
        -void
        +error_code = contacts_db_add_changed_cb(_contacts_person._uri, _person_changed_callback, NULL);
        +
        +
      2. + +
      3. +

        Define the person change callback.

        +

        The following example shows how to retrieve the new person details in the callback:

        +
        +static contacts_gl_person_data_t *_gl_person_data = ...;
        +
        +static void
         _person_changed_callback(const char *view_uri, void *user_data)
         {
        -   int error_code;
        +    if (0 != strcmp(view_uri, _contacts_person._uri))
        +        return;
         
        -   if (0 != strcmp(view_uri, _contacts_person._uri))
        -      return;
        +    if (_gl_person_data == NULL)
        +        return;
         
        -   if (_gl_person_data == NULL)
        -      return;
        +    int person_id = _gl_person_data->id;
        +    _free_gl_person_data(_gl_person_data);
        +    _gl_person_data = NULL;
        +
        +    contacts_record_h record = NULL;
        +    int error_code;
        +    error_code = contacts_db_get_record(_contacts_person._uri, person_id, &record);
        +    if (error_code != CONTACTS_ERROR_NONE)
        +        return;
        +
        +    _gl_person_data = _create_gl_person_data(record);
        +    /* Use _gl_person_data */
        +
        +    contacts_record_destroy(record, true);
        +}
        +
        +
      4. -   int person_id = _gl_person_data->id; -   _free_gl_person_data(_gl_person_data); -   _gl_person_data = NULL; +
      -   contacts_record_h record = NULL; -   error_code = contacts_db_get_record(_contacts_person._uri, person_id, &record); -   if (error_code != CONTACTS_ERROR_NONE) -      return; +

      Creating a Group

      -   _gl_person_data = _create_gl_person_data(record); -   // Use _gl_person_data +

      A group is a collection of contacts from the same address book. Creating a new group involves creating a group handle, setting the group properties, and inserting the group into the contact database. To add contacts to the group, see Managing Group Members.

      -   contacts_record_destroy(record, true); -}
    +

    To create a new group:

    -

    Creating a Group

    +
      -

      To create a new group record:

      -
      contacts_record_h group = NULL;
      +
    1. +

      Create a group handle using the contacts_record_create() function with the _contacts_group._uri property as the first parameter and the group handle variable as the second parameter:

      +
      +contacts_record_h group = NULL;
       
       error_code = contacts_record_create(_contacts_group._uri, &group);
       
      +
    2. -

      Setting Group Properties

      - -

      To set group properties:

      - -
      • Set the group name with the contacts_record_set_str() function. This function takes the group record handle as the first parameter, _contacts_group.name as the second, and the name, which is a string value, as the third parameter. The name parameter is taken from the UI part of the application. The function returns the status code. If the function returns an error, take appropriate action, such as freeing memory, removing handles, and disconnecting from the service if needed. -
        error_code = contacts_record_set_str(group, _contacts_group.name, "Neighbors");
        -
      • -
      • Set an image and ringtone path with the contacts_record_set_str() function and check the error codes. You can set the other properties similarly. +
      • +

        Set the group properties:

        +
          +
        • +

          To set the group name, use the contacts_record_set_str() function with the _contacts_group.name property as the second parameter:

          +
          +error_code = contacts_record_set_str(group, _contacts_group.name, "Neighbors");
          +
          +
        • +
        • +

          To set the group image, define the path to the image file, and set the path to the group using the contacts_record_set_str() function with the _contacts_group.image_path property as the second parameter:

           char *resource_path = app_get_resource_path();
           char temp_path[1024];
           snprintf(temp_path, sizeof(temp_path), "%s/group_image.jpg", resource_path);
           error_code = contacts_record_set_str(group, _contacts_group.image_path, temp_path);
          -snprintf(temp_path, sizeof(temp_path), "%s/ringtone.mp3", resource_path);
           free(resource_path);
          +
          +
        • +
        • +

          To set the group ringtone, define the path to the ringtone file, and set the path to the group using the contacts_record_set_str() function with the _contacts_group.ringtone_path property as the second parameter:

          +
          +char *resource_path = app_get_resource_path();
          +char temp_path[1024];
          +snprintf(temp_path, sizeof(temp_path), "%s/ringtone.mp3", resource_path);
           error_code = contacts_record_set_str(group, _contacts_group.ringtone_path, temp_path);
          -
        - -

        Inserting a Group to the Database

        +free(resource_path); +
      + + +

      Set other group properties similarly, as needed.

      + -

      To insert a group record:

      -
      1. Use the contacts_db_insert_record() function to insert a newly created group into the contacts database. -

        The first parameter is the group record handle, the second is the record ID. A unique ID is assigned to the record your are adding, and is returned as the third parameter of the called function. If the group is inserted successfully, the function returns CONTACTS_ERROR_NONE.

        -
        int added_group_id = -1;
        +
      2. +

        Insert the group into the contact database using the contacts_db_insert_record() function:

        +
        +int added_group_id = -1;
         
         error_code = contacts_db_insert_record(group, &added_group_id);
        -
      3. -
      4. After inserting, the used structures have to be destroyed: -
        contacts_record_destroy(group, true);
      + + + +
    3. +

      When no longer needed, destroy the group handle and release all its resources using the contacts_record_destroy() function:

      +
      +contacts_record_destroy(group, true);
      +
      +
    4. -

      Getting Groups

      +
    + +

    Retrieving Groups

    + +

    To retrieve a single group:

    + +
      -

      To get all of the group records one by one, or to filter them by one of the properties:

      +
    1. +

      Retrieve a group record using the contacts_db_get_record() function with the group ID as the second parameter:

      +
      +contacts_record_h group;
      +int group_id = ...; /* Get the group ID */
      +int error_code;
       
      -
      1. Get a single group record: -
        1. Use the contacts_db_get_record() function with the appropriate group_id:

          -
          contacts_record_h group;
          -int group_id = ... // Acquire group ID
           error_code = contacts_db_get_record(_contacts_group._uri, group_id, &group);
          -
        2. -
        3. When you no longer need the group record, destroy the used structures: +
      +
    2. -
      contacts_record_destroy(group, true);
    +
  • +

    When no longer needed, destroy the group handle and release all its resources using the contacts_record_destroy() function:

    +
    +contacts_record_destroy(group, true);
    +
    +
  • -
  • Get the total group record list: -
    1. -

      Use the contacts_db_get_all_records() function:

      -
      contacts_list_h list = NULL;
      -error_code = contacts_db_get_all_records(_contacts_group._uri, 0, 0, &list);
      -
    2. - -
    3. To iterate the list and read the records: - - - - - - - - - - -
      Note
      Some functions have the _p postfix. It means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
      -
        -
      1. -

        To get the records from the list, use the contacts_list_get_current_record_p(), and contacts_list_next() or contacts_list_prev() functions. The following example gets the details of each record in the loop.

        - -
        -contacts_record_h record;
        -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
        -{
        -   char* name;
        -   error_code = contacts_record_get_str_p(record, _contacts_group.name, &name);
        -   dlog_print(DLOG_DEBUG, LOG_TAG, "group name: %s", name);
        -
        -   error_code = contacts_list_next(list);
        -   if (error_code != CONTACTS_ERROR_NONE)
        -      break;
        -}
        -
      2. -
      3. If you want to get more details of each record, use the contacts_gl_group_data_t structure: -
        -contacts_gl_group_data_t *gl_group_data = NULL;
        -contacts_record_h record;
        -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
        -{
        -   gl_group_data = _create_gl_group_data(record);
        -   // You can get, for example, display name:
        -   // gl_group_data->name
        -
        -   error_code = contacts_list_next(list);
        -   if (error_code != CONTACTS_ERROR_NONE)
        -      break;
        -}
        -
      4. -
      5. The memory for the record data is allocated, and the data is copied from the record by the functions listed in the following example: -
        -typedef struct
        -_contacts_gl_group_data
        -{
        -   int id;
        -   char *name;
        -   char *image_path;
        -   char *ringtone_path;
        -} contacts_gl_group_data_t;
        +
      -static void -_free_gl_group_data(contacts_gl_group_data_t *gl_group_data) -{ -   if (NULL == gl_group_data) -      return; +

      To retrieve multiple groups:

      -   free(gl_group_data->name); -   free(gl_group_data->image_path); -   free(gl_group_data->ringtone_path); -   free(gl_group_data); -} +
        -static contacts_gl_group_data_t* -_create_gl_group_data(contacts_record_h record) -{ -   contacts_gl_group_data_t *gl_group_data; -   int error_code; - -   gl_group_data = malloc(sizeof(contacts_gl_group_data_t)); -   memset(gl_group_data, 0x0, sizeof(contacts_gl_group_data_t)); - -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_group.id, &gl_group_data->id)) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed "); -      _free_gl_group_data(gl_group_data); - -      return NULL; -   } -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.name, &gl_group_data->name)) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed "); -      _free_gl_group_data(gl_group_data); - -      return NULL; -   } -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.image_path, &gl_group_data->image_path)) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed "); -      _free_gl_group_data(gl_group_data); - -      return NULL; -   } -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.ringtone_path, &gl_group_data->ringtone_path)) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed "); -      _free_gl_group_data(gl_group_data); - -      return NULL; -   } - -   return gl_group_data; -} - -
      -
    4. -
    5. When you no longer need the group record, destroy the used structures: -
      -contacts_list_destroy(list, true);
      +
    6. +

      Retrieve a list of all groups, or retrieve a filtered list of groups:

      +
        +
      • +

        To retrieve a list of all groups, use the contacts_db_get_all_records() function:

        +
        +contacts_list_h list = NULL;
        +
        +error_code = contacts_db_get_all_records(_contacts_group._uri, 0, 0, &list);
         
        -
      • -
    -
  • -
  • Get the filtered group record list: -
      -
    1. Use the contacts_db_get_records_with_query() function to filter the list with parameters: -
        -
      1. To get groups with filtering, you need a record list and a query: -
        contacts_list_h list = NULL;
        +
      2. +
      3. +

        To retrieve a filtered list of groups:

        +
          +
        1. +

          Define a list handle variable, and create a query handle using the contacts_query_create() function:

          +
          +contacts_list_h list = NULL;
           contacts_query_h query = NULL;
           
           error_code = contacts_query_create(_contacts_group._uri, &query);
          -
        2. -
        3. Before getting the groups, filter the list. There is a possibility to filter based on various parameters. To create a filter: -
          contacts_filter_h filter = NULL;
          +
          +
        4. +
        5. +

          Create a filter handle using the contacts_filter_create() function:

          +
          +contacts_filter_h filter = NULL;
           
           error_code = contacts_filter_create(_contacts_group._uri, &filter);
          -
        6. -
        7. Add a condition, such as group name: -
          error_code = contacts_filter_add_str(filter, _contacts_group.name, CONTACTS_MATCH_CONTAINS, "neighbors");
           
          -

          That way only groups which contain the name "neighbors" are retrieved. To use multiple conditions, add an operator between them:

          -
          error_code = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR);
          -
          -error_code = contacts_filter_add_str(filter, _contacts_group.name, CONTACTS_MATCH_CONTAINS, "friend");
          -
        8. -
        9. Connect the query with the list: -
          error_code = contacts_query_set_filter(query, filter);
          +
        10. +
        11. +

          Add a filtering condition using a contacts_filter_add_XXX() function.

          +

          The following example adds a string-based filtering condition that retrieves any group whose name contains the string "neighbors":

          +
          +error_code = contacts_filter_add_str(filter, _contacts_group.name,
          +                                     CONTACTS_MATCH_CONTAINS, "neighbors");
          +
          +
        12. +
        13. +

          To add more conditions, define an operator between the conditions.

          +

          The following example first adds an OR operator and then a string-based filtering condition that retrieves any group whose name contains the string "friend".

          +

          The combination of the OR operator and the 2 conditions means that the filter only retrieves groups whose name contains the string "neighbors" or "friend".

          +
          +error_code = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR);
           
          +error_code = contacts_filter_add_str(filter, _contacts_group.name,
          +                                     CONTACTS_MATCH_CONTAINS, "friend");
          +
          +
        14. +
        15. +

          Set the filter to the query using the contacts_query_set_filter() function:

          +
          +error_code = contacts_query_set_filter(query, filter);
          +
          +
        16. +
        17. +

          Retrieve the filtered list of groups using the contacts_db_get_records_with_query() function:

          +
           error_code = contacts_db_get_records_with_query(query, 0, 0, &list);
           
          -

          The third parameter refers to the limit of the results. If 0 is passed, there are no limits. Remember that after all operations, the list must be released.

        18. -
        19. Free the filter and query: +

          The third parameter defines a limit for the number of results. If you set it to 0, the list returns all groups matching the query.

          +
        20. +
        21. +

          When no longer needed, destroy the filter and query handles and release all their resources using the contacts_filter_destroy() and contacts_query_destroy() functions:

           contacts_filter_destroy(filter);
           contacts_query_destroy(query);
          -
        22. -
      4. -
      5. To iterate the list and read the records: - - - - - - - - - - -
        Note
        Some functions have the _p postfix. It means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
        - -
        1. To get the records from the list, use the contacts_list_get_current_record_p(), and contacts_list_next() or contacts_list_prev() functions. Get the details of each record in the loop.

          - -
          contacts_record_h record;
          -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
          -{
          -   char* name;
          -   error_code = contacts_record_get_str_p(record, _contacts_group.name, &name);
          -   dlog_print(DLOG_DEBUG, LOG_TAG, "group name: %s", name);
          -
          -   error_code = contacts_list_next(list);
          -   if (error_code != CONTACTS_ERROR_NONE)
          -      break;
          -}
        2. -
        3. If you want to get more details of each record, use the contacts_gl_group_data_t structure:

          -
          contacts_gl_group_data_t *gl_group_data = NULL;
          +
          +
        4. +
        +
      6. + + + +
      7. +

        Iterate through the list of found groups, and retrieve group details:

        +
          +
        1. +

          Use a loop to iterate through the list and retrieve the group details.

          +

          Move forward and backward within the list using the contacts_list_next() and contacts_list_prev() functions, and retrieve the current group using the contacts_list_get_current_record_p() function.

          + + + + + + + + + +
          Note
          Some functions have the _p postfix. The postfix means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
          +

          The following example iterates through the list and retrieves the name of each group:

          +
           contacts_record_h record;
          -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
          -{
          -   gl_group_data = _create_gl_group_data(record);
          -   // You can get, for example, display name:
          -   // gl_group_data->name
          -
          -   error_code = contacts_list_next(list);
          -   if (error_code != CONTACTS_ERROR_NONE)
          -      break;
          -}
        2. -
        3. The memory for the record data is allocated, and the data is copied from the record by the functions listed further on in this tutorial:

          -
          -typedef struct
          -_contacts_gl_group_data
          -{
          -   int id;
          -   char *name;
          -   char *image_path;
          -   char *ringtone_path;
          -} contacts_gl_group_data_t;
          +while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) {
          +    char *name;
          +    error_code = contacts_record_get_str_p(record, _contacts_group.name, &name);
          +    dlog_print(DLOG_DEBUG, LOG_TAG, "group name: %s", name);
          +
          +    error_code = contacts_list_next(list);
          +    if (error_code != CONTACTS_ERROR_NONE)
          +        break;
          +}
          +
          +
        4. +
        5. +

          Optionally, retrieve more details of each group using the contacts_gl_group_data_t structure:

          +
          +contacts_gl_group_data_t *gl_group_data = NULL;
          +contacts_record_h record;
          +while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) {
          +    gl_group_data = _create_gl_group_data(record);
          +    /* You can get, for example, display name: */
          +    /* gl_group_data->name */
          +
          +    error_code = contacts_list_next(list);
          +    if (error_code != CONTACTS_ERROR_NONE)
          +        break;
          +}
          +
          +

          Define the contacts_gl_group_data_t structure and the functions for using the structure:

          +
          +struct _contacts_gl_group_data {
          +    int id;
          +    char *name;
          +    char *image_path;
          +    char *ringtone_path;
          +};
          +typedef struct _contacts_gl_group_data contacts_gl_group_data_t;
           
          +/* Release the resources allocated to the structure */
           static void
           _free_gl_group_data(contacts_gl_group_data_t *gl_group_data)
           {
          -   if (NULL == gl_group_data)
          -      return;
          +    if (NULL == gl_group_data)
          +        return;
           
          -   free(gl_group_data->name);
          -   free(gl_group_data->image_path);
          -   free(gl_group_data->ringtone_path);
          -   free(gl_group_data);
          +    free(gl_group_data->name);
          +    free(gl_group_data->image_path);
          +    free(gl_group_data->ringtone_path);
          +    free(gl_group_data);
           }
           
          +/* Create the structure for a group */
           static contacts_gl_group_data_t*
           _create_gl_group_data(contacts_record_h record)
           {
          -   contacts_gl_group_data_t *gl_group_data;
          -   int error_code;
          -
          -   gl_group_data = malloc(sizeof(contacts_gl_group_data_t));
          -   memset(gl_group_data, 0x0, sizeof(contacts_gl_group_data_t));
          -
          -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_group.id, &gl_group_data->id))
          -   {
          -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed ");
          -      _free_gl_group_data(gl_group_data);
          -
          -      return NULL;
          -   }
          -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.name, &gl_group_data->name))
          -   {
          -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed ");
          -      _free_gl_group_data(gl_group_data);
          -
          -      return NULL;
          -   }
          -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.image_path, &gl_group_data->image_path))
          -   {
          -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed ");
          -      _free_gl_group_data(gl_group_data);
          -
          -      return NULL;
          -   }
          -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.ringtone_path, &gl_group_data->ringtone_path))
          -   {
          -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed ");
          -      _free_gl_group_data(gl_group_data);
          -
          -      return NULL;
          -   }
          -
          -   return gl_group_data;
          -}
      8. -
      9. When you no longer need the group record, destroy the used structures: -
        -contacts_list_destroy(list, true);
        -
    - -

    Updating a Group

    - -

    To change the name and image of an existing person:

    -
    1. Get the group. -

      To modify a record, you need to have a handle (contacts_record_h type variable) to a memory object representing the record in the database. One of the ways to acquire it is to use the group ID.

      -
      int group_id = ... // Acquire group ID
      +    contacts_gl_group_data_t *gl_group_data;
      +    int error_code;
      +
      +    gl_group_data = malloc(sizeof(contacts_gl_group_data_t));
      +    memset(gl_group_data, 0x0, sizeof(contacts_gl_group_data_t));
      +
      +    if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_group.id,
      +                                                       &gl_group_data->id)) {
      +        dlog_print(DLOG_ERROR, LOG_TAG, "get group ID failed ");
      +        _free_gl_group_data(gl_group_data);
      +
      +        return NULL;
      +    }
      +    if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.name,
      +                                                       &gl_group_data->name)) {
      +        dlog_print(DLOG_ERROR, LOG_TAG, "get group name failed ");
      +        _free_gl_group_data(gl_group_data);
      +
      +        return NULL;
      +    }
      +    if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.image_path,
      +                                                       &gl_group_data->image_path)) {
      +        dlog_print(DLOG_ERROR, LOG_TAG, "get group image failed ");
      +        _free_gl_group_data(gl_group_data);
      +
      +        return NULL;
      +    }
      +    if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_group.ringtone_path,
      +                                                       &gl_group_data->ringtone_path)) {
      +        dlog_print(DLOG_ERROR, LOG_TAG, "get group ringtone failed ");
      +        _free_gl_group_data(gl_group_data);
      +
      +        return NULL;
      +    }
      +
      +    return gl_group_data;
      +}
      +
      +
    2. +
    +
  • + +
  • +

    When no longer needed, destroy the list handle and release all its resources using the contacts_list_destroy() function:

    +
    +contacts_list_destroy(list, true);
    +
    +
  • + + + +

    Updating a Group

    + +

    To update group details:

    + +
      + +
    1. +

      Retrieve the group you want to update using the contacts_db_get_record() function with the group ID as the second parameter:

      +
      +int group_id = ...; /* Get the group ID */
       contacts_record_h group = NULL;
       
       error_code = contacts_db_get_record(_contacts_group._uri, group_id, &group);
       
      -

      Such handles are also provided by search functions, such as contacts_db_get_records_with_query().

      +

      You can also retrieve the group using a search function, such as contacts_db_get_records_with_query().

    2. -
    3. Change the name and image property using the contacts_record_set_str() function: -
      error_code = contacts_record_set_str(group, _contacts_group.name, "Family");
      +
      +
    4. +

      Set the properties you want to update.

      +

      The following example sets a new name and image for the group:

      +
      +error_code = contacts_record_set_str(group, _contacts_group.name, "Family");
      +
       char *resource_path = app_get_resource_path();
       char temp_path[1024];
       snprintf(temp_path, sizeof(temp_path), "%s/group_image_new.jpg", resource_path);
       free(resource_path);
       error_code = contacts_record_set_str(group, _contacts_group.image_path, temp_path);
      -
    5. +
      +
    6. + +
    7. +

      Update the group using the contacts_db_update_record() function:

      +
      +error_code = contacts_db_update_record(group);
      +
      +

      Since the update concerns direct properties of the group record, not child records, updating the group record by definition also updates the properties.

      +
    8. + +
    9. +

      When no longer needed, destroy the group handle and release all its resources using the contacts_record_destroy() function:

      +
      +contacts_record_destroy(group, true);
      +
      +
    10. -
    11. Update the group record. The above changes (name and image) are also inserted. -
      error_code = contacts_db_update_record(group);
      -
    12. -
    13. When the record handle is no longer needed, use the contacts_record_destroy() function to destroy the record handle and free the allocated memory: -
      contacts_record_destroy(group, true);
    + -

    Deleting a Group

    +

    Deleting a Group

    -

    To delete a group, call the contacts_db_delete_record() function with _contacts_group._uri as the first parameter and group ID as the second one:

    -
    int group_id = ... // Acquire group ID
    +

    To delete a group, use the contacts_db_delete_record() function with the group ID as the second parameter:

    +
    +int group_id = ...; /* Get the group ID */
     
     error_code = contacts_db_delete_record(_contacts_group._uri, group_id);
     
    -

    Managing Group Members

    +

    Managing Group Members

    + +

    Group members are contacts from the same address book. Each contact is associated with a person.

    -

    To manage group members:

    +

    To add, remove, and retrieve group members:

    + +
      -
      • Add a group member by getting the contact ID and the group ID, and call the contacts_group_add_contact() function: -
        int contact_id = ... // Acquire contact ID
        -int group_id = ... // Acquire group ID
        +
      • +

        To add a new contact to a group, retrieve the contact ID and the group ID, and use the contacts_group_add_contact() function:

        +
        +int contact_id = ...; /* Get the contact ID */
        +int group_id = ...; /* Get the group ID */
         
         error_code = contacts_group_add_contact(group_id, contact_id);
        -
      • -
      • Remove a contact from a group with the contacts_group_remove_contact() function: +
      • +
      • + +
      • +

        To remove a contact from a group, use the contacts_group_remove_contact() function:

         error_code = contacts_group_remove_contact(group_id, contact_id);
        -
      • +
    + -
  • Get a list of persons assigned to a specific group: -
    1. Get the records of the _contacts_person_group_assigned type: +
    2. +

      To retrieve all persons assigned to a group:

      +
        +
      1. +

        Create and run a query for retrieving a list of all persons assigned to the group:

         contacts_query_h query = NULL;
         contacts_filter_h filter = NULL;
         contacts_list_h list = NULL;
         
        +/* Create a person query with a filter for group ID */
         contacts_query_create(_contacts_person_group_assigned._uri, &query);
         contacts_filter_create(_contacts_person_group_assigned._uri, &filter);
        -contacts_filter_add_int(filter, _contacts_person_group_assigned.group_id, CONTACTS_MATCH_EQUAL, group_id);
        +contacts_filter_add_int(filter, _contacts_person_group_assigned.group_id,
        +                        CONTACTS_MATCH_EQUAL, group_id);
         contacts_query_set_filter(query, filter);
        -contacts_db_get_records_with_query(query, 0, 0, &list);
      2. -
      3. Iterate over the list elements: -
        contacts_record_h person = NULL;
        +
        +/* Run the query: Retrieve a list of all persons assigned to the specified group */
        +contacts_db_get_records_with_query(query, 0, 0, &list);
        +
        +
      4. +
      5. +

        Iterate through the list, and retrieve the person details.

        +

        The following example iterates through the list and retrieves the ID and display name of each person:

        +
        +contacts_record_h person = NULL;
         int error_code;
         
        -while (contacts_list_get_current_record_p(list, &person) == CONTACTS_ERROR_NONE)
        -{
        -   int person_id;
        -   contacts_record_get_int(person, _contacts_person_group_assigned.person_id, &person_id);
        -   dlog_print(DLOG_DEBUG, LOG_TAG, "Person id: %d", person_id);
        -
        -   char *display_name;
        -   contacts_record_get_str_p(person, _contacts_person_group_assigned.display_name, &display_name);
        -   dlog_print(DLOG_DEBUG, LOG_TAG, "Display name: %s", display_name);
        -
        -   error_code = contacts_list_next(list);
        -   if (error_code != CONTACTS_ERROR_NONE)
        -      break;
        -}
      6. -
      7. Destroy the filter, query, and list handles when no longer needed: -
        contacts_list_destroy(list, true);
        +while (contacts_list_get_current_record_p(list, &person) == CONTACTS_ERROR_NONE) {
        +    int person_id;
        +    contacts_record_get_int(person, _contacts_person_group_assigned.person_id, &person_id);
        +    dlog_print(DLOG_DEBUG, LOG_TAG, "Person id: %d", person_id);
        +
        +    char *display_name;
        +    contacts_record_get_str_p(person, _contacts_person_group_assigned.display_name, &display_name);
        +    dlog_print(DLOG_DEBUG, LOG_TAG, "Display name: %s", display_name);
        +
        +    error_code = contacts_list_next(list);
        +    if (error_code != CONTACTS_ERROR_NONE)
        +        break;
        +}
        +
        +
      8. +
      9. +

        When no longer needed, destroy the list, filter, and query handles and release all their resources using the contacts_list_destroy(), contacts_filter_destroy(), and contacts_query_destroy() functions:

        +
        +contacts_list_destroy(list, true);
         contacts_filter_destroy(filter);
        -contacts_query_destroy(query);
    3. +contacts_query_destroy(query); + + +
    +
  • + + -

    Monitoring Group Changes

    +

    Monitoring Group Changes

    + +

    To receive a notification whenever the group details change:

    + +
      + +
    1. +

      Register a callback using the contacts_db_add_changed_cb() function:

      +
      +error_code = contacts_db_add_changed_cb(_contacts_group._uri, _group_changed_callback, NULL);
      +
      +
    2. + +
    3. +

      Define the group change callback.

      +

      The following example shows how to retrieve the new group details in the callback:

      +
      +static contacts_gl_group_data_t *_gl_group_data = ...;
       
      -

      To register a callback function to listen for group changes:

      -
      1. Register the callback function to listen for group changes: -
        error_code = contacts_db_add_changed_cb(_contacts_group._uri, _group_changed_callback, NULL);
        -
      2. -
      3. Define the callback function to be called when the group data changes: -
        static contacts_gl_group_data_t *_gl_group_data = ...
         static void
         _group_changed_callback(const char *view_uri, void *user_data)
         {
        -   int error_code;
        +    if (0 != strcmp(view_uri, _contacts_group._uri))
        +        return;
        +
        +    if (_gl_group_data == NULL)
        +        return;
         
        -   if (0 != strcmp(view_uri, _contacts_group._uri))
        -      return;
        +    int group_id = _gl_group_data->id;
        +    _free_gl_group_data(_gl_group_data);
        +    _gl_group_data = NULL;
         
        -   if (_gl_group_data == NULL)
        -      return;
        +    contacts_record_h record = NULL;
        +    int error_code;
        +    error_code = contacts_db_get_record(_contacts_group._uri, group_id, &record);
        +    if (error_code != CONTACTS_ERROR_NONE)
        +        return;
         
        -   int group_id = _gl_group_data->id;
        -   _free_gl_group_data(_gl_group_data);
        -   _gl_group_data = NULL;
        +    _gl_group_data = _create_gl_group_data(record);
        +    /* Use _gl_group_data */
         
        -   contacts_record_h record = NULL;
        -   error_code = contacts_db_get_record(_contacts_group._uri, group_id, &record);
        -   if (error_code != CONTACTS_ERROR_NONE)
        -      return;
        +    contacts_record_destroy(record, true);
        +}
        +
        +
      4. -   _gl_group_data = _create_gl_group_data(record); -   // Use _gl_group_data +
      -   contacts_record_destroy(record, true); -}
    +

    Creating a vCard

    -

    Making a vCard

    +

    To create a vCard stream from a person:

    -

    To make a vCard stream from a person record:

    -
    1. Get the person record by the person ID: -
      int person_id = ... // Acquire person ID
      +
        +
      1. +

        Retrieve the person:

        +
        +int person_id = ...; /* Get the person ID */
         contacts_record_h record = NULL;
        +
         error_code = contacts_db_get_record(_contacts_person._uri, person_id, &record);
        -
      2. -
      3. Make the vCard stream by the person record: -
        char *vcard_stream = NULL;
        +
        +
      4. + +
      5. +

        Create the vCard stream from the person:

        +
        +char *vcard_stream = NULL;
         error_code = contacts_vcard_make_from_person(record, &vcard_stream);
         
        - - - - - - - - - -
        Note
        The Contact Service API allows you to make a vCard stream from a person, contact, and my profile records: -
        int contacts_vcard_make_from_person(contacts_record_h person, char **vcard_stream);
        -int contacts_vcard_make_from_contact(contacts_record_h contact, char **vcard_stream);
        -int contacts_vcard_make_from_my_profile(contacts_record_h my_profile, char **vcard_stream);
        -
      6. + + + + + + + + + +
        Note
        The contacts service allows you to create a vCard stream from a person, contact, or my profile (using the contacts_vcard_make_from_person(), contacts_vcard_make_from_contact(), or contacts_vcard_make_from_my_profile() function).
        + + +
      7. +

        When no longer needed, free the vCard stream, destroy the person handle, and release all its resources:

        +
        +free(vcard_stream);
        +contacts_record_destroy(record, true);
        +
        +
      8. + +
      + +

      Parsing a vCard

      -
    2. Destroy the handle when it is no longer needed: -
      free(vcard_stream);
      -contacts_record_destroy(record, true);
      -
    +

    To parse a vCard from a file and insert its content into the content database:

    -

    Parsing a vCard

    +
      -

      To parse a vCard from a file and insert to the database:

      +
    1. +

      Parse the vCard stream using the contacts_vcard_parse_to_contact_foreach() function:

       char *resource_path = app_get_resource_path();
       char temp_path[1024];
       snprintf(temp_path, sizeof(temp_path), "%s/vcard.vcf", resource_path);
       free(resource_path);
      -error_code = contacts_vcard_parse_to_contact_foreach(temp_path, // File path of vCard
      -                                                     _vcard_parse_cb, // Callback function to invoke
      -                                                     NULL); // User data to be passed to the callback function
      +
      +error_code = contacts_vcard_parse_to_contact_foreach(temp_path, /* File path of vCard */
      +                                                     _vcard_parse_cb, /* Callback to invoke */
      +                                                     NULL); /* User data passed to the callback */
       
      +
    2. -

      The vCard stream contains multiple contact objects. The callback function is called after parsing each contact. If you return false on the callback function, parsing stops.

      +
    3. +

      Define a callback that inserts the parsed contact into the contact database.

      +

      The vCard stream can contain multiple contacts. The contacts_vcard_parse_to_contact_foreach() function invokes a separate callback for each parsed contact. As long as the callbacks return true, the foreach function continues to parse new contacts.

       static bool
       _vcard_parse_cb(contacts_record_h contact, void *user_data)
       {
      -   if (NULL == contact)
      -      return false;
      +    if (NULL == contact)
      +        return false;
      +
      +    int contact_id = -1;
      +    error_code = contacts_db_insert_record(contact, &contact_id);
      +    /* Use the contact record */
      +
      +    return true;
      +}
      +
      +
    4. -   int contact_id = -1; -   error_code = contacts_db_insert_record(contact, &contact_id); -   // Use the contact record +
    + +

    Creating a Speed Dial

    -   return true; -} +

    Creating a new speed dial involves creating a speed dial handle, setting the speed dial properties, and inserting the speed dial into the contact database.

    +

    To create a new speed dial:

    -

    Creating a Speed Dial

    +
      -

      To create a speed dial record:

      +
    1. +

      Create a speed dial handle using the contacts_record_create() function with the _contacts_speeddial._uri property as the first parameter and the speed dial handle variable as the second parameter:

       contacts_record_h speeddial;
      +
       error_code = contacts_record_create(_contacts_speeddial._uri, &speeddial);
       
      -

      The first parameter determines the type of the created record. Use _contacts_speeddial._uri to create speed dial type records.

      - -

      Setting Speed Dial Properties

      +
    2. -

      To set speed dial properties:

      -
        -
      1. Set the speed dial number with the contacts_record_set_int() function. This function takes the speed dial record handle as the first parameter, _contacts_speeddial.speeddial_number as the second, and the speed dial number, which is an integer value, as the third parameter. The function returns the status code. If the function returns an error, take appropriate action, such as freeing memory, removing handles, or disconnecting from the service. +
      2. +

        Set the speed dial properties:

        +
          +
        • +

          To set the speed dial number, use the contacts_record_set_int() function with the _contacts_speeddial.speeddial_number property as the second parameter:

          -int speeddial_number = ... // Acquire speed dial number
          -error_code = contacts_record_set_int(speeddial, _contacts_speeddial.speeddial_number, speeddial_number);
          +int speeddial_number = ...; /* Get the speed dial number */
          +error_code = contacts_record_set_int(speeddial, _contacts_speeddial.speeddial_number,
          +                                     speeddial_number);
           
        • - -
        • Set the number ID: +
        • +

          To set the ID for the speed dial number, use the contacts_record_set_int() function with the _contacts_speeddial.number_id property as the second parameter:

          -int number_id = ... // Acquire number id
          -error_code = contacts_record_set_int(speeddial, _contacts_speeddial. number_id, number_id);
          +int number_id = ...; /* Get the speed dial number ID */
          +error_code = contacts_record_set_int(speeddial, _contacts_speeddial.number_id, number_id);
           
        • -
      - -

      Inserting a Speed Dial to the Database

      + +

      Set other speed dial properties similarly, as needed.

      + -

      To insert a speed dial record:

      -
      1. Use the contacts_db_insert_record() function to insert a newly created speed dial into the contacts database. The first parameter is the speed dial record handle, the second is the speed dial number. If the speed dial is inserted successfully, the function returns CONTACTS_ERROR_NONE. +
      2. +

        Insert the speed dial into the contact database using the contacts_db_insert_record() function:

         int added_speeddial_id = -1;
         
        @@ -1427,199 +1750,111 @@ error_code = contacts_db_insert_record(speeddial, &added_speeddial_id);
         
      3. -
      4. After inserting the speed dial record, destroy the used structures: +
      5. +

        When no longer needed, destroy the speed dial handle and release all its resources using the contacts_record_destroy() function:

         contacts_record_destroy(speeddial, true);
         
      6. -
      -

      Getting Speed Dials

      +
    -

    To get all of the speed dial records one by one, or to filter them by one of the properties:

    -
      -
    1. Get a single speed dial record: -
        -
      1. Use the contacts_db_get_record() function with the appropriate speeddial_id:

        -
        -contacts_record_h speeddial;
        -int speeddial_id = ... // Acquire speed dial ID
        -error_code = contacts_db_get_record(_contacts_speeddial._uri, speeddial_id, &speeddial);
        -
        -
      2. +

        Retrieving Speed Dials

        -
      3. After finish using the speed dial record, destroy the used structures: +

        To retrieve a single speed dial:

        -
        contacts_record_destroy(speeddial, true);
    2. +
        -
      1. Get the total speed dial record list: -
        1. Use the contacts_db_get_all_records() function: +
        2. +

          Retrieve a speed dial record using the contacts_db_get_record() function with the speed dial ID as the second parameter:

          -contacts_list_h list = NULL;
          -error_code = contacts_db_get_all_records(_contacts_speeddial._uri, 0, 0, &list);
          -
          -
        3. - -
        4. To iterate the list and read the records, you can get the records from the list using the contacts_list_get_current_record_p(), contacts_list_next(), or contacts_list_prev() function. Get the details of each record in the loop. - - - - - - - - - - -
          Note
          Some functions have the _p postfix. It means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
          - - -
          -contacts_record_h record;
          -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
          -{
          -   int number;
          -   error_code = contacts_record_get_int(record, _contacts_speeddial.speeddial_number, &number);
          -   dlog_print(DLOG_DEBUG, LOG_TAG, "speed dial number: %d", number);
          -
          -   error_code = contacts_list_next(list);
          -   if (error_code != CONTACTS_ERROR_NONE)
          -      break;
          -}
          -
          - -

          To get more details of each record, use the contacts_gl_speeddial_data_t structure:

          +contacts_record_h speeddial; +int speeddial_id = ...; /* Get the speed dial ID */ +int error_code; -
          -contacts_gl_speeddial_data_t *gl_speeddial_data = NULL;
          -contacts_record_h record;
          -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
          -{
          -   gl_speeddial_data = _create_gl_speeddial_data(record);
          +error_code = contacts_db_get_record(_contacts_speeddial._uri, speeddial_id, &speeddial);
          +
          +
        5. -   _free_gl_speeddial_data(gl_speeddial_data); -   error_code = contacts_list_next(list); -   if (error_code != CONTACTS_ERROR_NONE) -      break; -} +
        6. +

          When no longer needed, destroy the speed dial handle and release all its resources using the contacts_record_destroy() function:

          +
          +contacts_record_destroy(speeddial, true);
           
          -

          The memory for the record data is allocated, and the data is copied from the record by the functions shown in the following example:

          +
        7. -
          -typedef struct
          -_contacts_gl_speeddial_data
          -{
          -   int speeddial_number;
          -   char *number;
          -   char *display_name;
          -   char *image_thumbnail_path;
          -} contacts_gl_speeddial_data_t;
          +
        -static void -_free_gl_speeddial_data(contacts_gl_speeddial_data_t *gl_speeddial_data) -{ -   if (NULL == gl_speeddial_data) -      return; +

        To retrieve multiple speed dials:

        -   free(gl_speeddial_data->number); -   free(gl_speeddial_data->display_name); -   free(gl_speeddial_data->image_thumbnail_path); -   free(gl_speeddial_data); -} +
          -static contacts_gl_speeddial_data_t* -_create_gl_speeddial_data(contacts_record_h record) -{ -   contacts_gl_speeddial_data_t *gl_speeddial_data; -   int error_code; - -   gl_speeddial_data = malloc(sizeof(contacts_gl_speeddial_data_t)); -   memset(gl_speeddial_data, 0x0, sizeof(contacts_gl_speeddial_data_t)); - -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_speeddial.speeddial_number, &gl_speeddial_data->speeddial_number)) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed "); -      _free_gl_speeddial_data(gl_speeddial_data); - -      return NULL; -   } -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_speeddial.number, &gl_speeddial_data->number)) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed "); -      _free_gl_speeddial_data(gl_speeddial_data); - -      return NULL; -   } -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_speeddial.display_name, &gl_speeddial_data->display_name)) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed "); -      _free_gl_speeddial_data(gl_speeddial_data); - -      return NULL; -   } -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_speeddial.image_thumbnail_path, &gl_speeddial_data->image_thumbnail_path)) -   { -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed "); -      _free_gl_speeddial_data(gl_speeddial_data); - -      return NULL; -   } - -   return gl_speeddial_data; -} +
        1. +

          Retrieve a list of all speed dials, or retrieve a filtered list of speed dials:

          +
            +
          • +

            To retrieve a list of all speed dials, use the contacts_db_get_all_records() function:

            +
            +contacts_list_h list = NULL;
            +
            +error_code = contacts_db_get_all_records(_contacts_speeddial._uri, 0, 0, &list);
             
            -
          • -
          • After you no longer need the speed dial record, destroy the used structures: -
            -contacts_list_destroy(list, true);
            -
          • -
        -
      2. -
      3. Get the filtered speed dial record list: -
          -
        1. Use the contacts_db_get_records_with_query() function. -
            -
          1. Create a record list and query: - -
            +
          2. +
          3. +

            To retrieve a filtered list of speed dials:

            +
              +
            1. +

              Define a list handle variable, and create a query handle using the contacts_query_create() function:

              +
               contacts_list_h list = NULL;
               contacts_query_h query = NULL;
               
               error_code = contacts_query_create(_contacts_speeddial._uri, &query);
               
              -
            2. -
            3. Filter the list before getting the speed dials. It is possible to filter with various parameters. To create a filter: -
              +
            4. +
            5. +

              Create a filter handle using the contacts_filter_create() function:

              +
               contacts_filter_h filter = NULL;
               
               error_code = contacts_filter_create(_contacts_speeddial._uri, &filter);
               
              -
            6. - -
            7. Add a condition, such as the speed dial number. -

              The following example retrieves only those speed dials whose numbers are less than 3.

              -
              -error_code = contacts_filter_add_int(filter, _contacts_speeddial.speeddial_number, CONTACTS_MATCH_LESS_THAN, 3);
              +
            8. +
            9. +

              Add a filtering condition using a contacts_filter_add_XXX() function.

              +

              The following example adds an integer-based filtering condition that retrieves only speed dials whose number is less than 3:

              +
              +error_code = contacts_filter_add_int(filter, _contacts_speeddial.speeddial_number,
              +                                     CONTACTS_MATCH_LESS_THAN, 3);
               
              -

              To use multiple conditions, add an operator between them:

              -
              +
            10. +
            11. +

              To add more conditions, define an operator between the conditions.

              +

              The following example first adds an OR operator and then an integer-based filtering condition that retrieves only speed dials whose number is greater than 15.

              +

              The combination of the OR operator and the 2 conditions means that the filter only retrieves speed dials whose number is less than 3 or greater than 15.

              +
               error_code = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR);
               
              -error_code = contacts_filter_add_int(filter, _contacts_speeddial.speeddial_number, CONTACTS_MATCH_GREATER_THAN, 15);
              +error_code = contacts_filter_add_int(filter, _contacts_speeddial.speeddial_number,
              +                                     CONTACTS_MATCH_GREATER_THAN, 15);
               
              -
            12. - -
            13. Connect the query with the list: -
              +
            14. +
            15. +

              Set the filter to the query using the contacts_query_set_filter() function:

              +
               error_code = contacts_query_set_filter(query, filter);
              -
              +
              +
            16. +
            17. +

              Retrieve the filtered list of speed dials using the contacts_db_get_records_with_query() function:

              +
               error_code = contacts_db_get_records_with_query(query, 0, 0, &list);
               
              -

              The third parameter refers to the limit of the results. If 0 is passed, there are no limits. Remember that after all operations, the list must be released.

              -
            18. - -
            19. Free the filter and query: +

              The third parameter defines a limit for the number of results. If you set it to 0, the list returns all speed dials matching the query.

              +
            20. +
            21. +

              When no longer needed, destroy the filter and query handles and release all their resources using the contacts_filter_destroy() and contacts_query_destroy() functions:

               contacts_filter_destroy(filter);
               contacts_query_destroy(query);
              @@ -1627,625 +1862,628 @@ contacts_query_destroy(query);
               
          4. + + -
          5. To iterate the list and read the records, you can get the records from the list using the contacts_list_get_current_record_p(), contacts_list_next(), or contacts_list_prev() function. Get the details of each record in the loop. - - - - - - - - - - -
            Note
            Some functions have the _p postfix. It means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
            - +
          6. +

            Iterate through the list of found speed dials, and retrieve speed dial details:

            +
              +
            1. +

              Use a loop to iterate through the list and retrieve the speed dial details.

              +

              Move forward and backward within the list using the contacts_list_next() and contacts_list_prev() functions, and retrieve the current speed dial using the contacts_list_get_current_record_p() function.

              + + + + + + + + + +
              Note
              Some functions have the _p postfix. The postfix means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
              +

              The following example iterates through the list and retrieves the number of each speed dial:

               contacts_record_h record;
              -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
              -{
              -   int number;
              -   error_code = contacts_record_get_int(record, _contacts_speeddial.speeddial_number, &number);
              -   dlog_print(DLOG_DEBUG, LOG_TAG, "speed dial number: %d", number);
              -
              -   error_code = contacts_list_next(list);
              -   if (error_code != CONTACTS_ERROR_NONE)
              -      break;
              +while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) {
              +    int number;
              +    error_code = contacts_record_get_int(record, _contacts_speeddial.speeddial_number,
              +                                         &number);
              +    dlog_print(DLOG_DEBUG, LOG_TAG, "speed dial number: %d", number);
              +
              +    error_code = contacts_list_next(list);
              +    if (error_code != CONTACTS_ERROR_NONE)
              +        break;
               }
               
              - -

              To get more details of each record, use the contacts_gl_speeddial_data_t structure:

              +
            2. +
            3. +

              Optionally, retrieve more details of each speed dial using the contacts_gl_speeddial_data_t structure:

               contacts_gl_speeddial_data_t *gl_speeddial_data = NULL;
               contacts_record_h record;
              -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
              -{
              -   gl_speeddial_data = _create_gl_speeddial_data(record);
              +while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) {
              +    gl_speeddial_data = _create_gl_speeddial_data(record);
              +
              +    _free_gl_speeddial_data(gl_speeddial_data);
               
              -   _free_gl_speeddial_data(gl_speeddial_data);
              -   error_code = contacts_list_next(list);
              -   if (error_code != CONTACTS_ERROR_NONE)
              -      break;
              +    error_code = contacts_list_next(list);
              +    if (error_code != CONTACTS_ERROR_NONE)
              +        break;
               }
               
              -

              The memory for the record data is allocated, and the data is copied from the record by the functions shown in the following example.

              +

              Define the contacts_gl_speeddial_data_t structure and the functions for using the structure:

              -typedef struct
              -_contacts_gl_speeddial_data
              -{
              -   int speeddial_number;
              -   char *number;
              -   char *display_name;
              -   char *image_thumbnail_path;
              -} contacts_gl_speeddial_data_t;
              +struct _contacts_gl_speeddial_data {
              +    int speeddial_number;
              +    char *number;
              +    char *display_name;
              +    char *image_thumbnail_path;
              +};
              +typedef struct _contacts_gl_speeddial_data contacts_gl_speeddial_data_t;
               
              +/* Release the resources allocated to the structure */
               static void
               _free_gl_speeddial_data(contacts_gl_speeddial_data_t *gl_speeddial_data)
               {
              -   if (NULL == gl_speeddial_data)
              -      return;
              +    if (NULL == gl_speeddial_data)
              +        return;
               
              -   free(gl_speeddial_data->number);
              -   free(gl_speeddial_data->display_name);
              -   free(gl_speeddial_data->image_thumbnail_path);
              -   free(gl_speeddial_data);
              +    free(gl_speeddial_data->number);
              +    free(gl_speeddial_data->display_name);
              +    free(gl_speeddial_data->image_thumbnail_path);
              +    free(gl_speeddial_data);
               }
               
              +/* Create the structure for a speed dial */
               static contacts_gl_speeddial_data_t*
               _create_gl_speeddial_data(contacts_record_h record)
               {
              -   contacts_gl_speeddial_data_t *gl_speeddial_data;
              -   int error_code;
              -
              -   gl_speeddial_data = malloc(sizeof(contacts_gl_speeddial_data_t));
              -   memset(gl_speeddial_data, 0x0, sizeof(contacts_gl_speeddial_data_t));
              -
              -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_speeddial.speeddial_number, &gl_speeddial_data->speeddial_number))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed ");
              -      _free_gl_speeddial_data(gl_speeddial_data);
              -
              -      return NULL;
              -   }
              -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_speeddial.number, &gl_speeddial_data->number))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed ");
              -      _free_gl_speeddial_data(gl_speeddial_data);
              -
              -      return NULL;
              -   }
              -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_speeddial.display_name, &gl_speeddial_data->display_name))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed ");
              -      _free_gl_speeddial_data(gl_speeddial_data);
              -
              -      return NULL;
              -   }
              -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_speeddial.image_thumbnail_path, &gl_speeddial_data->image_thumbnail_path))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed ");
              -      _free_gl_speeddial_data(gl_speeddial_data);
              -
              -      return NULL;
              -   }
              -
              -   return gl_speeddial_data;
              +    contacts_gl_speeddial_data_t *gl_speeddial_data;
              +    int error_code;
              +
              +    gl_speeddial_data = malloc(sizeof(contacts_gl_speeddial_data_t));
              +    memset(gl_speeddial_data, 0x0, sizeof(contacts_gl_speeddial_data_t));
              +
              +    if (CONTACTS_ERROR_NONE != contacts_record_get_int(record,
              +                                                       _contacts_speeddial.speeddial_number,
              +                                                       &gl_speeddial_data->speeddial_number)) {
              +        dlog_print(DLOG_ERROR, LOG_TAG, "get speed dial number failed ");
              +        _free_gl_speeddial_data(gl_speeddial_data);
              +
              +        return NULL;
              +    }
              +    if (CONTACTS_ERROR_NONE != contacts_record_get_str(record,
              +                                                       _contacts_speeddial.number,
              +                                                       &gl_speeddial_data->number)) {
              +        dlog_print(DLOG_ERROR, LOG_TAG, "get contact number failed ");
              +        _free_gl_speeddial_data(gl_speeddial_data);
              +
              +        return NULL;
              +    }
              +    if (CONTACTS_ERROR_NONE != contacts_record_get_str(record,
              +                                                       _contacts_speeddial.display_name,
              +                                                       &gl_speeddial_data->display_name)) {
              +        dlog_print(DLOG_ERROR, LOG_TAG, "get display name failed ");
              +        _free_gl_speeddial_data(gl_speeddial_data);
              +
              +        return NULL;
              +    }
              +    if (CONTACTS_ERROR_NONE != contacts_record_get_str(record,
              +                                                       _contacts_speeddial.image_thumbnail_path,
              +                                                       &gl_speeddial_data->image_thumbnail_path)) {
              +        dlog_print(DLOG_ERROR, LOG_TAG, "get thumbnail failed ");
              +        _free_gl_speeddial_data(gl_speeddial_data);
              +
              +        return NULL;
              +    }
              +
              +    return gl_speeddial_data;
               }
               
            4. -
            5. When you no longer need the speed dial record, destroy the used structures: +
            +
          7. + +
          8. +

            When no longer needed, destroy the list handle and release all its resources using the contacts_list_destroy() function:

            -contacts_list_destroy(list, true);
          9. -
        +contacts_list_destroy(list, true); + +
      4. + +
      + +

      Updating a Speed Dial

      -

      Updating a Speed Dial

      +

      To update speed dial details:

      -

      To change the number ID of an existing speed dial:

        -
      1. Get the speed dial. -

        To modify a record, you need to have a handle (contacts_record_h type variable) to a memory object representing the record in the database. One of the ways to acquire it is to use the speed dial number:

        + +
      2. +

        Retrieve the speed dial you want to update using the contacts_db_get_record() function with the speed dial number as the second parameter:

        +
        -int speeddial_number = ... // Acquire speed dial number
        +int speeddial_number = ...; /* Get the speed dial number */
         contacts_record_h speeddial = NULL;
         
         error_code = contacts_db_get_record(_contacts_speeddial._uri, speeddial_number, &speeddial);
         
        - -

        Such handles are also provided by search functions, such as contacts_db_get_records_with_query().

        +

        You can also retrieve the speed dial using a search function, such as contacts_db_get_records_with_query().

      3. -
      4. Change the number ID by setting the number_id property using the contacts_record_set_int() function: +
      5. +

        Set the properties you want to update.

        +

        The following example sets a new ID for the speed dial number:

        -int number_id = ... // Acquire number id
        +int number_id = ...; /* Get the number ID */
        +
         error_code = contacts_record_set_int(speeddial, _contacts_speeddial.number_id, number_id);
         if (error_code != CONTACTS_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts record set integer failed: %x", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "get number ID failed: %x", error_code);
         
      6. -
      7. Update the speed dial record. The above changes (number_id) are also inserted. +
      8. +

        Update the speed dial using the contacts_db_update_record() function:

         error_code = contacts_db_update_record(speeddial);
         
        +

        Since the update concerns a direct property of the speed dial record, not a child record, updating the speed dial record by definition also updates the property.

      9. -
      10. When the record handle is no longer needed, use the contacts_record_destroy() function to destroy the record handle and free the allocated memory: +
      11. +

        When no longer needed, destroy the speed dial handle and release all its resources using the contacts_record_destroy() function:

         contacts_record_destroy(speeddial, true);
         
      12. +
      -

      Deleting a Speed Dial

      +

      Deleting a Speed Dial

      + +

      To delete a speed dial, use the contacts_db_delete_record() function with the speed dial number as the second parameter:

      -

      To delete a speed dial, call the contacts_db_delete_record() function with _contacts_speeddial._uri as the first parameter and speed dial number as the second one:

      -int speeddial_number = ... // Acquire speed dial number
      +int speeddial_number = ...; /* Get the speed dial number */
       
       error_code = contacts_db_delete_record(_contacts_speeddial._uri, speeddial_number);
       
      +

      Creating a Log

      + +

      Creating a new log entry involves creating a log handle, setting the log properties, and inserting the log entry into the contact database.

      + +

      To create a new log entry:

      -

      Creating a Log

      +
        -

        To create a log record:

        +
      1. +

        Create a log handle using the contacts_record_create() function with the _contacts_phone_log._uri property as the first parameter and the log handle variable as the second parameter:

         contacts_record_h log;
        +
         error_code = contacts_record_create(_contacts_phone_log._uri, &log);
         if (error_code != CONTACTS_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts record create failed: %x", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_record_create failed: %x", error_code);
         
        -

        The first parameter determines the type of the created record. Use _contacts_phone_log._uri to create log type records.

        - -

        Setting Log Properties

        +
      2. -

        To set log properties:

        -
          -
        1. Set the log type with contacts_record_set_int() function. This function takes the log record handle as the first parameter, _contacts_phone_log.log_type as the second, and the type, which is a integer value, as the third parameter. The function returns the status code. If the function returns an error, free memory, remove handles, and disconnect from the service, if needed. +
        2. +

          Set the log properties:

          +
            +
          • +

            To set the log type, use the contacts_record_set_int() function with the _contacts_phone_log.log_type property as the second parameter. The third parameter defines the log type using the values of the contacts_phone_log_type_e enumeration (in mobile and wearable applications).

            -error_code = contacts_record_set_int(log, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_VOICE_INCOMING);
            +error_code = contacts_record_set_int(log, _contacts_phone_log.log_type,
            +                                     CONTACTS_PLOG_TYPE_VOICE_INCOMING);
             if (error_code != CONTACTS_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts record set integer failed: %x", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "set log type failed: %x", error_code);
             
            -

            The enumeration flag names for the log types are listed in the contacts_phone_log_type_e enumeration.

          • - -
          • Set time, duration, and address: +
          • +
          • +

            To set the log time (calculated as number of seconds since 1970-01-01 00:00:00 UTC), use the contacts_record_set_int() function with the _contacts_phone_log.log_time property as the second parameter:

             error_code = contacts_record_set_int(log, _contacts_phone_log.log_time, (int)time(NULL));
             if (error_code != CONTACTS_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts record set integer failed: %x", error_code);
            -
            +    dlog_print(DLOG_ERROR, LOG_TAG, "set log time failed: %x", error_code);
            +
            +
          • +
          • +

            To set the log duration (in practice, the message ID, email ID, or call duration in seconds), use the contacts_record_set_int() function with the _contacts_phone_log.extra_data1 property as the second parameter:

            +
             error_code = contacts_record_set_int(log, _contacts_phone_log.extra_data1, 37);
             if (error_code != CONTACTS_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts record set integer failed: %x", error_code);
            -
            +    dlog_print(DLOG_ERROR, LOG_TAG, "set duration failed: %x", error_code);
            +
            +
          • +
          • +

            To set the log address (in practice, the phone number or email address), use the contacts_record_set_str() function with the _contacts_phone_log.address property as the second parameter:

            +
             error_code = contacts_record_set_str(log, _contacts_phone_log.address, "+8231-1234-5678");
             if (error_code != CONTACTS_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts record set string failed: %x", error_code);
            +    dlog_print(DLOG_ERROR, LOG_TAG, "set address failed: %x", error_code);
             
            - -

            Log time means the number of seconds since 1970-01-01 00:00:00 (UTC). The extra_data1 property means the message_id, email_id, or duration (seconds) of a call. The address property means a number or an email.

          • -
        + -

        Inserting a Log to the Database

        +

        Set other log properties similarly, as needed.

        -

        To insert a log record:

        -
          -
        1. Use the contacts_db_insert_record() function to insert a newly created log into the contacts database. The first parameter is the log record handle, the second is the record ID. If the log is inserted successfully, the function returns CONTACTS_ERROR_NONE. +
        2. + +
        3. +

          Insert the log into the contact database using the contacts_db_insert_record() function:

           int added_log_id = -1;
           
           error_code = contacts_db_insert_record(log, &added_log_id);
           if (error_code != CONTACTS_ERROR_NONE)
          -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts db insert record failed: %x", error_code);
          +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_db_insert_record failed: %x", error_code);
           
        4. -
        5. After inserting the log, destroy the used structures: -
          contacts_record_destroy(log, true);
          -
        6. -
        -

        Getting Logs

        - -

        To get all log records one by one, or to filter them by one of the properties:

        -
          -
        1. Get a single log record: -
          1. Use the contacts_db_get_record() function with the appropriate log_id:

            -
            contacts_record_h log;
            -int log_id = ... // Acquire log ID
            -error_code = contacts_db_get_record(_contacts_phone_log._uri, log_id, &log);
            -if (error_code != CONTACTS_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts db get record failed: %x", error_code);
            -
          2. -
          3. After inserting the log, destroy the used structures: -
            contacts_record_destroy(log, true);
          -
        2. -
        3. Get the total log record list: -
          1. Use the contacts_db_get_all_records() function:

            +
          2. +

            When no longer needed, destroy the log handle and release all its resources using the contacts_record_destroy() function:

            -contacts_list_h list = NULL;
            -error_code = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
            -if (error_code != CONTACTS_ERROR_NONE)
            -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts db get all records failed: %x", error_code);
            +contacts_record_destroy(log, true);
             
          3. -
          4. To iterate the list and read the records, you can get the records from the list using the contacts_list_get_current_record_p(), contacts_list_next(), or contacts_list_prev() function. Get the details of each record in the loop. +
          + +

          Retrieving Logs

          - - - - - - - - - -
          Note
          Some functions have the _p postfix. It means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
          +

          To retrieve a single log entry:

          +
            +
          1. +

            Retrieve a log record using the contacts_db_get_record() function with the log ID as the second parameter:

            -contacts_record_h record;
            -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
            -{
            -   int type;
            -   error_code = contacts_record_get_int(record, _contacts_phone_log.log_type, &type);
            -   dlog_print(DLOG_DEBUG, LOG_TAG, "log type: %d", type);
            +contacts_record_h log;
            +int log_id = ...; /* Get the log ID */
            +int error_code;
             
            -   error_code = contacts_list_next(list);
            -   if (error_code != CONTACTS_ERROR_NONE)
            -      break;
            -}
            +error_code = contacts_db_get_record(_contacts_phone_log._uri, log_id, &log);
            +if (error_code != CONTACTS_ERROR_NONE)
            +    dlog_print(DLOG_ERROR, LOG_TAG, "get log failed: %x", error_code);
             
            +
          2. -

            To get more details of each record, use the contacts_gl_log_data_t structure:

            - +
          3. +

            When no longer needed, destroy the log handle and release all its resources using the contacts_record_destroy() function:

            -contacts_gl_log_data_t *gl_log_data = NULL;
            -contacts_record_h record;
            -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
            -{
            -   gl_log_data = _create_gl_log_data(record);
            -
            -   _free_gl_log_data(gl_log_data);
            -   error_code = contacts_list_next(list);
            -   if (error_code != CONTACTS_ERROR_NONE)
            -      break;
            -}
            +contacts_record_destroy(log, true);
             
            +
          4. -

            The memory for the record data is allocated, and the data is copied from the record by the functions listed further on in this tutorial.

            +
          -
          -typedef struct
          -_contacts_gl_log_data
          -{
          -   int id;
          -   char *address;
          -   int log_type;
          -   int log_time;
          -} contacts_gl_log_data_t;
          +

          To retrieve multiple log entries:

          -static void -_free_gl_log_data(contacts_gl_log_data_t *gl_log_data) -{ -   if (NULL == gl_log_data) -      return; +
            -   free(gl_log_data->address); -   free(gl_log_data); -} +
          1. +

            Retrieve a list of all logs, or retrieve a filtered list of logs:

            +
              +
            • +

              To retrieve a list of all logs, use the contacts_db_get_all_records() function:

              +
              +contacts_list_h list = NULL;
               
              -static contacts_gl_log_data_t*
              -_create_gl_log_data(contacts_record_h record)
              -{
              -   contacts_gl_log_data_t *gl_log_data;
              -   int error_code;
              -
              -   gl_log_data = malloc(sizeof(contacts_gl_log_data_t));
              -   memset(gl_log_data, 0x0, sizeof(contacts_gl_log_data_t));
              -
              -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_phone_log.id, &gl_log_data->id))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed ");
              -      _free_gl_log_data(gl_log_data);
              -
              -      return NULL;
              -   }
              -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_phone_log.address, &gl_log_data->address))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed ");
              -      _free_gl_log_data(gl_log_data);
              -
              -      return NULL;
              -   }
              -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_phone_log.log_type, &gl_log_data->log_type))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed ");
              -      _free_gl_log_data(gl_log_data);
              -
              -      return NULL;
              -   }
              -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_phone_log.log_time, &gl_log_data->log_time))
              -   {
              -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed ");
              -      _free_gl_log_data(gl_log_data);
              -
              -      return NULL;
              -   }
              -
              -   return gl_log_data;
              -}
              +error_code = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
              +if (error_code != CONTACTS_ERROR_NONE)
              +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_db_get_all_records failed: %x", error_code);
               
              -
            • -
            • After getting the log record, destroy the used structures: -
              -contacts_list_destroy(list, true);
              -
            • -
          -
        4. -
        5. Get the filtered log record list: -
            -
          1. Use the contacts_db_get_records_with_query() function. -
              -
            1. Create a record list and query: +
            2. +
            3. +

              To retrieve a filtered list of logs:

              +
                +
              1. +

                Define a list handle variable, and create a query handle using the contacts_query_create() function:

                 contacts_list_h list = NULL;
                 contacts_query_h query = NULL;
                 
                 error_code = contacts_query_create(_contacts_phone_log._uri, &query);
                 if (error_code != CONTACTS_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts query create failed: %x", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_query_create failed: %x", error_code);
                 
                -
              2. - -
              3. Before getting the logs, filter the list. There is a possibility to filter based on various parameters. To create a filter: -
                +
              4. +
              5. +

                Create a filter handle using the contacts_filter_create() function:

                +
                 contacts_filter_h filter = NULL;
                 
                 error_code = contacts_filter_create(_contacts_phone_log._uri, &filter);
                 if (error_code != CONTACTS_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts filter create failed: %x", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_filter_create failed: %x", error_code);
                 
                -
              6. - -
              7. Add a condition, such as the log type. -

                The following example retrieves only those logs which type is CONTACTS_PLOG_TYPE_VOICE_INCOMING.

                -
                -error_code = contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMING);
                +
              8. +
              9. +

                Add a filtering condition using a contacts_filter_add_XXX() function.

                +

                The following example adds an integer-based filtering condition that retrieves any log whose type is CONTACTS_PLOG_TYPE_VOICE_INCOMING:

                +
                +error_code = contacts_filter_add_int(filter, _contacts_phone_log.log_type,
                +                                     CONTACTS_MATCH_EQUAL,
                +                                     CONTACTS_PLOG_TYPE_VOICE_INCOMING);
                 if (error_code != CONTACTS_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts filter add integer failed: %x", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x", error_code);
                 
                - -

                To use multiple conditions, add an operator between them:

                -
                +
              10. +
              11. +

                To add more conditions, define an operator between the conditions.

                +

                The following example first adds an OR operator and then an integer-based filtering condition that retrieves any log whose type is CONTACTS_PLOG_TYPE_VOICE_OUTGOING.

                +

                The combination of the OR operator and the 2 conditions means that the filter only retrieves logs whose type is CONTACTS_PLOG_TYPE_VOICE_INCOMMING or CONTACTS_PLOG_TYPE_VOICE_OUTGOING.

                +
                 error_code = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR);
                 if (error_code != CONTACTS_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts filter add operator failed: %x", error_code);
                -error_code = contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_OUTGOING);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_filter_add_operator failed: %x", error_code);
                +
                +error_code = contacts_filter_add_int(filter, _contacts_phone_log.log_type,
                +                                     CONTACTS_MATCH_EQUAL,
                +                                     CONTACTS_PLOG_TYPE_VOICE_OUTGOING);
                 if (error_code != CONTACTS_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts filter add integer failed: %x", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "filter add condition failed: %x", error_code);
                 
                -
              12. - -
              13. Connect the query with the list: -
                +
              14. +
              15. +

                Set the filter to the query using the contacts_query_set_filter() function:

                +
                 error_code = contacts_query_set_filter(query, filter);
                 if (error_code != CONTACTS_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts query set filter failed: %x", error_code);
                -
                +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_query_set_filter failed: %x", error_code);
                +
                +
              16. +
              17. +

                Retrieve the filtered list of logs using the contacts_db_get_records_with_query() function:

                +
                 error_code = contacts_db_get_records_with_query(query, 0, 0, &list);
                 if (error_code != CONTACTS_ERROR_NONE)
                -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts db get records with query failed: %x", error_code);
                +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_db_get_records_with_query failed: %x", error_code);
                 
                -

                The third parameter refers to the limit of the results. If 0 is passed, there are no limits. After all operations, release the list.

                -
              18. - -
              19. Free the filter and query: -
                +

                The third parameter defines a limit for the number of results. If you set it to 0, the list returns all logs matching the query.

                +
              20. +
              21. +

                When no longer needed, destroy the filter and query handles and release all their resources using the contacts_filter_destroy() and contacts_query_destroy() functions:

                +
                 contacts_filter_destroy(filter);
                 contacts_query_destroy(query);
                 
                -
              22. +
            4. + + -
            5. To iterate the list and read the records, use the contacts_list_get_current_record_p(), contacts_list_next(), or contacts_list_prev() function. Get the details of each record in the loop. - - - - - - - - - - - -
              Note
              Some functions have the _p postfix. It means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
              - +
            6. +

              Iterate through the list of found logs, and retrieve log details:

              +
                +
              1. +

                Use a loop to iterate through the list and retrieve the log details.

                +

                Move forward and backward within the list using the contacts_list_next() and contacts_list_prev() functions, and retrieve the current log using the contacts_list_get_current_record_p() function.

                + + + + + + + + + +
                Note
                Some functions have the _p postfix. The postfix means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
                +

                The following example iterates through the list and retrieves the type of each log:

                 contacts_record_h record;
                -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
                -{
                -   int type;
                -   error_code = contacts_record_get_int(record, _contacts_phone_log.log_type, &type);
                -   dlog_print(DLOG_DEBUG, LOG_TAG, "log type: %d", type);
                -
                -   error_code = contacts_list_next(list);
                -   if (error_code != CONTACTS_ERROR_NONE)
                -      break;
                +while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) {
                +    int type;
                +    error_code = contacts_record_get_int(record, _contacts_phone_log.log_type, &type);
                +    dlog_print(DLOG_DEBUG, LOG_TAG, "log type: %d", type);
                +
                +    error_code = contacts_list_next(list);
                +    if (error_code != CONTACTS_ERROR_NONE)
                +        break;
                 }
                 
                - -

                To get more details of each record, use the contacts_gl_log_data_t structure:

                +
              2. +
              3. +

                Optionally, retrieve more details of each log using the contacts_gl_log_data_t structure:

                 contacts_gl_log_data_t *gl_log_data = NULL;
                 contacts_record_h record;
                -while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)
                -{
                -   gl_log_data = _create_gl_log_data(record);
                +while (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) {
                +    gl_log_data = _create_gl_log_data(record);
                 
                -   _free_gl_log_data(gl_log_data);
                -   error_code = contacts_list_next(list);
                -   if (error_code != CONTACTS_ERROR_NONE)
                -      break;
                +    _free_gl_log_data(gl_log_data);
                +    error_code = contacts_list_next(list);
                +    if (error_code != CONTACTS_ERROR_NONE)
                +        break;
                 }
                 
                -

                The memory for the record data is allocated, and the data is copied from the record by the functions listed further on in this tutorial.

                +

                Define the contacts_gl_log_data_t structure and the functions for using the structure:

                -typedef struct
                -_contacts_gl_log_data
                -{
                -   int id;
                -   char *address;
                -   int log_type;
                -   int log_time;
                -} contacts_gl_log_data_t;
                +struct _contacts_gl_log_data {
                +    int id;
                +    char *address;
                +    int log_type;
                +    int log_time;
                +};
                +typedef struct _contacts_gl_log_data contacts_gl_log_data_t;
                 
                +/* Release the resources allocated to the structure */
                 static void
                 _free_gl_log_data(contacts_gl_log_data_t *gl_log_data)
                 {
                -   if (NULL == gl_log_data)
                -      return;
                +    if (NULL == gl_log_data)
                +        return;
                 
                -   free(gl_log_data->address);
                -   free(gl_log_data);
                +    free(gl_log_data->address);
                +    free(gl_log_data);
                 }
                 
                +/* Create the structure for a log */
                 static contacts_gl_log_data_t*
                 _create_gl_log_data(contacts_record_h record)
                 {
                -   contacts_gl_log_data_t *gl_log_data;
                -   int error_code;
                -
                -   gl_log_data = malloc(sizeof(contacts_gl_log_data_t));
                -   memset(gl_log_data, 0x0, sizeof(contacts_gl_log_data_t));
                -
                -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_phone_log.id, &gl_log_data->id))
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed ");
                -      _free_gl_log_data(gl_log_data);
                -
                -      return NULL;
                -   }
                -   if (CONTACTS_ERROR_NONE != contacts_record_get_str(record, _contacts_phone_log.address, &gl_log_data->address))
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get string failed ");
                -      _free_gl_log_data(gl_log_data);
                -
                -      return NULL;
                -   }
                -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_phone_log.log_type, &gl_log_data->log_type))
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed ");
                -      _free_gl_log_data(gl_log_data);
                -
                -      return NULL;
                -   }
                -   if (CONTACTS_ERROR_NONE != contacts_record_get_int(record, _contacts_phone_log.log_time, &gl_log_data->log_time))
                -   {
                -      dlog_print(DLOG_ERROR, LOG_TAG, "contacts record get integer failed ");
                -      _free_gl_log_data(gl_log_data);
                -
                -      return NULL;
                -   }
                -
                -   return gl_log_data;
                +    contacts_gl_log_data_t *gl_log_data;
                +    int error_code;
                +
                +    gl_log_data = malloc(sizeof(contacts_gl_log_data_t));
                +    memset(gl_log_data, 0x0, sizeof(contacts_gl_log_data_t));
                +
                +    if (CONTACTS_ERROR_NONE != contacts_record_get_int(record,
                +                                                       _contacts_phone_log.id,
                +                                                       &gl_log_data->id)) {
                +        dlog_print(DLOG_ERROR, LOG_TAG, "get log ID failed ");
                +        _free_gl_log_data(gl_log_data);
                +
                +        return NULL;
                +    }
                +    if (CONTACTS_ERROR_NONE != contacts_record_get_str(record,
                +                                                       _contacts_phone_log.address,
                +                                                       &gl_log_data->address)) {
                +        dlog_print(DLOG_ERROR, LOG_TAG, "get log address failed ");
                +        _free_gl_log_data(gl_log_data);
                +
                +        return NULL;
                +    }
                +    if (CONTACTS_ERROR_NONE != contacts_record_get_int(record,
                +                                                       _contacts_phone_log.log_type,
                +                                                       &gl_log_data->log_type)) {
                +        dlog_print(DLOG_ERROR, LOG_TAG, "get log type failed ");
                +        _free_gl_log_data(gl_log_data);
                +
                +        return NULL;
                +    }
                +    if (CONTACTS_ERROR_NONE != contacts_record_get_int(record,
                +                                                       _contacts_phone_log.log_time,
                +                                                       &gl_log_data->log_time)) {
                +        dlog_print(DLOG_ERROR, LOG_TAG, "get log time failed ");
                +        _free_gl_log_data(gl_log_data);
                +
                +        return NULL;
                +    }
                +
                +    return gl_log_data;
                 }
                 
              4. -
              5. After getting the log record, destroy the used structures. +
              +
            7. + +
            8. +

              When no longer needed, destroy the list handle and release all its resources using the contacts_list_destroy() function:

              -contacts_list_destroy(list, true);
            9. -
          +contacts_list_destroy(list, true); + +
        6. + +
        -

        Deleting a Log

        +

        Deleting a Log

        + +

        To delete a log entry, use the contacts_db_delete_record() function with the log ID as the second parameter:

        -

        To delete a log, use the contacts_db_delete_record() function with _contacts_phone_log._uri as the first parameter and log ID as the second one:

        -int log_id = ... // Acquire log ID
        +int log_id = ...; /* Get the log ID */
         
         error_code = contacts_db_delete_record(_contacts_phone_log._uri, log_id);
         if (error_code != CONTACTS_ERROR_NONE)
        -   dlog_print(DLOG_ERROR, LOG_TAG, "contacts db delete record failed: %x", error_code);
        +    dlog_print(DLOG_ERROR, LOG_TAG, "contacts_db_delete_record failed: %x", error_code);
         
        -

        Inserting New Records

        - -

        To insert a new record:

        - -
          -
        1. Create a record. +

          Creating a Record

          -

          The basic concept in the Contacts API is a record. A record can be a complex set of data, containing other data. For example, an address record can contain the country, region, and street. Also, the contained data can be a reference to another record. For example, a contact record contains the address property, which is a reference to an address record. Effectively, a record can be a node in a tree or a graph of relations between records.

          +

          The basic concept in the Contacts API is a record. A record can be a complex set of data, containing other data. For example, an address record can contain data about the country, region, and street. Also, the contained data can be a reference to another record. For example, a contact record contains the address property, which is a reference to an address record. A record can therefore be a node in a tree of relations between records.

          Each record type has a special view structure, which contains identifiers of its properties. For example, the _contacts_contact view describes the properties of the contact record. It contains properties, such as the name, company, and nickname of the contact. A special property in such structures is the URI, which is used to identify the record type. Every view describing a record has this property.

          -

          To create a new contact record, create a root record of the _contacts_contact view type:

          +

          To insert a new record into the contact database:

          +
            + +
          1. +

            Create a new record.

            +

            For example, to create a new contact record, create a record using the _contacts_contact view:

             contacts_record_h hcontact = NULL;
             
             error_code = contacts_record_create(_contacts_contact._uri, &hcontact);
             
            - -

            Creating a group is similar to creating a record. The only difference is using another view – the group view.

            +

            Creating another type of record, such as a group or speed dial, is similar to creating a record. The only difference is using another view, for example, _contacts_group for a group or _contacts_speeddial for a speed dial.

          2. -
          3. Set the properties of the newly created record. Almost every property in the contact view is a record itself, so create more records, as needed. The following example shows how to add an address record to a contact. - +
          4. +

            Set the record properties.

            +

            Most properties in the contact view are separate records, so create more records, as needed. For example, to set the address for the contact:

              -
            1. Create a new record. -

              Use the address view because the added record is an address:

              - +
            2. +

              Create a new address record using the _contacts_address view:

               contacts_record_h haddress = NULL;
              -contacts_record_create(_contacts_address._uri, &haddress);
              +
              +error_code = contacts_record_create(_contacts_address._uri, &haddress);
               
            3. - -
            4. Set the address record properties (parameters available in the current view): - +
            5. +

              Set the address record properties.

              +

              The following example sets the country of the address:

              -contacts_record_set_str(haddress, _contacts_address.country, "Korea");
              +error_code = contacts_record_set_str(haddress, _contacts_address.country, "Korea");
               
            6. - -
            7. Add the address record to your contact: - +
            8. +

              Add the address record as a child record to the contact record:

              -contacts_record_add_child_record(hcontact, _contacts_contact.address, haddress
              +error_code = contacts_record_add_child_record(hcontact, _contacts_contact.address, haddress);
               
              -

              Do not destroy the record handle which is added to another as a child.

              -
            + + + + + + + + + +
            Note
            Do not destroy the child record handle.
            +
          5. +
        2. -
        3. After setting properties, insert the root record only to the database. You receive the ID of this record in the database. - +
        4. +

          Insert the record into the contact database. You receive the ID of the record in the database.

           int id;
          +
           error_code = contacts_db_insert_record(hcontact, &id);
           
          + + + + + + + + + +
          Note
          Do not manually insert any of the child records into the database. The system inserts the child records automatically along with the parent record.
        5. -
        6. Clean up and destroy the record structure: - +
        7. +

          When no longer needed, destroy the record handle and release all its resources:

           error_code = contacts_record_destroy(hcontact, true);
           
        -

        Getting Record Details

        +

        Retrieving Record Details

        -

        To find all records and get their details:

        +

        Before you can retrieve details (properties) from a record, you must first retrieve the record. You must know the ID of the record you want to retrieve.

        -
          -
        1. Get a record handle of a single record when you know its ID: +

          To retrieve a record, retrieve a handle for it with the record ID:

           contacts_record_h record;
          @@ -2253,301 +2491,319 @@ const int ID = 2;
           
           contacts_db_get_record(_contacts_contact._uri, ID, &record);
           
          -
        2. -
        3. Get record details with the contacts_record_get_*() function with the record handle. The following example gets the contact display name. +

          To retrieve the record details:

          + +
            +
          • +

            Retrieve direct record details.

            +

            To retrieve details directly from the record, use a contacts_record_get_XXX() function. The specific function depends on the data type of the detail (property) you want to retrieve.

            +

            The following example uses the contacts_record_get_str() function to retrieve a contact's display name, which is a string value:

            -char * d_name;
            +char *d_name;
             contacts_record_get_str(record, _contacts_contact.display_name, d_name);
             free(d_name);
             
          • -
          • Get child record details. -

            When using 1 view, you sometimes need details from another view. For example, you get records using the contact view and need to get the first or last name. If you want to get the name, get the record from the name view using the contacts_db_get_child_record_at_p() function.

            +
          • +

            Retrieve child record details.

            +

            When working with a record from one view, you sometimes need details from its child record from another view. To retrieve details from a child record, use the contacts_record_get_child_record_at_p() function.

            +

            The following example first retrieves a name record associated as a child record of a contact record, and then retrieves the first name from the name record:

             contacts_record_h child_record;
             contacts_record_get_child_record_at_p(record, _contacts_contact.name, 0, &child_record);
            -// In the child_record, you have the record form name view
            +
            +/* From the child record, retrieve the first name using the name view */
             char *f_name = NULL;
             contacts_record_get_str(child_record, _contacts_name.first_name, &f_name);
             free(f_name);
             
          • -
          • Get parent record details. -

            When using the child view, you sometimes need to get details of the parent. For example, you get records using the name view and want to know whether the contact has an email address. To get the parent details, get its ID in almost every view with contact_id. After that, get the parent record.

            - +
          • +

            Retrieve parent record details.

            +

            When working with a child record from one view, you sometimes need details from its parent record from another view. To access the parent record, first determine its ID, and then retrieve the parent record.

            +

            The following example first retrieves the parent contact record ID for a name record using the contact_id property, then retrieves the contact record, and finally checks whether the contact has an email address:

             contacts_record_h parent_record;
             int parent_id;
             contacts_record_get_int(record, _contacts_name.contact_id, &parent_id);
             contacts_db_get_record(_contacts_contact._uri, parent_id, &parent_record);
            -// In the parent_record, get bool
            +
            +/* From the parent record, check the boolean has_email property */
             bool h_email;
             contacts_record_get_bool(parent_record, _contacts_contact.has_email, &h_email);
             
          • -
          • Get details through a structure: -
            1. For more record details, use a structure to get them.

              -

              The memory for the record data is allocated and the data is copied from the record by functions listed in the following step.

              - +
            2. +

              Retrieve more record details using a structure:

              +
                +
              1. +

                Create the structure.

                +

                The following example defines the contact_gl_data_t structure for contacts and implements the create function for the structure:

                 gldata = _create_gl_data(record);
                -char * number = gldata->number;
                -
                -typedef struct
                -_contact_gl_data
                -{
                -   int id;
                -   char *first;
                -   char *last;
                -   char *number;
                -   char *image_path;
                -} contact_gl_data_t;
                -
                +char *number = gldata->number;
                +
                +/* Define the structure */
                +struct _contact_gl_data {
                +    int id;
                +    char *first;
                +    char *last;
                +    char *number;
                +    char *image_path;
                +};
                +typedef struct _contact_gl_data contact_gl_data_t;
                +
                +/* Create the structure */
                 static contact_gl_data_t*
                 _create_gl_data(contacts_record_h r_contact)
                 {
                -   contact_gl_data_t *data;
                -   data = malloc(sizeof(contact_gl_data_t));
                -   memset(data, 0x0, sizeof(contact_gl_data_t));
                -
                -   if (! _get_contact_id(r_contact, &data->id))
                -   {
                -      free(data);
                -
                -      return NULL;
                -   }
                -
                -   if (!_get_contact_number(r_contact, &data->number))
                -   {
                -      free(data);
                -
                -      return NULL;
                -   }
                -   if (!_get_contact_first(r_contact, &data->first))
                -   {
                -      free(data->number);
                -      free(data);
                -
                -      return NULL;
                -   }
                -   if (!_get_contact_last(r_contact, &data->last))
                -   {
                -      free(data->number);
                -      free(data->first);
                -      free(data);
                -
                -      return NULL;
                -   }
                -   if (!_get_contact_image(r_contact, &data->image_path))
                -   {
                -      free(data->number);
                -      free(data->first);
                -      free(data->last);
                -      free(data);
                -
                -      return NULL;
                -   }
                -
                -   return data;
                -}
                -
                -
              2. +    contact_gl_data_t *data; +    data = malloc(sizeof(contact_gl_data_t)); +    memset(data, 0x0, sizeof(contact_gl_data_t)); -
              3. Retrieve record data into the structure. -

                Contacts are organized in a parent-child structure. To access specified data from a record, get the child responsible for the requested type using the contacts_record_get_child_record_at_p() function. For the property lists, see View/Property. Do not pass any data returned by a function with the _p suffix to the free() function.

                +    if (! _get_contact_id(r_contact, &data->id)) { +        free(data); -
                • To get the name details, get the _contacts_contact.name (representing the child) from the r_contact parent. Both structures have the contacts_record_h type. After obtaining a child record, get the desired data from it using the contacts_record_get_str() function.

                  +        return NULL; +    } -
                  -static bool
                  -_get_contact_last(contacts_record_h r_contact, char **last)
                  -{
                  -   contacts_record_h r_name;
                  -   int error_code;
                  +    if (!_get_contact_number(r_contact, &data->number)) {
                  +        free(data);
                   
                  -   error_code = contacts_record_get_child_record_at_p(r_contact,  _contacts_contact.name, 0, &r_name);
                  +        return NULL;
                  +    }
                  +    if (!_get_contact_first(r_contact, &data->first)) {
                  +        free(data->number);
                  +        free(data);
                   
                  -   error_code = contacts_record_get_str(r_name, _contacts_name.last, last);
                  -}
                  -
                • +        return NULL; +    } +    if (!_get_contact_last(r_contact, &data->last)) { +        free(data->number); +        free(data->first); +        free(data); + +        return NULL; +    } +    if (!_get_contact_image(r_contact, &data->image_path)) { +        free(data->number); +        free(data->first); +        free(data->last); +        free(data); -
                • Obtain the record ID directly from the parent record. An ID is a unique number representing the record key in the database. You can manipulate a record with functions, such as contacts_db_get_record() or contacts_db_delete_records(), if you know their ID.

                  +        return NULL; +    } +    return data; +} + +
                • +
                • +

                  Retrieve record data into the structure.

                  +

                  Contacts, for example, are organized in a parent-child structure, where the contact record is the parent. To retrieve specific data from a contact record:

                  +
                    +
                  • +

                    If the data is stored directly in the contact record, access the correct property using the appropriate contacts_record_get_XXX() function.

                    +
                  • +
                  • +

                    If the data is stored in a child record, retrieve the child record responsible for the data type using the contacts_record_get_child_record_at_p() function, and then access the correct property in the child record using the appropriate contacts_record_get_XXX() function.

                    +
                  • +
                  +

                  For a list of properties by view, see View/Property (in mobile and wearable applications).

                  + + + + + + + + + +
                  Note
                  Do not pass any data returned by a function with the _p suffix to the free() function.
                  +

                  To retrieve contact details into the contact_gl_data_t structure:

                  +
                    +
                  • +

                    To retrieve the ID of the contact record, use the contacts_record_get_int() function on the contact record with the _contacts_contact.id property.

                    +

                    The ID is a unique number representing the record key in the contact database. If you know the ID of a record, you can access and manipulate the record with different functions, such as contacts_db_get_record() or contacts_db_delete_record().

                     static bool
                     _get_contact_id(contacts_record_h r_contact, int *id)
                     {
                    -   int error_code;
                    +    int error_code;
                     
                    -   error_code = contacts_record_get_int(r_contact, _contacts_contact.id, id);
                    +    error_code = contacts_record_get_int(r_contact, _contacts_contact.id, id);
                     
                    -   return true;
                    +    return true;
                     }
                    -
                  • - -
                  • To get a contact number, check whether it exists using the contacts_record_get_bool() function. If it exists, use the various Query and Filter functions from the Contacts API to make a query to get a list. At the end, free any data returned by a function not containing the _p suffix.

                    -
                    • Get a list of all numbers and filter the list to get the default: + +
                    • +
                    • +

                      To retrieve the contact's phone number, first check whether the contact has at least 1 phone number using the contacts_record_get_bool() function on the contact record with the _contacts_contact.has_phonenumber property. If the contact has 1 or more phone numbers, retrieve the numbers using the various Query (in mobile and wearable applications) and Filter (in mobile and wearable applications) functions from the Contacts API. The numbers are stored in the number child records (the _contacts_number view). After you are done, free any data returned by a function not containing the _p suffix.

                      +

                      The following example checks whether the contact has any phone numbers. Then, it queries all phone numbers and filters the search so that only the numbers that are default numbers and belong to the specific contact are included in the search result.

                       static bool
                       _get_contact_number(contacts_record_h r_contact, char **number)
                       {
                      -   int id;
                      -   int error_code;
                      -   contacts_record_h r_number;
                      -   contacts_query_h query = NULL;
                      -   contacts_filter_h filter = NULL;
                      -   contacts_list_h list = NULL;
                      +    int id;
                      +    int error_code;
                      +    contacts_record_h r_number;
                      +    contacts_query_h query = NULL;
                      +    contacts_filter_h filter = NULL;
                      +    contacts_list_h list = NULL;
                       
                      -   if (!_get_contact_id(r_contact, &id))
                      -      return false;
                      +    if (!_get_contact_id(r_contact, &id))
                      +        return false;
                       
                      -   bool has_number;
                      -   error_code = contacts_record_get_bool(r_contact, _contacts_contact.has_phonenumber, &has_number);
                      +    bool has_number;
                      +    error_code = contacts_record_get_bool(r_contact, _contacts_contact.has_phonenumber, &has_number);
                       
                      -   error_code = contacts_query_create(_contacts_number._uri, &query);
                      +    error_code = contacts_query_create(_contacts_number._uri, &query);
                       
                      -   unsigned int fields[] = {_contacts_number.number};
                      -   error_code = contacts_query_set_projection(query, fields, 1);
                      +    unsigned int fields[] = {_contacts_number.number};
                      +    error_code = contacts_query_set_projection(query, fields, 1);
                       
                      -   error_code = contacts_filter_create(_contacts_number._uri, &filter);
                      +    error_code = contacts_filter_create(_contacts_number._uri, &filter);
                       
                      -   error_code = contacts_filter_add_int(filter, _contacts_number.contact_id, CONTACTS_MATCH_EXACTLY, id);
                      +    error_code = contacts_filter_add_int(filter, _contacts_number.contact_id,
                      +                                         CONTACTS_MATCH_EXACTLY, id);
                       
                      -   error_code = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
                      +    error_code = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
                       
                      -   error_code = contacts_filter_add_bool(filter, _contacts_number.is_default, true);
                      +    error_code = contacts_filter_add_bool(filter, _contacts_number.is_default, true);
                       
                      -   error_code = contacts_query_set_filter(query, filter);
                      +    error_code = contacts_query_set_filter(query, filter);
                       
                      -   error_code = contacts_db_get_records_with_query(query, 0, 1, &list);
                      +    error_code = contacts_db_get_records_with_query(query, 0, 1, &list);
                       
                      -   error_code = contacts_list_get_current_record_p(list, &r_number);
                      +    error_code = contacts_list_get_current_record_p(list, &r_number);
                       
                      -   error_code = contacts_record_get_str(r_number, _contacts_number.number, number);
                      +    error_code = contacts_record_get_str(r_number, _contacts_number.number, number);
                       
                      -   contacts_query_destroy(query);
                      -   contacts_filter_destroy(filter);
                      -   contacts_list_destroy(list, true);
                      +    contacts_query_destroy(query);
                      +    contacts_filter_destroy(filter);
                      +    contacts_list_destroy(list, true);
                       }
                      -
                    • - -
                    • Directly access the default number:

                      - + +

                      The following alternative example retrieves the contact's default phone number directly:

                       static bool
                       _get_contact_number(contacts_record_h r_contact, char **number)
                       {
                      -   int error_code;
                      -   contacts_record_h r_number;
                      -
                      -   bool has_number;
                      -   error_code = contacts_record_get_bool(r_contact, _contacts_contact.has_phonenumber, &has_number);
                      -
                      -   if (!has_number)
                      -   {
                      -      *number = NULL;
                      -
                      -      return true;
                      -   }
                      -   int i;
                      -   unsigned int count = 0;
                      -   bool is_default = false;
                      -   error_code = contacts_record_get_child_record_count(contact, _contacts_contact.number, &count);
                      -
                      -   for (i = 0; i < count; i++)
                      -   {
                      -      error_code = contacts_record_get_child_record_at_p(r_contact, _contacts_contact.number, i, &r_number);
                      -      error_code = contacts_record_get_bool(r_number, _contacts_number.is_default, &is_default);
                      -      if(is_default)
                      -      {
                      -         error_code = contacts_record_get_str(r_number, _contacts_number.number, number);
                      -         return true;
                      -      }
                      -   }
                      -   *number = NULL;
                      -
                      -   return false;
                      -}
                      -
                      -

                      To get a second number, change the third parameter (contacts_record_get_child_record_at_p) from 0 to 1.

                  • - - -
                  • Obtain an image directly from the parent record:

                    +    int error_code; +    contacts_record_h r_number; -
                    -static bool
                    -_get_contact_image(contacts_record_h r_contact, char **image_path)
                    -{
                    -   int error_code;
                    +    bool has_number;
                    +    error_code = contacts_record_get_bool(r_contact, _contacts_contact.has_phonenumber, &has_number);
                     
                    -   error_code = contacts_record_get_str(r_contact, _contacts_contact.image_thumbnail_path, image_path);
                    +    if (!has_number) {
                    +        *number = NULL;
                     
                    -   dlog_print(DLOG_ERROR, LOG_TAG, "Thumb path: \'%s\'", *image_path);
                    +        return true;
                    +    }
                     
                    -   return true;
                    -}
                    -
                  • +    int i; +    unsigned int count = 0; +    bool is_default = false; +    error_code = contacts_record_get_child_record_count(contact, _contacts_contact.number, &count); + +    for (i = 0; i < count; i++) { +        error_code = contacts_record_get_child_record_at_p(r_contact, _contacts_contact.number, i, &r_number); +        error_code = contacts_record_get_bool(r_number, _contacts_number.is_default, &is_default); +        if (is_default) { +            error_code = contacts_record_get_str(r_number, _contacts_number.number, number); -
                  • Get the first name as the last name:

                    +            return true; +        } +    } +    *number = NULL; +    return false; +} + +

                    To retrieve a second number, change the third parameter of the contacts_record_get_child_record_at_p() function from 0 to 1.

                    +
                  • +
                  • +

                    To retrieve the contact's name details, retrieve the name child record of the contact record using the contacts_record_get_child_record_at_p() function with the _contacts_contact.name property. From the child record, retrieve the name data using the contacts_record_get_str() function.

                    +

                    The following example retrieves the contact's first name from the name record:

                     static bool
                     _get_contact_first(contacts_record_h r_contact, char **first)
                     {
                    -   contacts_record_h r_name;
                    -   int error_code;
                    +    contacts_record_h r_name;
                    +    int error_code;
                     
                    -   error_code = contacts_record_get_child_record_at_p(r_contact, _contacts_contact.name, 0, &r_name);
                    +    error_code = contacts_record_get_child_record_at_p(r_contact, _contacts_contact.name, 0, &r_name);
                     
                    -   error_code = contacts_record_get_str(r_name, _contacts_name.first, first);
                    +    error_code = contacts_record_get_str(r_name, _contacts_name.first, first);
                     }
                    -
                  -
            3. + +

              The following example retrieves the contact's last name from the name record:

              +
              +static bool
              +_get_contact_last(contacts_record_h r_contact, char **last)
              +{
              +    contacts_record_h r_name;
              +    int error_code;
               
              -
            4. Clean up. -
              1. Destroy the contacts_list_h list.

                -

                When the access to the database is no longer needed, disconnect from the service using the contact_disconnect() function.

                +    error_code = contacts_record_get_child_record_at_p(r_contact, _contacts_contact.name, 0, &r_name); +    error_code = contacts_record_get_str(r_name, _contacts_name.last, last); +} +
            5. + +
            6. +

              To retrieve the contact's image, use the contacts_record_get_str() function on the contact record with the _contacts_contact.image_thumbnail_path property:

              -error_code = contacts_list_destroy(list, true);
              +static bool
              +_get_contact_image(contacts_record_h r_contact, char **image_path)
              +{
              +    int error_code;
               
              -error_code = contacts_disconnect();
              -
            7. +    error_code = contacts_record_get_str(r_contact, _contacts_contact.image_thumbnail_path, image_path); -
            8. Destroy all other used handles as well:

              +    dlog_print(DLOG_ERROR, LOG_TAG, "Thumb path: \'%s\'", *image_path); -
              -contacts_query_destroy(query); // If query has been used
              -contacts_filter_destroy(filter); // If filter has been used
              -
            +    return true; +} + +
          • +
        + + + -

        Handling Lists

        +

        Using Record Lists

        -

        To access multiple records using lists and contact property filters, and to sort records:

        +

        To retrieve multiple records at the same time using a list:

          -
        1. Get a record list. -
          • Get all records in a result list with the contacts_db_get_all_records() function. After all operations, the list must be released with the contacts_list_destroy() function. +
          • +

            Retrieve a list of records:

            +
              +
            • +

              To retrieve a list of all records of a given type, use the contacts_db_get_all_records() function.

              +

              The following example retrieves a list of all contacts:

               contacts_list_h list = NULL;
               
               contacts_db_get_all_records(_contacts_contact._uri, 0, 0, &list);
               
            • -
            • Filter and get specific records: +
            • +

              To retrieve a filtered and sorted list of records of a given type:

                -
              1. Create a query for a list. -

                To filter or sort records, you need a record list and query:

                - +
              2. +

                Create a query using the contacts_query_create() function.

                +

                The following example creates a query for contact names:

                 contacts_list_h list = NULL;
                 contacts_query_h query = NULL;
                @@ -2555,179 +2811,201 @@ contacts_query_h query = NULL;
                 contacts_query_create(_contacts_name._uri, &query);
                 
              3. - -
              4. Create a filter for the query. -

                Before getting contacts, filter the list. It is possible to filter by various parameters, such as the name view.

                - +
              5. +

                Create a filter for the query using the contacts_filter_create() function:

                +

                The following example creates a name filter:

                 contacts_filter_h filter = NULL;
                 
                 contacts_filter_create(_contacts_name._uri, &filter);
                 
                - -

                The first parameter defines in which view to place the filter. To filter by the first and last name, use the _contacts_name filter. The first parameter of the contacts_query_create() function must be the same parameter as in the filter to be appended. For more information on views, see the View/Property tables.

              6. - -
              7. Add a condition, such as the following where only contacts beginning with "Za" are shown:

                - +

                The first parameter defines in which view to place the filter. To filter contacts by first and last name, use the _contacts_name view. The first parameter must be the same as the first parameter of the contacts_query_create() function, that is, the query and its filter must both use the same view. For more information on views, see View/Property (in mobile and wearable applications).

                +
              8. +
              9. +

                Add a filtering condition using a contacts_filter_add_XXX() function.

                +

                The following example adds a string-based filtering condition that retrieves name records where the last name starts with "Za":

                -contacts_filter_add_str(filter, _contacts_name.last_name, CONTACTS_MATCH_CONTAINS, "Za");
                +contacts_filter_add_str(filter, _contacts_name.last_name, CONTACTS_MATCH_STARTSWITH, "Za");
                 
                - -

                To receive contacts which starts by a given string, the CONTACTS_MATCH_CONTAINS parameter has to be set. Use the parameter if you need to get records which contain the given string anywhere.

              10. - -
              11. To add more conditions, add operators between them. In this case, define the operator between conditions first.

                - +

                The available matching options (third parameter) for string-based filtering conditions are defined in the contacts_match_str_flag_e enumeration (in mobile and wearable applications).

                +
              12. +
              13. +

                To add more conditions, add a logical operator before each new condition using the contacts_filter_add_operator() function. The conditions and operators together define the filtering logic as a whole.

                +

                The following example first adds an AND operator and then a string-based filtering condition that retrieves name records where the last name ends with "ra".

                +

                The combination of the AND operator and the 2 conditions means that the filter only retrieves name records where the last name starts with "Za" and ends with "ra".

                 contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
                -
                - -

                After that you can add another condition. If you need to use a logic expression "C1 AND (C2 OR C3)", conditions 2 and 3 must be in another filter to have logical brackets. The following example shows a filter that passes through contacts with a first name starting with "Ada" or "Igo".

                +contacts_filter_add_str(filter, _contacts_name.last_name, CONTACTS_MATCH_ENDSWITH, "ra"); + +
              14. +
              15. +

                If you need to use a logical expression with brackets, such as "C1 AND C2 AND (C3 OR C4)", define the bracketed conditions in a separate filter, and add the new filter to the parent filter as a filtering condition using the contacts_filter_add_filter() function.

                +

                The following example extends the previous example by first adding an AND operator and then a child filter with 2 string-based filtering conditions separated by an OR operator.

                +

                The combination of all the filtering conditions means that the parent filter only retrieves name records where (1) the last name starts with "Za" and ends with "ra" and (2) the first name starts with either "Ada" or "Igo".

                +contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
                +
                 contacts_filter_h n_filter = NULL;
                 contacts_filter_create(_contacts_name._uri, &n_filter);
                 contacts_filter_add_str(n_filter, _contacts_name.first_name, CONTACTS_MATCH_STARTSWITH, "Ada");
                 contacts_filter_add_operator(n_filter, CONTACTS_FILTER_OPERATOR_OR);
                -contacts_filter_add_str(n_filter, _contacts_name.first_name, CONTACTS_MATCH_STARTSWITH, "Igo”");
                -
              16. - -
              17. To add an extra filter to a parent filter:

                +contacts_filter_add_str(n_filter, _contacts_name.first_name, CONTACTS_MATCH_STARTSWITH, "Igo"); -
                 contacts_filter_add_filter(filter, n_filter);
                 
                - -

                The parent filter passes through contacts with a last name beginning with "Za" and a first name starting with "Ada" or "Igo".

              18. -
              19. Connect a filter with query:

                - +
              20. +
              21. +

                Set the filter to the query using the contacts_query_set_filter() function:

                 contacts_query_set_filter(query, filter);
                -
            +
          • - -
          • Sort a record list by any of its view details: - +
          • +

            Sort the query results by one of its view properties using the contacts_query_set_sort() function.

            +

            The following example sorts the contact name query by first name:

             contacts_query_set_sort(query, _contacts_name.first, true);
             
            - -

            The first parameter is the query to be filtered, the second is the property to sort, and the last sets the ascending order.

          • - -
          • Set a projection to a list. -

            A projection allows you to query the data for specific properties of a record. It can reduce latency in case of a large database.

            -

            To set the projection, use the contacts_query_set_projection() function. The following example limits the properties from the previous steps to the first and last name.

            - +
          • +

            Set a projection to the query using the contacts_query_set_projection() function.

            +

            A projection allows you to query the data for specific properties of a record. Using a projection can reduce latency in case of a large database.

            +

            The following example limits the properties from the previous steps to the first and last name:

             unsigned my_projection[] = {_contacts_name.contact_id, _contacts_name.first, _contacts_name.last}
             contacts_query_set_projection(query, my_projection, sizeof(my_projection)/sizeof(int));
             
            - -

            After filtering, such as getting numbers, there can be several records which differ only in a few detail types. When setting the projection, the results can contain identical records. To avoid these situations, use the distinction function.

            - +

            The results of a filtered query can contain records that differ only in a few properties. After setting a projection to the filtered query, the results can contain identical records. To avoid these, use the contacts_query_set_distinct() function, which removes duplicates from the results:

             contacts_query_set_distinct(query, true);
             
          • - -
          • Get the record list with a query: - +
          • +

            Retrieve the filtered list using the contacts_db_get_records_with_query() function:

             contacts_db_get_records_with_query(query, 0, 0, &list);
             
            - -

            The third parameter refers to limiting results. If 0 is passed, there are no limits. Release the list after all the operations.

            +

            The third parameter defines a limit for the number of results. If you set it to 0, the list returns all records matching the query.

            +
          • +
        + + -
      3. Iterate on the list and read the records. -

        The contacts_list_get_current_record_p() function retrieves a record from the contacts list. The current default record is the first record.

        - -

        To iterate on a list, use the contacts_list_prev(), contacts_list_next(), contacts_list_first(), and contacts_list_last() functions.

        - - - - - - - - - - -
        Note
        Some functions have the _p postfix. It means that the returned value must not be freed by the application, as it is a pointer to data in an existing record.
        - -

        To read records:

        - -
        • To get only a few details: - +
        • +

          Iterate through the list of found records, and retrieve the record details:

          +

          Use a loop to iterate through the list and retrieve the details:

          +
            +
          • +

            Move forward and backward within the list using the contacts_list_prev(), contacts_list_next(), contacts_list_first(), and contacts_list_last() functions.

            +
          • +
          • +

            Retrieve the current record using the contacts_list_get_current_record_p() function. By default, before iterating through the list, the current record is the first record.

            +
          • +
          + + + + + + + + + +
          Note
          Some functions have the _p postfix. The postfix means that the returned value must not be freed by the application, as it is a pointer to the data in an existing record.
          +

          To retrieve the record details:

          +
            +
          • +

            To retrieve only basic details, use a contacts_record_get_XXX() function on the record.

            +

            The following example use the contacts_record_get_str() function to retrieve a contact's display name:

             contacts_record_h record;
             
            -while (contacts_list_get_current_record_p(list, &record) == 0)
            -{
            -   // Get details
            -   char * disp_name;
            -   contacts_record_get_str(record, _contacts_contact.display_name, &disp_name);
            -   free(disp_name);
            -   error_code = contacts_list_next(list);
            +while (contacts_list_get_current_record_p(list, &record) == 0) {
            +    /* Get details */
            +    char *disp_name;
            +    contacts_record_get_str(record, _contacts_contact.display_name, &disp_name);
            +    free(disp_name);
            +    error_code = contacts_list_next(list);
             }
            -
          • - -
          • To get more details, use the following example, where the obtained records are passed to the _create_gl_data() function for further processing:

            - + +
          • +
          • +

            To retrieve more details, including child record details, use a structure. For more information, see Retrieving Record Details.

            +

            The following example uses the contact_gl_data_t structure to retrieve contact details:

             contacts_record_h record;
             contact_gl_data_t *gldata = NULL;
             
            -while (contacts_list_get_current_record_p(list, &record) == 0)
            -{
            -   gldata = _create_gl_data(record);
            +while (contacts_list_get_current_record_p(list, &record) == 0) {
            +    gldata = _create_gl_data(record);
             
            -   error_code = contacts_list_next(list);
            +    error_code = contacts_list_next(list);
             }
            -
          • - -
          • The previous examples work if you use the default (_contacts_contact) view. If you use filtering in another view as shown in the filter example, and you want to use this structure (change view to default), use the following code.

            - + +
          • +
          • +

            The previous examples work only if you use the _contacts_contact view, that is, if you are dealing with contact records. If you use filtering in another view, as shown in the filtering examples, and you want to use the same contact structure with those records, first retrieve the parent contact record of the current record, and then use the structure for the parent record. This is basically a way to switch to the _contacts_contact view from another view.

            +

            In the following example, the loop iterates through a list of name records. To retrieve the full details of the contact record corresponding to the current name record, the code retrieves the parent of the name record, which is a contact, and creates the contact_gl_data_t structure for the parent, retrieving its full details.

             contacts_record_h record;
             contact_gl_data_t *gldata = NULL;
             
            -while (contacts_list_get_current_record_p(list, &record) == 0)
            -{
            -   int record_id;
            -   contacts_record_h c_record;
            -   contacts_record_get_int(record, _contacts_name.contact_id, &contact_id);
            -   contacts_db_get_record(_contacts_contact._uri, contact_id, &c_record);
            -   gldata = _create_gl_data(c_record);
            +while (contacts_list_get_current_record_p(list, &record) == 0) {
            +    int record_id;
            +    contacts_record_h c_record;
            +
            +    /* Get the ID of the parent contact record */
            +    contacts_record_get_int(record, _contacts_name.contact_id, &contact_id);
            +
            +    /* Get the parent contact record */
            +    contacts_db_get_record(_contacts_contact._uri, contact_id, &c_record);
             
            -   error_code = contacts_list_next(list);
            +    /* Create the structure for the parent contact record */
            +    gldata = _create_gl_data(c_record);
            +
            +    error_code = contacts_list_next(list);
             }
             
            +
          • +
          +
        • -

          This way it is possible to switch to the default view from another view (in a similar manner to the above example _contacts_name).

        +
      4. +

        When no longer needed, destroy the filter, query, and list handles and release all their resources using the contacts_filter_destroy(), contacts_query_destroy(), and contacts_list_destroy() functions:

        +
        +contacts_filter_destroy(filter);
        +contacts_query_destroy(query);
        +contacts_list_destroy(list, true);
        +
      5. -
      6. Insert the list to the database. -

        You can insert a whole list to the database. This can be useful when you have several records to create and you want to insert them all at once.

        +
      + +

      You can insert a whole list into the contact database. This is useful when you have several records to create and want to insert them all at once.

      -
        -
      1. If you have a list, use it or create a new one: +

        To insert a list into the contact database:

        +
          + +
        1. +

          Create the list:

           contacts_list_h list;
           contacts_list_create(&list);
           
        2. -
        3. Add records to the list: - +
        4. +

          Add records to the list:

           contacts_list_add(list, record);
           
        5. -
        6. Insert the list into the database: - +
        7. +

          Insert the list into the contact database and get the IDs of the inserted records:

           int *ids = NULL;
           unsigned int count = 0;
          @@ -2735,492 +3013,504 @@ contacts_db_insert_records(list, &ids, &count);
           dlog_print(DLOG_DEBUG, LOG_TAG, "%d records inserted", count);
           free(ids);
           
          - -

          This inserts the entire list to the database and gets the IDs of the inserted records.

        8. -
        9. Destroy the list: - +
        10. +

          When no longer needed, destroy the list handle and release all its resources using the contacts_list_destroy() function:

           contacts_list_destroy(list, true);
           
        11. +
        -
      2. -
      -

      Deleting Records

      +

      Deleting a Record

      + +

      To delete a record, use the contacts_db_delete_record() function with the view URI as the first parameter and the record ID as the second parameter.

      -

      To delete records from the contacts database, you need to know their ID:

      +

      The following example deletes a contact record:

      -int id;
      -// Get the ID
      -int error = contacts_db_delete_record(_contacts_contact._uri, id);
      +int id = ...; /* Get the record ID */
      +
      +error_code = contacts_db_delete_record(_contacts_contact._uri, id);
       
      -

      If you only have the record handle, get the ID first:

      +

      If you only have the record handle, retrieve the ID first:

      -contacts_record_get_int(record, _contacts_contact.id, &id);
      +error_code = contacts_record_get_int(record, _contacts_contact.id, &id);
       
      -

      Linking Persons

      +

      Linking Persons

      -

      To link persons (a useful joining method if there are several contacts assigned to one person):

      +

      Linking one person to another is a useful method for combining contacts under a single person.

      -
        -
      1. Link a person to another person. -

        To link persons with the contacts_person_link_person() function, you need the person ID. To get the person ID, use the contacts_record_get_int() function.

        +

        To link 2 persons and manage the linked person:

        + +
          + +
        • +

          Link a person to another person using the contacts_person_link_person() function with the corresponding person IDs.

          +

          The following example first retrieves the person IDs using the contacts_record_get_int() function and then links the persons:

          -int first_person_id;
          +/* Get the ID of the first person */
           contacts_record h record1;
          -// Get the first record
          +int first_person_id;
           int error_code = contacts_record_get_int(record1, _contacts_contact.person_id, &first_person_id);
           
          +/* Get the ID of the second person */
           contacts_record h record2;
          -// Get the second record
          +int second_person_id;
           error_code = contacts_record_get_int(record2, _contacts_contact.person_id, &second_person_id);
           
          +/* Link the persons */
           contacts_person_link_person(first_person_id, second_person_id);
          -
          -

          This links the 2 contacts available through record handles.

          +int person_id = first_person_id; +
        • -
        • Set the default properties. -

          Set the default values from one of the linked contacts with the contacts_person_set_default_property() function. The first parameter determines the detail to be set using the contacts_person_property_e enum.

          - -

          To set a default number from one of the persons, you have to know its ID. Get the detail ID using the contacts_record_get_child_record_at_p() function, because you need to get the value from the _contact_number view.

          - +
        • +

          Set the default properties for the linked person.

          +

          Set the default properties from one of the associated contacts using the contacts_person_set_default_property() function. The first parameter uses the values of the contacts_person_property_e enumeration (in mobile and wearable applications), which defines the available default properties for a person.

          +

          For example, to set the person's default phone number based on the number of one of the associated contacts:

          +
            +
          1. Retrieve the contact whose phone number you want to use.

          2. +
          3. Retrieve the correct phone number record associated with the contact using the contacts_record_get_child_record_at_p() function.

          4. +
          5. Retrieve the phone number ID from the phone number record using the contacts_record_get_int() function with the _contacts_number view.

          6. +
          7. Set the phone number as the default for the person using the contacts_person_set_default_property() function.

          8. +
           contacts_record_h record;
          -int record_number = -1;
          -// Get the record handle
          +int error_code = -1;
          +
          +/* Get the contact record */
          +
          +/* Get the phone number record */
           contacts_record_h record_number;
           error_code = contacts_record_get_child_record_at_p(record, _contacts_contact.number, 0, &record_number);
           
          +/* Get the phone number ID */
          +int number_id;
           error_code = contacts_record_get_int(record_number, _contacts_number.id, &number_id);
          -
           error_code = contacts_record_destroy(record_number, true);
           
          -// Use the record_number variable
          +/* Set the phone number as the default for the person */
           error_code = contacts_person_set_default_property(CONTACTS_PERSON_PROPERTY_NUMBER, person_id, number_id);
           
        • -
        • Get default property values of a person with the contacts_person_get_default_property() function: - -
          1. Get the ID of the default email details:

            +
          2. +

            Retrieve the default properties of the linked person using the contacts_person_get_default_property() function.

            +

            For example, to retrieve the default email address:

            +
              +
            1. +

              Retrieve the ID of the default email record using the contacts_person_get_default_property() function with the CONTACTS_PERSON_PROPERTY_EMAIL property:

               int person_email_number;
              -error_code = contacts_person_get_default_property(CONTACTS_PERSON_PROPERTY_EMAIL, person_id, &person_email_number);
              -
            2. - -
            3. Get the default email:

              - +error_code = contacts_person_get_default_property(CONTACTS_PERSON_PROPERTY_EMAIL, person_id, +                                                  &person_email_number); + +
            4. +
            5. +

              Retrieve the default email record using the contacts_db_get_record() function with the email record ID:

              -int person_email_detail_number;
              -error_code = contacts_person_get_default_property(CONTACTS_PERSON_PROPERTY_EMAIL, person_id, &person_email_number);
              -
               contacts_record_h email_record;
              -error_code = contacts_db_get_record(_contacts_email._uri, person_email_detail_number, &email_record);
              -char * default_email;
              -
              +error_code = contacts_db_get_record(_contacts_email._uri, person_email_number, &email_record);
              +
              +
            6. +
            7. +

              Retrieve the email address from the email record:

              +
              +char *default_email;
               error_code = contacts_record_get_str_p(email_record, _contacts_email.email, &default_email);
               
              -// Use default_email
              +/* Use default_email */
               
               error_code = contacts_record_destroy(email_record, true);
              -
            + +
          3. +
        • -
        • Unlink persons using the contacts_person_unlink_contact() function: - -
          1. If you have the record handle, get the contact ID:

            - -
            -int person_id;
            -contacts_record_get_int(record, _contacts_contact.id, &person_id);
            -
          2. - -
          3. Unlink a contact from another and get its ID:

            - +
          4. +

            Unlink a contact from the linked person using the contacts_person_unlink_contact() function. The function removes the contact (second parameter) from the person (first parameter), creates a new person (third parameter), and links the contact to the new person.

            +int contact_id = ...; /* Get the contact ID */
             int unlinked_person_id;
            -int contacts_person_unlink_contact(person_id,
            -                                   contact_id,
            -                                   &unlinked_person_id)
            -
          + +error_code = contacts_person_unlink_contact(person_id, contact_id, &unlinked_person_id); +
        • -
      -

      Managing Contact Settings

      + + +

      Managing Contact Settings

      -

      To manage the display settings of contacts:

      +

      To manage the display and sorting order settings for contacts:

        -
      1. Check the current display order (the order in which the names are displayed) using the contacts_setting_get_name_display_order() function, and the sorting order using the contacts_setting_get_name_sorting_order() function: +
      2. +

        Check the current display order using the contacts_setting_get_name_display_order() function. The display order defines the order in which contacts (names) are displayed on the device screen.

         contacts_name_display_order_e display_order;
         contacts_setting_get_name_display_order(&display_order);
        -// Now you have the display order
        -sprintf("Display order: %s", display_order==CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST?"CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST":"CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST");
        +/* Now you have the display order */
        +sprintf("Display order: %s",
        +        display_order==CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST ?
        +        "CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST" : "CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST");
        +
        +
      3. +
      4. +

        Check the current sorting order using the contacts_setting_get_name_sorting_order() function. The sorting order defines the order in which contact records are returned.

        +
         contacts_name_sorting_order_e sorting_order;
         contacts_setting_get_name_sorting_order(&sorting_order);
        -// Now you have the sorting order
        -sprintf("Sorting order: %s", sorting_order==CONTACTS_NAME_SORTING_ORDER_FIRSTLAST?"CONTACTS_NAME_SORTING_ORDER_FIRSTLAST":"CONTACTS_NAME_SORTING_ORDER_LASTFIRST");
        +/* Now you have the sorting order */
        +sprintf("Sorting order: %s",
        +        sorting_order==CONTACTS_NAME_SORTING_ORDER_FIRSTLAST ?
        +        "CONTACTS_NAME_SORTING_ORDER_FIRSTLAST" : "CONTACTS_NAME_SORTING_ORDER_LASTFIRST");
         
      5. -
      6. Change the display and sorting orders using the contacts_setting_set_name_display_order() and contacts_setting_set_name_sorting_order() functions: - +
      7. +

        Change the display and sorting orders using the contacts_setting_set_name_display_order() and contacts_setting_set_name_sorting_order() functions. Both functions use as a parameter a value of an enumeration: contacts_name_display_order_e (in mobile and wearable applications) and contacts_name_sorting_order_e (in mobile and wearable applications) that define the available display and sorting orders.

         contacts_setting_set_name_display_order(CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST);
         
         contacts_setting_set_name_sorting_order(CONTACTS_NAME_SORTING_ORDER_FIRSTLAST);
         
        +
      8. -
      9. Track the changes in the display and sorting orders: -
        1. Register callbacks with the contacts_setting_add_name_display_order_changed_cb() and contacts_setting_add_name_sorting_order_changed_cb() functions.
        2. -
        3. Define the callbacks themselves: +
        4. +

          Receive a notification whenever the display or sorting order changes:

          +
            +
          1. Register callbacks using the contacts_setting_add_name_display_order_changed_cb() and contacts_setting_add_name_sorting_order_changed_cb() functions.

          2. +
          3. +

            Define the order change callbacks.

            +

            The following example shows how to print a message when the display or sorting order changes:

             static void
             display_changed_cb(contacts_name_display_order_e name_display_order, void *user_data)
             {
            -   dlog_print(DLOG_DEBUG, LOG_TAG, "changed display order: %s", name_display_order==CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST?"CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST":"CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST");
            +    dlog_print(DLOG_DEBUG, LOG_TAG, "changed display order: %s",
            +               name_display_order==CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST ?
            +               "CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST" : "CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST");
             }
             
             static void
             sorting_changed_cb(contacts_name_sorting_order_e name_display_order, void *user_data)
             {
            -   dlog_print(DLOG_DEBUG, LOG_TAG, "changed sorting order: %s", name_display_order==CONTACTS_NAME_SORTING_ORDER_FIRSTLAST?"CONTACTS_NAME_SORTING_ORDER_FIRSTLAST":"CONTACTS_NAME_SORTING_ORDER_LASTFIRST");
            +    dlog_print(DLOG_DEBUG, LOG_TAG, "changed sorting order: %s",
            +               name_display_order==CONTACTS_NAME_SORTING_ORDER_FIRSTLAST ?
            +               "CONTACTS_NAME_SORTING_ORDER_FIRSTLAST" : "CONTACTS_NAME_SORTING_ORDER_LASTFIRST");
             }
             
            -

            The above examples cause a message to be printed when the order changes. To track the changes, write a timeout function after setting the callback.

          4. -
          5. Unregister the callbacks when they are no longer needed using the contacts_setting_remove_name_display_order_changed_cb() and contacts_setting_remove_name_sorting_order_changed_cb() functions.
          - +

          To track the changes, implement a timeout function after setting the callbacks.

          +
        5. +
        6. When no longer needed, deregister the callbacks using the contacts_setting_remove_name_display_order_changed_cb() and contacts_setting_remove_name_sorting_order_changed_cb() functions.

        7. +
      10. +
      -

      Managing Contacts on the SIM Card

      +

      Importing Contacts from the SIM Card

      + +

      To import contacts from the SIM card:

      -

      To check whether the SIM card is initialized and then import contacts from the SIM card:

        -
      1. Before using any SIM card methods, ensure that the SIM card initialization is complete: +
      2. +

        Make sure the SIM card has been initialized:

         bool completed = false;
         contacts_sim_get_initialization_status(&completed);
        -dlog_print(DLOG_DEBUG, LOG_TAG, "SIM %s completed", completed?"":"not ");
        -
      3. - -
      4. When the contacts from the SIM card are available, import them: +dlog_print(DLOG_DEBUG, LOG_TAG, "SIM %s completed", completed ? "" : "not "); + + + + + + + + + + +
        Note
        You cannot access contacts on a SIM card that has not been initialized.
        +
      5. +
      6. +

        Import the contacts:

        -int err = contacts_sim_import_all_contacts();
        +int error_code = contacts_sim_import_all_contacts();
         
      -

      Importing from vCard

      +

      Importing from vCard

      -

      To import contacts from all vCard files from a specified directory:

      +

      Importing contacts from a vCard file involves parsing the vCard file for contacts and inserting the parsed contacts into the contact database. You have the following options for parsing a vCard file:

        -
      • Get contact records from a stream. -

        To receive a records list from the vCard stream, use the contacts_vcard_parse_to_contacts() function. Afterwards, the received list is ready to use and you can perform the iteration on the list.

        - -

        The following example uses the stream in the vCard format and gets the records from the received list.

        - -
        -char * vcard_stream;
        -// Get vCard stream
        -contacts_list_h contacts_list;
        -int err = contacts_vcard_parse_to_contacts(vcard_stream, contacts_list);
        -
        -while (contacts_list_get_current_record_p(list_import, &record) == 0)
        -{
        -   // Get next records from file
        -   err = contacts_list_next(list_import);
        -}
        -err = contacts_list_destroy(list_import, true);
        -
        - -

        You can also use the contacts_vcard_parse_to_contact_foreach() function. With this function, you have to get the file content manually, and it needs a callback.

        - -
        -bool
        -contacts_vcard_cb(contacts_record_h record, void *user_data)
        -{
        -   // Here you have a record
        -   return true;
        -}
        -
        - -

        The callback is called for each record from a vCard file. The iteration continues as long as the callback returns true.

        +
      • Parse a vCard stream of the file. This option gives you a list of all contact records in a single function call, but you must first create the vCard stream.

      • +
      • Parse the file directly. This option requires that you use a callback to handle each parsed contact record separately.

      • +
      -

      To check how many records are contained in a vCard file, use the contacts_vcard_get_entity_count() function.

      +

      To import contacts from vCard streams:

      - + + + + + + + + + +
      Note
      This use case imports contacts from every vCard file in a given directory.
      -
    3. Import the vCard stream. -
      • Get all the files with a .vcf extension from the directory. It can be done through dirent structures available in the <dirent.h> header. The following example gets the path to every file in a directory.

        +
          +
        1. +

          Retrieve the path to the source directory containing the vCard files you want to import.

          +

          The following example retrieves the path to the downloads directory of the device's internal storage:

           int internal_storage_id;
           char *vcf_path = NULL;
           
          +/* Handle the storages found on the device */
           static bool
           storage_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
           {
          -   if (type == STORAGE_TYPE_INTERNAL)
          -   {
          -      internal_storage_id = storage_id;
          -
          -      return false;
          -   }
          +    /* Check whether the storage is the device's internal storage */
          +    if (type == STORAGE_TYPE_INTERNAL) {
          +        /* Get the internal storage ID */
          +        internal_storage_id = storage_id;
           
          -   return true;
          -}
          +        /* Internal storage found, end the callback loop */
          +        return false;
          +    }
           
          -void
          -_get_storage_path()
          -{
          -   int error_code = 0;
          -   char *path = NULL;
          -
          -   error_code = storage_foreach_device_supported(storage_cb, NULL);
          -   error_code = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_DOWNLOADS, &path);
          -   if (error_code != STORAGE_ERROR_NONE)
          -   {
          -      vcf_path = strdup(path);
          -      free(path);
          -   }
          +    /* Internal storage not found, continue the callback loop */
          +    return true;
           }
           
          +/* Get the source directory path */
           void
          -_import_vcard()
          +get_storage_path()
           {
          -   int path_len = 0;
          -
          -   DIR *dir = opendir(vcf_path);
          -   struct dirent *pDirent = NULL;
          -   if (NULL == dir)
          -   {
          -      free(vcf_path);
          -
          -      return;
          -   }
          -
          -   while ((pDirent = readdir(dir)) != NULL)
          -   {
          -      if (pDirent->d_type != DT_REG)
          -         continue;
          -      char *extension = strrchr(pDirent->d_name, '.');
          -      if (!extension || strcmp(extension, ".vcf"))
          -         continue;
          -      char * filepath = malloc(strlen(vcf_path)+strlen(pDirent->d_name)+4);
          -      sprintf(filepath, "%s/%s", vcf_path, pDirent->d_name);
          -
          -      // Full path to file available through filepath string
          -
          -      free(filepath);
          -   }
          -}
          -
        2. +    int error_code = 0; +    char *path = NULL; -
        3. If you use the contacts_vcard_parse_to_contacts() function, you need to get the file stream manually. The following example shows how to get a records list from a file.

          - -
          -FILE *fp = fopen(filepath, "r");
          -fseek(fp, 0, 2);
          -int bufsize = ftell(fp);
          -rewind(fp);
          -if (bufsize < 1)
          -   return 1;
          +    /* Get the storages available on the device */
          +    /* Handle each storage in the storage_cb() callback */
          +    error_code = storage_foreach_device_supported(storage_cb, NULL);
           
          -char * vcard_stream = malloc(sizeof(char) * (bufsize));
          -memset(vcard_stream, '\0', sizeof(vcard_stream));
          -if (fp != NULL)
          -{
          -   char str[200];
          -   while(fgets(str, 200, fp) != NULL)
          -      sprintf(vcard_stream+strlen(vcard_stream), "%s", str);
          -   fclose(fp);
          +    /* Get the absolute path to the downloads directory of the device's internal storage */
          +    error_code = storage_get_directory(internal_storage_id, STORAGE_DIRECTORY_DOWNLOADS, &path);
          +    if (error_code != STORAGE_ERROR_NONE) {
          +        vcf_path = strdup(path);
          +        free(path);
          +    }
           }
          -else
          -   // Error handling
          -int err = contacts_vcard_parse_to_contacts(vcard_stream, contacts_list);
          -free(vcard_stream);
          -
        4. - -
        5. You can also use the contacts_vcard_parse_to_contact_foreach() function. It requires a callback and retrieves the file path instead of a file stream.

          + +
        6. +
        7. +

          Create a vCard stream of each vCard file in the source directory. You can do this with the dirent structure and the directory stream functions available in the <dirent.h> header file.

          +

          The following example implements a while loop that cycles through the vCard files in the source directory and creates a vCard stream of each file:

          -bool
          -contacts_vcard_cb(contacts_record_h record, void *user_data)
          -{
          -   // Here you have a record
          -   return true;
          -}
          +/* Open a directory stream for the source directory */
          +DIR *dir = opendir(vcf_path);
           
          -err = contacts_vcard_parse_to_contact_foreach (filepath, contacts_vcard_cb, NULL);
          -
        8. - -
        9. Add a record in a callback function:

          +/* Parse the directory stream for directory entries (dirent) */ +struct dirent *pDirent = NULL; -
          -int id = -1;
          -err = contacts_db_insert_record(record, &id);
          -
      +if (dir == NULL) { +    free(vcf_path); -

      The following example represents the full code of the previous step.

      +    return; +} -
      -char []folder = "/path/";
      -contacts_list_h list_import;
      -contacts_record_h record;
      -err = contacts_vcard_parse_to_contacts(content, &list_import);
      +if (dir) {
      +    while ((pDirent = readdir(dir)) != NULL) {
      +        /*
      +           If the directory entry is not a regular file,
      +           skip to the next directory entry
      +        */
      +        if (pDirent->d_type != DT_REG)
      +            continue;
       
      -while (contacts_list_get_current_record_p(list_import, &record) == 0)
      -{
      -   int id = -1;
      -   err = contacts_db_insert_record(record, &id); // Add to list
      +        /*
      +           If the file is not a vCard file,
      +           skip to the next directory entry
      +        */
      +        char *extension = strrchr(pDirent->d_name, '.');
      +        if (!extension || strcmp(extension, ".vcf"))
      +            continue;
      +        dlog_print(DLOG_DEBUG, LOG_TAG, "file %s", pDirent->d_name);
      +
      +        /* Get the vCard file path */
      +        char *file_path = malloc(strlen(vcf_path) + strlen(pDirent->d_name) + 4);
      +        sprintf(file_path, "%s/%s", vcf_path, pDirent->d_name);
      +
      +        /*
      +           If the vCard file does not contain any records,
      +           skip to the next directory entry
      +        */
      +        int count;
      +        int error_code = contacts_vcard_get_entity_count(file_path, &count);
      +        if (count < 1)
      +            continue;
       
      -   contacts_list_next(list_import);
      -}
      +        /* Calculate the vCard file size */
      +        FILE *fp = fopen(file_path, "r");
      +        if (fseek(fp, 0, 2) != 0)
      +            /* Error handling */
      +        int bufsize = ftell(fp);
      +        rewind(fp);
      +        dlog_print(DLOG_DEBUG, LOG_TAG, "file size: %i", bufsize);
      +        if (bufsize < 1)
      +            return 1;
      +
      +        /* Create the vCard stream */
      +        char *vcard_stream = malloc(sizeof(char) * (bufsize));
      +        memset(vcard_stream, '\0', sizeof(vcard_stream));
      +        if (fp != NULL) {
      +            char str[150];
      +            while (fgets(str, 150, fp) != NULL)
      +                sprintf(vcard_stream + strlen(vcard_stream), "%s", str);
      +            fclose(fp);
      +        } else {
      +            return 1;
      +        }
      +
      +
    4. -DIR *dir = opendir(folder); -struct dirent *pDirent = NULL; -if (dir) -{ -   while ((pDirent = readdir(dir)) != NULL) -   { -      if (pDirent->d_type != DT_REG) -         continue; - -      char *exte = strrchr(pDirent->d_name, '.'); -      if (!exte || strcmp(exte, ".vcf")) -         continue; -      dlog_print(DLOG_DEBUG, LOG_TAG, "file %s", pDirent->d_name); - -      char * file_path = malloc(strlen(folder)+strlen(pDirent->d_name)+4); -      sprintf(file_path, "%s/%s", folder, pDirent->d_name); -      int count; -      contacts_vcard_get_entity_count(file_path, &count); -      // Number of records in file: count -      if (count < 1) -         continue; - -      FILE * fp = fopen(file_path, "r"); -      if (fseek(fp, 0, 2) != 0) -         // Error handling -      int bufsize = ftell(fp); -      rewind(fp); -      dlog_print(DLOG_DEBUG, LOG_TAG, "file size: %i", bufsize); -      if (bufsize < 1) -         return 1; - -      char * vcard_stream = malloc(sizeof(char) * (bufsize)); -      memset(vcard_stream, '\0', sizeof(vcard_stream)); -      if (fp != NULL) -      { -         char str[150]; -         while(fgets(str, 150, fp) != NULL) -            sprintf(vcard_stream+strlen(vcard_stream), "%s", str); -         fclose(fp); -      } -      else -         return 1; - -      // Import the contacts -      contacts_list_h list_import; -      err = contacts_vcard_parse_to_contacts(vcard_stream, &list_import); -      if (err != 0) -         dlog_print(DLOG_ERROR, LOG_TAG, "contacts_vcard_parse_to_contacts failed: %d", err); -      free(vcard_stream); -      while (contacts_list_get_current_record_p(list_import, &record) == 0) -      { -         int id = -1; -         err = contacts_db_insert_record(record, &id); // Add to list -         if (err != 0) -            dlog_print(DLOG_ERROR, LOG_TAG, "contacts_list_add failed"); -         err = contacts_list_next(list_import); -      } -      err = contacts_list_destroy(list_import, true); -      if (err != 0) -      { -         dlog_print(DLOG_ERROR, LOG_TAG, "contacts_list_destroy failed: %d", err); -      } -      free (file_path); -   } -   closedir(dir); +
    5. +

      Parse the vCard streams for contacts using the contacts_vcard_parse_to_contacts() function. The function returns a list of all contact records parsed from the stream.

      +

      The following example first parses a list of contact records from the vCard stream and then iterates through the list inserting each record to the contact database:

      +
      +        contacts_list_h contacts_list;
      +        contacts_record_h record;
      +
      +        /* Get the contact list from the vCard stream */
      +        error_code = contacts_vcard_parse_to_contacts(vcard_stream, &contacts_list);
      +        if (error_code != 0)
      +            dlog_print(DLOG_ERROR, LOG_TAG, "contacts_vcard_parse_to_contacts failed: %d", error_code);
      +        free(vcard_stream);
      +
      +        /* Iterate through the contact list */
      +        while (contacts_list_get_current_record_p(contacts_list, &record) == 0) {
      +            int id = -1;
      +            error_code = contacts_db_insert_record(record, &id); /* Add to the database */
      +            if (error_code != 0)
      +                dlog_print(DLOG_ERROR, LOG_TAG, "contacts_db_insert_record failed");
      +
      +            /* Move to the next record */
      +            error_code = contacts_list_next(contacts_list);
      +        }
      +        error_code = contacts_list_destroy(contacts_list, true);
      +        if (error_code != 0)
      +            dlog_print(DLOG_ERROR, LOG_TAG, "contacts_list_destroy failed: %d", error_code);
      +        free (file_path);
      +    }
      +    closedir(dir);
       }
       
    6. - - -

      Exporting to vCard

      +
    -

    To export your contacts to a vCard file:

    +

    To import contacts directly from a vCard file:

      -
    1. Export contacts to a file. -
      • To export a contact from the _contacts_contact view to the vCard format, use the contacts_vcard_make_from_contact() function.

      • - -
      • To export details from the _contacts_person view, use the contacts_vcard_make_from_person() function. If you need to export details from the _contacts_my_profile view, use the contacts_vcard_make_from_my_profile() function.

      +
    2. +

      Parse the vCard file using the contacts_vcard_parse_to_contact_foreach() function. The function invokes a callback for each contact record it parses from the file.

      +

      The following example first defines the vCard file path and then parses the vCard file:

      +
      +/* Get the vCard file path */
      +char *resource_path = app_get_resource_path();
      +char vcard_path[1024] = {0};
      +snprintf(vcard_path, sizeof(vcard_path), "%s/vcard.vcf", resource_path);
      +free(resource_path);
       
      -

      The following example uses the _contacts_contact view, but the use of the other views is the same.

      +/* Get the contacts from the vCard file */ +int error_code = contacts_vcard_parse_to_contact_foreach(vcard_path, _contacts_vcard_cb, NULL); +
      +

      To check how many records are contained in a vCard file, use the contacts_vcard_get_entity_count() function.

      +
    3. +
    4. +

      Implement the callback for handling the contact records parsed from the vCard file. You can use the callback to insert the records into the contact database.

      +

      The callback is invoked separately for each parsed contact record. As long as the callbacks return true, the contacts_vcard_parse_to_contact_foreach() function continues to parse new contacts.

      +

      The following example implements a callback that inserts the parsed record into the contact database:

      -contacts_record_h contact;
      -// Get record to contacts_record_h
      -char *vcard_stream;
      -int err = contacts_vcard_make_from_contact(contact, &vcard_stream);
      +bool
      +_contacts_vcard_cb(contacts_record_h record, void *user_data)
      +{
      +    int id = -1;
      +    int error_code = contacts_db_insert_record(record, &id);
       
      -// Stream in vCard format is now in vcard_stream
      -free(vcard_stream);
      -
    5. +    return true; +} + + -
    6. Write to a file:

      +
    -
    -FILE * file = fopen("/path/contacts.vcf", "w");
    -fwrite(vcard_stream, 1, strlen(vcard_stream), file);
    -fclose(file);
    -
    +

    Exporting to vCard

    +

    To export all contact records from the contact database and store them to a single vCard file:

    -

    The following example shows how to get all records from a database and put them into a single file.

    -

    Get the list of all records using the contacts_db_get_all_records() function and the current records using the contacts_list_get_current_record_p() function. Get the vCard stream and write to the file in a while loop.

    +
      +
    1. +

      Define the location of the vCard file where the contacts are to be exported, and retrieve a list of all records using the contacts_db_get_all_records() function:

       char file_path[] = "/path/contacts.vcf";
       contacts_list_h list = NULL;
      -err = contacts_db_get_all_records(_contacts_contact._uri, 0, 0, &list);
      +error_code = contacts_db_get_all_records(_contacts_contact._uri, 0, 0, &list);
      +
      +
    2. +
    3. +

      Open the vCard file for writing:

      +
      +FILE *file = fopen(file_path, "w");
      +
      +
    4. -contacts_record_h record; -FILE * file = fopen(file_path, "w"); +
    5. +

      Loop through the contact list, export each contact record in the vCard format, and write the record to the file:

      +
        +
      • To export a contact from the _contacts_contact view, use the contacts_vcard_make_from_contact() function.

      • +
      • To export details from the _contacts_person view, use the contacts_vcard_make_from_person() function.

      • +
      • To export details from the _contacts_my_profile view, use the contacts_vcard_make_from_my_profile() function.

      • +
      +

      The following example uses the _contacts_contact view, but other views work the same way.

      +
      +contacts_record_h contact;
      +char *vcard_stream;
       
      -while (contacts_list_get_current_record_p(list, &record) == 0)
      -{
      -   err = contacts_vcard_make_from_contact(record, &vcard_stream);
      -   // Save to file
      -   fwrite(vcard_stream, 1, strlen(vcard_stream), file);
      -   free(vcard_stream);
      -   err = contacts_list_next(list);
      +while (contacts_list_get_current_record_p(list, &record) == 0) {
      +    error_code = contacts_vcard_make_from_contact(record, &vcard_stream);
      +    /* Save to file */
      +    fwrite(vcard_stream, 1, strlen(vcard_stream), file);
      +    free(vcard_stream);
      +    error_code = contacts_list_next(list);
       }
       fclose(file);
       contacts_list_destroy(list, true);
       
      +
    6. +
    @@ -3245,4 +3535,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/social/service_adaptor_tutorial_n.htm b/org.tizen.tutorials/html/native/social/service_adaptor_tutorial_n.htm index 5cd0f91..da1256d 100644 --- a/org.tizen.tutorials/html/native/social/service_adaptor_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/social/service_adaptor_tutorial_n.htm @@ -10,7 +10,6 @@ - Service Adaptor: Working with Plugins @@ -21,15 +20,14 @@

    Mobile native

    +

    Service Adaptor: Working with Plugins

    -

    This tutorial demonstrates how you can use adaptors to work with plugins.

    - + +

    This tutorial demonstrates how you can use the Service Adaptor to work with service plugins.

    +

    This feature is supported in mobile applications only.

    -

    Warm-up

    -

    Become familiar with the Service Adaptor API basics:

    - +

    Warm-up

    + +

    Become familiar with the Service Adaptor API basics by learning about:

    + +

    Initializing the Service Adaptor

    -

    To use the Service Adaptor plugins in your application, you must learn to obtain a Service Adaptor handle and a list of the available plugins:

    + +

    To initialize the Service Adaptor for use:

    +
      -
    1. To use the functions and data types of the Service Adaptor API, include the <service_adaptor_client.h> header file in your application:

      + +
    2. +

      To use the functions and data types of the Service Adaptor API, include the <service_adaptor_client.h> header file in your application:

       #include <service_adaptor_client.h>
      -
    3. + + -
    4. Obtain a Service Adaptor handle:

      +
    5. +

      Create a Service Adaptor handle using the service_adaptor_create() function:

       static service_adaptor_h service_adaptor;
       
       void
       service_adaptor_init()
       {
      -   int ret = service_adaptor_create(&service_adaptor);
      +    int ret = service_adaptor_create(&service_adaptor);
       
      -   if (SERVICE_ADAPTOR_ERROR_NONE != ret)
      -   {
      -      // Error handling
      -   }
      +    if (ret != SERVICE_ADAPTOR_ERROR_NONE)
      +        /* Error handling */
       }
       
    6. -
    7. Use a data structure to store the obtained plugin handles:

      + +
    8. +

      Create a data structure for storing the service plugin handles:

      -struct
      -plugin_list_item_s
      -{
      -   service_plugin_h plugin;
      -   struct plugin_list_item_s *next;
      +struct plugin_list_item_s {
      +    service_plugin_h plugin;
      +    struct plugin_list_item_s *next;
       };
       
       typedef struct plugin_list_item_s plugin_list_item_t;
      @@ -100,234 +104,278 @@ typedef plugin_list_item_t* plugin_list_item_h;
       typedef plugin_list_t* plugin_list_h;
       
    9. -
    10. Obtain a list of available Service Adaptor plugins:

      + +
    11. +

      Retrieve a list of available service plugins:

       static plugin_list_t plugins;
       
      +/* Handle a plugin from the plugin list */
       static bool
       _plugin_iterator_cb(char *plugin_uri, int service_mask, void *user_data)
       {
      -   plugin_list_item_h plugin_item = (plugin_list_item_h)calloc(1, sizeof(plugin_list_item_t));
      +    plugin_list_item_h plugin_item = (plugin_list_item_h)calloc(1, sizeof(plugin_list_item_t));
       
      -   // Create plugin handle
      -   service_adaptor_create_plugin(service_adaptor, plugin_uri, &plugin_item->plugin);
      +    /* Create the plugin handle */
      +    service_adaptor_create_plugin(service_adaptor, plugin_uri, &plugin_item->plugin);
       
      -   // Set plugin properties
      -   service_plugin_add_property(plugin_item->plugin, SERVICE_PLUGIN_PROPERTY_APP_KEY, "app_key");
      -   service_plugin_add_property(plugin_item->plugin, SERVICE_PLUGIN_PROPERTY_APP_SECRET, "app_secret");
      +    /* Set the plugin properties */
      +    service_plugin_add_property(plugin_item->plugin, SERVICE_PLUGIN_PROPERTY_APP_KEY, "app_key");
      +    service_plugin_add_property(plugin_item->plugin, SERVICE_PLUGIN_PROPERTY_APP_SECRET, "app_secret");
       
      -   // Initialize plugin
      -   service_plugin_start(plugin_item->plugin, service_mask);
      +    /* Initialize the plugin */
      +    service_plugin_start(plugin_item->plugin, service_mask);
       
      -   return true;
      +    return true;
       }
       
      +/* Retrieve the plugin list */
       void
       plugin_lookup()
       {
      -   // Iterate over plugin list
      -   int ret = service_adaptor_foreach_plugin(service_adaptor, _plugin_iterator_cb, &plugins);
      -
      -   if (SERVICE_ADAPTOR_ERROR_NO_DATA == ret)
      -   {
      -      // Handle no plugins
      -   }
      -   else if (SERVICE_ADAPTOR_ERROR_NONE != ret)
      -   {
      -      // Error handling
      -   }
      +    /* Iterate through the plugin list */
      +    /* Use the callback to separately handle each plugin in the list */
      +    int ret = service_adaptor_foreach_plugin(service_adaptor, _plugin_iterator_cb, &plugins);
      +
      +    if (ret == SERVICE_ADAPTOR_ERROR_NO_DATA)
      +        /* Handle no plugins */
      +    else if (ret != SERVICE_ADAPTOR_ERROR_NONE)
      +        /* Error handling */
       }
      -
    12. -
    + + +
  • +

    When no longer needed, destroy the Service Adaptor handle and release all its resources with the service_adaptor_destroy() function:

    -

    Retrieving the File List

    -

    To list the files in the storage, use the obtained plugin handle:

    -static bool
    -_file_iterator_cb(service_storage_file_h file, void *user_data)
    +static void
    +service_adaptor_deinit(int result, void *user_data)
     {
    -   char *name = NULL;
    -   unsigned long long size = 0;
    -   bool is_dir = false;
    +    int ret = service_adaptor_destroy(service_adaptor);
     
    -   // Fetch basic file info
    -   service_storage_file_is_dir(file, &is_dir);
    -   service_storage_file_get_size(file, &size);
    -   service_storage_file_get_logical_path(file, &name);
    +    if (ret != SERVICE_ADAPTOR_ERROR_NONE)
    +        /* Error handling */
    +}
    +
    +
  • + + +

    Retrieving Files

    + +

    To retrieve information about all the files in the storage:

    -   return true; +
      + +
    1. +

      Retrieve the list of files using the service_storage_get_file_list() function with the storage service plugin handle as the first parameter and the file list callback as the third parameter:

      +
      +void
      +plugin_get_file_list(service_plugin_h plugin)
      +{
      +    service_storage_get_file_list(plugin, "/", _service_storage_result_cb, NULL);
       }
      +
      +
    2. +
    3. +

      Define the file list callback. In the callback, iterate through the list using the service_storage_file_list_foreach_file() function with the file callback as the second parameter. The file callback is called separately for each file in the list.

      +
      +/* Handle the returned file list */
       static void
       _service_storage_result_cb(int result, service_storage_file_list_h list, void *user_data)
       {
      -   // Iterate over file list
      -   service_storage_file_list_foreach_file(list, _file_iterator_cb, NULL);
      +    /* Iterate through the list */
      +    /* Use the callback to separately handle each file in the list */
      +    service_storage_file_list_foreach_file(list, _file_iterator_cb, NULL);
       }
      +
      +
    4. -void -plugin_get_file_list(service_plugin_h plugin) +
    5. +

      Define the file callback. In the callback, use the service_storage_file_XXX() functions to retrieve information about the current file.

      +
      +/* Handle a file from the file list */
      +static bool
      +_file_iterator_cb(service_storage_file_h file, void *user_data)
       {
      -   service_storage_get_file_list(plugin, "/", _service_storage_result_cb, NULL);
      +    char *name = NULL;
      +    unsigned long long size = 0;
      +    bool is_dir = false;
      +
      +    /* Get basic file information */
      +    service_storage_file_is_dir(file, &is_dir);
      +    service_storage_file_get_size(file, &size);
      +    service_storage_file_get_logical_path(file, &name);
      +
      +    return true;
       }
       
      +
    6. + +

    Uploading Files

    +

    To upload a file to the storage:

    +
      -
    1. Define callbacks: + +
    2. +

      Define the callbacks for monitoring the upload task progress and state during the upload:

       static void
       task_progress_cb(unsigned long long progress, unsigned long long total, void *user_data)
       {
      -   // Handle the task progress
      +    /* Handle the task progress */
       }
       
       static void
       task_state_cb(service_storage_task_state_e state, void *user_data)
       {
      -   // Handle task states
      -   switch (state)
      -   {
      -      case SERVICE_STORAGE_TASK_IN_PROGRESS:
      -         break;
      -      case SERVICE_STORAGE_TASK_COMPLETED:
      -         break;
      -      case SERVICE_STORAGE_TASK_CANCELED:
      -         break;
      -      case SERVICE_STORAGE_TASK_FAILED:
      -         break;
      -   }
      -}
    3. -
    4. Create an upload task:

      +    /* Handle task states */ +    switch (state) { +    case SERVICE_STORAGE_TASK_IN_PROGRESS: +        break; +    case SERVICE_STORAGE_TASK_COMPLETED: +        break; +    case SERVICE_STORAGE_TASK_CANCELED: +        break; +    case SERVICE_STORAGE_TASK_FAILED: +        break; +    } +} + +
    5. + +
    6. +

      Create an upload task:

       void
       plugin_upload_file(service_plugin_h plugin, const char *local_path, const char *storage_path)
       {
      -   service_storage_task_h task;
      +    service_storage_task_h task;
      +
      +    /* Upload a local file to the storage */
      +    if (service_storage_create_upload_task(plugin, local_path, storage_path, &task) != SERVICE_ADAPTOR_ERROR_NONE) {
      +        /* Error handling */
       
      -   // Upload a local file to the storage
      -   if (SERVICE_ADAPTOR_ERROR_NONE != service_storage_create_upload_task(plugin, local_path, storage_path, &task))
      -   {
      -      // Error handling
      +        return;
      +    }
      +
      +
    7. -      return; -   } - -
    8. Register callbacks to monitor the upload progress and task state changes:

      +
    9. +

      Register the defined callbacks:

      -   // Task progress change callback
      -   if (SERVICE_ADAPTOR_ERROR_NONE != service_storage_set_task_progress_cb(task, task_progress_cb, NULL))
      -   {
      -      // Error handling
      -
      -      return;
      -   }
      -
      -   // Task state change callback
      -   if (SERVICE_ADAPTOR_ERROR_NONE != service_storage_set_task_state_changed_cb(task, task_state_cb, NULL))
      -   {
      -      // Error handling
      -
      -      return;
      -   }
      -
    10. -
    11. Start the upload task:

      +    /* Register the task progress change callback */ +    if (service_storage_set_task_progress_cb(task, task_progress_cb, NULL) != SERVICE_ADAPTOR_ERROR_NONE) { +        /* Error handling */ + +        return; +    } + +    /* Register the task state change callback */ +    if (service_storage_set_task_state_changed_cb(task, task_state_cb, NULL) != SERVICE_ADAPTOR_ERROR_NONE) { +        /* Error handling */ + +        return; +    } + +
    12. + +
    13. +

      Start the upload task:

      -   if (SERVICE_ADAPTOR_ERROR_NONE != service_storage_start_task(task))
      -   {
      -      // Error handling
      +    if (service_storage_start_task(task) != SERVICE_ADAPTOR_ERROR_NONE) {
      +        /* Error handling */
       
      -      return;
      -   }
      +        return;
      +    }
       }
      -
    14. + + +

    Downloading Files

    +

    To download a file from the storage:

    +
      -
    1. Create a download task: + +
    2. +

      Create a download task:

       void
       plugin_download_file(service_plugin_h plugin, const char *storage_path, const char *local_path)
       {
      -   service_storage_task_h task;
      +    service_storage_task_h task;
      +
      +    /* Download a file from the storage to a local directory */
      +    if (service_storage_create_download_task(plugin, storage_path, local_path, &task) != SERVICE_ADAPTOR_ERROR_NONE) {
      +        /* Error handling */
       
      -   // Download file from the storage to a local directory
      -   if (SERVICE_ADAPTOR_ERROR_NONE != service_storage_create_download_task(plugin, storage_path, local_path, &task))
      -   {
      -      // Error handling
      +        return;
      +    }
      +
      +
    3. -      return; -   } - -
    4. Register callbacks to monitor the download progress and task state changes: +
    5. +

      Register callbacks for monitoring the download task progress and state:

      -   // Task progress change callback
      -   if (SERVICE_ADAPTOR_ERROR_NONE != service_storage_set_task_progress_cb(task, task_progress_cb, NULL))
      -   {
      -      // Error handling
      -
      -      return;
      -   }
      -
      -   // Task state change callback
      -   if (SERVICE_ADAPTOR_ERROR_NONE != service_storage_set_task_state_changed_cb(task, task_state_cb, NULL))
      -   {
      -      // Error handling
      -
      -      return;
      -   }
      -
    6. -
    7. Start the download task: +    /* Register the task progress change callback */ +    if (service_storage_set_task_progress_cb(task, task_progress_cb, NULL) != SERVICE_ADAPTOR_ERROR_NONE) { +        /* Error handling */ + +        return; +    } + +    /* Register the task state change callback */ +    if (service_storage_set_task_state_changed_cb(task, task_state_cb, NULL) != SERVICE_ADAPTOR_ERROR_NONE) { +        /* Error handling */ + +        return; +    } + + +

      The file upload and download processes use the same callback types. You can use the callbacks defined for the file upload, or define separate callbacks, as needed.

      + +
    8. + +
    9. +

      Start the download task:

      -   if (SERVICE_ADAPTOR_ERROR_NONE != service_storage_start_task(task))
      -   {
      -      // Error handling
      +    if (service_storage_start_task(task) != SERVICE_ADAPTOR_ERROR_NONE) {
      +        /* Error handling */
       
      -      return;
      -   }
      +        return;
      +    }
       }
      -
    10. + +

    Removing Files

    +

    To remove a file from the storage, use the service_storage_remove() function:

    +
    +/* Handle the results of removing the file */
     static void
     file_remove_cb(int result, void *user_data)
     {
    -   if (SERVICE_ADAPTOR_ERROR_NONE != result)
    -   {
    -      // Error handling
    -   }
    +    if (result != SERVICE_ADAPTOR_ERROR_NONE)
    +        /* Error handling */
     }
     
    +/* Remove the file */
     void
     plugin_remove_file(service_plugin_h plugin, const char *file)
     {
    -   int ret = service_storage_remove(plugin, file, file_remove_cb, NULL);
    -
    -   if (SERVICE_ADAPTOR_ERROR_NONE == ret)
    -   {
    -      // Error handling
    -   }
    -}
    -
    - -

    Cleaning Up

    -

    To clean up and destroy the Service Adaptor handle, use the service_adaptor_destroy() function:

    -
    -static void
    -service_adaptor_deinit(int result, void *user_data)
    -{
    -   int ret = service_adaptor_destroy(service_adaptor);
    +    int ret = service_storage_remove(plugin, file, file_remove_cb, NULL);
     
    -   if (SERVICE_ADAPTOR_ERROR_NONE != ret)
    -   {
    -      // Error handling
    -   }
    +    if (ret != SERVICE_ADAPTOR_ERROR_NONE)
    +        /* Error handling */
     }
     
    @@ -342,7 +390,7 @@ service_adaptor_deinit(int result, void *user_data)
    - - - + + \ No newline at end of file diff --git a/org.tizen.tutorials/html/native/social/social_tutorials_n.htm b/org.tizen.tutorials/html/native/social/social_tutorials_n.htm index 096639c..88e09ff 100644 --- a/org.tizen.tutorials/html/native/social/social_tutorials_n.htm +++ b/org.tizen.tutorials/html/native/social/social_tutorials_n.htm @@ -16,13 +16,14 @@ @@ -31,13 +32,15 @@

    Social: Managing Personal Data

    -

    The social tutorials demonstrate how to use the following features in creating Tizen native applications.

    - +

    The social tutorials demonstrate how to use the following features in creating Tizen native applications:

    + +

    The following tutorials apply in mobile applications only:

    diff --git a/org.tizen.tutorials/html/native/system/device_tutorial_n.htm b/org.tizen.tutorials/html/native/system/device_tutorial_n.htm index 62b339e..2d931d1 100644 --- a/org.tizen.tutorials/html/native/system/device_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/system/device_tutorial_n.htm @@ -23,6 +23,7 @@

    Content

      +
    • Prerequisites
    • Retrieving Battery Information
    • Device control
        @@ -72,6 +73,21 @@

        Register a callback to monitor device changes.

      +

      Prerequisites

      + +

      To use the Device API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

      +
      +<privileges>
      +   <!--To use the Display API-->
      +   <privilege>http://tizen.org/privilege/display</privilege>
      +   <!--To use the Haptic API-->
      +   <privilege>http://tizen.org/privilege/haptic</privilege>
      +   <!--To use the Led API-->
      +   <privilege>http://tizen.org/privilege/led</privilege>
      +</privileges>
      +
      + +

      Retrieving Battery Information

      To retrieve battery information:

      @@ -79,7 +95,8 @@
    • To use the functions and data types of the Battery API (in mobile and wearable applications), include the <device/battery.h> header file in your application:

      -#include <device/battery.h>
      +#include <device/battery.h> +
    • To get the battery details: @@ -88,7 +105,8 @@

      The function returns the current battery percentage as an integer value from 0 to 100 that indicates the remaining battery charge as a percentage of the maximum level.

      -int error, pct;
      +int error;
      +int pct;
       error = device_battery_get_percent(&pct);
       
    • @@ -119,34 +137,34 @@ error = device_battery_get_level_status(&level);
    • To use the functions and data types of the Display API (in mobile and wearable applications), include the <device/display.h> header file in your application:

      -#include <device/display.h>
      +#include <device/display.h> +
    • -
    • To retrieve and set display properties:
        -
      • Get the number of display devices with the device_display_get_numbers() function. -

        The function requires the http://tizen.org/privilege/display privilege.

        +
      • Get the number of display devices with the device_display_get_numbers() function:
        -int error, num;
        +int error;
        +int num;
         error = device_display_get_numbers(&num);
         
      • Get the maximum brightness with the device_display_get_max_brightness() function.

        The function returns the maximum brightness value that can be set.

        -

        The function requires the http://tizen.org/privilege/display privilege.

        -int error, max;
        +int error;
        +int max;
         error = device_display_get_max_brightness(0, &max);
         
      • -
      • Get and set the display brightness with the device_display_get_brightness() and device_display_set_brightness() functions. -

        The functions require the http://tizen.org/privilege/display privilege.

        +
      • Get and set the display brightness with the device_display_get_brightness() and device_display_set_brightness() functions:
        -int error, brt;
        +int error;
        +int brt;
         error = device_display_get_brightness(0, &brt);
         
         error = device_display_set_brightness(0, 100);
        @@ -154,8 +172,7 @@ error = device_display_set_brightness(0, 100);
         		
      • Get and set the display state with the device_display_get_state() and device_display_change_state() functions. -

        The display_state_e enumerator (in mobile and wearable applications) defines the available display states.

        -

        The device_display_change_state() function requires the http://tizen.org/privilege/display privilege.

        +

        The display_state_e enumerator (in mobile and wearable applications) defines the available display states.

         int error;
         display_state_e state;
        @@ -175,14 +192,15 @@ error = device_display_change_state(DISPLAY_STATE_NORMAL);
         		
      • To use the functions and data types of the Haptic API (in mobile and wearable applications), include the <device/haptic.h> header file in your application:

        -#include <device/haptic.h>
        +#include <device/haptic.h> +
      • -
      • Get the number of haptic devices with the device_haptic_get_count() function. -

        The function requires the http://tizen.org/privilege/haptic privilege.

        +
      • Get the number of haptic devices with the device_haptic_get_count() function:
        -int error, num;
        +int error;
        +int num;
         error = device_haptic_get_count(&num);
         
      • @@ -190,7 +208,6 @@ error = device_haptic_get_count(&num);
        1. Initialize the haptic device with the device_haptic_open() function.

          The function opens a haptic-vibration device and returns the handle to it. It makes a connection to the vibrator.

          -

          The function requires the http://tizen.org/privilege/haptic privilege.

           int error;
           haptic_device_h handle;
          @@ -200,7 +217,6 @@ error = device_haptic_open(0, &handle);
           
           
        2. Play and stop an effect on the device with the device_haptic_vibrate() and device_haptic_stop() functions.

          The device vibrates during specified time with a constant intensity. The effect handle can be 0.

          -

          The functions require the http://tizen.org/privilege/haptic privilege.

           int error;
           haptic_effect_h effect_handle;
          @@ -210,9 +226,8 @@ error = device_haptic_stop(handle, &effect_handle);
           
        3. -
        4. When no longer needed, uninitialize the haptic device with the device_haptic_close() function. +
        5. When no longer needed, deinitialize the haptic device with the device_haptic_close() function.

          The function closes the haptic handle and disconnects the connection to the vibrator.

          -

          The function requires the http://tizen.org/privilege/haptic privilege.

           int error;
          @@ -226,17 +241,17 @@ error = device_haptic_close(0, handle);
           

          Controlling IR Devices

          To control IR devices:

          -
            -
          1. +
              +
            1. To use the functions and data types of the IR API (in mobile and wearable applications), include the <device/ir.h> header file in your application:

              -#include <device/ir.h>
              +#include <device/ir.h> +
        6. -
        7. To manage a ir device: +
        8. To manage an IR device:
            -
          1. Bring information whether IR is available with the device_ir_is_available() function. -

            The function check whether IR device is available.

            +
          2. Determine whether IR is available in the device using the device_ir_is_available() function:
             bool avail;
             int error;
            @@ -244,8 +259,7 @@ error = device_ir_is_available(&avail);
             
          3. -
          4. Transmit IR pattern with the device_ir_transmit() function. -

            The device transmit ir pattern with specific carrier frequency.

            +
          5. Transmit an IR pattern with a specific carrier frequency using the device_ir_transmit() function:
             int error;
             int carrier_frequency;
            @@ -253,7 +267,6 @@ int *pattern;
             error = device_ir_transmit(carrier_frequency, pattern, size);
             
          6. -
        @@ -265,24 +278,25 @@ error = device_ir_transmit(carrier_frequency, pattern, size);
      • To use the functions and data types of the Led API (in mobile and wearable applications), include the <device/led.h> header file in your application:

        -#include <device/led.h>
        +#include <device/led.h> +
      • To manage a LED device:
        • Get the maximum brightness value of a torch LED with the device_flash_get_max_brightness() function.

          The function returns the maximum brightness value of the torch LED located next to the camera.

          -

          The function requires the http://tizen.org/privilege/led privilege.

          -int error, max;
          +int error;
          +int max;
           error = device_flash_get_max_brightness(&max);
           
        • -
        • Get and set the current brightness value of a torch LED with the device_flash_get_brightness() and device_flash_set_brightness() functions. -

          The functions require the http://tizen.org/privilege/led privilege.

          +
        • Get and set the current brightness value of a torch LED with the device_flash_get_brightness() and device_flash_set_brightness() functions:
          -int error, val;
          +int error;
          +int val;
           error = device_flash_get_brightness(&val);
           
           error = device_flash_set_brightness(1);
          @@ -292,7 +306,6 @@ error = device_flash_set_brightness(1);
           
        • Play and stop a custom effect of the service LED with the device_led_play_custom() and device_led_stop_custom() functions.

          The led_custom_flags enumerator (in mobile and wearable applications) defines the available custom effects.

          The custom effect plays on the service LED that is located on the front of the device.

          -

          The functions require the http://tizen.org/privilege/led privilege.

           int error;
          @@ -312,7 +325,8 @@ error = device_led_stop_custom();
           		
        • To use the functions and data types of the Power API (in mobile and wearable applications), include the <device/power.h> header file in your application:

          -#include <device/power.h>
          +#include <device/power.h> +
        • To lock and unlock the power state:
            @@ -320,7 +334,6 @@ error = device_led_stop_custom();

            The function locks the specific lock type for a specified time. After the given timeout, the lock type is unlocked automatically. If the process is destroyed, every lock is removed.

            The power_lock_e enumerator (in mobile and wearable applications) defines the available lock types.

            -

            The function requires the http://tizen.org/privilege/display privilege.

             int error;
            @@ -330,7 +343,6 @@ error = device_power_request_lock(POWER_LOCK_CPU, 0);
             
             
          • Unlock the power state with the device_power_release_lock() function.

            The function releases the specific lock type locked before.

            -

            The function requires the http://tizen.org/privilege/display privilege.

             int error;
             error = device_power_release_lock(POWER_LOCK_CPU);
            @@ -347,7 +359,8 @@ error = device_power_release_lock(POWER_LOCK_CPU);
             		
          • To use the functions and data types of the Callback API (in mobile and wearable applications), include the <device/callback.h> header file in your application:

            -#include <device/callback.h>
            +#include <device/callback.h> +
          • Define a callback, which is called when the device status changes. @@ -355,14 +368,14 @@ error = device_power_release_lock(POWER_LOCK_CPU);

            The device_callback_e enumerator (in mobile and wearable applications) defines the available callback types.

            -static void 
            +static void
             changed_cb(device_callback_e type, void *value, void *user_data)
             {
            -   int val;
            -   if (type != DEVICE_CALLBACK_DISPLAY_STATE)
            -      return;
            -   val = (int)value;
            -   dlog_print(DLOG_DEBUG, LOG_TAG, "current display state : %d", val);
            +    int val;
            +    if (type != DEVICE_CALLBACK_DISPLAY_STATE)
            +        return;
            +    val = (int)value;
            +    dlog_print(DLOG_DEBUG, LOG_TAG, "current display state : %d", val);
             }
             
          • @@ -375,7 +388,7 @@ error = device_add_callback(DEVICE_CALLBACK_DISPLAY_STATE, changed_cb, NULL);
            -
          • When no longer needed, unregister the callback function: +
          • When no longer needed, deregister the callback function:
             int error;
             error = device_remove_callback(DEVICE_CALLBACK_DISPLAY_STATE, changed_cb);
            diff --git a/org.tizen.tutorials/html/native/system/dlog_tutorial_n.htm b/org.tizen.tutorials/html/native/system/dlog_tutorial_n.htm
            index 08c1bff..487804b 100644
            --- a/org.tizen.tutorials/html/native/system/dlog_tutorial_n.htm
            +++ b/org.tizen.tutorials/html/native/system/dlog_tutorial_n.htm
            @@ -79,19 +79,19 @@
             
             #define TAG "MY_APP"
             
            -int 
            +int
             main(void)
             {
            -   int integer = 21;
            -   char string[] = "test dlog";
            +    int integer = 21;
            +    char string[] = "test dlog";
             
            -   dlog_print(DLOG_DEBUG, TAG, "debug message");
            -   dlog_print(DLOG_INFO, TAG, "info message");
            -   dlog_print(DLOG_WARN, TAG, "warning message");
            -   dlog_print(DLOG_ERROR, TAG, "error message");
            -   dlog_print(DLOG_INFO, TAG, "%s, %d", string, integer);
            +    dlog_print(DLOG_DEBUG, TAG, "debug message");
            +    dlog_print(DLOG_INFO, TAG, "info message");
            +    dlog_print(DLOG_WARN, TAG, "warning message");
            +    dlog_print(DLOG_ERROR, TAG, "error message");
            +    dlog_print(DLOG_INFO, TAG, "%s, %d", string, integer);
             
            -   return 0;
            +    return 0;
             }
             
            @@ -186,7 +186,7 @@ W/MY_APP (11097): warning message E/MY_APP (11097): error message I/MY_APP (11097): test dlog, 21
            - + diff --git a/org.tizen.tutorials/html/native/system/runtime_tutorial_n.htm b/org.tizen.tutorials/html/native/system/runtime_tutorial_n.htm index ace697b..33b9589 100644 --- a/org.tizen.tutorials/html/native/system/runtime_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/system/runtime_tutorial_n.htm @@ -23,7 +23,8 @@

            Content

            @@ -46,16 +47,16 @@

            Warm-up

            Become familiar with the Runtime information API basics by learning about:

            -

            Getting Runtime Information

            - -

            Using Key-Value Pair

            +

            Getting Runtime Information with a Key-Value Pair

            Some runtime information consists of key and value pairs.

            To get information on, for example, whether Bluetooth is enabled or an audio jack connected:

            @@ -72,19 +73,18 @@
             #include <stdbool.h>
             
            -void 
            +void
             func(void)
             {
            -   bool value;
            -   int ret;
            -
            -   ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BLUETOOTH_ENABLED, &value);
            -   if (ret != RUNTIME_INFO_ERROR_NONE)
            -   {
            -      // Error handling
            -      return;
            -   }
            -   dlog_print(DLOG_INFO, LOG_TAG, "Bluetooth: %s", value ? "Enabled" : "Disabled");
            +    bool value;
            +    int ret;
            +
            +    ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BLUETOOTH_ENABLED, &value);
            +    if (ret != RUNTIME_INFO_ERROR_NONE) {
            +        /* Error handling */
            +        return;
            +    }
            +    dlog_print(DLOG_INFO, LOG_TAG, "Bluetooth: %s", value ? "Enabled" : "Disabled");
             }
             
          • Get the audio jack connection status. @@ -92,66 +92,63 @@ func(void)

            The audio jack status key data type is integer, which means that you need to use the runtime_info_get_value_int() function.

            -void 
            +void
             func(void)
             {
            -   int value;
            -   int ret;
            -
            -   ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &value);
            -   if (ret != RUNTIME_INFO_ERROR_NONE)
            -   {
            -      // Error handling
            -      return;
            -   }
            -
            -   dlog_print(DLOG_INFO, LOG_TAG, "Audio jack status: %d", value);
            -   switch (value)
            -   {
            -      case RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED:
            -         // Audio jack is disconnected
            -         break;
            -      case RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE:
            -         // 3-conductor wire is connected
            -         break;
            -      case RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE:
            -         // 4-conductor wire is connected
            -         break;
            -   }
            +    int value;
            +    int ret;
            +
            +    ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &value);
            +    if (ret != RUNTIME_INFO_ERROR_NONE) {
            +        /* Error handling */
            +        return;
            +    }
            +
            +    dlog_print(DLOG_INFO, LOG_TAG, "Audio jack status: %d", value);
            +    switch (value) {
            +    case RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED:
            +        /* Audio jack is disconnected */
            +        break;
            +    case RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE:
            +        /* 3-conductor wire is connected */
            +        break;
            +    case RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE:
            +        /* 4-conductor wire is connected */
            +        break;
            +    }
             }
             
          • -

            Using Function

            -

            Some runtime information can be gotten by using function.

            -

            To get information on, for example, the current frequency of CPU core 0:

            +

            Getting Runtime Information with a Function

            + +

            Some runtime information can be retrieved by using a function.

            +

            To get information on, for example, the current frequency of the CPU core 0:

            1. To use the functions and data types of the Runtime information API (in mobile and wearable applications), include the <runtime_info.h> header file in your application:

               #include <runtime_info.h>
               
            2. -
            3. Use the runtime_info_get_processor_current_frequency function with the appropriate arguments.

              +
            4. Retrieve the CPU core frequency with the runtime_info_get_processor_current_frequency() function:

               void
               func(void)
               {
              -   int core_idx = 0;
              -   int freq;
              -   int ret;
              -
              -   ret = runtime_info_get_processor_current_frequency(core_idx, &freq);
              -   if (ret != RUNTIME_INFO_ERROR_NONE)
              -   {
              -      // Error handling
              -      return;
              -   }
              -   dlog_print(DLOG_INFO, LOG_TAG, "The frequency of CPU core 0 : %d", freq);
              -}
              -
            +    int core_idx = 0; +    int freq; +    int ret; +    ret = runtime_info_get_processor_current_frequency(core_idx, &freq); +    if (ret != RUNTIME_INFO_ERROR_NONE) { +        /* Error handling */ +        return; +    } +    dlog_print(DLOG_INFO, LOG_TAG, "The frequency of CPU core 0: %d", freq); +} +
        • Monitoring Runtime Information Changes

          @@ -164,51 +161,48 @@ func(void) #include <runtime_info.h>
        • Use the runtime_info_set_changed_cb() function with the RUNTIME_INFO_KEY_USB_CONNECTED key to register a callback that is triggered each time the USB cable connection state changes.

          -

          When no longer needed, unregister the callback with the runtime_info_unset_changed_cb() function.

          +

          When no longer needed, deregister the callback with the runtime_info_unset_changed_cb() function.

           #include <stdbool.h>
           
          -// Callback
          -void 
          +/* Callback */
          +void
           usb_connection_changed(runtime_info_key_e key, void *user_data)
           {
          -   bool value;
          -   int ret;
          +    bool value;
          +    int ret;
           
          -   if (key != RUNTIME_INFO_KEY_USB_CONNECTED)
          -      return;
          +    if (key != RUNTIME_INFO_KEY_USB_CONNECTED)
          +        return;
           
          -   ret = runtime_info_get_value_bool(key, &value);
          -   if (ret != RUNTIME_INFO_ERROR_NONE)
          -   {
          -      // Error handling
          -      return;
          -   }
          +    ret = runtime_info_get_value_bool(key, &value);
          +    if (ret != RUNTIME_INFO_ERROR_NONE) {
          +        /* Error handling */
          +        return;
          +    }
           
          -   dlog_print(DLOG_INFO, LOG_TAG, "USB status: %s", value ? "Connected" : "Disconnected");
          +    dlog_print(DLOG_INFO, LOG_TAG, "USB status: %s", value ? "Connected" : "Disconnected");
           }
           
          -// Register and unregister
          -void 
          +/* Register and deregister */
          +void
           func(void)
           {
          -   int ret;
          -   void *data;
          -
          -   ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED, usb_connection_changed, data);
          -   if (ret != RUNTIME_INFO_ERROR_NONE)
          -   {
          -      // Error handling
          -      return;
          -   }
          -
          -   ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED);
          -   if (ret != RUNTIME_INFO_ERROR_NONE)
          -   {
          -      // Error handling
          -      return;
          -   }
          +    int ret;
          +    void *data;
          +
          +    ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED, usb_connection_changed, data);
          +    if (ret != RUNTIME_INFO_ERROR_NONE) {
          +        /* Error handling */
          +        return;
          +    }
          +
          +    ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED);
          +    if (ret != RUNTIME_INFO_ERROR_NONE) {
          +        /* Error handling */
          +        return;
          +    }
           }
           
        • diff --git a/org.tizen.tutorials/html/native/system/sensor_tutorial_n.htm b/org.tizen.tutorials/html/native/system/sensor_tutorial_n.htm index bd9dc67..0091f8a 100644 --- a/org.tizen.tutorials/html/native/system/sensor_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/system/sensor_tutorial_n.htm @@ -35,7 +35,7 @@
        • Sensor API for Wearable Native
    -
    +

    Sensor: Using Sensors and Managing Sensor Events

    @@ -78,20 +78,20 @@ error = sensor_is_supported(type, &supported);
     int error;
     
    -// Get default sensor handle
    +/* Get default sensor handle */
     sensor_type_e type = SENSOR_ACCELEROMETER;
     sensor_h sensor;
     
     error = sensor_get_default_sensor(type, &sensor);
     
    -// Get sensor list
    +/* Get sensor list */
     sensor_type_e type = SENSOR_ALL;
     sensor_h *list;
     int sensor_count;
     
     error = sensor_get_sensor_list(type, &list, &sensor_count);
     
    -// Free the list after use
    +/* Free the list after use */
     free(list);
     
    @@ -112,23 +112,23 @@ free(list); sensor_h sensor; sensor_listener_h listener; -error = sensor_create_listener(sensor, &listener); +error = sensor_create_listener(sensor, &listener); +
  • Register a callback for the listener.

    The callback returns information about the sensor measurements (events) in a sensor_event_s structure (in mobile and wearable applications) in its second parameter:

    -void 
    +void
     on_sensor_event(sensor_h sensor, sensor_event_s *event, void *user_data)
     {
    -   // Select a specific sensor with a sensor handle
    -   // This example uses the sensor type, assuming there is only 1 sensor for each type
    -   sensor_type_e type;
    -   sensor_get_type(sensor, &type);
    -   switch (type) 
    -   {
    -      case SENSOR_ACCELEROMETER:
    -         // Use sensor information
    -   }
    +    /* Select a specific sensor with a sensor handle */
    +    /* This example uses the sensor type, assuming there is only 1 sensor for each type */
    +    sensor_type_e type;
    +    sensor_get_type(sensor, &type);
    +    switch (type) {
    +    case SENSOR_ACCELEROMETER:
    +        /* Use sensor information */
    +    }
     }
     
     error = sensor_listener_set_event_cb(listener, 100, on_sensor_event, user_data);
    @@ -217,15 +217,16 @@ error = sensor_create_listener(sensor, &listener);
     
     error = sensor_listener_set_accuracy_cb(listener, sensor_accuracy_changed_cb, user_data);
     
    -void 
    -sensor_accuracy_changed_cb(sensor_h sensor, unsigned long long timestamp, 
    +void
    +sensor_accuracy_changed_cb(sensor_h sensor, unsigned long long timestamp,
                                sensor_data_accuracy_e accuracy, void *data)
     {
    -   // Use the timestamp or accuracy from the sensor
    -}
    +    /* Use the timestamp or accuracy from the sensor */ +} +
  • - + diff --git a/org.tizen.tutorials/html/native/system/storage_tutorial_n.htm b/org.tizen.tutorials/html/native/system/storage_tutorial_n.htm index 67e6a93..7d7156a 100644 --- a/org.tizen.tutorials/html/native/system/storage_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/system/storage_tutorial_n.htm @@ -108,18 +108,17 @@ error = storage_get_external_memory_size(&s);

    Within the callback, you can get information about the individual storage type, state, location, and ID.

     static int internal_storage_id;
    -static bool 
    -storage_cb(int storage_id, storage_type_e type, storage_state_e state, 
    +static bool
    +storage_cb(int storage_id, storage_type_e type, storage_state_e state,
                const char *path, void *user_data)
     {
    -   if (type == STORAGE_TYPE_INTERNAL) 
    -   {
    -      internal_storage_id = storage_id;
    +    if (type == STORAGE_TYPE_INTERNAL) {
    +        internal_storage_id = storage_id;
     
    -      return false;
    -   }
    +        return false;
    +    }
     
    -   return true;
    +    return true;
     }
     
     int error;
    @@ -171,7 +170,8 @@ error = storage_get_type(internal_storage_id, &type);
     
     int error;
     storage_state_e state;
    -error = storage_get_state(internal_storage_id, &state);
    +error = storage_get_state(internal_storage_id, &state); +

    Monitoring Storage State Changes

    @@ -185,12 +185,12 @@ error = storage_get_state(internal_storage_id, &state);
  • Define a callback, which is called when the storage state changes:
    -static void 
    +static void
     storage_changed_cb(int storage_id, storage_state_e state, void *user_data)
     {
    -   if (storage_id != internal_storage_id)
    -      return;
    -   dlog_print(DLOG_DEBUG, LOG_TAG, "state changed to %d", state);
    +    if (storage_id != internal_storage_id)
    +        return;
    +    dlog_print(DLOG_DEBUG, LOG_TAG, "state changed to %d", state);
     }
     
  • @@ -202,7 +202,7 @@ error = storage_set_state_changed_cb(internal_storage_id, storage_changed_cb, NU -
  • When no longer needed, unregister the callback: +
  • When no longer needed, deregister the callback:
     int error;
     error = storage_unset_state_changed_cb(internal_storage_id, storage_changed_cb);
    diff --git a/org.tizen.tutorials/html/native/system/sysinfo_tutorial_n.htm b/org.tizen.tutorials/html/native/system/sysinfo_tutorial_n.htm
    index 201494d..232dc91 100644
    --- a/org.tizen.tutorials/html/native/system/sysinfo_tutorial_n.htm
    +++ b/org.tizen.tutorials/html/native/system/sysinfo_tutorial_n.htm
    @@ -64,23 +64,23 @@
     

    When no longer needed, release the value of the key with the free() function.

    -void 
    +void
     func(void)
     {
    -   char *value;
    -   int ret;
    +    char *value;
    +    int ret;
     
    -   ret = system_info_get_platform_string("http://tizen.org/system/model_name", &value);
    -   if (ret != SYSTEM_INFO_ERROR_NONE) 
    -   {
    -      // Error handling
    -      return;
    -   }
    +    ret = system_info_get_platform_string("http://tizen.org/system/model_name", &value);
    +    if (ret != SYSTEM_INFO_ERROR_NONE) {
    +        /* Error handling */
     
    -   dlog_print(DLOG_INFO, LOG_TAG, "Model name: %s", value);
    +        return;
    +    }
     
    -   free(value); // Release after use 
    -} 
    +    dlog_print(DLOG_INFO, LOG_TAG, "Model name: %s", value);
    +
    +    free(value); /* Release after use */
    +}
     
  • Checking for Supported Features

    @@ -97,23 +97,23 @@ func(void)
     #include <stdbool.h>
     
    -void 
    +void
     func(void)
     {
    -   bool value;
    -   int ret;
    +    bool value;
    +    int ret;
    +
    +    ret = system_info_get_platform_bool("http://tizen.org/feature/camera", &value);
    +    if (ret != SYSTEM_INFO_ERROR_NONE) {
    +        /* Error handling */
     
    -   ret = system_info_get_platform_bool("http://tizen.org/feature/camera", &value);
    -   if (ret != SYSTEM_INFO_ERROR_NONE) 
    -   {
    -      // Error handling
    -      return;
    -   }
    +        return;
    +    }
     
    -   dlog_print(DLOG_INFO, LOG_TAG, "Camera: %s", value ? "Supported" : "Not supported");
    +    dlog_print(DLOG_INFO, LOG_TAG, "Camera: %s", value ? "Supported" : "Not supported");
     }
     
    - + diff --git a/org.tizen.tutorials/html/native/system/system_setting_tutorial_n.htm b/org.tizen.tutorials/html/native/system/system_setting_tutorial_n.htm index 69fc312..9c209e1 100644 --- a/org.tizen.tutorials/html/native/system/system_setting_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/system/system_setting_tutorial_n.htm @@ -61,57 +61,54 @@
  • Define auxiliary structures:

    -struct
    -_ret_type_define
    -{
    -   system_settings_key_e key;
    -   int returns;
    +struct _ret_type_define {
    +    system_settings_key_e key;
    +    int returns;
     };
     
    -typedef 
    -enum
    -{
    -   _RET_BOO = 0,
    -   _RET_INT,
    -   _RET_STRING
    +typedef
    +enum {
    +    _RET_BOOL = 0,
    +    _RET_INT,
    +    _RET_STRING
     } _SYSTEM_SETTINGS_TYPES;
     
     struct _ret_type_define
     _ret_type[] =
     {
    -   {
    -      SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, _RET_STRING
    -   },
    -   {
    -      SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, _RET_STRING
    -   },
    -   {
    -      SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, _RET_STRING
    -   },
    -   {
    -      SYSTEM_SETTINGS_KEY_FONT_SIZE, _RET_INT
    -   },
    -   {
    -      SYSTEM_SETTINGS_KEY_FONT_TYPE, _RET_STRING
    -   },
    -   {
    -      SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, _RET_BOOL
    -   },
    -   {
    -      // Others
    -   }
    +    {
    +        SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, _RET_STRING
    +    },
    +    {
    +        SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, _RET_STRING
    +    },
    +    {
    +        SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, _RET_STRING
    +    },
    +    {
    +        SYSTEM_SETTINGS_KEY_FONT_SIZE, _RET_INT
    +    },
    +    {
    +        SYSTEM_SETTINGS_KEY_FONT_TYPE, _RET_STRING
    +    },
    +    {
    +        SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, _RET_BOOL
    +    },
    +    {
    +        /* Others */
    +    }
     };
     
     static const char*
     _info_key[SYS_INFO_COUNT]=
     {
    -   "SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE",
    -   "SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN",
    -   "SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN",
    -   "SYSTEM_SETTINGS_KEY_FONT_SIZE",
    -   "SYSTEM_SETTINGS_KEY_FONT_TYPE",
    -   "SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION",
    -   // Others
    +    "SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE",
    +    "SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN",
    +    "SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN",
    +    "SYSTEM_SETTINGS_KEY_FONT_SIZE",
    +    "SYSTEM_SETTINGS_KEY_FONT_TYPE",
    +    "SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION",
    +    /* Others */
     };
     
  • @@ -131,32 +128,25 @@ _info_key[SYS_INFO_COUNT]= #define SYS_INFO_COUNT 6 int i; -for (i = 0; i < SYS_INFO_COUNT; i++) -{ -   dlog_print(DLOG_ERROR, LOG_TAG, "%d- System_settings: %s: ", i, _info_key[_ret_type[i].key]); - -   if (_ret_type[i].returns==_RET_BOOL) -   { -      system_settings_get_value_bool(_ret_type[i].key, &_bool_ret); -      dlog_print(DLOG_ERROR, LOG_TAG, "%d", _bool_ret); -   } -   else if (_ret_type[i].returns==_RET_INT) -   { -      system_settings_get_value_int(_ret_type[i].key, &_int_ret); -      dlog_print(DLOG_ERROR, LOG_TAG, "%d", _int_ret); -   } -   else if (_ret_type[i].returns==_RET_STRING) -   { -      system_settings_get_value_string(_ret_type[i].key, &_string_ret); -      dlog_print(DLOG_ERROR, LOG_TAG, "%s", _string_ret); -      free(_string_ret); -   } -   else if (_ret_type[i].returns==_RET_DOUBLE) -   { -      system_settings_get_value_double(_ret_type[i].key, &_double_ret); -      dlog_print(DLOG_ERROR, LOG_TAG, "%f", _double_ret); -   } -   else dlog_print(DLOG_ERROR, LOG_TAG, "Undefined return type"); +for (i = 0; i < SYS_INFO_COUNT; i++) { +    dlog_print(DLOG_ERROR, LOG_TAG, "%d- System_settings: %s: ", i, _info_key[_ret_type[i].key]); + +    if (_ret_type[i].returns==_RET_BOOL) { +        system_settings_get_value_bool(_ret_type[i].key, &_bool_ret); +        dlog_print(DLOG_ERROR, LOG_TAG, "%d", _bool_ret); +    } else if (_ret_type[i].returns==_RET_INT) { +        system_settings_get_value_int(_ret_type[i].key, &_int_ret); +        dlog_print(DLOG_ERROR, LOG_TAG, "%d", _int_ret); +    } else if (_ret_type[i].returns==_RET_STRING) { +        system_settings_get_value_string(_ret_type[i].key, &_string_ret); +        dlog_print(DLOG_ERROR, LOG_TAG, "%s", _string_ret); +        free(_string_ret); +    } else if (_ret_type[i].returns==_RET_DOUBLE) { +        system_settings_get_value_double(_ret_type[i].key, &_double_ret); +        dlog_print(DLOG_ERROR, LOG_TAG, "%f", _double_ret); +    } else { +        dlog_print(DLOG_ERROR, LOG_TAG, "Undefined return type"); +    } } @@ -167,9 +157,7 @@ for (i = 0; i < SYS_INFO_COUNT; i++)
     for (i = 0; i < SYS_INFO_COUNT; i++)
    -{
    -   system_settings_set_changed_cb(_ret_type[i].key, _system_settings_changed_cb, 0);
    -}
    +    system_settings_set_changed_cb(_ret_type[i].key, _system_settings_changed_cb, 0);
     
  • Define the callback to be invoked after each change.

    @@ -179,7 +167,7 @@ for (i = 0; i < SYS_INFO_COUNT; i++) static void _system_settings_changed_cb(system_settings_key_e key, void *user_data) { -   dlog_print(DLOG_ERROR, LOG_TAG, "Runtime Info changed: %s", _info_key[key]); +    dlog_print(DLOG_ERROR, LOG_TAG, "Runtime Info changed: %s", _info_key[key]); }
  • @@ -187,9 +175,7 @@ _system_settings_changed_cb(system_settings_key_e key, void *user_data)
     for (i = 0; i < SYS_INFO_COUNT; i++)
    -{
    -   system_settings_unset_changed_cb(_ret_type[i].key, _system_settings_changed_cb, 0);
    -}
    +    system_settings_unset_changed_cb(_ret_type[i].key, _system_settings_changed_cb, 0);
     
    diff --git a/org.tizen.tutorials/html/native/system/t-trace_tutorial_n.htm b/org.tizen.tutorials/html/native/system/t-trace_tutorial_n.htm index 53a80cd..9cae8bf 100644 --- a/org.tizen.tutorials/html/native/system/t-trace_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/system/t-trace_tutorial_n.htm @@ -83,15 +83,15 @@

    If the trace event starts and ends in a same context within the same process, thread, and function, use the trace_begin() and trace_end() functions to track the event. Note that every trace_begin() function matches up with a trace_end() function that occurs after it.

    -int 
    -main(void) 
    +int
    +main(void)
     {
    -   int integer = 12;
    -   trace_begin("event name: %d", integer);
    +    int integer = 12;
    +    trace_begin("event name: %d", integer);
     
    -   trace_end();
    +    trace_end();
     
    -   return 0;
    +    return 0;
     }
     
    @@ -99,20 +99,20 @@ main(void)
  • Use asynchronous tracing.

    If the trace event starts and ends in a different context, use the trace_async_begin() and trace_async_end() functions to track the event. Note that every trace_async_begin() function matches with a trace_async_end() function that has the same name and cookie. As the cookie provides an identifier among several events, it must have a unique integer value.

    -void 
    -function1() 
    +void
    +function1()
     {
    -   int cookies_f1 = 123;
    +    int cookies_f1 = 123;
     
    -   trace_async_begin(cookies_f1, "event name");
    -} 
    +    trace_async_begin(cookies_f1, "event name");
    +}
     
    -void 
    -function2() 
    +void
    +function2()
     {
    -   int cookies_f2 = 123;
    +    int cookies_f2 = 123;
     
    -   trace_async_end(cookies_f2, "event name");
    +    trace_async_end(cookies_f2, "event name");
     
     }
     
    @@ -120,10 +120,10 @@ function2()
  • Track the trace counter.

    To track the change of an integer counter on your application, use the trace_update_counter() function:

    -void 
    -function2(int count) 
    +void
    +function2(int count)
     {
    -   trace_update_counter(count, "event_name");
    +    trace_update_counter(count, "event_name");
     }
     
  • diff --git a/org.tizen.tutorials/html/native/telephony/phonenumber_util_tutorial_n.htm b/org.tizen.tutorials/html/native/telephony/phonenumber_util_tutorial_n.htm index b3c3300..1a10f56 100644 --- a/org.tizen.tutorials/html/native/telephony/phonenumber_util_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/telephony/phonenumber_util_tutorial_n.htm @@ -18,18 +18,21 @@ @@ -37,76 +40,102 @@

    Phonenumber utils: Parsing and Formatting Phone Numbers

    -

    This tutorial demonstrates how you can parse and format phone numbers.

    -

    This feature is supported in mobile applications only.

    -

    Warm-up

    Become familiar with the Phonenumber utils API basics by learning about:

    -

    Getting the Location

    + +

    Initializing the Phonenumber Utility

    -

    To get the location from the phone number:

    +

    To connect to the phonenumber utils service:

      -
    1. To use the functions and data types of the Phonenumber utils API, include the <phone_number.h> header file in your application:

      +
    2. To use the functions and data types of the Phonenumber utils API (in mobile and wearable applications), include the <phone_number.h> header file in your application:

       #include <phone_number.h>
       
      +

      To ensure that a Phonenumber utils function has been executed properly, make sure that the return is equal to PHONE_NUMBER_ERROR_NONE.

      +
    3. +
    4. To connect to the phonenumber utils service to access the service features, use the phone_number_connect() function:

      + +
      +int error_code;
      +error_code = phone_number_connect();
      +
      +
    5. -
    6. To get the location, use the phone_number_get_location_from_number() function:

      +
    7. When the service is no longer needed, disconnect from it using the phone_number_disconnect() function:

      + +
      +error_code = phone_number_disconnect();
      +
      + +
    + +

    Getting the Location

    -
    int ret;
    +

    To get the location from the phone number, use the phone_number_get_location_from_number() function:

    + +
    +int ret;
     char *location = NULL;
     
    -ret = phone_number_get_location_from_number("0222550114", PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, 
    +ret = phone_number_get_location_from_number("0222550114", PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA,
                                                 PHONE_NUMBER_LANG_ENGLISH, &location);
    -if (PHONE_NUMBER_ERROR_NONE == ret) 
    -{
    -   // Use location
    -   // location – "Seoul"
    -   dlog_print(DLOG_DEBUG, LOG_TAG, "location=%s", location);
    +if (PHONE_NUMBER_ERROR_NONE == ret) {
    +    /* Use location */
    +    /* location – "Seoul" */
    +    dlog_print(DLOG_DEBUG, LOG_TAG, "location=%s", location);
     }
     free(location);
     
    -

    Formatting the Number

    -

    To format the phone number according to the rules of a specific region:

    - -
      +

      To format the phone number to use region-specific separators, use the phone_number_get_formatted_number() function:

      -
    1. To use the functions and data types of the Phonenumber utils API, include the <phone_number.h> header file in your application:

      -#include <phone_number.h>
      -
      -
    2. -
    3. Format the phone number to use region-specific separators:

      - -
      int ret;
      +int ret;
       char *formatted_number = NULL;
       
      -ret = phone_number_get_formatted_number("0222550114", PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, 
      +ret = phone_number_get_formatted_number("0222550114", PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA,
                                               &formatted_number);
      -if (PHONE_NUMBER_ERROR_NONE == ret) 
      -{
      -   // Use formatted_number
      -   // formatted_number - "02-2255-0114"
      -   dlog_print(DLOG_DEBUG, LOG_TAG, "formatted_number=%s", formatted_number);
      +if (PHONE_NUMBER_ERROR_NONE == ret) {
      +    /* Use formatted_number */
      +    /* formatted_number - "02-2255-0114" */
      +    dlog_print(DLOG_DEBUG, LOG_TAG, "formatted_number=%s", formatted_number);
       }
       free(formatted_number);
       
      -
    + +

    Normalizing the Number

    +

    To normalize the phone number, use the phone_number_get_normalized_number() function:

    + +
    +int ret;
    +char *normalized_number = NULL;
    +
    +ret = phone_number_get_normalized_number("0222550114", normalized_number);
    +if (PHONE_NUMBER_ERROR_NONE == ret) {
    +    /* Use normalized_number */
    +    /* normalized_number - "+821022550114" */
    +    dlog_print(DLOG_DEBUG, LOG_TAG, "normalized_number=%s", normalized_number);
    +}
    +free(normalized_number);
    +
    diff --git a/org.tizen.tutorials/html/native/telephony/telephony_info_tutorial_n.htm b/org.tizen.tutorials/html/native/telephony/telephony_info_tutorial_n.htm index eade759..9bb4b90 100644 --- a/org.tizen.tutorials/html/native/telephony/telephony_info_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/telephony/telephony_info_tutorial_n.htm @@ -23,6 +23,7 @@

    Content

    + +

    Prerequisites

    -

    To use the telephony APIs, the application has to request permission by adding the corresponding privileges to the tizen-manifest.xml file.

    + +

    To use the Telephony API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

     <privileges>
    -    <privilege>http://tizen.org/privilege/telephony</privilege>
    -    <privilege>http://tizen.org/privilege/location.coarse</privilege>
    +   <privilege>http://tizen.org/privilege/telephony</privilege>
    +   <privilege>http://tizen.org/privilege/location.coarse</privilege>
     </privileges>
     
    @@ -85,12 +89,11 @@

    To create a telephony handle, use the telephony_handle_list_s structure that holds the handles for all the subscriptions defined in the telephony_common.h header file:

    -typedef 
    -struct
    -{
    -   unsigned int count;
    -   telephony_h *handle;
    -} telephony_handle_list_s;
    +struct _telephony_handle_list_s {
    +    unsigned int count;
    +    telephony_h *handle;
    +};
    +typedef struct _telephony_handle_list_s telephony_handle_list_s;
     
  • @@ -99,33 +102,32 @@ struct
     telephony_handle_list_s handle_list;
     
    -int 
    +int
     main()
     {
    -   int i;
    -
    -   ret = telephony_init(&handle_list); // In case of single SIM, you get only one handle
    -   if (ret != TELEPHONY_ERROR_NONE)
    -   {
    -      // Error handling
    -      return -1;
    -   }
    -   for (i = 0; i < handle_list.count; i++)
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "telephony handle[%p] for subscription[%d]",
    -                 handle_list.handle[i], i);
    -   }
    -
    -   return 0;
    - }
    +    int i;
    +
    +    ret = telephony_init(&handle_list); /* In case of single SIM, you get only one handle */
    +    if (ret != TELEPHONY_ERROR_NONE) {
    +        /* Error handling */
    +
    +        return -1;
    +    }
    +    for (i = 0; i < handle_list.count; i++) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "telephony handle[%p] for subscription[%d]",
    +                   handle_list.handle[i], i);
    +    }
    +
    +    return 0;
    +}
     
  • When no longer needed, free the telephony handle with the telephony_deinit() function:

    -void 
    +void
     tutorial_telephony_deinit()
     {
    -   ret = telephony_deinit(&handle_list);
    +    ret = telephony_deinit(&handle_list);
     }
     
  • @@ -150,69 +152,64 @@ tutorial_telephony_deinit() unsigned int count; telephony_call_h *call_list; -void +void tutorial_telephony_call_get_call_list() { -   telephony_error_e ret; - -   ret = telephony_call_get_call_list(handle_list.handle[0], &count, &call_list); -   if (ret != TELEPHONY_ERROR_NONE) -   { -      // Error handling -   } -   else -   { -      int i; -      unsigned int handle_id = 0; -      char *number = NULL; -      telephony_call_type_e type = 0; -      telephony_call_status_e status = 0; -      telephony_call_direction_e direction = 0; -      bool conf_status = 0; - -      if (count == 0) -      { -         dlog_print(DLOG_INFO, LOG_TAG, "count[%d], No calls", count); - -         return; -      } - -      for (i = 0; i < count; i++) -      { -         telephony_call_get_handle_id(call_list[i], &handle_id); -         telephony_call_get_number(call_list[i], &number); -         telephony_call_get_type(call_list[i], &type); -         telephony_call_get_status(call_list[i], &status); -         telephony_call_get_direction(call_list[i], &direction); -         telephony_call_get_conference_status(call_list[i], &conf_status); - -         dlog_print(DLOG_INFO, LOG_TAG, -                    "id[%d] number[%s] type[%s] status[%s] direction[%s] conference_status[%s]", -                    handle_id, number, -                    type == TELEPHONY_CALL_TYPE_VOICE ? "VOICE" : -                    type == TELEPHONY_CALL_TYPE_VIDEO ? "VIDEO" : "E911", -                    status == TELEPHONY_CALL_STATUS_IDLE ? "IDLE" : -                    status == TELEPHONY_CALL_STATUS_ACTIVE ? "ACTIVE" : -                    status == TELEPHONY_CALL_STATUS_HELD ? "HELD" : -                    status == TELEPHONY_CALL_STATUS_DIALING ? "DIALING" : -                    status == TELEPHONY_CALL_STATUS_ALERTING ? "ALERTING" : -                    status == TELEPHONY_CALL_STATUS_INCOMING ? "INCOMING" : "UNKNOWN", -                    direction == TELEPHONY_CALL_DIRECTION_MO ? "MO" : "MT", -                    conf_status ? "TRUE" : "FALSE"); -         free(number); -      } -      telephony_call_release_call_list(count, &call_list); -   } +    telephony_error_e ret; + +    ret = telephony_call_get_call_list(handle_list.handle[0], &count, &call_list); +    if (ret != TELEPHONY_ERROR_NONE) { +        /* Error handling */ +    } else { +        int i; +        unsigned int handle_id = 0; +        char *number = NULL; +        telephony_call_type_e type = 0; +        telephony_call_status_e status = 0; +        telephony_call_direction_e direction = 0; +        bool conf_status = 0; + +        if (count == 0) { +            dlog_print(DLOG_INFO, LOG_TAG, "count[%d], No calls", count); + +            return; +        } + +        for (i = 0; i < count; i++) { +            telephony_call_get_handle_id(call_list[i], &handle_id); +            telephony_call_get_number(call_list[i], &number); +            telephony_call_get_type(call_list[i], &type); +            telephony_call_get_status(call_list[i], &status); +            telephony_call_get_direction(call_list[i], &direction); +            telephony_call_get_conference_status(call_list[i], &conf_status); + +            dlog_print(DLOG_INFO, LOG_TAG, +                       "id[%d] number[%s] type[%s] status[%s] direction[%s] conference_status[%s]", +                       handle_id, number, +                       type == TELEPHONY_CALL_TYPE_VOICE ? "VOICE" : +                       type == TELEPHONY_CALL_TYPE_VIDEO ? "VIDEO" : "E911", +                       status == TELEPHONY_CALL_STATUS_IDLE ? "IDLE" : +                       status == TELEPHONY_CALL_STATUS_ACTIVE ? "ACTIVE" : +                       status == TELEPHONY_CALL_STATUS_HELD ? "HELD" : +                       status == TELEPHONY_CALL_STATUS_DIALING ? "DIALING" : +                       status == TELEPHONY_CALL_STATUS_ALERTING ? "ALERTING" : +                       status == TELEPHONY_CALL_STATUS_INCOMING ? "INCOMING" : "UNKNOWN", +                       direction == TELEPHONY_CALL_DIRECTION_MO ? "MO" : "MT", +                       conf_status ? "TRUE" : "FALSE"); +            free(number); +        } +        telephony_call_release_call_list(count, &call_list); +    } }
  • When no longer needed, free the call handle with the telephony_call_release_call_list() function:

    -void 
    +void
     tutorial_telephony_call_release_call_list()
     {
    -   telephony_call_release_call_list(count, &call_list);
    +    telephony_call_release_call_list(count, &call_list);
     }
     
  • @@ -220,118 +217,104 @@ tutorial_telephony_call_release_call_list()

    To receive notifications of call state changes asynchronously, register a callback with the telephony_set_noti_cb() function.

    You have to register the callback separately for each call state, using the applicable TELEPHONY_NOTI_VOICE_CALL_XXX or TELEPHONY_NOTI_VIDEO_CALL_XXX notification value in the second parameter of the telephony_set_noti_cb() function. The available values are defined in the telephony_noti_e enumerator (in mobile and wearable applications).

    -

    When the notifications are no longer needed, unregister the callback for each call state with the telephony_unset_noti_cb() function.

    +

    When the notifications are no longer needed, deregister the callback for each call state with the telephony_unset_noti_cb() function.

    The following example registers callbacks for various voice call states:

    -static int 
    -voice_call_noti_tbl[] = 
    +static int
    +voice_call_noti_tbl[] =
     {
    -   TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE,
    -   TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE,
    -   TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD,
    -   TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING,
    -   TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING,
    -   TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING,
    +    TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE,
    +    TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE,
    +    TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD,
    +    TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING,
    +    TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING,
    +    TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING,
     };
     
    -void 
    +void
     voice_call_status_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void* user_data)
     {
    -   int ret_value;
    -   telephony_call_h *call_list;
    -   unsigned int count = 0;
    -
    -   switch (noti_id) 
    -   {
    -      case TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE:
    -         dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Idle!!! [%d]", *(int *)data);
    -         break;
    -
    -      case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE:
    -         dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Active!!! [%d]", *(int *)data);
    -         break;
    -
    -      case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD:
    -         dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Held!!! [%d]", *(int *)data);
    -         break;
    -
    -      case TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING:
    -         dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Dialing!!! [%d]", *(int *)data);
    -         break;
    -
    -      case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING:
    -         dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Alerting!!! [%d]", *(int *)data);
    -         break;
    -
    -      case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING:
    -         dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Incoming!!! [%d]", *(int *)data);
    -         break;
    -
    -      default:
    -         dlog_print(DLOG_INFO, LOG_TAG, "Unknown noti");
    -         break;
    -   }
    -
    -   ret_value = telephony_call_get_call_list(handle_list.handle[0], &count, &call_list);
    -   if (ret_value != TELEPHONY_ERROR_NONE) 
    -   {
    -      dlog_print(DLOG_INFO, LOG_TAG, "telephony_call_get_call_list() failed!!! [0x%x]", ret_value);
    -   } 
    -   else 
    -   {
    -      int i;
    -      unsigned int handle_id = 0;
    -      char *number = NULL;
    -      telephony_call_type_e type = 0;
    -      telephony_call_status_e status = 0;
    -      telephony_call_direction_e direction = 0;
    -      bool conf_status = 0;
    -
    -      for (i = 0; i < count; i++) 
    -      {
    -         telephony_call_get_handle_id(call_list[i], &handle_id);
    -         telephony_call_get_number(call_list[i], &number);
    -         telephony_call_get_type(call_list[i], &type);
    -         telephony_call_get_status(call_list[i], &status);
    -         telephony_call_get_direction(call_list[i], &direction);
    -         telephony_call_get_conference_status(call_list[i], &conf_status);
    -
    -         dlog_print(DLOG_INFO, LOG_TAG, 
    -                    "id[%d] number[%s] type[%s] status[%s] direction[%s] conference_status[%s]",
    -                    handle_id, number,
    -                    type == TELEPHONY_CALL_TYPE_VOICE ? "VOICE" :
    -                    type == TELEPHONY_CALL_TYPE_VIDEO ? "VIDEO" : "E911",
    -                    status == TELEPHONY_CALL_STATUS_IDLE ? "IDLE" :
    -                    status == TELEPHONY_CALL_STATUS_ACTIVE ? "ACTIVE" :
    -                    status == TELEPHONY_CALL_STATUS_HELD ? "HELD" :
    -                    status == TELEPHONY_CALL_STATUS_DIALING ? "DIALING" :
    -                    status == TELEPHONY_CALL_STATUS_ALERTING ? "ALERTING" :
    -                    status == TELEPHONY_CALL_STATUS_INCOMING ? "INCOMING" : "UNKNOWN",
    -                    direction == TELEPHONY_CALL_DIRECTION_MO ? "MO" : "MT",
    -                    conf_status ? "TRUE" : "FALSE");
    -         free(number);
    -      }
    -      telephony_call_release_call_list(count, &call_list);
    -   }
    +    int ret_value;
    +    telephony_call_h *call_list;
    +    unsigned int count = 0;
    +
    +    switch (noti_id) {
    +    case TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE:
    +        dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Idle!!! [%d]", *(int *)data);
    +        break;
    +    case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE:
    +        dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Active!!! [%d]", *(int *)data);
    +        break;
    +    case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD:
    +        dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Held!!! [%d]", *(int *)data);
    +        break;
    +    case TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING:
    +        dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Dialing!!! [%d]", *(int *)data);
    +        break;
    +    case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING:
    +        dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Alerting!!! [%d]", *(int *)data);
    +        break;
    +    case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING:
    +        dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Incoming!!! [%d]", *(int *)data);
    +        break;
    +    default:
    +        dlog_print(DLOG_INFO, LOG_TAG, "Unknown noti");
    +        break;
    +    }
    +
    +    ret_value = telephony_call_get_call_list(handle_list.handle[0], &count, &call_list);
    +    if (ret_value != TELEPHONY_ERROR_NONE) {
    +        dlog_print(DLOG_INFO, LOG_TAG, "telephony_call_get_call_list() failed!!! [0x%x]", ret_value);
    +    } else {
    +        int i;
    +        unsigned int handle_id = 0;
    +        char *number = NULL;
    +        telephony_call_type_e type = 0;
    +        telephony_call_status_e status = 0;
    +        telephony_call_direction_e direction = 0;
    +        bool conf_status = 0;
    +
    +        for (i = 0; i < count; i++) {
    +            telephony_call_get_handle_id(call_list[i], &handle_id);
    +            telephony_call_get_number(call_list[i], &number);
    +            telephony_call_get_type(call_list[i], &type);
    +            telephony_call_get_status(call_list[i], &status);
    +            telephony_call_get_direction(call_list[i], &direction);
    +            telephony_call_get_conference_status(call_list[i], &conf_status);
    +
    +            dlog_print(DLOG_INFO, LOG_TAG,
    +                       "id[%d] number[%s] type[%s] status[%s] direction[%s] conference_status[%s]",
    +                       handle_id, number,
    +                       type == TELEPHONY_CALL_TYPE_VOICE ? "VOICE" :
    +                       type == TELEPHONY_CALL_TYPE_VIDEO ? "VIDEO" : "E911",
    +                       status == TELEPHONY_CALL_STATUS_IDLE ? "IDLE" :
    +                       status == TELEPHONY_CALL_STATUS_ACTIVE ? "ACTIVE" :
    +                       status == TELEPHONY_CALL_STATUS_HELD ? "HELD" :
    +                       status == TELEPHONY_CALL_STATUS_DIALING ? "DIALING" :
    +                       status == TELEPHONY_CALL_STATUS_ALERTING ? "ALERTING" :
    +                       status == TELEPHONY_CALL_STATUS_INCOMING ? "INCOMING" : "UNKNOWN",
    +                       direction == TELEPHONY_CALL_DIRECTION_MO ? "MO" : "MT",
    +                       conf_status ? "TRUE" : "FALSE");
    +            free(number);
    +        }
    +        telephony_call_release_call_list(count, &call_list);
    +    }
     }
     
    -void 
    +void
     tutorial_telephony_set_noti_cb_voice()
     {
    -   telephony_error_e ret;
    -   int i;
    -
    -   for (i = 0; i < (sizeof(voice_call_noti_tbl) / sizeof(int)); i++) 
    -   {
    -      ret = telephony_set_noti_cb(handle_list.handle[0], voice_call_noti_tbl[i],
    -                                  voice_call_status_noti_cb, NULL);
    -      if (ret != TELEPHONY_ERROR_NONE)
    -      {
    -         // Error handling
    -      }
    -   }
    +    telephony_error_e ret;
    +    int i;
    +
    +    for (i = 0; i < (sizeof(voice_call_noti_tbl) / sizeof(int)); i++) {
    +        ret = telephony_set_noti_cb(handle_list.handle[0], voice_call_noti_tbl[i],
    +                                    voice_call_status_noti_cb, NULL);
    +        if (ret != TELEPHONY_ERROR_NONE)
    +            /* Error handling */
    +    }
     }
     
    @@ -355,48 +338,46 @@ tutorial_telephony_set_noti_cb_voice()

    To get the state, call the telephony_sim_get_state() function. It returns the SIM card state in its second parameter, using the values of the telephony_sim_state_e enumerator (in mobile and wearable applications).

    -void 
    +void
     tutorial_telephony_sim_get_state()
     {
    -   telephony_sim_state_e state;
    -   ret = telephony_sim_get_state(handle_list.handle[0], &state);
    -   if (ret != TELEPHONY_ERROR_NONE)
    -   {
    -      // Error handling
    -      return -1;
    -   } 
    -   dlog_print(DLOG_INFO, LOG_TAG, "SIM status: [%d]", status);
    -
    -   return 0;
    +    telephony_sim_state_e state;
    +    ret = telephony_sim_get_state(handle_list.handle[0], &state);
    +    if (ret != TELEPHONY_ERROR_NONE)
    +    {
    +        /* Error handling */
    +        return -1;
    +    }
    +    dlog_print(DLOG_INFO, LOG_TAG, "SIM status: [%d]", status);
    +
    +    return 0;
     }
     

    Receiving Change Notifications for the SIM Card State

    To receive notifications of SIM card state changes asynchronously, register a callback with the telephony_set_noti_cb() function. The callback returns the SIM state in its third parameter.

    -

    When the notifications are no longer needed, unregister the callback with the telephony_unset_noti_cb() function by passing the notification ID as a parameter.

    +

    When the notifications are no longer needed, deregister the callback with the telephony_unset_noti_cb() function by passing the notification ID as a parameter.

    -void 
    +void
     sim_state_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void* user_data)
     {
    -   telephony_sim_state_e sim_state = *(int *)data;
    -   dlog_print(DLOG_INFO, LOG_TAG, "SIM state: [%d]", sim_state);
    +    telephony_sim_state_e sim_state = *(int *)data;
    +    dlog_print(DLOG_INFO, LOG_TAG, "SIM state: [%d]", sim_state);
     }
     
    -void 
    +void
     tutorial_telephony_set_noti_cb_sim()
     {
    -   telephony_error_e ret;
    -   ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_SIM_STATUS,
    -                               sim_state_noti_cb, NULL);
    -   if (ret != TELEPHONY_ERROR_NONE) 
    -   {
    -         // Error handling
    -   }
    -
    -   return 0;
    +    telephony_error_e ret;
    +    ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_SIM_STATUS,
    +                                sim_state_noti_cb, NULL);
    +    if (ret != TELEPHONY_ERROR_NONE)
    +        /* Error handling */
    +
    +    return 0;
     }
     
    @@ -409,17 +390,17 @@ tutorial_telephony_set_noti_cb_sim()

    For example, to get ICC-ID information from a SIM card:

    -void 
    +void
     tutorial_telephony_sim_get_icc_id()
     {
    -   telephony_error_e ret;
    -   char *iccid;
    -   ret = telephony_sim_get_icc_id(handle_list.handle[0], &iccid);
    -   if (ret == TELEPHONY_ERROR_NONE) 
    -      dlog_print(DLOG_INFO, LOG_TAG, "Integrated Circuit Card IDentification: %s", iccid);
    -   free(iccid);
    -
    -   return ret;
    +    telephony_error_e ret;
    +    char *iccid;
    +    ret = telephony_sim_get_icc_id(handle_list.handle[0], &iccid);
    +    if (ret == TELEPHONY_ERROR_NONE)
    +        dlog_print(DLOG_INFO, LOG_TAG, "Integrated Circuit Card IDentification: %s", iccid);
    +    free(iccid);
    +
    +    return ret;
     }
     
    @@ -445,17 +426,18 @@ tutorial_telephony_sim_get_icc_id() void tutorial_telephony_network_get_service_state() { -   telephony_network_service_state_e network_service_state; -   int ret; -   ret = telephony_network_get_service_state(handle_list.handle[0], &network_service_state); -   if (ret != TELEPHONY_ERROR_NONE) -   { -      // Error handling -      return -1; -   } -   dlog_print(DLOG_INFO, LOG_TAG, "Network Service State [%d]", network_service_state); - -   return 0; +    telephony_network_service_state_e network_service_state; +    int ret; +    ret = telephony_network_get_service_state(handle_list.handle[0], &network_service_state); +    if (ret != TELEPHONY_ERROR_NONE) +    { +        /* Error handling */ + +        return -1; +    } +    dlog_print(DLOG_INFO, LOG_TAG, "Network Service State [%d]", network_service_state); + +    return 0; } @@ -463,29 +445,27 @@ tutorial_telephony_network_get_service_state()

    To receive notifications of network service state changes asynchronously, register a callback with the telephony_set_noti_cb() function. The callback returns the service state in its third parameter.

    You have to register the callback separately for each service state (for example, Cell ID, RSSI level, network name, PS type, default data subscription, default subscription, or roaming state), using the applicable TELEPHONY_NOTI_NETWORK_XXX notification value in the second parameter of the telephony_set_noti_cb() function. The available values are defined in the telephony_noti_e enumerator (in mobile and wearable applications).

    -

    When the notifications are no longer needed, unregister the callback for each service state with the telephony_unset_noti_cb() function by passing the notification ID as a parameter.

    +

    When the notifications are no longer needed, deregister the callback for each service state with the telephony_unset_noti_cb() function by passing the notification ID as a parameter.

    The following example registers a callback for the network service states:

    -void 
    +void
     network_service_state_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void* user_data)
     {
    -   telephony_network_service_state_e network_state = *(int *)data;
    -   dlog_print(DLOG_INFO, LOG_TAG, "Network service state: [%d]", network_state);
    +    telephony_network_service_state_e network_state = *(int *)data;
    +    dlog_print(DLOG_INFO, LOG_TAG, "Network service state: [%d]", network_state);
     }
     
    -void 
    +void
     tutorial_telephony_set_noti_cb_network()
     {
    -   telephony_error_e ret;
    -   ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SERVICE_STATE,
    -         network_service_state_noti_cb, NULL);
    -   if (ret != TELEPHONY_ERROR_NONE) 
    -   {
    -      // Error handling
    -   }
    -
    -   return 0;
    +    telephony_error_e ret;
    +    ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SERVICE_STATE,
    +                                network_service_state_noti_cb, NULL);
    +    if (ret != TELEPHONY_ERROR_NONE)
    +        /* Error handling */
    +
    +    return 0;
     }
     
    @@ -496,31 +476,31 @@ tutorial_telephony_set_noti_cb_network()

    For example, to get the cell ID and MNC information:

    -// Cell ID
    -void 
    +/* Cell ID */
    +void
     tutorial_telephony_network_get_cell_id()
     {
    -   telephony_error_e ret;
    -   int cell_id;
    -   ret = telephony_network_get_cell_id(handle_list.handle[0], &cell_id);
    -   if (ret == TELEPHONY_ERROR_NONE) 
    -      dlog_print(DLOG_INFO, LOG_TAG, "Cell Id: %d", cell_id);
    +    telephony_error_e ret;
    +    int cell_id;
    +    ret = telephony_network_get_cell_id(handle_list.handle[0], &cell_id);
    +    if (ret == TELEPHONY_ERROR_NONE)
    +        dlog_print(DLOG_INFO, LOG_TAG, "Cell Id: %d", cell_id);
     
    -   return ret;
    +    return ret;
     }
     
    -// MNC
    -void 
    +/* MNC */
    +void
     tutorial_telephony_network_get_mnc()
     {
    -   telephony_error_e ret;
    -   char *mnc;
    -   ret = telephony_network_get_mnc(handle_list.handle[0], &mnc);
    -   if (ret == TELEPHONY_ERROR_NONE) 
    -      dlog_print(DLOG_INFO, LOG_TAG, "mnc: %s", mnc);
    -   free(mnc);
    -
    -   return ret;
    +    telephony_error_e ret;
    +    char *mnc;
    +    ret = telephony_network_get_mnc(handle_list.handle[0], &mnc);
    +    if (ret == TELEPHONY_ERROR_NONE)
    +        dlog_print(DLOG_INFO, LOG_TAG, "mnc: %s", mnc);
    +    free(mnc);
    +
    +    return ret;
     }
     
    @@ -532,17 +512,17 @@ tutorial_telephony_network_get_mnc()

    For example, to get IMEI information:

    -void 
    +void
     tutorial_telephony_modem_get_imei()
     {
    -   telephony_error_e ret;
    -   char *imei;
    -   ret = telephony_modem_get_imei(handle_list.handle[0], &imei);
    -   if (ret == TELEPHONY_ERROR_NONE) 
    -      dlog_print(DLOG_INFO, LOG_TAG, "imei: %s", imei);
    -   free(imei);
    -
    -   return ret;
    +    telephony_error_e ret;
    +    char *imei;
    +    ret = telephony_modem_get_imei(handle_list.handle[0], &imei);
    +    if (ret == TELEPHONY_ERROR_NONE)
    +        dlog_print(DLOG_INFO, LOG_TAG, "imei: %s", imei);
    +    free(imei);
    +
    +    return ret;
     }
     
    diff --git a/org.tizen.tutorials/html/native/telephony/telephony_tutorials_n.htm b/org.tizen.tutorials/html/native/telephony/telephony_tutorials_n.htm index 424cfac..7675c79 100644 --- a/org.tizen.tutorials/html/native/telephony/telephony_tutorials_n.htm +++ b/org.tizen.tutorials/html/native/telephony/telephony_tutorials_n.htm @@ -35,16 +35,12 @@

    The telephony tutorials demonstrate how to manage phone numbers and various information related to the Telephony Service:

    -

    The following tutorials apply in mobile applications only:

    - - diff --git a/org.tizen.tutorials/html/native/tutorials_n.htm b/org.tizen.tutorials/html/native/tutorials_n.htm index 60452bc..88f64cc 100644 --- a/org.tizen.tutorials/html/native/tutorials_n.htm +++ b/org.tizen.tutorials/html/native/tutorials_n.htm @@ -38,6 +38,8 @@

    Select the API domain you are interested in and see how you can implement its various functionalities into your application:

    diff --git a/org.tizen.tutorials/html/native/ui/eom_tutorial_n.htm b/org.tizen.tutorials/html/native/ui/eom_tutorial_n.htm index 660b992..6eefe34 100644 --- a/org.tizen.tutorials/html/native/ui/eom_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/ui/eom_tutorial_n.htm @@ -63,7 +63,9 @@

    To initialize EOM:

    1. To use the functions and data types of the External Output Manager API, include the <eom.h> header file in your application: -
      #include <eom.h>
      +
      +#include <eom.h>
      +
    2. Initialize the application with the eom_init() function.
    @@ -72,48 +74,41 @@

    To retrieve the output ID, use the eom_get_eom_output_ids() function. You need the ID to get information about the output device and to control the external window.

    -int 
    +int
     sample_get_output_id(const char *output_name)
     {
    -   eom_output_id *output_ids = NULL;
    -   eom_output_id output_id = 0;
    -   eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
    -   int id_cnt = 0;
    -   int i;
    -
    -   output_ids = eom_get_eom_output_ids(&id_cnt);
    -   if (id_cnt == 0)
    -   {
    -      printf ("no external outputs supported\n");
    -
    -      return 0;
    -   }
    -
    -   for (i = 0; i < id_cnt; i++)
    -   {
    -      eom_get_output_type(output_ids[i], &output_type);
    -      if (!strncmp(output_name, "HDMI", 4))
    -      {
    -         if (output_type == EOM_OUTPUT_TYPE_HDMIA || output_type == EOM_OUTPUT_TYPE_HDMIB)
    -         {
    -            output_id = output_ids[i];
    -            break;
    -         }
    -      }
    -      else if (!strncmp(output_name, "Virtual", 7))
    -      {
    -         if (output_type == EOM_OUTPUT_TYPE_VIRTUAL)
    -         {
    -            output_id = output_ids[i];
    -            break;
    -         }
    -      }
    -   }
    -
    -   if (output_ids)
    -      free(output_ids);
    -
    -   return output_id;
    +    eom_output_id *output_ids = NULL;
    +    eom_output_id output_id = 0;
    +    eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
    +    int id_cnt = 0;
    +    int i;
    +
    +    output_ids = eom_get_eom_output_ids(&id_cnt);
    +    if (id_cnt == 0) {
    +        printf ("no external outputs supported\n");
    +
    +        return 0;
    +    }
    +
    +    for (i = 0; i < id_cnt; i++) {
    +        eom_get_output_type(output_ids[i], &output_type);
    +        if (!strncmp(output_name, "HDMI", 4)) {
    +            if (output_type == EOM_OUTPUT_TYPE_HDMIA || output_type == EOM_OUTPUT_TYPE_HDMIB) {
    +                output_id = output_ids[i];
    +                break;
    +            }
    +        } else if (!strncmp(output_name, "Virtual", 7)) {
    +            if (output_type == EOM_OUTPUT_TYPE_VIRTUAL) {
    +                output_id = output_ids[i];
    +                break;
    +            }
    +        }
    +    }
    +
    +    if (output_ids)
    +        free(output_ids);
    +
    +    return output_id;
     }
     
    @@ -123,25 +118,24 @@ sample_get_output_id(const char *output_name)

    To connect to an external output device in the presentation mode, use the eom_set_output_attribute() function to set the presentation mode priority attribute.

    If the setting is successful, the External Output Manager module uses the presentation mode when the external output device connected.

    -int 
    +int
     set_attribute()
     {
    -   m_output_id output_id = 0;
    -   int ret;
    +    m_output_id output_id = 0;
    +    int ret;
     
    -   output_id = sample_get_output_id("HDMI");
    +    output_id = sample_get_output_id("HDMI");
     
    -   ret = eom_set_output_attribute(output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL);
    -   if (ret != EOM_ERROR_NONE) 
    -   {
    -      // Attribute setting failed, the external output device cannot be used
    -      // Deinitializing
    -      eom_deinit();
    +    ret = eom_set_output_attribute(output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL);
    +    if (ret != EOM_ERROR_NONE) {
    +        /* Attribute setting failed, the external output device cannot be used */
    +        /* Deinitializing */
    +        eom_deinit();
     
    -      return -1;
    -   }
    +        return -1;
    +    }
     
    -   return 0;
    +    return 0;
     }
     
    @@ -152,19 +146,18 @@ set_attribute()

    To set an external window, use the eom_set_output_window() function. This function moves the window to the external output and automatically resizes it to the best resolution of the external output device.

    Before calling this function, you must receive a success return from the eom_set_output_attribute() function.

    -int 
    +int
     make_external_window()
     {
    -   Evas_Object *window;
    -   window = elm_win_add(NULL, "external_window", ELM_WIN_BASIC);
    -   if (eom_set_output_window(output_id, window) == EOM_ERROR_NONE)
    -      return 0;
    -   else
    -   {
    -      evas_object_del(window);
    -
    -      return -1;
    -   }
    +    Evas_Object *window;
    +    window = elm_win_add(NULL, "external_window", ELM_WIN_BASIC);
    +    if (eom_set_output_window(output_id, window) == EOM_ERROR_NONE) {
    +        return 0;
    +    } else {
    +        evas_object_del(window);
    +
    +        return -1;
    +    }
     }
     
    @@ -194,76 +187,67 @@ make_external_window()
    1. Define the callbacks for various state changes:
      -typedef struct
      -{
      -   Evas_Object *external_window;
      -   int output_id;
      -} SampleInfo;
      +struct _SampleInfo {
      +    Evas_Object *external_window;
      +    int output_id;
      +};
      +typedef struct _SampleInfo SampleInfo;
       
      -// Triggered when the external output is connected
      +/* Triggered when the external output is connected */
       static void
       sample_notify_cb_output_add(eom_output_id output_id, void *user_data)
       {
      -   SampleInfo *info = (SampleInfo*)user_data;
      -   if (!info->external_window)
      -   {
      -      // Create the external window
      -      make_external_window(info->external_window);
      -   }
      +    SampleInfo *info = (SampleInfo*)user_data;
      +    if (!info->external_window) {
      +        /* Create the external window */
      +        make_external_window(info->external_window);
      +    }
       }
       
      -// Triggered when the external output is disconnected
      +/* Triggered when the external output is disconnected */
       static void
       sample_notify_cb_output_remove(eom_output_id output_id, void *user_data)
       {
      -   SampleInfo *info = (SampleInfo*)user_data;
      -   if (!info->external_window)
      -   {
      -      evas_object_del(info->external_window)
      -      info->external_window = NULL;
      -   }
      +    SampleInfo *info = (SampleInfo*)user_data;
      +    if (!info->external_window) {
      +        evas_object_del(info->external_window)
      +        info->external_window = NULL;
      +    }
       }
       
      -// Triggered when the state of the EOM output attribute changes
      +/* Triggered when the state of the EOM output attribute changes */
       static void
       sample_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
       {
      -   SampleInfo *info = (SampleInfo*)user_data;
      -   eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
      -   eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
      -   
      -   eom_get_output_attribute(output_id, &attribute);
      -   eom_get_output_attribute_state(output_id, &state);
      -   
      -   if (state == EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE)
      -   {
      -      // Start displaying the image to the external output (info->external_window);
      -   }
      -   else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE)
      -   {
      -      // Stop displaying the image
      -      // Destroy the external_window
      -      if (info->external_window)
      -      {
      -         evas_object_del(info->external_window);
      -         info->external_window = NULL;
      -      }
      -   }
      -   else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST)
      -   {
      -      // Stop displaying the image
      -      // Destroy the external_window
      -      if (info->external_window)
      -      {
      -         evas_object_del(info->external_window);
      -         info->external_window = NULL;
      -      }
      -      // Remove the callbacks
      -      eom_unset_output_added_cb(sample_notify_cb_output_add);
      -      eom_unset_output_removed_cb(sample_notify_cb_output_remove);
      -      eom_unset_attribute_changed_cb(sample_notify_cb_attribute_changed);
      -      eom_deinit ();
      -   }
      +    SampleInfo *info = (SampleInfo*)user_data;
      +    eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
      +    eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
      +
      +    eom_get_output_attribute(output_id, &attribute);
      +    eom_get_output_attribute_state(output_id, &state);
      +
      +    if (state == EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE) {
      +        /* Start displaying the image to the external output (info->external_window); */
      +    } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE) {
      +        /* Stop displaying the image */
      +        /* Destroy the external_window */
      +        if (info->external_window) {
      +            evas_object_del(info->external_window);
      +            info->external_window = NULL;
      +        }
      +    } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST) {
      +        /* Stop displaying the image */
      +        /* Destroy the external_window */
      +        if (info->external_window) {
      +            evas_object_del(info->external_window);
      +            info->external_window = NULL;
      +        }
      +        /* Remove the callbacks */
      +        eom_unset_output_added_cb(sample_notify_cb_output_add);
      +        eom_unset_output_removed_cb(sample_notify_cb_output_remove);
      +        eom_unset_attribute_changed_cb(sample_notify_cb_attribute_changed);
      +        eom_deinit();
      +    }
       }
       
      @@ -272,53 +256,49 @@ sample_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
    2. Register the callbacks:
      -int 
      +int
       elm_main()
       {
      -   SampleInfo *info;
      -   eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
      -   int ret;
      -   
      -   info = calloc(sizeof(SampleInfo));
      -   
      -   eom_init();
      -   info->output_id = sample_get_output_id("HDMI");
      -   
      -   ret = eom_set_output_attribute(info->hdmi_output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL);
      -   if (ret != EOM_ERROR_NONE)
      -   {
      -      // Cannot use the external output device
      -      eom_deinit();
      -   }
      -   else
      -   {
      -      eom_get_output_mode(info->output_id, &output_mode);
      -      if (output_mode != EOM_OUTPUT_MODE_NONE)
      -      {
      -         // Create the external window
      -         make_external_window(info->external_window);
      -      }
      -
      -      // Add the callbacks
      -      eom_set_output_added_cb(sample_notify_cb_output_add, info);
      -      eom_set_output_removed_cb(sample_notify_cb_output_remove, info);
      -      eom_set_attribute_changed_cb(sample_notify_cb_attribute_changed, info);
      -   }
      -   
      -   elm_run();
      +    SampleInfo *info;
      +    eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
      +    int ret;
      +
      +    info = calloc(sizeof(SampleInfo));
      +
      +    eom_init();
      +    info->output_id = sample_get_output_id("HDMI");
      +
      +    ret = eom_set_output_attribute(info->hdmi_output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL);
      +    if (ret != EOM_ERROR_NONE) {
      +        /* Cannot use the external output device */
      +        eom_deinit();
      +    } else {
      +        eom_get_output_mode(info->output_id, &output_mode);
      +        if (output_mode != EOM_OUTPUT_MODE_NONE) {
      +            /* Create the external window */
      +            make_external_window(info->external_window);
      +        }
      +
      +        /* Add the callbacks */
      +        eom_set_output_added_cb(sample_notify_cb_output_add, info);
      +        eom_set_output_removed_cb(sample_notify_cb_output_remove, info);
      +        eom_set_attribute_changed_cb(sample_notify_cb_attribute_changed, info);
      +    }
      +
      +    elm_run();
       

      To register the eom_mode_change_cb callback, use the eom_set_mode_changed_cb() function.

    3. When no longer needed, delete the callbacks:
      -   eom_unset_output_added_cb(sample_notify_cb_output_add);
      -   eom_unset_output_removed_cb(sample_notify_cb_output_remove);
      -   eom_unset_attribute_changed_cb(sample_notify_cb_attribute_changed);
      -   eom_deinit();
      -   elm_shutdown();
      +    eom_unset_output_added_cb(sample_notify_cb_output_add);
      +    eom_unset_output_removed_cb(sample_notify_cb_output_remove);
      +    eom_unset_attribute_changed_cb(sample_notify_cb_attribute_changed);
      +    eom_deinit();
      +    elm_shutdown();
       
      -   return 0;
      +    return 0;
       }
       
      diff --git a/org.tizen.tutorials/html/native/ui/minicontrol_tutorial_n.htm b/org.tizen.tutorials/html/native/ui/minicontrol_tutorial_n.htm index 6f0ef51..22d1abc 100644 --- a/org.tizen.tutorials/html/native/ui/minicontrol_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/ui/minicontrol_tutorial_n.htm @@ -107,11 +107,11 @@ evas_object_smart_callback_add(button, "clicked", _button_clicked_cb,

      Define the callback function for hiding the quick panel:

      -static void 
      +static void
       _button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
       {
      -   Evas_Object *win = data;
      -   minicontrol_send_event(win, MINICONTROL_PROVIDER_EVENT_REQUEST_HIDE, NULL);
      +    Evas_Object *win = data;
      +    minicontrol_send_event(win, MINICONTROL_PROVIDER_EVENT_REQUEST_HIDE, NULL);
       }
       
    diff --git a/org.tizen.tutorials/html/native/uix/ime_tutorial_n.htm b/org.tizen.tutorials/html/native/uix/ime_tutorial_n.htm index 7b50fc1..a16e7e6 100644 --- a/org.tizen.tutorials/html/native/uix/ime_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/uix/ime_tutorial_n.htm @@ -23,7 +23,8 @@

    Content

    - +

    Prerequisites

    + +

    To use the Input Method Manager API, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

    +
    +<privileges>
    +   <privilege>http://tizen.org/privilege/imemanager</privilege>
    +</privileges>
    +
    +

    Starting the IME Life-cycle

    To start the IME application life-cycle:

      @@ -104,79 +113,79 @@ static void terminate(void *user_data); static void show(int context_id, ime_context_h context, void *user_data); static void hide(int context_id, void *user_data); -void +void ime_app_main(int argc, char **argv) { -   ime_callback_s basic_callback = -   { -      create, // When the input panel is created -      terminate, // When the input panel is terminated -      show, // When the input panel is shown -      hide, // When the input panel is hidden -   }; - -   ime_run(&basic_callback, NULL); +    ime_callback_s basic_callback = +    { +        create, /* When the input panel is created */ +        terminate, /* When the input panel is terminated */ +        show, /* When the input panel is shown */ +        hide, /* When the input panel is hidden */ +    }; + +    ime_run(&basic_callback, NULL); }
    1. Define the callbacks:
      -static void 
      +static void
       create(void *user_data)
       {
      -   int portrait_w, portrait_h, landscape_w, landscape_h;
      -   Evas_Object *ime_win = ime_get_main_window();
      +    int portrait_w, portrait_h, landscape_w, landscape_h;
      +    Evas_Object *ime_win = ime_get_main_window();
       
      -   // Update IME size information 
      -   ime_set_size(portrait_w, portrait_h, landscape_w, landscape_h);
      +    /* Update IME size information */
      +    ime_set_size(portrait_w, portrait_h, landscape_w, landscape_h);
       
      -   // Create or initialize resources
      +    /* Create or initialize resources */
       }
       
      -static void 
      +static void
       terminate(void *user_data)
       {
      -   // Release the resources
      +    /* Release the resources */
       }
       
      -static void 
      +static void
       show(int context_id, ime_context_h context, void *user_data)
       {
      -   Ecore_IMF_Input_Panel_Layout layout;
      -   ime_layout_variation_e layout_variation;
      -   int cursor_pos;
      -   Ecore_IMF_Autocapital_Type autocapital_type;
      -   Ecore_IMF_Input_Panel_Return_Key_Type return_key_type;
      -   bool return_key_state, prediction_mode, password_mode;
      -   Ecore_IMF_Input_Hints input_hint;
      -   Ecore_IMF_BiDi_Direction bidi;
      -   Ecore_IMF_Input_Panel_Lang language;
      -
      -   Evas_Object *ime_win = ime_get_main_window();
      -
      -   ime_context_get_layout(context, &layout);
      -   ime_context_get_layout_variation(context, &layout_variation);
      -   // Draw the proper layout 
      -
      -   ime_context_get_autocapital_type(context, &autocapital_type);
      -   ime_context_get_cursor_position(context, &cursor_pos);
      -   // Draw the capital or small characters accordingly
      -
      -   ime_context_get_return_key_type(context, &return_key_type);
      -   ime_context_get_return_key_state(context, &return_key_state);
      -   // Draw the proper Return key
      -
      -   // Show the IME window
      -   evas_object_show(ime_win);
      +    Ecore_IMF_Input_Panel_Layout layout;
      +    ime_layout_variation_e layout_variation;
      +    int cursor_pos;
      +    Ecore_IMF_Autocapital_Type autocapital_type;
      +    Ecore_IMF_Input_Panel_Return_Key_Type return_key_type;
      +    bool return_key_state, prediction_mode, password_mode;
      +    Ecore_IMF_Input_Hints input_hint;
      +    Ecore_IMF_BiDi_Direction bidi;
      +    Ecore_IMF_Input_Panel_Lang language;
      +
      +    Evas_Object *ime_win = ime_get_main_window();
      +
      +    ime_context_get_layout(context, &layout);
      +    ime_context_get_layout_variation(context, &layout_variation);
      +    /* Draw the proper layout */
      +
      +    ime_context_get_autocapital_type(context, &autocapital_type);
      +    ime_context_get_cursor_position(context, &cursor_pos);
      +    /* Draw the capital or small characters accordingly */
      +
      +    ime_context_get_return_key_type(context, &return_key_type);
      +    ime_context_get_return_key_state(context, &return_key_state);
      +    /* Draw the proper Return key */
      +
      +    /* Show the IME window */
      +    evas_object_show(ime_win);
       }
       
      -static void 
      +static void
       hide(int context_id, void *user_data)
       {
      -   Evas_Object *ime_win = ime_get_main_window();
      +    Evas_Object *ime_win = ime_get_main_window();
       
      -   // Hide the IME window
      -   evas_object_hide(ime_win);
      +    /* Hide the IME window */
      +    evas_object_hide(ime_win);
       }
       

      In the show() callback, the IME application can get the contextual information from an associated text input UI control to configure the keyboard state and look accordingly. The contextual information of each input UI control is provided through the ime_context_get_XXX() functions defined in the inputmethod.h header file.

      @@ -194,19 +203,19 @@ static int focus_in(int context_id, void *user_data); static int focus_out(int context_id, void *user_data); static int cursor_position_updated(int cursor_pos, void *user_data); -void +void ime_app_main(int argc, char **argv) { -   ime_callback_s basic_callback = -   { -      // Add the mandatory callbacks -   }; - -   ime_event_set_focus_in_cb(focus_in, NULL); -   ime_event_set_focus_out_cb(focus_out, NULL); -   ime_event_set_cursor_position_updated_cb(cursor_position_updated, NULL); - -   ime_run(&basic_callback, NULL); +    ime_callback_s basic_callback = +    { +        /* Add the mandatory callbacks */ +    }; + +    ime_event_set_focus_in_cb(focus_in, NULL); +    ime_event_set_focus_out_cb(focus_out, NULL); +    ime_event_set_cursor_position_updated_cb(cursor_position_updated, NULL); + +    ime_run(&basic_callback, NULL); }
    2. @@ -215,28 +224,28 @@ ime_app_main(int argc, char **argv)
    3. The focus_in() callback is triggered when an associated text input UI control in any application gets the focus. Usually, the focus_in() event is followed by the show() event.
      -static int 
      +static int
       focus_in(int context_id, void *user_data)
       {
      -   // Take action
      +    /* Take action */
       }
       
    4. The focus_out() callback is triggered when an associated text input UI control in any application loses the focus. Usually, the focus_out() event is followed by the hide() event.
      -static int 
      +static int
       focus_out(int context_id, void *user_data)
       {
      -   // Take action
      +    /* Take action */
       }
       
    5. The cursor_position_updated() callback is triggered when the position of the cursor in an associated text input UI control changes. You can use this callback to provide, for example, auto-capitalization or predictive text features.
      -static int 
      +static int
       cursor_position_updated(int cursor_pos, void *user_data)
       {
      -   // Take action
      +    /* Take action */
       }
       
    6. @@ -254,18 +263,18 @@ cursor_position_updated(int cursor_pos, void *user_data) static void option_window_created(Evas_Object *window, ime_option_window_type_e type, void *user_data); static void option_window_destroyed(Evas_Object *window, void *user_data); -void +void ime_app_main(int argc, char **argv) { -   ime_callback_s basic_callback = -   { -      // Add the mandatory callbacks -   }; +    ime_callback_s basic_callback = +    { +        /* Add the mandatory callbacks */ +    }; -   ime_event_set_option_window_created_cb(option_window_created, NULL); -   ime_event_set_option_window_destroyed_cb(option_window_destroyed, NULL); +    ime_event_set_option_window_created_cb(option_window_created, NULL); +    ime_event_set_option_window_destroyed_cb(option_window_destroyed, NULL); -   ime_run(&basic_callback, NULL); +    ime_run(&basic_callback, NULL); } @@ -274,13 +283,13 @@ ime_app_main(int argc, char **argv)
    7. The device Settings application can open the keyboard option menu from Settings > Language and input > Keyboard > Keyboard settings.

      If the user selects the keyboard settings, the option_window_created() callback is executed:

      -static void 
      +static void
       option_window_created(Evas_Object *window, ime_option_window_type_e type, void *user_data)
       {
      -   // Create the option window
      -   // Draw the content to the given window object
      +    /* Create the option window */
      +    /* Draw the content to the given window object */
       
      -   evas_object_show(window);
      +    evas_object_show(window);
       }
       
    8. @@ -289,11 +298,11 @@ option_window_created(Evas_Object *window, ime_option_window_type_e type, void *

      If the user clicks the key button, you can use the ime_create_option_window() function in the button click callback to open the option menu:

      -static void 
      +static void
       _clicked(void *data, Evas_Object *obj, void *event_info)
       {
      -   // Open the IME option menu window
      -   ime_create_option_window();
      +    /* Open the IME option menu window */
      +    ime_create_option_window();
       }
       

      The ime_create_option_window() function call triggers the option_window_created() callback, in which you can draw the option menu content on the given window.

      @@ -301,11 +310,11 @@ _clicked(void *data, Evas_Object *obj, void *event_info)
    9. To close the option menu, call the ime_destroy_option_window() function. The function call triggers the option_window_destroyed() callback:
      -static void 
      +static void
       option_window_destroyed(Evas_Object *window, void *user_data)
       {
      -   // Destroy the option window
      -   // Release the resources
      +    /* Destroy the option window */
      +    /* Release the resources */
       }
       
    10. @@ -317,19 +326,19 @@ option_window_destroyed(Evas_Object *window, void *user_data)
      1. To use the functions and data types of the Input Method Manager API, include the <inputmethod_manager.h> header file in your application: -
        #include <inputmethod_manager.h>
        +
        +#include <inputmethod_manager.h>
        +
      2. -
      3. Add the http://tizen.org/privilege/imemanager privilege to the application manifest file.
      4. Open the IME list menu with the ime_manager_show_ime_list() function:
        -void show_ime_list() 
        +void
        +show_ime_list()
         {
        -   int ret = ime_manager_show_ime_list();
        -   if (IME_MANAGER_ERROR_NONE != ret) 
        -   {
        -      // Error handling
        -   }
        +    int ret = ime_manager_show_ime_list();
        +    if (IME_MANAGER_ERROR_NONE != ret)
        +        /* Error handling */
         }
         
        @@ -342,19 +351,19 @@ void show_ime_list()
        1. To use the functions and data types of the Input Method Manager API, include the <inputmethod_manager.h> header file in your application: -
          #include <inputmethod_manager.h>
          +
          +#include <inputmethod_manager.h>
          +
        2. -
        3. Add the http://tizen.org/privilege/imemanager privilege to the application manifest file.
        4. Open the IME selector menu with the ime_manager_show_ime_selector() function:
          -void show_ime_selector() 
          +void
          +show_ime_selector()
           {
          -   int ret = ime_manager_show_ime_selector();
          -   if (IME_MANAGER_ERROR_NONE != ret) 
          -   {
          -      // Error handling
          -   }
          +    int ret = ime_manager_show_ime_selector();
          +    if (IME_MANAGER_ERROR_NONE != ret)
          +        /* Error handling */
           }
           
          @@ -366,20 +375,18 @@ void show_ime_selector()

          To check the current default keyboard or whether a specific IME is enabled or to get the number of IMEs which are enabled (usable):

            -
          1. Add the http://tizen.org/privilege/imemanager privilege to the application manifest file.
          2. To check whether a specific IME is enabled, call the ime_manager_is_ime_enabled() function. The first parameter is the application ID of the IME whose status you want to check.
            -boolean is_ime_enabled(const char *app_id) 
            +boolean
            +is_ime_enabled(const char *app_id)
             {
            -   boolean enabled = false;
            -   int ret = ime_manager_is_ime_enabled(app_id, &enabled);
            -   if (IME_MANAGER_ERROR_NONE != ret)
            -   {
            -      // Error handling
            -   }
            +    boolean enabled = false;
            +    int ret = ime_manager_is_ime_enabled(app_id, &enabled);
            +    if (IME_MANAGER_ERROR_NONE != ret)
            +        /* Error handling */
             
            -   return enabled;
            +    return enabled;
             }
             
            @@ -388,17 +395,16 @@ boolean is_ime_enabled(const char *app_id)
          3. To check which IME is currently selected as the default keyboard, call the ime_manager_get_active_ime() function:
            -void get_active_ime()
            +void
            +get_active_ime()
             {
            -   char *app_id = NULL;
            -   int ret = ime_manager_get_active_ime(&app_id);
            -   if (IME_MANAGER_ERROR_NONE != ret) 
            -   {
            -      // Error handling
            -   }
            -   // Take action
            +    char *app_id = NULL;
            +    int ret = ime_manager_get_active_ime(&app_id);
            +    if (IME_MANAGER_ERROR_NONE != ret)
            +        /* Error handling */
            +    /* Take action */
             
            -   free(app_id);
            +    free(app_id);
             }
             
            diff --git a/org.tizen.tutorials/html/native/uix/stt_tutorial_n.htm b/org.tizen.tutorials/html/native/uix/stt_tutorial_n.htm index b7ddac5..9a3e89b 100644 --- a/org.tizen.tutorials/html/native/uix/stt_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/uix/stt_tutorial_n.htm @@ -70,8 +70,9 @@

            To initialize the STT:

            1. To use the functions and data types of the STT (speech-to-text) API (in mobile and wearable applications), include the <stt.h> header file in your application:
              -#include <stt.h>
              -
            2. +#include <stt.h> + +
            3. To use the STT library, create an STT handle.

              The STT handle is used in other STT functions as a parameter. After the handle creation, the STT state changes to STT_STATE_CREATED.

              @@ -87,31 +88,27 @@
              -void 
              +void
               create_stt_handle()
               {
              -   stt_h stt;
              -   int ret;
              -   ret = stt_create(&stt);
              -   if (STT_ERROR_NONE != result)
              -   {
              -      // Error handling
              -   }
              +    stt_h stt;
              +    int ret;
              +    ret = stt_create(&stt);
              +    if (STT_ERROR_NONE != result)
              +        /* Error handling */
               }
               
            4. When you no longer need the STT library, destroy the STT handle using the stt_destroy() function:

              -void 
              +void
               destroy_stt_handle(stt_h stt)
               {
              -   int ret;
              -   ret = stt_destroy(stt); // stt is the STT handle
              -   if (STT_ERROR_NONE != result)
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_destroy(stt); /* stt is the STT handle */
              +    if (STT_ERROR_NONE != result)
              +        /* Error handling */
               }
               
              @@ -139,71 +136,63 @@ destroy_stt_handle(stt_h stt)
            5. State changed

              If you set the state changed callback, it is invoked when the STT state changes.

              -// Callback
              -void 
              +/* Callback */
              +void
               state_changed_cb(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data)
              -{ 
              -   // Your code 
              +{
              +    /* Your code */
               }
               
              -// Set
              -void 
              +/* Set */
              +void
               set_state_changed_cb(stt_h stt)
               {
              -   int ret;
              -   ret = stt_set_state_changed_cb(stt, state_changed_cb, NULL);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling 
              -   }
              +    int ret;
              +    ret = stt_set_state_changed_cb(stt, state_changed_cb, NULL);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -// Unset
              -void 
              +/* Unset */
              +void
               unset_state_changed_cb(stt_h stt)
               {
              -   int ret;
              -   ret = stt_unset_state_changed_cb(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_unset_state_changed_cb(stt);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            6. Default language changed

              The default language of the STT is changed either when the system language is changed, or through the STT settings. To get a notification of a language change, set the default language changed callback:

              -// Callback
              -void 
              +/* Callback */
              +void
               default_language_changed_cb(stt_h stt, const char* previous_language,
                                           const char* current_language, void* user_data)
               {
              -   // Your code 
              +    /* Your code */
               }
               
              -// Set
              -void 
              +/* Set */
              +void
               set_default_language_changed_cb(stt_h stt)
               {
              -   int ret;
              -   ret = stt_set_default_language_changed_cb(stt, default_language_changed_cb, NULL);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_set_default_language_changed_cb(stt, default_language_changed_cb, NULL);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -// Unset
              -void 
              +/* Unset */
              +void
               unset_default_language_changed_cb(stt_h stt)
               {
              -   int ret;
              -   ret = stt_unset_default_language_changed_cb(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_unset_default_language_changed_cb(stt);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            7. @@ -212,51 +201,45 @@ unset_default_language_changed_cb(stt_h stt)

              To get the STT recognition result, set the recognition result callback.

              Within the callback, use the stt_foreach_detailed_result() function to trigger a result time callback that retrieves the time stamp of the current recognition result.

              -// Result time callback
              -bool 
              +/* Result time callback */
              +bool
               result_time_cb(stt_h stt, int index, stt_result_time_event_e event, const char* text,
                              long start_time, long end_time, void* user_data)
               {
              -   // Your code 
              +    /* Your code */
               }
               
              -// Recognition result callback
              -void 
              -recognition_result_cb(stt_h stt, stt_result_event_e event, const char** data, 
              +/* Recognition result callback */
              +void
              +recognition_result_cb(stt_h stt, stt_result_event_e event, const char** data,
                                     int data_count, const char* msg, void* user_data)
               {
              -   // If you want to get time info of result 
              -   int ret;
              -   ret = stt_foreach_detailed_result(stt, result_time_cb, NULL);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              -   // Your code 
              +    /* If you want to get time info of result */
              +    int ret;
              +    ret = stt_foreach_detailed_result(stt, result_time_cb, NULL);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
              +    /* Your code */
               }
               
              -// Set
              -void 
              +/* Set */
              +void
               set_recognition_result_cb(stt_h stt)
               {
              -   int ret;
              -   ret = stt_set_recognition_result_cb(stt, recognition_result_cb, NULL);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_set_recognition_result_cb(stt, recognition_result_cb, NULL);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -// Unset
              -void 
              +/* Unset */
              +void
               unset_recognition_result_cb(stt_h stt)
               {
              -   int ret;
              -   ret = stt_unset_recognition_result_cb(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_unset_recognition_result_cb(stt);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              @@ -264,35 +247,31 @@ unset_recognition_result_cb(stt_h stt)
            8. Error

              When an error occurs, the STT library sends an error message using a callback:

              -// Callback 
              -void 
              +/* Callback */
              +void
               error_cb(stt_h stt, stt_error_e reason, void* user_data)
               {
              -   // Your code 
              +    /* Your code */
               }
               
              -// Set
              -void 
              +/* Set */
              +void
               set_error_cb(stt_h stt)
               {
              -   int ret;
              -   ret = stt_set_error_cb(stt, error_cb, NULL);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_set_error_cb(stt, error_cb, NULL);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -// Unset
              -void 
              +/* Unset */
              +void
               unset_error_cb(stt_h stt)
               {
              -   int ret;
              -   ret = stt_unset_error_cb(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_unset_error_cb(stt);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            9. @@ -304,16 +283,14 @@ unset_error_cb(stt_h stt)
            10. Get the current state using the stt_get_state() function.

              The STT state is changed by various STT functions, and it is applied as a precondition for each function.

              -void 
              +void
               get_state(stt_h stt)
               {
              -   stt_state_e current_state;
              -   int ret;
              -   ret = stt_get_state(stt, &current_state);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    stt_state_e current_state;
              +    int ret;
              +    ret = stt_get_state(stt, &current_state);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            11. @@ -321,23 +298,21 @@ get_state(stt_h stt)
            12. Obtain a list of languages supported by the STT using the stt_foreach_supported_languages() function.

              The foreach function triggers a separate callback for each supported language. As long as the callback returns true, the foreach function continues to loop over the supported languages.

              -bool 
              +bool
               supported_language_cb(stt_h stt, const char* language, void* user_data)
               {
              -   return true; // To continue to get the next supported language 
              +    return true; /* To continue to get the next supported language */
               
              -   return false; // To stop the loop
              +    return false; /* To stop the loop */
               }
               
              -void 
              +void
               get_supported_language(stt_h stt)
               {
              -   int ret;
              -   ret = stt_foreach_supported_languages(stt, supported_language_cb, NULL);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_foreach_supported_languages(stt, supported_language_cb, NULL);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            13. @@ -345,16 +320,14 @@ get_supported_language(stt_h stt)
            14. Get the default language using the stt_get_default_language() function.

              The STT recognition process works for this default language, if you do not set the language as a parameter of the stt_start() function.

              -void 
              +void
               get_default_language(stt_h stt)
               {
              -   int ret;
              -   char* default_lang = NULL;
              -   ret = stt_get_default_language(stt, &default_lang);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    char* default_lang = NULL;
              +    ret = stt_get_default_language(stt, &default_lang);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               

              You can get a notification about the default language changes by setting a default language changed callback.

              @@ -363,24 +336,22 @@ get_default_language(stt_h stt)
            15. Obtain a list of engines supported by the STT using the stt_foreach_supported_engines() function.

              The foreach function triggers a separate callback for each supported engine. As long as the callback returns true, the foreach function continues to loop over the supported engines.

              -bool 
              +bool
               supported_engine_cb(stt_h stt, const char* engine_id, const char* engine_name,
                                   void* user_data)
               {
              -   return true; // To continue to get the next supported engine 
              +    return true; /* To continue to get the next supported engine */
               
              -   return false; // To stop the loop
              +    return false; /* To stop the loop */
               }
               
              -void 
              +void
               get_supported_engine(stt_h stt)
               {
              -   int ret;
              -   ret = stt_foreach_supported_engines(stt, supported_engine_cb, NULL);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_foreach_supported_engines(stt, supported_engine_cb, NULL);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            16. @@ -388,29 +359,25 @@ get_supported_engine(stt_h stt)
            17. Get or set the current engine for the STT recognition using the stt_set_engine() and stt_get_engine() functions.

              The supported language, silence detection, and supported recognition types depend on the STT engine.

              -// Get the engine 
              -void 
              +/* Get the engine */
              +void
               get_current_engine(stt_h stt)
               {
              -   int ret;
              -   char* current_engine_id = NULL;
              -   ret = stt_get_engine(stt, &current_engine_id);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    char* current_engine_id = NULL;
              +    ret = stt_get_engine(stt, &current_engine_id);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -// Set the engine 
              -void 
              +/* Set the engine */
              +void
               set_current_engine(stt_h stt, const char* engine_id)
               {
              -   int ret;
              -   ret = stt_set_engine(stt, engine_id);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_set_engine(stt, engine_id);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            18. @@ -418,18 +385,16 @@ set_current_engine(stt_h stt, const char* engine_id)
            19. Check whether a recognition type defined in the <stt.h> header file is supported by the current engine.

              The normal recognition type, STT_RECOGNITION_TYPE_FREE, means that the whole recognition result is sent at the end of the recognition process. The STT_RECOGNITION_TYPE_FREE_PARTIAL recognition type is used to get a partial recognition result.

              -void 
              +void
               check_supported_recognition_type(stt_h stt)
               {
              -   int ret;
              -   bool support;
              -   ret = stt_is_recognition_type_supported(stt, 
              -                                           STT_RECOGNITION_TYPE_FREE_PARTIAL, 
              -                                           &support);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    bool support;
              +    ret = stt_is_recognition_type_supported(stt,
              +                                            STT_RECOGNITION_TYPE_FREE_PARTIAL,
              +                                            &support);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            20. @@ -443,16 +408,15 @@ check_supported_recognition_type(stt_h stt)

              The function is asynchronous and the STT state changes to STT_STATE_READY.

              -void 
              +void
               prepare_for_stt(stt_h stt)
               {
              -   int ret;
              -   ret = stt_prepare(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              -}
              +    int ret; +    ret = stt_prepare(stt); +    if (STT_ERROR_NONE != ret) +        /* Error handling */ +} +
              @@ -469,16 +433,15 @@ prepare_for_stt(stt_h stt)

              When the connection is no longer needed, use the stt_unprepare() function to disconnect the STT, and change the state to STT_STATE_CREATED:

              -void 
              +void
               unprepared_for_stt(stt_h stt)
               {
              -   int ret;
              -   ret = stt_unprepare(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              -}
              +    int ret; +    ret = stt_unprepare(stt); +    if (STT_ERROR_NONE != ret) +        /* Error handling */ +} + @@ -490,16 +453,14 @@ unprepared_for_stt(stt_h stt)

              After the STT starts recognizing sound, some STT engines can detect silence when the sound input from the user ends. If the silence detection is enabled, the STT library stops recognition automatically and sends the result. Otherwise, you can manually stop the recognition process using the stt_stop() function.

              If you set the silence detection as automatic, STT works according to the global STT setting. This option must be set in the STT_STATE_READY state.

              -void 
              +void
               set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
               {
              -   int ret;
              -   // Default type is STT_OPTION_SILENCE_DETECTION_AUTO 
              -   ret = stt_set_silence_detection(stt, type); 
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    /* Default type is STT_OPTION_SILENCE_DETECTION_AUTO */
              +    ret = stt_set_silence_detection(stt, type);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              @@ -519,26 +480,22 @@ set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
              -void 
              +void
               set_start_sound(stt_h stt, const char* filename)
               {
              -   int ret;
              -   ret = stt_set_start_sound(stt, filename);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_set_start_sound(stt, filename);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -void 
              +void
               unset_start_sound(stt_h stt)
               {
              -   int ret;
              -   ret = stt_unset_start_sound(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_unset_start_sound(stt);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            21. @@ -558,26 +515,22 @@ unset_start_sound(stt_h stt)
              -void 
              +void
               set_stop_sound(stt_h stt, const char* filename)
               {
              -   int ret;
              -   ret = stt_set_stop_sound(stt, filename);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_set_stop_sound(stt, filename);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -void 
              +void
               unset_stop_sound(stt_h stt)
               {
              -   int ret;
              -   ret = stt_unset_stop_sound(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_unset_stop_sound(stt);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              @@ -599,15 +552,13 @@ unset_stop_sound(stt_h stt)

              The language and recognition type must be supported by the current STT engine. If you set NULL as the language parameter, the STT default language is used based on the stt_get_default_language() function.

              -void 
              +void
               start(stt_h stt, const char* language, const char* type)
               {
              -   int ret;
              -   ret = stt_start(stt, language, type); // Default language is NULL
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_start(stt, language, type); /* Default language is NULL */
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              @@ -615,16 +566,14 @@ start(stt_h stt, const char* language, const char* type)
            22. While the STT recording is in process, you can retrieve the current recording volume using the stt_get_recording_volume() function.

              The volume value is retrieved periodically with the short-term recorded sound data as dB (decibels). The STT volume normally has a negative value, and 0 is the maximum value.

              -void 
              +void
               get_volume(stt_h stt)
               {
              -   int ret;
              -   float current_volume;
              -   ret = stt_get_recording_volume(stt, &current_volume);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    float current_volume;
              +    ret = stt_get_recording_volume(stt, &current_volume);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            23. @@ -632,15 +581,13 @@ get_volume(stt_h stt)

              To stop the recording and get the recognition result, use the stt_stop() function.

              The recording stops and the state is changed to STT_STATE_PROCESSING. When the recognition result has been processed, the result is sent in the recognition result callback and the state is changed back to STT_STATE_READY.

              -void 
              +void
               stop(stt_h stt)
               {
              -   int ret;
              -   ret = stt_stop(stt);
              -   if (STT_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_stop(stt);
              +    if (STT_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              @@ -648,15 +595,13 @@ stop(stt_h stt)

              To cancel the recording without getting the result, use the stt_cancel() function.

              The state changes to STT_STATE_READY.

              -void 
              +void
               cancel(stt_h stt)
               {
              -   int ret;
              -   ret = stt_cancel(stt);
              -   if (VC_STATIC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = stt_cancel(stt);
              +    if (VC_STATIC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              diff --git a/org.tizen.tutorials/html/native/uix/tts_tutorial_n.htm b/org.tizen.tutorials/html/native/uix/tts_tutorial_n.htm index 4a42449..cfed190 100644 --- a/org.tizen.tutorials/html/native/uix/tts_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/uix/tts_tutorial_n.htm @@ -85,7 +85,8 @@

              To initialize the TTS:

              1. To use the functions and data types of the TTS (text-to-speech) API (in mobile and wearable applications), include the <tts.h> header file in your application:
                -#include <tts.h>
                +#include <tts.h> +
              2. To use the TTS library, create a TTS handle.

                The TTS handle is used in other TTS functions as a parameter. After the handle creation, the TTS state changes to TTS_STATE_CREATED.

                @@ -102,16 +103,14 @@
                -void 
                +void
                 create_tts_handle()
                 {
                -   tts_h tts;
                -   int ret;
                -   ret = tts_create(&tts);
                -   if (TTS_ERROR_NENE != result)
                -   {
                -      // Error handling
                -   }
                +    tts_h tts;
                +    int ret;
                +    ret = tts_create(&tts);
                +    if (TTS_ERROR_NENE != result)
                +        /* Error handling */
                 }
                 
              3. @@ -120,15 +119,13 @@ create_tts_handle()
                -void 
                +void
                 destroy_tts_handle(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_destroy(tts); // tts is the TTS handle
                -   if (TTS_ERROR_NONE != result)
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_destroy(tts); /* tts is the TTS handle */
                +    if (TTS_ERROR_NONE != result)
                +        /* Error handling */
                 }
                 
                @@ -155,35 +152,31 @@ destroy_tts_handle(tts_h tts)
              4. State changed

                If you set the state change callback, it is invoked when the TTS state changes.

                -// Callback
                -void 
                +/* Callback */
                +void
                 state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data)
                -{ 
                -   // Your code 
                +{
                +    /* Your code */
                 }
                 
                -// Set
                -void 
                +/* Set */
                +void
                 set_state_changed_cb(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_set_state_changed_cb(tts, state_changed_cb, NULL);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_set_state_changed_cb(tts, state_changed_cb, NULL);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_state_changed_cb(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_unset_state_changed_cb(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_unset_state_changed_cb(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              5. @@ -191,36 +184,32 @@ unset_state_changed_cb(tts_h tts)
              6. Default voice changed

                In the TTS library, the voice includes the language used and the voice type, such as male or female. The default voice of the TTS is changed either when the system language is changed, or through the TTS settings. To get a notification of a voice change, set the default voice changed callback:

                -// Callback
                -void 
                +/* Callback */
                +void
                 default_voice_changed_cb(tts_h tts, const char* previous_language, int previous_voice_type,
                                          const char* current_language, int current_voice_type, void* user_data)
                 {
                -   // Your code 
                +    /* Your code */
                 }
                 
                -// Set
                -void 
                +/* Set */
                +void
                 set_default_voice_changed_cb(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_set_default_voice_changed_cb(tts, default_voice_changed_cb, NULL);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_set_default_voice_changed_cb(tts, default_voice_changed_cb, NULL);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_default_language_changed_cb(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_unset_default_voice_changed_cb(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_unset_default_voice_changed_cb(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              7. @@ -228,53 +217,45 @@ unset_default_language_changed_cb(tts_h tts)
              8. Utterance started or completed

                If you add text in the TTS, that text is handled as an utterance and it obtains its own ID. After you request the TTS process to start, the text is synthesized by an engine and played out. To get a notification when an utterance is started or completed, set the respective callbacks:

                -// Started callback
                -void 
                +/* Started callback */
                +void
                 utterance_started_cb(tts_h tts, int utt_id, void* user_data)
                 {
                -   // Your code 
                +    /* Your code */
                 }
                 
                -// Completed callback
                -void 
                +/* Completed callback */
                +void
                 utterance_completed_cb(tts_h tts, int utt_id, void* user_data)
                 {
                -   // Your code 
                +    /* Your code */
                 }
                 
                -// Set
                -void 
                +/* Set */
                +void
                 set_utterance_cb(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_set_utterance_started_cb(tts, utterance_started_cb, NULL);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                -
                -   ret = tts_set_utterance_completed_cb(tts, utterance_completed_cb, NULL);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_set_utterance_started_cb(tts, utterance_started_cb, NULL);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                +
                +    ret = tts_set_utterance_completed_cb(tts, utterance_completed_cb, NULL);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_utterance_cb(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_unset_utterance_started_cb(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                -   ret = tts_unset_utterance_completed_cb(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_unset_utterance_started_cb(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                +    ret = tts_unset_utterance_completed_cb(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              9. @@ -282,35 +263,31 @@ unset_utterance_cb(tts_h tts)
              10. Error

                When an error occurs, the TTS library sends a message using a callback:

                -// Callback
                -void 
                +/* Callback */
                +void
                 error_cb(tts_h tts, int utt_id, tts_error_e reason, void* user_data)
                 {
                -   // Your code 
                +    /* Your code */
                 }
                 
                -// Set
                -void 
                +/* Set */
                +void
                 set_error_cb(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_set_error_cb(tts, error_cb, NULL);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_set_error_cb(tts, error_cb, NULL);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_error_cb(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_unset_error_cb(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_unset_error_cb(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              11. @@ -323,16 +300,14 @@ unset_error_cb(tts_h tts)
              12. Get the current state using the tts_get_state() function.

                The TTS state is changed by various TTS functions, and it is applied as a precondition of each function.

                -void 
                +void
                 get_state(tts_h tts)
                 {
                -   tts_state_e current_state;
                -   int ret;
                -   ret = tts_get_state(tts, &current_state);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    tts_state_e current_state;
                +    int ret;
                +    ret = tts_get_state(tts, &current_state);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              13. @@ -340,23 +315,21 @@ get_state(tts_h tts)
              14. Obtain a list of voices supported by the TTS using the tts_foreach_supported_voices() function.

                The foreach function triggers a separate callback for each supported voice. As long as the callback returns true, the foreach function continues to loop over the supported voices.

                -bool 
                +bool
                 supported_voice_cb(tts_h tts, const char* language, int voice_type, void* user_data)
                 {
                -   return true; // To continue to get the next supported language 
                +    return true; /* To continue to get the next supported language */
                 
                -   return false; // To stop the loop
                +    return false; /* To stop the loop */
                 }
                 
                -void 
                +void
                 get_supported_voice(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_foreach_supported_voices(tts, supported_language_cb, NULL);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_foreach_supported_voices(tts, supported_language_cb, NULL);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              15. @@ -364,17 +337,15 @@ get_supported_voice(tts_h tts)
              16. Get the default voice using the tts_get_default_voice() function.

                The TTS synthesizes the text using the default voice, if you do not set the language and the voice type as parameters of the tts_add_text() function.

                -void 
                +void
                 get_default_voice(tts_h tts)
                 {
                -   int ret;
                -   char* default_lang = NULL;
                -   int default_voice_type;
                -   ret = tts_get_default_voice(tts, &default_lang, &default_voice_type);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    char* default_lang = NULL;
                +    int default_voice_type;
                +    ret = tts_get_default_voice(tts, &default_lang, &default_voice_type);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 

                You can get a notification about the default voice changes by setting a default voice changed callback.

                @@ -398,28 +369,24 @@ get_default_voice(tts_h tts)
                -void 
                +void
                 set_mode(tts_h tts)
                 {
                -   int ret;
                -   tts_mode_e mode = TTS_MODE_DEFAULT;
                -   ret = tts_set_mode(tts, mode);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    tts_mode_e mode = TTS_MODE_DEFAULT;
                +    ret = tts_set_mode(tts, mode);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -void 
                +void
                 get_mode(tts_h tts)
                 {
                -   int ret;
                -   tts_mode_e mode;
                -   ret = tts_get_mode(tts, &mode);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    tts_mode_e mode;
                +    ret = tts_get_mode(tts, &mode);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                @@ -432,16 +399,15 @@ get_mode(tts_h tts)

                The daemon synthesizes the text with the engine and plays the resulting sound data. The function is asynchronous and the TTS state changes to TTS_STATE_READY.

                -void 
                +void
                 prepare_for_tts(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_prepare(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                -}
                +    int ret; +    ret = tts_prepare(tts); +    if (TTS_ERROR_NONE != ret) +        /* Error handling */ +} +
              17. @@ -458,15 +424,13 @@ prepare_for_tts(tts_h tts)
              18. When the connection is no longer needed, use the tts_unprepare() function to disconnect the TTS and change the state to TTS_STATE_CREATED:

                -void 
                +void
                 unprepared_for_tts(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_unprepare(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_unprepare(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              19. @@ -495,21 +459,19 @@ unprepared_for_tts(tts_h tts)

                You can add text at any point after the tts_prepare() function changes the state to TTS_STATE_READY.

                -void 
                +void
                 add_text(tts_h tts)
                 {
                -   const char* text = "tutorial"; // Text for read 
                -   const char* language = "en_US"; // Language 
                -   int voice_type = TTS_VOICE_TYPE_FEMALE; // Voice type 
                -   int speed = TTS_SPEED_AUTO; // Read speed 
                -   int utt_id; // Utterance ID for the requested text
                -
                -   int ret;
                -   ret = tts_add_text(tts, text, language, voice_type, speed, &utt_id);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    const char* text = "tutorial"; /* Text for read */
                +    const char* language = "en_US"; /* Language */
                +    int voice_type = TTS_VOICE_TYPE_FEMALE; /* Voice type */
                +    int speed = TTS_SPEED_AUTO; /* Read speed */
                +    int utt_id; /* Utterance ID for the requested text */
                +
                +    int ret;
                +    ret = tts_add_text(tts, text, language, voice_type, speed, &utt_id);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                @@ -518,16 +480,14 @@ add_text(tts_h tts)

                There is a length limit for the added text in the engine.

                To retrieve the maximum value, use the tts_get_max_text_size() function in the TTS_STATE_READY state:

                -void 
                +void
                 get_maximum_text_size(tts_h tts)
                 {
                -   int ret;
                -   int size;
                -   ret = tts_get_max_text_size(tts, &size);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    int size;
                +    ret = tts_get_max_text_size(tts, &size);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                @@ -554,15 +514,13 @@ get_maximum_text_size(tts_h tts)
                -void 
                +void
                 start(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_play(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_play(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                @@ -570,15 +528,13 @@ start(tts_h tts)

                To pause the playback, use the tts_pause() function.

                The state is changed to TTS_STATE_PAUSED. To resume playback, use the tts_play() function.

                -void 
                +void
                 pause(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_pause(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_pause(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                @@ -586,15 +542,13 @@ pause(tts_h tts)

                To stop the playback, use the tts_stop() function.

                All the texts in the queue are removed, and the state is changed to TTS_STATE_READY.

                -void 
                +void
                 stop(tts_h tts)
                 {
                -   int ret;
                -   ret = tts_stop(tts);
                -   if (TTS_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = tts_stop(tts);
                +    if (TTS_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                diff --git a/org.tizen.tutorials/html/native/uix/voicecontrol_elm_tutorial_n.htm b/org.tizen.tutorials/html/native/uix/voicecontrol_elm_tutorial_n.htm index 9110562..321f877 100644 --- a/org.tizen.tutorials/html/native/uix/voicecontrol_elm_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/uix/voicecontrol_elm_tutorial_n.htm @@ -60,71 +60,63 @@

                To initialize the Voice control elementary library and create a handle:

                1. To use the functions and data types of the Voice control elementary API, include the <voice_control_elm.h> header file in your application: -
                  #include <voice_control_elm.h>
                  +
                  +#include <voice_control_elm.h>
                  +
                2. Initialize the Voice control elementary library with the vc_elm_initialize() function:
                  -void 
                  +void
                   initialize_voice_control_elm()
                   {
                  -   int ret;
                  -   ret = vc_elm_initialize();
                  -   if (VC_ELM_ERROR_NONE != ret)
                  -   {
                  -      // Error handling
                  -   }
                  +    int ret;
                  +    ret = vc_elm_initialize();
                  +    if (VC_ELM_ERROR_NONE != ret)
                  +        /* Error handling */
                   }
                   
                3. Create a handle for each UI component for which you want to set a command and hint.

                  Use the vc_elm_create_object() function to create a handle for Evas_Object instances, and the vc_elm_create_item() function for Elm_Object_Item instances.

                  -void 
                  +void
                   create_vc_elm_handler()
                   {
                  -   int ret;
                  -   vc_elm_h handler_object;
                  -   vc_elm_h handler_item;
                  -	
                  -   // Creating Evas_Object button
                  -   Evas_Object *button = elm_button_add(win);
                  -   ret = vc_elm_create_object(button, &handler_object);
                  -   if (VC_ELM_ERROR_NONE != ret) 
                  -   {
                  -      // Error handling
                  -   }
                  -   // Creating Elm_Object_Item list
                  -   Elm_Object_Item *item = elm_list_item_append(...);
                  -   ret = vc_elm_create_item(item, &handler_item);
                  -   if (VC_ELM_ERROR_NONE != ret) 
                  -   {
                  -      // Error handling
                  -   }
                  +    int ret;
                  +    vc_elm_h handler_object;
                  +    vc_elm_h handler_item;
                  +
                  +    /* Creating Evas_Object button */
                  +    Evas_Object *button = elm_button_add(win);
                  +    ret = vc_elm_create_object(button, &handler_object);
                  +    if (VC_ELM_ERROR_NONE != ret)
                  +        /* Error handling */
                  +    /* Creating Elm_Object_Item list */
                  +    Elm_Object_Item *item = elm_list_item_append(...);
                  +    ret = vc_elm_create_item(item, &handler_item);
                  +    if (VC_ELM_ERROR_NONE != ret)
                  +        /* Error handling */
                   }
                   
                4. When voice control is no longer needed, destroy the handle and deinitialize the library:
                  -void 
                  +void
                   destroy_vc_elm_handler(vc_elm_h &handler)
                   {
                  -   int ret;
                  -   ret = vc_elm_destroy(handler);
                  -   if (VC_ELM_ERROR_NONE != ret) 
                  -   {
                  -      // Error handling
                  -   }
                  +    int ret;
                  +    ret = vc_elm_destroy(handler);
                  +    if (VC_ELM_ERROR_NONE != ret)
                  +        /* Error handling */
                   }
                   
                  -void 
                  +void
                   deinitialize_voice_control_elm()
                   {
                  -   int ret;
                  -   ret = vc_elm_deinitialize();
                  -   if (VC_ELM_ERROR_NONE != ret)
                  -   {
                  -      // Error handling
                  -   }
                  +    int ret;
                  +    ret = vc_elm_deinitialize();
                  +    if (VC_ELM_ERROR_NONE != ret)
                  +        /* Error handling */
                   }
                   
                @@ -137,47 +129,40 @@ deinitialize_voice_control_elm()
              20. Set the language change callback to be invoked when the system or application language changes.

                It is important to track the current language, since you must set the commands and hints accordingly to ensure that the voice commands are recognized correctly.

                -void 
                +void
                 set_language_changed_cb()
                 {
                -   int ret;
                -   ret = vc_elm_set_current_language_changed_cb(language_changed_cb, NULL);
                -   if (VC_ELM_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_elm_set_current_language_changed_cb(language_changed_cb, NULL);
                +    if (VC_ELM_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              21. Define the callback to set the commands and hints according to the current language:
                -void 
                +void
                 language_changed_cb(const char *previous, const char *current, void* user_data)
                -{ 
                -   if ("en_US" == current) 
                -   {
                -      vc_elm_set_command(handler, "button");
                -      vc_elm_set_command_hint(handler, "button");
                -   }
                -   else if ("ko_KR" = current) 
                -   {
                -      vc_elm_set_command(handler, "버튼");
                -      vc_elm_set_command_hint(handler, "버튼");
                -   }
                +{
                +    if ("en_US" == current) {
                +        vc_elm_set_command(handler, "button");
                +        vc_elm_set_command_hint(handler, "button");
                +    } else if ("ko_KR" = current) {
                +        vc_elm_set_command(handler, "버튼");
                +        vc_elm_set_command_hint(handler, "버튼");
                +    }
                 }
                 
              22. When no longer needed, unset the callback:
                -void 
                +void
                 unset_state_changed_cb()
                 {
                -   int ret;
                -   ret = vc_elm_unset_current_language_changed_cb();
                -   if (VC_ELM_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_elm_unset_current_language_changed_cb();
                +    if (VC_ELM_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              @@ -190,87 +175,79 @@ unset_state_changed_cb()
            24. Get the current Voice control elementary language using the vc_elm_get_current_language() function:

              -void 
              +void
               get_language()
               {
              -   char *current_language;
              -   int ret;
              -   ret = vc_elm_get_current_language(&current_language);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    char *current_language;
              +    int ret;
              +    ret = vc_elm_get_current_language(&current_language);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            25. Get the languages supported by the Voice control elementary library with a foreach function that triggers a separate callback for each language.

              As long as the callback returns true, the foreach function continues to loop over the supported languages.

              -bool 
              +bool
               supported_language_cb(const char *language, void* user_data)
               {
              -   return true; // To continue to get the next language
              +    return true; /* To continue to get the next language */
               
              -   return false; // To stop the loop
              +    return false; /* To stop the loop */
               }
               
              -void 
              +void
               set_default_language_changed_cb()
               {
              -   int ret;
              -   ret = vc_elm_foreach_supported_languages(supported_language_cb, NULL);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_elm_foreach_supported_languages(supported_language_cb, NULL);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            26. Get the UI components supported by the Voice control elementary library with a foreach function that triggers a separate callback for each UI component.

              As long as the callback returns true, the foreach function continues to loop over the supported UI components.

              -void 
              +void
               widget_cb(const char *widget, void *user_data)
               {
              -   return true; // To continue to get the next UI component 
              +    return true; /* To continue to get the next UI component */
               
              -   return false; // To stop the loop
              +    return false; /* To stop the loop */
               }
               
              -void 
              +void
               set_supported_widget_cb()
               {
              -   int ret;
              -   ret = vc_elm_foreach_supported_widgets(widget_cb, NULL);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_elm_foreach_supported_widgets(widget_cb, NULL);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            27. Get the actions supported by the Voice control elementary library for specific UI components with a foreach function that triggers a separate callback for each action.

              As long as the callback returns true, the foreach function continues to loop over the supported actions.

              To translate an action to corresponding command parameters, use the vc_elm_get_action_command() function.

              -void 
              +void
               action_cb(const char *action, void *user_data)
               {
              -   char *command_param;
              -   vc_elm_get_action_command(action, &command_param);
              +    char *command_param;
              +    vc_elm_get_action_command(action, &command_param);
               
              -   return true; // To continue to get the next action
              +    return true; /* To continue to get the next action */
               
              -   return false; // To stop the loop
              +    return false; /* To stop the loop */
               }
               
              -void 
              +void
               set_supported_action_cb()
               {
              -   int ret;
              -   // Elm_Button is an example, it can be obtained using vc_elm_foreach_supported_widgets callback
              -   ret = vc_elm_foreach_supported_actions("Elm_Button", action_cb, NULL);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    /* Elm_Button is an example, it can be obtained using vc_elm_foreach_supported_widgets callback */
              +    ret = vc_elm_foreach_supported_actions("Elm_Button", action_cb, NULL);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            28. @@ -282,107 +259,94 @@ set_supported_action_cb()
            29. Use the handle created for a specific UI component to set a command the user must speak in order to perform actions on the UI component:
              -void 
              +void
               set_command(vc_elm_h &handler)
               {
              -   int ret;
              -   ret = vc_elm_set_command(handler, "Command"); 
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              -}
              +    int ret; +    ret = vc_elm_set_command(handler, "Command"); +    if (VC_ELM_ERROR_NONE != ret) +        /* Error handling */ +} +
            30. To show the command on the screen as a tooltip, set a hint (tooltip) for the UI component:
              -void 
              +void
               set_command_hint(vc_elm_h &handler)
               {
              -   int ret;
              -   ret = vc_elm_set_command_hint(handler, "Hint");
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              -}
              +    int ret; +    ret = vc_elm_set_command_hint(handler, "Hint"); +    if (VC_ELM_ERROR_NONE != ret) +        /* Error handling */ +} +
            31. Set the hint direction and offset (X and Y coordinates).

              By default, the hint tooltip is shown so that it does not cover the underlying UI component and does not intersect with other hints.

              -void 
              +void
               set_hint_direction(vc_elm_h &handler)
               {
              -   int ret; 
              -   ret = vc_elm_set_command_hint_direction(handler, VC_ELM_DIRECTION_RIGHT);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_elm_set_command_hint_direction(handler, VC_ELM_DIRECTION_RIGHT);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -void 
              +void
               set_hint_offset(vc_elm_h &handler)
               {
              -   int ret; 
              -   ret = vc_elm_set_command_hint_offset(handler, 100, 100);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_elm_set_command_hint_offset(handler, 100, 100);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               

              You can get the current hint location using the vc_elm_get_command_hint_direction() and vc_elm_get_command_hint_offset() functions:

              -void 
              +void
               get_hint_direction(vc_elm_h &handler)
               {
              -   int ret;
              -   vc_elm_direction_e direction;
              -   ret = vc_elm_get_command_hint_direction(handler, &direction);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    vc_elm_direction_e direction;
              +    ret = vc_elm_get_command_hint_direction(handler, &direction);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -void 
              +void
               get_hint_offset(vc_elm_h &handler)
               {
              -   int ret;
              -   int x, y;
              -   ret = vc_elm_get_command_hint_offset(handler, &x, &y);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    int x;
              +    int y;
              +    ret = vc_elm_get_command_hint_offset(handler, &x, &y);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            32. When no longer needed, unset the command and hint:
              -void 
              +void
               unset_command(vc_elm_h &handler)
               {
              -   int ret;
              -   ret = vc_elm_unset_command(handler);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_elm_unset_command(handler);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -void 
              +void
               unset_command_hint(vc_elm_h &handler)
               {
              -   int ret;
              -   ret = vc_elm_unset_command_hint(handler);
              -   if (VC_ELM_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_elm_unset_command_hint(handler);
              +    if (VC_ELM_ERROR_NONE != ret)
              +        /* Error handling */
               }
            diff --git a/org.tizen.tutorials/html/native/uix/voicecontrol_tutorial_n.htm b/org.tizen.tutorials/html/native/uix/voicecontrol_tutorial_n.htm index 297cd01..12975c5 100644 --- a/org.tizen.tutorials/html/native/uix/voicecontrol_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/uix/voicecontrol_tutorial_n.htm @@ -60,19 +60,19 @@

            To initialize and prepare the voice control for use:

            1. To use the functions and data types of the Voice control API, include the <voice_control.h> header file in your application: -
              #include <voice_control.h>
              +
              +#include <voice_control.h>
              +
            2. Initialize the voice control with the vc_initialize() function:
              -void 
              +void
               initialize_voice_control()
               {
              -   int ret;
              -   ret = vc_initialize();
              -   if (VC_ERROR_NONE != result)
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_initialize();
              +    if (VC_ERROR_NONE != result)
              +        /* Error handling */
               }
               

              If the function call is successful, the voice control state changes to VC_STATE_INITIALIZED.

              @@ -93,41 +93,35 @@ initialize_voice_control()
              -void 
              +void
               prepare_vc()
               {
              -   int ret;
              -   ret = vc_prepare();
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_prepare();
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               

              The vc_prepare() function is asynchronous, and when the preparation succeeds, the voice control state changes from VC_STATE_INITIALIZED to VC_STATE_READY. If the vc_prepare() function fails, the error callback is triggered.

            3. When the voice control is no longer needed, unprepare and deinitialize it:
              -void 
              +void
               unprepared_vc()
               {
              -   int ret;
              -   ret = vc_unprepare();
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_unprepare();
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -void 
              +void
               deinitialize_voice_control()
               {
              -   int ret;
              -   ret = vc_deinitialize(); 
              -   if (VC_ERROR_NONE != result)
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_deinitialize();
              +    if (VC_ERROR_NONE != result)
              +        /* Error handling */
               }
               
              @@ -164,103 +158,91 @@ deinitialize_voice_control()
              • Set the state change callback to be invoked when the voice control state changes:
                -// Callback 
                -void 
                +/* Callback */
                +void
                 state_changed_cb(vc_state_e previous, vc_state_e current, void* user_data)
                -{ 
                -   // Your code
                +{
                +    /* Your code */
                 }
                 
                -// Set
                -void 
                +/* Set */
                +void
                 set_state_changed_cb()
                 {
                -   int ret;
                -   ret = vc_set_state_changed_cb(state_changed_cb, NULL);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_set_state_changed_cb(state_changed_cb, NULL);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_state_changed_cb()
                 {
                -   int ret;
                -   ret = vc_unset_state_changed_cb();
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_unset_state_changed_cb();
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              • Set the service state change callback to be invoked when the Voice control service state changes:
                -// Callback 
                -void 
                +/* Callback */
                +void
                 __service_state_changed_cb(vc_service_state_e previous, vc_service_state_e current, void* user_data)
                -{ 
                -   // Your code
                +{
                +    /* Your code */
                 }
                 
                -// Set
                -void 
                +/* Set */
                +void
                 set_service_state_changed_cb()
                 {
                -   int ret;
                -   ret = vc_set_service_state_changed_cb(__service_state_changed_cb, NULL);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_set_service_state_changed_cb(__service_state_changed_cb, NULL);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_service_state_changed_cb()
                 {
                -   int ret;
                -   ret = vc_unset_service_state_changed_cb();
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_unset_service_state_changed_cb();
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              • Set the current language change callback to be invoked when the system or application language changes:
                -// Callback 
                -void 
                +/* Callback */
                +void
                 __current_language_changed_cb(const char* previous, const char* current, void* user_data)
                 {
                -   // Your code
                +    /* Your code */
                 }
                 
                -// Set
                -void 
                +/* Set */
                +void
                 set_current_language_changed_cb()
                 {
                -   int ret;
                -   ret = vc_set_current_language_changed_cb(__current_language_changed_cb, NULL);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_set_current_language_changed_cb(__current_language_changed_cb, NULL);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_current_language_changed_cb()
                 {
                -   int ret;
                -   ret = vc_unset_current_language_changed_cb();
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_unset_current_language_changed_cb();
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              • Set the recognition result callback to be invoked when a voice command is recognized. @@ -279,98 +261,87 @@ unset_current_language_changed_cb()

                To get the command, use the Voice control APIs with the vc_cmd_list parameter, which is a list of recognized commands. The result parameter contains the recognized text.

                -// Callback
                -void 
                +/* Callback */
                +void
                 __result_cb(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, const char* result, void* user_data)
                 {
                -   int ret = -1;
                -   int count = 0;
                -   ret = vc_cmd_list_get_count(vc_cmd_list, &count);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // No result
                -
                -      return;
                -   }
                -	
                -   vc_cmd_list_first(vc_cmd_list);
                -
                -   int i = 0;
                -   int type = 0;
                -   char* cmd = NULL;
                -   vc_cmd_h result_command = NULL;
                -   for (i = 0; i < count; i++) 
                -   {
                -      result_command = NULL;
                -      ret = vc_cmd_list_get_current(vc_cmd_list, &result_command);
                -      if (0 == ret && NULL != result_command) 
                -      {
                -         cmd = NULL;
                -         type = 0;
                -         vc_cmd_get_command(result_command, &cmd);
                -         vc_cmd_get_type(result_command, &type);
                -         // Check command and type
                -      }
                -   }
                -
                -   return;
                -}
                -
                -// Set
                -void 
                +    int ret = -1;
                +    int count = 0;
                +    ret = vc_cmd_list_get_count(vc_cmd_list, &count);
                +    if (VC_ERROR_NONE != ret) {
                +        /* No result */
                +
                +        return;
                +    }
                +
                +    vc_cmd_list_first(vc_cmd_list);
                +
                +    int i = 0;
                +    int type = 0;
                +    char* cmd = NULL;
                +    vc_cmd_h result_command = NULL;
                +    for (i = 0; i < count; i++) {
                +        result_command = NULL;
                +        ret = vc_cmd_list_get_current(vc_cmd_list, &result_command);
                +        if (0 == ret && NULL != result_command) {
                +            cmd = NULL;
                +            type = 0;
                +            vc_cmd_get_command(result_command, &cmd);
                +            vc_cmd_get_type(result_command, &type);
                +            /* Check command and type */
                +        }
                +    }
                +
                +    return;
                +}
                +
                +/* Set */
                +void
                 set_result_cb()
                 {
                -   int ret;
                -   ret = vc_set_result_cb(__result_cb, NULL);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_set_result_cb(__result_cb, NULL);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_result_cb()
                 {
                -   int ret;
                -   ret = vc_unset_result_cb();
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_unset_result_cb();
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              • Set the error callback to be invoked when an error occurs in the voice control process:
                -// Callback 
                -void 
                +/* Callback */
                +void
                 __error_cb(vc_error_e reason, void* user_data)
                 {
                -   // Your code
                +    /* Your code */
                 }
                 
                -// Set
                -void 
                +/* Set */
                +void
                 set_error_cb(vc_h vc)
                 {
                -   int ret;
                -   ret = vc_set_error_cb(__error_cb, NULL);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_set_error_cb(__error_cb, NULL);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Unset
                -void 
                +/* Unset */
                +void
                 unset_error_cb(vc_h vc)
                 {
                -   int ret;
                -   ret = vc_unset_error_cb();
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_unset_error_cb();
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              @@ -384,16 +355,14 @@ unset_error_cb(vc_h vc)

              Get the current voice control state using the vc_get_state() function.

              The voice control state changes according to function calls when the voice control is, for example, initialized and prepared.

              -void 
              +void
               get_state()
               {
              -   vc_state_e current_state;
              -   int ret;
              -   ret = vc_get_state(&current_state);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    vc_state_e current_state;
              +    int ret;
              +    ret = vc_get_state(&current_state);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            4. @@ -405,53 +374,47 @@ get_state()

              If the application uses continuous recognition, the voice control service state can be changed from VC_SERVICE_STATE_PROCESSING directly to VC_SERVICE_STATE_RECORDING.

              -void 
              +void
               get_state(vc_h vc)
               {
              -   vc_service_state_e service_state;
              -   int ret;
              -   ret = vc_get_service_state(&service_state);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    vc_service_state_e service_state;
              +    int ret;
              +    ret = vc_get_service_state(&service_state);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            5. Get the supported languages with a foreach function that triggers a separate callback for each language.

              As long as the callback returns true, the foreach function continues to loop over the supported languages.

              -bool 
              +bool
               supported_language_cb(const char* language, void* user_data)
               {
              -   return true; // To continue to get the next language
              +    return true; /* To continue to get the next language */
               
              -   return false; // To stop the loop
              +    return false; /* To stop the loop */
               }
               
              -void 
              +void
               get_supported_language()
               {
              -   int ret;
              -   ret = vc_foreach_supported_languages(supported_language_cb, NULL);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_foreach_supported_languages(supported_language_cb, NULL);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            6. Get the current language with the vc_get_current_language() function. The voice control recognition works for the current (default) language. Use the language change callback to be notified of language changes.
              -void 
              +void
               get_current_language()
               {
              -   int ret;
              -   char* current_lang = NULL;
              -   ret = vc_get_current_language(&current_lang);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    char* current_lang = NULL;
              +    ret = vc_get_current_language(&current_lang);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            7. @@ -466,75 +429,61 @@ get_current_language()

              You can access the command list after you set it to the voice control and when you get the recognition result.

              -void 
              +void
               create_command_list()
               {
              -   int ret;
              -   vc_cmd_list_h vc_cmd_list;
              -   ret = vc_cmd_list_create(&vc_cmd_list);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    vc_cmd_list_h vc_cmd_list;
              +    ret = vc_cmd_list_create(&vc_cmd_list);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            8. Create a command.

              First create a command handle, and then define the command and type.

              -void 
              +void
               create_command()
               {
              -   int ret;
              -   vc_cmd_h vc_cmd = NULL;
              -   ret = vc_cmd_create(&vc_cmd);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              -
              -   ret = vc_cmd_set_command(vc_cmd, "open");
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              -   ret = vc_cmd_set_type(vc_cmd, VC_COMMAND_TYPE_FOREGROUND);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    vc_cmd_h vc_cmd = NULL;
              +    ret = vc_cmd_create(&vc_cmd);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
              +
              +    ret = vc_cmd_set_command(vc_cmd, "open");
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
              +    ret = vc_cmd_set_type(vc_cmd, VC_COMMAND_TYPE_FOREGROUND);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
            9. Add the command to the command list.

              If necessary, you can also remove commands from the command list. After you remove a command, if you no longer use it, destroy the command handle with the vc_cmd_destroy() function.

              -void 
              +void
               add_command(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_cmd)
               {
              -   int ret;
              -   ret = vc_cmd_list_add(vc_cmd_list, vc_cmd);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_cmd_list_add(vc_cmd_list, vc_cmd);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              -void 
              +void
               remove_command(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_cmd)
               {
              -   int ret;
              -   ret = vc_cmd_list_remove(vc_cmd_list, vc_cmd);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              -   // Destroy the command if no longer needed
              -   ret = vc_cmd_destroy(vc_cmd);
              -   if (VC_ERROR_NONE != ret) 
              -   {
              -      // Error handling
              -   }
              +    int ret;
              +    ret = vc_cmd_list_remove(vc_cmd_list, vc_cmd);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
              +    /* Destroy the command if no longer needed */
              +    ret = vc_cmd_destroy(vc_cmd);
              +    if (VC_ERROR_NONE != ret)
              +        /* Error handling */
               }
               
              @@ -542,24 +491,22 @@ remove_command(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_cmd)
              • You can use the vc_cmd_list_foreach_commands() function to get each command within a callback function:
                -bool 
                +bool
                 __vc_get_command_cb(vc_cmd_h vc_command, void* user_data)
                 {
                -   // Your code
                -	
                -   return true;
                +    /* Your code */
                +
                +    return true;
                 }
                 
                -void 
                +void
                 foreach_command(vc_cmd_list_h vc_cmd_list)
                 {
                -   int ret;
                -   vc_cmd_h vc_cmd;
                -   ret = vc_cmd_list_foreach_commands(vc_cmd_list, __vc_get_command_cb, NULL);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    vc_cmd_h vc_cmd;
                +    ret = vc_cmd_list_foreach_commands(vc_cmd_list, __vc_get_command_cb, NULL);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              • @@ -576,61 +523,49 @@ foreach_command(vc_cmd_list_h vc_cmd_list)
                -void 
                +void
                 get_commands(vc_cmd_list_h vc_cmd_list)
                 {
                -   int i;
                -   int ret;
                -   int count;
                -   vc_cmd_h vc_cmd;
                -   char* command = NULL;
                -   int type = 0;
                -
                -   ret = vc_cmd_list_get_count(vc_cmd_list, &count);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                -
                -   if (0 >= count) 
                -   {
                -      // Error handling
                -		
                -      return;
                -   }
                -
                -   ret = vc_cmd_list_first(vc_cmd_list);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                -	
                -   do 
                -   {
                -      ret = vc_cmd_list_get_current(vc_cmd_list, &vc_cmd);
                -      if (VC_ERROR_NONE == ret) 
                -      {
                -         ret = vc_cmd_get_command(vc_cmd, &command);
                -         if (VC_ERROR_NONE != ret) 
                -         {
                -            // Error handling
                -         }
                -         if (NULL != command) 
                -         {
                -            // Command must be released
                -            free(command);
                -         }
                -
                -         ret = vc_cmd_get_type(vc_cmd, &type);
                -         if (VC_ERROR_NONE != ret) 
                -         {
                -            // Error handling
                -         }
                -         // Do not release the command handle
                -      }
                -
                -      ret = vc_cmd_list_next(vc_cmd_list);
                -   } while (VC_ERROR_ITERATION_END != ret);
                +    int i;
                +    int ret;
                +    int count;
                +    vc_cmd_h vc_cmd;
                +    char* command = NULL;
                +    int type = 0;
                +
                +    ret = vc_cmd_list_get_count(vc_cmd_list, &count);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                +
                +    if (0 >= count) {
                +        /* Error handling */
                +
                +        return;
                +    }
                +
                +    ret = vc_cmd_list_first(vc_cmd_list);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                +
                +    do {
                +        ret = vc_cmd_list_get_current(vc_cmd_list, &vc_cmd);
                +        if (VC_ERROR_NONE == ret) {
                +            ret = vc_cmd_get_command(vc_cmd, &command);
                +            if (VC_ERROR_NONE != ret)
                +                /* Error handling */
                +            if (NULL != command) {
                +                /* Command must be released */
                +                free(command);
                +            }
                +
                +            ret = vc_cmd_get_type(vc_cmd, &type);
                +            if (VC_ERROR_NONE != ret)
                +                /* Error handling */
                +            /* Do not release the command handle */
                +        }
                +
                +        ret = vc_cmd_list_next(vc_cmd_list);
                +    } while (VC_ERROR_ITERATION_END != ret);
                 }
                 
                @@ -639,55 +574,47 @@ get_commands(vc_cmd_list_h vc_cmd_list)
              • Register the commands for recognition by setting the command list to the voice control.

                If you want to update registered commands, set the command list again with the updated commands.

                -void 
                +void
                 set_command(vc_cmd_list_h vc_cmd_list, int type)
                 {
                -   int ret;
                -   ret = vc_set_command_list(vc_cmd_list, type); 
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_set_command_list(vc_cmd_list, type);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              • When no longer needed, unset the command list, and destroy the command and command list handles.

                When you destroy the command list, all the commands in the command list are not automatically released. If you no longer need the commands, set the second parameter of the vc_cmd_list_destroy() function to true.

                -// Unset the command list
                -void 
                +/* Unset the command list */
                +void
                 unset_command(int type)
                 {
                -   int ret;
                -   ret = vc_unset_command_list(type); 
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_unset_command_list(type);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Destroy the command handle
                -void 
                +/* Destroy the command handle */
                +void
                 destroy_command(vc_cmd_h vc_cmd)
                 {
                -   int ret;
                -   ret = vc_cmd_destroy(vc_cmd);
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_cmd_destroy(vc_cmd);
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
                -// Destroy the command list handle
                -void 
                +/* Destroy the command list handle */
                +void
                 destroy_command_list(vc_cmd_list_h vc_cmd_list)
                 {
                -   int ret;
                -   ret = vc_cmd_list_destroy(vc_cmd_list, true); // true destroys all commands
                -   if (VC_ERROR_NONE != ret) 
                -   {
                -      // Error handling
                -   }
                +    int ret;
                +    ret = vc_cmd_list_destroy(vc_cmd_list, true); /* true destroys all commands */
                +    if (VC_ERROR_NONE != ret)
                +        /* Error handling */
                 }
                 
              • diff --git a/org.tizen.tutorials/html/native/web/web_tutorials_n.htm b/org.tizen.tutorials/html/native/web/web_tutorials_n.htm index 6af26a6..bc0ca22 100644 --- a/org.tizen.tutorials/html/native/web/web_tutorials_n.htm +++ b/org.tizen.tutorials/html/native/web/web_tutorials_n.htm @@ -23,6 +23,7 @@

                Content

                +

                Prerequisites

                + +

                To use the Web API, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

                +
                +<privileges>
                +   <!--To launch another application conditionally-->
                +   <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
                +   <!--To create, update, and delete content-->
                +   <privilege>http://tizen.org/privilege/content.write</privilege>
                +   <!--To use the Internet connection-->
                +   <privilege>http://tizen.org/privilege/internet</privilege>
                +   <!--To provide user notifications, such as messages and badges-->
                +   <privilege>http://tizen.org/privilege/notification</privilege>
                +   <!--To use the user location data-->
                +   <privilege>http://tizen.org/privilege/location</privilege>
                +   <!--To manage the device cameras to preview and capture pictures-->
                +   <privilege>http://tizen.org/privilege/camera</privilege>
                +   <!--To access, read, and write to the external storage-->
                +   <privilege>http://tizen.org/privilege/externalstorage</privilege>
                +   <!--To access the display-->
                +   <privilege>http://tizen.org/privilege/display</privilege>
                +   <!--To create a network connection-->
                +   <privilege>http://tizen.org/privilege/network.get</privilege>
                +</privileges>
                +

                Initializing the EWK WebKit

                @@ -92,79 +118,29 @@

                The sample browser created in this tutorial also requires the <Ecore.h>, <Ecore_Evas.h>, <Ecore_Getopt.h>, <Eet.h>, <Eina.h>, <Elementary.h>, <Evas.h>, and <app.h> header files.

                -
              • To use the sample browser, set the following privileges in the manifest file of the application: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                - Table: Required privileges for an EWK application -
                PrivilegeDescription
                http://tizen.org/privilege/appmanager.launchAllows the application to launch another application conditionally.
                http://tizen.org/privilege/content.writeAllows the application to create, update, and delete content.
                http://tizen.org/privilege/internetAllows the application to use the Internet connection.
                http://tizen.org/privilege/notificationAllows the application to provide user notifications, such as messages and badges.
                http://tizen.org/privilege/locationAllows the application to use the user location data.
                http://tizen.org/privilege/cameraAllows the application to manage the device cameras to preview and capture pictures.
                http://tizen.org/privilege/externalstorageAllows the application to access, read, and write to the external storage.
                http://tizen.org/privilege/displayAllows the application to access the display.
                http://tizen.org/privilege/network.getAllows the application to create a network connection.
              • The sample browser uses several Evas objects to build the browser UI. To easily manage the UI elements, store the browser window data (including the Evas_Object instances) in the Browser_window data structure:
                -typedef struct 
                -_Browser_Window
                -{ 
                -   Evas_Object *elm_window; 
                -   Evas_Object *ewk_view; 
                -   Evas_Object *back_button;
                -   Evas_Object *forward_button;
                -} Browser_Window;
                - 
                -EXPORT_API int 
                -main(int argc, char *argv[]) 
                -{ 
                -   int args = 1; 
                -   Browser_Window window; 
                -   memset(&window, 0x00, sizeof(Browser_Window));
                +struct _Browser_Window {
                +    Evas_Object *elm_window;
                +    Evas_Object *ewk_view;
                +    Evas_Object *back_button;
                +    Evas_Object *forward_button;
                +};
                +typedef struct _Browser_Window Browser_Window;
                 
                -   ui_app_lifecycle_callback_s ops;
                -   memset(&ops, 0x00, sizeof(ui_app_lifecycle_callback_s));
                +EXPORT_API int
                +main(int argc, char *argv[])
                +{
                +    int args = 1;
                +    Browser_Window window;
                +    memset(&window, 0x00, sizeof(Browser_Window));
                 
                -   ops.create = br_app_create;
                +    ui_app_lifecycle_callback_s ops;
                +    memset(&ops, 0x00, sizeof(ui_app_lifecycle_callback_s));
                 
                -   return ui_app_main(argc, argv, &ops, &window); 
                +    ops.create = br_app_create;
                +
                +    return ui_app_main(argc, argv, &ops, &window);
                 }
                 
              • @@ -183,32 +159,31 @@ window = window_create(NULL, 0, 0, EINA_FALSE); static Browser_Window* window_create(Evas_Object *opener, int width, int height, Eina_Bool view_mode) { -   // Allocate memory -   Browser_Window *window = calloc(1, sizeof(Browser_Window)); -   if (!window) -   { -      // "ERROR: could not create browser window." -      return NULL; -   } - -   // If you want to use GPU acceleration, use the following function -   // elm_config_accel_preference_set("opengl:depth24:stencil8"); - -   // Create window -   window->elm_window = elm_win_add(NULL, "minibrowser-window", ELM_WIN_BASIC); +    /* Allocate memory */ +    Browser_Window *window = calloc(1, sizeof(Browser_Window)); +    if (!window) { +        /* "ERROR: could not create browser window." */ +        return NULL; +    } + +    /* If you want to use GPU acceleration, use the following function */ +    /* elm_config_accel_preference_set("opengl:depth24:stencil8"); */ + +    /* Create window */ +    window->elm_window = elm_win_add(NULL, "minibrowser-window", ELM_WIN_BASIC);
              • Add a smart callback to the window to handle the window deletion event.

                In the callback, call the window_close() function for the object returned from the window_find_with_elm_window() function call.

                -   evas_object_smart_callback_add(window->elm_window, "delete,request", on_window_deletion, &window);
                +    evas_object_smart_callback_add(window->elm_window, "delete,request", on_window_deletion, &window);
                 }
                 
                -static void 
                +static void
                 on_window_deletion(void *user_data, Evas_Object *elm_window, void *event_info)
                 {
                -   window_close(window_find_with_elm_window(elm_window));
                +    window_close(window_find_with_elm_window(elm_window));
                 }
                 
            @@ -238,14 +213,14 @@ on_window_deletion(void *user_data, Evas_Object *elm_window, void *event_info)
          -// Create vertical layout
          +/* Create vertical layout */
           Evas_Object *vertical_layout = elm_box_add(window->elm_window);
           elm_box_padding_set(vertical_layout, 0, 2);
           evas_object_size_hint_weight_set(vertical_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
           elm_win_resize_object_add(window->elm_window, vertical_layout);
           evas_object_show(vertical_layout);
           
          -// Create horizontal layout for top bar
          +/* Create horizontal layout for top bar */
           Evas_Object *horizontal_layout = elm_box_add(window->elm_window);
           elm_box_horizontal_set(horizontal_layout, EINA_TRUE);
           evas_object_size_hint_weight_set(horizontal_layout, EVAS_HINT_EXPAND, 0.0);
          @@ -263,13 +238,14 @@ evas_object_show(horizontal_layout);
           
           
           static Browser_Window*
          -window_create(Evas_Object *opener, int width, int height, Eina_Bool view_mode) 
          -{ 
          -   Evas *evas = evas_object_evas_get(window->elm_window);
          -   window->ewk_view = ewk_view_add(evas);
          +window_create(Evas_Object *opener, int width, int height, Eina_Bool view_mode)
          +{
          +    Evas *evas = evas_object_evas_get(window->elm_window);
          +    window->ewk_view = ewk_view_add(evas);
           
          -   ewk_view_user_agent_set(window->ewk_view, user_agent_string);
          -}
          +    ewk_view_user_agent_set(window->ewk_view, user_agent_string); +} +
        @@ -281,29 +257,29 @@ window_create(Evas_Object *opener, int width, int height, Eina_Bool view_mode)
         static Browser_Window*
        -window_create(Evas_Object *opener, int width, int height, Eina_Bool view_mode) 
        -{ 
        -   // Key down event
        -   evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_KEY_DOWN, on_key_down, window); 
        -   // Mouse down event
        -   evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_MOUSE_DOWN, on_mouse_down, window); 
        +window_create(Evas_Object *opener, int width, int height, Eina_Bool view_mode)
        +{
        +    /* Key down event */
        +    evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_KEY_DOWN, on_key_down, window);
        +    /* Mouse down event */
        +    evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_MOUSE_DOWN, on_mouse_down, window);
         }
         
      5. Define the key event down callback. -

        The ev->key instance contains the name of the key that caused the event.

        +

        The ev->key instance contains the name of the key that caused the event.

        To handle pressed key modifiers, such as Ctrl or Alt, use the evas_key_modifier_is_set() function. To get the Evas_Modifier object that contains information about which key modifiers are registered, call the evas_key_modifier_get() function, passing the Evas canvas object as a parameter.

        -static void 
        -on_key_down(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info) 
        -{ 
        -   Browser_Window *window = (Browser_Window *)user_data; 
        -   Evas_Event_Key_Down *ev = (Evas_Event_Key_Down*) event_info; 
        -
        -   const Evas_Modifier *mod = evas_key_modifier_get(e); 
        -   Eina_Bool ctrlPressed = evas_key_modifier_is_set(mod, "Control"); 
        -   Eina_Bool altPressed = evas_key_modifier_is_set(mod, "Alt");
        +static void
        +on_key_down(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info)
        +{
        +    Browser_Window *window = (Browser_Window *)user_data;
        +    Evas_Event_Key_Down *ev = (Evas_Event_Key_Down*)event_info;
        +
        +    const Evas_Modifier *mod = evas_key_modifier_get(e);
        +    Eina_Bool ctrlPressed = evas_key_modifier_is_set(mod, "Control");
        +    Eina_Bool altPressed = evas_key_modifier_is_set(mod, "Alt");
         }
         
        @@ -353,14 +329,14 @@ on_key_down(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info)

        In the following example, pressing the first button calls the view_focus_set() function to update the focus:

        -static void 
        -on_mouse_down(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info) 
        -{ 
        -   Browser_Window *window = (Browser_Window *)user_data; 
        -   Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *)event_info; 
        -
        -   if (ev->button == 1) 
        -      view_focus_set(window, EINA_TRUE); 
        +static void
        +on_mouse_down(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info)
        +{
        +    Browser_Window *window = (Browser_Window *)user_data;
        +    Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *)event_info;
        +
        +    if (ev->button == 1)
        +        view_focus_set(window, EINA_TRUE);
         }
         
      6. @@ -376,14 +352,16 @@ on_mouse_down(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info)

        Unfocus the window with the elm_object_focus_set() function, and move the focus to the view with the evas_object_focus_set() function:

        -static void 
        -view_focus_set(Browser_Window *window, Eina_Bool focus) 
        -{ 
        -   // You steal focus away from the elm focus model and start to do things 
        -   // manually, so elm has no clue what is up. Tell elm to unfocus
        -   // the top level UI component
        -   elm_object_focus_set(elm_object_top_widget_get(window->elm_window), EINA_FALSE); 
        -   evas_object_focus_set(window->ewk_view, focus); 
        +static void
        +view_focus_set(Browser_Window *window, Eina_Bool focus)
        +{
        +    /*
        +       You steal focus away from the elm focus model and start to do things
        +       manually, so elm has no clue what is up. Tell elm to unfocus
        +       the top level UI component
        +    */
        +    elm_object_focus_set(elm_object_top_widget_get(window->elm_window), EINA_FALSE);
        +    evas_object_focus_set(window->ewk_view, focus);
         };
         
        @@ -393,14 +371,14 @@ view_focus_set(Browser_Window *window, Eina_Bool focus)
         window_create()
         {
        -   elm_win_resize_object_add(window->elm_window, window->ewk_view);
        -   evas_object_show(window->ewk_view);
        +    elm_win_resize_object_add(window->elm_window, window->ewk_view);
        +    evas_object_show(window->ewk_view);
         
        -   evas_object_show(window->elm_window);
        +    evas_object_show(window->elm_window);
         
        -   view_focus_set(window, EINA_TRUE);
        +    view_focus_set(window, EINA_TRUE);
         
        -   return window;
        +    return window;
         }
         
        @@ -417,41 +395,39 @@ window_create()
         static Browser_Window*
        -window_find_with_elm_window(Evas_Object *elm_window) 
        -{ 
        -   Eina_List *l; 
        -   void *data; 
        -
        -   if (!elm_window) 
        -      return NULL; 
        -
        -   EINA_LIST_FOREACH(windows, l, data)
        -   { 
        -      Browser_Window *window = (Browser_Window *)data; 
        -      if (window->elm_window == elm_window) 
        -         return window; 
        -   } 
        -
        -   return NULL; 
        +window_find_with_elm_window(Evas_Object *elm_window)
        +{
        +    Eina_List *l;
        +    void *data;
        +
        +    if (!elm_window)
        +        return NULL;
        +
        +    EINA_LIST_FOREACH(windows, l, data) {
        +        Browser_Window *window = (Browser_Window *)data;
        +        if (window->elm_window == elm_window)
        +            return window;
        +    }
        +
        +    return NULL;
         }
         
         static Browser_Window*
        -window_find_with_ewk_view(Evas_Object *ewk_view) 
        -{ 
        -   Eina_List *l; 
        -   void *data; 
        -
        -   if (!ewk_view) 
        -      return NULL; 
        -
        -   EINA_LIST_FOREACH(windows, l, data)
        -   { 
        -      Browser_Window *window = (Browser_Window *)data; 
        -      if (window->ewk_view == ewk_view) 
        -         return window; 
        -   } 
        -
        -   return NULL; 
        +window_find_with_ewk_view(Evas_Object *ewk_view)
        +{
        +    Eina_List *l;
        +    void *data;
        +
        +    if (!ewk_view)
        +        return NULL;
        +
        +    EINA_LIST_FOREACH(windows, l, data) {
        +        Browser_Window *window = (Browser_Window *)data;
        +        if (window->ewk_view == ewk_view)
        +            return window;
        +    }
        +
        +    return NULL;
         }
         
        @@ -462,10 +438,10 @@ window_find_with_ewk_view(Evas_Object *ewk_view)
      7. To clean up any resources your application has allocated, use the ewk_shutdown() function in the termination life-cycle callback:
        -static void 
        +static void
         br_app_terminate(void *app_data)
         {
        -   ewk_shutdown();
        +    ewk_shutdown();
         }
         
      8. @@ -475,15 +451,15 @@ br_app_terminate(void *app_data)
         main()
         {
        -   ops.create = br_app_create;
        -   ops.terminate = br_app_terminate;
        +    ops.create = br_app_create;
        +    ops.terminate = br_app_terminate;
         
        -   return ui_app_main(argc, argv, &ops, &window);
        +    return ui_app_main(argc, argv, &ops, &window);
         }
         
      - + diff --git a/org.tizen.tutorials/html/web/tizen/account/account_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/account/account_tutorial_w.htm index 7d1cef8..1249b5d 100644 --- a/org.tizen.tutorials/html/web/tizen/account/account_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/account/account_tutorial_w.htm @@ -21,6 +21,7 @@

      Content

        +
      • Prerequisites
      • Retrieving Accounts
      • Retrieving Providers
      • Managing Accounts
      • @@ -46,6 +47,8 @@

        Warm-up

        Become familiar with the Account API basics by learning about:

          +
        • Prerequisites +

          Prepare your application to use the account functionality.

        • Retrieving Accounts

          Get all accounts or one with a specific ID.

        • @@ -63,10 +66,14 @@
        -

        Prerequisites

        -

        To use the account APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

        -
        <tizen:privilege name="http://tizen.org/privilege/account.read"/>
        -<tizen:privilege name="http://tizen.org/privilege/account.write"/>
        +

        Prerequisites

        + +

        To use the Account API, the application has to request permission by adding the following privileges to the config.xml file:

        +
        +<tizen:privilege name="http://tizen.org/privilege/account.read"/>
        +<tizen:privilege name="http://tizen.org/privilege/account.write"/>
        +
        +

        Retrieving Accounts

        @@ -100,17 +107,6 @@ tizen.account.getAccounts(getAccountsSuccess, getAccountsError);

        To create accounts, you must learn how to get access to account providers:

        - - - - - - - - - -
        Note
        To perform these operations, your application needs the http://tizen.org/privilege/account.read privilege.
        -
        • Get a specific account provider with the given application ID using the getProviders() method of the ApplicationManager interface.

          If the current application is an account provider application (meaning that it contains the <tizen:account> element in its config.xml file), you can use the current application ID. Otherwise, get the ID of the current application using the getCurrentApplication() method of the ApplicationManager interface:

          @@ -143,7 +139,7 @@ tizen.account.getProviders(getProvidersSuccess, getProvidersError, "http:// Note - To perform these operations, your application needs the http://tizen.org/privilege/account.write privilege and must be the account provider. + To perform these operations, your application must be the account provider. @@ -181,17 +177,6 @@ var accountProvider = tizen.account.getProvider(appId);

          Learning how to register change listeners enables you to synchronize the view of your application with the changes in the account database:

          - - - - - - - - - -
          Note
          To perform these operations, your application needs the http://tizen.org/privilege/account.read privilege.
          -
          1. Define a listener implementing the AccountChangeCallback interface: @@ -215,7 +200,7 @@ var accountProvider = tizen.account.getProvider(appId);
            var watchId = tizen.account.addAccountListener(accountChangeListener);
          2. -
          3. When notifications are no longer required, unregister the listener using the removeAccountListener() method of the AccountManager interface: +
          4. When notifications are no longer required, deregister the listener using the removeAccountListener() method of the AccountManager interface:
            tizen.account.removeAccountListener(watchId);
          5. @@ -234,16 +219,6 @@ var accountProvider = tizen.account.getProvider(appId); var value = 'nickname of anonymous user'; account.setExtendedData(key, value); - - - - - - - - - -
            Note
            To perform this operation, your application needs the http://tizen.org/privilege/account.write privilege.

            To overwrite the previous data value, set a new value with the same key:

            account.setExtendedData(key, 'nickname updated');
            @@ -255,16 +230,6 @@ account.setExtendedData(key, value);
            var key = 'accessToken';
             var value = account.getExtendedData(key); 
            - - - - - - - - - -
            Note
            To perform this operation, your application needs the http://tizen.org/privilege/account.read privilege.
          6. To retrieve all extended data for an account, use the asynchronous version of the getExtendedData() method. The success callback contains an array of the extended data key-value pairs. diff --git a/org.tizen.tutorials/html/web/tizen/application/alarm_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/alarm_tutorial_w.htm index 7cdb576..df5a0b2 100644 --- a/org.tizen.tutorials/html/web/tizen/application/alarm_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/application/alarm_tutorial_w.htm @@ -23,6 +23,7 @@

            Content

            -
      +
      @@ -37,15 +37,17 @@

      The application management tutorials demonstrate how to use the following features in creating Tizen Web applications:

      +
    11. Application: Providing Information about Applications and Controlling Applications

      Demonstrates how you can retrieve application information, receive application notifications, and perform application management actions.

    12. +
    13. Application Group: Managing Groups

      Demonstrates how you can define the application launch mode and manage your applications in a group.

    14. +
    15. Badge: Displaying the Notification (Badge) Count on the Home Screen

      Demonstrates how you can manage home screen badges.

    16. +
    17. Data Control: Providing Information about Packages and their Installation +

      Demonstrates how you can share data between applications.

    18. +
    19. Input Device: Managing Input Keys in the Application +

      Demonstrates how you can manage input keys in the application.

    20. +
    21. Message Port: Communicating with Other Applications

      Demonstrates how you can send and receive messages through message ports.

    22. +
    23. Notification: Notifying Users of Application Events

      Demonstrates how you can manage notifications created based on application events.

    24. +
    25. Package: Providing Information about Package Installation and Installed Packages

      Demonstrates how you can retrieve package information, receive package notifications, and perform package management actions.

    26. + diff --git a/org.tizen.tutorials/html/web/tizen/application/appgroup_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/appgroup_tutorial_w.htm index f7a1417..483099a 100644 --- a/org.tizen.tutorials/html/web/tizen/application/appgroup_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/application/appgroup_tutorial_w.htm @@ -23,6 +23,7 @@

      Content

      Related Info

      @@ -44,13 +45,18 @@ This tutorial demonstrates how you can define the application launch mode and ma

      Warm-up

      Become familiar with the Application API basics by learning about:

      -

      Prerequisites

      -

      To use the application APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

      -
      <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
      +

      Prerequisites

      + +

      To use the Application API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

      +
      +<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
      +
      +

      Controlling the Launch Mode

      @@ -65,7 +71,7 @@ var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/ -
    27. Define an array with callback functions for the tizen.application.launchAppControl() method: +
    28. Define an array with callbacks for the tizen.application.launchAppControl() method:
       var appControlReplyCallback = 
       {
      diff --git a/org.tizen.tutorials/html/web/tizen/application/application_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/application_tutorial_w.htm
      index 81c7f4f..5813ba3 100644
      --- a/org.tizen.tutorials/html/web/tizen/application/application_tutorial_w.htm
      +++ b/org.tizen.tutorials/html/web/tizen/application/application_tutorial_w.htm
      @@ -23,6 +23,7 @@
       	

      Content

        +
      • Prerequisites
      • Retrieving Application Information
      • Managing Applications @@ -54,18 +55,23 @@

        Warm-up

        Become familiar with the Application API basics by learning about:

        + +

        Prerequisites

        -

        Prerequisites

        -

        To use the application APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

        -
        <tizen:privilege name="http://tizen.org/privilege/application.info"/>
        +

        To use the Application API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the config.xml file:

        +
        +<tizen:privilege name="http://tizen.org/privilege/application.info"/>
         <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
        -<tizen:privilege name="http://tizen.org/privilege/appmanager.kill"/>
        +<tizen:privilege name="http://tizen.org/privilege/appmanager.kill"/> +
        +

        Retrieving Application Information

        diff --git a/org.tizen.tutorials/html/web/tizen/application/badge_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/badge_tutorial_w.htm index 6cc5f68..8447eb3 100644 --- a/org.tizen.tutorials/html/web/tizen/application/badge_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/application/badge_tutorial_w.htm @@ -23,6 +23,7 @@

        Content

        @@ -45,27 +46,22 @@

        Warm-up

        Become familiar with the Badge API basics by learning about:

        -

        Prerequisites

        -

        To use the badge APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

        -
        <tizen:privilege name="http://tizen.org/privilege/notification"/>
        +

        Prerequisites

        + +

        To use the Badge API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

        +
        +<tizen:privilege name="http://tizen.org/privilege/notification"/>
        +
        +

        Managing Badges

        Getting and setting the badge number is a useful UI management skill:

        - - - - - - - - - -
        Note
        To perform these operations, your application must have the http://tizen.org/privilege/notification privilege.
        1. Retrieve application identifier using the getCurrentApplication() method:

          @@ -90,17 +86,6 @@ tizen.badge.setBadgeCount(appId, 0);
           
           

          Registering a listener for badge count changes to react to new badges and display your badges is a useful UI management skill:

          - - - - - - - - - -
          Note
          To perform these operations, your application must have the http://tizen.org/privilege/notification privilege.
          -
          1. To register an event handler for receiving a notification about badge changes, use the addChangeListener() method of the BadgeManager interface (in mobile and wearable applications), specifying a list of application IDs:

            diff --git a/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm
            index 56c1820..452e66c 100644
            --- a/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm
            +++ b/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm
            @@ -18,11 +18,12 @@
             
             	
            @@ -40,29 +41,34 @@
             	

            Data Control: Providing Information about Packages and their Installation

            This tutorial demonstrates how you can share data between applications.

            + +

            The Data Control API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable applications. All mandatory APIs are supported on the Tizen Emulators.

            -

            The Data control API is mandatory for both Tizen mobile and wearable profiles, which means that i -t is supported in all mobile and wearable applications. All mandatory APIs are supported on the Tize -n Emulators.

            Warm-up

            Become familiar with the Data Control API basics by learning about:

            - -

            Prerequisites

            -

            To use the data control APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

            -
            <tizen:privilege name="http://tizen.org/privilege/datacontrol.consumer"/>
            + +

            Prerequisites

            + +

            To use the Data Control API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

            +
            +<tizen:privilege name="http://tizen.org/privilege/datacontrol.consumer"/>
            +
            + +

            Managing Data in Key-value Pairs

            Learning how to manage map-type data allows you to use key-value pairs exposed by a DataControl provider:

              -
            1. Retrieve the the MappedDataControlConsumer object (in mobile and wearable applications) using +

            2. Retrieve the MappedDataControlConsumer object (in mobile and wearable applications) using the getDataControlConsumer() method of - the DataControlManager interface (in mobile and wearable applications). + the DataControlManager interface (in mobile and wearable applications). This object allows accessing the key-value data stored by the DataControl provider.

              You need a running DataControl provider application, which uses the "http://tizen.org/datacontrol/provider/DictionaryDataControlProvider" provider ID.

              @@ -135,9 +141,9 @@ try
               				
                 

              Learning how to manage SQL-type data allows you to use databases exposed by a DataControl provider:

                -
              1. To retrieve a SQLDataControlConsumer object (in mobile and wearable applications), use +

              2. To retrieve a SQLDataControlConsumer object (in mobile and wearable applications), use the getDataControlConsumer() method of - the DataControlManager interface (in mobile and wearable applications). + the DataControlManager interface (in mobile and wearable applications). This object allows accessing the data stored by the DataControl provider.

                You need a running DataControl provider application, which uses the "http://tizen.org/datacontrol/provider/DictionaryDataControlProvider" provider ID.

                @@ -178,7 +184,7 @@ try
                 {
                    var rowData = 
                    {
                -      columns: ["WORD", "WORD_DESC"] ,
                +      columns: ["WORD", "WORD_DESC"],
                       values: ["'tizen1'", "'tizen2'"]
                    };
                    /* Increases globalReqId for uniqueness */
                @@ -203,12 +209,14 @@ function onSelectSuccess(result, id)
                 
                 try 
                 {
                -   var columns = ["WORD", "WORD_DESC" ];
                +   var columns = ["WORD", "WORD_DESC"];
                    var order = "WORD ASC";
                    var page = null;
                    var maxNumberPerPage = null;
                +
                    globalReqId++;
                -   globalSQLConsumer.select(globalReqId, columns, "WORD='tizen1'", onSelectSuccess, onRequestError, page, maxNumberPerPage, order);
                +   globalSQLConsumer.select(globalReqId, columns, "WORD='tizen1'", onSelectSuccess, 
                +                            onRequestError, page, maxNumberPerPage, order);
                 }
                 
              3. To update data, use the update() method of the SQLDataControlConsumer interface:

                @@ -217,7 +225,7 @@ try {    var rowData =    { -      columns: ["WORD", "WORD_DESC"] , +      columns: ["WORD", "WORD_DESC"],       values: ["'tizen1'", "'Web apps platform!'"]    };    globalReqId++; diff --git a/org.tizen.tutorials/html/web/tizen/application/inputdevice_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/inputdevice_tutorial_w.htm index e11c64e..b5e1f19 100644 --- a/org.tizen.tutorials/html/web/tizen/application/inputdevice_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/application/inputdevice_tutorial_w.htm @@ -25,13 +25,13 @@

                Related Info

      @@ -41,24 +41,21 @@

      This tutorial demonstrates how you can manage input device keys and perform custom actions when they are pressed.

      -

      The Input Device API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices.

      +

      The Input Device API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The Input Device API is not supported on any Tizen Emulators.

      Warm-up

      Become familiar with the Input Device API basics by learning about:

      -
        + -

        Prerequisites

        -

        There are not any privileges to be required for this APIs.

        -

        Getting a List of All Supported Keys

        To manage input device keys, you must learn to gather a list of all supported keys:

          -
        1. To get a supported key list, use the getSupportedKeys() method of the InputDeviceManager interface (in mobile and wearable applications):

          +
        2. To get a supported key list, use the getSupportedKeys() method of the InputDeviceManager interface (in mobile and wearable applications):

           var keyCodes = {};
          @@ -91,7 +88,7 @@ var keyCodes = {};
           
        3. -
        4. Check each key separately using the getKey() method of the InputDeviceManager interface (in mobile and wearable applications).

          +
        5. Check each key separately using the getKey() method of the InputDeviceManager interface (in mobile and wearable applications).

          If the result of the getKey() method is not null, you can access the key information. If the result is null, the key is not supported.

          @@ -119,7 +116,7 @@ for (var i = 0; i < keys.length; i++)
           
        -

        Registering and Unregistering Keys

        +

        Registering and Deregistering Keys

        To manage input device keys, you must learn to change the action of a supported key:

          @@ -200,16 +197,16 @@ window.addEventListener("keyup", function(keyEvent)
        1. -

          When custom actions are no longer needed, unregister the keys:

          +

          When custom actions are no longer needed, deregister the keys:

          -for (var i = 0; i < supportedKeys.length; ++i)
          +for (var i = 0; i < supportedKeys.length; ++i) 
           {
              tizen.inputdevice.unregisterKey(supportedKeys[i].name);
              console.log("key: " + supportedKeys[i].name + " was unregistered for event handling");
           }
           
          -

          The unregistration can also be done with the unregisterKeyBatch() method:

          +

          The deregistration can also be done with the unregisterKeyBatch() method:

           var keys = ["VolumeUp", "VolumeDown"];
           
          @@ -226,7 +223,7 @@ function successCB()
           tizen.inputdevice.unregisterKeyBatch(keys, successCB, errorCB);
           
          -

          After unregistration, the keydown and keyup events are no longer triggered for the keys.

          +

          After deregistration, the keydown and keyup events are no longer triggered for the keys.

        diff --git a/org.tizen.tutorials/html/web/tizen/application/message_port_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/message_port_tutorial_w.htm index ba8e945..355a0b6 100644 --- a/org.tizen.tutorials/html/web/tizen/application/message_port_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/application/message_port_tutorial_w.htm @@ -47,10 +47,7 @@ - -

        Prerequisites

        -

        There are not any privileges to be required for this APIs.

        - +

        Managing Message Ports

        Learning how to send messages to and receive responses from other Tizen applications through message ports is a basic data communication skill:

        @@ -71,7 +68,8 @@ var localPortWatchId = localPort.addMessagePortListener(function(data, replyPort    for (var i = 0; i < data.length; i++)    {       var key = data[i].key; -      switch(key) +      switch (key) +      {          case "command":             console.log("key:" + key + " / value:" + data[i].value);             break; @@ -106,18 +104,6 @@ var localPortWatchId = localPort.addMessagePortListener(function(data, replyPort });
    29. Use the sendMessage() method of the RemoteMessagePort interface to send a message:

      -var messageData = 
      -[
      -   {key:"command", value:"begin"},
      -      }
      -   }
      -   if (replyPort)
      -   {
      -      console.log("replyPort given: " + replyPort.messagePortName);
      -   }
      -});
      -
    30. -
    31. Use the sendMessage() method of the RemoteMessagePort interface to send a message:

       var messageData =
       [
          {key:"command", value:"begin"},
      diff --git a/org.tizen.tutorials/html/web/tizen/application/noti_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/noti_tutorial_w.htm
      index 6cf29a7..ecf9ce0 100644
      --- a/org.tizen.tutorials/html/web/tizen/application/noti_tutorial_w.htm
      +++ b/org.tizen.tutorials/html/web/tizen/application/noti_tutorial_w.htm
      @@ -23,6 +23,7 @@
       	

      Content

        +
      • Prerequisites
      • Creating Simple Notifications
      • Creating Progress Notifications
      • Managing Notifications
      • @@ -46,14 +47,18 @@

        Warm-up

        Become familiar with the Notification API basics by learning about:

        + +

        Prerequisites

        +

        To use the Notification API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

        +
        +<tizen:privilege name="http://tizen.org/privilege/notification"/>
        +
        -

        Prerequisites

        -

        To use the notification APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

        -
        <tizen:privilege name="http://tizen.org/privilege/notification"/>

        Creating Simple Notifications

        diff --git a/org.tizen.tutorials/html/web/tizen/application/package_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/package_tutorial_w.htm index 75b2ece..a94465e 100644 --- a/org.tizen.tutorials/html/web/tizen/application/package_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/application/package_tutorial_w.htm @@ -24,6 +24,7 @@

        Content

          +
        • Prerequisites
        • Retrieving Package Information
        • @@ -54,16 +55,21 @@

          Warm-up

          Become familiar with the Package API basics by learning about:

          - -

          Prerequisites

          -

          To use the package manager APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

          -
          <tizen:privilege name="http://tizen.org/privilege/package.info"/>
          -<tizen:privilege name="http://tizen.org/privilege/packagemanager.install"/>
          - +
        + +

        Prerequisites

        + +

        To use the Package API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the config.xml file:

        +
        +<tizen:privilege name="http://tizen.org/privilege/package.info"/>
        +<tizen:privilege name="http://tizen.org/privilege/packagemanager.install"/>
        +
        + +

        Retrieving Package Information

        Learning how to retrieve information about installed packages allows you to manage device packages from your application:

        diff --git a/org.tizen.tutorials/html/web/tizen/base/archive_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/base/archive_tutorial_w.htm index 516922f..15211e7 100644 --- a/org.tizen.tutorials/html/web/tizen/base/archive_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/base/archive_tutorial_w.htm @@ -23,6 +23,7 @@

        Content

          +
        • Prerequisites
        • Reading the Content of an Archive
        • Creating an Archive
        • Extracting Files from an Archive
        • @@ -46,21 +47,25 @@

          Warm-up

          Become familiar with the Archive API basics by learning about:

          -

          Prerequisites

          -

          To use the archive APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

          -
          <tizen:privilege name="http://tizen.org/privilege/filesystem.read"/>
          -<tizen:privilege name="http://tizen.org/privilege/filesystem.write"/>
          +

          Prerequisites

          +

          To use the Archive API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the config.xml file:

          +
          +<tizen:privilege name="http://tizen.org/privilege/filesystem.read"/>
          +<tizen:privilege name="http://tizen.org/privilege/filesystem.write"/>
          +
          +

          Reading the Content of an Archive

          Opening an archive and accessing a list of its members is a basic archive management skill:

            -
          1. To access the archive file, use the open() method of the ArchiveManager interface (in mobile and wearable applications). The provided callback function receives an ArchiveFile object (in mobile and wearable applications).

            +
          2. To access the archive file, use the open() method of the ArchiveManager interface (in mobile and wearable applications). The provided callback receives an ArchiveFile object (in mobile and wearable applications).

            var myArchive = null;
             function openSuccess(arch)
            diff --git a/org.tizen.tutorials/html/web/tizen/base/base_tutorials_w.htm b/org.tizen.tutorials/html/web/tizen/base/base_tutorials_w.htm
            index e7a12d3..273f856 100644
            --- a/org.tizen.tutorials/html/web/tizen/base/base_tutorials_w.htm
            +++ b/org.tizen.tutorials/html/web/tizen/base/base_tutorials_w.htm
            @@ -34,10 +34,10 @@
             

            Base: Managing the Basic Tizen Features

            The base tutorials demonstrate how to use the following features in creating Tizen Web applications:

            -
              + diff --git a/org.tizen.tutorials/html/web/tizen/base/filesystem_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/base/filesystem_tutorial_w.htm index c7aa476..107f0b3 100644 --- a/org.tizen.tutorials/html/web/tizen/base/filesystem_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/base/filesystem_tutorial_w.htm @@ -23,6 +23,7 @@

              Content

                +
              • Prerequisites
              • Managing File Storages
              • Creating and Deleting Files and Directories @@ -52,20 +53,24 @@

                Become familiar with the Filesystem API basics by learning about:

                -

                Prerequisites

                -

                To use the filesystem APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

                -
                <tizen:privilege name="http://tizen.org/privilege/filesystem.read"/>
                -<tizen:privilege name="http://tizen.org/privilege/filesystem.write"/>
                -

                Task

                In the File Manager task, we will walk through how to manage files in your application.

                +

                Prerequisites

                +

                To use the Filesystem API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the config.xml file:

                +
                +<tizen:privilege name="http://tizen.org/privilege/filesystem.read"/>
                +<tizen:privilege name="http://tizen.org/privilege/filesystem.write"/>
                +
                + +

                Managing File Storages

                @@ -179,7 +184,7 @@ tizen.filesystem.resolve("documents", function(result) var testFile = documentsDir.createFile("test.txt"); if (testFile != null) { -   testFile.openStream("w", onOpenSuccess, null, "UTF-8"); +   testFile.openStream("rw", onOpenSuccess, null, "UTF-8"); }
          3. Perform all actual operations, such as reading, writing, or closing, on the file through the FileStream object based on a position attribute, which represents the current position in the file:

             function onOpenSuccess(fs)
            @@ -187,7 +192,10 @@ function onOpenSuccess(fs)
                /* Write HelloWorld to the file */
                fs.write("HelloWorld");
             
            -   /* Read the file content */
            +   /* Move pointer to the beginning */
            +   fs.position = 0;
            +
            +   /* Read the file content from the beginning */
                fs.read(testFile.fileSize);
             
                /* Close the file */
            diff --git a/org.tizen.tutorials/html/web/tizen/base/task_filemanager_w.htm b/org.tizen.tutorials/html/web/tizen/base/task_filemanager_w.htm
            index d74bcc2..6541d8a 100644
            --- a/org.tizen.tutorials/html/web/tizen/base/task_filemanager_w.htm
            +++ b/org.tizen.tutorials/html/web/tizen/base/task_filemanager_w.htm
            @@ -30,7 +30,7 @@
             		

        Related Info

        @@ -50,7 +50,7 @@

        This sample is a fully functional application for browsing the device storage. The user can create, copy, move, and remove folders and files.

        Defining the Application Layout

        -

        The FileManager sample application layout uses the template manager based on the MVC (Model-View-Controller) architecture, and consists of 1 screen that displays the device storage folder and file structure.

        +

        The FileManager sample application layout uses the template manager based on the MVC (Model View Controller) architecture, and consists of 1 screen that displays the device storage folder and file structure.

        Additionally, the sample application layout consists of 2 UI elements: the clipboard footer controls enable you to delete, move, or copy selected folders and files, and the More pop-up window enables you to create a new folder and to paste content to a folder.

        diff --git a/org.tizen.tutorials/html/web/tizen/base/tizen_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/base/tizen_tutorial_w.htm index 159baa7..510da9e 100644 --- a/org.tizen.tutorials/html/web/tizen/base/tizen_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/base/tizen_tutorial_w.htm @@ -64,8 +64,6 @@
      • Making Complex Queries Using Filters

        Create complex queries by combining filters.

      -

      Prerequisites

      -

      There are not any privileges to be required for this APIs.

      Creating Attribute Filters

      diff --git a/org.tizen.tutorials/html/web/tizen/content/content_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/content/content_tutorial_w.htm index 75734e4..b4eee22 100644 --- a/org.tizen.tutorials/html/web/tizen/content/content_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/content/content_tutorial_w.htm @@ -23,6 +23,7 @@

      Content

      - -

      Prerequisites

      -

      To use the content APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

      -
      <tizen:privilege name="http://tizen.org/privilege/content.read"/>
      -<tizen:privilege name="http://tizen.org/privilege/content.write"/>

      Task

      In the Media Content task, we will walk through how to browse and manage the media directories in your application.

      + +

      Prerequisites

      +

      To use the Content API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the config.xml file:

      +
      +<tizen:privilege name="http://tizen.org/privilege/content.read"/>
      +<tizen:privilege name="http://tizen.org/privilege/content.write"/>
      +
      +

      Browsing Content

      @@ -107,7 +112,7 @@ manager.find(onContentItemArraySuccess, null, null, filter); Note - To retrieve a specific set of content items, you can specify a content directory (with the directory ID), filter, and sorting order for the search operation through the directoryId, filter and sortMode parameters (for attributes supported in the filter, see Content Filter Attributes).

      In this example, the directory ID is set to null (which means that all directories are searched), the filter retrieves all content items whose type is VIDEO, and no sorting order is defined (which means that the default sorting order is used).

      + To retrieve a specific set of content items, you can specify a content directory (with the directory ID), filter, and sorting order for the search operation through the directoryId, filter and sortMode parameters (for attributes supported in the filter, see Content Filter Attributes).

      In this example, the directory ID is set to null (which means that all directories are searched), the filter retrieves all content items whose type is VIDEO, and no sorting order is defined (which means that the default sorting order is used).

    32. @@ -117,7 +122,8 @@ manager.find(onContentItemArraySuccess, null, null, filter);

      Learning how to view content details and update them is a basic content management skill:

        -
      1. Retrieve theContentManager interface instance (in mobile and wearable applications) using the tizen global object, and search for the item whose details you want to update.

        In the following example, the item whose title is image7.jpg is retrieved.

        var manager = tizen.content();
        +   
      2. Retrieve the ContentManager interface instance (in mobile and wearable applications) using the tizen global object, and search for the item whose details you want to update.

        In the following example, the item whose title is image7.jpg is retrieved.

        +
        var manager = tizen.content;
         
         var filter = new tizen.AttributeFilter("title", "EXACTLY", "image7.jpg");
         manager.find(onMediaItemArraySuccess, null, null, filter);
      3. @@ -206,7 +212,7 @@ tizen.content.unsetChangeListener(); tizen.content.createPlaylist("My new playlist", createSuccess);
      4. -
      5. To create a new playlist based on an existing one (basically copy the existing playlist content to a new playlist), use the createPlaylist() method, passing the source playlist as an argument: +
      6. To create a new playlist based on an existing one (basically copy the existing playlist content to a new playlist), use the createPlaylist() method, passing the source playlist as a parameter:
        function createSuccess(playlist)
         {
        @@ -316,7 +322,7 @@ tizen.content.getPlaylists(function(playlists)
         });
      7. -
      8. To change the position of a single playlist item (track), use the move() method of the Playlist interface. The 2nd argument indicates how much and in which direction the item is moved. +
      9. To change the position of a single playlist item (track), use the move() method of the Playlist interface. The second parameter indicates how much and in which direction the item is moved.

        Note that before moving the item, first you must retrieve it using the get() method.

         var myItem; /* Assume that it was retrieved using the get() method */
        @@ -331,7 +337,7 @@ tizen.content.getPlaylists(function(playlists)
            myPlaylist.move(myItem, -2, moveSuccess);
         });
        -

        The example above moves the track 2 positions up on the playlist. The second argument of the move() method can be a negative value, which means moving the track up, or a positive value, which means moving the track down. If the value is greater than number of tracks above or below, the item is accordingly moved to the beginning or end of the playlist.

        +

        The example above moves the track 2 positions up on the playlist. The second parameter of the move() method can be a negative value, which means moving the track up, or a positive value, which means moving the track down. If the value is greater than number of tracks above or below, the item is accordingly moved to the beginning or end of the playlist.

      10. diff --git a/org.tizen.tutorials/html/web/tizen/content/download_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/content/download_tutorial_w.htm index 0c37d1c..ebd472e 100644 --- a/org.tizen.tutorials/html/web/tizen/content/download_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/content/download_tutorial_w.htm @@ -23,6 +23,7 @@

        Content

          +
        • Prerequisites
        • Managing Downloads
        • Checking the Download State and Information @@ -48,16 +49,21 @@

          Warm-up

          Become familiar with the Download API basics by learning about:

          - -

          Prerequisites

          -

          To use the download APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

          -
          <tizen:privilege name=" http://tizen.org/privilege/download"/>

          Task

          In the Download Manager task, we will walk through how to download URL content to the device storage.

          + +

          Prerequisites

          + +

          To use the Download API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

          +
          +<tizen:privilege name=" http://tizen.org/privilege/download"/>
          +
          +

          Managing Downloads

          diff --git a/org.tizen.tutorials/html/web/tizen/content/task_downloadmanager_w.htm b/org.tizen.tutorials/html/web/tizen/content/task_downloadmanager_w.htm index 7b50c06..84827e2 100644 --- a/org.tizen.tutorials/html/web/tizen/content/task_downloadmanager_w.htm +++ b/org.tizen.tutorials/html/web/tizen/content/task_downloadmanager_w.htm @@ -107,7 +107,7 @@ $('#refresh-button').on('tap', function onRefreshBtnTap(event)

          Defining the Template Mechanism

          -

          The Template Manager is used to follow the MVC architecture while generating a view item for the downloaded content. The whole process of generating the output HTML is divided into 3 parts:

          +

          The Template Manager is used to follow the MVC (Model View Controller) architecture while generating a view item for the downloaded content. The whole process of generating the output HTML is divided into 3 parts:

          1. js/app.ui.templateManager.js Source File diff --git a/org.tizen.tutorials/html/web/tizen/messaging/messaging_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/messaging/messaging_tutorial_w.htm index d1c3eb4..d18cc41 100644 --- a/org.tizen.tutorials/html/web/tizen/messaging/messaging_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/messaging/messaging_tutorial_w.htm @@ -23,6 +23,7 @@

            Content

              +
            • Prerequisites
            • Message sending
              • Creating and Sending Messages
              • @@ -51,6 +52,7 @@

                Warm-up

                Become familiar with the Messaging API basics by learning about:

                  +
                • Prerequisites

                  Prepare your application to use the messaging functionality.

                • Message sending - -

                  Prerequisites

                  -

                  To use the messaging APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

                  -
                  <tizen:privilege name="http://tizen.org/privilege/messaging.read"/>
                  -<tizen:privilege name="http://tizen.org/privilege/messaging.write"/>
                  -

                  Task

                  In the Chatter task, we will walk through how to send, receive, and manage messages in your application.

                  + + +

                  Prerequisites

                  +

                  To use the Messaging API, the application has to request permission by adding the following privileges to the config.xml file:

                  +
                  +<tizen:privilege name="http://tizen.org/privilege/messaging.read"/>
                  +<tizen:privilege name="http://tizen.org/privilege/messaging.write"/>
                  +
                  +

                  Creating and Sending Messages

                  @@ -169,7 +174,7 @@ function serviceSuccess(messageService)                             to: ["0001"],                             plainBody: "Surprise!"                          }); -   /* SIM is selected (first SIM - 1, second SIM - 2): */ +   /* SIM is selected (first SIM - 1, second SIM - 2) */    messageService.sendMessage(message, sendSuccess, null, 2); } @@ -182,7 +187,7 @@ tizen.messaging.getMessageServices("messaging.sms", serviceSuccess);

                  To create engaging applications with various messaging features, you must learn to work with messages in the message store:

                    -
                  1. Retrieve messages whose sender is "me" from the message storage using the findMessages() method of the MessageStorage interface with a filter (for attributes supported in the filter, see Messaging Filter Attributes):

                    +
                  2. Retrieve messages whose sender is "me" from the message storage using the findMessages() method of the MessageStorage interface with a filter (for attributes supported in the filter, see Messaging Filter Attributes):

                     var emailService;
                     function serviceListCB(services) 
                    @@ -247,7 +252,7 @@ function onFindFoldersFail(error)
                        console.log("Error occurred:  " + error.name);
                     }
                     
                  3. -
                  4. Define a filter (for attributes supported by the message folder filter, see Messaging Filter Attributes):

                    +
                  5. Define a filter (for attributes supported by the message folder filter, see Messaging Filter Attributes):

                     var filter = new tizen.AttributeFilter("serviceId", "EXACTLY", service.id);
                     
                  6. diff --git a/org.tizen.tutorials/html/web/tizen/messaging/messaging_tutorials_w.htm b/org.tizen.tutorials/html/web/tizen/messaging/messaging_tutorials_w.htm index cfa8c4c..4aa0ad0 100644 --- a/org.tizen.tutorials/html/web/tizen/messaging/messaging_tutorials_w.htm +++ b/org.tizen.tutorials/html/web/tizen/messaging/messaging_tutorials_w.htm @@ -11,7 +11,7 @@ - Messaging: Managing and Receiving SMS, MMS, and Email Messages + Messaging: Managing Messages and Push Notifications @@ -25,21 +25,25 @@
        -

        Messaging: Managing and Receiving SMS, MMS, and Email Messages

        +

        Messaging: Managing Messages and Push Notifications

        The messaging tutorials demonstrate how to use the following features in creating Tizen Web applications:

        -
          -
        • Messaging: Managing and Receiving SMS, MMS, and Email Messages

          Demonstrates how you can create, send, and read messages as well as manage messages in the message storage.

        • -
        • Push: Receiving Push Notifications from a Push Server

          Demonstrates how you can register your application, connect to the push service, and start receiving push notifications.

        • + - +

          The following tutorials apply in mobile applications only:

          + + diff --git a/org.tizen.tutorials/html/web/tizen/messaging/push_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/messaging/push_tutorial_w.htm index cd8949e..1e15a65 100644 --- a/org.tizen.tutorials/html/web/tizen/messaging/push_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/messaging/push_tutorial_w.htm @@ -23,6 +23,7 @@

          Content

          @@ -45,14 +46,18 @@

          Warm-up

          Become familiar with the Push API basics by learning about:

          + +

          Prerequisites

          +

          To use the Push API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

          +
          +<tizen:privilege name="http://tizen.org/privilege/push"/>
          +
          -

          Prerequisites

          -

          To use the push APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

          -
          <tizen:privilege name="http://tizen.org/privilege/push"/>
          - +

          Registering to the Push Service

          To receive push notifications, you must learn how to register your application to the push service:

          diff --git a/org.tizen.tutorials/html/web/tizen/messaging/task_chatter_w.htm b/org.tizen.tutorials/html/web/tizen/messaging/task_chatter_w.htm index d994563..0735037 100644 --- a/org.tizen.tutorials/html/web/tizen/messaging/task_chatter_w.htm +++ b/org.tizen.tutorials/html/web/tizen/messaging/task_chatter_w.htm @@ -65,7 +65,7 @@
        • main_page.tpl Source File

          The header section of the screen is defined within a <div> element whose data-role attribute is set to header. The header section determines the title of the screen.

          -

          The content section of the screen is added dynamically and displays a contact list (in mobile or wearable applications). The footer section contains a tab bar with a button for starting a new chat.

          +

          The content section of the screen is added dynamically and displays a contact list (in mobile or wearable applications). The footer section contains a tab bar with a button for starting a new chat.

          <!--Header section-->
           <div id="main-header" data-role="header" data-position="fixed">
              <h1>Chatter</h1>
          @@ -104,7 +104,7 @@ $('#contactSelect-button').on('click', function(event)
             

          Defining the Select Contact Screen

          1. contactSelect.tpl Source File -

            The content section of the Select contact screen displays a contact list. If the user taps the Enter number button (in mobile or wearable applications), a pop-up appears allowing the user to enter a phone number for a contact not on the list. The popup component (in mobile or wearable applications) contains a form for number input.

            +

            The content section of the Select contact screen displays a contact list. If the user taps the Enter number button (in mobile or wearable applications), a pop-up opens allowing the user to enter a phone number for a contact not on the list. The popup component (in mobile or wearable applications) contains a form for number input.

             <!--Content section-->
             <div data-role="content">
            diff --git a/org.tizen.tutorials/html/web/tizen/content/exif_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/multimedia/exif_tutorial_w.htm
            similarity index 99%
            rename from org.tizen.tutorials/html/web/tizen/content/exif_tutorial_w.htm
            rename to org.tizen.tutorials/html/web/tizen/multimedia/exif_tutorial_w.htm
            index f7f0171..c26eb1f 100644
            --- a/org.tizen.tutorials/html/web/tizen/content/exif_tutorial_w.htm
            +++ b/org.tizen.tutorials/html/web/tizen/multimedia/exif_tutorial_w.htm
            @@ -30,7 +30,7 @@
                     

        Related Info

        @@ -53,9 +53,6 @@
      11. Copying the EXIF Data

        Copy the EXIF data from one JPEG file to another.

      12. -

        Prerequisites

        -

        There are not any privileges to be required for this APIs.

        -

        Loading the EXIF Data

        Learning how to retrieve EXIF data from JPEG files is a useful content management skill:

        diff --git a/org.tizen.tutorials/html/web/tizen/multimedia/fm_radio_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/multimedia/fm_radio_tutorial_w.htm index 1ab4617..c792f0f 100644 --- a/org.tizen.tutorials/html/web/tizen/multimedia/fm_radio_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/multimedia/fm_radio_tutorial_w.htm @@ -51,9 +51,6 @@
      13. Getting Information about Interruptions

        Set an event handler to retrieve information about radio playback interruptions and restart the playback.

      14. -

        Prerequisites

        -

        There are not any privileges to be required for this APIs.

        -

        Managing the FM Radio

        Starting and stopping an FM radio and changing the frequency is a basic FM radio management skill:

        diff --git a/org.tizen.tutorials/html/web/tizen/multimedia/media_controller_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/multimedia/media_controller_tutorial_w.htm index ca1ccde..4f37aef 100644 --- a/org.tizen.tutorials/html/web/tizen/multimedia/media_controller_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/multimedia/media_controller_tutorial_w.htm @@ -23,6 +23,7 @@
        @@ -40,14 +41,15 @@

        Media Controller: Communicating Between the Media Controller Server and Client

        -

        -This tutorial demonstrates how you can to develop server and client applications for controlling various media functions of the device.

        +

        This tutorial demonstrates how you can to develop server and client applications for controlling various media functions of the device.

        -

        This feature is supported in mobile applications only.

        +

        The Media Controller API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable applications. All mandatory APIs are supported on the Tizen Emulators.

        Warm-up

        Become familiar with the Media Controller API basics by learning about:

          +
        • Prerequisites +

          Prepare your application to use the media controller functionality.

        • Getting the Client and Server

          Create a server, and get a client and find all active servers.

        • Managing Requests @@ -58,10 +60,14 @@ This tutorial demonstrates how you can to develop server and client applications

          Send a custom command from the client, and receive and handle it in the server.

        -

        Prerequisites

        -

        To use the media controller APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

        -
        <tizen:privilege name="http://tizen.org/privilege/mediacontroller.client"/>
        -<tizen:privilege name="http://tizen.org/privilege/mediacontroller.server"/>
        +

        Prerequisites

        + +

        To use the Media Controller API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the config.xml file:

        +
        +<tizen:privilege name="http://tizen.org/privilege/mediacontroller.client"/>
        +<tizen:privilege name="http://tizen.org/privilege/mediacontroller.server"/>
        +
        +

        Getting the Client and Server

        @@ -80,7 +86,7 @@ var mcClient = tizen.mediaController.getClient(); -
      15. Define a success (and optionally error) event handler by implementing the MediaControllerServerInfoArraySuccessCallback interface: +
      16. Define a success (and optionally error) event handler by implementing the MediaControllerServerInfoArraySuccessCallback interface (in mobile and wearable applications):
         var mcServerInfo;
        @@ -101,7 +107,7 @@ function findErrorCallback(e)
         
      17. -
      18. To search for all activated media controller servers, use the findServers() method of the MediaControllerClient interface: +
      19. To search for all activated media controller servers, use the findServers() method of the MediaControllerClient interface (in mobile and wearable applications):
         mcClient.findServers(findSuccessCallback, findErrorCallback);
        @@ -113,7 +119,7 @@ mcClient.findServers(findSuccessCallback, findErrorCallback);

        To manage the media controller features in your application, you must learn to handle requests from the client to the server:

          -
        1. Create a MediaControllerChangeRequestPlaybackInfoCallback object to define listeners for getting the requests from a client. +
        2. Create a MediaControllerChangeRequestPlaybackInfoCallback object (in mobile and wearable applications) to define listeners for getting the requests from a client.

          Each listener must invoke the appropriate function to perform the related update on the server and send an appropriate notification to the client. For example, the onplaybackstaterequest listener must use the updatePlaybackState() method to update the playback state.

          @@ -166,7 +172,7 @@ function errorCallback(e)
        3. -
        4. You can send a request from the client using the sendPlaybackState(), sendPlaybackPosition(), endShuffleMode(), or sendRepeatMode() method of the MediaControllerServerInfo interface. +
        5. You can send a request from the client using the sendPlaybackState(), sendPlaybackPosition(), endShuffleMode(), or sendRepeatMode() method of the MediaControllerServerInfo interface (in mobile and wearable applications).

          In the following example, send a request for the changing the playback state to paused using the sendPlaybackState() method:

          @@ -188,7 +194,7 @@ var watcherId;
        6. -
        7. Define the event handlers for different notifications by implementing the MediaControllerPlaybackInfoChangeCallback interface: +
        8. Define the event handlers for different notifications by implementing the MediaControllerPlaybackInfoChangeCallback interface (in mobile and wearable applications):
           var playbackListener = 
          @@ -246,7 +252,7 @@ var exampleCustomCommandData =
           
        9. -
        10. Define a success (and optionally error) callback implementing the MediaControllerSendCommandSuccessCallback interface: +
        11. Define a success (and optionally error) callback implementing the MediaControllerSendCommandSuccessCallback interface (in mobile and wearable applications):
           function sendCommandSuccessCallback(response) 
          @@ -272,7 +278,7 @@ mcServerInfo.sendCommand("myPlaylistFilter", sendCommandSuccessCallbac
           
        12. On the server side:
            -
          1. Create the MediaControllerReceiveCommandCallback object to define a listener for receiving custom commands from a client: +
          2. Create the MediaControllerReceiveCommandCallback object (in mobile and wearable applications) to define a listener for receiving custom commands from a client:
             var commandReceiveListener = function(client, command, data) 
            @@ -282,7 +288,7 @@ var commandReceiveListener = function(client, command, data)
                return {reply: 'response from server'};
             };
             
            -

            The callback function within the listener returns the object with the response to the client. The client can obtain this value as an argument of the success callback of the sendCommand() method that it used to send the command.

            +

            The callback within the listener returns the object with the response to the client. The client can obtain this value as an argument of the success callback of the sendCommand() method that it used to send the command.

          3. Add the listener defined in the MediaControllerReceiveCommandCallback object to the server: diff --git a/org.tizen.tutorials/html/web/tizen/multimedia/multimedia_tutorials_w.htm b/org.tizen.tutorials/html/web/tizen/multimedia/multimedia_tutorials_w.htm index 7da88b4..2c56582 100644 --- a/org.tizen.tutorials/html/web/tizen/multimedia/multimedia_tutorials_w.htm +++ b/org.tizen.tutorials/html/web/tizen/multimedia/multimedia_tutorials_w.htm @@ -40,12 +40,12 @@
          4. Sound: Controlling the Sound Volume Level and the Sound Devices

            Demonstrates how you can manage the device volume levels and the sound devices.

          5. -

            The following tutorials apply in mobile applications only:

            +

            The following tutorials apply in mobile applications only:

            - + diff --git a/org.tizen.tutorials/html/web/tizen/multimedia/sound_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/multimedia/sound_tutorial_w.htm index ca23ab6..cd50ad9 100644 --- a/org.tizen.tutorials/html/web/tizen/multimedia/sound_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/multimedia/sound_tutorial_w.htm @@ -23,6 +23,7 @@

            Content

              +
            • Prerequisites
            • Managing Sound Mode and Volume
            • Monitoring Sound Mode and Volume Changes
            • Managing Sound Devices
            • @@ -48,15 +49,20 @@

              Warm-up

              Become familiar with the Sound API basics by learning about:

              -

              Prerequisites

              -

              To use the sound APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

              -
              <tizen:privilege name="http://tizen.org/privilege/volume.set"/>
              + +

              Prerequisites

              +

              To use the Sound API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

              +
              +<tizen:privilege name="http://tizen.org/privilege/volume.set"/>
              +
              +

              Managing Sound Mode and Volume

              diff --git a/org.tizen.tutorials/html/web/tizen/network/bluetooth_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/network/bluetooth_tutorial_w.htm index 22fa35f..e3ace97 100644 --- a/org.tizen.tutorials/html/web/tizen/network/bluetooth_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/network/bluetooth_tutorial_w.htm @@ -23,6 +23,7 @@

              Content

              - -

              Prerequisites

              -

              To use the application and bluetooth APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

              -
              <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
              -<tizen:privilege name="http://tizen.org/privilege/bluetooth"/>
              -

              Task

              In the Bluetooth Chat task, we will walk through how to use the device as a Bluetooth server or client in a chat application.

              + +

              Prerequisites

              +

              To use the Application (in mobile and wearable applications) and Bluetooth (in mobile and wearable applications) APIs, the application has to request permission by adding the following privileges to the config.xml file:

              +
              +<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
              +<tizen:privilege name="http://tizen.org/privilege/bluetooth"/>
              +
              +

              Managing the Local Bluetooth Adapter

              @@ -99,7 +103,7 @@
              var bluetoothSwitchAppControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/edit", null, "application/x-bluetooth-on-off");
               var adapter = tizen.bluetooth.getDefaultAdapter();
              -
            • Define a callback function for the launchAppControl() method: +
            • Define a callback for the launchAppControl() method:
              function launchSuccess()
               {
                  console.log("Bluetooth Settings application is successfully launched.");
              @@ -519,7 +523,7 @@ function onDeviceFound(device)
                  
            • When the callbacks are completed, initiate the Bluetooth Low Energy scan:

              adapter.startScan(onDeviceFound);
            • -
            • When the notifications about the connection are no longer required, unregister the listener from the device by calling the removeConnectStateChangeListener() method of the BluetoothLEDevice interface:

              +
            • When the notifications about the connection are no longer required, deregister the listener from the device by calling the removeConnectStateChangeListener() method of the BluetoothLEDevice interface:

              remoteDevice.removeConnectStateChangeListener(watchId);
          @@ -563,15 +567,13 @@ for (i; i < serviceUUIDs.length; i++)    showGATTService(service); }
        13. - -
        14. Retrieve all service UUIDs using the getServiceAllUuids() method of the BluetoothLEDevice interface.

          +
        15. Retrieve all service UUIDs using the getServiceAllUuids() method of the BluetoothLEDevice interface:

           var services = remoteDevice.getServiceAllUuids();
           
           console.log("Services length " + services.length);
           
          -
        16. - +

        Accessing the Bluetooth GATT Characteristic Value

        @@ -660,7 +662,7 @@ function onValueChange(value)
      20. Register a value change listener using the addValueChangeListener() method of the BluetoothGATTCharacteristic interface (in mobile and wearable applications):

        var watchId = property.addValueChangeListener(onValueChange);
      21. -
      22. When the notifications about the connection are no longer required, unregister the listener from the device by calling the removeValueChangeListener() method of the BluetoothGATTCharacteristic interface:

        +
      23. When the notifications about the connection are no longer required, deregister the listener from the device by calling the removeValueChangeListener() method of the BluetoothGATTCharacteristic interface:

        property.removeValueChangeListener(watchId);
      diff --git a/org.tizen.tutorials/html/web/tizen/network/network_tutorials_w.htm b/org.tizen.tutorials/html/web/tizen/network/network_tutorials_w.htm index 88c1c87..84ce09a 100644 --- a/org.tizen.tutorials/html/web/tizen/network/network_tutorials_w.htm +++ b/org.tizen.tutorials/html/web/tizen/network/network_tutorials_w.htm @@ -34,13 +34,13 @@

      Network: Connecting to the Network and Communicating with Messages

      -

      The Network tutorials demonstrate how to use the following features in creating Tizen Web applications:

      +

      The network tutorials demonstrate how to use the following features in creating Tizen Web applications:

      - + diff --git a/org.tizen.tutorials/html/web/tizen/network/nfc_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/network/nfc_tutorial_w.htm index 8a332f8..fbfed2c 100644 --- a/org.tizen.tutorials/html/web/tizen/network/nfc_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/network/nfc_tutorial_w.htm @@ -23,6 +23,7 @@

      Content

        +
      • Prerequisites
      • Managing NFC Connectivity
      • Detecting NFC Tags and Peer Devices
      • NDEF data @@ -48,11 +49,12 @@

        This tutorial demonstrates how you can use NFC connectivity to detect NFC tags and exchange data with NFC-enabled devices.

        -

        The NFC API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices.

        +

        The NFC API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The NFC API is supported on the Tizen wearable Emulator, but not on the Tizen mobile Emulator.

        Warm-up

        Become familiar with the NFC API basics by learning about:

        Task in Mobile Applications

        In the Contacts Exchanger task, we will walk through how to exchange contacts between devices over an NFC connection.

        + +

        Prerequisites

        +

        To use the Application (in mobile and wearable applications) and NFC (in mobile and wearable applications) APIs, the application has to request permission by adding the following privileges to the config.xml file:

        -

        Prerequisites

        -

        To use the application and NFC APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

        -
        <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
        +
        +<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
         <tizen:privilege name="http://tizen.org/privilege/nfc.cardemulation"/>
         <tizen:privilege name="http://tizen.org/privilege/nfc.common"/>
         <tizen:privilege name="http://tizen.org/privilege/nfc.p2p"/>
        -<tizen:privilege name="http://tizen.org/privilege/nfc.tag"/>
        +<tizen:privilege name="http://tizen.org/privilege/nfc.tag"/> +
        +

        Managing NFC Connectivity

        diff --git a/org.tizen.tutorials/html/web/tizen/network/secure_element_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/network/secure_element_tutorial_w.htm index 8f79dd4..bde787a 100644 --- a/org.tizen.tutorials/html/web/tizen/network/secure_element_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/network/secure_element_tutorial_w.htm @@ -24,6 +24,7 @@

        Content

          +
        • Prerequisites
        • Managing Secure Elements
        • Opening Sessions and Channels
        • Transmitting APDUs to Secure Elements
        • @@ -48,15 +49,20 @@

          Warm-up

          Become familiar with the Secure Element API basics by learning about:

          + +

          Prerequisites

          + +

          To use the Secure Element API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

          +
          +<tizen:privilege name="http://tizen.org/privilege/secureelement"/>
          +
          -

          Prerequisites

          -

          To use the secure element APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

          -
          <tizen:privilege name="http://tizen.org/privilege/secureelement"/>

          Managing Secure Elements

          @@ -147,7 +153,7 @@ session.openLogicalChannel([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x

          To use secure elements in your application, you must learn to transmit application protocol data units (APDU) to secure elements:

          1. To transmit an APDU command to a secure element, use the transmit() method of the Channel interface (in mobile and wearable applications).

            -/* The APDU command is defined in ISO7816-4 */  
            +/* APDU command is defined in ISO7816-4 */  
             channel.transmit(command, successCB, errorCB);
             
          2. The transmit() method registers the TransmitSuccessCallback interface (in mobile and wearable applications), which is invoked when a command has been successfully transmitted:

            @@ -172,7 +178,8 @@ channel.close();
                
          3. To close all channels within a specific session, use the closeChannels() method of the Session interface (in mobile and wearable applications):

             session.closeChannels();
             
          4. -
          5. To close a specific session, use the close() method of the Session interface:

            +     
          6. To close a specific session, use the close() method of the Session interface (in mobile and wearable applications):

            +
             session.close();
             
          7. To close all session for a specific reader, use the closeSessions() method of the Reader interface (in mobile and wearable applications):

            diff --git a/org.tizen.tutorials/html/web/tizen/network/task_bluetoothchat_w.htm b/org.tizen.tutorials/html/web/tizen/network/task_bluetoothchat_w.htm
            index c451608..acf46c3 100644
            --- a/org.tizen.tutorials/html/web/tizen/network/task_bluetoothchat_w.htm
            +++ b/org.tizen.tutorials/html/web/tizen/network/task_bluetoothchat_w.htm
            @@ -31,7 +31,7 @@
             		

        Related Info

        @@ -52,7 +52,7 @@

        This sample is a fully functional application for creating a chat application.

        Defining the Application Layout

        -

        The BluetoothChat sample application layout uses the template manager based on the MVC (Model-View-Controller) architecture, and consists of 3 screens: the main screen displays buttons for creating or joining a chat, the Choose your server screen displays a list of available servers, and the chat screen displays the conversation history, an input area, and a button, allowing the user to write and send messages.

        +

        The BluetoothChat sample application layout uses the template manager based on the MVC (Model View Controller) architecture, and consists of 3 screens: the main screen displays buttons for creating or joining a chat, the Choose your server screen displays a list of available servers, and the chat screen displays the conversation history, an input area, and a button, allowing the user to write and send messages.

        The following figure shows the main screens of the application.

        Figure: BluetoothChat screens

        @@ -71,7 +71,7 @@    <div id="start-header" data-role="header" data-position="fixed">       <h1>Bluetooth chat</h1>    </div>
      • -
      • The actual content section of the screen is defined within a <div> element whose data-role attribute is set to content. It contains buttons (in mobile or wearable applications) for turning on the Bluetooth connection and either creating or joining a server connection. The buttons displayed depend on whether the Bluetooth adapter is on.

        +
      • The actual content section of the screen is defined within a <div> element whose data-role attribute is set to content. It contains buttons (in mobile or wearable applications) for turning on the Bluetooth connection and either creating or joining a server connection. The buttons displayed depend on whether the Bluetooth adapter is on.

           <!--Content section-->
            <div id="start-content" data-role="content" data-scroll="none">
               <div class="box">
        @@ -176,7 +176,7 @@ $('#keyboard-ok-button').on('click', function(event)
         

        Defining the Choose Your Server Screen

        1. templates/choose_page.tpl Source File -
          1. The content section of the Choose your server screen displays a list (in mobile or wearable applications) of available servers.

            +
            1. The content section of the Choose your server screen displays a list (in mobile or wearable applications) of available servers.

               <div data-role="page" id="choose">
                  <!--Header section-->
              @@ -193,7 +193,7 @@ $('#keyboard-ok-button').on('click', function(event)
               
            2. -

              When the user taps a server name, the system starts searching for the server and attempts to connect to it. After connecting, the system displays confirmation pop-ups (in mobile or wearable applications).

              +

              When the user taps a server name, the system starts searching for the server and attempts to connect to it. After connecting, the system displays confirmation pop-ups (in mobile or wearable applications).

               $('#choose-content').on('tap', 'ul.ui-listview li', function() 
               {
              diff --git a/org.tizen.tutorials/html/web/tizen/network/task_contactsexchanger_w.htm b/org.tizen.tutorials/html/web/tizen/network/task_contactsexchanger_w.htm
              index b46143d..4f47b49 100644
              --- a/org.tizen.tutorials/html/web/tizen/network/task_contactsexchanger_w.htm
              +++ b/org.tizen.tutorials/html/web/tizen/network/task_contactsexchanger_w.htm
              @@ -102,10 +102,10 @@ loadStartPage: function ui_loadStartPage()
               
            3. -

              If the default contact card is not defined, the content section of the screen displays a message and a button (in mobile or wearable applications) allowing user to create the default card.

              +

              If the default contact card is not defined, the content section of the screen displays a message and a button (in mobile or wearable applications) allowing user to create the default card.

               <div class="box" id="temporaryBox">
              -   <p class="defaultText">Default card is not defined yet!<br>Do you want to define it now?</p>
              +   <p class="defaultText">Default card is not defined yet!<br/>Do you want to define it now?</p>
                  <div data-role="button" class="ui-btn-create">Create default card</div>
               </div>
               
              @@ -141,7 +141,7 @@ loadStartPage: function ui_loadStartPage()

            Defining the Contacts List Screen

            1. index.html Source File -

              The Contacts list screen displays an aggregated contact list (in mobile or wearable applications) sorted by name. The contacts are loaded from the device default address book using the Contact API methods.

              +

              The Contacts list screen displays an aggregated contact list (in mobile or wearable applications) sorted by name. The contacts are loaded from the device default address book using the Contact API methods.

               <ul data-role="listview" id="list-choose">
                  <li class="ui-li-multiline">
              @@ -177,19 +177,19 @@ $('#transfer').on('pageshow', function()
                        if (option === 'read') 
                        {
                           self.prepareWaitingPage('Card to device', 
              -                                    'PUT WIRELESS TAG<br>CLOSE TO<br>YOUR DEVICE');
              +                                    'PUT WIRELESS TAG<br/>CLOSE TO<br/>YOUR DEVICE');
                           self.app.nfc.card.setTagDetectRead();
                        } 
                        else if (option === 'write') 
                        {
                           self.prepareWaitingPage('Device to card', 
              -                                    'PUT WIRELESS TAG<br>CLOSE TO<br>YOUR DEVICE');
              +                                    'PUT WIRELESS TAG<br/>CLOSE TO<br/>YOUR DEVICE');
                           self.app.nfc.card.setTagDetectWrite();
                        } 
                        else 
                        {
                           self.prepareWaitingPage('Device to device', 
              -                                    'PUT YOUR DEVICE<br>CLOSE TO<br>OTHER DEVICE');
              +                                    'PUT YOUR DEVICE<br/>CLOSE TO<br/>OTHER DEVICE');
                           self.app.nfc.peer.setTargetDetect();
                        }
                     }
              diff --git a/org.tizen.tutorials/html/web/tizen/security/keymanager_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/security/keymanager_tutorial_w.htm
              index 6eaa34f..08a4663 100644
              --- a/org.tizen.tutorials/html/web/tizen/security/keymanager_tutorial_w.htm
              +++ b/org.tizen.tutorials/html/web/tizen/security/keymanager_tutorial_w.htm
              @@ -11,7 +11,7 @@
                   
                   
               
              -    Key Manager: Save, get, or remove data
              +    Key Manager: Saving, Getting, and Removing Data
               
               
               
              @@ -23,9 +23,9 @@
                   
              -

              Key Manager: Save, get, or remove data

              +

              Key Manager: Saving, Getting, and Removing Data

              -

              Prerequisites

              -

              There are not any privileges to be required for this APIs.

              -

              Save data in Key Manager

              -
                -
              1. Save data

                - var data_name = "data1", raw_data = "my data";
                -
                - function onSave() {
                -     console.log("Successfully saved data");
                - }
                -
                - tizen.keymanager.saveData(data_name, raw_data, null, onSave);
                - 
              2. -
              3. -

                Application this time set permission for application with id 9PdoiICQ4c to remove its data.

                -
                -  var data_name = "data1", raw_data = "my data";
                -
                - function onPermissionSet() {
                -     console.log("Successfully set permission");
                - }
                -
                - function onSave() {
                -     // Dictionary does not require package ID because an
                -     // application can only set permission for data which it saved
                -     tizen.keymanager.setPermission({
                -         "name": data_name
                -     }, "9PdoiICQ4c", "READ_REMOVE", onPermissionSet);
                - }
                -
                - tizen.keymanager.saveData(data_name, raw_data, null, onSave);
                - 
              4. -
              +

              This tutorial demonstrates how you can use the key manager to manage data in a secure manner.

              -

              Remove data from Key Manager

              -
                -
              1. Remove data from application which added particular data.

                - var data_name = "data1", raw_data = "my data";
                +

                The Key Manager API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable devices. All mandatory APIs are supported on the Tizen Emulators.

                - function onSave() { - // do something +

                Warm-up

                +

                Become familiar with the Key Manager API basics by learning about:

                +
                  +
                • Saving Data +

                  Store data in a secure repository.

                • - // Dictionary does not require package ID because the - // application which is calling removeData() saved "data1" - tizen.keymanager.removeData({ - "name": data_name - }); - } +
                • Getting Data +

                  Retrieve data from a secure repository.

                • - tizen.keymanager.saveData(data_name, raw_data, null, onSave); -
              2. - -
              3. Remove data from other application with assuming that application which, added data gave, permission for it.

                - -

                Now the other application can remove it assuming they are on list item 0

                -
                +		
              4. Removing Data +

                Remove data from a secure repository.

              5. +
      + +

      Saving Data

      - var aliases = tizen.keymanager.getDataAliasList(); +

      To save data in a repository:

      - if (aliases.length != 0) { - // Assuming the application calling removeData() has permission - // to remove aliases[0] - var app_data = tizen.keymanager.removeData(aliases[0]); - } - +
        +
      1. Save the data using the saveData() method:

        + +
        +var data_name = "data1", raw_data = "my data";
        +
        +tizen.keymanager.saveData(data_name, raw_data, null, onSave);
        +
      2. + +
      3. +

        To set a permission for an application to remove the data, use the setPermission() method in the data saving callback.

        +

        In this example, the permission is granted for an application with the 9PdoiICQ4c ID:

        +
        +function onPermissionSet() 
        +{
        +   console.log("Successfully set permission");
        +}
        +
        +function onSave() 
        +{
        +   /* Dictionary does not require a package ID because an */
        +   /* application can only set permission for data which it saved */
        +   tizen.keymanager.setPermission({"name": data_name}, "9PdoiICQ4c", 
        +                                  "READ_REMOVE", onPermissionSet);
        +}
        +
        +
      -

      Get Data from key manager

      + +

      Getting Data

      + +

      To retrieve data from a repository:

      + +
        +
      • Retrieve data which your application has added:

        +
        +var data_name = "data1", raw_data = "my data";
        +
        +function onSave() 
        +{
        +   /* Dictionary does not require a package ID because the */
        +   /* application calling getData() saved "data1" */
        +   var app_data = tizen.keymanager.getData({"name": data_name});
        +   console.log("App data: " + app_data + " was retrieved");
        +}
        +
        +tizen.keymanager.saveData(data_name, raw_data, null, onSave);
        +
        +
      • + +
      • Retrieve data which another application has saved, and granted permission for you to access.

        +

        The following example assumes that the application that created aliases[0] also gave your application permission to read it:

        + +
        +var aliases = tizen.keymanager.getDataAliasList();
        +
        +if (aliases.length != 0) 
        +{
        +   /* Assuming that the application calling getData() */
        +   /* has permission to read aliases[0] */
        +   var app_data = tizen.keymanager.getData(aliases[0]);
        +   console.log("App data: " + app_data + " was retrieved");
        +}
        +
        +
      • +
      + +

      Removing Data

      + +

      To remove data from a repository:

      +
        -
      1. Getdata from application which added particular data.

        - var data_name = "data1", raw_data = "my data";
        +
      2. Remove data which your application has added:

        - var data_name = "data1", raw_data = "my data"; +
        +var data_name = "data1", raw_data = "my data";
         
        - function onSave() {
        -     // Dictionary does not require package ID because the
        -     // application which is calling getData() saved "data1"
        -     var app_data = tizen.keymanager.getData({
        -         "name": data_name
        -     });
        -     console.log("App data: " + app_data + " was retrieved");
        - }
        +function onSave() 
        +{
        +   /* Do something */
         
        - tizen.keymanager.saveData(data_name, raw_data, null, onSave);
        - 
      3. +   /* Dictionary does not require a package ID because the */ +   /* application calling removeData() saved "data1" */ +   tizen.keymanager.removeData({"name": data_name}); +} -
      4. Get data from other application with assuming that application, which added data, gave permission for it.

        - -

        Now the other application can read it assuming they are on list item 0

        -
        -
        - var aliases = tizen.keymanager.getDataAliasList();
        -
        - if (aliases.length != 0) {
        -     // Assuming the application calling getData() has permission to read
        -     // aliases[0]
        -     var app_data = tizen.keymanager.getData(aliases[0]);
        -     console.log("App data: " + app_data + " was retrieved");
        - }
        - 
      5. +tizen.keymanager.saveData(data_name, raw_data, null, onSave); +
        +
      6. +
      7. Remove data which another application has saved, and granted permission for you to remove.

        +

        The following example assumes that the application that created aliases[0] also gave your application permission to remove it:

        + +
        +var aliases = tizen.keymanager.getDataAliasList();
        +
        +if (aliases.length != 0) 
        +{
        +   /* Assuming that the application calling removeData() */
        +   /* has permission to remove aliases[0] */
        +   var app_data = tizen.keymanager.removeData(aliases[0]);
        +}
        +
        +
      diff --git a/org.tizen.tutorials/html/web/tizen/security/security_tutorials_w.htm b/org.tizen.tutorials/html/web/tizen/security/security_tutorials_w.htm index efd5034..67ae040 100644 --- a/org.tizen.tutorials/html/web/tizen/security/security_tutorials_w.htm +++ b/org.tizen.tutorials/html/web/tizen/security/security_tutorials_w.htm @@ -11,30 +11,33 @@ - Security: Storing and recalling data in secure storage + Security: Storing and Recalling Data in a Secure Storage
      -

      Security: Storing and recalling data in secure storage

      +

      Security: Storing and Recalling Data in a Secure Storage

      -

      The Security tutorials demonstrate how to use the following features in creating Tizen Web applications:

      +

      The security tutorials demonstrate how to use the following features in creating Tizen Web applications:

      diff --git a/org.tizen.tutorials/html/web/tizen/service/service_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/service/service_tutorial_w.htm index af183ed..feb4c6d 100644 --- a/org.tizen.tutorials/html/web/tizen/service/service_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/service/service_tutorial_w.htm @@ -23,6 +23,7 @@

      Content

        +
      • Prerequisites
      • Creating a Service Application
      • Packaging a Service Application
      • Launching a Service Application
      • @@ -46,6 +47,7 @@

        Become familiar with the service application basics by learning about:

        -

        Prerequisites

        -

        To use the application APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

        -
        <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
        +

        Prerequisites

        + +

        To use the Application API, the application has to request permission by adding the following privilege to the config.xml file:

        +
        +<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
        +
        +

        Creating a Service Application

        @@ -93,7 +99,7 @@ module.exports.onStart = function()
      • Write the request handler with the onRequest() callback. -

        The callback is invoked to handle incoming service requests. Within the callback, write code for each request from other applications and the platform. To obtain the request, use the getRequestedAppControl() function in the Application API.

        +

        The callback is invoked to handle incoming service requests. Within the callback, write code for each request from other applications and the platform. To obtain the request, use the getRequestedAppControl() method in the Application API.

         module.exports.onRequest = function() 
         {
        @@ -130,7 +136,7 @@ module.exports.onExit = function()
         

        The <tizen:service> element allows you to define the characteristics of the service application. For example, you can specify the name, icon, and starting JavaScipt file of the service application.

         <?xml version="1.0"encoding="TF-8">
        -<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen=http://tizen.org/ns/widgets
        +<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
                 id="http://yourdomain/WebServiceApplication" version="1.0.0" viewmodes="maximized">
            <tizen:application id="websvcapp0.WebServiceApplication" package="websvcapp0" required_version="2.3" />
            <content src="index.html" />
        @@ -154,7 +160,7 @@ module.exports.onExit = function()
         
         
        • Launch by other applications -

          The Web application launches a service application by calling the launch() or launchAppControl() function with the service application ID:

          +

          The Web application launches a service application by calling the launch() or launchAppControl() method with the service application ID:

           tizen.application.launchAppControl(new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/service"),
                                              "websvcapp0.service1",
          @@ -178,14 +184,14 @@ tizen.application.launchAppControl(new tizen.ApplicationControl("http://tiz
           
           
          1. The service application can terminate itself when it receives a particular request. The following example code uses the Message Port API to send such a request to the service application.

            -

            The application sends a message by calling the sendMessage() function.

            +

            The application sends a message by calling the sendMessage() method.

             var remoteMsgPort = tizen.messageport.requestRemoteMessagePort("websvcapp0.service1", "SERVICE_SAMPLE2");
             remoteMsgPort.sendMessage([{key: "key", value: "SERVICE_EXIT"}]);
             
          2. -
          3. The service application can terminate itself by calling the exit() function after getting a signal through the message port: +
          4. The service application can terminate itself by calling the exit() method after getting a signal through the message port:
             var localMsgPort = tizen.messageport.requestLocalMessagePort("SERVICE_SAMPLE2");
             function onreceived(data, remoteMsgPort) 
            diff --git a/org.tizen.tutorials/html/web/tizen/social/bookmark_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/social/bookmark_tutorial_w.htm
            index 8edf717..813e555 100644
            --- a/org.tizen.tutorials/html/web/tizen/social/bookmark_tutorial_w.htm
            +++ b/org.tizen.tutorials/html/web/tizen/social/bookmark_tutorial_w.htm
            @@ -21,6 +21,7 @@
                 

            Content

              +
            • Prerequisites
            • Creating Bookmark Folders and Items
            • Deleting Bookmarks
            • Retrieving the Bookmark List
            • @@ -44,16 +45,20 @@

              Warm-up

              Become familiar with the Bookmark API basics by learning about:

              -

              Prerequisites

              -

              To use the bookmark APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

              -
              <tizen:privilege name="http://tizen.org/privilege/bookmark.read"/>
              -<tizen:privilege name="http://tizen.org/privilege/bookmark.write"/>
              +

              Prerequisites

              +

              To use the Bookmark API, the application has to request permission by adding the following privileges to the config.xml file:

              +
              +<tizen:privilege name="http://tizen.org/privilege/bookmark.read"/>
              +<tizen:privilege name="http://tizen.org/privilege/bookmark.write"/>
              +
              +

              Creating Bookmark Folders and Items

              To create engaging applications with bookmark-related features, you must learn how to add bookmark folders and items to the root bookmark folder and subfolders:

              diff --git a/org.tizen.tutorials/html/web/tizen/social/calendar_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/social/calendar_tutorial_w.htm index c9b581c..3c406bd 100644 --- a/org.tizen.tutorials/html/web/tizen/social/calendar_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/social/calendar_tutorial_w.htm @@ -21,6 +21,7 @@

              Content

                +
              • Prerequisites
              • Creating a Calendar
              • Events
                  @@ -60,6 +61,7 @@

                  Warm-up

                  Become familiar with the Calendar API basics by learning about:

                  - -

                  Prerequisites

                  -

                  To use the calendar APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

                  -
                  <tizen:privilege name="http://tizen.org/privilege/calendar.read"/>
                  -<tizen:privilege name="http://tizen.org/privilege/calendar.write"/>
                  -

                  Task

                  In the Event Manager task, we will walk through how to manage calendar events in your application.

                  +

                  Prerequisites

                  +

                  To use the Calendar API, the application has to request permission by adding the following privileges to the config.xml file:

                  +
                  +<tizen:privilege name="http://tizen.org/privilege/calendar.read"/>
                  +<tizen:privilege name="http://tizen.org/privilege/calendar.write"/>
                  +
                  + +

                  Creating a Calendar

                  Creating a new calendar is a basic calendar management skill:

                  @@ -214,7 +218,7 @@ myCalendar.find(eventSearchSuccessCallback);
            Note - To retrieve a specific set of events, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

            In this example, all the events are retrieved because no filter is used.

            + To retrieve a specific set of events, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

            In this example, all the events are retrieved because no filter is used.

          5. @@ -267,7 +271,7 @@ myCalendar.find(eventSearchSuccessCallback, errorCallback);
          Note - To retrieve a specific set of events, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

          In this example, all the events are retrieved because no filter is used.

          + To retrieve a specific set of events, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

          In this example, all the events are retrieved because no filter is used.

        • @@ -433,7 +437,7 @@ myCalendar.find(taskSearchSuccessCallback);
        Note - To retrieve a specific set of tasks, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

        In this example, all the tasks are retrieved because no filter is used.

        + To retrieve a specific set of tasks, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

        In this example, all the tasks are retrieved because no filter is used.

      • @@ -464,7 +468,7 @@ myCalendar.find(taskSearchSuccessCallback); Note - To retrieve a specific set of tasks, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

        In this example, all the tasks are retrieved because no filter is used.

        + To retrieve a specific set of tasks, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

        In this example, all the tasks are retrieved because no filter is used.

        diff --git a/org.tizen.tutorials/html/web/tizen/social/call_history_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/social/call_history_tutorial_w.htm index 55d495a..880d072 100644 --- a/org.tizen.tutorials/html/web/tizen/social/call_history_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/social/call_history_tutorial_w.htm @@ -21,6 +21,7 @@

        Content

          +
        • Prerequisites
        • Searching for Call History Items
        • Removing Call History Items
        • Monitoring the Call History
        • @@ -44,19 +45,21 @@

          Warm-up

          Become familiar with the Call History API basics by learning about:

          - -

          Prerequisites

          -

          To use the call history APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

          -
          <tizen:privilege name="http://tizen.org/privilege/callhistory.read"/>
          -<tizen:privilege name="http://tizen.org/privilege/callhistory.write"/>
          -

          Task

          In the Call Log task, we will walk through how to manage call logs in your application.

          +

          Prerequisites

          +

          To use the Call History API, the application has to request permission by adding the following privileges to the config.xml file:

          +
          +<tizen:privilege name="http://tizen.org/privilege/callhistory.read"/>
          +<tizen:privilege name="http://tizen.org/privilege/callhistory.write"/>
          +
          +

          Searching for Call History Items

          @@ -72,9 +75,9 @@       /* Process the CallHistoryEntry */    } } -
        • Use the filter parameter of the find() method to define a filter for the query result set. A filter with the CallHistoryEntry attributes is used to limit the results of the call history search.

          You can define various filters:

          +
        • Use the filter parameter of the find() method to define a filter for the query result set. A filter with the CallHistoryEntry attributes is used to limit the results of the call history search.

          You can define various filters:

            -
          • The AttributeFilter type is used to search based on a single CallHistoryEntry attribute (for attributes supported in the filter, see CallHistory Filter Attributes).

            For example, the following filters define that only cellular calls or calls where the remote party has the telephone number 123456789 are included in the query results:

            /* First filter example */
            +     
          • The AttributeFilter type is used to search based on a single CallHistoryEntry attribute (for attributes supported in the filter, see CallHistory Filter Attributes).

            For example, the following filters define that only cellular calls or calls where the remote party has the telephone number 123456789 are included in the query results:

            /* First filter example */
             var filter = new tizen.AttributeFilter("type", "EXACTLY", "TEL");
             
             /* Second filter example */
            @@ -168,7 +171,7 @@ tizen.callhistory.find(onSuccess, onError, numberFilter);
             
          • Use the addChangeListener() method of the CallHistory interface to register a listener for observing call history changes:

            var callHistoryListener = tizen.callhistory.addChangeListener(onHistoryChange);
          • -
          • Use the removeChangeListener() method to unregister a previously registered listener. Use the ID returned by the addChangeListener():

            tizen.callhistory.removeChangeListener(callHistoryListener);
          • +
          • Use the removeChangeListener() method to deregister a previously registered listener. Use the ID returned by the addChangeListener():

            tizen.callhistory.removeChangeListener(callHistoryListener);
    diff --git a/org.tizen.tutorials/html/web/tizen/social/contact_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/social/contact_tutorial_w.htm index 277db99..66f43e3 100644 --- a/org.tizen.tutorials/html/web/tizen/social/contact_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/social/contact_tutorial_w.htm @@ -21,6 +21,7 @@

    Content

      +
    • Prerequisites
    • Address book
      • Creating an Address Book
      • @@ -68,6 +69,7 @@

        Warm-up

        Become familiar with the Contact API basics by learning about:

          +
        • Prerequisites

          Prepare your application to use the contact functionality.

        • Address book -

          Prerequisites

          -

          To use the contact APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

          -
          <tizen:privilege name="http://tizen.org/privilege/contact.read"/>
          -<tizen:privilege name="http://tizen.org/privilege/contact.write"/>
          + +

          Prerequisites

          +

          To use the Contact API, the application has to request permission by adding the following privileges to the config.xml file:

          +
          +<tizen:privilege name="http://tizen.org/privilege/contact.read"/>
          +<tizen:privilege name="http://tizen.org/privilege/contact.write"/>
          +

          Creating an Address Book

          @@ -220,7 +225,7 @@ try Note - To retrieve a specific contact, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Contact Filter Attributes).

          In this example, contacts whose first name contains "Chris" are retrieved and sorted in the ascending order based on their last name. The filter includes the standard English characters in the uppercase and lowercase. The entire list consists of ASCII characters from 32 to 126, and from 160 to 255.

          + To retrieve a specific contact, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Contact Filter Attributes).

          In this example, contacts whose first name contains "Chris" are retrieved and sorted in the ascending order based on their last name. The filter includes the standard English characters in the uppercase and lowercase. The entire list consists of ASCII characters from 32 to 126, and from 160 to 255.

          The contacts that match the filter are passed as an array to the registered success event handler in the selected sorting order.

        • @@ -474,11 +479,13 @@ try
          1. To manage a single person:
              -
            1. To retrieve persons, use the find() method of the ContactManager interface. You can retrieve the most frequently used persons using a SortMode with the attribute usageCount.

              +
            2. To retrieve persons, use the find() method of the ContactManager interface.

              +

              You can retrieve the most frequently used persons using the sort mode as the final parameter.

              -var sortMode = new tizen.SortMode("usageCount", "ASC");
              +var sortMode = new tizen.SortMode("usageCount", "ASC");
               tizen.contact.find(personsFoundCB, personsErrorCB, null, sortMode);
               
            3. +
            4. Update or delete the found persons in the personsFoundCB() event handler. In this example, the favorite flag of the first person is changed and the contact is updated using the update() method. The second person is deleted using the remove() method.

              /* Define the event success callback */
               function personsFoundCB(persons)
               {
              diff --git a/org.tizen.tutorials/html/web/tizen/social/data_sync_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/social/data_sync_tutorial_w.htm
              index 7b3a011..c9a4498 100644
              --- a/org.tizen.tutorials/html/web/tizen/social/data_sync_tutorial_w.htm
              +++ b/org.tizen.tutorials/html/web/tizen/social/data_sync_tutorial_w.htm
              @@ -21,6 +21,7 @@
                   

              Content

              @@ -43,14 +44,19 @@

              Warm-up

              Become familiar with the Data Synchronization API basics by learning about:

              -

              Prerequisites

              -

              To use the data sync APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

              -
              <tizen:privilege name="http://tizen.org/privilege/datasync"/>
              +

              Prerequisites

              +

              To use the Data Synchronization API, the application has to request permission by adding the following privilege to the config.xml file:

              +
              +<tizen:privilege name="http://tizen.org/privilege/datasync"/>
              +
              + +

              Creating a Sync Profile

              To be able to synchronize your device data, such as contacts and calendar events, with the OMA DS server, you must learn how to create a sync profile:

              diff --git a/org.tizen.tutorials/html/web/tizen/social/social_tutorials_w.htm b/org.tizen.tutorials/html/web/tizen/social/social_tutorials_w.htm index 5a2b304..e5252bd 100644 --- a/org.tizen.tutorials/html/web/tizen/social/social_tutorials_w.htm +++ b/org.tizen.tutorials/html/web/tizen/social/social_tutorials_w.htm @@ -30,10 +30,10 @@

              Social: Managing Personal Data

              - -

              The Social API domain is supported in mobile applications only.

              -

              The social data tutorials demonstrate how to use the following features in creating Tizen Web applications:

              +

              The social data tutorials demonstrate how to use the following features in creating Tizen Web applications.

              + +

              The following tutorials apply in mobile applications only:

              • Bookmark: Managing Web Browser Bookmarks

                Demonstrates how you can manage Tizen Web browser bookmarks on the device.

              • Calendar: Managing Calendars and Calendar Events

                Demonstrates how you can manage and monitor calendar items, and convert them to the iCalender format.

              • diff --git a/org.tizen.tutorials/html/web/tizen/social/task_calllog_w.htm b/org.tizen.tutorials/html/web/tizen/social/task_calllog_w.htm index e3abbbe..3c78d5e 100644 --- a/org.tizen.tutorials/html/web/tizen/social/task_calllog_w.htm +++ b/org.tizen.tutorials/html/web/tizen/social/task_calllog_w.htm @@ -53,7 +53,7 @@

                This sample is a fully functional application for displaying a detailed call history of the device or of a specific caller. The user can respond by calling or sending a message. Additionally, the user can delete a call history log.

                Defining the Application Layout

                -

                The CallLog sample application layout uses the template manager based on the MVC (Model-View-Controller) architecture, and consists of 2 screens: the main screen displays the entire call history and the History for Caller screen displays the detailed call history of a specific caller.

                +

                The CallLog sample application layout uses the template manager based on the MVC (Model View Controller) architecture, and consists of 2 screens: the main screen displays the entire call history and the History for Caller screen displays the detailed call history of a specific caller.

                The following figure shows the main screens of the application.

                Figure: CallLog screens

                diff --git a/org.tizen.tutorials/html/web/tizen/social/task_eventmanager_w.htm b/org.tizen.tutorials/html/web/tizen/social/task_eventmanager_w.htm index ec19fb1..4a53497 100644 --- a/org.tizen.tutorials/html/web/tizen/social/task_eventmanager_w.htm +++ b/org.tizen.tutorials/html/web/tizen/social/task_eventmanager_w.htm @@ -54,7 +54,7 @@

                This sample is a fully functional application for managing the device calendar. The user can add, modify, retrieve, and remove events, set the event type and duration, and set alarms for the events.

                Defining the Application Layout

                -

                The EventManager sample application layout uses the template manager based on the MVC (Model-View-Controller) architecture, and consists of 3 screens: the main screen displays the events list, the New event screen allows adding and editing events, and the Set alarm screen enables setting an alarm for an event.

                +

                The EventManager sample application layout uses the template manager based on the MVC (Model View Controller) architecture, and consists of 3 screens: the main screen displays the events list, the New event screen allows adding and editing events, and the Set alarm screen enables setting an alarm for an event.

                The following figure shows the main screens of the application.

                Figure: EventManager screens

                @@ -159,7 +159,7 @@ loadToCache: function TemplateManager_loadToCache(tplNames, onSuccess)       <h1>Event manager</h1>    </div>
            5. -
            6. The actual content section of the screen is defined within a <div> element whose data-role attribute is set to content. The content section of the main screen contains a list component (in mobile or wearable applications) displaying the elements as defined in the templates/event.tpl and templates/all_day_event.tpl files.

              +
            7. The actual content section of the screen is defined within a <div> element whose data-role attribute is set to content. The content section of the main screen contains a list component (in mobile or wearable applications) displaying the elements as defined in the templates/event.tpl and templates/all_day_event.tpl files.

                  <!--Content section-->
                  <div data-role="content">
              @@ -186,7 +186,7 @@ loadToCache: function TemplateManager_loadToCache(tplNames, onSuccess)
               
          2. templates/event.tpl Source File -

            Each event is displayed in the list showing a summary text, and a start and end date, and 2 buttons (in mobile or wearable applications).

            +

            Each event is displayed in the list showing a summary text, and a start and end date, and 2 buttons (in mobile or wearable applications).

             <li class="event" data-eventid="%uid%">
                <div class="ui-li-aside ui-li-desc">
            @@ -303,7 +303,7 @@ loadToCache: function TemplateManager_loadToCache(tplNames, onSuccess)
                   <label for="radio-choice-4">1 hour before</label>
             
                   <input type="radio" class="customDuration" name="radio-choice" id="yes_1"
            -             value="Yes" >
            +             value="Yes"/>
                   <label for="yes_1">custom time:</label>
                   <span class="customDetails">
                      <input placeholder="00" class="customDuration" type="number"
            diff --git a/org.tizen.tutorials/html/web/tizen/system/ham_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/ham_tutorial_w.htm
            index 5fdf535..4ff989b 100644
            --- a/org.tizen.tutorials/html/web/tizen/system/ham_tutorial_w.htm
            +++ b/org.tizen.tutorials/html/web/tizen/system/ham_tutorial_w.htm
            @@ -20,19 +20,20 @@
                     

            Mobile Web Wearable Web

    @@ -50,17 +51,22 @@

    Become familiar with the Human Activity Monitor API basics by learning about:

    -

    Prerequisites

    -

    To use the HAM APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

    -
    <tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
    -<tizen:privilege name="http://tizen.org/privilege/location"/>
    +

    Prerequisites

    + +

    To use the Human Activity Monitor API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the config.xml file:

    +
    +<tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
    +<tizen:privilege name="http://tizen.org/privilege/location"/>
    +
    +

    Retrieving Data

    @@ -89,43 +95,53 @@ tizen.humanactivitymonitor.start("HRM", onchangedCB);

    You can also detect the wrist up gesture using the start() method:

    -
    function onchangedCB()
    +
    +function onchangedCB()
     {
        console.log("You are looking at your smartwatch");
     }
     
    -tizen.humanactivitymonitor.start("WRIST_UP", onchangedCB)
    +tizen.humanactivitymonitor.start("WRIST_UP", onchangedCB) +
    + -
  • When the a heart-rate monitor (HRM) is enabled, you can get the current data using the getHumanActivityData() method of the HumanActivityMonitorManager interface: -
    function onsuccessCB(hrmInfo)
    +
  • When the heart rate monitor (HRM) is enabled, you can get the current data using the getHumanActivityData() method of the HumanActivityMonitorManager interface: +
    +function onsuccessCB(hrmInfo)
     {
        console.log("Heart rate: " + hrmInfo.heartRate);
     }
    +
     function onerrorCB(error)
     {
        console.log("Error occurred: " + error.message);
     }
    -tizen.humanactivitymonitor.getHumanActivityData("HRM", onsuccessCB, onerrorCB);
    + +tizen.humanactivitymonitor.getHumanActivityData("HRM", onsuccessCB, onerrorCB); +
  • To disable HAM when it is no longer required, use the stop() method of the HumanActivityMonitorManager interface: -
    tizen.humanactivitymonitor.stop("HRM");
    +
    +tizen.humanactivitymonitor.stop("HRM");
    +
  • -

    Using user-defined intervals

    -

    Human Activity API allows user to choose own intervals for collecting samples in specified range. -Such functionality could be used to build more power efficient applications, which collects data (less often device gathers data -> less energy is used). Developer could change interval according to state of device, e.g. when display is turned off, then sampling interval could be less.

    +

    Using User-defined Intervals

    +

    The Human Activity Monitor API allows the user to select their own intervals for collecting samples in a specified range. Such functionality can be used to build more power-efficient data collection applications (the less often the device gathers data, the less energy is used). You can change the interval according to the device state, for example, when the display is switched off, the sampling interval can be decreased.

      -
    1. If a human activity type allows setting the interval at which data is sent to the application or setting the sampling interval, the last parameter of the start() method, option, can be used to specify this information: +
    2. If a human activity type allows setting the interval at which data is sent to the application or setting the sampling interval, the last parameter of the start() method can be used to specify this information: -
      var myCallbackInterval = 240000;
      +
      +var myCallbackInterval = 240000;
       var mySampleInterval = 10000;
       
       function onchangedCB(gpsInfo)
       {
      -   console.log("this callback will be called every " + myCallbackInterval + " milliseconds");
      -   console.log("the gpsInfo will include the information of the GPS that is collected every " + mySampleInterval + " millisenconds");
      +   console.log("this callback is called every " + myCallbackInterval + " milliseconds");
      +   console.log("the gpsInfo includes the information of the GPS that is collected every " + 
      +               mySampleInterval + " milliseconds");
       }
       
       function onerrorCB(error)
      @@ -136,10 +152,11 @@ function onerrorCB(error)
       var option = {"callbackInterval": myCallbackInterval,
                     "sampleInterval": mySampleInterval};
       
      -tizen.humanactivitymonitor.start("GPS", onchangedCB, onerrorCB, option);
      +tizen.humanactivitymonitor.start("GPS", onchangedCB, onerrorCB, option); +
    3. -
    4. When the a heart-rate monitor (HRM) is enabled, you can get the current data using the getHumanActivityData() method of the HumanActivityMonitorManager interface: +
    5. When the heart-rate monitor (HRM) is enabled, you can get the current data using the getHumanActivityData() method of the HumanActivityMonitorManager interface:
      function onsuccessCB(hrmInfo)
       {
          console.log("Heart rate: " + hrmInfo.heartRate);
      @@ -152,12 +169,15 @@ tizen.humanactivitymonitor.getHumanActivityData("HRM", onsuccessCB, on
       
    6. To disable HAM when it is no longer required, use the stop() method of the HumanActivityMonitorManager interface: -
      tizen.humanactivitymonitor.stop("HRM");
      +
      +tizen.humanactivitymonitor.stop("HRM");
      +
    +

    Receiving Notifications on Pedometer Data Changes

    -

    Learning how to register a listener for accumulative allows you to monitor the step count maintained by the system without enabling the Pedometer sensor and the PEDOMETER monitor:

    +

    Learning how to register a listener for accumulative allows you to monitor the step count maintained by the system without enabling the Pedometer sensor and the PEDOMETER monitor is a basic Human Activity Monitor (HAM) management skill:

    1. To register an event handler for accumulative pedometer changes, use the setAccumulativePedometerListener() method of the HumanActivityMonitorManager interface (in mobile and wearable applications):
      function onchangedCB(pedometerInfo)
      @@ -165,7 +185,7 @@ tizen.humanactivitymonitor.getHumanActivityData("HRM", onsuccessCB, on
          console.log("Step status: " + pedometerInfo.stepStatus);
          console.log("Speed: " + pedometerInfo.speed);
          console.log("Walking frequency: " + pedometerInfo.walkingFrequency);
      -   /* Unregisters a previously registered listener */
      +   /* Deregisters a previously registered listener */
          tizen.humanactivitymonitor.unsetAccumulativePedometerListener();
       }
       
      @@ -180,41 +200,46 @@ tizen.humanactivitymonitor.setAccumulativePedometerListener(onchangedCB);
    +

    Recognizing an Activity

    - -

    Activity Recognition

    - -

    Learning how to register a listener that allows you to recognize and monitor activity of the given type:

    +

    Learning how to register a listener that allows you to recognize and monitor an activity of the given type is a basic Human Activity Monitor (HAM) management skill:

      -
    1. To register an event handler for activity recognition, use the addActivityRecognitionListener() method of the HumanActivityMonitorManager interface (in mobile and wearable applications): +
    2. To register an event handler for recognizing a walking activity, use the addActivityRecognitionListener() method of the HumanActivityMonitorManager interface (in mobile and wearable applications):
      -function errorCallback(error) {
      +function errorCallback(error) 
      +{
         console.log (error.name +": " + error.message);
       }
       
      -function listener(info) {
      -  console.log("type: "      + info.type);
      +function listener(info) 
      +{
      +  console.log("type: " + info.type);
         console.log("timestamp: " + info.timestamp);
      -  console.log("accuracy: "  + info.accuracy);
      +  console.log("accuracy: " + info.accuracy);
       }
       
      -try {
      +try 
      +{
         var listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback);
      -} catch (error) {
      +} 
      +catch (error) 
      +{
         console.log (error.name +": " + error.message);
       }
       
    3. -
    4. To stop receiving notifications about recognition of activity, use the removeActivityRecognitionListener() method of the HumanActivityMonitorManager interface: +
    5. To stop receiving activity recognition notifications, use the removeActivityRecognitionListener() method of the HumanActivityMonitorManager interface:
       var listenerId;
       
      -function errorCallback(error) {
      +function errorCallback(error) 
      +{
         console.log (error.name + ": " + error.message);
       }
       
      -function listener(info) {
      +function listener(info) 
      +{
         console.log("type: " + info.type);
         console.log("timestamp: " + info.timestamp);
         console.log("accuracy: " + info.accuracy);
      @@ -222,18 +247,21 @@ function listener(info) {
         tizen.humanactivitymonitor.removeActivityRecognitionListener(listenerId, errorCallback);
       }
       
      -try {
      +try 
      +{
         listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback);
      -} catch (error) {
      +} 
      +catch (error) 
      +{
         console.log (error.name +": " + error.message);
       }
       
    -

    Sleep monitor

    - -

    This tutorial shows how to use the monitor which detects whether or not user is asleep:

    +

    Monitoring Sleep

    + +

    Learning how to detect whether the user is asleep is a basic Human Activity Monitor (HAM) management skill:

    1. To enable the monitor and start collecting data, use the start() method of the HumanActivityMonitorManager interface (in mobile and wearable applications):
      @@ -269,9 +297,6 @@ tizen.humanactivitymonitor.stop("SLEEP_MONITOR");
       
    - - - diff --git a/org.tizen.tutorials/html/web/tizen/system/media_key_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/media_key_tutorial_w.htm index ae63a84..8e836eb 100644 --- a/org.tizen.tutorials/html/web/tizen/system/media_key_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/system/media_key_tutorial_w.htm @@ -48,9 +48,6 @@
  • Managing Media Key State Changes

    Register a listener and monitor changes in the media key states.

  • -

    Prerequisites

    -

    There are not any privileges to be required for this APIs.

    -

    Managing Media Key State Changes

    Learning how to register key event listener is a basic media key management skill:

    @@ -77,7 +74,7 @@ var myMediaKeyChangeListener = tizen.mediakey.setMediaKeyEventListener(myMediaKeyChangeListener); -
  • Unregister the media key state change listener when it is no longer needed: +
  • Deregister the media key state change listener when it is no longer needed:
     tizen.mediakey.unsetMediaKeyEventListener();
    diff --git a/org.tizen.tutorials/html/web/tizen/system/power_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/power_tutorial_w.htm index 426487c..38b2eeb 100644 --- a/org.tizen.tutorials/html/web/tizen/system/power_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/system/power_tutorial_w.htm @@ -22,6 +22,7 @@

    Content

      +
    • Prerequisites
    • Managing the Power Resource
    • Managing the Screen Brightness
    • Managing the Screen State
    • @@ -46,13 +47,18 @@

      Warm-up

      Become familiar with the Power API basics by learning about:

      -

      Prerequisites

      -

      To use the power APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

      -
      <tizen:privilege name="http://tizen.org/privilege/power"/>
      +

      Prerequisites

      + +

      To use the Power API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

      +
      +<tizen:privilege name="http://tizen.org/privilege/power"/>
      +
      +

      Managing the Power Resource

      diff --git a/org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm index 71f8995..2ff4b56 100644 --- a/org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm @@ -50,9 +50,6 @@
    • Receiving Notifications on Sensor Data Changes

      Register an event handler to receive notifications on sensor data changes.

    -

    Prerequisites

    -

    There are not any privileges to be required for this APIs.

    -

    Task in Mobile Applications

    In the Sensor Ball task, we will walk through simulating ball behavior to create a game.

    @@ -63,11 +60,12 @@
    1. Check that the sensor is supported by the device using the getCapability() method of the SystemInfo interface (in mobile and wearable applications) for the proper capability related to the sensor:

      -
      var proximityCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.proximity");
      +
      +var proximityCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.proximity");
       
       if (proximityCapability === true)
       {
      -   /* The device supports the proximity sensor */
      +   /* Device supports the proximity sensor */
          var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
       }
       
      @@ -75,26 +73,30 @@ if (proximityCapability === true)
    2. To get all available sensor types, use the getAvailableSensors() method:

      -
      var sensors = tizen.sensorservice.getAvailableSensors();
      +
      +var sensors = tizen.sensorservice.getAvailableSensors();
       console.log("Available sensor: " + sensors.toString());
       
    3. Obtain the Sensor object (in mobile and wearable applications) using the getDefaultSensor() method of the SensorService interface (in mobile and wearable applications). Enable the sensor using the start() method:

      -
      var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
      +
      +var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
       
       function onsuccessCB()
       {
          console.log("The proximity sensor started successfully.");
       }
       
      -proximitySensor.start(onsuccessCB);
      +proximitySensor.start(onsuccessCB); +
    4. To get data from the sensor, use the appropriate method of the sensor object. For example, for the LightSensor (in mobile and wearable applications), use the getLightSensorData() method:

      -
      var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
      +
      +var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
       
       function onGetSuccessCB(sensorData)
       {
      @@ -113,7 +115,9 @@ lightSensor.start(onsuccessCB);
       
    5. To disable the sensor when it is no longer needed, use the stop() method of the Sensor interface:

      -
      proximitySensor.stop(); 
      +
      +proximitySensor.stop();
      +
    @@ -124,7 +128,8 @@ lightSensor.start(onsuccessCB);
    1. Define an event handler for sensor data changes by implementing the SensorDataSuccessCallback interface (in mobile and wearable applications): -
      function onchangedCB(sensorData)
      +
      +function onchangedCB(sensorData)
       {
          console.log("Light sensor data: " + sensorData.lightLevel);
       }
      @@ -132,9 +137,17 @@ lightSensor.start(onsuccessCB);
       
    2. Register a change listener to be called when the sensor data changes. -

      To register a change listener, use the setChangeListener() method of the Sensor interface (in mobile and wearable applications).

      -

      This command requires two parameters. The first one is a handle to the callback method, which will be invoked for every incoming event. The second argument determines the amount of time (in milliseconds) passing between two consecutive events. Valid values are integers in range <10, 1000> inclusively. For example, setting an interval to 100 results in approximately 10 events being send every second.

      -
      var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
      +

      To register a change listener, use the setChangeListener() method of the Sensor interface (in mobile and wearable applications).

      + + +

      This command requires 2 parameters:

      +
        +
      • The first one is a handle to the callback method, which is invoked for every incoming event.
      • +
      • The second determines the amount of time (in milliseconds) passing between 2 consecutive events. Valid values are integers from 10 to 1000, inclusively. For example, the value 100 results in approximately 10 events being send every second.
      • +
      + +
      +var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
       
       function onsuccessCB()
       {
      @@ -147,9 +160,12 @@ function onchangedCB(sensorData)
       }
       
       lightSensor.setChangeListener(onchangedCB, 500);
      -lightSensor.start(onsuccessCB);
      -The default value of interval parameter is 100. If you do not pass an interval value, a default one will be used: -
      var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
      +lightSensor.start(onsuccessCB);
      +
      + +

      The default value of the second parameter is 100. If you do not pass a value, the default is used:

      +
      +var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
       
       function onsuccessCB()
       {
      @@ -161,16 +177,17 @@ function onchangedCB(sensorData)
          console.log("Light sensor data: " + sensorData.lightLevel);
       }
       
      -// use the default interval value (100 ms):
      +/* Use the default interval value (100 ms) */
       lightSensor.setChangeListener(onchangedCB);
      -
      -lightSensor.start(onsuccessCB);
      - +lightSensor.start(onsuccessCB); +
    3. To stop receiving notifications on sensor data changes, use the unsetChangeListener() method of the Sensor interface. -
      lightSensor.unsetChangeListener();
      +
      +lightSensor.unsetChangeListener();
      +
    diff --git a/org.tizen.tutorials/html/web/tizen/system/system_info_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/system_info_tutorial_w.htm index 58d4bac..716348d 100644 --- a/org.tizen.tutorials/html/web/tizen/system/system_info_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/system/system_info_tutorial_w.htm @@ -23,6 +23,7 @@

    Content

      +
    • Prerequisites
    • Retrieving a Device Capability
    • Retrieving the Current State of a Property
    • Retrieving the Memory State
    • @@ -49,20 +50,23 @@

      Warm-up

      Become familiar with the System Information API basics by learning about:

      - -

      Prerequisites

      -

      To use the system info APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

      -
      <tizen:privilege name="http://tizen.org/privilege/system"/>
      -<tizen:privilege name="http://tizen.org/privilege/telephony"/>
      -

      Task

      In the System Information task, we will walk through how to access and use system information in your application.

      + +

      Prerequisites

      +

      To use the System Information API (in mobile and wearable applications), the application has to request permission by adding the following privileges to the config.xml file:

      +
      +<tizen:privilege name="http://tizen.org/privilege/system"/>
      +<tizen:privilege name="http://tizen.org/privilege/telephony"/>
      +
      +

      Retrieving a Device Capability

      @@ -180,7 +184,7 @@ function successCallback(memory) } tizen.systeminfo.addPropertyValueChangeListener("MEMORY", successCallback); -

      The method returns a watch identifier, which can be used to unregister the event handler.

      +

      The method returns a watch identifier, which can be used to deregister the event handler.

    • In the success event handler of the addPropertyValueChangeListener() method, define the notification event actions.

      In the following example, a warning about the low battery is logged to the console.

       /* Trigger a notification */
       function onSuccessCallback(battery)
      @@ -190,7 +194,7 @@ function onSuccessCallback(battery)
       
       tizen.systeminfo.addPropertyValueChangeListener("BATTERY", onSuccessCallback);
       
    • -
    • To unregister the event handler, use removePropertyValueChangeListener() method with the watch identifier returned from the addPropertyValueChangeListener() method.

      In the following example, the event handler is unregistered when the first change of the SIM card state is detected.

      +   
    • To deregister the event handler, use removePropertyValueChangeListener() method with the watch identifier returned from the addPropertyValueChangeListener() method.

      In the following example, the event handler is deregistered when the first change of the SIM card state is detected.

       function successCallback(properties)
       {
          for (var i = 0; i properties.length; i++)
      diff --git a/org.tizen.tutorials/html/web/tizen/system/system_setting_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/system_setting_tutorial_w.htm
      index 7974e5a..e0a1ef9 100644
      --- a/org.tizen.tutorials/html/web/tizen/system/system_setting_tutorial_w.htm
      +++ b/org.tizen.tutorials/html/web/tizen/system/system_setting_tutorial_w.htm
      @@ -22,6 +22,7 @@
           

      Content

      @@ -46,13 +47,17 @@

      Warm-up

      Become familiar with the System Setting API basics by learning about:

      + +

      Prerequisites

      +

      To use the System Setting API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the config.xml file:

      +
      +<tizen:privilege name="http://tizen.org/privilege/setting"/>
      +
      -

      Prerequisites

      -

      To use the system setting APIs, the application has to request permission by adding the corresponding privileges to the config.xml file.

      -
      <tizen:privilege name="http://tizen.org/privilege/setting"/>

      Managing the Device Wallpapers

      diff --git a/org.tizen.tutorials/html/web/tizen/system/system_tutorials_w.htm b/org.tizen.tutorials/html/web/tizen/system/system_tutorials_w.htm index 1bcf462..eac21b4 100644 --- a/org.tizen.tutorials/html/web/tizen/system/system_tutorials_w.htm +++ b/org.tizen.tutorials/html/web/tizen/system/system_tutorials_w.htm @@ -35,19 +35,20 @@

      The system tutorials demonstrate how to use the following features in creating Tizen Web applications:

      +
    • Time: Exposing Information about Date, Time, and Time Zones

      Demonstrates how you can manage date and time information.

    • +

    The following tutorials apply in mobile applications only:

    +
  • Web Setting: Managing the Setting States of the Web View +

    Demonstrates how you can manage Web view properties.

  • + diff --git a/org.tizen.tutorials/html/web/tizen/system/task_systeminfo_w.htm b/org.tizen.tutorials/html/web/tizen/system/task_systeminfo_w.htm index 371d80c..5cbf375 100644 --- a/org.tizen.tutorials/html/web/tizen/system/task_systeminfo_w.htm +++ b/org.tizen.tutorials/html/web/tizen/system/task_systeminfo_w.htm @@ -65,7 +65,7 @@       <h1>System information</h1>    </div> -
  • The actual content section of the screen is defined within a <div> element whose data-role attribute is set to content. The content section of the main screen contains a list component (in mobile or wearable applications) displaying the system properties.

       <!--Content section-->
    +     
  • The actual content section of the screen is defined within a <div> element whose data-role attribute is set to content. The content section of the main screen contains a list component (in mobile or wearable applications) displaying the system properties.

       <!--Content section-->
        <div data-role="content">
           <ul data-role="listview">
              <li id="storage-info">Storage</li>
    diff --git a/org.tizen.tutorials/html/web/tizen/system/time_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/time_tutorial_w.htm
    index 98579ff..4809164 100644
    --- a/org.tizen.tutorials/html/web/tizen/system/time_tutorial_w.htm
    +++ b/org.tizen.tutorials/html/web/tizen/system/time_tutorial_w.htm
    @@ -54,8 +54,6 @@
     
        
     
    -

    Prerequisites

    -

    There are not any privileges to be required for this APIs.

    Retrieving Date and Time

    @@ -194,13 +192,13 @@ tizen.time.setTimezoneChangeListener(timezoneChangedCallback);
  • -
  • To stop receiving the notifications, unregister the listeners:

    +
  • To stop receiving the notifications, deregister the listeners:

      -
    • To unregister the time change listener, use the unsetDateTimeChangeListener() method of the TimeUtil interface:

      +
    • To deregister the time change listener, use the unsetDateTimeChangeListener() method of the TimeUtil interface:

       tizen.time.unsetDateTimeChangeListener();
       
    • -
    • To unregister the time zone change listener, use the unsetTimezoneChangeListener() method of the TimeUtil interface:

      +
    • To deregister the time zone change listener, use the unsetTimezoneChangeListener() method of the TimeUtil interface:

       tizen.time.unsetTimezoneChangeListener();
       
    • diff --git a/org.tizen.tutorials/html/web/tizen/system/web_setting_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/web_setting_tutorial_w.htm index 2b48f95..e8d344c 100644 --- a/org.tizen.tutorials/html/web/tizen/system/web_setting_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/system/web_setting_tutorial_w.htm @@ -47,10 +47,7 @@
    • Setting a User Agent for a Running Application

      Set a Web view user agent string.

    • Deleting Web View Cookies

      Delete Web view cookies.

    - -

    Prerequisites

    -

    There are not any privileges to be required for this APIs.

    - +

    Setting a User Agent for a Running Application

    Learning how to set a user agent string to perform tasks is a basic Web setting management skill:

    diff --git a/org.tizen.tutorials/html/web/tizen/tutorials_tizen_w.htm b/org.tizen.tutorials/html/web/tizen/tutorials_tizen_w.htm index e2f8d57..cd1dce1 100644 --- a/org.tizen.tutorials/html/web/tizen/tutorials_tizen_w.htm +++ b/org.tizen.tutorials/html/web/tizen/tutorials_tizen_w.htm @@ -39,23 +39,25 @@ diff --git a/org.tizen.tutorials/html/web/w3c/communication/server_sent_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/communication/server_sent_tutorial_w.htm index c9414e6..72aa440 100644 --- a/org.tizen.tutorials/html/web/w3c/communication/server_sent_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/communication/server_sent_tutorial_w.htm @@ -18,7 +18,7 @@
    -

    Mobile Web

    +

    Mobile Web

    Content

    @@ -131,7 +131,7 @@    /* message event */    eventSource.onmessage = function(e)    { -      log.innerHTML+= "<p>[push data]: <br>" + e.data + "</p>"; +      log.innerHTML+= "<p>[push data]: <br/>" + e.data + "</p>";    }; </script> diff --git a/org.tizen.tutorials/html/web/w3c/device/device_orientation_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/device/device_orientation_tutorial_w.htm index f224b44..cdf9a38 100644 --- a/org.tizen.tutorials/html/web/w3c/device/device_orientation_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/device/device_orientation_tutorial_w.htm @@ -113,21 +113,21 @@    window.addEventListener("devicemotion", function(e)    {       /* Data for acceleration */ -      firElem.innerHTML = 'acceleration value<br><br> ' -         + '[ x value: '+ Math.round(e.acceleration.x) + " ]<br>" -         + '[ y value: '+ Math.round(e.acceleration.y) + " ]<br>" +      firElem.innerHTML = 'acceleration value<br/><br/> ' +         + '[ x value: '+ Math.round(e.acceleration.x) + " ]<br/>" +         + '[ y value: '+ Math.round(e.acceleration.y) + " ]<br/>"          + '[ z value: '+ Math.round(e.acceleration.z) + ']';       /* Data for acceleration, including gravity */ -      secElem.innerHTML = 'accelerationIncludingGravity value<br><br> ' -         + '[ x value: ' + Math.round(e.accelerationIncludingGravity.x) + " ]<br>" -         + '[ y value: ' + Math.round(e.accelerationIncludingGravity.y) + " ]<br>" +      secElem.innerHTML = 'accelerationIncludingGravity value<br/><br/> ' +         + '[ x value: ' + Math.round(e.accelerationIncludingGravity.x) + " ]<br/>" +         + '[ y value: ' + Math.round(e.accelerationIncludingGravity.y) + " ]<br/>"          + '[ z value: ' + Math.round(e.accelerationIncludingGravity.z) + ']';       /* Data for rotation rate */ -      thirElem.innerHTML = 'rotationRate value<br><br> ' -         + '[ alpha value: ' + Math.round(e.rotationRate.alpha) + " degree ]<br>" -         + '[ beta value: ' + Math.round(e.rotationRate.beta) + " degree ]<br>" +      thirElem.innerHTML = 'rotationRate value<br/><br/> ' +         + '[ alpha value: ' + Math.round(e.rotationRate.alpha) + " degree ]<br/>" +         + '[ beta value: ' + Math.round(e.rotationRate.beta) + " degree ]<br/>"          + '[ gamma value: ' + Math.round(e.rotationRate.gamma) + ' degree ]';    }, true);
     </script>
    diff --git a/org.tizen.tutorials/html/web/w3c/device/screen_orientation_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/device/screen_orientation_tutorial_w.htm
    index d22052e..97acb24 100644
    --- a/org.tizen.tutorials/html/web/w3c/device/screen_orientation_tutorial_w.htm
    +++ b/org.tizen.tutorials/html/web/w3c/device/screen_orientation_tutorial_w.htm
    @@ -63,10 +63,10 @@
           <p>Current orientation is:</p>
           <p id="currentOrientation" class="current-orientation"></p>
         
    -      <button id="portrait-primary" class="button">Portrait primary</button><br>
    -      <button id="landscape-secondary" class="button">Landscape secondary</button><br>
    -      <button id="portrait-secondary" class="button">Portrait secondary</button><br>
    -      <button id="landscape-primary" class="button">Landscape primary</button><br>
    +      <button id="portrait-primary" class="button">Portrait primary</button><br/>
    +      <button id="landscape-secondary" class="button">Landscape secondary</button><br/>
    +      <button id="portrait-secondary" class="button">Portrait secondary</button><br/>
    +      <button id="landscape-primary" class="button">Landscape primary</button><br/>
           <button id="unlock-orientation" class="button">Unlock orientation</button>
        </div>
     </body>
    @@ -95,7 +95,7 @@
              screen.lockOrientation('portrait-primary');
           }
      
    -      /* The other 3 orientation buttons are handled similarly */
    +      /* Other 3 orientation buttons are handled similarly */
       
           document.getElementById("unlock-orientation").onclick = function() 
           {
    diff --git a/org.tizen.tutorials/html/web/w3c/device/task_touch_paint_mw.htm b/org.tizen.tutorials/html/web/w3c/device/task_touch_paint_mw.htm
    index 5288fdd..847fcde 100644
    --- a/org.tizen.tutorials/html/web/w3c/device/task_touch_paint_mw.htm
    +++ b/org.tizen.tutorials/html/web/w3c/device/task_touch_paint_mw.htm
    @@ -75,7 +75,7 @@
        <div class="desc">
           <label>Color: <input type="color" class="strokeColor"></label>
           <label>Line width: 
    -         <input type="range" min="5" max="30" step="5" value="5" class="strokeWidth">
    +         <input type="range" min="5" max="30" step="5" value="5" class="strokeWidth"/>
           </label>
        </div>
        <nav></nav>
    @@ -127,7 +127,7 @@ function touchMoveHandler(e)
        touches = e.touches.item(0);
         
        log.innerHTML ='<strong>pageX:</strong> ' + touches.pageX + 
    -                  '<br><strong>pageY:</strong> ' + touches.pageY;
    +                  '<br/><strong>pageY:</strong> ' + touches.pageY;
         
        context.fillStyle = "#f00";
         
    diff --git a/org.tizen.tutorials/html/web/w3c/device/task_touch_paint_ww.htm b/org.tizen.tutorials/html/web/w3c/device/task_touch_paint_ww.htm
    index be8e699..69f038c 100644
    --- a/org.tizen.tutorials/html/web/w3c/device/task_touch_paint_ww.htm
    +++ b/org.tizen.tutorials/html/web/w3c/device/task_touch_paint_ww.htm
    @@ -86,7 +86,7 @@
       
    1. index.html Source File -

      The Options screen displays a slider element, line preview, four-color (white, red, green, and blue) picker and 2 buttons (Cancel and OK).

      +

      The Options screen displays a slider element, line preview, 4-color (white, red, green, and blue) picker and 2 buttons (Cancel and OK).

      The slider allows the user to change the line width. Each slider position change results in a change in the line preview thickness. A tap action on the color picker results in a change in the line preview color. A tap action on the buttons moves the user to main screen without or with saving the changes.

      diff --git a/org.tizen.tutorials/html/web/w3c/device/touch_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/device/touch_tutorial_w.htm
      index 5196fe7..409602c 100644
      --- a/org.tizen.tutorials/html/web/w3c/device/touch_tutorial_w.htm
      +++ b/org.tizen.tutorials/html/web/w3c/device/touch_tutorial_w.htm
      @@ -136,8 +136,8 @@
       
       
    2. When the user long-presses the DOM element, such as text or image, in the element, the touchstart and touchcancel events occur. -

      Figure: Cancelling touch with long press (in mobile applications only)

      -

      Cancelling touch with long press (in mobile applications only)

      +

      Figure: Cancelling touch with a long press (in mobile applications only)

      +

      Cancelling touch with a long press (in mobile applications only)

    3. @@ -198,11 +198,11 @@       log.innerHTML =          '<strong>pageX:</strong> ' + pTarget.pageX + -         '<br><strong>pageY:</strong> ' + pTarget.pageY + -         '<br><strong>clientX:</strong> ' + pTarget.clientX + -         '<br><strong>clientY:</strong> ' + pTarget.clientY + -         '<br><strong>screenX:</strong> ' + pTarget.screenX + -         '<br><strong>screenY:</strong> ' + pTarget.screenY; +         '<br/><strong>pageY:</strong> ' + pTarget.pageY + +         '<br/><strong>clientX:</strong> ' + pTarget.clientX + +         '<br/><strong>clientY:</strong> ' + pTarget.clientY + +         '<br/><strong>screenX:</strong> ' + pTarget.screenX + +         '<br/><strong>screenY:</strong> ' + pTarget.screenY;       e.preventDefault();    } diff --git a/org.tizen.tutorials/html/web/w3c/graphics/canvas_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/graphics/canvas_tutorial_w.htm index 2df5db9..fd40710 100644 --- a/org.tizen.tutorials/html/web/w3c/graphics/canvas_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/graphics/canvas_tutorial_w.htm @@ -272,8 +272,8 @@ context.fillStyle = 'tomato';
       <canvas id="canvas" width="600" height="300"></canvas>
      -<input type="button" value="Small brush" id="smallBrush">
      -<input type="button" value="Big brush" id="bigBrush">
      +<input type="button" value="Small brush" id="smallBrush"/> +<input type="button" value="Big brush" id="bigBrush"/>
    4. Define the CSS style for the background image: diff --git a/org.tizen.tutorials/html/web/w3c/graphics/task_basicwatch_w.htm b/org.tizen.tutorials/html/web/w3c/graphics/task_basicwatch_w.htm index c5a1b76..bdcbdac 100644 --- a/org.tizen.tutorials/html/web/w3c/graphics/task_basicwatch_w.htm +++ b/org.tizen.tutorials/html/web/w3c/graphics/task_basicwatch_w.htm @@ -61,7 +61,7 @@

      Defining the Main Screen

      1. index.html Source File -

        The main screen displays a canvas element on which the clock face and needles are placed.

        +

        The main screen displays a canvas element on which the watch face and needles are placed.

         <head>
        @@ -76,11 +76,11 @@
         
      2. main.js Source File
        1. -

          Create the clock in the middle of the canvas. Define the clock face style.

          +

          Create the clock in the middle of the canvas. Define the watch face style.

           function renderDots() 
           {
          -   'use strict';
          +   'use strict';
           
              var dx = 0,
                  dy = 0,
          @@ -90,9 +90,9 @@ function renderDots()
              context.save();
              context.translate(canvas.width / 2, canvas.height / 2);
              context.beginPath();
          -   context.fillStyle = '#999999';	
          +   context.fillStyle = '#999999';	
           
        2. -
        3. Create 4 dots on the sides of the clock face and use the fill() method to style the dots.

          +
        4. Create 4 dots on the sides of the watch face and use the fill() method to style the dots.

              for (i = 1; i <= 4; i++) 
          @@ -140,7 +140,8 @@ function renderDots()
                
    - +
    Note

    To run your application on Samsung Gear 2, Samsung Gear 2 Neo, and Samsung Gear S devices, use <tizen:category name="com.samsung.wmanager.WATCH_CLOCK" /> instead of <tizen:category name="http://tizen.org/category/wearable_clock" />.

    +

    To run your application on Samsung Gear 2, Samsung Gear 2 Neo, and Samsung Gear S devices, use <tizen:category name="com.samsung.wmanager.WATCH_CLOCK" /> instead of <tizen:category name="http://tizen.org/category/wearable_clock" />.

    diff --git a/org.tizen.tutorials/html/web/w3c/location/geolocation_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/location/geolocation_tutorial_w.htm index 6281811..53ad6b7 100644 --- a/org.tizen.tutorials/html/web/w3c/location/geolocation_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/location/geolocation_tutorial_w.htm @@ -57,7 +57,7 @@ function successCallback(position) {    document.getElementById("locationInfo").innerHTML = "Latitude: " + -   position.coords.latitude + "<br>Longitude: " + position.coords.longitude; +   position.coords.latitude + "<br/>Longitude: " + position.coords.longitude; } function errorCallback(error) diff --git a/org.tizen.tutorials/html/web/w3c/media/getusermedia_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/media/getusermedia_tutorial_w.htm index ddb899a..2d0fc65 100644 --- a/org.tizen.tutorials/html/web/w3c/media/getusermedia_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/media/getusermedia_tutorial_w.htm @@ -63,7 +63,7 @@
     <body>
        <video id="videoPlay" src="" autoplay controls></video><br/>
    -   <input type="button" value="START" onclick="getVideoStream();" id="btnStart">
    +   <input type="button" value="START" onclick="getVideoStream();" id="btnStart"/>
     </body>
     
  • @@ -86,7 +86,7 @@    function SuccessCallback(stream)    {       var URL = window.webkitURL; -      document.getElementById("videoPlay").src = URL.createObjectURL(stream); +      document.getElementById("videoPlay").src = URL.createObjectURL(stream);    } </script>
    @@ -108,9 +108,9 @@ <body>    <video id="videoView" src="" autoplay></video><br/>    <img id="imgView" src=""> -   <canvas id="canvasView" style="display: none;" width="300" height="225"></canvas><br> -   <input type="button" value="WebCamStart" onclick="getVideoStream();" id="btnPlay"> -   <input type="button" value="Capture" onclick="getCapture();" id="btnCapture"> +   <canvas id="canvasView" style="display: none;" width="300" height="225"></canvas><br/> +   <input type="button" value="WebCamStart" onclick="getVideoStream();" id="btnPlay"/> +   <input type="button" value="Capture" onclick="getCapture();" id="btnCapture"/> </body>
  • diff --git a/org.tizen.tutorials/html/web/w3c/media/media_capture_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/media/media_capture_tutorial_w.htm index 0cd33de..278c3a3 100644 --- a/org.tizen.tutorials/html/web/w3c/media/media_capture_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/media/media_capture_tutorial_w.htm @@ -58,7 +58,7 @@ adding the capture
    -<input type="file" capture="filesystem">
    +<input type="file" capture="filesystem"/>
     

    File types

    @@ -67,9 +67,9 @@ adding the captureAssign format, such as filesystem, camera, or camcorder:

    -<input type="file" accept="audio/*" capture="camera">
    -<input type="file" accept="image/*" capture="camcorder">
    -<input type="file" accept="video/*" capture="microphone">
    +<input type="file" accept="audio/*" capture="camera"/>
    +<input type="file" accept="image/*" capture="camcorder"/>
    +<input type="file" accept="video/*" capture="microphone"/>
     

    diff --git a/org.tizen.tutorials/html/web/w3c/media/webaudio_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/media/webaudio_tutorial_w.htm index 81054de..841674c 100644 --- a/org.tizen.tutorials/html/web/w3c/media/webaudio_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/media/webaudio_tutorial_w.htm @@ -147,7 +147,7 @@          /* Create the sound source */          soundSource = context.createBufferSource(); -         /* Import callback function that provides PCM audio data decoded as an audio buffer */ +         /* Import a callback that provides PCM audio data decoded as an audio buffer */          context.decodeAudioData(request.response, function(buffer)          {             bufferData = buffer; diff --git a/org.tizen.tutorials/html/web/w3c/perf_opt/web_workers_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/perf_opt/web_workers_tutorial_w.htm index 8f05a48..ba27669 100644 --- a/org.tizen.tutorials/html/web/w3c/perf_opt/web_workers_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/perf_opt/web_workers_tutorial_w.htm @@ -66,7 +66,7 @@ index: while (true)       if (n % i == 0) continue index;    postMessage(n); } -

    This JavaScript operation delivers the calculated value of the Math.sqrt(n) function to the postMessage() method. It cannot be used for continuous posting of the Boolean operation.

    +

    This JavaScript operation delivers the calculated value of the Math.sqrt(n) method to the postMessage() method. It cannot be used for continuous posting of the Boolean operation.

  • Create a Web worker to be activated in the background. The JavaScript URL defining the worker needs to be delivered when creating the worker object:

    diff --git a/org.tizen.tutorials/html/web/w3c/security/iframe_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/security/iframe_tutorial_w.htm index fff4c0a..42c466d 100644 --- a/org.tizen.tutorials/html/web/w3c/security/iframe_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/security/iframe_tutorial_w.htm @@ -264,10 +264,10 @@    <fieldset>       <legend>Login</legend> -      <input type="text" id="email" name="email" placeholder="e-mail address" required> -      <input type="password" id="password" name="password" placeholder="password" required> +      <input type="text" id="email" name="email" placeholder="e-mail address" required /> +      <input type="password" id="password" name="password" placeholder="password" required />    </fieldset> -   <input type="submit" value="Login"> +   <input type="submit" value="Login"/> </form>
  • If the sandbox attribute is deactivated, the imported login information is displayed: diff --git a/org.tizen.tutorials/html/web/w3c/storage/appcache_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/storage/appcache_tutorial_w.htm index e22f834..bfb6058 100644 --- a/org.tizen.tutorials/html/web/w3c/storage/appcache_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/storage/appcache_tutorial_w.htm @@ -219,7 +219,7 @@ cache_test.js
  • -

    Different events can occur based on the cache status. Use the addEventListener method to add listeners in order to detect events:

    +

    Different events can occur based on the cache status. Use the addEventListener() method to add listeners in order to detect events:

     <script>
        var appCache = window.applicationCache;
    diff --git a/org.tizen.tutorials/html/web/w3c/supplement/typedarray_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/supplement/typedarray_tutorial_w.htm
    index b18d312..a2f0ff4 100644
    --- a/org.tizen.tutorials/html/web/w3c/supplement/typedarray_tutorial_w.htm
    +++ b/org.tizen.tutorials/html/web/w3c/supplement/typedarray_tutorial_w.htm
    @@ -172,14 +172,14 @@
     
        var x = new Uint8ClampedArray(10);
        x.set([18, 93, 42], 3);
    -   log.innerHTML += "<br><div>[Result2]</div>";
    +   log.innerHTML += "<br/><div>[Result2]</div>";
        log.innerHTML += "<div>" + x[3] + "<div>";
        log.innerHTML += "<div>" + x[4] + "<div>";
        log.innerHTML += "<div>" + x[5] + "<div>";
     
        var x = new Uint8ClampedArray([0, 1, 2, 3, 4, 5]);
        var y = x.subarray(2, 5);
    -   log.innerHTML += "<br><div>[Result3]</div>";
    +   log.innerHTML += "<br/><div>[Result3]</div>";
        log.innerHTML += "<div>" + y.length + "<div>";	
     </script>
    diff --git a/org.tizen.tutorials/html/web/w3c/supplement/webgl_tutorial_w.htm b/org.tizen.tutorials/html/web/w3c/supplement/webgl_tutorial_w.htm index 63e0034..521474a 100644 --- a/org.tizen.tutorials/html/web/w3c/supplement/webgl_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/w3c/supplement/webgl_tutorial_w.htm @@ -560,7 +560,7 @@ gl.drawArrays(gl. TRIANGLE_FAN, 0, 6);    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW);    /* Bring the color attribute position from the WebGlProgram instance */ -   var vertexColorAttribute = gl.getAttribLocation(program, "attVertexColor"); +   var vertexColorAttribute = gl.getAttribLocation(program, "attVertexColor");    /* Activate the attribute data array */    gl.enableVertexAttribArray(vertexColorAttribute);    gl.vertexAttribPointer(vertexColorAttribute, 4, gl.FLOAT, false, 0, 0); @@ -891,7 +891,7 @@ gl.drawArrays(gl. TRIANGLE_FAN, 0, 6);
     <script>
        gl.viewport(0, 0, canvas.width, canvas.height);
    -   mat4.perspective(45, canvas.width / canvas.height , 0.1, 100.0, pMatrix);
    +   mat4.perspective(45, canvas.width / canvas.height, 0.1, 100.0, pMatrix);
        mat4.identity(mvMatrix);
        mat4.translate(mvMatrix, [0, 0, -2.0]);
     </script>
    @@ -1161,7 +1161,7 @@ gl.drawArrays(gl. TRIANGLE_FAN, 0, 6);
            Note 
            
            
    -       The perspective() method is not WebGL-embedded, so it must be used directly, or a 3rd party matrix library must be used. 
    +       The perspective() method is not WebGL-embedded, so it must be used directly, or a third-party matrix library must be used. 
            
          
      
    @@ -1171,7 +1171,7 @@ gl.drawArrays(gl. TRIANGLE_FAN, 0, 6);
     
           mat4.translate(mvMatrix, [0.0, 0.0, -5.0]);
     
    -      mat4.rotate(mvMatrix, xRot * Math.PI / 180 , [1, 0, 0]);
    +      mat4.rotate(mvMatrix, xRot * Math.PI / 180, [1, 0, 0]);
           mat4.rotate(mvMatrix, yRot * Math.PI / 180, [0, 1, 0]);
     
           gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexPositionBuffer);
    @@ -1364,7 +1364,7 @@ gl.drawArrays(gl. TRIANGLE_FAN, 0, 6);
     
     
  • -
  • Create a new Scene instance and create the mesh and light elements using the createMeshs() and setupLight(); methods:

    +
  • Create a new Scene instance and create the mesh and light elements using the createMeshs() and setupLight() methods:

        function setupScene()
        {
    @@ -1412,7 +1412,7 @@ gl.drawArrays(gl. TRIANGLE_FAN, 0, 6);
                                         new THREE.MeshLambertMaterial({color:'red'}));
              plane.overdraw = true;
              plane.position.y = -100;
    -         plane.rotation.x =  Math.PI * -0.4;
    +         plane.rotation.x = Math.PI * -0.4;
     
              return plane;
           })();  		
    diff --git a/org.tizen.tutorials/html/web/w3c/tutorials_w3c_w.htm b/org.tizen.tutorials/html/web/w3c/tutorials_w3c_w.htm
    index 0c5f2ce..d4be056 100644
    --- a/org.tizen.tutorials/html/web/w3c/tutorials_w3c_w.htm
    +++ b/org.tizen.tutorials/html/web/w3c/tutorials_w3c_w.htm
    @@ -55,13 +55,10 @@
     	

    Demonstrates how you can use geolocation features.

  • Supplementary Features: Managing Supplementary Features

    Demonstrates how you can take advantage of supplementary features, such as full screen views, typed arrays, and the WebGL graphics library.

  • -
  • Watch Application: Developing a Watch Face Application in wearable applications only -

    Demonstrates how you can create and run a wearable watch face application using the Tizen IDE.

  • For more information about implementing the UI for your application using the W3C features, see W3C.

    -
    diff --git a/org.tizen.tutorials/html/web/w3c/watchface/developing_watch_app.htm b/org.tizen.tutorials/html/web/w3c/watchface/developing_watch_app.htm deleted file mode 100644 index 9097626..0000000 --- a/org.tizen.tutorials/html/web/w3c/watchface/developing_watch_app.htm +++ /dev/null @@ -1,555 +0,0 @@ - - - - - - - - - - - - - - Watch Application: Developing a Watch Face Application - - - - - - -
    -

    Watch Application: Developing a Watch Face Application

    - -

    You can easily create a watch face application for a wearable device by taking advantage of the BasicWatch sample delivered with the Tizen SDK. The sample is a fully functional application that displays an analog clock on a canvas, and you can use it as a basis for your watch face application.

    - -

    For more information on the sample functionality and the full source code, see Basic Watch task.

    - -

    This feature is supported in wearable applications only.

    - -

    This article describes the main steps required to develop a watch face application using the Tizen IDE. For more detailed information about the application development process, see Web Application Development Process. To learn how to design a watch face, see the Gear UI guides on the Samsung Developers site.

    - -

    Step 1: Creating the Project

    - -

    To create the application project in the IDE:

    - -
      -
    1. Launch the Tizen IDE.
    2. -
    3. In the IDE menu, select File > New > Tizen Web Project. -

      If the project option you want is not visible, make sure that you are using the correct perspective (Tizen Web). To switch perspectives, go to Window > Open Perspective > Other and select the perspective you need.

    4. -
    5. In the New Tizen Web Project window, select Sample > WEARABLE-[version] > Basic > BasicWatch.
    6. -
    7. Define your project name and location, and click Finish.
    8. -
    - -

    Figure: Creating the project

    -

    Creating the project

    - -

    The new project is shown in the Project Explorer view of the IDE, with full sample content:

    -
      -
    • css folder: CSS file directory
    • -
    • js folder: JavaScript file directory
    • -
    • config.xml: Application configuration file
    • -
    • icon.png: Icon file
    • -
    • index.html: HTML file defining the application layout
    • -
    - -

    Setting the Application Layout

    - -

    You can define the application layout with the index.html file.

    - -

    Figure: BasicWatch screen

    -

    BasicWatch screen

    - -

    By default, the BasicWatch sample application layout contains only the main screen that displays the clock on a canvas element.

    - -
    -<head>
    -   <title>Canvas Clock - Canvas API Tutorial</title>
    -   <link rel="stylesheet" type="text/css" href="css/style.css" />
    -</head>
    -<body>
    -   <div id="box">
    -      <canvas class="canvas"></canvas>
    -   </div>
    -   <script src="js/main.js"></script>
    -</body>
    -
    - -

    To draw the watch face on the canvas, use the main.js file:

    -
      -
    1. Create the clock in the middle of the canvas, and define the watch face style: -
      -function renderDots() 
      -{
      -   'use strict';
      -
      -   var dx = 0,
      -       dy = 0,
      -       i = 1,
      -       angle = null;
      -
      -   context.save();
      -   context.translate(canvas.width / 2, canvas.height / 2);
      -   context.beginPath();
      -   context.fillStyle = '#999999';
      -
    2. -
    3. Create 4 dots on the sides of the watch face and use the fill() method to style the dots: -
      -   for (i = 1; i <= 4; i++) 
      -   {
      -      angle = (i - 3) * (Math.PI * 2) / 4;
      -      dx = clockRadius * 0.9 * Math.cos(angle);
      -      dy = clockRadius * 0.9 * Math.sin(angle);
      -
      -      context.arc(dx, dy, 3, 0, 2 * Math.PI, false);
      -      context.fill();
      -   }
      -   context.closePath();
      -
    4. -
    5. Create the center point: -
      -   context.beginPath();
      -
      -   context.fillStyle = '#ff9000';
      -   context.strokeStyle = '#fff';
      -   context.lineWidth = 4;
      -
      -   context.arc(0, 0, 7, 0, 2 * Math.PI, false);
      -   context.fill();
      -   context.stroke();
      -   context.closePath();
      -}
      -
    6. -
    - -

    Configuring and Initializing the Application

    - -

    You can set the application configuration using the config.xml file.

    - - - - - - - - - - -
    Note
    By default, the BasicWatch sample has the application category defined as <tizen:category name="http://tizen.org/category/wearable_clock" />. -

    To run your application on Samsung Gear 2, Samsung Gear 2 Neo, and Samsung Gear S devices, use <tizen:category name="com.samsung.wmanager.WATCH_CLOCK" /> instead.

    - -

    To initialize the application and define basic features, use the main.js file:

    - -
      -
    1. Modify the window.requestAnimationFrame() method to make the application compatible with the main browsers: -
      -window.requestAnimationFrame = window.requestAnimationFrame ||
      -   window.webkitRequestAnimationFrame ||
      -   window.mozRequestAnimationFrame ||
      -   window.oRequestAnimationFrame ||
      -   window.msRequestAnimationFrame ||
      -   function (callback) 
      -   {
      -      'use strict';
      -      window.setTimeout(callback, 1000 / 60);
      -   };
      -
    2. -
    3. Initialize the canvas context and define the canvas area: -
      -window.onload = function () 
      -{
      -   'use strict';
      -
      -   canvas = document.querySelector('canvas');
      -   context = canvas.getContext('2d');
      -   clockRadius = document.width / 2;
      -
      -   canvas.width = document.width;
      -   canvas.height = canvas.width;
      -
    4. -
    5. Define an event listener to detect back key events: -
      -   window.addEventListener('tizenhwkey', function (e) 
      -   {
      -      if (e.keyName == 'back') 
      -      {
      -         tizen.application.getCurrentApplication().exit();
      -      }
      -   });
      -
      -   window.requestAnimationFrame(watch);
      -};
      -
    6. -
    - -

    Coding the Main Features

    - -

    To display the actual time on the watch face, create the clock needles and set their position using the main.js file:

    - -
      -
    1. Render the clock needles: -
        -
      1. The needles can be created using the renderNeedle() method. -

        To create the needle as a triangle or a polygon, assign the coordinate of the beginning point with the moveTo() method. To assign the rest of the points of the triangle or polygon, use the lineTo() method, which defines the position of the next connecting vertex. You can also adjust the size of each clock needle with the lineTo() method.

        -
        -function renderNeedle(angle, radius) 
        -{
        -   'use strict';
        -   context.save();
        -   context.rotate(angle);
        -   context.beginPath();
        -   context.lineWidth = 4;
        -   context.strokeStyle = '#fff';
        -   context.moveTo(6, 0);
        -   context.lineTo(radius, 0);
        -   context.closePath();
        -   context.stroke();
        -   context.closePath();
        -   context.restore();
        -}
        -
      2. -
      3. Create the hour needle using the renderHourNeedle() method: -
        -function renderHourNeedle(hour) 
        -{
        -   'use strict';
        -
        -   var angle = null,
        -       radius = null;
        -
        -   angle = (hour - 3) * (Math.PI * 2) / 12;
        -   radius = clockRadius * 0.55;
        -   renderNeedle(angle, radius);
        -}
        -
      4. -
      5. Create the minute needle using the renderMinuteNeedle() method: -
        -function renderMinuteNeedle(minute)
        -{
        -   'use strict';
        -
        -   var angle = null,
        -       radius = null;
        -
        -   angle = (minute - 15) * (Math.PI * 2) / 60;
        -   radius = clockRadius * 0.75;
        -   renderNeedle(angle, radius);
        -}
        -
      6. -
      -
    2. -
    3. Indicate the current time: -
        -
      1. Determine the current time using the new Date() method. -

        To point the needles accurately, define variables for the current hour and minute.

        -
        -function watch() 
        -{
        -   'use strict';
        -
        -   var date = new Date(),
        -       hours = date.getHours(),
        -       minutes = date.getMinutes(),
        -       seconds = date.getSeconds(),
        -       hour = hours + minutes / 60,
        -       minute = minutes + seconds / 60;
        -       nextMove = 1000 - date.getMilliseconds();
        -
      2. -
      3. Every time a new time is indicated, erase the previous time (the previously positioned needles) using the clearRect() method: -
        -   context.clearRect(0, 0, context.canvas.width, context.canvas.height);
        -
      4. -
      5. Point the clock needles to display the current time: -
        -   renderDots();
        -   renderHourNeedle(hour);
        -   renderMinuteNeedle(minute);
        -
        -   context.restore();
        -   setTimeout(function() 
        -   {
        -      window.requestAnimationFrame(watch);
        -   }, nextMove);}
        -
      6. -
      -
    4. -
    - -

    Step 2: Building the Project

    - -

    When your code is ready, you can build the project:

    - -
      -
    1. In the Project Explorer view, select your project.
    2. -
    3. In the IDE menu, select Project > Build Project. -

      Any build errors are shown in the Problems and Project Explorer views.

      -
    4. -
    - -

    After building, the Tizen IDE automatically packages the project by creating a .wgt package file.

    - -

    Step 3: Running the Application

    - -

    You can run the application on the Emulator or a real target device.

    - -

    To run the application on the Emulator:

    - -
      -
    1. Launch the Emulator: -
        -
      1. Start the Emulator Manager by clicking the Emulator Manager icon in the Connection Explorer view.
      2. -
      3. In the Emulator Manager window, select the wearable-[version] tab.
      4. -
      5. If no Emulator images exist, create one by clicking Create New.
      6. -
      7. Launch the Emulator by clicking the play button.
      8. -
      -

      Emulator Manager

      -
    2. -
    3. In the Project Explorer view, right-click the project and select Run As > Tizen Web Application.
    4. -
    - -

    To run the application on a target device:

    - -
      -
    1. Connect the target device to your computer.
    2. -
    3. In the Project Explorer view, right-click the project and select Run As > Run Configurations.
    4. -
    5. In the Run Configurations window, click New Launch Configuration and set the timeout using the Timeout value slider. -

      The timeout value represents the waiting time for the application launch operation. If you are using a lower configuration computer, set a higher timeout value to avoid application launch failure errors.

    6. -
    7. To start the run, click Run.
    8. -
    - -

    BasicWatch Source Code

    - -

    index.html:

    - -
    -<!DOCTYPE html><html><head>
    -   <meta charset="utf-8" />
    -   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
    -   <meta name="description" content="Canvas Clock - Canvas API Tutorial" />
    -
    -   <title>Canvas Clock - Canvas API Tutorial</title>
    -
    -   <link rel="stylesheet" type="text/css" href="css/style.css" />
    -</head>
    -<body>
    -   <div id="box">
    -      <canvas class="canvas"></canvas>
    -   </div>
    -   <script src="js/main.js"></script>
    -</body>
    -</html>
    - -

    main.js:

    - -
    -var canvas, context, clockRadius;
    -
    -window.requestAnimationFrame = window.requestAnimationFrame ||
    -   window.webkitRequestAnimationFrame ||
    -   window.mozRequestAnimationFrame ||
    -   window.oRequestAnimationFrame ||
    -   window.msRequestAnimationFrame ||
    -   function (callback) 
    -   {
    -      'use strict';
    -      window.setTimeout(callback, 1000 / 60);
    -   };
    -
    -function renderDots() 
    -{
    -   'use strict';
    -
    -   var dx = 0,
    -       dy = 0,
    -       i = 1,
    -       angle = null;
    -
    -   context.save();
    -
    -   /* Assign the clock creation location in the middle of the canvas */
    -   context.translate(canvas.width / 2, canvas.height / 2);
    -
    -   /* Assign the style of the number which will be applied to the clock plate */
    -   context.beginPath();
    -
    -   context.fillStyle = '#999999';
    -
    -   /* Create 4 dots in a circle */
    -   for (i = 1; i <= 4; i++) 
    -   {
    -      angle = (i - 3) * (Math.PI * 2) / 4;
    -      dx = clockRadius * 0.9 * Math.cos(angle);
    -      dy = clockRadius * 0.9 * Math.sin(angle);
    -
    -      context.arc(dx, dy, 3, 0, 2 * Math.PI, false);
    -      context.fill();
    -   }
    -   context.closePath();
    -
    -   /* Render center dot */
    -   context.beginPath();
    -
    -   context.fillStyle = '#ff9000';
    -   context.strokeStyle = '#fff';
    -   context.lineWidth = 4;
    -
    -   context.arc(0, 0, 7, 0, 2 * Math.PI, false);
    -   context.fill();
    -   context.stroke();
    -   context.closePath();
    -}
    -
    -function renderNeedle(angle, radius) 
    -{
    -   'use strict';
    -   context.save();
    -   context.rotate(angle);
    -   context.beginPath();
    -   context.lineWidth = 4;
    -   context.strokeStyle = '#fff';
    -   context.moveTo(6, 0);
    -   context.lineTo(radius, 0);
    -   context.closePath();
    -   context.stroke();
    -   context.closePath();
    -   context.restore();
    -}
    -
    -function renderHourNeedle(hour) 
    -{
    -   'use strict';
    -
    -   var angle = null,
    -      radius = null;
    -
    -   angle = (hour - 3) * (Math.PI * 2) / 12;
    -   radius = clockRadius * 0.55;
    -   renderNeedle(angle, radius);
    -}
    -
    -function renderMinuteNeedle(minute) 
    -{
    -   'use strict';
    -
    -   var angle = null,
    -      radius = null;
    -
    -   angle = (minute - 15) * (Math.PI * 2) / 60;
    -   radius = clockRadius * 0.75;
    -   renderNeedle(angle, radius);
    -}
    -
    -function getDate() 
    -{
    -   'use strict';
    -
    -   var date;
    -   try 
    -   {
    -      date = tizen.time.getCurrentDateTime();
    -   } 
    -   catch (err) 
    -   {
    -      console.error('Error: ', err.message);
    -      date = new Date();
    -   }
    -
    -   return date;
    -}
    -
    -function watch() 
    -{
    -   'use strict';
    -
    -   /* Import the current time */
    -   /* noinspection JSUnusedAssignment */
    -   var date = getDate(),
    -      hours = date.getHours(),
    -      minutes = date.getMinutes(),
    -      seconds = date.getSeconds(),
    -      hour = hours + minutes / 60,
    -      minute = minutes + seconds / 60,
    -      nextMove = 1000 - date.getMilliseconds();
    -
    -   /* Erase the previous time */
    -   context.clearRect(0, 0, context.canvas.width, context.canvas.height);
    -
    -   renderDots();
    -   renderHourNeedle(hour);
    -   renderMinuteNeedle(minute);
    -
    -   context.restore();
    -   setTimeout(function () 
    -   {
    -      window.requestAnimationFrame(watch);
    -   }, nextMove);
    -}
    -
    -window.onload = function () 
    -{
    -   'use strict';
    -
    -   canvas = document.querySelector('canvas');
    -   context = canvas.getContext('2d');
    -   clockRadius = document.width / 2;
    -
    -   /* Assign the area that will use Canvas */
    -   canvas.width = document.width;
    -   canvas.height = canvas.width;
    -
    -   /* Add eventListener for tizenhwkey */
    -   window.addEventListener('tizenhwkey', function (e) 
    -   {
    -      if (e.keyName === 'back') 
    -      {
    -         try 
    -         {
    -            tizen.application.getCurrentApplication().exit();
    -         } 
    -         catch (err) 
    -         {
    -            console.error('Error: ', err.message);
    -         }
    -      }
    -   });
    -
    -   window.requestAnimationFrame(watch);
    -};
    - - - -
    - -Go to top - - - - - - - \ No newline at end of file diff --git a/org.tizen.tutorials/index.xml b/org.tizen.tutorials/index.xml index 0768eda..4d392a1 100644 --- a/org.tizen.tutorials/index.xml +++ b/org.tizen.tutorials/index.xml @@ -3,6 +3,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -12,7 +150,6 @@ - @@ -33,16 +170,16 @@ + - - + @@ -53,20 +190,9 @@ - + - - - - - - - - - - - @@ -81,6 +207,18 @@ + + + + + + + + + + + + @@ -146,136 +284,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.tizen.ui.practices/html/native/efl/accessibility_implementation_n.htm b/org.tizen.ui.practices/html/native/efl/accessibility_implementation_n.htm index 477e775..1bb2a2b 100644 --- a/org.tizen.ui.practices/html/native/efl/accessibility_implementation_n.htm +++ b/org.tizen.ui.practices/html/native/efl/accessibility_implementation_n.htm @@ -100,7 +100,7 @@

    Creating an Accessible Application

    -

    You can use the mobile native UI Components sample application provided within the SDK to see how the most important accessibility features are implemented in practice. The sample application contains an AT-SPI2 compliant screen reader, which you can use to test the accessibility features in a device. Enable the screen reader by running the sample application and selecting Accessibility > Screen Reader > Screen Reader (TTS).

    +

    You can use the mobile native UI Components sample application provided within the SDK to see how the most important accessibility features are implemented in practice. The sample application contains an AT-SPI2 compliant screen reader, which you can use to test the accessibility features in a device. Enable the screen reader by running the sample application and selecting Accessibility > Screen Reader > Screen Reader (TTS).

    In the Tizen 2.4 release, the screen reader is available only inside the UI Components application. This means that when the UI Components application is terminated or paused and sent to the background, the screen reader is automatically disabled, and when the UI Components application is restored, the screen reader is enabled.

    Figure: UI Components sample application

    @@ -202,18 +202,18 @@
  • Button with a custom name

    Use the elm_object_text_set() function to define a custom name.

    -// File: src/accessibility/screen_reader/description.c
    +/* File: src/accessibility/screen_reader/description.c */
     
     btn = elm_button_add(layout);
     elm_object_text_set(btn, "Test Name");
    -
    +

    If the user highlights the button, the screen reader says "Test Name, button" (it reads out the component custom name and default trait).

  • Button without a name and description

    If you define a button with an icon image only, no name or description is provided by default.

    -// File: src/accessibility/screen_reader/description.c
    +/* File: src/accessibility/screen_reader/description.c */
     
     btn = elm_button_add(layout);
     img = elm_image_add(btn);
    @@ -226,40 +226,40 @@ elm_object_part_content_set(btn, "icon", img);
     
  • Button with an internationalized description

    Use the elm_atspi_accessible_description_set() function to define a description. To make multiple language versions available define the actual description strings in PO files and use the elm_atspi_accessible_translation_domain_set() function to bind the translation domain to the component.

    -// File: CMakeLists.txt
    +/* File: CMakeLists.txt */
     
     # i18n
     ADD_SUBDIRECTORY(po)
     
    -// File: packaging/ui-controls.spec
    +/* File: packaging/ui-controls.spec */
     
     BuildRequires:  gettext-tools
     
     /opt/usr/apps/org.tizen.ui-controls/res/locale/<any language, use asterisk>/LC_MESSAGES/<any file, use asterisk>
     
    -// File: po/CMakeLists.txt
    +/* File: po/CMakeLists.txt */
     
     SET(POFILES en_US.po it_IT.po)
     SET(MSGFMT "/usr/bin/msgfmt")
     
     FOREACH(pofile ${POFILES})
    -   SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
    -   MESSAGE(PO: "  ${pofile}")
    -   GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
    -   GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
    -   SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
    -   ADD_CUSTOM_COMMAND(
    -      OUTPUT ${moFile}
    -      COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
    -      DEPENDS ${absPofile})
    -   INSTALL(FILES ${moFile}
    -      DESTINATION ${LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${PACKAGE}.mo)
    -   SET(moFiles ${moFiles} ${moFile})
    +    SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
    +    MESSAGE(PO: "  ${pofile}")
    +    GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
    +    GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
    +    SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
    +    ADD_CUSTOM_COMMAND(
    +        OUTPUT ${moFile}
    +        COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
    +        DEPENDS ${absPofile})
    +    INSTALL(FILES ${moFile}
    +        DESTINATION ${LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${PACKAGE}.mo)
    +    SET(moFiles ${moFiles} ${moFile})
     ENDFOREACH(pofile)
     
     ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles})
     
    -// File: po/en_US.po
    +/* File: po/en_US.po */
     
     msgid "IDS_BUTTON_DESCRIPTION"
     msgstr "One finger double tap to activate"
    @@ -267,7 +267,7 @@ msgstr "One finger double tap to activate"
     msgid "IDS_BUTTON_NAME"
     msgstr "Button accessibility name"
     
    -// File: po/it_IT.po
    +/* File: po/it_IT.po */
     
     msgid "IDS_BUTTON_DESCRIPTION"
     msgstr "Un dito doppio tap per attivare"
    @@ -275,13 +275,13 @@ msgstr "Un dito doppio tap per attivare"
     msgid "IDS_BUTTON_NAME"
     msgstr "Button nome di accessibilità"
     
    -// File: src/main.c
    +/* File: src/main.c */
     
    -// Bind package locale file
    +/* Bind package locale file */
     bindtextdomain (PACKAGE, LOCALE_DIR);
     textdomain (PACKAGE);
     
    -// File: src/accessibility/screen_reader/description.c
    +/* File: src/accessibility/screen_reader/description.c */
     
     btn = elm_button_add(layout);
     elm_object_text_set(btn, "Test Name");
    @@ -297,7 +297,7 @@ elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
      
  • Button with an accessible name

    Use the elm_atspi_accessible_name_set() function to define an accessible name.

    -// File: src/accessibility/screen_reader/description.c
    +/* File: src/accessibility/screen_reader/description.c */
     
     btn = elm_button_add(layout);
     elm_object_text_set(btn, "Test Name");
    @@ -324,7 +324,7 @@ elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
     

    The following source code snippet demonstrates how to handle the favorite and on&off checkbox styles in the application source code:

    -// File: src/check.c
    +/* File: src/check.c */
     
     check = elm_check_add(box);
     elm_object_style_set(check, "favorite");
    @@ -382,7 +382,7 @@ elm_atspi_accessible_name_set(check, "On, off");
     

    You can have various independent relation-based navigation chains on one screen. Each relation-based navigation chain is resolved locally and has priority over the default navigation order maintained by the screen reader. When one of the ends of a relation-based navigation chain is reached, the highlight frame goes forward along to the actual navigation direction to the closest component in the default navigation order. It omits interim components of the relation-based navigation chains. In this example, when the navigation command "next" is called from the c button, the highlight frame goes from the c button to the Default reading order label.

    -// File: src/accessibility/screen_reader/reading_order.c
    +/* File: src/accessibility/screen_reader/reading_order.c */
     
     Evas_Object *btnA;
     Evas_Object *btnB;
    @@ -391,17 +391,17 @@ Evas_Object *btnD;
     Evas_Object *btnE;
     Evas_Object *labelCustom;
     
    -// Creating buttons with custom order
    +/* Creating buttons with custom order */
     btnA = elm_button_add(layout);
     elm_object_text_set(btnA, "a");
     
    -// Inform the assistive technology that UI information must be presented in following order (btnA is by-passed)
    +/* Inform the assistive technology that UI information must be presented in following order (btnA is by-passed) */
     elm_atspi_accessible_relationship_append(labelCustom, ELM_ATSPI_RELATION_FLOWS_TO, btnD);
     elm_atspi_accessible_relationship_append(btnD, ELM_ATSPI_RELATION_FLOWS_TO, btnE);
     elm_atspi_accessible_relationship_append(btnE, ELM_ATSPI_RELATION_FLOWS_TO, btnB);
     elm_atspi_accessible_relationship_append(btnB, ELM_ATSPI_RELATION_FLOWS_TO, btnC);
     
    -// Inverse relations
    +/* Inverse relations */
     elm_atspi_accessible_relationship_append(btnC, ELM_ATSPI_RELATION_FLOWS_FROM, btnB);
     elm_atspi_accessible_relationship_append(btnB, ELM_ATSPI_RELATION_FLOWS_FROM, btnE);
     elm_atspi_accessible_relationship_append(btnE, ELM_ATSPI_RELATION_FLOWS_FROM, btnD);
    @@ -448,21 +448,21 @@ elm_atspi_accessible_relationship_append(btnD, ELM_ATSPI_RELATION_FLOWS_FROM, la
     
     
     
    -group 
    -{ 
    +group
    +{
        name: "elm/button/base/custom2";
     
        data.item: "access_highlight" "on";
        images.image: "../../res/images/c_h_2.png" COMP;
     
    -   parts 
    +   parts
        {
           part
    -      { 
    +      {
              name: "highlight";
              clip_to: "highlight_clip";
    -         description 
    -         { 
    +         description
    +         {
                 state: "default" 0.0;
                 image.normal: "../../res/images/c_h_2.png";
                 image.border: 10 10 10 10;
    @@ -474,26 +474,26 @@ group
                 rel2.offset: -30 0;
                 visible: 0;
              }
    -         description 
    -         { 
    +         description
    +         {
                 state: "visible" 0.0;
                 inherit: "default" 0.0;
                 visible: 1;
              }
           }
        }
    -   programs 
    +   programs
        {
    -      program 
    -      { 
    +      program
    +      {
              name: "show_new_highlight";
              signal: "elm,action,access_highlight,show";
              source: "elm";
              action: STATE_SET "visible" 0.0;
              target: "highlight";
           }
    -      program 
    -      { 
    +      program
    +      {
              name: "hide_new_highlight";
              signal: "elm,action,access_highlight,hide";
              source: "elm";
    @@ -507,22 +507,22 @@ group
     

    In the src/accessibility/screen_reader/custom_frame.c file, assign the style defined above to the button component using the elm_object_style_set() function, where the second parameter is the last segment of the elm/button/base/custom2 group name defined in the EDC file.

    -static Evas_Object* 
    +static Evas_Object*
     create_custom_frame(Evas_Object *parent)
     {
    -   Evas_Object *btn;
    -   Evas_Object *layout;
    -	
    -   layout = elm_layout_add(parent);
    +    Evas_Object *btn;
    +    Evas_Object *layout;
     
    -   btn = elm_button_add(layout);
    +    layout = elm_layout_add(parent);
     
    -   elm_object_style_set(btn, "custom2");
    +    btn = elm_button_add(layout);
     
    -   return layout;
    +    elm_object_style_set(btn, "custom2");
    +
    +    return layout;
     }
    - +
  • -- 2.7.4