<h2>Follow-up</h2>
<p>Once we have learned the basics of the Notification API, we can now move on to more advanced tasks, including:</p>
<ul>
- <li><a href="#status">Displaying the Notification Status</a>
- <p>Display and track the notification status.</p></li>
<li><a href="#bar">Displaying the Progress Bar</a>
<p>Create, display, and update a progress bar.</p>
</li>
<pre class="prettyprint">
#include <notification.h></pre></li>
-<li>To follow this tutorial, place a JPEG image file named <span style="font-family: Courier New,Courier,monospace">notification_image.jpg</span> in your device's <span style="font-family: Courier New,Courier,monospace">/tmp</span> directory. The following variables are used in the tutorial code:
-<pre class="prettyprint">static const char *image_path = "tmp/notification_image.jpg";
-static notification_h notification = NULL;</pre></li></ol>
+<li>To follow this tutorial, place an image file i.e. in yours application shared resource directory. The following variables are used in the tutorial code:
+<pre class="prettyprint">static notification_h notification = NULL;
+char *image_path[BUFLEN];
+char * shared_path = app_get_shared_resource_path();
+snprintf(image_path, BUFLEN, "%stutorial_native_api_application.png", shared_path);
+free(shared_path);</pre></li></ol>
</div>
</li>
<li>
<div class="devicespec-tit">
- <h2 id="status" name="status" class="items-tit-h2">Displaying the Notification Status</h2>
-<span class="fr"><a href="#" class="bt-arr"><em>Hide</em></a></span>
- </div>
- <div class="devicespec-con">
-<p>To display the notification status:</p>
-
-<ol>
-<li><p>Define the message and register the callback for tracking the message status:</p>
-
-<pre class="prettyprint">
-notification_status_monitor_message_cb_set(_notification_status_message_cb, NULL);
-
-notification_status_message_post("Example 2 Msg.");
-
-notification_status_monitor_message_cb_unset();
-</pre></li>
-
-<li><p>When the message is posted on screen, the callback function is invoked:</p>
-
-<pre class="prettyprint">
-static void _notification_status_message_cb(const char *message, void *data)
-{
- dlog_print(DLOG_INFO, "NOTIFICATION", "Callback: %s\n", message);
-}
-</pre></li></ol>
-
- <p class="figure">Figure: Notification status</p>
- <p style="text-align:center;"><img alt="Notification status" src="../../images/notification_status_sd.png" /></p>
- </div>
- </li>
- <li>
- <div class="devicespec-tit">
<h2 id="bar" name="bar" class="items-tit-h2">Displaying the Progress Bar</h2>
<span class="fr"><a href="#" class="bt-arr"><em>Hide</em></a></span>
</div>
<p>To display the progress bar:</p>
-<ol><li><p>The Notification API provides allows you to create a progress bar, which is initialized by the <span style="font-family: Courier New,Courier,monospace">NOTIFICATION_LY_ONGOING_PROGRESS</span> argument in the <span style="font-family: Courier New,Courier,monospace">GetNewNotification()</span> function.</p>
+<ol><li><p>Notification with progress bar, is created with <span style="font-family: Courier New,Courier,monospace">NOTIFICATION_TYPE_ONGOING</span> parameter. Then progress may be updated like in following example:</p>
<p>To set the initial progress:</p>
<pre class="prettyprint">
-static GMainLoop* gmainloop = NULL;
-mainloop = g_main_loop_new(NULL, FALSE);
+notification_h notification = NULL;
-GetNewNotification(&notification, "Notification", NOTIFICATION_LY_ONGOING_PROGRESS);
+// Create notification
+notification = notification_create(NOTIFICATION_TYPE_ONGOING);
+PRINT_MSG("notification_create %s", (notification != NULL) ? "succeed" : "failed");
-notification_set_progress(notification, 0);
+// Set 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");
-notification_set_tag(notification, "noti_tag");
+ret = notification_set_progress(notification, 0);
+PRINT_MSG("notification_set_progress %s", (ret == 0) ? "succeed" : "failed");
-notification_post(notification);
+ret = notification_set_tag(notification, "noti_tag");
+PRINT_MSG("notification_set_tag %s", (ret == 0) ? "succeed" : "failed");
-g_timeout_add(1000, timeout_func, gmainloop);
-g_main_loop_run(gmainloop);
-g_main_loop_unref(gmainloop);
+// Send notification
+ret = notification_post(notification);
+PRINT_MSG("notification_post %s", (ret == 0) ? "succeed" : "failed");
-notification_delete(notification);
+// Change status of notification
+ecore_timer_add(1, timeout_func, NULL);
</pre></li>
<li>To update the progress bar, use the <span style="font-family: Courier New,Courier,monospace">notification_load_by_tag()</span> function for getting the notification handle:
<pre class="prettyprint">
-static gboolean timeout_func(gpointer data)
+static Eina_Bool timeout_func(void *data)
{
- static int i = 0;
- double percent = 0;
- i++;
- notification_h notification = notification_load_by_tag("noti_tag");
- notification_set_progress(notification, ((double) i / 10.0));
- notification_get_progress(notification, &percent);
- notification_update(notification);
-
- dlog_print(DLOG_INFO, "NOTIFICATION", "Progress: %f\n", percent);
-
- if (timeout == i)
- {
- g_main_loop_quit((GMainLoop*) data);
- dlog_print(DLOG_INFO, "NOTIFICATION", "End of awaiting!\n");
-
- return FALSE;
- }
-
- return TRUE;
+ 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);
+
+ if (10 == i)
+ {
+ dlog_print(DLOG_INFO, "NOTIFICATION", "End of awaiting!n");
+ notification_delete(notification);
+ return ECORE_CALLBACK_DONE;
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
}
</pre></li></ol>
#include <shortcut_manager.h>
</pre>
</li>
-<li><p>To add a shortcut, use the <span style="font-family: Courier New,Courier,monospace">shortcut_add_to_home()</span> function:</p>
+<li><p>Add a shortcut, using the <span style="font-family: Courier New,Courier,monospace">shortcut_add_to_home()</span> function:</p>
-<pre class="prettyprint">shortcut_add_to_home("Music Player", LAUNCH_BY_PACKAGE, NULL, image_path, 1, result_cb, NULL);</pre>
+<pre class="prettyprint">shortcut_add_to_home("Music Player", LAUNCH_BY_PACKAGE, NULL, "/path/to/icon", 1, result_cb, NULL);</pre>
-<p>To add a shortcut, you have to know the package name and set an icon for the application. The above example sets the icon parameter to <span style="font-family: Courier New,Courier,monospace">NULL</span>, which adds a default icon for the application.</p></li>
+<p>To add a shortcut, you have to know the package name and set an icon for the application. The icon parameter may be set to <span style="font-family: Courier New,Courier,monospace">NULL</span>, for adding a default icon for the application.</p></li>
-<li><p>To track possible errors, define a callback function:</p>
+<li><p>Track possible errors by a callback function:</p>
<pre class="prettyprint">static int result_cb(int ret, void *data)
{
if (ret < 0)