2. Fix bugs on setting.
Change-Id: If7fea48aff3fc3a171fdb7c634392667d74ff9f6
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
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
* @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
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
* @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
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
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,
Name: notification
Summary: notification library
-Version: 0.2.32
+Version: 0.2.33
Release: 1
Group: TBD
License: Apache
//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;
strncat(result_str, buf_str,
max_len);
-
num_args++;
}
-
}
/* Check variable IN pos */
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;
*text = NULL;
}
+ NOTIFICATION_INFO("text[%s]", *text);
+
return NOTIFICATION_ERROR_NONE;
}
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.
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;
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));
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);
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);
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:
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) {
}
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);
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;
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;
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;
}