Accept NULL handler only for releasing pd/lb pixmap 32/15532/1
authorSung-jae Park <nicesj.park@samsung.com>
Thu, 23 Jan 2014 02:39:40 +0000 (11:39 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Thu, 23 Jan 2014 02:39:40 +0000 (11:39 +0900)
Change-Id: I07d639bc76ff91b9a4bce68f69c2b003ec54158f

include/livebox.h
packaging/liblivebox-viewer.spec
src/livebox.c

index bead828..630571c 100644 (file)
@@ -1419,7 +1419,7 @@ extern int livebox_pd_pixmap(const struct livebox *handler);
  *   After acquire the pixmap of PD, it will not be destroyed
  *   So if the new update is comming with new pixmap Id, you should release old pixmap manually
  * \remarks N/A
- * \param[in] handler Handler of a livebox instance
+ * \param[in] handler Handler of a livebox instance.
  * \param[in] cb Result callback for acquiring request
  * \param[in] data Callback Data
  * \return int
@@ -1438,7 +1438,7 @@ extern int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void
  * \brief Release the acquired pixmap ID
  * \details N/A
  * \remarks N/A
- * \param[in] handler Handler of a livebox instance
+ * \param[in] handler Handler of a livebox instance, This can be NULL, only if the handler is deleted.
  * \param[in] pixmap Pixmap Id to release it
  * \return int
  * \retval LB_STATUS_ERROR_INVALID Invalid argument
@@ -1480,7 +1480,7 @@ extern int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void
  *   After the client gets new pixmap or no more need to keep current pixmap, use this to release it.
  *   If there is no user for given pixmap, the pixmap will be destroyed.
  * \remarks N/A
- * \param[in] handler Handler of a livebox instance
+ * \param[in] handler Handler of a livebox instance, This can be NULL, only if the handler is deleted.
  * \param[in] pixmap Pixmap Id of given livebox handler
  * \return int
  * \retval LB_STATUS_ERROR_INVALID Invalid argument
index caeecbc..45998f7 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-viewer
 Summary: Library for developing the application
-Version: 0.20.7
+Version: 0.20.8
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index 06d00e6..d2dbd36 100644 (file)
@@ -3265,28 +3265,53 @@ EAPI int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *d
 EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap)
 {
        struct packet *packet;
+       const char *pkgname;
+       const char *id;
 
-       if (!handler || pixmap == 0 /* || handler->state != CREATE */ ) {
+       if (pixmap == 0 /* || handler->state != CREATE */ ) {
                ErrPrint("Handler is invalid [%d]\n", pixmap);
                return LB_STATUS_ERROR_INVALID;
        }
 
-       if (!handler->common /* || handler->common->state != CREATE */) {
-               ErrPrint("Handler is invalid\n");
-               return LB_STATUS_ERROR_INVALID;
-       }
+       if (!handler) {
+               /*!
+                * \note
+                * Even though the handler is NULL, we should send the release request to the master.
+                * Because the pixmap resource can be released after the handler is destroyed.
+                * Pixmap resource is used by client. and it cannot be guaranteed to release pixmap.
+                * In some cases, the pixmap can be released after the handler is deleted.
+                *
+                * Its implementation is up to the viewer app.
+                * But we cannot force it to use only with valid handler.
+                */
+               DbgPrint("Using NULL handler\n");
+               pkgname = NULL;
+               id = NULL;
+               /*!
+                * \note
+                * Master will try to find the buffer handler using given pixmap. if the pkgname and id is not valid.
+                */
+       } else {
+               if (!handler->common /* || handler->common->state != CREATE */) {
+                       ErrPrint("Handler is invalid\n");
+                       return LB_STATUS_ERROR_INVALID;
+               }
 
-       if (!handler->common->id) {
-               ErrPrint("Invalid handle\n");
-               return LB_STATUS_ERROR_INVALID;
-       }
+               if (!handler->common->id) {
+                       ErrPrint("Invalid handle\n");
+                       return LB_STATUS_ERROR_INVALID;
+               }
 
-       if (handler->common->lb.type != _LB_TYPE_SCRIPT && handler->common->lb.type != _LB_TYPE_BUFFER) {
-               ErrPrint("Handler is not valid type\n");
-               return LB_STATUS_ERROR_INVALID;
+               if (handler->common->lb.type != _LB_TYPE_SCRIPT && handler->common->lb.type != _LB_TYPE_BUFFER) {
+                       ErrPrint("Handler is not valid type\n");
+                       return LB_STATUS_ERROR_INVALID;
+               }
+
+               pkgname = handler->common->pkgname;
+               id = handler->common->id;
        }
 
-       packet = packet_create_noack("lb_release_pixmap", "ssi", handler->common->pkgname, handler->common->id, pixmap);
+       packet = packet_create_noack("lb_release_pixmap", "ssi", pkgname, id, pixmap);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
                return LB_STATUS_ERROR_INVALID;
@@ -3399,28 +3424,53 @@ EAPI int livebox_lb_pixmap(const struct livebox *handler)
 EAPI int livebox_release_pd_pixmap(struct livebox *handler, int pixmap)
 {
        struct packet *packet;
+       const char *pkgname;
+       const char *id;
 
-       if (!handler || pixmap == 0 /* || handler->state != CREATE */) {
-               ErrPrint("Handler is invalid [%d]\n", pixmap);
+       if (pixmap == 0 /* || handler->state != CREATE */) {
+               ErrPrint("Pixmap is invalid [%d]\n", pixmap);
                return LB_STATUS_ERROR_INVALID;
        }
 
-       if (!handler->common /* || handler-common->state != CREATE */) {
-               ErrPrint("Handler is invalid\n");
-               return LB_STATUS_ERROR_INVALID;
-       }
+       if (!handler) {
+               /*!
+                * \note
+                * Even though the handler is NULL, we should send the release request to the master.
+                * Because the pixmap resource can be released after the handler is destroyed.
+                * Pixmap resource is used by client. and it cannot be guaranteed to release pixmap.
+                * In some cases, the pixmap can be released after the handler is deleted.
+                *
+                * Its implementation is up to the viewer app.
+                * But we cannot force it to use only with valid handler.
+                */
+               DbgPrint("Using NULL handler\n");
+               pkgname = NULL;
+               id = NULL;
+               /*!
+                * \note
+                * Master will try to find the buffer handler using given pixmap. if the pkgname and id is not valid.
+                */
+       } else {
+               if (!handler->common /* || handler-common->state != CREATE */) {
+                       ErrPrint("Handler is invalid\n");
+                       return LB_STATUS_ERROR_INVALID;
+               }
 
-       if (!handler->common->id) {
-               ErrPrint("Invalid handle\n");
-               return LB_STATUS_ERROR_INVALID;
-       }
+               if (!handler->common->id) {
+                       ErrPrint("Invalid handle\n");
+                       return LB_STATUS_ERROR_INVALID;
+               }
 
-       if (handler->common->pd.type != _PD_TYPE_SCRIPT && handler->common->pd.type != _PD_TYPE_BUFFER) {
-               ErrPrint("Handler is not valid type\n");
-               return LB_STATUS_ERROR_INVALID;
+               if (handler->common->pd.type != _PD_TYPE_SCRIPT && handler->common->pd.type != _PD_TYPE_BUFFER) {
+                       ErrPrint("Handler is not valid type\n");
+                       return LB_STATUS_ERROR_INVALID;
+               }
+
+               pkgname = handler->common->pkgname;
+               id = handler->common->id;
        }
 
-       packet = packet_create_noack("pd_release_pixmap", "ssi", handler->common->pkgname, handler->common->id, pixmap);
+       packet = packet_create_noack("pd_release_pixmap", "ssi", pkgname, id, pixmap);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
                return LB_STATUS_ERROR_FAULT;