Skip to content
Snippets Groups Projects
Commit a7a84201 authored by Io Daza-Dillon's avatar Io Daza-Dillon Committed by Adrien Béraud
Browse files

nodejs: add composing indicators

Change-Id: I3a1109e0acc64aed296abe19a198d71253cd4364
parent b16308ea
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ using namespace v8; ...@@ -12,6 +12,7 @@ using namespace v8;
Persistent<Function> accountsChangedCb; Persistent<Function> accountsChangedCb;
Persistent<Function> accountDetailsChangedCb; Persistent<Function> accountDetailsChangedCb;
Persistent<Function> registrationStateChangedCb; Persistent<Function> registrationStateChangedCb;
Persistent<Function> composingStatusChangedCb;
Persistent<Function> volatileDetailsChangedCb; Persistent<Function> volatileDetailsChangedCb;
Persistent<Function> incomingAccountMessageCb; Persistent<Function> incomingAccountMessageCb;
Persistent<Function> accountMessageStatusChangedCb; Persistent<Function> accountMessageStatusChangedCb;
...@@ -56,6 +57,8 @@ getPresistentCb(std::string_view signal) ...@@ -56,6 +57,8 @@ getPresistentCb(std::string_view signal)
return &accountDetailsChangedCb; return &accountDetailsChangedCb;
else if (signal == "RegistrationStateChanged") else if (signal == "RegistrationStateChanged")
return &registrationStateChangedCb; return &registrationStateChangedCb;
else if (signal == "ComposingStatusChanged")
return &composingStatusChangedCb;
else if (signal == "VolatileDetailsChanged") else if (signal == "VolatileDetailsChanged")
return &volatileDetailsChangedCb; return &volatileDetailsChangedCb;
else if (signal == "IncomingAccountMessage") else if (signal == "IncomingAccountMessage")
...@@ -226,6 +229,28 @@ registrationStateChanged(const std::string& accountId, ...@@ -226,6 +229,28 @@ registrationStateChanged(const std::string& accountId,
uv_async_send(&signalAsync); uv_async_send(&signalAsync);
} }
void
composingStatusChanged(const std::string& accountId,
const std::string& conversationId,
const std::string& from,
int state)
{
std::lock_guard<std::mutex> lock(pendingSignalsLock);
pendingSignals.emplace([accountId, conversationId, from, state]() {
Local<Function> func = Local<Function>::New(Isolate::GetCurrent(),
composingStatusChangedCb);
if (!func.IsEmpty()) {
SWIGV8_VALUE callback_args[] = {V8_STRING_NEW_LOCAL(accountId),
V8_STRING_NEW_LOCAL(conversationId),
V8_STRING_NEW_LOCAL(from),
SWIGV8_INTEGER_NEW(state)};
func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 4, callback_args);
}
});
uv_async_send(&signalAsync);
}
void void
volatileDetailsChanged(const std::string& accountId, volatileDetailsChanged(const std::string& accountId,
const std::map<std::string, std::string>& details) const std::map<std::string, std::string>& details)
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
virtual void incomingAccountMessage(const std::string& /*account_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payload*/){} virtual void incomingAccountMessage(const std::string& /*account_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payload*/){}
virtual void accountMessageStatusChanged(const std::string& /*account_id*/, const std::string& /*conversationId*/, const std::string& /*peer*/, const std::string& /*message_id*/, int /*state*/){} virtual void accountMessageStatusChanged(const std::string& /*account_id*/, const std::string& /*conversationId*/, const std::string& /*peer*/, const std::string& /*message_id*/, int /*state*/){}
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*path*/){} virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*path*/){}
virtual void composingStatusChanged(const std::string& /*account_id*/, const std::string& /*convId*/, const std::string& /*from*/, int /*state*/){}
virtual void knownDevicesChanged(const std::string& /*account_id*/, const std::map<std::string, std::string>& /*devices*/){} virtual void knownDevicesChanged(const std::string& /*account_id*/, const std::map<std::string, std::string>& /*devices*/){}
virtual void exportOnRingEnded(const std::string& /*account_id*/, int /*state*/, const std::string& /*pin*/){} virtual void exportOnRingEnded(const std::string& /*account_id*/, int /*state*/, const std::string& /*pin*/){}
...@@ -91,6 +92,7 @@ std::vector<Message> getLastMessages(const std::string& accountID, const uint64_ ...@@ -91,6 +92,7 @@ std::vector<Message> getLastMessages(const std::string& accountID, const uint64_
int getMessageStatus(uint64_t id); int getMessageStatus(uint64_t id);
int getMessageStatus(const std::string& accountID, uint64_t id); int getMessageStatus(const std::string& accountID, uint64_t id);
bool cancelMessage(const std::string& accountID, uint64_t id); bool cancelMessage(const std::string& accountID, uint64_t id);
void setIsComposing(const std::string& accountID, const std::string& conversationUri, bool isWriting);
bool setMessageDisplayed(const std::string& accountID, const std::string& conversationUri, const std::string& messageId, int status); bool setMessageDisplayed(const std::string& accountID, const std::string& conversationUri, const std::string& messageId, int status);
bool lookupName(const std::string& account, const std::string& nameserver, const std::string& name); bool lookupName(const std::string& account, const std::string& nameserver, const std::string& name);
bool lookupAddress(const std::string& account, const std::string& nameserver, const std::string& address); bool lookupAddress(const std::string& account, const std::string& nameserver, const std::string& address);
...@@ -231,6 +233,7 @@ public: ...@@ -231,6 +233,7 @@ public:
virtual void incomingAccountMessage(const std::string& /*account_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payload*/){} virtual void incomingAccountMessage(const std::string& /*account_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payload*/){}
virtual void accountMessageStatusChanged(const std::string& /*account_id*/, const std::string& /*conversationId*/, const std::string& /*peer*/, const std::string& /*message_id*/, int /*state*/){} virtual void accountMessageStatusChanged(const std::string& /*account_id*/, const std::string& /*conversationId*/, const std::string& /*peer*/, const std::string& /*message_id*/, int /*state*/){}
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*path*/){} virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*path*/){}
virtual void composingStatusChanged(const std::string& /*account_id*/, const std::string& /*convId*/, const std::string& /*from*/, int /*state*/){}
virtual void knownDevicesChanged(const std::string& /*account_id*/, const std::map<std::string, std::string>& /*devices*/){} virtual void knownDevicesChanged(const std::string& /*account_id*/, const std::map<std::string, std::string>& /*devices*/){}
virtual void exportOnRingEnded(const std::string& /*account_id*/, int /*state*/, const std::string& /*pin*/){} virtual void exportOnRingEnded(const std::string& /*account_id*/, int /*state*/, const std::string& /*pin*/){}
......
...@@ -131,6 +131,7 @@ void init(const SWIGV8_VALUE& funcMap){ ...@@ -131,6 +131,7 @@ void init(const SWIGV8_VALUE& funcMap){
exportable_callback<ConfigurationSignal::AccountsChanged>(bind(&accountsChanged)), exportable_callback<ConfigurationSignal::AccountsChanged>(bind(&accountsChanged)),
exportable_callback<ConfigurationSignal::AccountDetailsChanged>(bind(&accountDetailsChanged, _1, _2)), exportable_callback<ConfigurationSignal::AccountDetailsChanged>(bind(&accountDetailsChanged, _1, _2)),
exportable_callback<ConfigurationSignal::RegistrationStateChanged>(bind(&registrationStateChanged, _1, _2, _3, _4)), exportable_callback<ConfigurationSignal::RegistrationStateChanged>(bind(&registrationStateChanged, _1, _2, _3, _4)),
exportable_callback<ConfigurationSignal::ComposingStatusChanged>(bind(composingStatusChanged, _1, _2, _3, _4 )),
exportable_callback<ConfigurationSignal::ContactAdded>(bind(&contactAdded, _1, _2, _3 )), exportable_callback<ConfigurationSignal::ContactAdded>(bind(&contactAdded, _1, _2, _3 )),
exportable_callback<ConfigurationSignal::ContactRemoved>(bind(&contactRemoved, _1, _2, _3 )), exportable_callback<ConfigurationSignal::ContactRemoved>(bind(&contactRemoved, _1, _2, _3 )),
exportable_callback<ConfigurationSignal::ExportOnRingEnded>(bind(&exportOnRingEnded, _1, _2, _3 )), exportable_callback<ConfigurationSignal::ExportOnRingEnded>(bind(&exportOnRingEnded, _1, _2, _3 )),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment