mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-30 01:39:20 +00:00
add linphone_core_enter_(back/fore)ground and (un)subscribe chat room event handler when needed
This commit is contained in:
parent
f163e95752
commit
603bd91bbb
10 changed files with 91 additions and 0 deletions
|
|
@ -6018,6 +6018,14 @@ void friends_config_uninit(LinphoneCore* lc)
|
|||
ms_message("Destroying friends done.");
|
||||
}
|
||||
|
||||
void linphone_core_enter_background(LinphoneCore *lc) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->enterBackground();
|
||||
}
|
||||
|
||||
void linphone_core_enter_foreground(LinphoneCore *lc) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->enterForeground();
|
||||
}
|
||||
|
||||
LpConfig * linphone_core_get_config(const LinphoneCore *lc){
|
||||
return lc->config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4026,6 +4026,18 @@ LINPHONE_PUBLIC void *linphone_core_get_user_data(const LinphoneCore *lc);
|
|||
**/
|
||||
LINPHONE_PUBLIC void linphone_core_set_user_data(LinphoneCore *lc, void *userdata);
|
||||
|
||||
/**
|
||||
* This method is called by the application to notify the linphone core library when it enters background mode.
|
||||
* @ingroup misc
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_enter_background(LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* This method is called by the application to notify the linphone core library when it enters foreground mode.
|
||||
* @ingroup misc
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_enter_foreground(LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* Returns the LpConfig object used to manage the storage (config) file.
|
||||
* @param[in] lc #LinphoneCore object
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ private:
|
|||
// CoreListener
|
||||
void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override;
|
||||
void onRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message) override;
|
||||
void onEnteringBackground () override;
|
||||
void onEnteringForeground () override;
|
||||
|
||||
ChatRoomId chatRoomId;
|
||||
|
||||
|
|
|
|||
|
|
@ -238,6 +238,14 @@ void RemoteConferenceEventHandlerPrivate::onRegistrationStateChanged (LinphonePr
|
|||
subscribe();
|
||||
}
|
||||
|
||||
void RemoteConferenceEventHandlerPrivate::onEnteringBackground () {
|
||||
unsubscribe();
|
||||
}
|
||||
|
||||
void RemoteConferenceEventHandlerPrivate::onEnteringForeground () {
|
||||
subscribe();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
RemoteConferenceEventHandler::RemoteConferenceEventHandler (RemoteConference *remoteConference) :
|
||||
|
|
|
|||
|
|
@ -245,4 +245,12 @@ void RemoteConferenceListEventHandler::onRegistrationStateChanged (LinphoneProxy
|
|||
subscribe();
|
||||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::onEnteringBackground () {
|
||||
unsubscribe();
|
||||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::onEnteringForeground () {
|
||||
subscribe();
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ private:
|
|||
// CoreListener
|
||||
void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override;
|
||||
void onRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message) override;
|
||||
void onEnteringBackground () override;
|
||||
void onEnteringForeground () override;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public:
|
|||
virtual void onGlobalStateChanged (LinphoneGlobalState state) {}
|
||||
virtual void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) {}
|
||||
virtual void onRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message) {}
|
||||
virtual void onEnteringBackground () {}
|
||||
virtual void onEnteringForeground () {}
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ public:
|
|||
void notifyGlobalStateChanged (LinphoneGlobalState state);
|
||||
void notifyNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable);
|
||||
void notifyRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message);
|
||||
void notifyEnteringBackground ();
|
||||
void notifyEnteringForeground ();
|
||||
|
||||
int addCall (const std::shared_ptr<Call> &call);
|
||||
bool canWeAddCall () const;
|
||||
|
|
@ -72,6 +74,8 @@ public:
|
|||
std::unique_ptr<LocalConferenceListEventHandler> localListEventHandler;
|
||||
|
||||
private:
|
||||
bool isInBackground = false;
|
||||
|
||||
std::list<CoreListener *> listeners;
|
||||
|
||||
std::list<std::shared_ptr<Call>> calls;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,26 @@ void CorePrivate::notifyRegistrationStateChanged (LinphoneProxyConfig *cfg, Linp
|
|||
listener->onRegistrationStateChanged(cfg, state, message);
|
||||
}
|
||||
|
||||
void CorePrivate::notifyEnteringBackground () {
|
||||
if (isInBackground)
|
||||
return;
|
||||
|
||||
isInBackground = true;
|
||||
auto listenersCopy = listeners; // Allow removable of a listener in its own call
|
||||
for (const auto &listener : listenersCopy)
|
||||
listener->onEnteringBackground();
|
||||
}
|
||||
|
||||
void CorePrivate::notifyEnteringForeground () {
|
||||
if (!isInBackground)
|
||||
return;
|
||||
|
||||
isInBackground = false;
|
||||
auto listenersCopy = listeners; // Allow removable of a listener in its own call
|
||||
for (const auto &listener : listenersCopy)
|
||||
listener->onEnteringForeground();
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Core::Core () : Object(*new CorePrivate) {
|
||||
|
|
@ -131,6 +151,24 @@ shared_ptr<Core> Core::create (LinphoneCore *cCore) {
|
|||
return core;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Application lifecycle.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void Core::enterBackground () {
|
||||
L_D();
|
||||
d->notifyEnteringBackground();
|
||||
}
|
||||
|
||||
void Core::enterForeground () {
|
||||
L_D();
|
||||
d->notifyEnteringForeground();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// C-Core.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
LinphoneCore *Core::getCCore () const {
|
||||
return L_GET_C_BACK_PTR(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,13 @@ public:
|
|||
// Return a new Core instance. Entry point of Linphone.
|
||||
static std::shared_ptr<Core> create (LinphoneCore *cCore);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Application lifecycle.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void enterBackground ();
|
||||
void enterForeground ();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// C-Core.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue