예제 #1
0
void NetworkManager::sendMessage(const qutim_sdk_0_3::Message &message)
{
	MessageAction *action = new MessageAction();
	ChatUnit *contact = const_cast<ChatUnit*>(message.chatUnit()->getHistoryUnit());
	action->account = AccountId(contact->account());
	action->contact = contact->id();
	action->time = message.time();
	action->text = message.text();
	action->incoming = message.isIncoming();
	if (message.property("otrEncrypted", false))
		action->encryption << QLatin1String("otr");
	if (message.property("pgpEncrypted", false)
	        || (encryptedMessageIdInited
	            && encryptedMessageId == message.id())) {
		action->encryption << QLatin1String("pgp");
	}
    if (message.property("autoreply", false))
        action->encryption << QLatin1String("autoreply");
	m_actions << action;
	trySend();
}
예제 #2
0
파일: message.cpp 프로젝트: nico-izo/qutim
QDebug operator<<(QDebug dbg, const qutim_sdk_0_3::Message &msg)
{
	dbg.nospace() << QLatin1String("Ureen::Message(")
				  << QLatin1String("id: ") << msg.id()
				  << QLatin1String("chatUnit: ") << msg.chatUnit()
				  << QLatin1String("isIncoming: ") << msg.isIncoming()
				  << QLatin1String("text: ") << msg.text()
				  << QLatin1String("time: ") << msg.time()
				  << QLatin1String("properties: (");
	foreach (QByteArray name, msg.dynamicPropertyNames())
		dbg.nospace() << name << ": " << msg.property(name);
	return dbg.nospace() << QLatin1String(") )");
}
예제 #3
0
void ChatController::onMessageAppended(const qutim_sdk_0_3::Message &msg)
{
	Message copy = msg;
	QString html = UrlParser::parseUrls(copy.html(), UrlParser::Html);
	copy.setProperty("messageId", msg.id());
	if (msg.property("topic", false)) {
		copy.setHtml(html);
		m_topic = copy;
//        if (!m_isLoading)
//            updateTopic();
		return;
	}
	if (msg.property("firstFocus", false))
		clearFocusClass();
	// We don't want emoticons in topic
	html = Emoticons::theme().parseEmoticons(html);
	copy.setHtml(html);
	bool similiar = isContentSimiliar(m_last, msg);
	QString script = m_style.scriptForAppendingContent(copy, similiar, false, false);
	m_last = msg;
	evaluateJavaScript(script);
}
QString WebKitMessageViewStyle::templateForContent(const qutim_sdk_0_3::Message &message, bool contentIsSimilar)
{
	Q_D(WebKitMessageViewStyle);
	QString result;
	
	// Get the correct result for what we're inserting
	
	if (message.property("topic", false)) {
		result = d->topicHTML;
	// FIXME: Implement file transfer support
//	} else if (content.pro == IContent::FileTranfser) {
//		result = d->fileTransferHTML;
	} else if (!message.property("service", false)) {
		bool isAction = message.html().startsWith(QLatin1String("/me "), Qt::CaseInsensitive);
		if (isAction && hasAction()) {
			if (!message.isIncoming())
				result = d->actionOutHTML;
			else
				result = d->actionInHTML;
		} else if (message.property("history", false)) {
			if (!message.isIncoming())
				result = contentIsSimilar ? d->nextContextOutHTML : d->contextOutHTML;
			else
				result = contentIsSimilar ? d->nextContextInHTML : d->contextInHTML;
		} else {
			if (!message.isIncoming())
				result = contentIsSimilar ? d->nextContentOutHTML : d->contentOutHTML;
			else
				result = contentIsSimilar ? d->nextContentInHTML : d->contentInHTML;
		} 
	} else {
		result = d->statusHTML;
	} 
	
	if (!result.isEmpty())
		fillKeywords(result, message, contentIsSimilar);
	
	return result;
}
예제 #5
0
파일: chatchannel.cpp 프로젝트: xujb/qutim
qint64 ChatChannel::doAppendMessage(qutim_sdk_0_3::Message &message)
{
	if (message.isIncoming())
		emit messageReceived(&message);
	else
		emit messageSent(&message);
	
	if (message.property("spam", false) || message.property("hide", false))
		return message.id();
	
	bool service = message.property("service", false);
	
	if ((!isActive() && !service) && message.isIncoming()) {
		m_unread.append(message);
		emit unreadChanged(m_unread);
		emit unreadCountChanged(m_unread.count());
	}
	
	if (!message.property("silent", false) && !isActive())
		Notification::send(message);
	
	emit messageAppended(message);
	return message.id();
}
예제 #6
0
void JMessageSessionManager::sendMessage(qutim_sdk_0_3::ChatUnit *unit, const qutim_sdk_0_3::Message &message)
{
	JID jid = unit->id();
	Jreen::MessageSession *s = session(jid, Jreen::Message::Chat, true);

	Jreen::Message msg(Jreen::Message::Chat,
					   jid,
					   message.text(),
					   message.property("subject").toString());
	msg.setID(QString::number(message.id()));
//	if (JPGPSupport::instance()->send(s, unit, msg))
//		emit messageEcnrypted(message.id());
//	else
		s->sendMessage(msg);
	//We will close the session at Jreen together with a session in qutim
	s->setParent(ChatLayer::get(const_cast<ChatUnit*>(message.chatUnit()),true));
}
QString WebKitMessageViewStyle::scriptForAppendingContent(const qutim_sdk_0_3::Message &message, bool contentIsSimilar, bool willAddMoreContentObjects, bool replaceLastContent)
{
	Q_D(WebKitMessageViewStyle);
	
	//If combining of consecutive messages has been disabled, we treat all content as non-similar
	
	if (!d->combineConsecutive)
		contentIsSimilar = false;
	
	//Fetch the correct template and substitute keywords for the passed content
	QString newHTML = templateForContent(message, contentIsSimilar);
	QString script;
	
	//BOM scripts vary by style version
	if (!d->usingCustomTemplateHTML && d->styleVersion >= 4) {
		/* If we're using the built-in template HTML, we know that it supports our most modern scripts */
		if (replaceLastContent)
			script = QLatin1String(REPLACE_LAST_MESSAGE);
		else if (willAddMoreContentObjects) {
			script = QLatin1String(contentIsSimilar ? APPEND_NEXT_MESSAGE_NO_SCROLL : APPEND_MESSAGE_NO_SCROLL);
		} else {
			script = QLatin1String(contentIsSimilar ? APPEND_NEXT_MESSAGE : APPEND_MESSAGE);
		}
		
	} else  if (d->styleVersion >= 3) {
		if (willAddMoreContentObjects) {
			script = QLatin1String(contentIsSimilar ? APPEND_NEXT_MESSAGE_NO_SCROLL : APPEND_MESSAGE_NO_SCROLL);
		} else {
			script = QLatin1String(contentIsSimilar ? APPEND_NEXT_MESSAGE : APPEND_MESSAGE);
		}
	} else if (d->styleVersion >= 1) {
		script = QLatin1String(contentIsSimilar ? APPEND_NEXT_MESSAGE : APPEND_MESSAGE);
		
	} else {
		if (d->usingCustomTemplateHTML && message.property("service", false)) {
			/* Old styles with a custom template.html had Status.html files without 'insert' divs coupled 
			 * with a APPEND_NEXT_MESSAGE_WITH_SCROLL script which assumes one exists.
			 */
			script = QLatin1String(APPEND_MESSAGE_WITH_SCROLL);
		} else {
			script = QLatin1String(contentIsSimilar ? APPEND_NEXT_MESSAGE_WITH_SCROLL : APPEND_MESSAGE_WITH_SCROLL);
		}
	}
	
	return script.arg(validateCpp(newHTML));
}