static void test_otrl_proto_default_query_msg(void) { const char *expected2 = "?OTRv2?\n<b>alice</b> has requested an " "<a href=\"https://otr.cypherpunks.ca/\">Off-the-Record " "private conversation</a>. However, you do not have a plugin " "to support that.\nSee <a href=\"https://otr.cypherpunks.ca/\">" "https://otr.cypherpunks.ca/</a> for more information."; const char *expected23 = "?OTRv23?\n<b>alice</b> has requested an " "<a href=\"https://otr.cypherpunks.ca/\">Off-the-Record " "private conversation</a>. However, you do not have a plugin " "to support that.\nSee <a href=\"https://otr.cypherpunks.ca/\">" "https://otr.cypherpunks.ca/</a> for more information."; const char *expected3 = "?OTRv3?\n<b>alice</b> has requested an " "<a href=\"https://otr.cypherpunks.ca/\">Off-the-Record " "private conversation</a>. However, you do not have a plugin " "to support that.\nSee <a href=\"https://otr.cypherpunks.ca/\">" "https://otr.cypherpunks.ca/</a> for more information."; const char* msg2 = otrl_proto_default_query_msg("alice", OTRL_POLICY_ALLOW_V2); const char* msg23 = otrl_proto_default_query_msg("alice", OTRL_POLICY_ALLOW_V2 | OTRL_POLICY_ALLOW_V3); const char* msg3 = otrl_proto_default_query_msg("alice", OTRL_POLICY_ALLOW_V3); ok(strcmp(expected2, msg2) == 0, "OTRv2 default query message is valid"); ok(strcmp(expected23, msg23) == 0, "OTRv23 default query message is valid"); ok(strcmp(expected3, msg3) == 0, "OTRv3 default query message is valid"); //ok(otrl_proto_default_query_msg("alice", 0) == NULL, "Wrong version query message is NULL"); }
void OtrInternal::startSession(const QString& account, const QString& contact) { m_callback->stateChange(account, contact, psiotr::OTR_STATECHANGE_GOINGSECURE); if (!otrl_privkey_find(m_userstate, account.toUtf8().constData(), OTR_PROTOCOL_STRING)) { create_privkey(account.toUtf8().constData(), OTR_PROTOCOL_STRING); } //TODO: make allowed otr versions configureable char* msg = otrl_proto_default_query_msg(m_callback->humanAccountPublic(account).toUtf8().constData(), OTRL_POLICY_DEFAULT); m_callback->sendMessage(account, contact, QString::fromUtf8(msg)); free(msg); }
void OtrSessionService::startSession(const Contact &contact) { if (!CurrentMessageManager || !PolicyService || !TrustLevelService) return; auto level = TrustLevelService->loadTrustLevelFromContact(contact); auto account = contact.contactAccount(); auto otrPolicy = PolicyService->accountPolicy(account); auto message = normalizeHtml( HtmlString{QString::fromUtf8(otrl_proto_default_query_msg(qPrintable(account.id()), otrPolicy.toOtrPolicy()))}); if (level == OtrTrustLevelService::TrustLevelNotPrivate) emit tryingToStartSession(contact); else emit tryingToRefreshSession(contact); CurrentMessageManager->sendMessage( ChatTypeContact::findChat(m_chatManager, m_chatStorage, contact, ActionCreateAndAdd), message, true); }
//----------------------------------------------------------------------------- void OtrInternal::startSession(const QString& account, const QString& jid, TreeModelItem &item, int pol) { Q_UNUSED(jid); OtrlPolicy policy = (OtrlPolicy)pol; char fingerprint[45]; if (!otrl_privkey_fingerprint(m_userstate, fingerprint, account.toStdString().c_str(), item.m_protocol_name.toStdString().c_str())) { create_privkey(account.toStdString().c_str(), item.m_protocol_name.toStdString().c_str()); } if (!otrl_privkey_fingerprint(m_userstate, fingerprint, account.toStdString().c_str(), item.m_protocol_name.toStdString().c_str())) return; //TODO: make allowed otr versions configureable char* msg = otrl_proto_default_query_msg(account.toStdString().c_str(), policy); m_plugin->sendCustomMessage(item,QString(msg),true); }