From: Michal Szczecinski Date: Tue, 24 Nov 2015 13:41:48 +0000 (+0100) Subject: [Files-Sharing] First part of the documentation (view and model) descritpion. X-Git-Tag: tizen_3.0/TD_SYNC/20161201~273^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d8e5290f5e1f5322e5442f4ef42fd3ced3da4f5;p=sdk%2Fonline-doc.git [Files-Sharing] First part of the documentation (view and model) descritpion. Change-Id: I225ff81c45267289b91774f046505bb13e822693 Signed-off-by: Michal Szczecinski --- diff --git a/org.tizen.sampledescriptions/html/images/files-sharing-main_view.png b/org.tizen.sampledescriptions/html/images/files-sharing-main_view.png new file mode 100644 index 0000000..b022742 Binary files /dev/null and b/org.tizen.sampledescriptions/html/images/files-sharing-main_view.png differ diff --git a/org.tizen.sampledescriptions/html/images/files_sharing_application_structure.png b/org.tizen.sampledescriptions/html/images/files_sharing_application_structure.png new file mode 100644 index 0000000..ec3f9fe Binary files /dev/null and b/org.tizen.sampledescriptions/html/images/files_sharing_application_structure.png differ diff --git a/org.tizen.sampledescriptions/html/images/files_sharing_sequence.png b/org.tizen.sampledescriptions/html/images/files_sharing_sequence.png new file mode 100644 index 0000000..d768f63 Binary files /dev/null and b/org.tizen.sampledescriptions/html/images/files_sharing_sequence.png differ diff --git a/org.tizen.sampledescriptions/html/images/files_sharing_view.png b/org.tizen.sampledescriptions/html/images/files_sharing_view.png new file mode 100644 index 0000000..7c907df Binary files /dev/null and b/org.tizen.sampledescriptions/html/images/files_sharing_view.png differ diff --git a/org.tizen.sampledescriptions/html/mobile_n/files_sharing_sd_mn.htm b/org.tizen.sampledescriptions/html/mobile_n/files_sharing_sd_mn.htm new file mode 100644 index 0000000..e3a439d --- /dev/null +++ b/org.tizen.sampledescriptions/html/mobile_n/files_sharing_sd_mn.htm @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + Files-Sharing Sample Overview + + + + +
+
+ +
+
+

Mobile native

+
+ +

Files-Sharing Sample Overview

+ +

The Files-Sharing sample application demonstrates how you can use Bluetooth OPP (Object Push Profile) API to send media data between two devices.

+

The following figure illustrates the application view:

+

Figure: Main view

+

Main view +

+ +

Prerequisites

+

To ensure proper application execution, the following privileges and features must be set:

+
    +
  • http://tizen.org/privilege/mediastorage,
  • +
  • http://tizen.org/privilege/bluetooth,
  • +
  • http://tizen.org/feature/network.bluetooth,
  • +
  • http://tizen.org/feature/network.bluetooth.opp.
  • +
+

Additional prerequisites:

+
    +
  • Bluetooth adapter should be switched on,
  • +
  • connection with the paired device should be available.
  • +
+ +

Implementation

+

The following figure illustrates the application structure:

+

Figure: Main view

+

Sample structure

+

The application uses a simple MVC (Model-View-Controller) architectural pattern. The application model consists of a media and Bluetooth module.

+ +

View

+

The view alignment is managed by an EDJE layout which is depicted in details below.

+

Figure: Main view structure

+

Sample structure

+

The view is very simple. It consists of three types of widgets. The paired devices list is handled by an elm_hoversel widget. The files list is shown in an elm_gengrid widget. To send the selected files list, an elm_button is used.

+ +

The view implementation is stored in the following files:

+
    +
  • src/view/view.c: The main view file. It creates a standard widgets set: a window, a conformant and a layout, as well as subwidgets shown in the figure above which are later inserted in the main layout.
  • +
  • src/view/view_devices_selector.c: The devices selector is used to choose the destination device.
  • +
  • src/view/view_files_selector.c: The files selector is an elm_gengrid widget used to show available pictures.
  • +
  • src/view/files_selector_item.c: The files selector item handles the view of each picture placed in the elm_gengrid widget.
  • +
  • src/view/view_popup.c: The popup view is responsible for displaying warnings and the file sending progress.
  • +
+ +

Model

+

The Model module deals directly with the application data. It is responsible for:

+
    +
  • creating the media files list. In case of this sample application, only image files are used;
  • +
  • creating the paired devices list;
  • +
  • preparing the data structures used in the sample application.
  • +
+ +

Media module

+

The implementation of the media module that is responsible for acquiring the list of available images was taken from the Media sample application and its description can be found in Tizen SDK as well as in the Media API tutorial (Media Content Tutorial).

+ +

Bluetooth module

+

The main tasks of the Bluetooth module:

+
    +
  • initializing Bluetooth,
  • +
  • reading paired devices list,
  • +
  • sending files between devices,
  • +
  • monitoring the status of the connection (sending progress, errors that occured during the process).
  • +
+ +

The Bluetooth module implementation is stored in the following files:

+
    +
  • src/bt_module/bt_module.c: The main file of the model. It is responsible for the Bluetooth adapter initialization and obtaining paired devices list.
  • +
  • src/bt_module/bt_device.c: It is responsible for bt_device data structure handling which holds additional device information such as the remote address.
  • +
  • src/bt_module/bt_devices_list.c: The bt_devices_list holds the list of all available devices obtained from the Bluetooth API. The file provides the API to find a device in that list.
  • +
+ +

The module is initialized in the bt_module_init() function which is described below.

+
+bool bt_module_init()
+{
+   Eina_List *bt_devices_list = NULL;
+   int ret = 0;
+   ret = bt_initialize();
+   if (ret != BT_ERROR_NONE) {
+      /*Function below is used to print detailed error description in the Tizen SDK log tool.*/
+      __bt_module_check_err("bt_initialize", ret);
+      return false;
+   }
+   ret = bt_opp_client_initialize();
+   if (ret != BT_ERROR_NONE) {
+      __bt_module_check_err("bt_opp_client_initialize", ret);
+      /*If opp client initialization fails, Bluetooth adapter must be freed.*/
+      bt_deinitialize();
+      return false;
+   }
+   /*Function is used to find all paired devices.*/
+   ret = bt_adapter_foreach_bonded_device(__bt_module_find_bonded_devices_cb, NULL);
+   bt_devices_list = bt_devices_list_get();return true;
+}
+
+ +

The devices are added into the list in the callback function invoked by bt_adapter_foreach_bonded_device() function.

+ +
+static bool __bt_module_find_bonded_devices_cb(bt_device_info_s *device_info, void *user_data)
+{
+   bt_dev_t *bt_dev = NULL;
+   if (!device_info) {
+      /*Print error message and return false.*/
+   }
+   /*Create the device handle based on the data obtained from the callback.*/
+   bt_dev = bt_device_create(device_info->remote_name, device_info->remote_address);
+   if (!bt_dev) {
+      /*If creation fails, print error message and return false.*/
+   }
+   if (!bt_devices_list_append_device((const bt_dev_t *) bt_dev)) {
+      /*If bt_devices_list API returns error, created device will be removed here.*/
+      bt_device_destroy(bt_dev);
+   }
+   if (!controller_update_view(bt_dev)) {
+      /*If view update fails, error message will be printed and function returns false.*/
+   }
+   return true;
+}
+
+ +

The following figure illustrates the process of files sharing.

+

Figure: Files sharing

+

Sample structure

+ +

Files exchange starts when the user presses the send button. Then, the view passes the selected files list and the device name to the controller module. The controller module uses the internal API to get the remote address for the specified device and uses the Bluetooth module to send the files. The bt_module_send_files() function which uses Bluetooth OPP API is described below.

+ +
+bool bt_module_send_files(Eina_List *files_list, const char *device_name)
+{
+   Eina_List *it = NULL;
+   const char *path = NULL;
+   bt_dev_t *dev = NULL;
+   const char *remote_addr = NULL;
+   int ret = BT_ERROR_NONE;
+   /*Find the device by name*/
+   dev = bt_devices_list_get_device(device_name);
+   /*Get the remote address of the device*/
+   remote_addr = bt_device_get_remote_addr(dev);
+   /*Each selected file is added into the OPP client.*/
+   EINA_LIST_FOREACH (files_list, it, path) {
+      ret = bt_opp_client_add_file(path);
+      if (ret != BT_ERROR_NONE) {
+         /*Check the status. If error occurs function releases used resources and returns false.*/
+      }
+   }
+   /*Push added files and check the status and setup callbacks invoked on events occurred in the Bluetooth module.*/
+   ret = bt_opp_client_push_files(remote_addr, __bt_module_responded_cb, __bt_module_progress_cb, __bt_module_push_finished_cb, NULL);
+   if (ret != BT_ERROR_NONE) {
+   /*Print errors and release used resources.*/
+   }
+   return true;
+}
+
+ + + + + +
+ +Go to top + + + + + + + diff --git a/org.tizen.sampledescriptions/html/mobile_n/sd_mn.htm b/org.tizen.sampledescriptions/html/mobile_n/sd_mn.htm index c69b28e..beb88b9 100644 --- a/org.tizen.sampledescriptions/html/mobile_n/sd_mn.htm +++ b/org.tizen.sampledescriptions/html/mobile_n/sd_mn.htm @@ -5,47 +5,47 @@ - + - Mobile Native Sample Descriptions + Mobile Native Sample Descriptions
-
+

Mobile native

- -

Mobile Native Sample Descriptions

- -

To access general information about the native sample functionality and the content of the sample source files, click the sample name in the following tables.

- - - + +

Mobile Native Sample Descriptions

+ +

To access general information about the native sample functionality and the content of the sample source files, click the sample name in the following tables.

+ + +
- - - - - - - - - + + + + + + + + + + - + @@ -70,28 +70,28 @@ - - + + - - + + - + - + - - + + - - + + - - - + + + @@ -106,40 +106,44 @@ - - + + - - - + + + - - + + - - - + + + - - + + - - + + + + + + - - + + - - + + @@ -150,52 +154,52 @@ - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -206,8 +210,8 @@ - - + + @@ -221,9 +225,9 @@ - - - + + + @@ -242,12 +246,12 @@ - - + + - - + + @@ -255,12 +259,12 @@ - - + + - - + + @@ -307,10 +311,10 @@ - - + + - + @@ -323,50 +327,50 @@ - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - -
Table: Mobile native samples in the Tizen SDK -
Sample nameDescription
Sample nameDescription
Alarm Demonstrates how you can implement recurring and on-time alarms.
Application Common Demonstrates how you can extract application-related information.Bundle Demonstrates how you can manipulate bundle objects.
Cairo Basic
Cairo Basic Demonstrates how you can implement the Cairo image backend.
Cairo EvasGL
Cairo EvasGL Demonstrates how you can implement the Cairo GL backend with the Evas_GL surface.
CalculatorCalculator Demonstrates how you can implement an advanced calculator application.
Contacts
Contacts Demonstrates how you can manage contacts.
Context History
Context History Demonstrates how you can retrieve device usage statistics using the Contextual History API.
Context Trigger
Context Trigger Demonstrates how you can manage contextual rules using the Context Trigger API.
Data-Control-Provider Demonstrates how you can implement a data control provider service using both SQL and map methods.
Drag and Drop
Drag and Drop Demonstrates how you can implement a drag-and-drop operation.
EFL Core
EFL Core Demonstrates how you can use the EFL and Elementary libraries and related APIs in Tizen.
EOM
EOM Demonstrates how you can use the EOM mode with the External Output Manager API.
EvasGLCube
EvasGLCube Demonstrates how you can implement a cube that can be rotated on the screen through Evas_GL.
Event Demonstrates how you can implement event listeners and publish custom events.
File Manager
File Manager Demonstrates how you can implement a complex view using EFL UI components and containers.
GLView11Cube
Files SharingDemonstrates how you can implement a Files Sharing application using Bluetooth OPP protocol.
GLView11Cube Demonstrates how you can use ElmGLView to create a 3D cube on the screen.
GLViewCube
GLViewCube Demonstrates how you can implement a simple UI and draw a rotating cube using simple vertex and fragment shaders.
GLViewShader
GLViewShader Demonstrates how you can render more complex geometric shapes with OpenGL® ES and use Elementary GLView helper macros to port existing code.
GPS Service Demonstrates how you can implement a Tizen service providing geolocation data using the IPC mechanism from the Tizen API.
HybridServiceApp
HybridServiceApp Demonstrates how you can communicate with a Tizen Web application (HybridWebApp) to manage the timer for the Web application.
IMF
IMF Demonstrates how you can implement the default keyboard layout change.
Internationalization Demonstrates how you can provide multilanguage support to the application using 2 different translation mechanisms.
LaunchOnEventServiceApp
LaunchOnEventServiceApp Demonstrates how you can use launch-on-event in your application.
Layout Transitions Demonstrates how you can implement an animated transition between different application views.
LBS Geofence
LBS Geofence Demonstrates how you can manage fences and places.
LBS Maps
LBS Maps Demonstrates how you can use map services, such as geocode, place search, and routing.
LibOauth Demonstrates how you can get access tokens from various resource owners, such as Twitter and Tumblr, who use the OAuth protocol RFC5849.
Lockscreen
Lockscreen Demonstrates how you can implement a screen locking mechanism.
Media App
Media App Demonstrates how you can develop media handling applications with the ability to manage different media sources.
Media-controller-client
Media-controller-client Demonstrates how you can create a custom media controller client type application.
Media-controller-server
Media-controller-server Demonstrates how you can create a custom media controller server type application.
Metadata Editor Demonstrates how you can retrieve and modify metadata.
Notification Manager
Notification Manager Demonstrates how you can present a notification to the user.
Pedometer Demonstrates how you can implement a simple pedometer.
Piano
Piano Demonstrates how you can implement a complex view using EFL UI components with different EDC styles.
Resource Management Demonstrates how you can use the Resource Manager API together with the SDK's Resource Manager to benefit from task automation.
Sample Account
Sample Account Demonstrates how you can implement an account provider which can add and configure an account.
Scheduler
Scheduler Demonstrates how you can manage scheduling of calendar events and other calendar options.
Demonstrates how you can implement an animated index connected with an Elm scroller component.
SelfCamera
SelfCamera Demonstrates how you can use the front camera in your application.
SensorApp
SensorApp Demonstrates how you can retrieve data from various Tizen sensor types.
TTS Demonstrates how you can use the TTS (Text-To-Speech) feature in your application.
UI Components
UI Components Demonstrates how you can implement an interactive application GUI with basic Elementary UI components.
Voice Control Demonstrates how you can use the Voice Control API to initialize, deinitialize, add, and remove voice commands.Volume Demonstrates how you can acquire and set the device sound levels.
[UI Sample] ApplicationStore
[UI Sample] ApplicationStore Demonstrates how you can implement an application store view with several boxes and buttons.
[UI Sample] Calculator
[UI Sample] Calculator Demonstrates how you can implement a simple calculator application with complex views.
[UI Sample] Clock
[UI Sample] Clock Demonstrates how you can implement a clock application with different views.
[UI Sample] Email
[UI Sample] Email Demonstrates how you can implement a complex email application view.
[UI Sample] GalleryDemonstrates how you can implement a gallery view to display images.
[UI Sample] LanguageChangeDemonstrates how you can implement an application that supports multiple languages and language change at runtime.
[UI Sample] LayoutSampleDemonstrates how you can implement a common layout for your application.
[UI Sample] MessageBubbleDemonstrates how you can manage communication between Edje code and C code through EFL UI components and containers.
[UI Sample] SNSDemonstrates how you can implement a scrollable view with tables and buttons through EFL UI components and containers.
[UI Sample] SettingDemonstrates how you can implement a Settings application with pop-up menus and different views through EFL UI components and containers.
- - + + [UI Sample] Gallery + Demonstrates how you can implement a gallery view to display images. + + + [UI Sample] LanguageChange + Demonstrates how you can implement an application that supports multiple languages and language change at runtime. + + + [UI Sample] LayoutSample + Demonstrates how you can implement a common layout for your application. + + + [UI Sample] MessageBubble + Demonstrates how you can manage communication between Edje code and C code through EFL UI components and containers. + + + [UI Sample] SNS + Demonstrates how you can implement a scrollable view with tables and buttons through EFL UI components and containers. + + + [UI Sample] Setting + Demonstrates how you can implement a Settings application with pop-up menus and different views through EFL UI components and containers. + + + + +