modify package manager tutorial
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 30 Jun 2015 05:01:49 +0000 (14:01 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 30 Jun 2015 05:45:40 +0000 (14:45 +0900)
Change-Id: Ie02823e46bc413030f0a72c18c984d79bb10d9b2
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
org.tizen.tutorials/html/native/app_framework/package_tutorial_n.htm [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 8667223..7f96c38
@@ -41,7 +41,7 @@
        <h1>Package Manager: Installing and Uninstalling Applications</h1>
 
   
-<p>This tutorial demonstrates how you can retrieve package information and manage packages.</p> 
+<p>This tutorial demonstrates how you can manage installed packages with its information.</p>
 
   <h2 id="warmup" name="warmup">Warm-up</h2> 
   <p>Become familiar with the Package Manager API basics by learning about:</p> 
 <pre class="prettyprint">
 #include &lt;package_manager.h&gt;
 </pre></li>
-<li><p>The <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.info</span>, <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.install</span>,  and <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.setting</span> privileges are required for the Package Manager API.</p>
-<p>Add the privileges to the <span style="font-family: Courier New,Courier,monospace">tizen-manifest.xml</span> file.</p></li></ol></li>
-<li>Use the 
-   <span style="font-family: Courier New,Courier,monospace">package_manager_foreach_package_info()</span> function:
-
-<pre class="prettyprint">
-package_manager_foreach_package_info(package_info_cb, NULL)
-</pre>
-
-<p>The function takes the following parameters:</p>
-<ul>
-  <li>[in] <span style="font-family: Courier New,Courier,monospace">callback</span>: Callback function to be invoked</li>
-  <li>[in] <span style="font-family: Courier New,Courier,monospace">user_data</span>: User data to be passed to the callback function </li>
-  <li>[out] 0 on success, otherwise a negative error value</li>
-</ul></li>
-
-<li><p> Use the <span style="font-family: Courier New,Courier,monospace">package_manager_package_info_cb</span> callback to retrieve all installed packages and print package information. Finally, destroy the package info handler. </p>
-
+<li><p>The <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.info</span> privilege is required to get package information.</p>
+<p>Add this privilege to the <span style="font-family: Courier New,Courier,monospace">tizen-manifest.xml</span> file.</p></li></ol></li>
+<li>Prepare callback function <span style="font-family: Courier New,Courier,monospace">package_info_cb</span> which will be invoked for each package information retrieved</li>
 <pre class="prettyprint">
 void package_info_cb(package_info_h package_info, void *user_data)
 {
@@ -124,7 +109,25 @@ void package_info_cb(package_info_h package_info, void *user_data)
 &nbsp;&nbsp;&nbsp;free(type);
 }
 </pre>
+<li>Use the
+   <span style="font-family: Courier New,Courier,monospace">package_manager_foreach_package_info()</span> function: This function will retrieve all package information and invoke callback for each information retrieved
+
+<pre class="prettyprint">
+package_manager_foreach_package_info(package_manager_package_info_cb callback, void *user_data)
+</pre>
+
+<p>The function takes the following parameters:</p>
+<ul>
+  <li>[in] <span style="font-family: Courier New,Courier,monospace">callback</span>: Callback function to be invoked for each package information retrieved</li>
+  <li>[in] <span style="font-family: Courier New,Courier,monospace">user_data</span>: User data to be passed to the callback function </li>
+  <li>[out] 0 on success, otherwise a negative error value</li>
+</ul></li>
+
+<li><p> Call <span style="font-family: Courier New,Courier,monospace">package_manager_foreach_package_info</span> with passing callback and userdata </p>
+
+
 <pre class="prettyprint">
+<<<<<<< Updated upstream
 ret = package_manager_foreach_package_info(package_info_cb, NULL);
 if (ret != PACKAGE_MANAGER_ERROR_NONE) 
 {
@@ -142,25 +145,60 @@ if (ret != PACKAGE_MANAGER_ERROR_NONE)
 <pre class="prettyprint">
 #include &lt;package_manager.h&gt;
 </pre></li>
-<li><p>The <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.info</span>, <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.install</span>,  and <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.setting</span> privileges are required for the Package Manager API.</p>
-<p>Add the privileges to the <span style="font-family: Courier New,Courier,monospace">tizen-manifest.xml</span> file.</p></li></ol></li>
+<li><p>The <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.info</span>  privilege is required for this Package Manager API.</p>
+<p>Add the privilege to the <span style="font-family: Courier New,Courier,monospace">tizen-manifest.xml</span> file.</p></li></ol></li>
 <li>Use the 
         <span style="font-family: Courier New,Courier,monospace">package_manager_get_package_info()</span> function:
+<pre class="prettyprint">
+int package_manager_get_package_info(const char *package_id, package_info_h *package_info)
+</pre>
+<p>The function takes the following parameters:</p>
+<ul>
+  <li>[in] <span style="font-family: Courier New,Courier,monospace">package_id</span>: ID of the package</li>
+  <li>[in] <span style="font-family: Courier New,Courier,monospace">package_info</span>: Package information for the given package ID.</li>
+  <li>[out] 0 on success, otherwise a negative error value</li>
+</ul></li>
 
+<li>After getting <span style="font-family: Courier New,Courier,monospace">package_info_h</span> handle, use package_info_get_ functions to retrieve specific information
 <pre class="prettyprint">
+char *version = NULL;
+char *label = NULL;
+char *type = NULL;
 package_info_h package_info = NULL;
 package_manager_get_package_info(&quot;PACKAGE-ID&quot;, &amp;package_info);
 
+package_info_get_version(package_info, &version);
+package_info_get_label(package_info, &label);
+package_info_get_type(package_info, &type);
+
+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);
+
+free(label);
+free(icon);
+free(version);
+
 // Use package information
 package_info_destroy(package_info);
 </pre>
 
-<p>The function takes the following parameters:</p>
-<ul>
-  <li>[in] <span style="font-family: Courier New,Courier,monospace">package_id</span>: ID of the package</li>
-  <li>[in] <span style="font-family: Courier New,Courier,monospace">package_info</span>: Package information for the given package ID</li>
-  <li>[out] 0 on success, otherwise a negative error value</li>
-</ul></li></ol>
+</li>
+<li>You can get package information with functions listed below:
+       <pre>
+package_info_get_label(package_info_h package_info, char **label)
+package_info_get_icon(package_info_h package_info, char **path)
+package_info_get_version(package_info_h package_info, char **version)
+package_info_get_type(package_info_h package_info, char **type)
+package_info_get_installed_storage(package_info_h package_info, package_info_installed_storage_type_e *storage)
+package_info_get_root_path(package_info_h package_info, char **path)
+package_info_is_system_package(package_info_h package_info, bool *system)
+package_info_is_removable_package(package_info_h package_info, bool *removable)
+package_info_is_preload_package(package_info_h package_info, bool *preload)
+package_info_is_accessible(package_info_h package_info, bool *accessible)</pre>
+</li>
+<li>Package Manager handle shoule be released with <span style="font-family: Courier New,Courier,monospace">package_info_destroy</span> function.</li>
+</ol>
 
 
  <h2 id="listen" name="listen">Listening to Package Events</h2>
@@ -172,14 +210,17 @@ package_info_destroy(package_info);
 <pre class="prettyprint">
 #include &lt;package_manager.h&gt;
 </pre></li>
-<li><p>The <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.info</span>, <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.install</span>,  and <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.setting</span> privileges are required for the Package Manager API.</p>
-<p>Add the privileges to the <span style="font-family: Courier New,Courier,monospace">tizen-manifest.xml</span> file.</p></li></ol></li>
+<li><p>The <span style="font-family: Courier New,Courier,monospace">http://tizen.org/privilege/packagemanager.info</span> privilege is required for this Package Manager API.</p>
+<p>Add privilege to the <span style="font-family: Courier New,Courier,monospace">tizen-manifest.xml</span> file.</p></li></ol></li>
 <li>
 <p>Create the package manager (<span style="font-family: Courier New,Courier,monospace">package_manager_h</span>) using the <span style="font-family: Courier New,Courier,monospace">package_manager_create()</span> function:</p>
 
+<pre class="prettyprint">
+package_manager_create(package_manager_h * manager)</pre>
 <pre class="prettyprint">package_manager_h manager;
 package_manager_create(&amp;manager);</pre>
 
+
 <p>The function takes the following parameters:</p>
 <ul>
   <li>[in] <span style="font-family: Courier New,Courier,monospace">manager</span>: Package manager handle that is newly created on success </li>
@@ -189,29 +230,25 @@ package_manager_create(&amp;manager);</pre>
 
 <li>
        
-<p>Set the status when the package is installed, uninstalled, or updated:</p>
-
+<p>Set the package event which you want to listen by invoking package_manager_set_event_status:</p>
+<pre class="prettyprint">package_manager_set_event_status(package_manager_h manager, int status_type)</pre>
 <pre class="prettyprint">package_manager_set_event_status(manager, PACKAGE_MANAGER_STATUS_TYPE_ALL);</pre>
 
 <p>The function takes the following parameters:</p>
 <ul>
  <li>[in] <span style="font-family: Courier New,Courier,monospace">manager</span>: Package manager handle</li>
- <li>[in] <span style="font-family: Courier New,Courier,monospace">status_type</span>: Status of the package</li>
- <li>[out] 0 on success, otherwise a negative error value</li>
-</ul>
-</li>
-
-<li>
-       <p>Register a callback function to be invoked when the package is installed, uninstalled, or updated:</p>
-<pre class="prettyprint">
-package_manager_set_event_cb(manager, event_cb, NULL);
-</pre>
-
-<p>The function takes the following parameters:</p>
-<ul>
- <li>[in] <span style="font-family: Courier New,Courier,monospace">manager</span>: Package manager handle</li>
- <li>[in] <span style="font-family: Courier New,Courier,monospace">callback</span>: Callback function to be registered</li>
- <li>[in] <span style="font-family: Courier New,Courier,monospace">user_data</span>: User data to be passed to the callback function</li>
+ <li>[in] <span style="font-family: Courier New,Courier,monospace">status_type</span>: Status of the package<br>
+       There are several event types want to listen
+       <pre class="prettyprint">
+PACKAGE_MANAGER_STATUS_TYPE_ALL : All status
+PACKAGE_MANAGER_STATUS_TYPE_INSTALL :  Install package status
+PACKAGE_MANAGER_STATUS_TYPE_UNINSTALL : Uninstall package status
+PACKAGE_MANAGER_STATUS_TYPE_UPGRADE : Upgrade package status
+PACKAGE_MANAGER_STATUS_TYPE_MOVE : Move package status
+PACKAGE_MANAGER_STATUS_TYPE_CLEAR_DATA : Clear data status
+PACKAGE_MANAGER_STATUS_TYPE_INSTALL_PROGRESS : Install progress status
+PACKAGE_MANAGER_STATUS_TYPE_GET_SIZE : Get size status
+</pre></li>
  <li>[out] 0 on success, otherwise a negative error value</li>
 </ul>
 </li>
@@ -241,6 +278,24 @@ package_manager_set_event_cb(manager, event_cb, NULL);
 }</pre>
 
 </li>
+
+<li>
+       <p>Register a callback function to be invoked when the event you registered has happened:</p>
+<pre class="prettyprint">
+int package_manager_set_event_cb(package_manager_h manager, package_manager_event_cb callback, void *user_data)</pre>
+<pre class="prettyprint">
+package_manager_set_event_cb(manager, event_cb, NULL);
+</pre>
+
+<p>The function takes the following parameters:</p>
+<ul>
+ <li>[in] <span style="font-family: Courier New,Courier,monospace">manager</span>: Package manager handle</li>
+ <li>[in] <span style="font-family: Courier New,Courier,monospace">callback</span>: Callback function to be registered</li>
+ <li>[in] <span style="font-family: Courier New,Courier,monospace">user_data</span>: User data to be passed to the callback function</li>
+ <li>[out] 0 on success, otherwise a negative error value</li>
+</ul>
+</li>
+
 <li>
        <p>Free the package manager:</p>