|
|
@ -151,13 +151,29 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
AddressBook::AddressBook (): m_IsLoaded (false), m_IsDownloading (false), |
|
|
|
AddressBook::AddressBook (): m_Storage (nullptr), m_IsLoaded (false), m_IsDownloading (false), |
|
|
|
m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr) |
|
|
|
m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AddressBook::~AddressBook () |
|
|
|
AddressBook::~AddressBook () |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
Stop (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AddressBook::Start () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StartSubscriptions (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AddressBook::Stop () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StopSubscriptions (); |
|
|
|
|
|
|
|
if (m_SubscriptionsUpdateTimer) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delete m_SubscriptionsUpdateTimer; |
|
|
|
|
|
|
|
m_SubscriptionsUpdateTimer = nullptr; |
|
|
|
|
|
|
|
} |
|
|
|
if (m_IsDownloading) |
|
|
|
if (m_IsDownloading) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogInfo, "Subscription is downloading. Waiting for temination..."); |
|
|
|
LogPrint (eLogInfo, "Subscription is downloading. Waiting for temination..."); |
|
|
@ -171,16 +187,22 @@ namespace client |
|
|
|
std::this_thread::sleep_for (std::chrono::seconds (1)); // wait for 1 seconds
|
|
|
|
std::this_thread::sleep_for (std::chrono::seconds (1)); // wait for 1 seconds
|
|
|
|
} |
|
|
|
} |
|
|
|
LogPrint (eLogError, "Subscription download hangs"); |
|
|
|
LogPrint (eLogError, "Subscription download hangs"); |
|
|
|
|
|
|
|
m_IsDownloading = false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (m_Storage) |
|
|
|
if (m_Storage) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_Storage->Save (m_Addresses); |
|
|
|
m_Storage->Save (m_Addresses); |
|
|
|
delete m_Storage; |
|
|
|
delete m_Storage; |
|
|
|
|
|
|
|
m_Storage = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (m_DefaultSubscription) |
|
|
|
|
|
|
|
{ |
|
|
|
delete m_DefaultSubscription; |
|
|
|
delete m_DefaultSubscription; |
|
|
|
|
|
|
|
m_DefaultSubscription = nullptr; |
|
|
|
|
|
|
|
} |
|
|
|
for (auto it: m_Subscriptions) |
|
|
|
for (auto it: m_Subscriptions) |
|
|
|
delete it; |
|
|
|
delete it; |
|
|
|
delete m_SubscriptionsUpdateTimer; |
|
|
|
m_Subscriptions.clear (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AddressBookStorage * AddressBook::CreateStorage () |
|
|
|
AddressBookStorage * AddressBook::CreateStorage () |
|
|
|