Commit ba89633e authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

More work related to ChatMessage file transfer

parent 0118f6ee
......@@ -84,6 +84,9 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
content/content-manager.h
content/content-type.h
content/content.h
content/content-p.h
content/file-content.h
content/file-transfer-content.h
core/core-accessor.h
core/core-p.h
core/core.h
......@@ -184,6 +187,8 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
content/content-manager.cpp
content/content-type.cpp
content/content.cpp
content/file-content.cpp
content/file-transfer-content.cpp
core/core-accessor.cpp
core/core-chat-room.cpp
core/core.cpp
......
......@@ -252,12 +252,8 @@ const LinphoneErrorInfo *linphone_chat_message_get_error_info(const LinphoneChat
// Methods
// =============================================================================
int linphone_chat_room_upload_file(LinphoneChatMessage *msg) {
return ((LinphoneStatus)L_GET_CPP_PTR_FROM_C_OBJECT(msg)->uploadFile());
}
LinphoneStatus linphone_chat_message_download_file(LinphoneChatMessage *msg) {
return ((LinphoneStatus)L_GET_CPP_PTR_FROM_C_OBJECT(msg)->downloadFile());
return ((LinphoneStatus)L_GET_PRIVATE_FROM_C_OBJECT(msg)->downloadFile());
}
void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
......
......@@ -25,6 +25,8 @@
#include "chat/chat-message/chat-message.h"
#include "chat/notification/imdn.h"
#include "content/content.h"
#include "content/file-content.h"
#include "content/file-transfer-content.h"
#include "content/content-type.h"
#include "object/object-p.h"
#include "sal/sal.h"
......@@ -92,6 +94,8 @@ public:
LinphoneContent *getFileTransferInformation() const;
void setFileTransferInformation(const LinphoneContent *content);
int downloadFile ();
// -----------------------------------------------------------------------------
// Need to be public to be called from static C callbacks
......@@ -138,7 +142,7 @@ private:
bool isReadOnly = false;
std::list<Content > contents;
Content internalContent;
Content *currentFileTransferContent;
FileContent *currentFileContentToTransfer;
std::unordered_map<std::string, std::string> customHeaders;
mutable LinphoneErrorInfo * errorInfo = nullptr;
belle_http_request_t *httpRequest = nullptr;
......@@ -153,7 +157,8 @@ private:
std::string cText;
// -----------------------------------------------------------------------------
int uploadFile ();
std::string createImdnXml(Imdn::Type imdnType, LinphoneReason reason);
void fileUploadEndBackgroundTask();
......@@ -165,7 +170,7 @@ private:
belle_http_request_listener_callbacks_t *cbs
);
void releaseHttpRequest();
void createFileTransferInformationsFromVndGsmaRcsFtHttpXml(const std::string &body);
void createFileTransferInformationsFromVndGsmaRcsFtHttpXml(FileTransferContent &content);
L_DECLARE_PUBLIC(ChatMessage);
};
......
This diff is collapsed.
......@@ -35,6 +35,7 @@ LINPHONE_BEGIN_NAMESPACE
class Address;
class ChatRoom;
class Content;
class FileTransferContent;
class ChatMessagePrivate;
class LINPHONE_PUBLIC ChatMessage : public Object, public CoreAccessor {
......@@ -61,8 +62,6 @@ public:
void setAppdata (const std::string &appData);
const std::string &getExternalBodyUrl () const;
void setExternalBodyUrl (const std::string &url);
int uploadFile ();
int downloadFile ();
void cancelFileTransfer ();
int putCharacter (uint32_t character);
void updateState (State state);
......@@ -115,6 +114,8 @@ public:
void addCustomHeader (const std::string &headerName, const std::string &headerValue);
void removeCustomHeader (const std::string &headerName);
int downloadFile (FileTransferContent& content);
private:
L_DECLARE_PRIVATE(ChatMessage);
L_DISABLE_COPY(ChatMessage);
......
/*
* content-p.h
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _CONTENT_P_H_
#define _CONTENT_P_H_
#include <vector>
#include "object/clonable-object-p.h"
#include "object/object-p.h"
#include "content-type.h"
#include "content.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class ContentPrivate : public ClonableObjectPrivate {
public:
std::vector<char> body;
ContentType contentType;
std::string contentDisposition;
};
LINPHONE_END_NAMESPACE
#endif // ifndef _CONTENT_P_H_
......@@ -18,8 +18,8 @@
*/
#include "content-type.h"
#include "object/clonable-object-p.h"
#include "content-p.h"
#include "content.h"
#include "linphone/core.h"
......@@ -29,14 +29,6 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
class ContentPrivate : public ClonableObjectPrivate {
public:
vector<char> body;
ContentType contentType;
string contentDisposition;
size_t expectedSize;
};
const Content Content::Empty;
// -----------------------------------------------------------------------------
......@@ -48,7 +40,6 @@ Content::Content (const Content &src) : ClonableObject(*new ContentPrivate), App
d->body = src.getBody();
d->contentType = src.getContentType();
d->contentDisposition = src.getContentDisposition();
d->expectedSize = src.getExpectedSize();
}
Content::Content (Content &&src) : ClonableObject(*new ContentPrivate), AppDataContainer(move(src)) {
......@@ -56,7 +47,10 @@ Content::Content (Content &&src) : ClonableObject(*new ContentPrivate), AppDataC
d->body = move(src.getPrivate()->body);
d->contentType = move(src.getPrivate()->contentType);
d->contentDisposition = move(src.getPrivate()->contentDisposition);
d->expectedSize = move(src.getExpectedSize());
}
Content::Content (ContentPrivate &p) : ClonableObject(p) {
}
Content &Content::operator= (const Content &src) {
......@@ -65,7 +59,6 @@ Content &Content::operator= (const Content &src) {
d->body = src.getBody();
d->contentType = src.getContentType();
d->contentDisposition = src.getContentDisposition();
d->expectedSize = src.getExpectedSize();
AppDataContainer::operator=(src);
}
......@@ -77,7 +70,6 @@ Content &Content::operator= (Content &&src) {
d->body = move(src.getPrivate()->body);
d->contentType = move(src.getPrivate()->contentType);
d->contentDisposition = move(src.getPrivate()->contentDisposition);
d->expectedSize = move(src.getExpectedSize());
AppDataContainer::operator=(move(src));
return *this;
}
......@@ -150,16 +142,6 @@ size_t Content::getSize () const {
return d->body.size();
}
void Content::setExpectedSize(size_t expectedSize) {
L_D();
d->expectedSize = expectedSize;
}
size_t Content::getExpectedSize() const {
L_D();
return d->expectedSize;
}
bool Content::isEmpty () const {
return getSize() == 0;
}
......@@ -174,8 +156,6 @@ LinphoneContent * Content::toLinphoneContent() const {
content = linphone_core_create_content(NULL);
linphone_content_set_type(content, getContentType().getType().c_str());
linphone_content_set_subtype(content, getContentType().getSubType().c_str());
linphone_content_set_size(content, getExpectedSize());
linphone_content_set_name(content, getContentDisposition().c_str());
return content;
}
......
......@@ -60,17 +60,17 @@ public:
size_t getSize () const;
void setExpectedSize(size_t expectedSize);
size_t getExpectedSize() const;
bool isValid() const;
bool isEmpty () const;
LinphoneContent * toLinphoneContent() const;
virtual LinphoneContent * toLinphoneContent() const;
static const Content Empty;
protected:
explicit Content (ContentPrivate &p);
private:
L_DECLARE_PRIVATE(Content);
};
......
/*
* file-content.cpp
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "content-p.h"
#include "file-content.h"
#include "linphone/core.h"
// =============================================================================
using namespace std;
LINPHONE_BEGIN_NAMESPACE
class FileContentPrivate : public ContentPrivate {
public:
string fileName;
string filePath;
size_t fileSize;
};
// -----------------------------------------------------------------------------
FileContent::FileContent() : Content(*new FileContentPrivate()) {
}
FileContent::FileContent (const FileContent &src) : Content(*new FileContentPrivate) {
L_D();
d->fileName = src.getFileName();
d->filePath = src.getFilePath();
d->fileSize = src.getFileSize();
}
FileContent::FileContent (FileContent &&src) : Content(*new FileContentPrivate) {
L_D();
d->fileName = move(src.getPrivate()->fileName);
d->filePath = move(src.getPrivate()->filePath);
d->fileSize = move(src.getPrivate()->fileSize);
}
FileContent &FileContent::operator= (const FileContent &src) {
L_D();
if (this != &src) {
Content::operator=(src);
d->fileName = src.getFileName();
d->filePath = src.getFilePath();
d->fileSize = src.getFileSize();
}
return *this;
}
FileContent &FileContent::operator= (FileContent &&src) {
L_D();
Content::operator=(move(src));
d->fileName = move(src.getPrivate()->fileName);
d->filePath = move(src.getPrivate()->filePath);
d->fileSize = move(src.getPrivate()->fileSize);
return *this;
}
bool FileContent::operator== (const FileContent &content) const {
L_D();
return Content::operator==(content) &&
d->fileName == content.getFileName() &&
d->filePath == content.getFilePath() &&
d->fileSize == content.getFileSize();
}
void FileContent::setFileSize(size_t size) {
L_D();
d->fileSize = size;
}
size_t FileContent::getFileSize() const {
L_D();
return d->fileSize;
}
void FileContent::setFileName(const string &name) {
L_D();
d->fileName = name;
}
string FileContent::getFileName() const {
L_D();
return d->fileName;
}
void FileContent::setFilePath(const string &path) {
L_D();
d->filePath = path;
}
string FileContent::getFilePath() const {
L_D();
return d->filePath;
}
LinphoneContent * FileContent::toLinphoneContent() const {
LinphoneContent* content;
content = linphone_core_create_content(NULL);
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;
}
LINPHONE_END_NAMESPACE
/*
* file-content.h
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _FILE_CONTENT_H_
#define _FILE_CONTENT_H_
#include "content.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class FileContentPrivate;
class LINPHONE_PUBLIC FileContent : public Content {
public:
FileContent();
FileContent (const FileContent &src);
FileContent (FileContent &&src);
FileContent &operator= (const FileContent &src);
FileContent &operator= (FileContent &&src);
bool operator== (const FileContent &content) const;
void setFileSize(size_t size);
size_t getFileSize() const;
void setFileName(const std::string &name);
std::string getFileName() const;
void setFilePath(const std::string &path);
std::string getFilePath() const;
LinphoneContent * toLinphoneContent() const override;
private:
L_DECLARE_PRIVATE(FileContent);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _FILE_CONTENT_H_
/*
* file-transfer-content.cpp
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "content-p.h"
#include "file-transfer-content.h"
#include "linphone/core.h"
// =============================================================================
using namespace std;
LINPHONE_BEGIN_NAMESPACE
class FileTransferContentPrivate : public ContentPrivate {
public:
string fileUrl;
string filePath;
FileContent fileContent;
};
// -----------------------------------------------------------------------------
FileTransferContent::FileTransferContent() : Content(*new FileTransferContentPrivate()) {
}
FileTransferContent::FileTransferContent (const FileTransferContent &src) : Content(*new FileTransferContentPrivate) {
L_D();
d->fileUrl = src.getFileUrl();
d->filePath = src.getFilePath();
d->fileContent = src.getFileContent();
}
FileTransferContent::FileTransferContent (FileTransferContent &&src) : Content(*new FileTransferContentPrivate) {
L_D();
d->fileUrl = move(src.getPrivate()->fileUrl);
d->filePath = move(src.getPrivate()->filePath);
d->fileContent = move(src.getPrivate()->fileContent);
}
FileTransferContent &FileTransferContent::operator= (const FileTransferContent &src) {
L_D();
if (this != &src) {
Content::operator=(src);
d->fileUrl = src.getFileUrl();
d->filePath = src.getFilePath();
d->fileContent = src.getFileContent();
}
return *this;
}
FileTransferContent &FileTransferContent::operator= (FileTransferContent &&src) {
L_D();
Content::operator=(move(src));
d->fileUrl = move(src.getPrivate()->fileUrl);
d->filePath = move(src.getPrivate()->filePath);
d->fileContent = move(src.getPrivate()->fileContent);
return *this;
}
bool FileTransferContent::operator== (const FileTransferContent &content) const {
L_D();
return Content::operator==(content) &&
d->fileUrl == content.getFileUrl() &&
d->filePath == content.getFilePath();
}
void FileTransferContent::setFileUrl(const string &url) {
L_D();
d->fileUrl = url;
}
string FileTransferContent::getFileUrl() const {
L_D();
return d->fileUrl;
}
void FileTransferContent::setFilePath(const string &path) {
L_D();
d->filePath = path;
}
string FileTransferContent::getFilePath() const {
L_D();
return d->filePath;
}
void FileTransferContent::setFileContent(const FileContent &content) {
L_D();
d->fileContent = content;
}
FileContent FileTransferContent::getFileContent() const {
L_D();
return d->fileContent;
}
LinphoneContent * FileTransferContent::toLinphoneContent() const {
LinphoneContent* content;
content = linphone_core_create_content(NULL);
linphone_content_set_type(content, getContentType().getType().c_str());
linphone_content_set_subtype(content, getContentType().getSubType().c_str());
return content;
}
LINPHONE_END_NAMESPACE
/*
* file-transfer-content.h
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _FILE_TRANSFER_CONTENT_H_
#define _FILE_TRANSFER_CONTENT_H_
#include "content.h"
#include "file-content.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class FileTransferContentPrivate;
class LINPHONE_PUBLIC FileTransferContent : public Content {
public:
FileTransferContent();
FileTransferContent (const FileTransferContent &src);
FileTransferContent (FileTransferContent &&src);
FileTransferContent &operator= (const FileTransferContent &src);
FileTransferContent &operator= (FileTransferContent &&src);
bool operator== (const FileTransferContent &content) const;
void setFileUrl(const std::string &url);
std::string getFileUrl() const;
void setFilePath(const std::string &path);
std::string getFilePath() const;
void setFileContent(const FileContent &content);
FileContent getFileContent() const;
LinphoneContent * toLinphoneContent() const override;
private:
L_DECLARE_PRIVATE(FileTransferContent);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _FILE_TRANSFER_CONTENT_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment