* @remarks However, if this function fails, the memory for a list is NOT allocated in this function.
*
* @param[in] handle The Message handle
- * @param[in] sourt_rule This indicates a sort type and sort order for querying messages
+ * @param[in] sort_rule This indicates a sort type and sort order for querying messages
* @param[out] msg_thread_view_list A pointer to an #msg_struct_list_s structure
*
* @return @c 0 on success,
/**
+ * @brief Gets the information of all peers to whom messages have been sent or received.
+ *
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/message.read
+ *
+ * @remarks The memory for a list will be allocated in this function.
+ * @remarks Applications need to call msg_release_thread_view_list() to free the memory.
+ * @remarks However, if this function fails, the memory for a list is NOT allocated in this function.
+ *
+ * @param[in] handle The Message handle
+ * @param[in] msg_list_conditions A pointer to a #msg_struct_t structure for getting conditions
+ * @param[out] msg_thread_view_list A pointer to an #msg_struct_list_s structure
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval MSG_SUCCESS Success in operation
+ * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
+ * @retval MSG_ERR_STORAGE_ERROR Storage error
+ * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
+ * @retval MSG_ERR_NOT_SUPPORTED Not supported
+ */
+
+int msg_get_thread_view_list2(msg_handle_t handle, const msg_struct_t msg_list_conditions, msg_struct_list_s *msg_thread_view_list);
+
+
+/**
* @briefs Gets the common information list of messages with the selected thread ID.
*
* @since_tizen 2.3
sortRule.sortType = MSG_SORT_BY_THREAD_DATE;
sortRule.bAscending = false;
- err = pHandle->getThreadViewList(&sortRule, msg_thread_view_list);
+ err = pHandle->getThreadViewList(&sortRule, NULL, msg_thread_view_list);
} else {
- err = pHandle->getThreadViewList((MSG_SORT_RULE_S *)pStruct->data, msg_thread_view_list);
+ err = pHandle->getThreadViewList((MSG_SORT_RULE_S *)pStruct->data, NULL, msg_thread_view_list);
}
} catch (MsgException& e) {
MSG_FATAL("%s", e.what());
}
+EXPORT_API int msg_get_thread_view_list2(msg_handle_t handle, const msg_struct_t msg_list_conditions, msg_struct_list_s *msg_thread_view_list)
+{
+ CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
+ msg_error_t err = MSG_SUCCESS;
+
+ if (handle == NULL || msg_thread_view_list == NULL)
+ return MSG_ERR_INVALID_PARAMETER;
+
+ MsgHandle* pHandle = (MsgHandle*)handle;
+ msg_struct_s *pCondition =(msg_struct_s *)msg_list_conditions;
+ if (pCondition)
+ MSG_TYPE_CHECK(pCondition->type, MSG_STRUCT_MSG_LIST_CONDITION);
+
+ MSG_LIST_CONDITION_S *pListCond = pCondition ? (MSG_LIST_CONDITION_S *)pCondition->data : NULL;
+
+ try {
+ MSG_SORT_RULE_S sortRule = {0};
+
+ sortRule.sortType = MSG_SORT_BY_THREAD_DATE;
+ sortRule.bAscending = false;
+
+ err = pHandle->getThreadViewList(&sortRule, pListCond, msg_thread_view_list);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return MSG_ERR_STORAGE_ERROR;
+ }
+
+ return err;
+}
+
+
EXPORT_API int msg_get_conversation_view_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_conv_view_list)
{
CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
}
+msg_error_t MsgStoGetThreadViewListWithCondition(const MSG_SORT_RULE_S *pSortRule, const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pThreadViewList)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+ if (!pListCond) {
+ err = MsgStoGetThreadViewList(pSortRule, pThreadViewList);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("MsgStoGetThreadViewList() Error!!");
+ }
+
+ return err;
+ }
+
+ MsgDbHandler *dbHandle = getDbHandle();
+ dbHandle->connectReadOnly();
+
+ pThreadViewList->nCount = 0;
+ pThreadViewList->msg_struct_info = NULL;
+
+ int rowCnt = 0, index = 0;
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+ char sqlQuerySubset[MAX_QUERY_LEN+1];
+ char conditionQuery[MAX_QUERY_LEN+1] = {0};
+
+ if (pListCond->bProtected == true) {
+ memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+ snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "PROTECTED = 1 AND ");
+ strncat(conditionQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(conditionQuery));
+ }
+
+ if (pListCond->folderId > MSG_ALLBOX_ID) {
+ memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+ snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "FOLDER_ID = %d ", pListCond->folderId);
+ strncat(conditionQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(conditionQuery));
+ } else {
+ memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+ snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "FOLDER_ID > %d AND FOLDER_ID < %d ", MSG_ALLBOX_ID, MSG_SPAMBOX_ID);
+ strncat(conditionQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(conditionQuery));
+ }
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(CONV_ID) FROM %s WHERE ", MSGFW_MESSAGE_TABLE_NAME);
+
+ strncat(sqlQuery, conditionQuery, MAX_QUERY_LEN-strlen(sqlQuery));
+
+ memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+ snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "ORDER BY DISPLAY_TIME DESC;");
+ strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
+
+
+ err = dbHandle->getTable(sqlQuery, &rowCnt, NULL);
+ if (err == MSG_ERR_DB_NORECORD) {
+ return MSG_SUCCESS;
+ } else if (err != MSG_SUCCESS) {
+ MSG_ERR("Fail to getTable(). [%d]", err);
+ dbHandle->freeTable();
+ return err;
+ }
+
+ msg_thread_id_t conv_ids[rowCnt];
+ for (int i = 1; i <= rowCnt; i++) {
+ conv_ids[i - 1] = dbHandle->getColumnToInt(i);
+ }
+
+ dbHandle->freeTable();
+
+ pThreadViewList->nCount = rowCnt;
+ MSG_DEBUG("pThreadViewList->nCount [%d]", pThreadViewList->nCount);
+
+ pThreadViewList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(msg_struct_t));
+ if (pThreadViewList->msg_struct_info == NULL) {
+ MSG_ERR("calloc failed");
+ return MSG_ERR_MEMORY_ERROR;
+ }
+
+ MSG_THREAD_VIEW_S *pTmp = NULL;
+ msg_struct_s *thread_t = NULL;
+
+ for (int i = 0; i < pThreadViewList->nCount; i++) {
+ thread_t = (msg_struct_s *)new msg_struct_s;
+ pThreadViewList->msg_struct_info[i] = (msg_struct_t)thread_t;
+ thread_t->type = MSG_STRUCT_THREAD_INFO;
+ thread_t->data = new MSG_THREAD_VIEW_S;
+
+ pTmp = (MSG_THREAD_VIEW_S *)thread_t->data;
+ memset(pTmp, 0x00, sizeof(MSG_THREAD_VIEW_S));
+
+ pTmp->threadId = conv_ids[i];
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, MAX_QUERY_LEN, "SELECT DISPLAY_NAME FROM %s WHERE CONV_ID = %d;",
+ MSGFW_CONVERSATION_TABLE_NAME, conv_ids[i]);
+
+ err = dbHandle->getTable(sqlQuery, &rowCnt, &index);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("Fail to getTable(). [%d]", err);
+ dbHandle->freeTable();
+ return err;
+ }
+
+ dbHandle->getColumnToString(index++, MAX_THREAD_NAME_LEN, pTmp->threadName);
+
+ dbHandle->freeTable();
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, MAX_QUERY_LEN, "SELECT "
+ "(COUNT(DISTINCT(CASE WHEN READ_STATUS = 0 THEN MSG_ID END))) AS UNREAD_CNT, "
+ "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS SMS_CNT, "
+ "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS MMS_CNT "
+ "FROM %s WHERE CONV_ID = %d AND ",
+ MSG_SMS_TYPE,
+ MSG_MMS_TYPE,
+ MSGFW_MESSAGE_TABLE_NAME, conv_ids[i]);
+
+ strncat(sqlQuery, conditionQuery, MAX_QUERY_LEN-strlen(sqlQuery));
+ snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), ";");
+ strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
+
+ err = dbHandle->getTable(sqlQuery, &rowCnt, &index);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("Fail to getTable(). [%d]", err);
+ dbHandle->freeTable();
+ return err;
+ }
+
+ pTmp->unreadCnt = dbHandle->getColumnToInt(index++);
+ pTmp->smsCnt = dbHandle->getColumnToInt(index++);
+ pTmp->mmsCnt = dbHandle->getColumnToInt(index++);
+
+ dbHandle->freeTable();
+
+ memset(sqlQuery, 0x00, MAX_QUERY_LEN);
+ snprintf(sqlQuery, sizeof(sqlQuery),
+ "SELECT MAIN_TYPE, SUB_TYPE, MSG_DIRECTION, DISPLAY_TIME, DPM_RESTRICTED, (CASE WHEN LENGTH(SUBJECT) > 0 THEN SUBJECT ELSE MSG_TEXT END) "
+ "FROM %s WHERE CONV_ID = %d AND ",
+ MSGFW_MESSAGE_TABLE_NAME, conv_ids[i]);
+
+ strncat(sqlQuery, conditionQuery, MAX_QUERY_LEN-strlen(sqlQuery));
+ snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "ORDER BY DISPLAY_TIME DESC LIMIT 1;");
+ strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
+
+ err = dbHandle->getTable(sqlQuery, &rowCnt, &index);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("Fail to getTable(). [%d]", err);
+ dbHandle->freeTable();
+ return err;
+ }
+
+ pTmp->mainType = (MSG_MAIN_TYPE_T)dbHandle->getColumnToInt(index++);
+ pTmp->subType = (MSG_SUB_TYPE_T)dbHandle->getColumnToInt(index++);
+ pTmp->direction = (msg_direction_type_t)dbHandle->getColumnToInt(index++);
+ pTmp->threadTime = (time_t)dbHandle->getColumnToInt(index++);
+ bool dpm_restricted = dbHandle->getColumnToInt(index++);
+ char tmpData[MAX_THREAD_DATA_LEN + 1] = {0};
+ if (!dpm_restricted) {
+ dbHandle->getColumnToString(index++, MAX_THREAD_DATA_LEN, tmpData);
+ } else {
+ snprintf(tmpData, sizeof(tmpData), "restricted message");
+ }
+
+ char *end = NULL;
+ if (g_utf8_validate(tmpData, -1, (const gchar **)&end) == true) {
+ g_utf8_strncpy(pTmp->threadData, tmpData, g_utf8_strlen(tmpData, -1));
+ } else {
+ g_utf8_strncpy(pTmp->threadData, tmpData, g_utf8_strlen(tmpData, end - tmpData));
+ }
+
+ dbHandle->freeTable();
+ }
+
+ return MSG_SUCCESS;
+}
+
+
msg_error_t MsgStoGetConversationPreview(MsgDbHandler *pDbHandle, MSG_CONVERSATION_VIEW_S *pConv)
{
char sqlQuery[MAX_QUERY_LEN + 1];