コード例 #1
0
	void testMessageWithLabelItem() {
		boost::shared_ptr<SecurityLabel> label = boost::make_shared<SecurityLabel>();
		label->setLabel("a");
		SecurityLabelsCatalog::Item labelItem;
		labelItem.setSelector("Bob");
		labelItem.setLabel(label);
		window_->label_ = labelItem;
		boost::shared_ptr<DiscoInfo> features = boost::make_shared<DiscoInfo>();
		features->addFeature(DiscoInfo::SecurityLabelsCatalogFeature);
		controller_->setAvailableServerFeatures(features);
		IQ::ref iq = iqChannel_->iqs_[iqChannel_->iqs_.size() - 1];
		SecurityLabelsCatalog::ref labelPayload = boost::make_shared<SecurityLabelsCatalog>();
		labelPayload->addItem(labelItem);
		IQ::ref result = IQ::createResult(self_, iq->getID(), labelPayload);
		iqChannel_->onIQReceived(result);
		std::string messageBody("agamemnon");
		window_->onSendMessageRequest(messageBody, false);
		boost::shared_ptr<Stanza> rawStanza = stanzaChannel_->sentStanzas[stanzaChannel_->sentStanzas.size() - 1];
		Message::ref message = boost::dynamic_pointer_cast<Message>(rawStanza);
		CPPUNIT_ASSERT_EQUAL(iq->getTo(), result->getFrom());
		CPPUNIT_ASSERT(window_->labelsEnabled_);
		CPPUNIT_ASSERT(stanzaChannel_->isAvailable()); /* Otherwise will prevent sends. */
		CPPUNIT_ASSERT(message);
		CPPUNIT_ASSERT_EQUAL(messageBody, message->getBody());
		CPPUNIT_ASSERT_EQUAL(label, message->getPayload<SecurityLabel>());
	}
コード例 #2
0
ファイル: EchoBot6.cpp プロジェクト: bessey/picnic-doc-server
		//...
		void handleMessageReceived(Message::ref message) {
			//...
			// Echo back the incoming message
			message->setTo(message->getFrom());
			message->setFrom(JID());
			//...
			if (!message->getPayload<EchoPayload>()) {
				boost::shared_ptr<EchoPayload> echoPayload = boost::make_shared<EchoPayload>();
				echoPayload->setMessage("This is an echoed message");
				message->addPayload(echoPayload);
				client->sendMessage(message);
			}
		}
コード例 #3
0
ファイル: EchoBot5.cpp プロジェクト: loewis/swift
		void handleMessageReceived(Message::ref message) {
			// Echo back the incoming message
			message->setTo(message->getFrom());
			message->setFrom(JID());
			client->sendMessage(message);
		}
コード例 #4
0
ファイル: sluift.cpp プロジェクト: bessey/picnic-doc-server
		void sendMessage(const JID& to, const std::string& body) {
			Message::ref message = boost::make_shared<Message>();
			message->setTo(to);
			message->setBody(body);
			client->sendMessage(message);
		}