Commit 655df54f authored by Nicolas Jager's avatar Nicolas Jager

text message : send message

- send the message to the contact during a conversation.

- add the message to the conversation.

Change-Id: Ia93d48feed1fa712f5757df8013fad90bd5853e8
parent 849221de
......@@ -93,4 +93,6 @@ RingClientUWP::Views::MessageTextPage::sendMessage()
if (!contact || txt->IsEmpty())
return;
RingD::instance->sendAccountTextMessage(txt);
}
......@@ -35,6 +35,7 @@ using namespace Windows::UI::Core;
using namespace RingClientUWP;
using namespace RingClientUWP::Utils;
using namespace RingClientUWP::ViewModel;
void
debugOutputWrapper(const std::string& str)
......@@ -63,6 +64,37 @@ RingClientUWP::RingD::reloadAccountList()
Configuration::UserPreferences::instance->load();
}
/* nb: send message during conversation not chat video message */
void RingClientUWP::RingD::sendAccountTextMessage(String^ message)
{
/* account id */
auto accountId = AccountsViewModel::instance->selectedAccount->accountID_;
std::wstring accountId2(accountId->Begin());
std::string accountId3(accountId2.begin(), accountId2.end());
/* recipient */
auto contact = ContactsViewModel::instance->selectedContact;
auto toRingId = contact->ringID_;
std::wstring toRingId2(toRingId->Begin());
std::string toRingId3(toRingId2.begin(), toRingId2.end());
/* payload(s) */
std::wstring message2(message->Begin());
std::string message3(message2.begin(), message2.end());
std::map<std::string, std::string> payloads;
payloads["text/plain"] = message3;
/* daemon */
auto sent = DRing::sendAccountTextMessage(accountId3, toRingId3, payloads);
/* conversation */
if (sent) {
contact->_conversation->addMessage(""/* date not yet used*/, MSG_FROM_ME, message);
} else {
WNG_("message not sent, see daemon outputs");
}
}
void
RingClientUWP::RingD::startDaemon()
{
......@@ -131,7 +163,7 @@ RingClientUWP::RingD::startDaemon()
DRing::exportable_callback<DRing::ConfigurationSignal::AccountsChanged>([this]()
{
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
ref new DispatchedHandler([=]() {
ref new DispatchedHandler([=]() {
reloadAccountList();
}));
})
......@@ -171,7 +203,7 @@ RingClientUWP::RingD::startDaemon()
}
else {
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
ref new DispatchedHandler([=]() {
ref new DispatchedHandler([=]() {
reloadAccountList();
}));
}
......
......@@ -55,6 +55,7 @@ internal:
/* functions */
void startDaemon();
void reloadAccountList();
void sendAccountTextMessage(String^ message);
/* TODO : move members */
bool hasConfig;
......
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