mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-20 12:38:09 +00:00
Added size information to FileTransferContent
This commit is contained in:
parent
7a100ac971
commit
7811dfa376
3 changed files with 28 additions and 2 deletions
|
|
@ -517,10 +517,16 @@ static void fillFileTransferContentInformationsFromVndGsmaRcsFtHttpXml(FileTrans
|
|||
if (!xmlStrcmp(typeAttribute, (const xmlChar *)"file")) { /* this is the node we are looking for */
|
||||
cur = cur->xmlChildrenNode; /* now loop on the content of the file-info node */
|
||||
while (cur != nullptr) {
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"file-size")) {
|
||||
xmlChar *fileSizeString = xmlNodeListGetString(xmlMessageBody, cur->xmlChildrenNode, 1);
|
||||
size_t size = (size_t)strtol((const char *)fileSizeString, nullptr, 10);
|
||||
fileTransferContent->setFileSize(size);
|
||||
xmlFree(fileSizeString);
|
||||
}
|
||||
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"file-name")) {
|
||||
xmlChar *filename = xmlNodeListGetString(xmlMessageBody, cur->xmlChildrenNode, 1);
|
||||
fileTransferContent->setFileName((char *)filename);
|
||||
|
||||
xmlFree(filename);
|
||||
}
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"data")) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
string fileUrl;
|
||||
string filePath;
|
||||
FileContent *fileContent = nullptr;
|
||||
size_t fileSize = 0;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -49,6 +50,7 @@ FileTransferContent::FileTransferContent (const FileTransferContent &src) : Cont
|
|||
d->fileUrl = src.getFileUrl();
|
||||
d->filePath = src.getFilePath();
|
||||
d->fileContent = src.getFileContent();
|
||||
d->fileSize = src.getFileSize();
|
||||
}
|
||||
|
||||
FileTransferContent::FileTransferContent (FileTransferContent &&src) : Content(*new FileTransferContentPrivate) {
|
||||
|
|
@ -57,6 +59,7 @@ FileTransferContent::FileTransferContent (FileTransferContent &&src) : Content(*
|
|||
d->fileUrl = move(src.getPrivate()->fileUrl);
|
||||
d->filePath = move(src.getPrivate()->filePath);
|
||||
d->fileContent = move(src.getPrivate()->fileContent);
|
||||
d->fileSize = move(src.getPrivate()->fileSize);
|
||||
}
|
||||
|
||||
FileTransferContent &FileTransferContent::operator= (const FileTransferContent &src) {
|
||||
|
|
@ -67,6 +70,7 @@ FileTransferContent &FileTransferContent::operator= (const FileTransferContent &
|
|||
d->fileUrl = src.getFileUrl();
|
||||
d->filePath = src.getFilePath();
|
||||
d->fileContent = src.getFileContent();
|
||||
d->fileSize = src.getFileSize();
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
|
@ -79,6 +83,7 @@ FileTransferContent &FileTransferContent::operator= (FileTransferContent &&src)
|
|||
d->fileUrl = move(src.getPrivate()->fileUrl);
|
||||
d->filePath = move(src.getPrivate()->filePath);
|
||||
d->fileContent = move(src.getPrivate()->fileContent);
|
||||
d->fileSize = move(src.getPrivate()->fileSize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +92,8 @@ bool FileTransferContent::operator== (const FileTransferContent &content) const
|
|||
return Content::operator==(content) &&
|
||||
d->fileName == content.getFileName() &&
|
||||
d->fileUrl == content.getFileUrl() &&
|
||||
d->filePath == content.getFilePath();
|
||||
d->filePath == content.getFilePath() &&
|
||||
d->fileSize == content.getFileSize();
|
||||
}
|
||||
|
||||
void FileTransferContent::setFileName (const string &name) {
|
||||
|
|
@ -130,11 +136,22 @@ FileContent *FileTransferContent::getFileContent () const {
|
|||
return d->fileContent;
|
||||
}
|
||||
|
||||
void FileTransferContent::setFileSize (size_t size) {
|
||||
L_D();
|
||||
d->fileSize = size;
|
||||
}
|
||||
|
||||
size_t FileTransferContent::getFileSize () const {
|
||||
L_D();
|
||||
return d->fileSize;
|
||||
}
|
||||
|
||||
LinphoneContent *FileTransferContent::toLinphoneContent () const {
|
||||
LinphoneContent *content = linphone_core_create_content(nullptr);
|
||||
linphone_content_set_type(content, getContentType().getType().c_str());
|
||||
linphone_content_set_subtype(content, getContentType().getSubType().c_str());
|
||||
linphone_content_set_name(content, getFileName().c_str());
|
||||
linphone_content_set_size(content, getFileSize());
|
||||
return content;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@ public:
|
|||
void setFileContent (FileContent *content);
|
||||
FileContent *getFileContent () const;
|
||||
|
||||
void setFileSize (size_t size);
|
||||
size_t getFileSize () const;
|
||||
|
||||
// TODO: Remove me later.
|
||||
LinphoneContent *toLinphoneContent () const override;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue