aboutsummaryrefslogtreecommitdiff
path: root/src/myself.cpp
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2016-03-31 16:53:36 -0300
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:37:39 +0200
commit676b6c35768e707710a7121ed9f71002c6226bd7 (patch)
tree977ef722a17e907a2d79beb33f0581fe43dd16ae /src/myself.cpp
parentb13d57194646736652610fd68793aa8f2a260566 (diff)
downloadayatana-indicator-datetime-676b6c35768e707710a7121ed9f71002c6226bd7.tar.gz
ayatana-indicator-datetime-676b6c35768e707710a7121ed9f71002c6226bd7.tar.bz2
ayatana-indicator-datetime-676b6c35768e707710a7121ed9f71002c6226bd7.zip
Update code as requested by reviewer.
Diffstat (limited to 'src/myself.cpp')
-rw-r--r--src/myself.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/myself.cpp b/src/myself.cpp
index 04c2126..0debfe4 100644
--- a/src/myself.cpp
+++ b/src/myself.cpp
@@ -41,8 +41,7 @@ Myself::Myself()
bool Myself::isMyEmail(const std::string &email)
{
- auto emails = m_emails.get();
- return (std::find(emails.begin(), emails.end(), email) != emails.end());
+ return m_emails.get().count(email) > 0;
}
void Myself::on_accounts_changed(AgManager *, guint, Myself *self)
@@ -52,15 +51,19 @@ void Myself::on_accounts_changed(AgManager *, guint, Myself *self)
void Myself::reloadEmails()
{
- std::vector<std::string> emails;
+ std::set<std::string> emails;
auto manager = m_accounts_manager.get();
auto ids = ag_manager_list(manager);
for (auto l=ids; l!=nullptr; l=l->next)
{
auto acc = ag_manager_get_account(manager, GPOINTER_TO_UINT(l->data));
- auto account_name = ag_account_get_display_name(acc);
- emails.push_back(account_name);
+ if (acc) {
+ auto account_name = ag_account_get_display_name(acc);
+ if (account_name != nullptr)
+ emails.insert(account_name);
+ g_object_unref(acc);
+ }
}
ag_manager_list_free(ids);