mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-06 20:23:08 +00:00
Convert the deprecated ProxyConfig into the new Account class.
This commit is contained in:
parent
fcba1893c1
commit
338772da77
32 changed files with 1277 additions and 1238 deletions
|
|
@ -600,7 +600,7 @@ static inline void registerSharedToolType (const char *name) {
|
|||
void App::registerTypes () {
|
||||
qInfo() << QStringLiteral("Registering types...");
|
||||
|
||||
qRegisterMetaType<shared_ptr<linphone::ProxyConfig>>();
|
||||
qRegisterMetaType<shared_ptr<linphone::Account>>();
|
||||
qRegisterMetaType<ChatRoomModel::EntryType>();
|
||||
qRegisterMetaType<shared_ptr<linphone::SearchResult>>();
|
||||
qRegisterMetaType<std::list<std::shared_ptr<linphone::SearchResult> > >();
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ static void cliJoinConferenceAs (QHash<QString, QString> &args) {
|
|||
Utils::appStringToCoreString(fromSipAddress)
|
||||
);
|
||||
if (!currentSipAddress->weakEqual(askedSipAddress)) {
|
||||
qWarning() << QStringLiteral("Guest sip address `%1` doesn't match with default proxy config.")
|
||||
qWarning() << QStringLiteral("Guest sip address `%1` doesn't match with default account.")
|
||||
.arg(fromSipAddress);
|
||||
return;
|
||||
}
|
||||
|
|
@ -139,14 +139,14 @@ static void cliInitiateConference (QHash<QString, QString> &args) {
|
|||
|
||||
address->clean();
|
||||
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
|
||||
if (!proxyConfig) {
|
||||
qWarning() << QStringLiteral("Not connected to a proxy config");
|
||||
shared_ptr<linphone::Account> account = core->getDefaultAccount();
|
||||
if (!account) {
|
||||
qWarning() << QStringLiteral("Not connected to an account");
|
||||
return;
|
||||
}
|
||||
if (!proxyConfig->getIdentityAddress()->weakEqual(address)) {
|
||||
if (!account->getParams()->getIdentityAddress()->weakEqual(address)) {
|
||||
qWarning() << QStringLiteral("Received different sip address from identity : `%1 != %2`.")
|
||||
.arg(Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()))
|
||||
.arg(Utils::coreStringToAppString(account->getParams()->getIdentityAddress()->asString()))
|
||||
.arg(Utils::coreStringToAppString(address->asString()));
|
||||
return;
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ static void cliInitiateConference (QHash<QString, QString> &args) {
|
|||
}
|
||||
|
||||
qInfo() << QStringLiteral("Create conference with id: `%1`.").arg(id);
|
||||
auto confParameters = core->createConferenceParams();
|
||||
auto confParameters = core->createConferenceParams(conference);
|
||||
confParameters->enableVideo(false);// Video is not yet fully supported by the application in conference
|
||||
conference = core->createConferenceWithParams(confParameters);
|
||||
conference->setId(Utils::appStringToCoreString(id));
|
||||
|
|
|
|||
|
|
@ -36,415 +36,424 @@ using namespace std;
|
|||
|
||||
class AssistantModel::Handlers : public linphone::AccountCreatorListener {
|
||||
public:
|
||||
Handlers (AssistantModel *assistant) {
|
||||
mAssistant = assistant;
|
||||
}
|
||||
|
||||
Handlers (AssistantModel *assistant) {
|
||||
mAssistant = assistant;
|
||||
}
|
||||
|
||||
private:
|
||||
void createProxyConfig (const shared_ptr<linphone::AccountCreator> &creator) {
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
|
||||
Q_CHECK_PTR(proxyConfig);
|
||||
CoreManager::getInstance()->getSettingsModel()->configureRlsUri(proxyConfig);
|
||||
}
|
||||
|
||||
void onCreateAccount (
|
||||
const shared_ptr<linphone::AccountCreator> &,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreator::Status::AccountCreated){
|
||||
emit mAssistant->createStatusChanged(QString(""));
|
||||
}else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->createStatusChanged(tr("requestFailed"));
|
||||
else if (status == linphone::AccountCreator::Status::ServerError)
|
||||
emit mAssistant->createStatusChanged(tr("cannotSendSms"));
|
||||
else
|
||||
emit mAssistant->createStatusChanged(tr("accountAlreadyExists"));
|
||||
}
|
||||
}
|
||||
|
||||
void onIsAccountExist (
|
||||
const shared_ptr<linphone::AccountCreator> &creator,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreator::Status::AccountExist || status == linphone::AccountCreator::Status::AccountExistWithAlias) {
|
||||
createProxyConfig(creator);
|
||||
CoreManager::getInstance()->getSipAddressesModel()->reset();
|
||||
emit mAssistant->loginStatusChanged(QString(""));
|
||||
} else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->loginStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
emit mAssistant->loginStatusChanged(tr("loginWithUsernameFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
void onActivateAccount (
|
||||
const shared_ptr<linphone::AccountCreator> &creator,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (
|
||||
status == linphone::AccountCreator::Status::AccountActivated ||
|
||||
status == linphone::AccountCreator::Status::AccountAlreadyActivated
|
||||
) {
|
||||
if (creator->getEmail().empty())
|
||||
createProxyConfig(creator);
|
||||
CoreManager::getInstance()->getSipAddressesModel()->reset();
|
||||
emit mAssistant->activateStatusChanged(QString(""));
|
||||
} else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->activateStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
emit mAssistant->activateStatusChanged(tr("smsActivationFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
void onIsAccountActivated (
|
||||
const shared_ptr<linphone::AccountCreator> &creator,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreator::Status::AccountActivated) {
|
||||
createProxyConfig(creator);
|
||||
CoreManager::getInstance()->getSipAddressesModel()->reset();
|
||||
emit mAssistant->activateStatusChanged(QString(""));
|
||||
} else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->activateStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
emit mAssistant->activateStatusChanged(tr("emailActivationFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
void onRecoverAccount (
|
||||
const shared_ptr<linphone::AccountCreator> &,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreator::Status::RequestOk) {
|
||||
CoreManager::getInstance()->getSipAddressesModel()->reset();
|
||||
emit mAssistant->recoverStatusChanged(QString(""));
|
||||
} else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->recoverStatusChanged(tr("requestFailed"));
|
||||
else if (status == linphone::AccountCreator::Status::ServerError)
|
||||
emit mAssistant->recoverStatusChanged(tr("cannotSendSms"));
|
||||
else
|
||||
emit mAssistant->recoverStatusChanged(tr("loginWithPhoneNumberFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
void createAccount (const shared_ptr<linphone::AccountCreator> &creator) {
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
|
||||
auto account = CoreManager::getInstance()->getCore()->getAccountByIdkey(proxyConfig->getIdkey());
|
||||
if(account){
|
||||
CoreManager::getInstance()->getSettingsModel()->configureRlsUri(account);
|
||||
CoreManager::getInstance()->getAccountSettingsModel()->setDefaultAccount(account);
|
||||
}
|
||||
}
|
||||
|
||||
void onCreateAccount (
|
||||
const shared_ptr<linphone::AccountCreator> & accountCreator,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreator::Status::AccountCreated){
|
||||
emit mAssistant->createStatusChanged(QString(""));
|
||||
}else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->createStatusChanged(tr("requestFailed"));
|
||||
else if (status == linphone::AccountCreator::Status::ServerError)
|
||||
emit mAssistant->createStatusChanged(tr("cannotSendSms"));
|
||||
else
|
||||
emit mAssistant->createStatusChanged(tr("accountAlreadyExists"));
|
||||
}
|
||||
}
|
||||
|
||||
void onIsAccountExist (
|
||||
const shared_ptr<linphone::AccountCreator> &creator,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreator::Status::AccountExist || status == linphone::AccountCreator::Status::AccountExistWithAlias) {
|
||||
createAccount(creator);
|
||||
CoreManager::getInstance()->getSipAddressesModel()->reset();
|
||||
emit mAssistant->loginStatusChanged(QString(""));
|
||||
} else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->loginStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
emit mAssistant->loginStatusChanged(tr("loginWithUsernameFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
void onActivateAccount (
|
||||
const shared_ptr<linphone::AccountCreator> &creator,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (
|
||||
status == linphone::AccountCreator::Status::AccountActivated ||
|
||||
status == linphone::AccountCreator::Status::AccountAlreadyActivated
|
||||
) {
|
||||
if (creator->getEmail().empty())
|
||||
createAccount(creator);
|
||||
CoreManager::getInstance()->getSipAddressesModel()->reset();
|
||||
emit mAssistant->activateStatusChanged(QString(""));
|
||||
} else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->activateStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
emit mAssistant->activateStatusChanged(tr("smsActivationFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
void onIsAccountActivated (
|
||||
const shared_ptr<linphone::AccountCreator> &creator,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreator::Status::AccountActivated) {
|
||||
createAccount(creator);
|
||||
CoreManager::getInstance()->getSipAddressesModel()->reset();
|
||||
emit mAssistant->activateStatusChanged(QString(""));
|
||||
} else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->activateStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
emit mAssistant->activateStatusChanged(tr("emailActivationFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
void onRecoverAccount (
|
||||
const shared_ptr<linphone::AccountCreator> &,
|
||||
linphone::AccountCreator::Status status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreator::Status::RequestOk) {
|
||||
CoreManager::getInstance()->getSipAddressesModel()->reset();
|
||||
emit mAssistant->recoverStatusChanged(QString(""));
|
||||
} else {
|
||||
if (status == linphone::AccountCreator::Status::RequestFailed)
|
||||
emit mAssistant->recoverStatusChanged(tr("requestFailed"));
|
||||
else if (status == linphone::AccountCreator::Status::ServerError)
|
||||
emit mAssistant->recoverStatusChanged(tr("cannotSendSms"));
|
||||
else
|
||||
emit mAssistant->recoverStatusChanged(tr("loginWithPhoneNumberFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
AssistantModel *mAssistant;
|
||||
AssistantModel *mAssistant;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
AssistantModel::AssistantModel (QObject *parent) : QObject(parent) {
|
||||
mHandlers = make_shared<AssistantModel::Handlers>(this);
|
||||
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
mAccountCreator = core->createAccountCreator(
|
||||
core->getConfig()->getString("assistant", "xmlrpc_url", Constants::DefaultXmlrpcUri)
|
||||
);
|
||||
mAccountCreator->addListener(mHandlers);
|
||||
mHandlers = make_shared<AssistantModel::Handlers>(this);
|
||||
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
mAccountCreator = core->createAccountCreator(
|
||||
core->getConfig()->getString("assistant", "xmlrpc_url", Constants::DefaultXmlrpcUri)
|
||||
);
|
||||
mAccountCreator->addListener(mHandlers);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void AssistantModel::activate () {
|
||||
if (mAccountCreator->getEmail().empty())
|
||||
mAccountCreator->activateAccount();
|
||||
else
|
||||
mAccountCreator->isAccountActivated();
|
||||
if (mAccountCreator->getEmail().empty())
|
||||
mAccountCreator->activateAccount();
|
||||
else
|
||||
mAccountCreator->isAccountActivated();
|
||||
}
|
||||
|
||||
void AssistantModel::create () {
|
||||
mAccountCreator->createAccount();
|
||||
mAccountCreator->createAccount();
|
||||
}
|
||||
|
||||
void AssistantModel::login () {
|
||||
if (!mCountryCode.isEmpty()) {
|
||||
mAccountCreator->recoverAccount();
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr<linphone::Config> config(CoreManager::getInstance()->getCore()->getConfig());
|
||||
if (!config->getString("assistant", "xmlrpc_url", "").empty()) {
|
||||
mAccountCreator->isAccountExist();
|
||||
return;
|
||||
}
|
||||
|
||||
// No verification if no xmlrpc url. Use addOtherSipAccount directly.
|
||||
QVariantMap map;
|
||||
map["sipDomain"] = Utils::coreStringToAppString(config->getString("assistant", "domain", ""));
|
||||
map["username"] = getUsername();
|
||||
map["password"] = getPassword();
|
||||
emit loginStatusChanged(addOtherSipAccount(map) ? QString("") : tr("unableToAddAccount"));
|
||||
if (!mCountryCode.isEmpty()) {
|
||||
mAccountCreator->recoverAccount();
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr<linphone::Config> config(CoreManager::getInstance()->getCore()->getConfig());
|
||||
if (!config->getString("assistant", "xmlrpc_url", "").empty()) {
|
||||
mAccountCreator->isAccountExist();
|
||||
return;
|
||||
}
|
||||
|
||||
// No verification if no xmlrpc url. Use addOtherSipAccount directly.
|
||||
QVariantMap map;
|
||||
map["sipDomain"] = Utils::coreStringToAppString(config->getString("assistant", "domain", ""));
|
||||
map["username"] = getUsername();
|
||||
map["password"] = getPassword();
|
||||
emit loginStatusChanged(addOtherSipAccount(map) ? QString("") : tr("unableToAddAccount"));
|
||||
}
|
||||
|
||||
void AssistantModel::reset () {
|
||||
mCountryCode = QString("");
|
||||
mAccountCreator->reset();
|
||||
|
||||
emit emailChanged(QString(""), QString(""));
|
||||
emit passwordChanged(QString(""), QString(""));
|
||||
emit phoneNumberChanged(QString(""), QString(""));
|
||||
emit usernameChanged(QString(""), QString(""));
|
||||
mCountryCode = QString("");
|
||||
mAccountCreator->reset();
|
||||
|
||||
emit emailChanged(QString(""), QString(""));
|
||||
emit passwordChanged(QString(""), QString(""));
|
||||
emit phoneNumberChanged(QString(""), QString(""));
|
||||
emit usernameChanged(QString(""), QString(""));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool AssistantModel::addOtherSipAccount (const QVariantMap &map) {
|
||||
CoreManager *coreManager = CoreManager::getInstance();
|
||||
|
||||
shared_ptr<linphone::Factory> factory = linphone::Factory::get();
|
||||
shared_ptr<linphone::Core> core = coreManager->getCore();
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->createProxyConfig();
|
||||
|
||||
const QString domain = map["sipDomain"].toString();
|
||||
|
||||
QString sipAddress = QStringLiteral("sip:%1@%2")
|
||||
.arg(map["username"].toString()).arg(domain);
|
||||
|
||||
// Server address.
|
||||
{
|
||||
shared_ptr<linphone::Address> address = factory->createAddress(
|
||||
Utils::appStringToCoreString(QStringLiteral("sip:%1").arg(domain))
|
||||
);
|
||||
if(!address) {
|
||||
qWarning() << QStringLiteral("Unable to create address from domain `%1`.")
|
||||
.arg(domain);
|
||||
CoreManager *coreManager = CoreManager::getInstance();
|
||||
|
||||
shared_ptr<linphone::Factory> factory = linphone::Factory::get();
|
||||
shared_ptr<linphone::Core> core = coreManager->getCore();
|
||||
std::shared_ptr<linphone::Account> account;
|
||||
std::string accountIdKey = map["accountIdKey"].toString().toStdString();
|
||||
if( accountIdKey != "")
|
||||
account = core->getAccountByIdkey(accountIdKey);
|
||||
shared_ptr<linphone::AccountParams> accountParams = core->createAccountParams();
|
||||
|
||||
|
||||
const QString domain = map["sipDomain"].toString();
|
||||
|
||||
QString sipAddress = QStringLiteral("sip:%1@%2")
|
||||
.arg(map["username"].toString()).arg(domain);
|
||||
{
|
||||
// Server address.
|
||||
shared_ptr<linphone::Address> address = factory->createAddress(
|
||||
Utils::appStringToCoreString(QStringLiteral("sip:%1").arg(domain))
|
||||
);
|
||||
if(!address) {
|
||||
qWarning() << QStringLiteral("Unable to create address from domain `%1`.")
|
||||
.arg(domain);
|
||||
return false;
|
||||
}
|
||||
const QString &transport(map["transport"].toString());
|
||||
if (!transport.isEmpty()) {
|
||||
LinphoneEnums::TransportType transportType;
|
||||
LinphoneEnums::fromString(transport, &transportType);
|
||||
address->setTransport(LinphoneEnums::toLinphone(transportType));
|
||||
}
|
||||
if (accountParams->setServerAddress(address)) {
|
||||
qWarning() << QStringLiteral("Unable to add server address: `%1`.")
|
||||
.arg(QString::fromStdString(address->asString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Sip Address.
|
||||
shared_ptr<linphone::Address> address = factory->createAddress(Utils::appStringToCoreString(sipAddress));
|
||||
if (!address) {
|
||||
qWarning() << QStringLiteral("Unable to create sip address object from: `%1`.").arg(sipAddress);
|
||||
return false;
|
||||
}
|
||||
const QString &transport(map["transport"].toString());
|
||||
if (!transport.isEmpty())
|
||||
address->setTransport(Utils::stringToTransportType(transport));
|
||||
|
||||
if (proxyConfig->setServerAddr(address->asString())) {
|
||||
qWarning() << QStringLiteral("Unable to add server address: `%1`.")
|
||||
.arg(QString::fromStdString(address->asString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Sip Address.
|
||||
shared_ptr<linphone::Address> address = factory->createAddress(Utils::appStringToCoreString(sipAddress));
|
||||
if (!address) {
|
||||
qWarning() << QStringLiteral("Unable to create sip address object from: `%1`.").arg(sipAddress);
|
||||
return false;
|
||||
}
|
||||
|
||||
address->setDisplayName(Utils::appStringToCoreString(map["displayName"].toString()));
|
||||
proxyConfig->setIdentityAddress(address);
|
||||
|
||||
// AuthInfo.
|
||||
core->addAuthInfo(
|
||||
factory->createAuthInfo(
|
||||
address->getUsername(), // Username.
|
||||
"", // User ID.
|
||||
Utils::appStringToCoreString(map["password"].toString()), // Password.
|
||||
"", // HA1.
|
||||
"", // Realm.
|
||||
address->getDomain() // Domain.
|
||||
)
|
||||
);
|
||||
|
||||
AccountSettingsModel *accountSettingsModel = coreManager->getAccountSettingsModel();
|
||||
if (accountSettingsModel->addOrUpdateProxyConfig(proxyConfig)) {
|
||||
accountSettingsModel->setDefaultProxyConfig(proxyConfig);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
address->setDisplayName(Utils::appStringToCoreString(map["displayName"].toString()));
|
||||
accountParams->setIdentityAddress(address);
|
||||
|
||||
// AuthInfo.
|
||||
core->addAuthInfo(
|
||||
factory->createAuthInfo(
|
||||
address->getUsername(), // Username.
|
||||
"", // User ID.
|
||||
Utils::appStringToCoreString(map["password"].toString()), // Password.
|
||||
"", // HA1.
|
||||
"", // Realm.
|
||||
address->getDomain() // Domain.
|
||||
)
|
||||
);
|
||||
|
||||
AccountSettingsModel *accountSettingsModel = coreManager->getAccountSettingsModel();
|
||||
if (accountSettingsModel->addOrUpdateAccount(account, accountParams)) {
|
||||
accountSettingsModel->setDefaultAccount(account);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getEmail () const {
|
||||
return Utils::coreStringToAppString(mAccountCreator->getEmail());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getEmail());
|
||||
}
|
||||
|
||||
void AssistantModel::setEmail (const QString &email) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (mAccountCreator->setEmail(Utils::appStringToCoreString(email))) {
|
||||
case linphone::AccountCreator::EmailStatus::Ok:
|
||||
break;
|
||||
case linphone::AccountCreator::EmailStatus::Malformed:
|
||||
error = tr("emailStatusMalformed");
|
||||
break;
|
||||
case linphone::AccountCreator::EmailStatus::InvalidCharacters:
|
||||
error = tr("emailStatusMalformedInvalidCharacters");
|
||||
break;
|
||||
}
|
||||
|
||||
emit emailChanged(email, error);
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (mAccountCreator->setEmail(Utils::appStringToCoreString(email))) {
|
||||
case linphone::AccountCreator::EmailStatus::Ok:
|
||||
break;
|
||||
case linphone::AccountCreator::EmailStatus::Malformed:
|
||||
error = tr("emailStatusMalformed");
|
||||
break;
|
||||
case linphone::AccountCreator::EmailStatus::InvalidCharacters:
|
||||
error = tr("emailStatusMalformedInvalidCharacters");
|
||||
break;
|
||||
}
|
||||
|
||||
emit emailChanged(email, error);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getPassword () const {
|
||||
return Utils::coreStringToAppString(mAccountCreator->getPassword());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getPassword());
|
||||
}
|
||||
|
||||
void AssistantModel::setPassword (const QString &password) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (mAccountCreator->setPassword(Utils::appStringToCoreString(password))) {
|
||||
case linphone::AccountCreator::PasswordStatus::Ok:
|
||||
break;
|
||||
case linphone::AccountCreator::PasswordStatus::TooShort:
|
||||
error = tr("passwordStatusTooShort").arg(config->getInt("assistant", "password_min_length", 1));
|
||||
break;
|
||||
case linphone::AccountCreator::PasswordStatus::TooLong:
|
||||
error = tr("passwordStatusTooLong").arg(config->getInt("assistant", "password_max_length", -1));
|
||||
break;
|
||||
case linphone::AccountCreator::PasswordStatus::InvalidCharacters:
|
||||
error = tr("passwordStatusInvalidCharacters")
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "password_regex", "")));
|
||||
break;
|
||||
case linphone::AccountCreator::PasswordStatus::MissingCharacters:
|
||||
error = tr("passwordStatusMissingCharacters")
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "missing_characters", "")));
|
||||
break;
|
||||
}
|
||||
|
||||
emit passwordChanged(password, error);
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (mAccountCreator->setPassword(Utils::appStringToCoreString(password))) {
|
||||
case linphone::AccountCreator::PasswordStatus::Ok:
|
||||
break;
|
||||
case linphone::AccountCreator::PasswordStatus::TooShort:
|
||||
error = tr("passwordStatusTooShort").arg(config->getInt("assistant", "password_min_length", 1));
|
||||
break;
|
||||
case linphone::AccountCreator::PasswordStatus::TooLong:
|
||||
error = tr("passwordStatusTooLong").arg(config->getInt("assistant", "password_max_length", -1));
|
||||
break;
|
||||
case linphone::AccountCreator::PasswordStatus::InvalidCharacters:
|
||||
error = tr("passwordStatusInvalidCharacters")
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "password_regex", "")));
|
||||
break;
|
||||
case linphone::AccountCreator::PasswordStatus::MissingCharacters:
|
||||
error = tr("passwordStatusMissingCharacters")
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "missing_characters", "")));
|
||||
break;
|
||||
}
|
||||
|
||||
emit passwordChanged(password, error);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getCountryCode () const {
|
||||
return mCountryCode;
|
||||
return mCountryCode;
|
||||
}
|
||||
|
||||
void AssistantModel::setCountryCode (const QString &countryCode) {
|
||||
mCountryCode = countryCode;
|
||||
emit countryCodeChanged(countryCode);
|
||||
mCountryCode = countryCode;
|
||||
emit countryCodeChanged(countryCode);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getPhoneNumber () const {
|
||||
return Utils::coreStringToAppString(mAccountCreator->getPhoneNumber());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getPhoneNumber());
|
||||
}
|
||||
|
||||
void AssistantModel::setPhoneNumber (const QString &phoneNumber) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (static_cast<linphone::AccountCreator::PhoneNumberStatus>(
|
||||
mAccountCreator->setPhoneNumber(Utils::appStringToCoreString(phoneNumber), Utils::appStringToCoreString(mCountryCode))
|
||||
)) {
|
||||
case linphone::AccountCreator::PhoneNumberStatus::Ok:
|
||||
break;
|
||||
case linphone::AccountCreator::PhoneNumberStatus::Invalid:
|
||||
error = tr("phoneNumberStatusInvalid");
|
||||
break;
|
||||
case linphone::AccountCreator::PhoneNumberStatus::TooShort:
|
||||
error = tr("phoneNumberStatusTooShort");
|
||||
break;
|
||||
case linphone::AccountCreator::PhoneNumberStatus::TooLong:
|
||||
error = tr("phoneNumberStatusTooLong");
|
||||
break;
|
||||
case linphone::AccountCreator::PhoneNumberStatus::InvalidCountryCode:
|
||||
error = tr("phoneNumberStatusInvalidCountryCode");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
emit phoneNumberChanged(phoneNumber, error);
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (static_cast<linphone::AccountCreator::PhoneNumberStatus>(
|
||||
mAccountCreator->setPhoneNumber(Utils::appStringToCoreString(phoneNumber), Utils::appStringToCoreString(mCountryCode))
|
||||
)) {
|
||||
case linphone::AccountCreator::PhoneNumberStatus::Ok:
|
||||
break;
|
||||
case linphone::AccountCreator::PhoneNumberStatus::Invalid:
|
||||
error = tr("phoneNumberStatusInvalid");
|
||||
break;
|
||||
case linphone::AccountCreator::PhoneNumberStatus::TooShort:
|
||||
error = tr("phoneNumberStatusTooShort");
|
||||
break;
|
||||
case linphone::AccountCreator::PhoneNumberStatus::TooLong:
|
||||
error = tr("phoneNumberStatusTooLong");
|
||||
break;
|
||||
case linphone::AccountCreator::PhoneNumberStatus::InvalidCountryCode:
|
||||
error = tr("phoneNumberStatusInvalidCountryCode");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
emit phoneNumberChanged(phoneNumber, error);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getUsername () const {
|
||||
return Utils::coreStringToAppString(mAccountCreator->getUsername());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getUsername());
|
||||
}
|
||||
|
||||
void AssistantModel::setUsername (const QString &username) {
|
||||
emit usernameChanged(
|
||||
username,
|
||||
mapAccountCreatorUsernameStatusToString(
|
||||
mAccountCreator->setUsername(Utils::appStringToCoreString(username))
|
||||
)
|
||||
);
|
||||
emit usernameChanged(
|
||||
username,
|
||||
mapAccountCreatorUsernameStatusToString(
|
||||
mAccountCreator->setUsername(Utils::appStringToCoreString(username))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getDisplayName () const {
|
||||
return Utils::coreStringToAppString(mAccountCreator->getDisplayName());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getDisplayName());
|
||||
}
|
||||
|
||||
void AssistantModel::setDisplayName (const QString &displayName) {
|
||||
emit displayNameChanged(
|
||||
displayName,
|
||||
mapAccountCreatorUsernameStatusToString(
|
||||
mAccountCreator->setDisplayName(Utils::appStringToCoreString(displayName))
|
||||
)
|
||||
);
|
||||
emit displayNameChanged(
|
||||
displayName,
|
||||
mapAccountCreatorUsernameStatusToString(
|
||||
mAccountCreator->setDisplayName(Utils::appStringToCoreString(displayName))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getActivationCode () const {
|
||||
return Utils::coreStringToAppString(mAccountCreator->getActivationCode());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getActivationCode());
|
||||
}
|
||||
|
||||
void AssistantModel::setActivationCode (const QString &activationCode) {
|
||||
mAccountCreator->setActivationCode(Utils::appStringToCoreString(activationCode));
|
||||
emit activationCodeChanged(activationCode);
|
||||
mAccountCreator->setActivationCode(Utils::appStringToCoreString(activationCode));
|
||||
emit activationCodeChanged(activationCode);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getConfigFilename () const {
|
||||
return mConfigFilename;
|
||||
return mConfigFilename;
|
||||
}
|
||||
|
||||
void AssistantModel::setConfigFilename (const QString &configFilename) {
|
||||
mConfigFilename = configFilename;
|
||||
|
||||
QString configPath = Utils::coreStringToAppString(Paths::getAssistantConfigDirPath()) + configFilename;
|
||||
qInfo() << QStringLiteral("Set config on assistant: `%1`.").arg(configPath);
|
||||
|
||||
CoreManager::getInstance()->getCore()->getConfig()->loadFromXmlFile(
|
||||
Utils::appStringToCoreString(configPath)
|
||||
);
|
||||
|
||||
emit configFilenameChanged(configFilename);
|
||||
mConfigFilename = configFilename;
|
||||
|
||||
QString configPath = Utils::coreStringToAppString(Paths::getAssistantConfigDirPath()) + configFilename;
|
||||
qInfo() << QStringLiteral("Set config on assistant: `%1`.").arg(configPath);
|
||||
|
||||
CoreManager::getInstance()->getCore()->getConfig()->loadFromXmlFile(
|
||||
Utils::appStringToCoreString(configPath)
|
||||
);
|
||||
|
||||
emit configFilenameChanged(configFilename);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::mapAccountCreatorUsernameStatusToString (linphone::AccountCreator::UsernameStatus status) const {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (status) {
|
||||
case linphone::AccountCreator::UsernameStatus::Ok:
|
||||
break;
|
||||
case linphone::AccountCreator::UsernameStatus::TooShort:
|
||||
error = tr("usernameStatusTooShort").arg(config->getInt("assistant", "username_min_length", 1));
|
||||
break;
|
||||
case linphone::AccountCreator::UsernameStatus::TooLong:
|
||||
error = tr("usernameStatusTooLong").arg(config->getInt("assistant", "username_max_length", -1));
|
||||
break;
|
||||
case linphone::AccountCreator::UsernameStatus::InvalidCharacters:
|
||||
error = tr("usernameStatusInvalidCharacters")
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "username_regex", "")));
|
||||
break;
|
||||
case linphone::AccountCreator::UsernameStatus::Invalid:
|
||||
error = tr("usernameStatusInvalid");
|
||||
break;
|
||||
}
|
||||
|
||||
return error;
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (status) {
|
||||
case linphone::AccountCreator::UsernameStatus::Ok:
|
||||
break;
|
||||
case linphone::AccountCreator::UsernameStatus::TooShort:
|
||||
error = tr("usernameStatusTooShort").arg(config->getInt("assistant", "username_min_length", 1));
|
||||
break;
|
||||
case linphone::AccountCreator::UsernameStatus::TooLong:
|
||||
error = tr("usernameStatusTooLong").arg(config->getInt("assistant", "username_max_length", -1));
|
||||
break;
|
||||
case linphone::AccountCreator::UsernameStatus::InvalidCharacters:
|
||||
error = tr("usernameStatusInvalidCharacters")
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "username_regex", "")));
|
||||
break;
|
||||
case linphone::AccountCreator::UsernameStatus::Invalid:
|
||||
error = tr("usernameStatusInvalid");
|
||||
break;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,17 +129,17 @@ void CallsListModel::launchAudioCall (const QString &sipAddress, const QString&
|
|||
iterator.next();
|
||||
params->addCustomHeader(Utils::appStringToCoreString(iterator.key()), Utils::appStringToCoreString(iterator.value()));
|
||||
}
|
||||
params->setProxyConfig(core->getDefaultProxyConfig());
|
||||
params->setAccount(core->getDefaultAccount());
|
||||
CallModel::setRecordFile(params, Utils::coreStringToAppString(address->getUsername()));
|
||||
shared_ptr<linphone::ProxyConfig> currentProxyConfig = core->getDefaultProxyConfig();
|
||||
if(currentProxyConfig){
|
||||
if(!CoreManager::getInstance()->getSettingsModel()->getWaitRegistrationForCall() || currentProxyConfig->getState() == linphone::RegistrationState::Ok)
|
||||
shared_ptr<linphone::Account> currentAccount = core->getDefaultAccount();
|
||||
if(currentAccount){
|
||||
if(!CoreManager::getInstance()->getSettingsModel()->getWaitRegistrationForCall() || currentAccount->getState() == linphone::RegistrationState::Ok)
|
||||
CallModel::prepareTransfert(core->inviteAddressWithParams(address, params), prepareTransfertAddress);
|
||||
else{
|
||||
QObject * context = new QObject();
|
||||
QObject::connect(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::registrationStateChanged,context,
|
||||
[address,core,params,currentProxyConfig,prepareTransfertAddress, context](const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, linphone::RegistrationState state) mutable {
|
||||
if(context && proxyConfig==currentProxyConfig && state==linphone::RegistrationState::Ok){
|
||||
[address,core,params,currentAccount,prepareTransfertAddress, context](const std::shared_ptr<linphone::Account> &account, linphone::RegistrationState state) mutable {
|
||||
if(context && account==currentAccount && state==linphone::RegistrationState::Ok){
|
||||
CallModel::prepareTransfert(core->inviteAddressWithParams(address, params), prepareTransfertAddress);
|
||||
context->deleteLater();
|
||||
context = nullptr;
|
||||
|
|
@ -166,18 +166,18 @@ void CallsListModel::launchSecureAudioCall (const QString &sipAddress, LinphoneE
|
|||
iterator.next();
|
||||
params->addCustomHeader(Utils::appStringToCoreString(iterator.key()), Utils::appStringToCoreString(iterator.value()));
|
||||
}
|
||||
params->setProxyConfig(core->getDefaultProxyConfig());
|
||||
params->setAccount(core->getDefaultAccount());
|
||||
CallModel::setRecordFile(params, Utils::coreStringToAppString(address->getUsername()));
|
||||
shared_ptr<linphone::ProxyConfig> currentProxyConfig = core->getDefaultProxyConfig();
|
||||
shared_ptr<linphone::Account> currentAccount = core->getDefaultAccount();
|
||||
params->setMediaEncryption(LinphoneEnums::toLinphone(encryption));
|
||||
if(currentProxyConfig){
|
||||
if(!CoreManager::getInstance()->getSettingsModel()->getWaitRegistrationForCall() || currentProxyConfig->getState() == linphone::RegistrationState::Ok)
|
||||
if(currentAccount){
|
||||
if(!CoreManager::getInstance()->getSettingsModel()->getWaitRegistrationForCall() || currentAccount->getState() == linphone::RegistrationState::Ok)
|
||||
CallModel::prepareTransfert(core->inviteAddressWithParams(address, params), prepareTransfertAddress);
|
||||
else{
|
||||
QObject * context = new QObject();
|
||||
QObject::connect(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::registrationStateChanged,context,
|
||||
[address,core,params,currentProxyConfig,prepareTransfertAddress, context](const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, linphone::RegistrationState state) mutable {
|
||||
if(context && proxyConfig==currentProxyConfig && state==linphone::RegistrationState::Ok){
|
||||
[address,core,params,currentAccount,prepareTransfertAddress, context](const std::shared_ptr<linphone::Account> &account, linphone::RegistrationState state) mutable {
|
||||
if(context && account==currentAccount && state==linphone::RegistrationState::Ok){
|
||||
CallModel::prepareTransfert(core->inviteAddressWithParams(address, params), prepareTransfertAddress);
|
||||
context->deleteLater();
|
||||
context = nullptr;
|
||||
|
|
@ -203,7 +203,7 @@ void CallsListModel::launchVideoCall (const QString &sipAddress, const QString&
|
|||
|
||||
shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
|
||||
params->enableVideo(true);
|
||||
params->setProxyConfig(core->getDefaultProxyConfig());
|
||||
params->setAccount(core->getDefaultAccount());
|
||||
CallModel::setRecordFile(params, Utils::coreStringToAppString(address->getUsername()));
|
||||
CallModel::prepareTransfert(core->inviteAddressWithParams(address, params), prepareTransfertAddress);
|
||||
}
|
||||
|
|
@ -219,7 +219,6 @@ ChatRoomModel* CallsListModel::launchSecureChat (const QString &sipAddress) cons
|
|||
std::list <shared_ptr<linphone::Address> > participants;
|
||||
std::shared_ptr<const linphone::Address> localAddress;
|
||||
participants.push_back(address);
|
||||
auto proxy = core->getDefaultProxyConfig();
|
||||
params->enableEncryption(true);
|
||||
|
||||
params->setSubject("Dummy Subject");
|
||||
|
|
@ -288,7 +287,6 @@ bool CallsListModel::createSecureChat (const QString& subject, const QString &pa
|
|||
std::list <shared_ptr<linphone::Address> > participants;
|
||||
std::shared_ptr<const linphone::Address> localAddress;
|
||||
participants.push_back(address);
|
||||
auto proxy = core->getDefaultProxyConfig();
|
||||
params->enableEncryption(true);
|
||||
|
||||
params->setSubject(Utils::appStringToCoreString(subject));
|
||||
|
|
@ -332,7 +330,6 @@ QVariantMap CallsListModel::createChatRoom(const QString& subject, const int& se
|
|||
if( address)
|
||||
chatRoomParticipants.push_back( address );
|
||||
}
|
||||
auto proxy = core->getDefaultProxyConfig();
|
||||
params->enableEncryption(securityLevel>0);
|
||||
|
||||
if( securityLevel>0){
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ bool ChatRoomModel::isMeAdmin() const{
|
|||
return mChatRoom->getMe()->isAdmin();
|
||||
}
|
||||
|
||||
bool ChatRoomModel::isCurrentProxy() const{
|
||||
bool ChatRoomModel::isCurrentAccount() const{
|
||||
return mChatRoom->getLocalAddress()->weakEqual(CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddress());
|
||||
}
|
||||
|
||||
|
|
@ -1264,7 +1264,7 @@ void ChatRoomModel::onMessageReceived(const std::shared_ptr<linphone::ChatRoom>
|
|||
}
|
||||
|
||||
void ChatRoomModel::onNewEvent(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::EventLog> & eventLog){
|
||||
if( eventLog->getType() == linphone::EventLog::Type::ConferenceCallEnd ){
|
||||
if( eventLog->getType() == linphone::EventLog::Type::ConferenceCallEnded ){
|
||||
setMissedCallsCount(mMissedCallsCount+1);
|
||||
}else if( eventLog->getType() == linphone::EventLog::Type::ConferenceCreated ){
|
||||
emit fullPeerAddressChanged();
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public:
|
|||
bool isConference() const;
|
||||
bool isOneToOne() const;
|
||||
bool isMeAdmin() const;
|
||||
bool isCurrentProxy() const; // Return true if this chat room is Me() is the current proxy
|
||||
bool isCurrentAccount() const; // Return true if this chat room is Me() is the current account
|
||||
bool canHandleParticipants() const;
|
||||
bool getIsRemoteComposing () const;
|
||||
bool isEntriesLoading() const;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ bool ConferenceHelperModel::ConferenceAddModel::removeFromConference (const QStr
|
|||
void ConferenceHelperModel::ConferenceAddModel::update () {
|
||||
shared_ptr<linphone::Conference> conference = mConferenceHelperModel->mCore->getConference();
|
||||
if(!conference){
|
||||
auto parameters = mConferenceHelperModel->mCore->createConferenceParams();
|
||||
auto parameters = mConferenceHelperModel->mCore->createConferenceParams(conference);
|
||||
parameters->enableVideo(false);// Video is not yet fully supported by the application in conference
|
||||
conference = mConferenceHelperModel->mCore->createConferenceWithParams(parameters);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,15 @@ CoreHandlers::~CoreHandlers () {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void CoreHandlers::onAccountRegistrationStateChanged (
|
||||
const shared_ptr<linphone::Core> &,
|
||||
const shared_ptr<linphone::Account> &account,
|
||||
linphone::RegistrationState state,
|
||||
const string &
|
||||
) {
|
||||
emit registrationStateChanged(account, state);
|
||||
}
|
||||
|
||||
void CoreHandlers::onAuthenticationRequested (
|
||||
const shared_ptr<linphone::Core> & core,
|
||||
const shared_ptr<linphone::AuthInfo> &authInfo,
|
||||
|
|
@ -56,17 +65,17 @@ void CoreHandlers::onAuthenticationRequested (
|
|||
) {
|
||||
Q_UNUSED(method)
|
||||
if( authInfo ) {
|
||||
auto configList = core->getProxyConfigList();
|
||||
auto config = configList.begin() ;
|
||||
auto accounts = core->getAccountList();
|
||||
auto itAccount = accounts.begin() ;
|
||||
std::string username = authInfo->getUsername();
|
||||
std::string domain = authInfo->getDomain();
|
||||
while(config != configList.end()) {
|
||||
auto contact = (*config)->getContact();
|
||||
if( contact && contact->getUsername() == username && (*config)->getContact()->getDomain() == domain) {
|
||||
emit authenticationRequested(authInfo);// Send authentification request only if a proxy still exists
|
||||
while(itAccount != accounts.end()) {
|
||||
auto contact = (*itAccount)->getParams()->getIdentityAddress();
|
||||
if( contact && contact->getUsername() == username && contact->getDomain() == domain) {
|
||||
emit authenticationRequested(authInfo);// Send authentification request only if an account still exists
|
||||
return;
|
||||
}else
|
||||
++config;
|
||||
++itAccount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -245,15 +254,6 @@ void CoreHandlers::onNotifyPresenceReceived (
|
|||
emit presenceStatusReceived(linphoneFriend);
|
||||
}
|
||||
|
||||
void CoreHandlers::onRegistrationStateChanged (
|
||||
const shared_ptr<linphone::Core> &,
|
||||
const shared_ptr<linphone::ProxyConfig> &proxyConfig,
|
||||
linphone::RegistrationState state,
|
||||
const string &
|
||||
) {
|
||||
emit registrationStateChanged(proxyConfig, state);
|
||||
}
|
||||
|
||||
void CoreHandlers::onTransferStateChanged (
|
||||
const shared_ptr<linphone::Core> &,
|
||||
const shared_ptr<linphone::Call> &call,
|
||||
|
|
|
|||
|
|
@ -30,158 +30,158 @@ class CoreManager;
|
|||
class QMutex;
|
||||
|
||||
class CoreHandlers :
|
||||
public QObject,
|
||||
public linphone::CoreListener {
|
||||
Q_OBJECT;
|
||||
|
||||
public QObject,
|
||||
public linphone::CoreListener {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
CoreHandlers (CoreManager *coreManager);
|
||||
~CoreHandlers ();
|
||||
|
||||
CoreHandlers (CoreManager *coreManager);
|
||||
~CoreHandlers ();
|
||||
|
||||
signals:
|
||||
void authenticationRequested (const std::shared_ptr<linphone::AuthInfo> &authInfo);
|
||||
void callEncryptionChanged (const std::shared_ptr<linphone::Call> &call);
|
||||
void callLogUpdated(const std::shared_ptr<linphone::CallLog> &call);
|
||||
void callStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state);
|
||||
void callTransferFailed (const std::shared_ptr<linphone::Call> &call);
|
||||
void callTransferSucceeded (const std::shared_ptr<linphone::Call> &call);
|
||||
void callCreated(const std::shared_ptr<linphone::Call> & call);
|
||||
void chatRoomStateChanged(const std::shared_ptr<linphone::ChatRoom> &chatRoom,linphone::ChatRoom::State state);
|
||||
void coreStarting();
|
||||
void coreStarted ();
|
||||
void coreStopped ();
|
||||
void isComposingChanged (const std::shared_ptr<linphone::ChatRoom> &chatRoom);
|
||||
void logsUploadStateChanged (linphone::Core::LogCollectionUploadState state, const std::string &info);
|
||||
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void presenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
|
||||
void presenceStatusReceived(std::shared_ptr<linphone::Friend> contact);
|
||||
void registrationStateChanged (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, linphone::RegistrationState state);
|
||||
void ecCalibrationResult(linphone::EcCalibratorStatus status, int delayMs);
|
||||
void setLastRemoteProvisioningState(const linphone::ConfiguringState &state);
|
||||
|
||||
void authenticationRequested (const std::shared_ptr<linphone::AuthInfo> &authInfo);
|
||||
void callEncryptionChanged (const std::shared_ptr<linphone::Call> &call);
|
||||
void callLogUpdated(const std::shared_ptr<linphone::CallLog> &call);
|
||||
void callStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state);
|
||||
void callTransferFailed (const std::shared_ptr<linphone::Call> &call);
|
||||
void callTransferSucceeded (const std::shared_ptr<linphone::Call> &call);
|
||||
void callCreated(const std::shared_ptr<linphone::Call> & call);
|
||||
void chatRoomStateChanged(const std::shared_ptr<linphone::ChatRoom> &chatRoom,linphone::ChatRoom::State state);
|
||||
void coreStarting();
|
||||
void coreStarted ();
|
||||
void coreStopped ();
|
||||
void isComposingChanged (const std::shared_ptr<linphone::ChatRoom> &chatRoom);
|
||||
void logsUploadStateChanged (linphone::Core::LogCollectionUploadState state, const std::string &info);
|
||||
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void presenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
|
||||
void presenceStatusReceived(std::shared_ptr<linphone::Friend> contact);
|
||||
void registrationStateChanged (const std::shared_ptr<linphone::Account> &account, linphone::RegistrationState state);
|
||||
void ecCalibrationResult(linphone::EcCalibratorStatus status, int delayMs);
|
||||
void setLastRemoteProvisioningState(const linphone::ConfiguringState &state);
|
||||
|
||||
private:
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Linphone callbacks.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void onAuthenticationRequested (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
||||
linphone::AuthMethod method
|
||||
) override;
|
||||
|
||||
void onCallEncryptionChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
bool on,
|
||||
const std::string &authenticationToken
|
||||
) override;
|
||||
|
||||
void onCallLogUpdated(const std::shared_ptr<linphone::Core> & core, const std::shared_ptr<linphone::CallLog> & callLog) override;
|
||||
|
||||
void onCallStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
linphone::Call::State state,
|
||||
const std::string &message
|
||||
) override;
|
||||
|
||||
void onCallStatsUpdated (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
const std::shared_ptr<const linphone::CallStats> &stats
|
||||
) override;
|
||||
|
||||
void onCallCreated(
|
||||
const std::shared_ptr<linphone::Core> & lc,
|
||||
const std::shared_ptr<linphone::Call> & call
|
||||
) override;
|
||||
|
||||
void onChatRoomStateChanged(
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
const std::shared_ptr<linphone::ChatRoom> & chatRoom,
|
||||
linphone::ChatRoom::State state
|
||||
) override;
|
||||
|
||||
void onConfiguringStatus(
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
linphone::ConfiguringState status,
|
||||
const std::string & message) override;
|
||||
|
||||
void onDtmfReceived(
|
||||
const std::shared_ptr<linphone::Core> & lc,
|
||||
const std::shared_ptr<linphone::Call> & call,
|
||||
int dtmf)override;
|
||||
|
||||
void onGlobalStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
linphone::GlobalState gstate,
|
||||
const std::string &message
|
||||
) override;
|
||||
|
||||
void onIsComposingReceived (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::ChatRoom> &room
|
||||
) override;
|
||||
|
||||
void onLogCollectionUploadStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
linphone::Core::LogCollectionUploadState state,
|
||||
const std::string &info
|
||||
) override;
|
||||
|
||||
void onLogCollectionUploadProgressIndication (
|
||||
const std::shared_ptr<linphone::Core> &lc,
|
||||
size_t offset,
|
||||
size_t total
|
||||
) override;
|
||||
|
||||
void onMessageReceived (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::ChatRoom> &room,
|
||||
const std::shared_ptr<linphone::ChatMessage> &message
|
||||
) override;
|
||||
|
||||
void onNotifyPresenceReceivedForUriOrTel (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Friend> &linphoneFriend,
|
||||
const std::string &uriOrTel,
|
||||
const std::shared_ptr<const linphone::PresenceModel> &presenceModel
|
||||
) override;
|
||||
|
||||
void onNotifyPresenceReceived (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Friend> &linphoneFriend
|
||||
) override;
|
||||
|
||||
void onRegistrationStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::ProxyConfig> &proxyConfig,
|
||||
linphone::RegistrationState state,
|
||||
const std::string &message
|
||||
) override;
|
||||
|
||||
void onTransferStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
linphone::Call::State state
|
||||
) override;
|
||||
|
||||
void onVersionUpdateCheckResultReceived (
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
linphone::VersionUpdateCheckResult result,
|
||||
const std::string &version,
|
||||
const std::string &url
|
||||
) override;
|
||||
|
||||
void onEcCalibrationResult(
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
linphone::EcCalibratorStatus status,
|
||||
int delayMs
|
||||
) override;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Linphone callbacks.
|
||||
// ---------------------------------------------------------------------------
|
||||
void onAccountRegistrationStateChanged(
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
const std::shared_ptr<linphone::Account> & account,
|
||||
linphone::RegistrationState state,
|
||||
const std::string & message) override;
|
||||
|
||||
void onAuthenticationRequested (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
||||
linphone::AuthMethod method
|
||||
) override;
|
||||
|
||||
void onCallEncryptionChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
bool on,
|
||||
const std::string &authenticationToken
|
||||
) override;
|
||||
|
||||
void onCallLogUpdated(const std::shared_ptr<linphone::Core> & core, const std::shared_ptr<linphone::CallLog> & callLog) override;
|
||||
|
||||
void onCallStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
linphone::Call::State state,
|
||||
const std::string &message
|
||||
) override;
|
||||
|
||||
void onCallStatsUpdated (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
const std::shared_ptr<const linphone::CallStats> &stats
|
||||
) override;
|
||||
|
||||
void onCallCreated(
|
||||
const std::shared_ptr<linphone::Core> & lc,
|
||||
const std::shared_ptr<linphone::Call> & call
|
||||
) override;
|
||||
|
||||
void onChatRoomStateChanged(
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
const std::shared_ptr<linphone::ChatRoom> & chatRoom,
|
||||
linphone::ChatRoom::State state
|
||||
) override;
|
||||
|
||||
void onConfiguringStatus(
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
linphone::ConfiguringState status,
|
||||
const std::string & message) override;
|
||||
|
||||
void onDtmfReceived(
|
||||
const std::shared_ptr<linphone::Core> & lc,
|
||||
const std::shared_ptr<linphone::Call> & call,
|
||||
int dtmf)override;
|
||||
|
||||
void onGlobalStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
linphone::GlobalState gstate,
|
||||
const std::string &message
|
||||
) override;
|
||||
|
||||
void onIsComposingReceived (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::ChatRoom> &room
|
||||
) override;
|
||||
|
||||
void onLogCollectionUploadStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
linphone::Core::LogCollectionUploadState state,
|
||||
const std::string &info
|
||||
) override;
|
||||
|
||||
void onLogCollectionUploadProgressIndication (
|
||||
const std::shared_ptr<linphone::Core> &lc,
|
||||
size_t offset,
|
||||
size_t total
|
||||
) override;
|
||||
|
||||
void onMessageReceived (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::ChatRoom> &room,
|
||||
const std::shared_ptr<linphone::ChatMessage> &message
|
||||
) override;
|
||||
|
||||
void onNotifyPresenceReceivedForUriOrTel (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Friend> &linphoneFriend,
|
||||
const std::string &uriOrTel,
|
||||
const std::shared_ptr<const linphone::PresenceModel> &presenceModel
|
||||
) override;
|
||||
|
||||
void onNotifyPresenceReceived (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Friend> &linphoneFriend
|
||||
) override;
|
||||
|
||||
//void onRegistrationStateChanged (
|
||||
|
||||
void onTransferStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
linphone::Call::State state
|
||||
) override;
|
||||
|
||||
void onVersionUpdateCheckResultReceived (
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
linphone::VersionUpdateCheckResult result,
|
||||
const std::string &version,
|
||||
const std::string &url
|
||||
) override;
|
||||
|
||||
void onEcCalibrationResult(
|
||||
const std::shared_ptr<linphone::Core> & core,
|
||||
linphone::EcCalibratorStatus status,
|
||||
int delayMs
|
||||
) override;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
};
|
||||
|
||||
#endif // CORE_HANDLERS_H_
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ void CoreManager::cleanLogs () const {
|
|||
|
||||
void CoreManager::setDatabasesPaths () {
|
||||
SET_DATABASE_PATH(Friends, Paths::getFriendsListFilePath());
|
||||
SET_DATABASE_PATH(CallLogs, Paths::getCallHistoryFilePath());
|
||||
linphone_core_set_call_logs_database_path(mCore->cPtr(), Paths::getCallHistoryFilePath().c_str());// Setting the message database let SDK to migrate data
|
||||
if(QFile::exists(Utils::coreStringToAppString(Paths::getMessageHistoryFilePath()))){
|
||||
linphone_core_set_chat_database_path(mCore->cPtr(), Paths::getMessageHistoryFilePath().c_str());// Setting the message database let SDK to migrate data
|
||||
QFile::remove(Utils::coreStringToAppString(Paths::getMessageHistoryFilePath()));
|
||||
|
|
@ -313,15 +313,6 @@ void CoreManager::migrate () {
|
|||
qInfo() << QStringLiteral("Migrate from old rc file (%1 to %2).")
|
||||
.arg(rcVersion).arg(Constants::RcVersionCurrent);
|
||||
|
||||
// Add message_expires param on old proxy configs.
|
||||
/*
|
||||
for (const auto &proxyConfig : mCore->getProxyConfigList()) {
|
||||
if (proxyConfig->getDomain() == Constants::LinphoneDomain) {
|
||||
proxyConfig->setContactParameters(Constants::DefaultContactParameters);
|
||||
proxyConfig->setExpires(Constants::DefaultExpires);
|
||||
proxyConfig->done();
|
||||
}
|
||||
}*/
|
||||
bool setlimeServerUrl = false;
|
||||
for(const auto &account : mCore->getAccountList()){
|
||||
auto params = account->getParams();
|
||||
|
|
|
|||
|
|
@ -79,16 +79,22 @@ AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
|
|||
|
||||
shared_ptr<const linphone::Address> AccountSettingsModel::getUsedSipAddress () const {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
|
||||
|
||||
return proxyConfig?proxyConfig->getIdentityAddress():core->createPrimaryContactParsed();
|
||||
shared_ptr<linphone::Account> account = core->getDefaultAccount();
|
||||
return account ? account->getParams()->getIdentityAddress() : core->createPrimaryContactParsed();
|
||||
}
|
||||
|
||||
void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::Address> &address) {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
|
||||
|
||||
proxyConfig ? proxyConfig->setIdentityAddress(address) : core->setPrimaryContact(address->asString());
|
||||
shared_ptr<linphone::Account> account = core->getDefaultAccount();
|
||||
if( account){
|
||||
auto params = account->getParams()->clone();
|
||||
if(!params->setIdentityAddress(address)) {
|
||||
account->setParams(params);
|
||||
emit sipAddressChanged();
|
||||
}
|
||||
return;
|
||||
}
|
||||
core->setPrimaryContact(address->asString());
|
||||
emit sipAddressChanged();
|
||||
}
|
||||
|
||||
|
|
@ -101,67 +107,67 @@ QString AccountSettingsModel::getUsedSipAddressAsString () const {
|
|||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
|
||||
Q_CHECK_PTR(proxyConfig);
|
||||
bool AccountSettingsModel::addOrUpdateAccount (std::shared_ptr<linphone::Account> account, const std::shared_ptr<linphone::AccountParams>& accountParams) {
|
||||
|
||||
CoreManager *coreManager = CoreManager::getInstance();
|
||||
shared_ptr<linphone::Core> core = coreManager->getCore();
|
||||
|
||||
list<shared_ptr<linphone::ProxyConfig>> proxyConfigs = core->getProxyConfigList();
|
||||
if (find(proxyConfigs.cbegin(), proxyConfigs.cend(), proxyConfig) != proxyConfigs.cend()) {
|
||||
if (proxyConfig->done() == -1) {
|
||||
qWarning() << QStringLiteral("Unable to update proxy config: `%1`.")
|
||||
.arg(QString::fromStdString(proxyConfig->getIdentityAddress()->asString()));
|
||||
return false;
|
||||
}
|
||||
coreManager->getSettingsModel()->configureRlsUri();
|
||||
} else {
|
||||
if (core->addProxyConfig(proxyConfig) == -1) {
|
||||
qWarning() << QStringLiteral("Unable to add proxy config: `%1`.")
|
||||
.arg(QString::fromStdString(proxyConfig->getIdentityAddress()->asString()));
|
||||
return false;
|
||||
}
|
||||
coreManager->getSettingsModel()->configureRlsUri(proxyConfig);
|
||||
list<shared_ptr<linphone::Account>> accounts = core->getAccountList();
|
||||
if(!account)
|
||||
account = core->createAccount(accountParams);
|
||||
if (account->setParams(accountParams) == -1) {
|
||||
qWarning() << QStringLiteral("Unable to update account: `%1`.")
|
||||
.arg(QString::fromStdString(account->getParams()->getIdentityAddress()->asString()));
|
||||
return false;
|
||||
}
|
||||
if (find(accounts.cbegin(), accounts.cend(), account) == accounts.cend()) {
|
||||
if (core->addAccount(account) == -1) {
|
||||
qWarning() << QStringLiteral("Unable to add account: `%1`.")
|
||||
.arg(QString::fromStdString(account->getParams()->getIdentityAddress()->asString()));
|
||||
return false;
|
||||
}
|
||||
coreManager->getSettingsModel()->configureRlsUri(account);
|
||||
}else
|
||||
coreManager->getSettingsModel()->configureRlsUri();
|
||||
|
||||
emit accountSettingsUpdated();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
|
||||
Q_CHECK_PTR(proxyConfig);
|
||||
|
||||
QVariantMap AccountSettingsModel::getAccountDescription (const shared_ptr<linphone::Account> &account) {
|
||||
QVariantMap map;
|
||||
auto accountParams = account->getParams();
|
||||
|
||||
{
|
||||
const shared_ptr<const linphone::Address> address = proxyConfig->getIdentityAddress();
|
||||
const shared_ptr<const linphone::Address> address = accountParams->getIdentityAddress();
|
||||
map["sipAddress"] = address
|
||||
? Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString())
|
||||
? Utils::coreStringToAppString(accountParams->getIdentityAddress()->asString())
|
||||
: QString("");
|
||||
}
|
||||
map["serverAddress"] = Utils::coreStringToAppString(proxyConfig->getServerAddr());
|
||||
map["registrationDuration"] = proxyConfig->getPublishExpires();
|
||||
map["serverAddress"] = Utils::coreStringToAppString(accountParams->getServerAddress()->asString());
|
||||
map["registrationDuration"] = accountParams->getPublishExpires();
|
||||
|
||||
if( map["serverAddress"].toString().toUpper().contains("TRANSPORT="))// transport has been specified : let the RFC select the transport
|
||||
map["transport"] = Utils::coreStringToAppString(proxyConfig->getTransport());
|
||||
map["transport"] = LinphoneEnums::toString(LinphoneEnums::fromLinphone(accountParams->getTransport()));
|
||||
else// Set to TLS as default
|
||||
map["transport"] = "tls";
|
||||
if( proxyConfig->getRoutes().size() > 0)
|
||||
map["route"] = Utils::coreStringToAppString(proxyConfig->getRoutes().front());
|
||||
map["transport"] = "TLS";
|
||||
auto routes = accountParams->getRoutesAddresses();
|
||||
if( routes.size() > 0)
|
||||
map["route"] = Utils::coreStringToAppString(routes.front()->asString());
|
||||
else
|
||||
map["route"] = "";
|
||||
map["conferenceUri"] = Utils::coreStringToAppString(proxyConfig->getConferenceFactoryUri());
|
||||
map["contactParams"] = Utils::coreStringToAppString(proxyConfig->getContactParameters());
|
||||
map["avpfInterval"] = proxyConfig->getAvpfRrInterval();
|
||||
map["registerEnabled"] = proxyConfig->registerEnabled();
|
||||
map["publishPresence"] = proxyConfig->publishEnabled();
|
||||
map["avpfEnabled"] = proxyConfig->getAvpfMode() == linphone::AVPFMode::Enabled;
|
||||
map["registrationState"] = mapLinphoneRegistrationStateToUi(proxyConfig->getState());
|
||||
map["conferenceUri"] = Utils::coreStringToAppString(accountParams->getConferenceFactoryUri());
|
||||
map["contactParams"] = Utils::coreStringToAppString(accountParams->getContactParameters());
|
||||
map["avpfInterval"] = accountParams->getAvpfRrInterval();
|
||||
map["registerEnabled"] = accountParams->registerEnabled();
|
||||
map["publishPresence"] = accountParams->publishEnabled();
|
||||
map["avpfEnabled"] = accountParams->getAvpfMode() == linphone::AVPFMode::Enabled;
|
||||
map["registrationState"] = mapLinphoneRegistrationStateToUi(account->getState());
|
||||
|
||||
shared_ptr<linphone::NatPolicy> natPolicy = proxyConfig->getNatPolicy();
|
||||
shared_ptr<linphone::NatPolicy> natPolicy = accountParams->getNatPolicy();
|
||||
bool createdNat = !natPolicy;
|
||||
if (createdNat)
|
||||
natPolicy = proxyConfig->getCore()->createNatPolicy();
|
||||
natPolicy = CoreManager::getInstance()->getCore()->createNatPolicy();
|
||||
map["iceEnabled"] = natPolicy->iceEnabled();
|
||||
map["turnEnabled"] = natPolicy->turnEnabled();
|
||||
|
||||
|
|
@ -171,8 +177,11 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
|
|||
map["turnUser"] = Utils::coreStringToAppString(turnUser);
|
||||
map["stunServer"] = Utils::coreStringToAppString(stunServer);
|
||||
|
||||
if (createdNat)
|
||||
proxyConfig->setNatPolicy(natPolicy);
|
||||
if (createdNat){
|
||||
auto accountParamsUpdated = accountParams->clone();
|
||||
accountParamsUpdated->setNatPolicy(natPolicy);
|
||||
account->setParams(accountParamsUpdated);
|
||||
}
|
||||
|
||||
shared_ptr<const linphone::AuthInfo> authInfo = CoreManager::getInstance()->getCore()->findAuthInfo(
|
||||
"", turnUser, stunServer
|
||||
|
|
@ -184,81 +193,79 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
|
|||
|
||||
QString AccountSettingsModel::getConferenceURI() const{
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
|
||||
return proxyConfig ? Utils::coreStringToAppString(proxyConfig->getConferenceFactoryUri()) : "";
|
||||
shared_ptr<linphone::Account> account = core->getDefaultAccount();
|
||||
return account ? Utils::coreStringToAppString(account->getParams()->getConferenceFactoryUri()) : "";
|
||||
}
|
||||
|
||||
void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
|
||||
void AccountSettingsModel::setDefaultAccount (const shared_ptr<linphone::Account> &account) {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
if (core->getDefaultProxyConfig() != proxyConfig) {
|
||||
core->setDefaultProxyConfig(proxyConfig);
|
||||
if (mSelectedAccount != account) {
|
||||
core->setDefaultAccount(account);
|
||||
mSelectedAccount = account;
|
||||
emit accountSettingsUpdated();
|
||||
emit defaultProxyChanged();
|
||||
emit defaultAccountChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void AccountSettingsModel::setDefaultProxyConfigFromSipAddress (const QString &sipAddress) {
|
||||
void AccountSettingsModel::setDefaultAccountFromSipAddress (const QString &sipAddress) {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
auto address = Utils::interpretUrl(sipAddress);
|
||||
if ( core->createPrimaryContactParsed()->weakEqual(address)) {
|
||||
setDefaultProxyConfig(nullptr);
|
||||
setDefaultAccount(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &proxyConfig : core->getProxyConfigList())
|
||||
if (proxyConfig->getIdentityAddress()->weakEqual(address)) {
|
||||
setDefaultProxyConfig(proxyConfig);
|
||||
for (const auto &account : core->getAccountList())
|
||||
if (account->getParams()->getIdentityAddress()->weakEqual(address)) {
|
||||
setDefaultAccount(account);
|
||||
return;
|
||||
}
|
||||
|
||||
qWarning() << "Unable to set default proxy config from:" << sipAddress;
|
||||
qWarning() << "Unable to set default account from:" << sipAddress;
|
||||
}
|
||||
void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
|
||||
Q_CHECK_PTR(proxyConfig);
|
||||
void AccountSettingsModel::removeAccount (const shared_ptr<linphone::Account> &account) {
|
||||
|
||||
CoreManager *coreManager = CoreManager::getInstance();
|
||||
std::shared_ptr<linphone::ProxyConfig> newProxy = nullptr;
|
||||
std::list<std::shared_ptr<linphone::ProxyConfig>> allProxies = coreManager->getCore()->getProxyConfigList();
|
||||
if( proxyConfig == coreManager->getCore()->getDefaultProxyConfig()){
|
||||
for(auto proxy : allProxies){
|
||||
if( proxy != proxyConfig ){
|
||||
newProxy = proxy;
|
||||
std::shared_ptr<linphone::Account> newAccount = nullptr;
|
||||
std::list<std::shared_ptr<linphone::Account>> allAccounts = coreManager->getCore()->getAccountList();
|
||||
if( account == coreManager->getCore()->getDefaultAccount()){
|
||||
for(auto nextAccount : allAccounts){
|
||||
if( nextAccount != account){
|
||||
newAccount = nextAccount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setDefaultProxyConfig(newProxy);
|
||||
setDefaultAccount(newAccount);
|
||||
}
|
||||
// "message-expires" is used to keep contact for messages. Setting to 0 will remove the contact for messages too.
|
||||
// Check if a "message-expires" exists and set it to 0
|
||||
QStringList parameters = Utils::coreStringToAppString(proxyConfig->getContactParameters()).split(";");
|
||||
QStringList parameters = Utils::coreStringToAppString(account->getParams()->getContactParameters()).split(";");
|
||||
for(int i = 0 ; i < parameters.size() ; ++i){
|
||||
QStringList fields = parameters[i].split("=");
|
||||
if( fields.size() > 1 && fields[0].simplified() == "message-expires"){
|
||||
parameters[i] = Constants::DefaultContactParametersOnRemove;
|
||||
}
|
||||
}
|
||||
proxyConfig->edit();
|
||||
proxyConfig->setContactParameters(Utils::appStringToCoreString(parameters.join(";")));
|
||||
if (proxyConfig->done() == -1) {
|
||||
qWarning() << QStringLiteral("Unable to reset message-expiry property before removing proxy config: `%1`.")
|
||||
.arg(QString::fromStdString(proxyConfig->getIdentityAddress()->asString()));
|
||||
}else if(proxyConfig->registerEnabled()) { // Wait for update
|
||||
mRemovingProxies.push_back(proxyConfig);
|
||||
auto accountParams = account->getParams()->clone();
|
||||
accountParams->setContactParameters(Utils::appStringToCoreString(parameters.join(";")));
|
||||
if (account->setParams(accountParams) == -1) {
|
||||
qWarning() << QStringLiteral("Unable to reset message-expiry property before removing account: `%1`.")
|
||||
.arg(QString::fromStdString(account->getParams()->getIdentityAddress()->asString()));
|
||||
}else if(account->getParams()->registerEnabled()) { // Wait for update
|
||||
mRemovingAccounts.push_back(account);
|
||||
}else{// Registration is not enabled : Removing without wait.
|
||||
CoreManager::getInstance()->getCore()->removeProxyConfig(proxyConfig);
|
||||
CoreManager::getInstance()->getCore()->removeAccount(account);
|
||||
}
|
||||
|
||||
emit accountSettingsUpdated();
|
||||
}
|
||||
|
||||
bool AccountSettingsModel::addOrUpdateProxyConfig (
|
||||
const shared_ptr<linphone::ProxyConfig> &proxyConfig,
|
||||
bool AccountSettingsModel::addOrUpdateAccount(
|
||||
const shared_ptr<linphone::Account> &account,
|
||||
const QVariantMap &data
|
||||
) {
|
||||
Q_CHECK_PTR(proxyConfig);
|
||||
bool newPublishPresence = false;
|
||||
|
||||
proxyConfig->edit();
|
||||
auto accountParams = account->getParams()->clone();
|
||||
|
||||
QString literal = data["sipAddress"].toString();
|
||||
|
||||
|
|
@ -271,7 +278,7 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
|
|||
return false;
|
||||
}
|
||||
|
||||
if (proxyConfig->setIdentityAddress(address)) {
|
||||
if (accountParams->setIdentityAddress(address)) {
|
||||
qWarning() << QStringLiteral("Unable to set identity address: `%1`.")
|
||||
.arg(Utils::coreStringToAppString(address->asStringUriOnly()));
|
||||
return false;
|
||||
|
|
@ -280,42 +287,45 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
|
|||
|
||||
// Server address.
|
||||
{
|
||||
QString serverAddress = data["serverAddress"].toString();
|
||||
auto serverAddress = Utils::interpretUrl(data["serverAddress"].toString());
|
||||
|
||||
if (proxyConfig->setServerAddr(Utils::appStringToCoreString(serverAddress))) {
|
||||
qWarning() << QStringLiteral("Unable to add server address: `%1`.").arg(serverAddress);
|
||||
if (accountParams->setServerAddress(serverAddress)) {
|
||||
qWarning() << QStringLiteral("Unable to add server address: `%1`.").arg(serverAddress->asString().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(data.contains("registrationDuration"))
|
||||
proxyConfig->setPublishExpires(data["registrationDuration"].toInt());
|
||||
if(data.contains("route"))
|
||||
proxyConfig->setRoute(Utils::appStringToCoreString(data["route"].toString()));
|
||||
accountParams->setPublishExpires(data["registrationDuration"].toInt());
|
||||
if(data.contains("route")) {
|
||||
std::list<std::shared_ptr<linphone::Address>> routes;
|
||||
routes.push_back(Utils::interpretUrl(data["route"].toString()));
|
||||
accountParams->setRoutesAddresses(routes);
|
||||
}
|
||||
QString conferenceURI = data["conferenceUri"].toString();
|
||||
if(!conferenceURI.isEmpty())
|
||||
proxyConfig->setConferenceFactoryUri(Utils::appStringToCoreString(conferenceURI));
|
||||
accountParams->setConferenceFactoryUri(Utils::appStringToCoreString(conferenceURI));
|
||||
if(data.contains("contactParams"))
|
||||
proxyConfig->setContactParameters(Utils::appStringToCoreString(data["contactParams"].toString()));
|
||||
accountParams->setContactParameters(Utils::appStringToCoreString(data["contactParams"].toString()));
|
||||
if(data.contains("avpfInterval"))
|
||||
proxyConfig->setAvpfRrInterval(uint8_t(data["avpfInterval"].toInt()));
|
||||
accountParams->setAvpfRrInterval(uint8_t(data["avpfInterval"].toInt()));
|
||||
if(data.contains("registerEnabled"))
|
||||
proxyConfig->enableRegister(data.contains("registerEnabled") ? data["registerEnabled"].toBool() : true);
|
||||
accountParams->enableRegister(data.contains("registerEnabled") ? data["registerEnabled"].toBool() : true);
|
||||
if(data.contains("publishPresence")) {
|
||||
newPublishPresence = proxyConfig->publishEnabled() != data["publishPresence"].toBool();
|
||||
proxyConfig->enablePublish(data["publishPresence"].toBool());
|
||||
newPublishPresence = accountParams->publishEnabled() != data["publishPresence"].toBool();
|
||||
accountParams->enablePublish(data["publishPresence"].toBool());
|
||||
}else
|
||||
newPublishPresence = proxyConfig->publishEnabled();
|
||||
newPublishPresence = accountParams->publishEnabled();
|
||||
if(data.contains("avpfEnabled"))
|
||||
proxyConfig->setAvpfMode(data["avpfEnabled"].toBool()
|
||||
accountParams->setAvpfMode(data["avpfEnabled"].toBool()
|
||||
? linphone::AVPFMode::Enabled
|
||||
: linphone::AVPFMode::Default
|
||||
);
|
||||
|
||||
shared_ptr<linphone::NatPolicy> natPolicy = proxyConfig->getNatPolicy();
|
||||
shared_ptr<linphone::NatPolicy> natPolicy = accountParams->getNatPolicy();
|
||||
bool createdNat = !natPolicy;
|
||||
if (createdNat)
|
||||
natPolicy = proxyConfig->getCore()->createNatPolicy();
|
||||
natPolicy = CoreManager::getInstance()->getCore()->createNatPolicy();
|
||||
if(data.contains("iceEnabled"))
|
||||
natPolicy->enableIce(data["iceEnabled"].toBool());
|
||||
if(data.contains("iceEnabled"))
|
||||
|
|
@ -331,9 +341,9 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
|
|||
natPolicy->setStunServer(stunServer);
|
||||
|
||||
if( createdNat)
|
||||
proxyConfig->setNatPolicy(natPolicy);
|
||||
accountParams->setNatPolicy(natPolicy);
|
||||
|
||||
shared_ptr<linphone::Core> core(proxyConfig->getCore());
|
||||
shared_ptr<linphone::Core> core(CoreManager::getInstance()->getCore());
|
||||
shared_ptr<const linphone::AuthInfo> authInfo(core->findAuthInfo("", turnUser, stunServer));
|
||||
if (authInfo) {
|
||||
shared_ptr<linphone::AuthInfo> clonedAuthInfo(authInfo->clone());
|
||||
|
|
@ -353,30 +363,30 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
|
|||
));
|
||||
if( newPublishPresence)
|
||||
emit publishPresenceChanged();
|
||||
return addOrUpdateProxyConfig(proxyConfig);
|
||||
return addOrUpdateAccount(account, accountParams);
|
||||
}
|
||||
|
||||
bool AccountSettingsModel::addOrUpdateProxyConfig (
|
||||
bool AccountSettingsModel::addOrUpdateAccount (
|
||||
const QVariantMap &data
|
||||
) {
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig;
|
||||
shared_ptr<linphone::Account> account;
|
||||
QString sipAddress = data["sipAddress"].toString();
|
||||
shared_ptr<linphone::Address> address = CoreManager::getInstance()->getCore()->interpretUrl(sipAddress.toStdString());
|
||||
|
||||
for (const auto &databaseProxyConfig : CoreManager::getInstance()->getCore()->getProxyConfigList())
|
||||
if (databaseProxyConfig->getIdentityAddress()->weakEqual(address)) {
|
||||
proxyConfig = databaseProxyConfig;
|
||||
for (const auto &databaseAccount : CoreManager::getInstance()->getCore()->getAccountList())
|
||||
if (databaseAccount->getParams()->getIdentityAddress()->weakEqual(address)) {
|
||||
account = databaseAccount;
|
||||
}
|
||||
if(!proxyConfig)
|
||||
proxyConfig = createProxyConfig(data.contains("configFilename") ? data["configFilename"].toString() : "create-app-sip-account.rc" );
|
||||
return addOrUpdateProxyConfig(proxyConfig, data);
|
||||
if(!account)
|
||||
account = createAccount(data.contains("configFilename") ? data["configFilename"].toString() : "create-app-sip-account.rc" );
|
||||
return addOrUpdateAccount(account, data);
|
||||
}
|
||||
|
||||
shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig (const QString& assistantFile) {
|
||||
shared_ptr<linphone::Account> AccountSettingsModel::createAccount(const QString& assistantFile) {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
qInfo() << QStringLiteral("Set config on assistant: `%1`.").arg(assistantFile);
|
||||
core->getConfig()->loadFromXmlFile(Paths::getAssistantConfigDirPath() + assistantFile.toStdString());
|
||||
return core->createProxyConfig();
|
||||
return core->createAccount(core->createAccountParams());
|
||||
}
|
||||
|
||||
void AccountSettingsModel::addAuthInfo (
|
||||
|
|
@ -421,8 +431,8 @@ void AccountSettingsModel::setUsername (const QString &username) {
|
|||
}
|
||||
|
||||
AccountSettingsModel::RegistrationState AccountSettingsModel::getRegistrationState () const {
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = CoreManager::getInstance()->getCore()->getDefaultProxyConfig();
|
||||
return proxyConfig ? mapLinphoneRegistrationStateToUi(proxyConfig->getState()) : RegistrationStateNoProxy;
|
||||
shared_ptr<linphone::Account> account = CoreManager::getInstance()->getCore()->getDefaultAccount();
|
||||
return account ? mapLinphoneRegistrationStateToUi(account->getState()) : RegistrationStateNoAccount;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -481,18 +491,18 @@ QVariantList AccountSettingsModel::getAccounts () const {
|
|||
account["fullSipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asString());
|
||||
account["unreadMessageCount"] = core->getUnreadChatMessageCountFromLocal(core->createPrimaryContactParsed());
|
||||
account["missedCallCount"] = CoreManager::getInstance()->getMissedCallCountFromLocal(account["sipAddress"].toString());
|
||||
account["proxyConfig"].setValue(nullptr);
|
||||
account["account"].setValue(nullptr);
|
||||
accounts << account;
|
||||
}
|
||||
|
||||
for (const auto &proxyConfig : core->getProxyConfigList()) {
|
||||
QVariantMap account;
|
||||
account["sipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asStringUriOnly());
|
||||
account["fullSipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString());
|
||||
account["proxyConfig"].setValue(proxyConfig);
|
||||
account["unreadMessageCount"] = proxyConfig->getUnreadChatMessageCount();
|
||||
account["missedCallCount"] = CoreManager::getInstance()->getMissedCallCountFromLocal(account["sipAddress"].toString());
|
||||
accounts << account;
|
||||
for (const auto &account : core->getAccountList()) {
|
||||
QVariantMap accountMap;
|
||||
accountMap["sipAddress"] = Utils::coreStringToAppString(account->getParams()->getIdentityAddress()->asStringUriOnly());
|
||||
accountMap["fullSipAddress"] = Utils::coreStringToAppString(account->getParams()->getIdentityAddress()->asString());
|
||||
accountMap["account"].setValue(account);
|
||||
accountMap["unreadMessageCount"] = account->getUnreadChatMessageCount();
|
||||
accountMap["missedCallCount"] = CoreManager::getInstance()->getMissedCallCountFromLocal(accountMap["sipAddress"].toString());
|
||||
accounts << accountMap;
|
||||
}
|
||||
|
||||
return accounts;
|
||||
|
|
@ -501,28 +511,27 @@ QVariantList AccountSettingsModel::getAccounts () const {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void AccountSettingsModel::handleRegistrationStateChanged (
|
||||
const shared_ptr<linphone::ProxyConfig> & proxy,
|
||||
const shared_ptr<linphone::Account> & account,
|
||||
linphone::RegistrationState state
|
||||
) {
|
||||
Q_UNUSED(proxy)
|
||||
Q_UNUSED(state)
|
||||
auto coreManager = CoreManager::getInstance();
|
||||
shared_ptr<linphone::ProxyConfig> defaultProxyConfig = coreManager->getCore()->getDefaultProxyConfig();
|
||||
shared_ptr<linphone::Account> defaultAccount = coreManager->getCore()->getDefaultAccount();
|
||||
if( state == linphone::RegistrationState::Cleared){
|
||||
auto authInfo = proxy->findAuthInfo();
|
||||
auto authInfo = account->findAuthInfo();
|
||||
if(authInfo)
|
||||
QTimer::singleShot(60000, [authInfo](){// 60s is just to be sure. proxy_update remove deleted proxy only after 32s
|
||||
QTimer::singleShot(60000, [authInfo](){// 60s is just to be sure. account_update remove deleted account only after 32s
|
||||
CoreManager::getInstance()->getCore()->removeAuthInfo(authInfo);
|
||||
});
|
||||
coreManager->getSettingsModel()->configureRlsUri();
|
||||
}else if(mRemovingProxies.contains(proxy)){
|
||||
mRemovingProxies.removeAll(proxy);
|
||||
QTimer::singleShot(100, [proxy, this](){// removeProxyConfig cannot be called from callback
|
||||
CoreManager::getInstance()->getCore()->removeProxyConfig(proxy);
|
||||
}else if(mRemovingAccounts.contains(account)){
|
||||
mRemovingAccounts.removeAll(account);
|
||||
QTimer::singleShot(100, [account, this](){// removeAccount cannot be called from callback
|
||||
CoreManager::getInstance()->getCore()->removeAccount(account);
|
||||
emit accountsChanged();
|
||||
});
|
||||
}
|
||||
if(defaultProxyConfig == proxy)
|
||||
if(defaultAccount == account)
|
||||
emit defaultRegistrationChanged();
|
||||
emit registrationStateChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,113 +31,115 @@
|
|||
// =============================================================================
|
||||
|
||||
class AccountSettingsModel : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
// Selected proxy config.
|
||||
Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY usernameChanged)
|
||||
Q_PROPERTY(QString sipAddress READ getUsedSipAddressAsStringUriOnly NOTIFY sipAddressChanged)
|
||||
Q_PROPERTY(QString fullSipAddress READ getUsedSipAddressAsString NOTIFY fullSipAddressChanged)
|
||||
Q_PROPERTY(RegistrationState registrationState READ getRegistrationState NOTIFY registrationStateChanged)
|
||||
|
||||
Q_PROPERTY(QString conferenceURI READ getConferenceURI NOTIFY conferenceURIChanged)
|
||||
|
||||
// Default info.
|
||||
Q_PROPERTY(QString primaryDisplayName READ getPrimaryDisplayName WRITE setPrimaryDisplayName NOTIFY primaryDisplayNameChanged)
|
||||
Q_PROPERTY(QString primaryUsername READ getPrimaryUsername WRITE setPrimaryUsername NOTIFY primaryUsernameChanged)
|
||||
Q_PROPERTY(QString primarySipAddress READ getPrimarySipAddress NOTIFY primarySipAddressChanged)
|
||||
|
||||
Q_PROPERTY(QVariantList accounts READ getAccounts NOTIFY accountsChanged)
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
// Selected account.
|
||||
Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY usernameChanged)
|
||||
Q_PROPERTY(QString sipAddress READ getUsedSipAddressAsStringUriOnly NOTIFY sipAddressChanged)
|
||||
Q_PROPERTY(QString fullSipAddress READ getUsedSipAddressAsString NOTIFY fullSipAddressChanged)
|
||||
Q_PROPERTY(RegistrationState registrationState READ getRegistrationState NOTIFY registrationStateChanged)
|
||||
|
||||
Q_PROPERTY(QString conferenceURI READ getConferenceURI NOTIFY conferenceURIChanged)
|
||||
|
||||
// Default info.
|
||||
Q_PROPERTY(QString primaryDisplayName READ getPrimaryDisplayName WRITE setPrimaryDisplayName NOTIFY primaryDisplayNameChanged)
|
||||
Q_PROPERTY(QString primaryUsername READ getPrimaryUsername WRITE setPrimaryUsername NOTIFY primaryUsernameChanged)
|
||||
Q_PROPERTY(QString primarySipAddress READ getPrimarySipAddress NOTIFY primarySipAddressChanged)
|
||||
|
||||
Q_PROPERTY(QVariantList accounts READ getAccounts NOTIFY accountsChanged)
|
||||
|
||||
public:
|
||||
enum RegistrationState {
|
||||
RegistrationStateRegistered,
|
||||
RegistrationStateNotRegistered,
|
||||
RegistrationStateInProgress,
|
||||
RegistrationStateNoProxy,
|
||||
};
|
||||
Q_ENUM(RegistrationState);
|
||||
|
||||
AccountSettingsModel (QObject *parent = Q_NULLPTR);
|
||||
|
||||
std::shared_ptr<const linphone::Address> getUsedSipAddress () const;
|
||||
void setUsedSipAddress (const std::shared_ptr<const linphone::Address> &address);
|
||||
|
||||
QString getUsedSipAddressAsStringUriOnly () const;
|
||||
QString getUsedSipAddressAsString () const;
|
||||
|
||||
bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
|
||||
|
||||
Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
|
||||
QString getConferenceURI() const;
|
||||
|
||||
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig = nullptr);
|
||||
Q_INVOKABLE void setDefaultProxyConfigFromSipAddress (const QString &sipAddress);
|
||||
|
||||
Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, const QVariantMap &data);
|
||||
Q_INVOKABLE bool addOrUpdateProxyConfig (const QVariantMap &data);// Create default proxy config and apply data
|
||||
Q_INVOKABLE void removeProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
|
||||
|
||||
Q_INVOKABLE std::shared_ptr<linphone::ProxyConfig> createProxyConfig (const QString& assistantFile);
|
||||
|
||||
Q_INVOKABLE void addAuthInfo (
|
||||
const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
||||
const QString &password,
|
||||
const QString &userId
|
||||
);
|
||||
|
||||
Q_INVOKABLE void eraseAllPasswords ();
|
||||
|
||||
enum RegistrationState {
|
||||
RegistrationStateRegistered,
|
||||
RegistrationStateNotRegistered,
|
||||
RegistrationStateInProgress,
|
||||
RegistrationStateNoAccount,
|
||||
};
|
||||
Q_ENUM(RegistrationState);
|
||||
|
||||
AccountSettingsModel (QObject *parent = Q_NULLPTR);
|
||||
|
||||
std::shared_ptr<const linphone::Address> getUsedSipAddress () const;
|
||||
void setUsedSipAddress (const std::shared_ptr<const linphone::Address> &address);
|
||||
|
||||
QString getUsedSipAddressAsStringUriOnly () const;
|
||||
QString getUsedSipAddressAsString () const;
|
||||
|
||||
// Update account with parameters or add a new one in core.
|
||||
bool addOrUpdateAccount (std::shared_ptr<linphone::Account> account, const std::shared_ptr<linphone::AccountParams>& accountParams);
|
||||
|
||||
Q_INVOKABLE QVariantMap getAccountDescription (const std::shared_ptr<linphone::Account> &account);
|
||||
QString getConferenceURI() const;
|
||||
|
||||
Q_INVOKABLE void setDefaultAccount (const std::shared_ptr<linphone::Account> &account = nullptr);
|
||||
Q_INVOKABLE void setDefaultAccountFromSipAddress (const QString &sipAddress);
|
||||
|
||||
Q_INVOKABLE bool addOrUpdateAccount (const std::shared_ptr<linphone::Account> &account, const QVariantMap &data);
|
||||
Q_INVOKABLE bool addOrUpdateAccount (const QVariantMap &data);// Create default account and apply data
|
||||
Q_INVOKABLE void removeAccount (const std::shared_ptr<linphone::Account> &account);
|
||||
|
||||
Q_INVOKABLE std::shared_ptr<linphone::Account> createAccount (const QString& assistantFile);
|
||||
|
||||
Q_INVOKABLE void addAuthInfo (
|
||||
const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
||||
const QString &password,
|
||||
const QString &userId
|
||||
);
|
||||
|
||||
Q_INVOKABLE void eraseAllPasswords ();
|
||||
|
||||
signals:
|
||||
|
||||
void usernameChanged();
|
||||
void sipAddressChanged();
|
||||
void fullSipAddressChanged();
|
||||
void registrationStateChanged();
|
||||
void conferenceURIChanged();
|
||||
|
||||
void primaryDisplayNameChanged();
|
||||
void primaryUsernameChanged();
|
||||
void primarySipAddressChanged();
|
||||
|
||||
void accountsChanged();
|
||||
|
||||
|
||||
|
||||
void accountSettingsUpdated ();
|
||||
void defaultProxyChanged();
|
||||
void publishPresenceChanged();
|
||||
void defaultRegistrationChanged();
|
||||
|
||||
|
||||
void usernameChanged();
|
||||
void sipAddressChanged();
|
||||
void fullSipAddressChanged();
|
||||
void registrationStateChanged();
|
||||
void conferenceURIChanged();
|
||||
|
||||
void primaryDisplayNameChanged();
|
||||
void primaryUsernameChanged();
|
||||
void primarySipAddressChanged();
|
||||
|
||||
void accountsChanged();
|
||||
|
||||
|
||||
|
||||
void accountSettingsUpdated ();
|
||||
void defaultAccountChanged();
|
||||
void publishPresenceChanged();
|
||||
void defaultRegistrationChanged();
|
||||
|
||||
private:
|
||||
QString getUsername () const;
|
||||
void setUsername (const QString &username);
|
||||
|
||||
RegistrationState getRegistrationState () const;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QString getPrimaryUsername () const;
|
||||
void setPrimaryUsername (const QString &username);
|
||||
|
||||
QString getPrimaryDisplayName () const;
|
||||
void setPrimaryDisplayName (const QString &displayName);
|
||||
|
||||
QString getPrimarySipAddress () const;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QVariantList getAccounts () const;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void handleRegistrationStateChanged (
|
||||
const std::shared_ptr<linphone::ProxyConfig> &proxyConfig,
|
||||
linphone::RegistrationState state
|
||||
);
|
||||
|
||||
QVector<std::shared_ptr<linphone::ProxyConfig> > mRemovingProxies;
|
||||
QString getUsername () const;
|
||||
void setUsername (const QString &username);
|
||||
|
||||
RegistrationState getRegistrationState () const;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QString getPrimaryUsername () const;
|
||||
void setPrimaryUsername (const QString &username);
|
||||
|
||||
QString getPrimaryDisplayName () const;
|
||||
void setPrimaryDisplayName (const QString &displayName);
|
||||
|
||||
QString getPrimarySipAddress () const;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QVariantList getAccounts () const;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void handleRegistrationStateChanged (
|
||||
const std::shared_ptr<linphone::Account> &account,
|
||||
linphone::RegistrationState state
|
||||
);
|
||||
|
||||
QVector<std::shared_ptr<linphone::Account> > mRemovingAccounts;
|
||||
std::shared_ptr<linphone::Account> mSelectedAccount;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::ProxyConfig>);
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::Account>);
|
||||
|
||||
#endif // ACCOUNT_SETTINGS_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -1212,8 +1212,8 @@ void SettingsModel::configureRlsUri () {
|
|||
|
||||
// Set rls uri if necessary.
|
||||
const string domain = getRlsUriDomain();
|
||||
for (const auto &proxyConfig : CoreManager::getInstance()->getCore()->getProxyConfigList())
|
||||
if (proxyConfig->getDomain() == domain) {
|
||||
for (const auto &account : CoreManager::getInstance()->getCore()->getAccountList())
|
||||
if (account->getParams()->getDomain() == domain) {
|
||||
mConfig->setString("sip", "rls_uri", Constants::DefaultRlsUri);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1221,21 +1221,23 @@ void SettingsModel::configureRlsUri () {
|
|||
mConfig->setString("sip", "rls_uri", "");
|
||||
}
|
||||
|
||||
void SettingsModel::configureRlsUri (const shared_ptr<const linphone::ProxyConfig> &proxyConfig) {
|
||||
void SettingsModel::configureRlsUri (const std::string& domain) {
|
||||
if (!getRlsUriEnabled()) {
|
||||
mConfig->setString("sip", "rls_uri", "");
|
||||
return;
|
||||
}
|
||||
|
||||
const string domain = getRlsUriDomain();
|
||||
if (proxyConfig->getDomain() == domain) {
|
||||
const string currentDomain = getRlsUriDomain();
|
||||
if (domain == currentDomain) {
|
||||
mConfig->setString("sip", "rls_uri", Constants::DefaultRlsUri);
|
||||
return;
|
||||
}
|
||||
|
||||
mConfig->setString("sip", "rls_uri", "");
|
||||
}
|
||||
|
||||
void SettingsModel::configureRlsUri (const shared_ptr<const linphone::Account> &account) {
|
||||
configureRlsUri(account->getParams()->getDomain());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::tunnelAvailable() const{
|
||||
|
|
|
|||
|
|
@ -474,7 +474,8 @@ public:
|
|||
void setRlsUriEnabled (bool status);
|
||||
|
||||
void configureRlsUri ();
|
||||
void configureRlsUri (const std::shared_ptr<const linphone::ProxyConfig> &proxyConfig);
|
||||
void configureRlsUri (const std::string& domain);
|
||||
void configureRlsUri (const std::shared_ptr<const linphone::Account> &account);
|
||||
|
||||
Q_INVOKABLE bool tunnelAvailable() const;
|
||||
Q_INVOKABLE TunnelModel * getTunnel() const;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -161,7 +161,7 @@ QVariantList TimelineListModel::getLastChatRooms(const int& maxCount) const{
|
|||
|
||||
for(auto timeline : mTimelines){
|
||||
auto chatRoom = timeline->getChatRoomModel();
|
||||
if(chatRoom && chatRoom->isCurrentProxy() && chatRoom->isOneToOne() && !chatRoom->haveEncryption()) {
|
||||
if(chatRoom && chatRoom->isCurrentAccount() && chatRoom->isOneToOne() && !chatRoom->haveEncryption()) {
|
||||
sortedData.insert(chatRoom->mLastUpdateTime.secsTo(currentDateTime),chatRoom);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ TimelineModel::TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObj
|
|||
if( mChatRoomModel ){
|
||||
CoreManager::getInstance()->handleChatRoomCreated(mChatRoomModel);
|
||||
QObject::connect(this, &TimelineModel::selectedChanged, this, &TimelineModel::updateUnreadCount);
|
||||
QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultProxyChanged, this, &TimelineModel::onDefaultProxyChanged);
|
||||
QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultAccountChanged, this, &TimelineModel::onDefaultAccountChanged);
|
||||
}
|
||||
mSelected = false;
|
||||
}
|
||||
|
|
@ -142,8 +142,8 @@ void TimelineModel::updateUnreadCount(){
|
|||
mChatRoomModel->resetMessageCount();// The reset will appear when the chat room has "mark as read enabled", that means that we should have read messages when going out.
|
||||
}
|
||||
}
|
||||
void TimelineModel::onDefaultProxyChanged(){
|
||||
if( mSelected && !mChatRoomModel->isCurrentProxy())
|
||||
void TimelineModel::onDefaultAccountChanged(){
|
||||
if( mSelected && !mChatRoomModel->isCurrentAccount())
|
||||
setSelected(false);
|
||||
}
|
||||
//----------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public:
|
|||
|
||||
public slots:
|
||||
void updateUnreadCount();
|
||||
void onDefaultProxyChanged();
|
||||
void onDefaultAccountChanged();
|
||||
//void chatRoomDeleted();
|
||||
|
||||
signals:
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ TimelineProxyModel::TimelineProxyModel (QObject *parent) : QSortFilterProxyModel
|
|||
connect(model, &TimelineListModel::selectedChanged, this, &TimelineProxyModel::selectedChanged);
|
||||
connect(model, &TimelineListModel::countChanged, this, &TimelineProxyModel::countChanged);
|
||||
|
||||
QObject::connect(accountSettingsModel, &AccountSettingsModel::defaultProxyChanged, this, [this]() {
|
||||
QObject::connect(accountSettingsModel, &AccountSettingsModel::defaultAccountChanged, this, [this]() {
|
||||
dynamic_cast<TimelineListModel*>(sourceModel())->update();
|
||||
invalidate();
|
||||
//updateCurrentSelection();
|
||||
|
|
@ -117,7 +117,7 @@ bool TimelineProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sou
|
|||
//|| timeline->getChatRoomModel()->getFullPeerAddress().contains(search); not enough significant?
|
||||
}
|
||||
if(show)
|
||||
show = timeline->getChatRoomModel()->isCurrentProxy();
|
||||
show = timeline->getChatRoomModel()->isCurrentAccount();
|
||||
return show;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,4 +81,28 @@ linphone::RecorderState LinphoneEnums::toLinphone(const LinphoneEnums::RecorderS
|
|||
}
|
||||
LinphoneEnums::RecorderState LinphoneEnums::fromLinphone(const linphone::RecorderState& data){
|
||||
return static_cast<LinphoneEnums::RecorderState>(data);
|
||||
}
|
||||
|
||||
linphone::TransportType LinphoneEnums::toLinphone(const LinphoneEnums::TransportType& type){
|
||||
return static_cast<linphone::TransportType>(type);
|
||||
}
|
||||
LinphoneEnums::TransportType LinphoneEnums::fromLinphone(const linphone::TransportType& type){
|
||||
return static_cast<LinphoneEnums::TransportType>(type);
|
||||
}
|
||||
QString LinphoneEnums::toString(const LinphoneEnums::TransportType& type){
|
||||
switch(type) {
|
||||
case TransportTypeTcp: return "TCP";
|
||||
case TransportTypeUdp: return "UDP";
|
||||
case TransportTypeTls: return "TLS";
|
||||
case TransportTypeDtls: return "DTLS";
|
||||
}
|
||||
}
|
||||
void LinphoneEnums::fromString(const QString& transportType, LinphoneEnums::TransportType *transport){
|
||||
if (transportType.toUpper() == QLatin1String("TCP"))
|
||||
*transport = TransportTypeTcp;
|
||||
if (transportType.toUpper() == QLatin1String("UDP"))
|
||||
*transport = TransportTypeUdp;
|
||||
if (transportType.toUpper() == QLatin1String("TLS"))
|
||||
*transport = TransportTypeTls;
|
||||
*transport = TransportTypeDtls;
|
||||
}
|
||||
|
|
@ -60,8 +60,8 @@ enum EventLogType {
|
|||
EventLogTypeNone = int(linphone::EventLog::Type::None),
|
||||
EventLogTypeConferenceCreated = int(linphone::EventLog::Type::ConferenceCreated),
|
||||
EventLogTypeConferenceTerminated = int(linphone::EventLog::Type::ConferenceTerminated),
|
||||
EventLogTypeConferenceCallStart = int(linphone::EventLog::Type::ConferenceCallStart),
|
||||
EventLogTypeConferenceCallEnd = int(linphone::EventLog::Type::ConferenceCallEnd),
|
||||
EventLogTypeConferenceCallStarted = int(linphone::EventLog::Type::ConferenceCallStarted),
|
||||
EventLogTypeConferenceCallEnded = int(linphone::EventLog::Type::ConferenceCallEnded),
|
||||
EventLogTypeConferenceChatMessage = int(linphone::EventLog::Type::ConferenceChatMessage),
|
||||
EventLogTypeConferenceParticipantAdded = int(linphone::EventLog::Type::ConferenceParticipantAdded),
|
||||
EventLogTypeConferenceParticipantRemoved = int(linphone::EventLog::Type::ConferenceParticipantRemoved),
|
||||
|
|
@ -69,7 +69,7 @@ enum EventLogType {
|
|||
EventLogTypeConferenceParticipantUnsetAdmin = int(linphone::EventLog::Type::ConferenceParticipantUnsetAdmin),
|
||||
EventLogTypeConferenceParticipantDeviceAdded = int(linphone::EventLog::Type::ConferenceParticipantDeviceAdded),
|
||||
EventLogTypeConferenceParticipantDeviceRemoved = int(linphone::EventLog::Type::ConferenceParticipantDeviceRemoved),
|
||||
EventLogTypeConferenceParticipantDeviceMediaChanged = int(linphone::EventLog::Type::ConferenceParticipantDeviceMediaChanged),
|
||||
//EventLogTypeConferenceParticipantDeviceMediaChanged = int(linphone::EventLog::Type::ConferenceParticipantDeviceMediaChanged),
|
||||
EventLogTypeConferenceSubjectChanged= int(linphone::EventLog::Type::ConferenceSubjectChanged),
|
||||
EventLogTypeConferenceAvailableMediaChanged = int(linphone::EventLog::Type::ConferenceAvailableMediaChanged),
|
||||
EventLogTypeConferenceSecurityEvent = int(linphone::EventLog::Type::ConferenceSecurityEvent),
|
||||
|
|
@ -131,6 +131,19 @@ Q_ENUM_NS(RecorderState)
|
|||
|
||||
linphone::RecorderState toLinphone(const LinphoneEnums::RecorderState& state);
|
||||
LinphoneEnums::RecorderState fromLinphone(const linphone::RecorderState& state);
|
||||
|
||||
enum TransportType{
|
||||
TransportTypeDtls = int(linphone::TransportType::Dtls),
|
||||
TransportTypeTcp = int(linphone::TransportType::Tcp),
|
||||
TransportTypeTls = int(linphone::TransportType::Tls),
|
||||
TransportTypeUdp = int(linphone::TransportType::Udp)
|
||||
};
|
||||
Q_ENUM_NS(TransportType)
|
||||
|
||||
linphone::TransportType toLinphone(const LinphoneEnums::TransportType& type);
|
||||
LinphoneEnums::TransportType fromLinphone(const linphone::TransportType& type);
|
||||
QString toString(const LinphoneEnums::TransportType& type);
|
||||
void fromString(const QString& transportType, LinphoneEnums::TransportType *transport);
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(LinphoneEnums::MediaEncryption)
|
||||
|
|
|
|||
|
|
@ -41,17 +41,6 @@ constexpr int SafeFilePathLimit = 100;
|
|||
|
||||
}
|
||||
|
||||
linphone::TransportType Utils::stringToTransportType (const QString &transport) {
|
||||
if (transport == QLatin1String("TCP"))
|
||||
return linphone::TransportType::Tcp;
|
||||
if (transport == QLatin1String("UDP"))
|
||||
return linphone::TransportType::Udp;
|
||||
if (transport == QLatin1String("TLS"))
|
||||
return linphone::TransportType::Tls;
|
||||
|
||||
return linphone::TransportType::Dtls;
|
||||
}
|
||||
|
||||
std::shared_ptr<linphone::Address> Utils::interpretUrl(const QString& address){
|
||||
return CoreManager::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(address));
|
||||
}
|
||||
|
|
@ -151,11 +140,11 @@ QString Utils::getSafeFilePath (const QString &filePath, bool *soFarSoGood) {
|
|||
}
|
||||
std::shared_ptr<linphone::Address> Utils::getMatchingLocalAddress(std::shared_ptr<linphone::Address> p_localAddress){
|
||||
QVector<std::shared_ptr<linphone::Address> > addresses;
|
||||
// Get default proxy
|
||||
// Get default account
|
||||
addresses.push_back(CoreManager::getInstance()->getCore()->createPrimaryContactParsed());
|
||||
auto proxyList = CoreManager::getInstance()->getCore()->getProxyConfigList();
|
||||
foreach(auto proxy, proxyList)
|
||||
addresses.push_back(proxy->getIdentityAddress()->clone());
|
||||
auto accounts = CoreManager::getInstance()->getCore()->getAccountList();
|
||||
foreach(auto account, accounts)
|
||||
addresses.push_back(account->getParams()->getIdentityAddress()->clone());
|
||||
foreach(auto address, addresses){
|
||||
if( address->getUsername() == p_localAddress->getUsername() && address->getDomain() == p_localAddress->getDomain())
|
||||
return address;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ public:
|
|||
|
||||
return connection;
|
||||
}
|
||||
static linphone::TransportType stringToTransportType (const QString &transport);
|
||||
static std::shared_ptr<linphone::Address> interpretUrl(const QString& address);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ RowLayout{
|
|||
//: 'You have left the group' : Little message to show on the event when the user leave the chat group.
|
||||
return qsTr('conferenceCreatedTerminated');
|
||||
}
|
||||
if (status == LinphoneEnums.EventLogTypeConferenceCallStart) {
|
||||
return 'EventLogTypeConferenceCallStart';
|
||||
if (status == LinphoneEnums.EventLogTypeConferenceCallStarted) {
|
||||
return 'EventLogTypeConferenceCallStarted';
|
||||
}
|
||||
if (status == LinphoneEnums.EventLogTypeConferenceCallEnd) {
|
||||
return 'EventLogTypeConferenceCallEnd';
|
||||
if (status == LinphoneEnums.EventLogTypeConferenceCallEnded) {
|
||||
return 'EventLogTypeConferenceCallEnded';
|
||||
}
|
||||
if (status == LinphoneEnums.EventLogTypeConferenceChatMessage) {
|
||||
return 'EventLogTypeConferenceChatMessage';
|
||||
|
|
@ -60,9 +60,9 @@ RowLayout{
|
|||
if (status == LinphoneEnums.EventLogTypeConferenceParticipantDeviceRemoved) {
|
||||
return 'EventLogTypeConferenceParticipantDeviceRemoved';
|
||||
}
|
||||
if (status == LinphoneEnums.EventLogTypeConferenceParticipantDeviceMediaChanged) {
|
||||
return 'EventLogTypeConferenceParticipantDeviceMediaChanged';
|
||||
}
|
||||
//if (status == LinphoneEnums.EventLogTypeConferenceParticipantDeviceMediaChanged) {
|
||||
//return 'EventLogTypeConferenceParticipantDeviceMediaChanged';
|
||||
//}
|
||||
if (status == LinphoneEnums.EventLogTypeConferenceAvailableMediaChanged) {
|
||||
return 'EventLogTypeConferenceAvailableMediaChanged';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ Notification {
|
|||
anchors.fill: parent
|
||||
|
||||
onClicked: notification._close(function () {
|
||||
AccountSettingsModel.setDefaultProxyConfigFromSipAddress(notification.localAddress)
|
||||
AccountSettingsModel.setDefaultAccountFromSipAddress(notification.localAddress)
|
||||
notification.timelineModel.selected = true
|
||||
console.log("Load conversation from notification")
|
||||
notification.notificationData.window.setView('Conversation', {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ AssistantAbstractView {
|
|||
console.log("[CreateAccount] Username : " +result.username);
|
||||
console.log("[CreateAccount] Registrar : " +result.registrar_address);
|
||||
console.log("[CreateAccount] Domain : " +result.domain);
|
||||
if (Linphone.AccountSettingsModel.addOrUpdateProxyConfig( {
|
||||
if (Linphone.AccountSettingsModel.addOrUpdateAccount( {
|
||||
sipAddress: result.sip,
|
||||
serverAddress: result.registrar_address,
|
||||
configFilename: view.configFilename
|
||||
|
|
@ -65,7 +65,7 @@ AssistantAbstractView {
|
|||
|
||||
console.log("[CreateAccount] Account created")
|
||||
view.status = 1
|
||||
Linphone.AccountSettingsModel.setDefaultProxyConfigFromSipAddress("sip:"+result.sip)
|
||||
Linphone.AccountSettingsModel.setDefaultAccountFromSipAddress("sip:"+result.sip)
|
||||
} else {
|
||||
console.error("[CreateAccount] Cannot create account. Check logs.")
|
||||
view.status = -1
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@
|
|||
// =============================================================================
|
||||
|
||||
function getItemIcon (data) {
|
||||
var proxyConfig = data.proxyConfig
|
||||
if (!proxyConfig) {
|
||||
var account = data.account
|
||||
if (!account) {
|
||||
return ''
|
||||
}
|
||||
|
||||
var description = AccountSettingsModel.getProxyConfigDescription(proxyConfig)
|
||||
var description = AccountSettingsModel.getAccountDescription(account)
|
||||
return description.registerEnabled && description.registrationState !== AccountSettingsModel.RegistrationStateRegistered
|
||||
? 'generic_error'
|
||||
: ''
|
||||
|
|
|
|||
|
|
@ -96,10 +96,10 @@ DialogPlus {
|
|||
|
||||
onClicked: {
|
||||
container.currentIndex = index
|
||||
if(flattenedModel.proxyConfig)
|
||||
AccountSettingsModel.setDefaultProxyConfig(flattenedModel.proxyConfig)
|
||||
if(flattenedModel.account)
|
||||
AccountSettingsModel.setDefaultAccount(flattenedModel.account)
|
||||
else
|
||||
AccountSettingsModel.setDefaultProxyConfig()
|
||||
AccountSettingsModel.setDefaultAccount()
|
||||
}
|
||||
|
||||
MessageCounter {
|
||||
|
|
|
|||
|
|
@ -27,16 +27,16 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
var proxyConfig
|
||||
var gAccount
|
||||
|
||||
function initForm (account) {
|
||||
var AccountSettingsModel = Linphone.AccountSettingsModel
|
||||
|
||||
proxyConfig = account
|
||||
? account.proxyConfig
|
||||
: AccountSettingsModel.createProxyConfig()
|
||||
gAccount = account
|
||||
? account.account
|
||||
: AccountSettingsModel.createAccount()
|
||||
|
||||
var config = AccountSettingsModel.getProxyConfigDescription(proxyConfig)
|
||||
var config = AccountSettingsModel.getAccountDescription(gAccount)
|
||||
|
||||
sipAddress.text = config.sipAddress
|
||||
serverAddress.text = config.serverAddress
|
||||
|
|
@ -76,7 +76,7 @@ function formIsValid () {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function validProxyConfig (proxyConfig) {
|
||||
function validAccount (account) {
|
||||
var data = {
|
||||
sipAddress: sipAddress.text,
|
||||
serverAddress: serverAddress.text,
|
||||
|
|
@ -96,8 +96,8 @@ function validProxyConfig (proxyConfig) {
|
|||
turnPassword: turnPassword.text
|
||||
}
|
||||
|
||||
if (proxyConfig && Linphone.AccountSettingsModel.addOrUpdateProxyConfig(proxyConfig, data)
|
||||
|| !proxyConfig && Linphone.AccountSettingsModel.addOrUpdateProxyConfig(data)) {
|
||||
if (gAccount && Linphone.AccountSettingsModel.addOrUpdateAccount(gAccount, data)
|
||||
|| !account && Linphone.AccountSettingsModel.addOrUpdateAccount(data)) {
|
||||
dialog.exit(1)
|
||||
} else {
|
||||
// TODO: Display errors on the form (if necessary).
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ DialogPlus {
|
|||
enabled: Logic.formIsValid()
|
||||
text: qsTr('confirm')
|
||||
|
||||
onClicked: Logic.validProxyConfig(dialog.account ? dialog.account.proxyConfig : null)
|
||||
onClicked: Logic.validAccount(dialog.account ? dialog.account.account : null)
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function deleteAccount (account) {
|
|||
descriptionText: qsTr('deleteAccountDescription'),
|
||||
}, function (status) {
|
||||
if (status) {
|
||||
Linphone.AccountSettingsModel.removeProxyConfig(account.proxyConfig)
|
||||
Linphone.AccountSettingsModel.removeAccount(account.account)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit fdfb9a2c8de008c4fedc9bd2a9f08459bfa7ec2d
|
||||
Subproject commit 28110434a26de7d9eaec988ce045504d5818e385
|
||||
Loading…
Add table
Reference in a new issue