void MainController::handleConnected() {
	boundJID_ = client_->getJID();
	loginWindow_->setIsLoggingIn(false);
	resetCurrentError();
	resetPendingReconnects();
	bool freshLogin = rosterController_ == NULL;
	myStatusLooksOnline_ = true;
	if (freshLogin) {
		profileController_ = new ProfileController(client_->getVCardManager(), uiFactory_, uiEventStream_);
		rosterController_ = new RosterController(jid_, client_->getRoster(), client_->getAvatarManager(), uiFactory_, client_->getNickManager(), client_->getNickResolver(), client_->getPresenceOracle(), client_->getSubscriptionManager(), eventController_, uiEventStream_, client_->getIQRouter(), settings_);
		rosterController_->onChangeStatusRequest.connect(boost::bind(&MainController::handleChangeStatusRequest, this, _1, _2));
		rosterController_->onSignOutRequest.connect(boost::bind(&MainController::signOut, this));

		contactEditController_ = new ContactEditController(rosterController_, uiFactory_, uiEventStream_);

		chatsManager_ = new ChatsManager(jid_, client_->getStanzaChannel(), client_->getIQRouter(), eventController_, uiFactory_, uiFactory_, client_->getNickResolver(), client_->getPresenceOracle(), client_->getPresenceSender(), uiEventStream_, uiFactory_, useDelayForLatency_, networkFactories_->getTimerFactory(), client_->getMUCRegistry(), client_->getEntityCapsProvider(), client_->getMUCManager(), uiFactory_, settings_);
		client_->onMessageReceived.connect(boost::bind(&ChatsManager::handleIncomingMessage, chatsManager_, _1));
		chatsManager_->setAvatarManager(client_->getAvatarManager());

		eventWindowController_ = new EventWindowController(eventController_, uiFactory_);

		loginWindow_->morphInto(rosterController_->getWindow());

		DiscoInfo discoInfo;
		discoInfo.addIdentity(DiscoInfo::Identity(CLIENT_NAME, "client", "pc"));
		discoInfo.addFeature(DiscoInfo::ChatStatesFeature);
		discoInfo.addFeature(DiscoInfo::SecurityLabelsFeature);
		client_->getDiscoManager()->setCapsNode(CLIENT_NODE);
		client_->getDiscoManager()->setDiscoInfo(discoInfo);


		userSearchControllerChat_ = new UserSearchController(UserSearchController::StartChat, jid_, uiEventStream_, uiFactory_, client_->getIQRouter(), rosterController_);
		userSearchControllerAdd_ = new UserSearchController(UserSearchController::AddContact, jid_, uiEventStream_, uiFactory_, client_->getIQRouter(), rosterController_);
	}
	
	client_->requestRoster();

	GetDiscoInfoRequest::ref discoInfoRequest = GetDiscoInfoRequest::create(JID(), client_->getIQRouter());
	discoInfoRequest->onResponse.connect(boost::bind(&MainController::handleServerDiscoInfoResponse, this, _1, _2));
	discoInfoRequest->send();

	client_->getVCardManager()->requestOwnVCard();
	
	rosterController_->setEnabled(true);
	profileController_->setAvailable(true);
	contactEditController_->setAvailable(true);
	/* Send presence later to catch all the incoming presences. */
	sendPresence(statusTracker_->getNextPresence());
	/* Enable chats last of all, so rejoining MUCs has the right sent presence */
	chatsManager_->setOnline(true);
}
示例#2
0
		void handleReceiverConnected() {
			receiver_->getFileTransferManager()->onIncomingFileTransfer.connect(boost::bind(&FileTransferTest::handleReceiverIncomingFileTransfer, this, _1));

			DiscoInfo discoInfo;
			discoInfo.addIdentity(DiscoInfo::Identity(CLIENT_NAME, "client", "pc"));
			discoInfo.addFeature(DiscoInfo::JingleFeature);
			discoInfo.addFeature(DiscoInfo::JingleFTFeature);
			discoInfo.addFeature(DiscoInfo::Bytestream);
			discoInfo.addFeature(DiscoInfo::JingleTransportsIBBFeature);
			discoInfo.addFeature(DiscoInfo::JingleTransportsS5BFeature);
			receiver_->getDiscoManager()->setCapsNode(CLIENT_NODE);
			receiver_->getDiscoManager()->setDiscoInfo(discoInfo);
			receiver_->getPresenceSender()->sendPresence(Presence::create());
		}
示例#3
0
        void testGenerate_XEP0115SimpleExample() {
            DiscoInfo discoInfo;
            discoInfo.addIdentity(DiscoInfo::Identity("Exodus 0.9.1", "client", "pc"));
            discoInfo.addFeature("http://jabber.org/protocol/disco#items");
            discoInfo.addFeature("http://jabber.org/protocol/caps");
            discoInfo.addFeature("http://jabber.org/protocol/disco#info");
            discoInfo.addFeature("http://jabber.org/protocol/muc");

            CapsInfoGenerator testling("http://code.google.com/p/exodus", crypto.get());
            CapsInfo result = testling.generateCapsInfo(discoInfo);

            CPPUNIT_ASSERT_EQUAL(std::string("http://code.google.com/p/exodus"), result.getNode());
            CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), result.getHash());
            CPPUNIT_ASSERT_EQUAL(std::string("QgayPKawpkPSDYmwT/WM94uAlu0="), result.getVersion());
        }
		void testHandleRequest_GetNodeInfo() {
			DiscoInfoResponder testling(router_); 
			testling.start();
			DiscoInfo discoInfo;
			discoInfo.addFeature("foo");
			testling.setDiscoInfo(discoInfo);
			DiscoInfo discoInfoBar;
			discoInfoBar.addFeature("bar");
			testling.setDiscoInfo("bar-node", discoInfoBar);

			boost::shared_ptr<DiscoInfo> query(new DiscoInfo());
			query->setNode("bar-node");
			channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("*****@*****.**"), "id-1", query));

			CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
			boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>());
			CPPUNIT_ASSERT(payload);
			CPPUNIT_ASSERT_EQUAL(std::string("bar-node"), payload->getNode());
			CPPUNIT_ASSERT(payload->hasFeature("bar"));

			testling.stop();
		}
示例#5
0
        void testGenerate_XEP0115ComplexExample() {
            DiscoInfo discoInfo;
            discoInfo.addIdentity(DiscoInfo::Identity("Psi 0.11", "client", "pc", "en"));
            discoInfo.addIdentity(DiscoInfo::Identity("\xce\xa8 0.11", "client", "pc", "el"));
            discoInfo.addFeature("http://jabber.org/protocol/disco#items");
            discoInfo.addFeature("http://jabber.org/protocol/caps");
            discoInfo.addFeature("http://jabber.org/protocol/disco#info");
            discoInfo.addFeature("http://jabber.org/protocol/muc");

            Form::ref extension(new Form(Form::ResultType));
            FormField::ref field = std::make_shared<FormField>(FormField::HiddenType, "urn:xmpp:dataforms:softwareinfo");
            field->setName("FORM_TYPE");
            extension->addField(field);
            field = std::make_shared<FormField>(FormField::ListMultiType);
            field->addValue("ipv6");
            field->addValue("ipv4");
            field->setName("ip_version");
            extension->addField(field);
            field = std::make_shared<FormField>(FormField::TextSingleType, "Psi");
            field->setName("software");
            extension->addField(field);
            field = std::make_shared<FormField>(FormField::TextSingleType, "0.11");
            field->setName("software_version");
            extension->addField(field);
            field = std::make_shared<FormField>(FormField::TextSingleType, "Mac");
            field->setName("os");
            extension->addField(field);
            field = std::make_shared<FormField>(FormField::TextSingleType, "10.5.1");
            field->setName("os_version");
            extension->addField(field);
            discoInfo.addExtension(extension);

            CapsInfoGenerator testling("http://psi-im.org", crypto.get());
            CapsInfo result = testling.generateCapsInfo(discoInfo);

            CPPUNIT_ASSERT_EQUAL(std::string("q07IKJEyjvHSyhy//CH0CxmKi8w="), result.getVersion());
        }
		void testHandleRequest_GetUnknownJID() {
			JIDDiscoInfoResponder testling(router_);
			DiscoInfo discoInfo;
			discoInfo.addFeature("foo");
			testling.setDiscoInfo(JID("[email protected]/baz"), discoInfo);
			testling.start();

			boost::shared_ptr<DiscoInfo> query(new DiscoInfo());
			channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("[email protected]/fum"), "id-1", query));

			CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
			boost::shared_ptr<ErrorPayload> payload(channel_->iqs_[0]->getPayload<ErrorPayload>());
			CPPUNIT_ASSERT(payload);

			testling.stop();
		}
示例#7
0
void MainController::handleConnected() {
	boundJID_ = client_->getJID();
	resetCurrentError();
	resetPendingReconnects();

	if (settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) {
		purgeCachedCredentials();
	}

	bool freshLogin = rosterController_ == NULL;
	myStatusLooksOnline_ = true;
	if (freshLogin) {
		profileController_ = new ProfileController(client_->getVCardManager(), uiFactory_, uiEventStream_);
		showProfileController_ = new ShowProfileController(client_->getVCardManager(), uiFactory_, uiEventStream_);
		ftOverview_ = new FileTransferOverview(client_->getFileTransferManager());
		fileTransferListController_->setFileTransferOverview(ftOverview_);
		rosterController_ = new RosterController(boundJID_, client_->getRoster(), client_->getAvatarManager(), uiFactory_, client_->getNickManager(), client_->getNickResolver(), client_->getPresenceOracle(), client_->getSubscriptionManager(), eventController_, uiEventStream_, client_->getIQRouter(), settings_, client_->getEntityCapsProvider(), ftOverview_, client_->getClientBlockListManager(), client_->getVCardManager());
		rosterController_->onChangeStatusRequest.connect(boost::bind(&MainController::handleChangeStatusRequest, this, _1, _2));
		rosterController_->onSignOutRequest.connect(boost::bind(&MainController::signOut, this));
		rosterController_->getWindow()->onShowCertificateRequest.connect(boost::bind(&MainController::handleShowCertificateRequest, this));

		blockListController_ = new BlockListController(client_->getClientBlockListManager(), uiEventStream_, uiFactory_, eventController_);

		contactEditController_ = new ContactEditController(rosterController_, client_->getVCardManager(), uiFactory_, uiEventStream_);
		whiteboardManager_ = new WhiteboardManager(uiFactory_, uiEventStream_, client_->getNickResolver(), client_->getWhiteboardSessionManager());

		/* Doing this early as an ordering fix. Various things later will
		 * want to have the user's nick available and this means it will
		 * be before they receive stanzas that need it (e.g. bookmarks).*/
		client_->getVCardManager()->requestOwnVCard();

		contactSuggesterWithoutRoster_ = new ContactSuggester();
		contactSuggesterWithRoster_ = new ContactSuggester();

		userSearchControllerInvite_ = new UserSearchController(UserSearchController::InviteToChat, jid_, uiEventStream_, client_->getVCardManager(), uiFactory_, client_->getIQRouter(), rosterController_, contactSuggesterWithRoster_, client_->getAvatarManager(), client_->getPresenceOracle(), profileSettings_);
#ifdef SWIFT_EXPERIMENTAL_HISTORY
		historyController_ = new HistoryController(storages_->getHistoryStorage());
		historyViewController_ = new HistoryViewController(jid_, uiEventStream_, historyController_, client_->getNickResolver(), client_->getAvatarManager(), client_->getPresenceOracle(), uiFactory_);
		chatsManager_ = new ChatsManager(jid_, client_->getStanzaChannel(), client_->getIQRouter(), eventController_, uiFactory_, uiFactory_, client_->getNickResolver(), client_->getPresenceOracle(), client_->getPresenceSender(), uiEventStream_, uiFactory_, useDelayForLatency_, networkFactories_->getTimerFactory(), client_->getMUCRegistry(), client_->getEntityCapsProvider(), client_->getMUCManager(), uiFactory_, profileSettings_, ftOverview_, client_->getRoster(), !settings_->getSetting(SettingConstants::REMEMBER_RECENT_CHATS), settings_, historyController_, whiteboardManager_, highlightManager_, client_->getClientBlockListManager(), emoticons_, client_->getVCardManager());
#else
		chatsManager_ = new ChatsManager(jid_, client_->getStanzaChannel(), client_->getIQRouter(), eventController_, uiFactory_, uiFactory_, client_->getNickResolver(), client_->getPresenceOracle(), client_->getPresenceSender(), uiEventStream_, uiFactory_, useDelayForLatency_, networkFactories_->getTimerFactory(), client_->getMUCRegistry(), client_->getEntityCapsProvider(), client_->getMUCManager(), uiFactory_, profileSettings_, ftOverview_, client_->getRoster(), !settings_->getSetting(SettingConstants::REMEMBER_RECENT_CHATS), settings_, NULL, whiteboardManager_, highlightManager_, client_->getClientBlockListManager(), emoticons_, client_->getVCardManager());
#endif
		contactsFromRosterProvider_ = new ContactsFromXMPPRoster(client_->getRoster(), client_->getAvatarManager(), client_->getPresenceOracle());
		contactSuggesterWithoutRoster_->addContactProvider(chatsManager_);
		contactSuggesterWithRoster_->addContactProvider(chatsManager_);
		contactSuggesterWithRoster_->addContactProvider(contactsFromRosterProvider_);
		highlightEditorController_->setContactSuggester(contactSuggesterWithoutRoster_);

		client_->onMessageReceived.connect(boost::bind(&ChatsManager::handleIncomingMessage, chatsManager_, _1));
		chatsManager_->setAvatarManager(client_->getAvatarManager());

		eventWindowController_ = new EventWindowController(eventController_, uiFactory_);

		loginWindow_->morphInto(rosterController_->getWindow());

		DiscoInfo discoInfo;
		discoInfo.addIdentity(DiscoInfo::Identity(CLIENT_NAME, "client", "pc"));
		discoInfo.addFeature(DiscoInfo::ChatStatesFeature);
		discoInfo.addFeature(DiscoInfo::SecurityLabelsFeature);
		discoInfo.addFeature(DiscoInfo::MessageCorrectionFeature);
#ifdef SWIFT_EXPERIMENTAL_FT
		discoInfo.addFeature(DiscoInfo::JingleFeature);
		discoInfo.addFeature(DiscoInfo::JingleFTFeature);
		discoInfo.addFeature(DiscoInfo::JingleTransportsIBBFeature);
		discoInfo.addFeature(DiscoInfo::JingleTransportsS5BFeature);
#endif
#ifdef SWIFT_EXPERIMENTAL_WB
		discoInfo.addFeature(DiscoInfo::WhiteboardFeature);
#endif
		discoInfo.addFeature(DiscoInfo::MessageDeliveryReceiptsFeature);
		client_->getDiscoManager()->setCapsNode(CLIENT_NODE);
		client_->getDiscoManager()->setDiscoInfo(discoInfo);

		userSearchControllerChat_ = new UserSearchController(UserSearchController::StartChat, jid_, uiEventStream_, client_->getVCardManager(), uiFactory_, client_->getIQRouter(), rosterController_, contactSuggesterWithRoster_, client_->getAvatarManager(), client_->getPresenceOracle(), profileSettings_);
		userSearchControllerAdd_ = new UserSearchController(UserSearchController::AddContact, jid_, uiEventStream_, client_->getVCardManager(), uiFactory_, client_->getIQRouter(), rosterController_, contactSuggesterWithoutRoster_, client_->getAvatarManager(), client_->getPresenceOracle(), profileSettings_);
		adHocManager_ = new AdHocManager(JID(boundJID_.getDomain()), uiFactory_, client_->getIQRouter(), uiEventStream_, rosterController_->getWindow());

		chatsManager_->onImpromptuMUCServiceDiscovered.connect(boost::bind(&UserSearchController::setCanInitiateImpromptuMUC, userSearchControllerChat_, _1));
	}
	loginWindow_->setIsLoggingIn(false);

	client_->requestRoster();

	GetDiscoInfoRequest::ref discoInfoRequest = GetDiscoInfoRequest::create(JID(boundJID_.getDomain()), client_->getIQRouter());
	discoInfoRequest->onResponse.connect(boost::bind(&MainController::handleServerDiscoInfoResponse, this, _1, _2));
	discoInfoRequest->send();

	client_->getVCardManager()->requestOwnVCard();

	rosterController_->setJID(boundJID_);
	rosterController_->setEnabled(true);
	rosterController_->getWindow()->setStreamEncryptionStatus(client_->isStreamEncrypted());
	profileController_->setAvailable(true);
	contactEditController_->setAvailable(true);
	/* Send presence later to catch all the incoming presences. */
	sendPresence(statusTracker_->getNextPresence());

	/* Enable chats last of all, so rejoining MUCs has the right sent presence */
	assert(chatsManager_);
	chatsManager_->setOnline(true);
	adHocManager_->setOnline(true);
}