diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 899677ab1..f633fc847 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,6 +54,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES chat/modifier/chat-message-modifier.h chat/modifier/cpim-chat-message-modifier.h chat/modifier/encryption-chat-message-modifier.h + chat/modifier/file-transfer-chat-message-modifier.h chat/modifier/multipart-chat-message-modifier.h chat/notification/imdn.h chat/notification/is-composing-listener.h @@ -170,6 +171,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES chat/cpim/parser/cpim-parser.cpp chat/modifier/cpim-chat-message-modifier.cpp chat/modifier/encryption-chat-message-modifier.cpp + chat/modifier/file-transfer-chat-message-modifier.cpp chat/modifier/multipart-chat-message-modifier.cpp chat/notification/imdn.cpp chat/notification/is-composing.cpp diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index 6eeca943c..f5ed8b223 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -39,6 +39,7 @@ class ChatMessagePrivate : public ObjectPrivate { friend class CpimChatMessageModifier; friend class EncryptionChatMessageModifier; friend class MultipartChatMessageModifier; + friend class FileTransferChatMessageModifier; public: enum Step { diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 8b1d12e1d..0fb01f56e 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -30,6 +30,7 @@ #include "chat/chat-room/real-time-text-chat-room.h" #include "chat/modifier/cpim-chat-message-modifier.h" #include "chat/modifier/encryption-chat-message-modifier.h" +#include "chat/modifier/file-transfer-chat-message-modifier.h" #include "chat/modifier/multipart-chat-message-modifier.h" #include "content/file-content.h" #include "content/content.h" @@ -1256,6 +1257,17 @@ void ChatMessagePrivate::send () { if ((currentSendStep & ChatMessagePrivate::Step::FileUpload) == ChatMessagePrivate::Step::FileUpload) { lInfo() << "File upload step already done, skipping"; } else { + // TODO + /*FileTransferChatMessageModifier ftcmm; + ChatMessageModifier::Result result = ftcmm.encode(q->getSharedFromThis(), errorCode); + if (result == ChatMessageModifier::Result::Error) { + return; + } else if (result == ChatMessageModifier::Result::Suspended) { + setState(ChatMessage::State::InProgress); + return; + } + currentSendStep |= ChatMessagePrivate::Step::FileUpload;*/ + currentFileContentToTransfer = nullptr; // For each FileContent, upload it and create a FileTransferContent for (Content *content : contents) { diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.cpp b/src/chat/modifier/file-transfer-chat-message-modifier.cpp new file mode 100644 index 000000000..e193b376c --- /dev/null +++ b/src/chat/modifier/file-transfer-chat-message-modifier.cpp @@ -0,0 +1,46 @@ +/* + * file-transfer-chat-message-modifier.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 "address/address.h" +#include "chat/chat-message/chat-message-p.h" +#include "content/content-type.h" +#include "content/content.h" +#include "logger/logger.h" + +#include "file-transfer-chat-message-modifier.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +ChatMessageModifier::Result FileTransferMessageModifier::encode (const shared_ptr &message, int &errorCode) { + chatMessage = message; + + return ChatMessageModifier::Result::Done; +} + +ChatMessageModifier::Result FileTransferMessageModifier::decode (const shared_ptr &message, int &errorCode) { + chatMessage = message; + + return ChatMessageModifier::Result::Done; +} + +LINPHONE_END_NAMESPACE diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.h b/src/chat/modifier/file-transfer-chat-message-modifier.h new file mode 100644 index 000000000..a03ceba31 --- /dev/null +++ b/src/chat/modifier/file-transfer-chat-message-modifier.h @@ -0,0 +1,42 @@ +/* + * file-transfer-chat-message-modifier.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_CHAT_MESSAGE_MODIFIER_H_ +#define _FILE_TRANSFER_CHAT_MESSAGE_MODIFIER_H_ + +#include "chat-message-modifier.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class FileTransferMessageModifier : public ChatMessageModifier { +public: + FileTransferMessageModifier () = default; + + Result encode (const std::shared_ptr &message, int &errorCode) override; + Result decode (const std::shared_ptr &message, int &errorCode) override; + +private: + std::shared_ptr chatMessage; +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _FILE_TRANSFER_CHAT_MESSAGE_MODIFIER_H_