示例#1
0
void MucContact::changeRole( ResourceContextRef rc, Role newRole ) {
    BOOST_ASSERT(newRole<=MODERATOR);

    JabberDataBlockRef item=JabberDataBlockRef(new JabberDataBlock("item"));
    item->setAttribute("nick",jid.getResource());
    item->setAttribute("role",roleName[newRole]);
    //todo:    
    //  if (!reason.empty) item->addChild("reason", reason);

    changeMucItem(rc, item);
}
示例#2
0
JabberDataBlockRef ClientCaps::presenceEntityCaps() {
    JabberDataBlockRef c=JabberDataBlockRef(new JabberDataBlock("c"));
    c->setAttribute("xmlns", "http://jabber.org/protocol/caps");
    c->setAttribute("node", node);

    c->setAttribute("ver", getCapsHash());
    c->setAttribute("hash", alg);
    //c->setAttribute("ver", appVersion.c_str());
    //c->setAttribute("ext", appVersion.c_str());

    return c;
}
示例#3
0
void MucContact::changeAffiliation( ResourceContextRef rc, Affiliation newAffiliation ) {
    BOOST_ASSERT(newAffiliation<=OWNER);

    JabberDataBlockRef item=JabberDataBlockRef(new JabberDataBlock("item"));
    Jid rj(realJid);
    item->setAttribute("jid",rj.getBareJid());
    item->setAttribute("affiliation",affiliationName[newAffiliation-OUTCAST]);
    //todo:    
    //  if (!reason.empty) item->addChild("reason", reason);

    changeMucItem(rc, item);
}
示例#4
0
void JabberStream::tagStart(const std::string & tagname, const StringMap &attr) {

    if (tagname=="xml") return;

    JabberDataBlockRef blk=JabberDataBlockRef( new JabberDataBlock( tagname, attr ) );

    if (tagname=="stream:stream") {

        //begin conversation
        JabberListener * listener=jabberListener.get();
        if (listener!=NULL) listener->beginConversation( blk );

        return;
    }

    // stanzas
    xmlStack.push( blk);
}
示例#5
0
void ChatView::setComposingState( bool composing ) {
    if (!Config::getInstance()->composing) return;
    if (!rc->isLoggedIn()) return;

    if (!contact->acceptComposing) return;
    if (composing==this->composing) return;

    this->composing=composing;

    std::string to=contact->jid.getJid();
    JabberDataBlockRef out=JabberDataBlockRef(new JabberDataBlock("message", NULL)); 
    out->setAttribute("to", to);
    out->addChildNS(
        (composing)? "composing" : "paused",
        "http://jabber.org/protocol/chatstates");

    /* xep-0022 deprecated; will be re-enabled with entity caps
    JabberDataBlockRef x=out->addChildNS("x", "jabber:x:event");
    x->addChild("id", NULL);
    if (composing) x->addChild("composing", NULL);
    */
    rc->jabberStream->sendStanza(*out);
}
示例#6
0
MucConfigForm::ref MucConfigForm::createMucConfigForm(HWND parent, const std::string &roomJid, ResourceContextRef rc) {
    MucConfigForm *af=new MucConfigForm();

    af->parentHWnd=parent;
    af->title=utf8::utf8_wchar(roomJid);
    af->wt=WndTitleRef(new WndTitle(af, icons::ICON_AD_HOC));

    af->init();
    
    SetParent(af->thisHWnd, parent);

    af->rc=rc;
    af->roomJid=roomJid;

    MucConfigForm::ref afRef=MucConfigForm::ref(af);
    af->formRef=afRef;

    /*GetMucConfig *getah=new GetMucConfig(jid, node, afRef);
    rc->jabberStanzaDispatcherRT->addListener(JabberDataBlockListenerRef(getah));
    getah->doRequest(rc, "", "execute", JabberDataBlockRef());*/
    af->sendIq(JabberDataBlockRef());

    return afRef;
}
示例#7
0
void VcardForm::onHotSpot( LPCSTR url, LPCSTR param ) {
    std::string nurl=std::string(url);
    if (nurl=="load") {
        wchar_t filename[MAX_PATH];
        *filename=0;
        OPENFILENAME ofn;
        memset(&ofn, 0, sizeof(OPENFILENAME));
        ofn.lStructSize=sizeof(OPENFILENAME);
        ofn.hwndOwner=getHWnd();
        ofn.hInstance=g_hInst;
        ofn.lpstrFilter=FILEIMGMASK;
        ofn.nFilterIndex=0;
        ofn.lpstrFile=filename;
        ofn.nMaxFile=MAX_PATH;
        ofn.lpstrTitle=L"Select image file";
        ofn.Flags=OFN_FILEMUSTEXIST | OFN_EXPLORER;
        BOOL result=GetOpenFileNameEx(&ofn);
        if (!result) return;

        loadPhoto(filename);

        vcardArrivedNotify(vcard);
        return;
    }
    if (nurl=="save") {
        savePhoto(NULL);
        return;
    }
    if (nurl=="clear") {
        //todo: clear photo
        JabberDataBlockRef vcardTemp=vcard->findChildNamespace("vCard","vcard-temp");
        if (!vcardTemp) return;
        vcardTemp->removeChild("PHOTO");
        vcardArrivedNotify(vcard);
        return;
    }
    if (nurl=="reload") {
        //todo: re-request vcard
        return;
    }
    if (nurl=="publish") {
        //todo: publish vcard

        
        JabberDataBlockRef vcardTemp=vcard->findChildNamespace("vCard","vcard-temp");
        if (!vcardTemp) {
            vcardTemp=JabberDataBlockRef(new JabberDataBlock("vCard"));
            vcardTemp->setAttribute("xmlns","vcard-temp");
        }

        JabberDataBlock viq("iq");
        viq.setAttribute("to",vcard->getAttribute("from"));
        viq.setAttribute("type","set");
        viq.setAttribute("id","my-vcard-publish");
        viq.addChild(vcardTemp);

        StringMapRef m=HtmlView::splitHREFtext(param);
        for (StringMap::iterator i=m->begin(); i!=m->end(); i++) {
            std::string key=i->first;
            std::string value=i->second;
            std::string key2;
            int k2=key.find('#');
            if (k2>0) {
                key2=key.substr(k2+1, key.length()-k2-1);
                key=key.substr(0, k2);
            }

            JabberDataBlockRef child=vcardTemp->getChildByName(key.c_str());
            if (!child) child=vcardTemp->addChild(key.c_str(), NULL);
            if (k2>0) {
                JabberDataBlockRef child2=child->getChildByName(key2.c_str());
                if (!child2) child2=child->addChild(key2.c_str(), NULL);
                child=child2;
            }
            child->setText(value);
        }

        /*if (img) if (img->getHBmp()) {
            std::wstring imgFile=appRootPath+L"$tmpimg.jpg";
            loadPhoto(imgFile.c_str());
        }*/

        //StringRef result=viq->toXML();

        //todo: verify result
        rc.lock()->jabberStream->sendStanza(viq);
        
        vcardArrivedNotify(vcard);
        return;
    }

}