Skip to content
Snippets Groups Projects
Commit bb752b88 authored by Léopold Chappuis's avatar Léopold Chappuis Committed by Léopold Chappuis
Browse files

nodejs_interface: link profileReceived & accountProfileReceived

These signals help the client know when a user updated his profile and are indeed needed in the expressJs server

Change-Id: Ib82d3bf477dbb77a3d86f79c6f9aa12a9b30dfd3
parent 6d5b090b
Branches
No related tags found
No related merge requests found
...@@ -52,6 +52,8 @@ Persistent<Function> conferenceRemovedCb; ...@@ -52,6 +52,8 @@ Persistent<Function> conferenceRemovedCb;
Persistent<Function> onConferenceInfosUpdatedCb; Persistent<Function> onConferenceInfosUpdatedCb;
Persistent<Function> conversationPreferencesUpdatedCb; Persistent<Function> conversationPreferencesUpdatedCb;
Persistent<Function> messageSendCb; Persistent<Function> messageSendCb;
Persistent<Function> accountProfileReceivedCb;
Persistent<Function> profileReceivedCb;
std::queue<std::function<void()>> pendingSignals; std::queue<std::function<void()>> pendingSignals;
std::mutex pendingSignalsLock; std::mutex pendingSignalsLock;
...@@ -147,6 +149,10 @@ getPresistentCb(std::string_view signal) ...@@ -147,6 +149,10 @@ getPresistentCb(std::string_view signal)
return &conversationPreferencesUpdatedCb; return &conversationPreferencesUpdatedCb;
else if (signal == "LogMessage") else if (signal == "LogMessage")
return &messageSendCb; return &messageSendCb;
else if (signal == "AccountProfileReceived")
return &accountProfileReceivedCb;
else if (signal == "ProfileReceived")
return &profileReceivedCb;
else else
return nullptr; return nullptr;
} }
...@@ -1077,3 +1083,40 @@ logMessage(const std::string& message) ...@@ -1077,3 +1083,40 @@ logMessage(const std::string& message)
}); });
uv_async_send(&signalAsync); uv_async_send(&signalAsync);
} }
void
accountProfileReceived(const std::string& accountId,
const std::string& displayName,
const std::string& photo)
{
std::lock_guard lock(pendingSignalsLock);
pendingSignals.emplace([accountId, displayName, photo]() {
Local<Function> func = Local<Function>::New(Isolate::GetCurrent(), accountProfileReceivedCb);
if (!func.IsEmpty()) {
SWIGV8_VALUE callback_args[] = {V8_STRING_NEW_LOCAL(accountId),
V8_STRING_NEW_LOCAL(displayName),
V8_STRING_NEW_LOCAL(photo)};
func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 3, callback_args);
}
});
uv_async_send(&signalAsync);
}
void
profileReceived(const std::string& accountId,
const std::string& from,
const std::string& path)
{
std::lock_guard lock(pendingSignalsLock);
pendingSignals.emplace([accountId, from, path]() {
Local<Function> func = Local<Function>::New(Isolate::GetCurrent(), profileReceivedCb);
if (!func.IsEmpty()) {
SWIGV8_VALUE callback_args[] = {V8_STRING_NEW_LOCAL(accountId),
V8_STRING_NEW_LOCAL(from),
V8_STRING_NEW_LOCAL(path)};
func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 3, callback_args);
}
});
uv_async_send(&signalAsync);
}
...@@ -145,7 +145,8 @@ void init(const SWIGV8_VALUE& funcMap){ ...@@ -145,7 +145,8 @@ void init(const SWIGV8_VALUE& funcMap){
exportable_callback<ConfigurationSignal::MessageSend>(bind(&logMessage, _1 )), exportable_callback<ConfigurationSignal::MessageSend>(bind(&logMessage, _1 )),
exportable_callback<ConfigurationSignal::NeedsHost>(bind(&needsHost, _1, _2 )), exportable_callback<ConfigurationSignal::NeedsHost>(bind(&needsHost, _1, _2 )),
exportable_callback<ConfigurationSignal::ActiveCallsChanged>(bind(&activeCallsChanged, _1, _2, _3 )), exportable_callback<ConfigurationSignal::ActiveCallsChanged>(bind(&activeCallsChanged, _1, _2, _3 )),
//exportable_callback<ConfigurationSignal::ProfileReceived>(bind(&profileReceived, _1, _2, _3, _4 )), exportable_callback<ConfigurationSignal::ProfileReceived>(bind(&profileReceived, _1, _2, _3)),
exportable_callback<ConfigurationSignal::AccountProfileReceived>(bind(&accountProfileReceived, _1, _2, _3)),
//exportable_callback<ConfigurationSignal::IncomingTrustRequest>(bind(&incomingTrustRequest, _1, _2, _3, _4, _5 )), //exportable_callback<ConfigurationSignal::IncomingTrustRequest>(bind(&incomingTrustRequest, _1, _2, _3, _4, _5 )),
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment