Пример #1
0
GaduRosterService::GaduRosterService(GaduListHelper *gaduListHelper, const QVector<Contact> &contacts, Protocol *protocol) :
		RosterService{contacts, protocol},
		m_stateMachine{new GaduRosterStateMachine{this, protocol}},
		m_gaduListHelper{gaduListHelper}
{
	connect(this, SIGNAL(contactAdded(Contact)), this, SLOT(rosterChanged()));
	connect(this, SIGNAL(contactRemoved(Contact)), this, SLOT(rosterChanged()));
	connect(this, SIGNAL(contactUpdatedLocally(Contact)), this, SLOT(rosterChanged()));

	connect(m_stateMachine, SIGNAL(performGet()), SLOT(importContactList()));
	connect(m_stateMachine, SIGNAL(performPut()), SLOT(exportContactList()));
}
Пример #2
0
void GaduProtocol::init()
{
    Connection = new ProtocolGaduConnection(this);
    Connection->setConnectionProtocol(this);

    m_gaduAccountAvatarService = new GaduAccountAvatarService(account(), this);

    CurrentChatImageService = new GaduChatImageService(account(), this);
    CurrentChatImageService->setConnection(Connection);

    CurrentImTokenService = new GaduIMTokenService{this};

    CurrentFileTransferService = pluginInjectedFactory()->makeInjected<GaduFileTransferService>(this);
    CurrentFileTransferService->setGaduIMTokenService(CurrentImTokenService);

    CurrentChatService = pluginInjectedFactory()->makeInjected<GaduChatService>(account(), this);
    CurrentChatService->setConnection(Connection);
    CurrentChatService->setGaduChatImageService(CurrentChatImageService);
    CurrentChatService->setGaduFileTransferService(CurrentFileTransferService);
    CurrentChatImageService->setGaduChatService(CurrentChatService);

    CurrentContactPersonalInfoService =
        pluginInjectedFactory()->makeInjected<GaduContactPersonalInfoService>(account(), this);
    CurrentContactPersonalInfoService->setConnection(Connection);

    CurrentPersonalInfoService = pluginInjectedFactory()->makeInjected<GaduPersonalInfoService>(account(), this);
    CurrentPersonalInfoService->setConnection(Connection);

    CurrentSearchService = pluginInjectedFactory()->makeInjected<GaduSearchService>(account(), this);
    CurrentSearchService->setConnection(Connection);

    CurrentMultilogonService = new GaduMultilogonService(account(), this);
    CurrentMultilogonService->setConnection(Connection);

    CurrentChatStateService = pluginInjectedFactory()->makeInjected<GaduChatStateService>(account(), this);
    CurrentChatStateService->setConnection(Connection);

    m_gaduContactAvatarService = pluginInjectedFactory()->makeInjected<GaduContactAvatarService>(account(), this);

    connect(
        CurrentChatService, SIGNAL(messageReceived(Message)), CurrentChatStateService, SLOT(messageReceived(Message)));

    CurrentDriveService = pluginInjectedFactory()->makeInjected<GaduDriveService>(account(), this);
    CurrentDriveService->setGaduIMTokenService(CurrentImTokenService);

    CurrentUserDataService =
        pluginInjectedFactory()->makeInjected<GaduUserDataService>(m_gaduContactAvatarService, account(), this);

    auto contacts = contactManager()->contacts(account(), ContactManager::ExcludeAnonymous);
    auto rosterService = pluginInjectedFactory()->makeInjected<GaduRosterService>(m_gaduListHelper, contacts, this);
    rosterService->setConnection(Connection);

    CurrentNotifyService = new GaduNotifyService{Connection, this};
    connect(rosterService, SIGNAL(contactAdded(Contact)), CurrentNotifyService, SLOT(contactAdded(Contact)));
    connect(rosterService, SIGNAL(contactRemoved(Contact)), CurrentNotifyService, SLOT(contactRemoved(Contact)));
    connect(
        rosterService, SIGNAL(contactUpdatedLocally(Contact)), CurrentNotifyService,
        SLOT(contactUpdatedLocally(Contact)));

    setRosterService(rosterService);

    configureServices();

    connect(account(), SIGNAL(updated()), this, SLOT(accountUpdated()));

    OpenChatRunner = m_pluginInjectedFactory->makeInjected<GaduOpenChatWithRunner>(account());
    OpenChatWithRunnerManager::instance()->registerRunner(OpenChatRunner);

    m_aggregatedAccountAvatarService->add(m_gaduAccountAvatarService);
    m_aggregatedContactAvatarService->add(m_gaduContactAvatarService);
    m_chatServiceRepository->addChatService(CurrentChatService);
    m_chatStateServiceRepository->addChatStateService(CurrentChatStateService);
}