Commit d8dfb0d9 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added new Core.pushNotificationReceived method

parent d6fe5b72
...@@ -5998,6 +5998,15 @@ LINPHONE_PUBLIC LinphoneXmlRpcSession * linphone_core_create_xml_rpc_session(Lin ...@@ -5998,6 +5998,15 @@ LINPHONE_PUBLIC LinphoneXmlRpcSession * linphone_core_create_xml_rpc_session(Lin
**/ **/
LINPHONE_PUBLIC void linphone_core_load_config_from_xml(LinphoneCore *lc, const char * xml_uri); LINPHONE_PUBLIC void linphone_core_load_config_from_xml(LinphoneCore *lc, const char * xml_uri);
/**
* Call this method when you receive a push notification.
* It will ensure the proxy configs are correctly registered to the proxy server,
* so the call or the message will be correctly delivered.
* @param[in] lc The #LinphoneCore
* @ingroup misc
**/
LINPHONE_PUBLIC void linphone_core_ensure_registered(LinphoneCore *lc);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -127,3 +127,7 @@ void linphone_core_enable_friend_list_subscription(LinphoneCore *lc, bool_t enab ...@@ -127,3 +127,7 @@ void linphone_core_enable_friend_list_subscription(LinphoneCore *lc, bool_t enab
bool_t linphone_core_is_friend_list_subscription_enabled(LinphoneCore *lc) { bool_t linphone_core_is_friend_list_subscription_enabled(LinphoneCore *lc) {
return L_GET_CPP_PTR_FROM_C_OBJECT(lc)->isFriendListSubscriptionEnabled() ? TRUE : FALSE; return L_GET_CPP_PTR_FROM_C_OBJECT(lc)->isFriendListSubscriptionEnabled() ? TRUE : FALSE;
} }
void linphone_core_ensure_registered(LinphoneCore *lc) {
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->pushNotificationReceived();
}
\ No newline at end of file
...@@ -429,6 +429,27 @@ bool Core::isFriendListSubscriptionEnabled () const { ...@@ -429,6 +429,27 @@ bool Core::isFriendListSubscriptionEnabled () const {
// Misc. // Misc.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Core::pushNotificationReceived () const {
LinphoneCore *lc = getCCore();
const bctbx_list_t *proxies = linphone_core_get_proxy_config_list(lc);
bctbx_list_t *it = (bctbx_list_t *)proxies;
lInfo() << "Push notification received";
while (it) {
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *) bctbx_list_get_data(it);
LinphoneRegistrationState state = linphone_proxy_config_get_state(proxy);
if (state == LinphoneRegistrationFailed) {
lInfo() << "Proxy config [" << proxy << "] is in failed state, refreshing REGISTER";
if (linphone_proxy_config_register_enabled(proxy) && linphone_proxy_config_get_expires(proxy) > 0) {
linphone_proxy_config_refresh_register(proxy);
}
} else if (state == LinphoneRegistrationOk) {
// TODO: send a keep-alive to ensure the socket isn't broken
}
it = bctbx_list_next(it);
}
}
int Core::getUnreadChatMessageCount () const { int Core::getUnreadChatMessageCount () const {
L_D(); L_D();
return d->mainDb->getUnreadChatMessageCount(); return d->mainDb->getUnreadChatMessageCount();
......
...@@ -177,6 +177,7 @@ public: ...@@ -177,6 +177,7 @@ public:
// Misc. // Misc.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void pushNotificationReceived () const;
int getUnreadChatMessageCount () const; int getUnreadChatMessageCount () const;
int getUnreadChatMessageCount (const IdentityAddress &localAddress) const; int getUnreadChatMessageCount (const IdentityAddress &localAddress) const;
int getUnreadChatMessageCountFromActiveLocals () const; int getUnreadChatMessageCountFromActiveLocals () const;
......
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