From 5c1c46a9c801643b19d83fde5525959c3e717b06 Mon Sep 17 00:00:00 2001 From: jiangbinghan Date: Thu, 6 Apr 2023 11:55:13 +0800 Subject: [PATCH 1/3] move session table from local to telephony Signed-off-by: jiangbinghan --- sms_mms/include/rdb_sms_mms_helper.h | 7 +++++++ sms_mms/include/sms_mms_ability.h | 2 +- sms_mms/include/sms_mms_data.h | 18 ++++++++++++++++++ sms_mms/src/rdb_sms_mms_helper.cpp | 21 +++++++++++++++++++++ sms_mms/src/sms_mms_ability.cpp | 16 +++++++++++++++- 5 files changed, 62 insertions(+), 2 deletions(-) diff --git a/sms_mms/include/rdb_sms_mms_helper.h b/sms_mms/include/rdb_sms_mms_helper.h index 5f186f46..0cb09686 100755 --- a/sms_mms/include/rdb_sms_mms_helper.h +++ b/sms_mms/include/rdb_sms_mms_helper.h @@ -124,6 +124,13 @@ private: */ void CreateMmsPartTableStr(std::string &createTableStr); + /** + * Create Session table + * + * @param createTableStr Create table statement + */ + void CreateSessionTableStr(std::string &createTableStr); + private: const std::string DB_NAME = "sms_mms.db"; std::string dbPath_ = FOLDER_PATH + DB_NAME; diff --git a/sms_mms/include/sms_mms_ability.h b/sms_mms/include/sms_mms_ability.h index 7d910fbd..313b64c0 100755 --- a/sms_mms/include/sms_mms_ability.h +++ b/sms_mms/include/sms_mms_ability.h @@ -36,7 +36,7 @@ class ValuesBucket; } namespace Telephony { enum class MessageUriType { - UNKNOW, SMS_MMS, THIRTY, MAX_GROUP, UNREAD_TOTAL, MMS_PROTOCOL, SMS_SUBSECTION, MMS_PART + UNKNOW, SMS_MMS, THIRTY, MAX_GROUP, UNREAD_TOTAL, MMS_PROTOCOL, SMS_SUBSECTION, MMS_PART, SESSION }; class SmsMmsAbility : public AppExecFwk::Ability { public: diff --git a/sms_mms/include/sms_mms_data.h b/sms_mms/include/sms_mms_data.h index bc857be8..0309497f 100755 --- a/sms_mms/include/sms_mms_data.h +++ b/sms_mms/include/sms_mms_data.h @@ -99,10 +99,28 @@ public: static constexpr const char *CONTENT = "content"; }; +class Session { +public: + static constexpr const char *ID = "id"; + static constexpr const char *TIME = "time"; + static constexpr const char *TELEPHONE = "telephone"; + static constexpr const char *CONTENT = "content"; + static constexpr const char *CONTACTS_NUM = "contacts_num"; + static constexpr const char *SMS_TYPE = "sys_type"; + static constexpr const char *UNREAD_COUNT = "unread_count"; + static constexpr const char *SENDING_STATUS = "sending_status"; + static constexpr const char *HAS_DRAFT = "has_draft"; + static constexpr const char *HAS_LOCK = "has_lock"; + static constexpr const char *MESSAGE_COUNT = "message_count"; + static constexpr const char *HAS_MMS = "has_mms"; + static constexpr const char *HAS_ATTACHMENT = "has_attachment"; +}; + constexpr const char *TABLE_SMS_MMS_INFO = "sms_mms_info"; constexpr const char *TABLE_SMS_SUBSECTION = "sms_subsection"; constexpr const char *TABLE_MMS_PROTOCOL = "mms_protocol"; constexpr const char *TABLE_MMS_PART = "mms_part"; +constexpr const char *TABLE_SESSION = "session"; constexpr const char *SMS_MMS_URI = "dataability:///com.ohos.smsmmsability"; } // namespace Telephony } // namespace OHOS diff --git a/sms_mms/src/rdb_sms_mms_helper.cpp b/sms_mms/src/rdb_sms_mms_helper.cpp index efbbe4c9..4237b51e 100755 --- a/sms_mms/src/rdb_sms_mms_helper.cpp +++ b/sms_mms/src/rdb_sms_mms_helper.cpp @@ -44,11 +44,14 @@ int RdbSmsMmsHelper::Init() CreateSmsSubsectionTableStr(smsSubsectionStr); std::string mmsPartStr; CreateMmsPartTableStr(mmsPartStr); + std::string sessionStr; + CreateSessionTableStr(sessionStr); std::vector createTableVec; createTableVec.push_back(messageInfoStr); createTableVec.push_back(mmsProtocolStr); createTableVec.push_back(smsSubsectionStr); createTableVec.push_back(mmsPartStr); + createTableVec.push_back(sessionStr); RdbSmsMmsCallback callback(createTableVec); CreateRdbStore(config, VERSION, callback, errCode); return errCode; @@ -148,6 +151,24 @@ void RdbSmsMmsHelper::CreateMmsPartTableStr(std::string &createTableStr) createTableStr.append(") on delete cascade on update cascade )"); } +void RdbSmsMmsHelper::CreateSessionTableStr(std::string &createTableStr) +{ + createTableStr.append("CREATE TABLE IF NOT EXISTS ").append(TABLE_SESSION); + createTableStr.append("(").append(Session::ID).append(" INTEGER PRIMARY KEY AUTOINCREMENT, "); + createTableStr.append(Session::TIME).append(" INTEGER DEFAULT 0, "); + createTableStr.append(Session::TELEPHONE).append(" TEXT , "); + createTableStr.append(Session::CONTENT).append(" TEXT , "); + createTableStr.append(Session::CONTACTS_NUM).append(" INTEGER DEFAULT 0 , "); + createTableStr.append(Session::SMS_TYPE).append(" INTEGER DEFAULT 0 , "); + createTableStr.append(Session::UNREAD_COUNT).append(" INTEGER DEFAULT 0 , "); + createTableStr.append(Session::SENDING_STATUS).append(" INTEGER DEFAULT 0 , "); + createTableStr.append(Session::HAS_DRAFT).append(" INTEGER DEFAULT 0 , "); + createTableStr.append(Session::HAS_LOCK).append(" INTEGER DEFAULT 0 , "); + createTableStr.append(Session::MESSAGE_COUNT).append(" INTEGER DEFAULT 0 , "); + createTableStr.append(Session::HAS_MMS).append(" INTEGER DEFAULT 0 , "); + createTableStr.append(Session::HAS_ATTACHMENT).append(" INTEGER DEFAULT 0 )"); +} + void RdbSmsMmsHelper::UpdateDbPath(const std::string &path) { dbPath_ = path + DB_NAME; diff --git a/sms_mms/src/sms_mms_ability.cpp b/sms_mms/src/sms_mms_ability.cpp index e8235236..a0011034 100755 --- a/sms_mms/src/sms_mms_ability.cpp +++ b/sms_mms/src/sms_mms_ability.cpp @@ -89,6 +89,9 @@ int SmsMmsAbility::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) helper_.Insert(id, value, TABLE_MMS_PART); break; } + case MessageUriType::SESSION: { + helper_.Insert(id, values, TABLE_SESSION); + break; default: DATA_STORAGE_LOGI("SmsMmsAbility::Insert##uri = %{public}s\n", uri.ToString().c_str()); break; @@ -123,6 +126,9 @@ std::shared_ptr SmsMmsAbility::Query( absRdbPredicates = new NativeRdb::AbsRdbPredicates(TABLE_MMS_PART); break; } + case MessageUriType::SESSION: { + absRdbPredicates = new NativeRdb::AbsRdbPredicates(TABLE_SESSION); + break; case MessageUriType::MAX_GROUP: { resultSet = helper_.QueryMaxGroupId(); break; @@ -174,6 +180,9 @@ int SmsMmsAbility::Update( absRdbPredicates = new NativeRdb::AbsRdbPredicates(TABLE_MMS_PART); break; } + case MessageUriType::SESSION: { + absRdbPredicates = new NativeRdb::AbsRdbPredicates(TABLE_SESSION); + break; default: DATA_STORAGE_LOGI("SmsMmsAbility::Update##uri = %{public}s\n", uri.ToString().c_str()); break; @@ -225,6 +234,10 @@ int SmsMmsAbility::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates absRdbPredicates = new NativeRdb::AbsRdbPredicates(TABLE_MMS_PART); break; } + case MessageUriType::SESSION: { + absRdbPredicates = new NativeRdb::AbsRdbPredicates(TABLE_SESSION); + break; + } default: DATA_STORAGE_LOGI("SmsMmsAbility::Delete##uri = %{public}s\n", uri.ToString().c_str()); break; @@ -260,7 +273,8 @@ void SmsMmsAbility::InitUriMap() {"/sms_mms/sms_mms_info/unread_total", MessageUriType::UNREAD_TOTAL}, {"/sms_mms/mms_protocol", MessageUriType::MMS_PROTOCOL}, {"/sms_mms/sms_subsection", MessageUriType::SMS_SUBSECTION}, - {"/sms_mms/mms_part", MessageUriType::MMS_PART} + {"/sms_mms/mms_part", MessageUriType::MMS_PART}, + {"/sms_mms/session", MessageUriType::SESSION} }; } -- Gitee From 755912176cf1d0b4f3869ea85df10bdc37199e22 Mon Sep 17 00:00:00 2001 From: jiangbinghan Date: Thu, 6 Apr 2023 19:48:32 +0800 Subject: [PATCH 2/3] move session table from local to telephony Signed-off-by: jiangbinghan --- sms_mms/src/sms_mms_ability.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sms_mms/src/sms_mms_ability.cpp b/sms_mms/src/sms_mms_ability.cpp index a0011034..af3e2043 100755 --- a/sms_mms/src/sms_mms_ability.cpp +++ b/sms_mms/src/sms_mms_ability.cpp @@ -90,8 +90,9 @@ int SmsMmsAbility::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) break; } case MessageUriType::SESSION: { - helper_.Insert(id, values, TABLE_SESSION); + helper_.Insert(id, value, TABLE_SESSION); break; + } default: DATA_STORAGE_LOGI("SmsMmsAbility::Insert##uri = %{public}s\n", uri.ToString().c_str()); break; @@ -129,6 +130,7 @@ std::shared_ptr SmsMmsAbility::Query( case MessageUriType::SESSION: { absRdbPredicates = new NativeRdb::AbsRdbPredicates(TABLE_SESSION); break; + } case MessageUriType::MAX_GROUP: { resultSet = helper_.QueryMaxGroupId(); break; @@ -183,6 +185,7 @@ int SmsMmsAbility::Update( case MessageUriType::SESSION: { absRdbPredicates = new NativeRdb::AbsRdbPredicates(TABLE_SESSION); break; + } default: DATA_STORAGE_LOGI("SmsMmsAbility::Update##uri = %{public}s\n", uri.ToString().c_str()); break; -- Gitee From b29150da8bc53a87d789611b8770cd8df758e5f6 Mon Sep 17 00:00:00 2001 From: jiangbinghan Date: Thu, 6 Apr 2023 21:10:56 +0800 Subject: [PATCH 3/3] move session table from local to telephony Signed-off-by: jiangbinghan --- sms_mms/include/sms_mms_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms_mms/include/sms_mms_data.h b/sms_mms/include/sms_mms_data.h index 0309497f..d086a122 100755 --- a/sms_mms/include/sms_mms_data.h +++ b/sms_mms/include/sms_mms_data.h @@ -106,7 +106,7 @@ public: static constexpr const char *TELEPHONE = "telephone"; static constexpr const char *CONTENT = "content"; static constexpr const char *CONTACTS_NUM = "contacts_num"; - static constexpr const char *SMS_TYPE = "sys_type"; + static constexpr const char *SMS_TYPE = "sms_type"; static constexpr const char *UNREAD_COUNT = "unread_count"; static constexpr const char *SENDING_STATUS = "sending_status"; static constexpr const char *HAS_DRAFT = "has_draft"; -- Gitee