Commit 8631cb81 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add infos about resources

parent 662fd032
......@@ -62,6 +62,7 @@ NewMailNotifierAgent::NewMailNotifierAgent( const QString &id )
Akonadi::AttributeFactory::registerAttribute<NewMailNotifierAttribute>();
new NewMailNotifierAdaptor( this );
initializeInstanceCache();
mIdentityManager = new KPIMIdentities::IdentityManager( false, this );
connect(mIdentityManager, SIGNAL(changed()), SLOT(slotIdentitiesChanged()));
slotIdentitiesChanged();
......@@ -74,6 +75,8 @@ NewMailNotifierAgent::NewMailNotifierAgent( const QString &id )
this, SLOT(slotInstanceStatusChanged(Akonadi::AgentInstance)) );
connect( Akonadi::AgentManager::self(), SIGNAL(instanceRemoved(Akonadi::AgentInstance)),
this, SLOT(slotInstanceRemoved(Akonadi::AgentInstance)) );
connect( Akonadi::AgentManager::self(), SIGNAL(instanceAdded(Akonadi::AgentInstance)),
this, SLOT(slotInstanceAdded(Akonadi::AgentInstance)) );
changeRecorder()->setMimeTypeMonitored( KMime::Message::mimeType() );
changeRecorder()->itemFetchScope().setCacheOnly( true );
......@@ -390,7 +393,8 @@ void NewMailNotifierAgent::slotShowNotifications()
hasUniqMessage = false;
}
}
texts.append( i18np( "One new email in %2", "%1 new emails in %2", it.value().count(), displayName ) );
texts.append( i18np( "One new email in %2 from \"%3\"", "%1 new emails in %2 from \"%3\"", it.value().count(), displayName,
mCacheResourceName.value(it.key().resource()) ) );
}
if (hasUniqMessage) {
SpecialNotifierJob *job = new SpecialNotifierJob(mListEmails, currentPath, item, this);
......@@ -462,6 +466,11 @@ void NewMailNotifierAgent::slotInstanceRemoved(const Akonadi::AgentInstance &ins
}
}
void NewMailNotifierAgent::slotInstanceAdded(const Akonadi::AgentInstance &instance)
{
mCacheResourceName.insert(instance.identifier(), instance.name());
}
void NewMailNotifierAgent::printDebug()
{
kDebug()<<"instance in progress: "<<mInstanceNameInProgress
......@@ -475,6 +484,13 @@ bool NewMailNotifierAgent::isActive() const
return isOnline() && NewMailNotifierAgentSettings::enabled();
}
void NewMailNotifierAgent::initializeInstanceCache()
{
Q_FOREACH ( const Akonadi::AgentInstance &instance, Akonadi::AgentManager::self()->instances() ) {
mCacheResourceName.insert(instance.identifier(), instance.name());
}
}
AKONADI_AGENT_MAIN( NewMailNotifierAgent )
......
......@@ -84,6 +84,7 @@ private slots:
void configure(WId windowId);
void slotInstanceStatusChanged(const Akonadi::AgentInstance &instance);
void slotInstanceRemoved(const Akonadi::AgentInstance &instance);
void slotInstanceAdded(const Akonadi::AgentInstance &instance);
void slotDisplayNotification(const QPixmap &pixmap, const QString &message);
void slotIdentitiesChanged();
......@@ -91,8 +92,10 @@ private:
bool isActive() const;
void clearAll();
bool excludeSpecialCollection(const Akonadi::Collection &collection) const;
void initializeInstanceCache();
QStringList mListEmails;
QHash<Akonadi::Collection, QList<Akonadi::Item::Id> > mNewMails;
QHash<QString, QString> mCacheResourceName;
QTimer mTimer;
QStringList mInstanceNameInProgress;
KPIMIdentities::IdentityManager *mIdentityManager;
......
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