Commit c0686613 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/assistant/AssistantModel): provide a `dealWithPhoneNumber` function

parent 3633ee50
...@@ -32,6 +32,10 @@ using namespace std; ...@@ -32,6 +32,10 @@ using namespace std;
// ============================================================================= // =============================================================================
inline bool dealWithPhoneNumber (const shared_ptr<linphone::AccountCreator> &creator) {
return creator->getEmail().empty();
}
class AssistantModel::Handlers : public linphone::AccountCreatorListener { class AssistantModel::Handlers : public linphone::AccountCreatorListener {
public: public:
Handlers (AssistantModel *assistant) { Handlers (AssistantModel *assistant) {
...@@ -83,7 +87,7 @@ private: ...@@ -83,7 +87,7 @@ private:
status == linphone::AccountCreatorStatusAccountActivated || status == linphone::AccountCreatorStatusAccountActivated ||
status == linphone::AccountCreatorStatusAccountAlreadyActivated status == linphone::AccountCreatorStatusAccountAlreadyActivated
) { ) {
if (creator->getEmail().empty()) { if (dealWithPhoneNumber(creator)) {
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig(); shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
Q_ASSERT(proxyConfig != nullptr); Q_ASSERT(proxyConfig != nullptr);
} }
...@@ -151,7 +155,7 @@ AssistantModel::AssistantModel (QObject *parent) : QObject(parent) { ...@@ -151,7 +155,7 @@ AssistantModel::AssistantModel (QObject *parent) : QObject(parent) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AssistantModel::activate () { void AssistantModel::activate () {
if (mAccountCreator->getEmail().empty()) if (dealWithPhoneNumber(mAccountCreator))
mAccountCreator->activateAccount(); mAccountCreator->activateAccount();
else else
mAccountCreator->isAccountActivated(); mAccountCreator->isAccountActivated();
...@@ -162,7 +166,7 @@ void AssistantModel::create () { ...@@ -162,7 +166,7 @@ void AssistantModel::create () {
} }
void AssistantModel::login () { void AssistantModel::login () {
if (mAccountCreator->getEmail().empty()) if (dealWithPhoneNumber(mAccountCreator))
mAccountCreator->recoverAccount(); mAccountCreator->recoverAccount();
else else
mAccountCreator->isAccountExist(); mAccountCreator->isAccountExist();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment