apply content_retip_if_fail() for invalid parameters
[platform/core/api/media-content.git] / src / media_face.c
index 89bc029..b191ca3 100755 (executable)
@@ -26,7 +26,7 @@ static int __media_face_check_media_id(const char *media_id)
        sqlite3_stmt *stmt = NULL;
        int item_count = 0;
 
-       content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
+       content_retip_if_fail(STRING_VALID(media_id));
 
        /* Get image count */
        query_str = sqlite3_mprintf(SELECT_IMAGE_COUNT_FROM_MEDIA_BY_ID, media_id);
@@ -48,7 +48,7 @@ int media_face_destroy(media_face_h face)
 {
        media_face_s *_face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+       content_retip_if_fail(face);
 
        g_free(_face->media_id);
        g_free(_face->face_tag);
@@ -117,8 +117,11 @@ int media_face_get_face_rect(media_face_h face, unsigned int *rect_x, unsigned i
 {
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
-       content_retvm_if(!(rect_x && rect_y && rect_w && rect_h), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect");
+       content_retip_if_fail(face);
+       content_retip_if_fail(rect_x);
+       content_retip_if_fail(rect_y);
+       content_retip_if_fail(rect_w);
+       content_retip_if_fail(rect_h);
 
        *rect_x = _face->face_rect_x;
        *rect_y = _face->face_rect_y;
@@ -132,8 +135,8 @@ int media_face_get_orientation(media_face_h face, media_content_orientation_e *o
 {
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
-       content_retvm_if(orientation == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid orientation");
+       content_retip_if_fail(face);
+       content_retip_if_fail(orientation);
 
        *orientation = _face->orientation;
 
@@ -174,9 +177,9 @@ int media_face_set_face_rect(media_face_h face, unsigned int rect_x, unsigned in
 {
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
-       content_retvm_if(rect_w == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_w");
-       content_retvm_if(rect_h == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_h");
+       content_retip_if_fail(face);
+       content_retip_if_fail(rect_w > 0);
+       content_retip_if_fail(rect_h > 0);
 
        _face->face_rect_x = rect_x;
        _face->face_rect_y = rect_y;
@@ -190,7 +193,7 @@ int media_face_set_orientation(media_face_h face, media_content_orientation_e or
 {
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+       content_retip_if_fail(face);
 
        _face->orientation = orientation;
 
@@ -217,10 +220,10 @@ int media_face_insert_to_db(media_face_h face)
 
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
-       content_retvm_if(_face->media_id == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_id");
-       content_retvm_if(_face->face_rect_w == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_w");
-       content_retvm_if(_face->face_rect_h == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_h");
+       content_retip_if_fail(face);
+       content_retip_if_fail(_face->media_id);
+       content_retip_if_fail(_face->face_rect_w > 0);
+       content_retip_if_fail(_face->face_rect_h > 0);
 
        query_str = sqlite3_mprintf(INSERT_FACE_TO_FACE, _face->media_id, _face->face_rect_x, _face->face_rect_y, _face->face_rect_w, _face->face_rect_h, _face->orientation, _face->face_tag);
 
@@ -248,11 +251,11 @@ int media_face_update_to_db(media_face_h face)
 
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
-       content_retvm_if(_face->face_id == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid face_id");
-       content_retvm_if(_face->media_id == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_id");
-       content_retvm_if(_face->face_rect_w == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_w");
-       content_retvm_if(_face->face_rect_h == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_h");
+       content_retip_if_fail(face);
+       content_retip_if_fail(_face->media_id);
+       content_retip_if_fail(_face->face_id > 0);
+       content_retip_if_fail(_face->face_rect_w > 0);
+       content_retip_if_fail(_face->face_rect_h > 0);
 
        query_str = sqlite3_mprintf(UPDATE_FACE_TO_FACE, _face->face_rect_x, _face->face_rect_y, _face->face_rect_w, _face->face_rect_h, _face->orientation, _face->face_tag, _face->face_id);
 
@@ -266,7 +269,9 @@ static int __media_face_safe_atoi(const char *buffer, int *si)
 {
        char *end = NULL;
        errno = 0;
-       content_retvm_if(buffer == NULL || si == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid parameter");
+
+       content_retip_if_fail(buffer);
+       content_retip_if_fail(si);
 
        const long sl = strtol(buffer, &end, 10);
 
@@ -286,7 +291,6 @@ int media_face_delete_from_db(const char *face_id)
        int ret = MEDIA_CONTENT_ERROR_NONE;
        char *query_str = NULL;
        int query_face_id = 0;
-       content_retvm_if(!STRING_VALID(face_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid face_id");
 
        ret = __media_face_safe_atoi(face_id, &query_face_id);
        content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid face_id");
@@ -306,25 +310,14 @@ int media_face_delete_from_db(const char *face_id)
 
 int media_face_get_face_count_from_db(filter_h filter, int *face_count)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-
-       if (face_count == NULL) {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(face_count);
 
-       ret = _media_db_get_group_count(filter, MEDIA_GROUP_FACE, face_count);
-
-       return ret;
+       return _media_db_get_group_count(filter, MEDIA_GROUP_FACE, face_count);
 }
 
 int media_face_foreach_face_from_db(filter_h filter, media_face_cb callback, void *user_data)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-
-       content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid paramter");
+       content_retip_if_fail(callback);
 
-       ret = _media_db_get_face(NULL, filter, callback, user_data);
-
-       return ret;
+       return _media_db_get_face(NULL, filter, callback, user_data);
 }