コード例 #1
0
ファイル: omemo.cpp プロジェクト: psi-plus/plugins
  void OMEMO::publishOwnBundle(int account) {
    Bundle b = getSignal(account)->collectBundle();
    if (!b.isValid()) return;

    QDomDocument doc;
    QDomElement publish = doc.createElement("publish");
    doc.appendChild(publish);

    QDomElement item = doc.createElement("item");
    publish.appendChild(item);

    QDomElement bundle = doc.createElementNS(OMEMO_XMLNS, "bundle");
    item.appendChild(bundle);

    publish.setAttribute("node", bundleNodeName(getSignal(account)->getDeviceId()));

    QDomElement signedPreKey = doc.createElement("signedPreKeyPublic");
    signedPreKey.setAttribute("signedPreKeyId", b.signedPreKeyId);
    setNodeText(signedPreKey, b.signedPreKeyPublic);
    bundle.appendChild(signedPreKey);

    QDomElement signedPreKeySignature = doc.createElement("signedPreKeySignature");
    setNodeText(signedPreKeySignature, b.signedPreKeySignature);
    bundle.appendChild(signedPreKeySignature);

    QDomElement identityKey = doc.createElement("identityKey");
    setNodeText(identityKey, b.identityKeyPublic);
    bundle.appendChild(identityKey);

    QDomElement preKeys = doc.createElement("prekeys");
    bundle.appendChild(preKeys);

    foreach (auto preKey, b.preKeys) {
      QDomElement preKeyPublic = doc.createElement("preKeyPublic");
      preKeyPublic.setAttribute("preKeyId", preKey.first);
      setNodeText(preKeyPublic, preKey.second);
      preKeys.appendChild(preKeyPublic);
    }

    pepPublish(account, doc.toString());
  }