1. Support multiple IDS strings.
authorKyuho Jo <kyuho.jo@samsung.com>
Mon, 18 May 2015 13:21:28 +0000 (22:21 +0900)
committerKyuho Jo <kyuho.jo@samsung.com>
Tue, 19 May 2015 04:54:25 +0000 (13:54 +0900)
2. Fix bugs on setting.

Change-Id: If7fea48aff3fc3a171fdb7c634392667d74ff9f6
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
include/notification.h
include/notification_type.h
packaging/notification.spec
src/notification.c
src/notification_setting.c
test-app/main.c

index db5897a..8e1744d 100644 (file)
@@ -1319,7 +1319,7 @@ int notification_delete_all(notification_type_e type);
 int notification_post(notification_h noti);
 
 /**
- * @brief Sets permissions to application for updating or deletin the notification
+ * @brief Sets permission to application for updating or deleting the notification
  * @since_tizen 2.4
  * @privlevel public
  * @privilege %http://tizen.org/privilege/notification
@@ -1327,7 +1327,6 @@ int notification_post(notification_h noti);
  * @param[in] permission_type permission type
  * @param[in] app_id target application id
  * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
- * @retval #NOTIFICATION_ERROR_NONE Success
  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
  * @see #notification_get_permission
@@ -1349,16 +1348,17 @@ int notification_post(notification_h noti);
 
        noti_err = notification_set_permission(noti, NOTIFICATION_PERMISSION_TYPE_DELETE, "org.tizen.xxx");
        if(noti_err != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
                return;
        }
 }
  * @endcode
  */
-int notification_set_permission(notification_h handle, notification_permission_type_e permission_type, const char *app_id);
+int notification_set_permission(notification_h noti, notification_permission_type_e permission_type, const char *app_id);
 
 /**
- * @brief Gets permissions of the notification
- * @remarks app_id must not be freed. This will be free with notification_free.
+ * @brief Gets permission of the notification
+ * @remarks @a app_id must be freed with notification_free() function.
  * @since_tizen 2.4
  * @privlevel public
  * @privilege %http://tizen.org/privilege/notification
@@ -1366,7 +1366,6 @@ int notification_set_permission(notification_h handle, notification_permission_t
  * @param[out] permission_type permission type
  * @param[out] app_id target application id
  * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
- * @retval #NOTIFICATION_ERROR_NONE Success
  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
  * @see #notification_set_permission
@@ -1385,12 +1384,13 @@ int notification_set_permission(notification_h handle, notification_permission_t
 
        noti_err = notification_get_permission(noti, &permission_type, &app_id);
        if(noti_err != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
                return;
        }
 }
  * @endcode
  */
-int notification_get_permission(notification_h handle, notification_permission_type_e *permission_type, const char **app_id);
+int notification_get_permission(notification_h noti, notification_permission_type_e *permission_type, const char **app_id);
 
 /**
  * @brief Gets the package name of the notification
index 6e94002..55cf56d 100644 (file)
@@ -403,6 +403,10 @@ typedef struct _notification_op {
        notification_h noti;    /**< Notification handler */
 } notification_op;
 
+/**
+ * @brief Enumeration for permission.
+ * @since_tizen 2.4
+ */
 typedef enum notification_permission_type {
     NOTIFICATION_PERMISSION_TYPE_NONE = 0,
     NOTIFICATION_PERMISSION_TYPE_DELETE = 1,
index a021790..327579f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       notification
 Summary:    notification library
-Version:    0.2.32
+Version:    0.2.33
 Release:    1
 Group:      TBD
 License:    Apache
index 3b271d7..d08471a 100644 (file)
@@ -550,6 +550,7 @@ EXPORT_API int notification_get_text(notification_h noti,
        //int display_option_flag = 0;
 
        char *temp_str = NULL;
+       char *translated_str = NULL;
        char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
        char buf_str[1024] = { 0, };
        int num_args = 0;
@@ -707,10 +708,8 @@ EXPORT_API int notification_get_text(notification_h noti,
 
                                        strncat(result_str, buf_str,
                                                        max_len);
-
                                        num_args++;
                                }
-
                        }
 
                        /* Check variable IN pos */
@@ -780,9 +779,20 @@ EXPORT_API int notification_get_text(notification_h noti,
                                                ret_val =
                                                    bundle_get_val(b, buf_key);
 
-                                               snprintf(buf_str,
-                                                        sizeof(buf_str), "%s",
-                                                        ret_val);
+                                               if (ret_val != NULL && noti->domain != NULL     && noti->dir != NULL) {
+                                                       /* Get application string */
+                                                       bindtextdomain(noti->domain, noti->dir);
+                                                       translated_str = dgettext(noti->domain, ret_val);
+                                                       NOTIFICATION_INFO("translated_str[%s]", translated_str);
+                                               } else if (ret_val != NULL) {
+                                                       /* Get system string */
+                                                       translated_str = dgettext("sys_string", ret_val);
+                                                       NOTIFICATION_INFO("translated_str[%s]", translated_str);
+                                               } else {
+                                                       translated_str = NULL;
+                                               }
+
+                                               strncpy(buf_str, sizeof(buf_str), translated_str);
 
                                                int src_len = strlen(result_str);
                                                int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
@@ -986,6 +996,8 @@ EXPORT_API int notification_get_text(notification_h noti,
                *text = NULL;
        }
 
+       NOTIFICATION_INFO("text[%s]", *text);
+
        return NOTIFICATION_ERROR_NONE;
 }
 
@@ -2248,7 +2260,7 @@ static notification_h _notification_create(notification_type_e type)
        noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
        noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
        noti->led_operation = NOTIFICATION_LED_OP_OFF;
-       noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY;
+       noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
        /*!
         * \NOTE
         * Other fields are already initialized with ZERO.
index 6812a0b..10cea24 100644 (file)
@@ -694,7 +694,6 @@ out:
 EXPORT_API int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class)
 {
        int err = NOTIFICATION_ERROR_NONE;
-       char *query_buffer = NULL;
        int sqlret;
        int field_index = 0;
        sqlite3 *db = NULL;
@@ -708,15 +707,9 @@ EXPORT_API int notification_setting_db_update_system_setting(int do_not_disturb,
                goto return_close_db;
        }
 
-       query_buffer = strdup("UPDATE ? SET do_not_disturb = ?, visibility_class = ? ");
+       sqlite3_exec(db, "BEGIN immediate;", NULL, NULL, NULL);
 
-       if (query_buffer == NULL) {
-               NOTIFICATION_ERR("fail to alloc query");
-               err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
-               goto return_close_db;
-       }
-
-       sqlret = sqlite3_prepare_v2(db, query_buffer, strlen(query_buffer), &db_statement, NULL);
+       sqlret = sqlite3_prepare_v2(db, "UPDATE notification_system_setting SET do_not_disturb = ?, visibility_class = ?;", -1, &db_statement, NULL);
 
        if (sqlret != SQLITE_OK) {
                NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlret, sqlite3_errmsg(db));
@@ -724,7 +717,6 @@ EXPORT_API int notification_setting_db_update_system_setting(int do_not_disturb,
                goto return_close_db;
        }
 
-       sqlite3_bind_text(db_statement, field_index++, NOTIFICATION_SYSTEM_SETTING_DB_TABLE, -1, SQLITE_STATIC);
        sqlite3_bind_int(db_statement, field_index++, do_not_disturb);
        sqlite3_bind_int(db_statement, field_index++, visibility_class);
 
@@ -738,22 +730,24 @@ EXPORT_API int notification_setting_db_update_system_setting(int do_not_disturb,
 
        sqlret = sqlite3_changes(db);
 
-       if (sqlret != SQLITE_OK && sqlret != SQLITE_DONE) {
-               NOTIFICATION_ERR("sqlite3_changes failed [%d][%s]", sqlret, sqlite3_errmsg(db));
-               err =  NOTIFICATION_ERROR_FROM_DB;
-               goto return_close_db;
+       if (sqlret == 0) {
+               NOTIFICATION_WARN("No changes on DB");
        }
 
 return_close_db:
-
-       if (query_buffer)
-               free(query_buffer);
-
-       if (db_statement)
+       if (db_statement) {
                sqlite3_finalize(db_statement);
+       }
 
-       if (db)
+       if (db) {
+               if (err == NOTIFICATION_ERROR_NONE) {
+                       sqlite3_exec(db, "END;", NULL, NULL, NULL);
+               }
+               else {
+                       sqlite3_exec(db, "ROLLBACK;", NULL, NULL, NULL);
+               }
                sqlret = db_util_close(db);
+       }
 
        if (sqlret != SQLITE_OK) {
                NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret);
index cd51f12..4069e5e 100755 (executable)
@@ -150,6 +150,7 @@ void testapp_show_menu (testapp_menu_type_e menu)
                testapp_print (" 4.  Post status status message\n");
                testapp_print (" 5.  Delete all notification\n");
                testapp_print (" 6.  Post a heads notification with a button\n");
+               testapp_print (" 7.  Post a notification with domain text\n");
                testapp_print ("------------------------------------------\n");
                break;
        case TESTAPP_MENU_TYPE_SETTING_TEST_MENU:
@@ -189,6 +190,8 @@ static int testapp_add_a_notification()
        noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_3, "I'm Info 3", "INFO_3", NOTIFICATION_VARIABLE_TYPE_NONE);
        noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_SUB_3, "I'm Info Sub 3", "INFO_SUB_3", NOTIFICATION_VARIABLE_TYPE_NONE);
 
+       noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_INDICATOR | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER);
+
        noti_err  = notification_post(noti_handle);
 
        if (noti_err != NOTIFICATION_ERROR_NONE) {
@@ -256,9 +259,9 @@ static int testapp_test_post_notification_on_indicator()
        }
 
        noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
-       noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "CONTENT", NOTIFICATION_VARIABLE_TYPE_NONE);
+       noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "This is very loooooooooooooooooooooooooooooooooooooooooong message", NOTIFICATION_VARIABLE_TYPE_NONE);
 
-       noti_err  = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_INDICATOR);
+       noti_err  = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR);
 
        if(noti_err != NOTIFICATION_ERROR_NONE) {
                testapp_print("notification_set_display_applist failed[%d]", noti_err);
@@ -409,6 +412,69 @@ FINISH_OFF:
        return noti_err;
 }
 
+static int testapp_test_post_notification_with_domain_text()
+{
+       notification_h noti_handle = NULL;
+       int noti_err = NOTIFICATION_ERROR_NONE;
+       int app_control_err = APP_CONTROL_ERROR_NONE;
+       int priv_id = 0;
+       int group_id = 0;
+       char *app_id = NULL;
+       time_t result = time(NULL);
+       char tag[100] = { 0, };
+
+       noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
+
+       if (noti_handle == NULL) {
+               testapp_print("notification_create failed");
+               goto FINISH_OFF;
+       }
+
+       noti_err = notification_set_text_domain(noti_handle, "message", "/usr/apps/org.tizen.message/res/locale");
+
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               testapp_print("notification_set_display_applist failed[%d]\n", noti_err);
+               goto FINISH_OFF;
+       }
+
+       noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
+       noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "[%s] *** [%s]",
+                       NOTIFICATION_VARIABLE_TYPE_STRING, "IDS_MSGF_BODY_NO_SUBJECT",
+                       NOTIFICATION_VARIABLE_TYPE_STRING, "IDS_MSGF_POP_NEW_MESSAGE",
+                       NOTIFICATION_VARIABLE_TYPE_NONE);
+
+       noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
+
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               testapp_print("notification_set_display_applist failed[%d]\n", noti_err);
+               goto FINISH_OFF;
+       }
+
+       snprintf(tag, 100, "%d", result);
+
+       noti_err = notification_set_tag(noti_handle, tag);
+
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               testapp_print("notification_set_tag failed[%d]\n", noti_err);
+               goto FINISH_OFF;
+       }
+
+       noti_err = notification_post(noti_handle);
+
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               testapp_print("notification_post failed[%d]", noti_err);
+               goto FINISH_OFF;
+       }
+
+FINISH_OFF:
+
+
+       if (noti_handle)
+               notification_free(noti_handle);
+
+       return noti_err;
+}
+
 static gboolean testapp_interpret_command_basic_test (int selected_number)
 {
        gboolean go_to_loop = TRUE;
@@ -438,6 +504,10 @@ static gboolean testapp_interpret_command_basic_test (int selected_number)
                testapp_test_post_heads_up_notification_with_button();
                break;
 
+       case 7:
+               testapp_test_post_notification_with_domain_text();
+               break;
+
        case 0:
                go_to_loop = FALSE;
                break;
@@ -493,11 +563,9 @@ static int testapp_test_get_setting_list()
                testapp_print("[%d] : package_name[%s], allow_to_notify[%d], do_not_disturb_except[%d], visibility_class[%d]\n"
                                ,i, package_name, allow_to_notify, do_not_disturb_except, visibility_class);
                free(package_name);
-               notification_setting_free_notification(setting_array );
        }
 
-       if (setting_array)
-               free(setting_array);
+       notification_setting_free_notification(setting_array);
 
        return err;
 }