UPnP doesn't always stop when it should
UPnP should only be active if there's at least one account that's (1) enabled and (2) has the "Use UPnP" setting on. However, this isn't always the case. Here are two example scenarios which result in incorrect behavior.
Scenario 1
Steps to reproduce
- Start Jami with one account enabled and with "Use UPnP" on.
- Turn the "Use UPnP" setting off (in the "Advanced settings" page).
Expected result
UPnP stops (i.e. the UPnPContext::stopUpnp
function gets called).
Actual result
UPnP doesn't stop.
Scenario 2
Steps to reproduce
- Start Jami with one account enabled and with "Use UPnP" on.
- Disable the account (in the "Manage account" settings page).
Expected result
UPnP stops.
Actual result
UPnP doesn't stop.
Cause
In the first scenario, the problem is due to the fact that the Account::updateUpnpController
function behaves incorrectly when called by an instance of the JamiAccount
subclass. The function assumes that resetting the upnpCtrl_
shared pointer will result in the underlying upnp::Controller
object being destroyed. This doesn't work for JamiAccount
objects because the shared pointer gets copied in the JamiAccount::initConnectionManager
function.
In the second scenario, the Account::updateUpnpController
doesn't get called at all, so the fact that the account got disabled has no impact on UPnP until Jami is restarted.