[Files Sharing Server] Added description of the view.
authorMichal Szczecinski <m.szczecinsk@samsung.com>
Fri, 18 Dec 2015 13:49:33 +0000 (14:49 +0100)
committerAgnieszka Janowicz <a.janowicz@samsung.com>
Tue, 22 Dec 2015 10:49:27 +0000 (11:49 +0100)
Change-Id: Ia242d1098ed818d39be3bf50731ae53373426808
Signed-off-by: Michal Szczecinski <m.szczecinsk@samsung.com>
org.tizen.sampledescriptions/html/images/files_sharing_server-help_text.png [new file with mode: 0644]
org.tizen.sampledescriptions/html/images/files_sharing_server_accept_button_enable.png [new file with mode: 0644]
org.tizen.sampledescriptions/html/images/files_sharing_server_received_list.png [new file with mode: 0644]
org.tizen.sampledescriptions/html/mobile_n/files_sharing_server_sd_mn.htm

diff --git a/org.tizen.sampledescriptions/html/images/files_sharing_server-help_text.png b/org.tizen.sampledescriptions/html/images/files_sharing_server-help_text.png
new file mode 100644 (file)
index 0000000..e451557
Binary files /dev/null and b/org.tizen.sampledescriptions/html/images/files_sharing_server-help_text.png differ
diff --git a/org.tizen.sampledescriptions/html/images/files_sharing_server_accept_button_enable.png b/org.tizen.sampledescriptions/html/images/files_sharing_server_accept_button_enable.png
new file mode 100644 (file)
index 0000000..eb297ac
Binary files /dev/null and b/org.tizen.sampledescriptions/html/images/files_sharing_server_accept_button_enable.png differ
diff --git a/org.tizen.sampledescriptions/html/images/files_sharing_server_received_list.png b/org.tizen.sampledescriptions/html/images/files_sharing_server_received_list.png
new file mode 100644 (file)
index 0000000..76e209d
Binary files /dev/null and b/org.tizen.sampledescriptions/html/images/files_sharing_server_received_list.png differ
index 34cbefc..8f243f3 100644 (file)
@@ -165,6 +165,157 @@ static Eina_Bool __controller_handle_reject_button_clicked_event(void *data, int
 }
 </pre>
 <h3>View</h3>
+<p>The following figure illustrates the application views:</p>
+<p class="figure">Figure: Files Sharing Server Screens</p>
+<p align="center"><img alt="" src="../images/files_sharing_server-help_text.png" border="1"/> <img alt="" src="../images/files_sharing_server_accept_button_enable.png" border="1"/> <img alt="" src="../images/files_sharing_server_received_list.png" border="1"/>
+
+<p>The view of the sample application is initialized by the controller module. It calls the <span style="font-family: Courier New,Courier,monospace">view_init()</span> function to initialize all view objects and data.</p>
+<pre class="prettyprint">
+view_data_t *view_init(void)
+{
+&nbsp;&nbsp;&nbsp;view_data_t *vd = NULL;
+&nbsp;&nbsp;&nbsp;vd = (view_data_t *)malloc(sizeof(view_data_t));
+&nbsp;&nbsp;&nbsp;if (!vd)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+
+&nbsp;&nbsp;&nbsp;/*Create window, conformant and layout. Code for that objects are generated by the SDK.*/
+&nbsp;&nbsp;&nbsp;/*...*/
+
+&nbsp;&nbsp;&nbsp;if (!__view_create_files_list(vd))
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+
+&nbsp;&nbsp;&nbsp;if (!__view_init_buttons(vd))
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+
+&nbsp;&nbsp;&nbsp;/*Show help text and disable buttons.*/
+&nbsp;&nbsp;&nbsp;view_show_help(vd);
+&nbsp;&nbsp;&nbsp;view_disable_accept_button(vd);
+&nbsp;&nbsp;&nbsp;view_disable_reject_button(vd);
+&nbsp;&nbsp;&nbsp;evas_object_show(vd->win);
+&nbsp;&nbsp;&nbsp;return vd;
+}
+</pre>
+<p>The most important part of the view is the received files list. It shows all files obtained by the Bluetooth OPP protocol as well as the current status of the files transfer. To add a new file to the list, <span style="font-family: Courier New,Courier,monospace">view_append_new_file()</span> function is used.</p>
+
+<pre class="prettyprint">
+Elm_Object_Item *view_append_new_file(view_data_t *vd, const char *file_name, int *progress)
+{
+&nbsp;&nbsp;&nbsp;struct _list_data_s *list_data_s = NULL;
+&nbsp;&nbsp;&nbsp;Elm_Object_Item *new_item = NULL;
+
+&nbsp;&nbsp;&nbsp;if (!vd || !file_name || !progress)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+
+&nbsp;&nbsp;&nbsp;list_data_s = (struct _list_data_s *)malloc(sizeof(struct _list_data_s));
+&nbsp;&nbsp;&nbsp;if (!list_data_s)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+
+&nbsp;&nbsp;&nbsp;/*List_data_s structure is used to pass one more parameter to the genlist item creation callback.*/
+&nbsp;&nbsp;&nbsp;list_data_s->file_name = file_name;
+&nbsp;&nbsp;&nbsp;list_data_s->progress = progress;
+
+&nbsp;&nbsp;&nbsp;/*Use elm_gengrid API to add a new file.*/
+&nbsp;&nbsp;&nbsp;new_item = elm_genlist_item_append(vd->files_list, vd->gic,
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(void *)list_data_s, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+&nbsp;&nbsp;&nbsp;if (!new_item)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+&nbsp;&nbsp;&nbsp;return new_item;
+}
+</pre>
+
+<p>The function described above calls <span style="font-family: Courier New,Courier,monospace">elm_genlist_item_append()</span> function, which uses a callback from the genlist constructor to create the item's <span style="font-family: Courier New,Courier,monospace">Evas_Object</span>. Callback presented below creates the item's content.</p>
+
+<pre class="prettyprint">
+static Evas_Object *__view_set_file_item_content_cb(void *data, Evas_Object *obj, const char *part)
+{
+&nbsp;&nbsp;&nbsp;if (!strncmp(part, FILE_LIST_ITEM_CONTENT, strlen(part)) &&
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strlen(part) == strlen(FILE_LIST_ITEM_CONTENT))
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return __view_create_file_list_item(obj, data);
+
+&nbsp;&nbsp;&nbsp;return NULL;
+}
+</pre>
+
+
+<pre class="prettyprint">
+static Evas_Object *__view_create_file_list_item(Evas_Object *parent, struct _list_data_s *list_data_s)
+{
+&nbsp;&nbsp;&nbsp;Evas_Object *item_ly = NULL;
+&nbsp;&nbsp;&nbsp;Evas_Object *progressbar = NULL;
+&nbsp;&nbsp;&nbsp;char edj_path[PATH_MAX] = {0, };
+&nbsp;&nbsp;&nbsp;char buf[64] = {0, };
+
+&nbsp;&nbsp;&nbsp;if (!parent || !list_data_s || !list_data_s->file_name || !list_data_s->progress)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+
+&nbsp;&nbsp;&nbsp;/*Create item layout*/
+&nbsp;&nbsp;&nbsp;item_ly = elm_layout_add(parent);
+&nbsp;&nbsp;&nbsp;if (!item_ly)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+
+&nbsp;&nbsp;&nbsp;/*Get the path to the EDJE layout*/
+&nbsp;&nbsp;&nbsp;app_utils_get_resource(EDJ_FILE, edj_path, (int)PATH_MAX);
+
+&nbsp;&nbsp;&nbsp;/*Create progressbar widget*/
+&nbsp;&nbsp;&nbsp;progressbar = elm_progressbar_add(parent);
+&nbsp;&nbsp;&nbsp;if (!progressbar)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling.*/
+
+&nbsp;&nbsp;&nbsp;/*Set initial values.*/
+&nbsp;&nbsp;&nbsp;elm_progressbar_value_set(progressbar, (double)(*(list_data_s->progress)) / 100.0);
+&nbsp;&nbsp;&nbsp;evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+&nbsp;&nbsp;&nbsp;/*Show the file name and the sending progress*/
+&nbsp;&nbsp;&nbsp;elm_object_part_text_set(item_ly, PART_ITEM_TITLE, list_data_s->file_name);
+&nbsp;&nbsp;&nbsp;snprintf(buf, sizeof(buf), "%d %%", *(list_data_s->progress));
+&nbsp;&nbsp;&nbsp;elm_object_part_text_set(item_ly, PART_ITEM_PROGRESS, buf);
+
+&nbsp;&nbsp;&nbsp;elm_object_part_content_set(item_ly, PART_ITEM_CONTENT, progressbar);
+&nbsp;&nbsp;&nbsp;evas_object_show(item_ly);
+&nbsp;&nbsp;&nbsp;return item_ly;
+}
+</pre>
+
+<p>Each item consists of an <span style="font-family: Courier New,Courier,monospace">elm_progressbar</span> widget, file name and progress text. To update mentioned content, <span style="font-family: Courier New,Courier,monospace">view_update_progress()</span> function is used.</p>
+
+<pre class="prettyprint">
+void view_update_progress(Elm_Object_Item *it, double progress)
+{
+&nbsp;&nbsp;&nbsp;Evas_Object *item_ly = NULL;
+&nbsp;&nbsp;&nbsp;Evas_Object *progressbar = NULL;
+&nbsp;&nbsp;&nbsp;char buf[64] = {0, };
+
+&nbsp;&nbsp;&nbsp;if (!it)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Erorr handling.*/
+
+&nbsp;&nbsp;&nbsp;item_ly = elm_object_item_part_content_get(it, FILE_LIST_ITEM_CONTENT);
+&nbsp;&nbsp;&nbsp;if (!item_ly) /*It is not an error. If the item_ly == NULL it means that it is not visible in the genlist so it should not be updated.*/
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;
+
+&nbsp;&nbsp;&nbsp;/*Get the reference to the elm_progressbar widget.*/
+&nbsp;&nbsp;&nbsp;progressbar = elm_object_part_content_get(item_ly, PART_ITEM_CONTENT);
+&nbsp;&nbsp;&nbsp;/*Save the progress in the buffer.*/
+&nbsp;&nbsp;&nbsp;snprintf(buf, sizeof(buf), "%d %%", (int) (progress * 100));
+&nbsp;&nbsp;&nbsp;/*Update progress text*/
+&nbsp;&nbsp;&nbsp;elm_object_part_text_set(item_ly, PART_ITEM_PROGRESS, buf);
+&nbsp;&nbsp;&nbsp;/*Update progressbar value*/
+&nbsp;&nbsp;&nbsp;elm_progressbar_value_set(progressbar, progress);
+}
+</pre>
+<p>File list items are deleted automatically by the <span style="font-family: Courier New,Courier,monospace">elm_genlist</span> API when application is terminated. Delete function is also called during the list scroll when items are not longer visible. In both cases additional data must be released.</p>
+
+<pre class="prettyprint">
+static void __view_del_file_item_cb(void *data, Evas_Object *obj)
+{
+&nbsp;&nbsp;&nbsp;struct _list_data_s *list_data_s = (struct _list_data_s *)data;
+&nbsp;&nbsp;&nbsp;if (!list_data_s)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*Error handling*/
+&nbsp;&nbsp;&nbsp;
+&nbsp;&nbsp;&nbsp;free(list_data_s);
+}
+</pre>
+
 
 <h3>Model</h3>