extend TextAttachment to allow setting text body.

PiperOrigin-RevId: 609547008
This commit is contained in:
Francis Tsui
2024-02-22 17:04:26 -08:00
committed by Copybara-Service
parent d15f533721
commit 2282fcb503
3 changed files with 13 additions and 4 deletions
+10
View File
@@ -137,6 +137,16 @@ TextAttachment::TextAttachment(int64_t id, Type type, std::string text_title,
type_(type),
text_title_(std::move(text_title)) {}
TextAttachment::TextAttachment(int64_t id, Type type, std::string text_body,
std::string text_title, int64_t size,
std::string mime_type, int32_t batch_id,
SourceType source_type)
: Attachment(id, Attachment::Family::kText, size, batch_id, source_type),
type_(type),
text_title_(std::move(text_title)),
text_body_(std::move(text_body)),
mime_type_(std::move(mime_type)) {}
void TextAttachment::MoveToShareTarget(ShareTarget& share_target) {
share_target.text_attachments.push_back(std::move(*this));
}
+3 -2
View File
@@ -42,6 +42,9 @@ class TextAttachment : public Attachment {
TextAttachment(int64_t id, Type type, std::string text_title, int64_t size,
int32_t batch_id = 0,
SourceType source_type = SourceType::kUnknown);
TextAttachment(int64_t id, Type type, std::string text_body,
std::string text_title, int64_t size, std::string mime_type,
int32_t batch_id, SourceType source_type);
TextAttachment(const TextAttachment&) = default;
TextAttachment(TextAttachment&&) = default;
TextAttachment& operator=(const TextAttachment&) = default;
@@ -60,14 +63,12 @@ class TextAttachment : public Attachment {
void set_text_body(std::string text_body);
std::string mime_type() const { return mime_type_; }
SourceType source_type() const { return source_type_; }
private:
Type type_ = service::proto::TextMetadata::UNKNOWN;
std::string text_title_;
std::string text_body_;
std::string mime_type_;
SourceType source_type_ = SourceType::kUnknown;
};
} // namespace sharing
-2
View File
@@ -55,7 +55,6 @@ class WifiCredentialsAttachment : public Attachment {
SecurityType security_type() const { return security_type_; }
absl::string_view password() const { return password_; }
bool is_hidden() const { return is_hidden_; }
SourceType source_type() const { return source_type_; }
// Attachment:
void MoveToShareTarget(ShareTarget& share_target) override;
@@ -70,7 +69,6 @@ class WifiCredentialsAttachment : public Attachment {
SecurityType security_type_;
std::string password_;
bool is_hidden_;
SourceType source_type_;
};
} // namespace sharing