Changeset View
Changeset View
Standalone View
Standalone View
src/akonadicontrol/agentmanager.cpp
Show First 20 Lines • Show All 611 Lines • ▼ Show 20 Line(s) | |||||
612 | } | 612 | } | ||
613 | 613 | | |||
614 | void AgentManager::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner) | 614 | void AgentManager::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner) | ||
615 | { | 615 | { | ||
616 | Q_UNUSED(oldOwner); | 616 | Q_UNUSED(oldOwner); | ||
617 | // This is called by the D-Bus server when a service comes up, goes down or changes ownership for some reason | 617 | // This is called by the D-Bus server when a service comes up, goes down or changes ownership for some reason | ||
618 | // and this is where we "hook up" our different Agent interfaces. | 618 | // and this is where we "hook up" our different Agent interfaces. | ||
619 | 619 | | |||
620 | //qCDebug(AKONADICONTROL_LOG) << "Service " << name << " owner changed from " << oldOwner << " to " << newOwner; | 620 | qCDebug(AKONADICONTROL_LOG) << "Service" << name << "owner changed from" << oldOwner << "to" << newOwner; | ||
dfaure: (too many spaces in the string constants here) | |||||
621 | 621 | | |||
622 | if ((name == Akonadi::DBus::serviceName(Akonadi::DBus::Server) || name == Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer)) && !newOwner.isEmpty()) { | 622 | if ((name == Akonadi::DBus::serviceName(Akonadi::DBus::Server) || name == Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer)) && !newOwner.isEmpty()) { | ||
623 | if (QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::Server)) | 623 | if (QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::Server)) | ||
624 | && (!mAgentServer || QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer)))) { | 624 | && (!mAgentServer || QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer)))) { | ||
625 | // server is operational, start agents | 625 | // server is operational, start agents | ||
626 | continueStartup(); | 626 | continueStartup(); | ||
627 | } | 627 | } | ||
628 | } | 628 | } | ||
Show All 14 Lines | 635 | case Akonadi::DBus::Agent: { | |||
643 | } | 643 | } | ||
644 | 644 | | |||
645 | const AgentInstance::Ptr instance = mAgentInstances.value(service->serviceName); | 645 | const AgentInstance::Ptr instance = mAgentInstances.value(service->serviceName); | ||
646 | const bool restarting = instance->hasAgentInterface(); | 646 | const bool restarting = instance->hasAgentInterface(); | ||
647 | if (!instance->obtainAgentInterface()) { | 647 | if (!instance->obtainAgentInterface()) { | ||
648 | return; | 648 | return; | ||
649 | } | 649 | } | ||
650 | 650 | | |||
651 | if (!restarting) { | 651 | Q_ASSERT(mAgents.contains(instance->agentType())); | ||
652 | const bool isResource = mAgents.value(instance->agentType()).capabilities.contains(AgentType::CapabilityResource); | ||||
653 | | ||||
654 | if (!restarting && (!isResource || instance->hasResourceInterface())) { | ||||
652 | Q_EMIT agentInstanceAdded(service->serviceName); | 655 | Q_EMIT agentInstanceAdded(service->serviceName); | ||
653 | } | 656 | } | ||
654 | 657 | | |||
655 | break; | 658 | break; | ||
656 | } | 659 | } | ||
657 | case Akonadi::DBus::Resource: { | 660 | case Akonadi::DBus::Resource: { | ||
658 | // A resource service went up or down | 661 | // A resource service went up or down | ||
659 | if (newOwner.isEmpty()) { | 662 | if (newOwner.isEmpty()) { | ||
660 | return; // It went down: we don't care here. | 663 | return; // It went down: we don't care here. | ||
661 | } | 664 | } | ||
662 | 665 | | |||
663 | if (!mAgentInstances.contains(service->serviceName)) { | 666 | if (!mAgentInstances.contains(service->serviceName)) { | ||
664 | return; | 667 | return; | ||
665 | } | 668 | } | ||
666 | 669 | | |||
667 | mAgentInstances.value(service->serviceName)->obtainResourceInterface(); | 670 | const AgentInstance::Ptr instance = mAgentInstances.value(service->serviceName); | ||
671 | const bool restarting = instance->hasResourceInterface(); | ||||
dfaure: I admit I don't fully understand the logic here. | |||||
We want to detect when the resource was running, crashed and was started again - in that case we will already have its DBus interface cached (hasResourceInterface == true) and we don't want to announce such event as agentInstanceAdded. dvratil: We want to detect when the resource was running, crashed and was started again - in that case… | |||||
672 | if (!instance->obtainResourceInterface()) { | ||||
673 | return; | ||||
674 | } | ||||
675 | | ||||
676 | if (!restarting && instance->hasAgentInterface()) { | ||||
677 | Q_EMIT agentInstanceAdded(service->serviceName); | ||||
678 | } | ||||
668 | 679 | | |||
669 | break; | 680 | break; | ||
670 | } | 681 | } | ||
671 | case Akonadi::DBus::Preprocessor: { | 682 | case Akonadi::DBus::Preprocessor: { | ||
672 | // A preprocessor service went up or down | 683 | // A preprocessor service went up or down | ||
673 | 684 | | |||
674 | // If the preprocessor is going up then the org.freedesktop.Akonadi.Agent.* interface | 685 | // If the preprocessor is going up then the org.freedesktop.Akonadi.Agent.* interface | ||
675 | // should be already up (as it's registered before the preprocessor one). | 686 | // should be already up (as it's registered before the preprocessor one). | ||
▲ Show 20 Lines • Show All 194 Lines • Show Last 20 Lines |
(too many spaces in the string constants here)