Commit 9b1d7f1c authored by Ghislain MARY's avatar Ghislain MARY

New method for file upload.

parent eafec331
......@@ -164,6 +164,13 @@ namespace Linphone.Agents
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void FileTransferProgressIndication(LinphoneChatMessage message, int offset, int total)
{
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
......
......@@ -154,7 +154,9 @@ namespace Linphone
Idle = 0,
InProgress = 1,
Delivered = 2,
NotDelivered = 3
NotDelivered = 3,
FileTransferError = 4,
FileTransferDone = 5
};
public enum class DeclineReason : int
......
......@@ -49,6 +49,29 @@ Linphone::Core::LinphoneChatMessage^ Linphone::Core::LinphoneChatRoom::CreateLin
return chatMessage;
}
Linphone::Core::LinphoneChatMessage^ Linphone::Core::LinphoneChatRoom::CreateFileTransferMessage(Platform::String^ type, Platform::String^ subtype, Platform::String^ name, int size, Platform::String^ filepath)
{
TRACE; gApiLock.Lock();
const char *ctype = Linphone::Core::Utils::pstoccs(type);
const char *csubtype = Linphone::Core::Utils::pstoccs(subtype);
const char *cname = Linphone::Core::Utils::pstoccs(name);
const char *cfilepath = Linphone::Core::Utils::pstoccs(filepath);
LinphoneContent content;
memset(&content, 0, sizeof(content));
content.type = (char *)ctype;
content.subtype = (char *)csubtype;
content.size = size;
content.name = (char *)cname;
Linphone::Core::LinphoneChatMessage^ chatMessage = (Linphone::Core::LinphoneChatMessage^) Linphone::Core::Utils::CreateLinphoneChatMessage(
linphone_chat_room_create_file_transfer_message_from_file(this->room, &content, cfilepath));
delete(ctype);
delete(csubtype);
delete(cname);
delete(cfilepath);
gApiLock.Unlock();
return chatMessage;
}
Platform::Boolean Linphone::Core::LinphoneChatRoom::IsRemoteComposing()
{
TRACE; gApiLock.Lock();
......
......@@ -73,6 +73,17 @@ namespace Linphone
/// </summary>
void DeleteMessageFromHistory(Linphone::Core::LinphoneChatMessage^ message);
/// <summary>
/// Creates a LinphoneChatMessage to transfer a file.
/// </summary>
/// <param name="type">MIME type of the file to transfer</param>
/// <param name="subtype">MIME subtype of the file to transfer</param>
/// <param name="name">Name of the file to transfer</param>
/// <param name="size">Size in bytes of the file to transfer</param>
/// <param name="filepath">Path to the file to transfer</param>
/// <returns>A new LinphoneChatMessage</returns>
Linphone::Core::LinphoneChatMessage^ CreateFileTransferMessage(Platform::String^ type, Platform::String^ subtype, Platform::String^ name, int size, Platform::String^ filepath);
private:
friend class Linphone::Core::Utils;
friend ref class Linphone::Core::LinphoneCore;
......
......@@ -16,6 +16,7 @@
#include "ApiLock.h"
#include <collection.h>
using namespace Microsoft::WRL;
using namespace Platform;
using namespace Platform::Collections;
using namespace Windows::Foundation;
......@@ -1665,6 +1666,21 @@ void composing_received(LinphoneCore *lc, LinphoneChatRoom *room)
Linphone::Core::gApiLock.LeaveListener();
}
void file_transfer_progress_indication(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent *content, size_t offset, size_t total) {
Linphone::Core::gApiLock.EnterListener();
Linphone::Core::LinphoneCoreListener^ listener = Linphone::Core::Globals::Instance->LinphoneCore->CoreListener;
if (listener != nullptr)
{
Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneChatMessage^> *proxy = reinterpret_cast< Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneChatMessage^> *>(linphone_chat_message_get_user_data(message));
Linphone::Core::LinphoneChatMessage^ lMessage = (proxy) ? proxy->Ref() : nullptr;
if (lMessage == nullptr) {
lMessage = (Linphone::Core::LinphoneChatMessage^)Linphone::Core::Utils::CreateLinphoneChatMessage(message);
}
listener->FileTransferProgressIndication(lMessage, (int)offset, total);
}
Linphone::Core::gApiLock.LeaveListener();
}
void log_collection_upload_progress_indication(LinphoneCore *lc, size_t progress) {
Linphone::Core::gApiLock.EnterListener();
Linphone::Core::LinphoneCoreListener^ listener = Linphone::Core::Globals::Instance->LinphoneCore->CoreListener;
......@@ -1746,6 +1762,7 @@ void Linphone::Core::LinphoneCore::Init()
vtable->call_stats_updated = call_stats_updated;
vtable->message_received = message_received;
vtable->is_composing_received = composing_received;
vtable->file_transfer_progress_indication = file_transfer_progress_indication;
vtable->log_collection_upload_progress_indication = log_collection_upload_progress_indication;
vtable->log_collection_upload_state_changed = log_collection_upload_state_changed;
......
......@@ -84,6 +84,14 @@ namespace Linphone
/// <param name="room">The room for which the composing status has been updated</param>
void ComposingReceived(LinphoneChatRoom^ room);
/// <summary>
/// Callback method called to notify the progression of a file transfer.
/// </summary>
/// <param name="message">The chat message</param>
/// <param name="offset">The number of bytes sent/received since the beginning of the file transfer</param>
/// <param name="total">The total number of bytes to be sent/received</param>
void FileTransferProgressIndication(LinphoneChatMessage^ message, int offset, int total);
/// <summary>
/// Callback method called when the status of the current log upload changes.
/// </summary>
......
......@@ -32,4 +32,5 @@ display=0
[misc]
history_max_size=30
max_calls=1
file_transfer_server_url=https://www.linphone.org:444/lft.php
log_collection_upload_server_url=https://www.linphone.org:444/lft.php
......@@ -1039,6 +1039,14 @@ namespace Linphone.Model
});
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
public void FileTransferProgressIndication(LinphoneChatMessage message, int offset, int total)
{
Logger.Msg(String.Format("FileTransferProgressIndication: {0}/{1}", offset, total));
}
/// <summary>
/// Callback for LinphoneCoreListener
/// </summary>
......
......@@ -111,7 +111,7 @@ namespace Linphone.Model
/// <param name="image">The bitmap image to save</param>
/// <param name="fileName">The file's name to use</param>
/// <returns>true if the operation succeeds</returns>
public static bool SaveImageInLocalFolder(BitmapImage image, string fileName)
public static string SaveImageInLocalFolder(BitmapImage image, string fileName)
{
try
{
......@@ -129,12 +129,12 @@ namespace Linphone.Model
file.Flush();
file.Close();
bitmap = null;
return true;
return file.Name;
}
}
}
catch { }
return false;
return null;
}
}
}
This diff is collapsed.
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