Source

Target

Commits (1)
Showing with 35 additions and 0 deletions
......@@ -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);
/**
* 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
}
......
......@@ -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) {
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 {
// 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 {
L_D();
return d->mainDb->getUnreadChatMessageCount();
......
......@@ -177,6 +177,7 @@ public:
// Misc.
// ---------------------------------------------------------------------------
void pushNotificationReceived () const;
int getUnreadChatMessageCount () const;
int getUnreadChatMessageCount (const IdentityAddress &localAddress) const;
int getUnreadChatMessageCountFromActiveLocals () const;
......