Beispiel #1
0
void JDCommands::ls(const QString& dir)
{
    QString txt = "ls";
    if(!dir.isEmpty())
        txt += " "+dir;
    sendStanza(txt, CommandLs);
}
Beispiel #2
0
bool JabberStream::tagEnd(const std::string & tagname) {
    if (xmlStack.empty()) {
        if (tagname=="stream:stream") throw std::exception("Stream normal shutdown");
        else throw std::exception("XML Stack underflow");
    }
    JabberDataBlockRef stanza=xmlStack.top();
    xmlStack.pop();
    if (xmlStack.empty()) {
        //full stanza arrived

        if (stanza->getTagName()!=tagname) {
            throw std::exception("XML: Tag mismatch");
        }

        if (tagname=="stream:error") {
            XmppError::ref xe=XmppError::decodeStreamError(stanza);
            std::string err("Stream error: ");
            err+=xe->toString();
            throw std::exception(err.c_str());
        }
        if(Config::getInstance()->xmllog) {
            if(Config::getInstance()->isLOG)Log::getInstance()->msg("xml.in: ", stanza->toXML()->c_str());
        }
        JabberStanzaDispatcher * dispatcher= rc->jabberStanzaDispatcherRT.get();
        if (dispatcher!=NULL)
            if (! dispatcher->dispatchDataBlock(stanza)) {
                //all lesteners rejected this stanza
                if (tagname=="iq") {

                    std::string &type=stanza->getAttribute("type");
                    if (type=="error") return false; //don't reply to error stanza
                    if (type=="result") return false; //don't reply to result stanza

                    //client sould reject unknown iq-stanza
                    JabberDataBlock iqError("iq");
                    iqError.setAttribute("type", "error");
                    iqError.setAttribute("to", stanza->getAttribute("from"));
                    iqError.setAttribute("id", stanza->getAttribute("id"));
                    //todo: optional iq child blocks
                    JabberDataBlockRef err=iqError.addChild("error", NULL);
                    err->setAttribute("type","cancel");
                    err->addChildNS("feature-not-implemented", "urn:ietf:params:xml:ns:xmpp-stanzas");
                    sendStanza(iqError);
                }
            }

        //puts(element->toXML()->c_str());
    } else {
        xmlStack.top()->addChild(stanza);
    }
    return false;
}
Beispiel #3
0
void EchoPlugin::message( const PsiAccount* account, const QString& message, const QString& fromJid, const QString& fromDisplay)
{
	qWarning(qPrintable(QString("Received message '%1', echoing back to %2").arg(message).arg(fromDisplay)));
	QVariant option;
	emit getGlobalOption(message, &option);
	QString reply;
	if (option.isValid())
		reply=QString("<message to=\"%1\" type=\"chat\"><body>Option %2 = %3 </body></message>").arg(fromJid).arg(message).arg(option.toString());
	else
		reply=QString("<message to=\"%1\"><body>What you say? %2 ?</body></message>").arg(fromJid).arg(message);
	
	emit sendStanza(account, reply);
}	
Beispiel #4
0
/**
 * Отправка приглашения поиграть выбранному джиду
 */
void GameSessions::sendInvite(const int account, const QString &full_jid, const QString &element)
{
    QString new_id = newId(true);
    if (!regGameSession(StatusInviteSend, account, full_jid, new_id, element)) {
        emit doPopup(getLastError());
        return;
    }
    emit sendStanza(account, QString("<iq type=\"set\" to=\"%1\" id=\"%2\"><create xmlns=\"games:board\" id=\"%3\" type=\"%4\" color=\"%5\"></create></iq>")
            .arg(XML::escapeString(full_jid))
            .arg(new_id)
            .arg(constProtoId)
            .arg(constProtoType)
            .arg(element));
}
Beispiel #5
0
void JDCommands::send(const QString &toJid, const QString &file)
{
    sendStanza("send "+toJid+" "+file, CommandSend);
}
Beispiel #6
0
void JDCommands::help()
{
    sendStanza("help", CommandHelp);
}
Beispiel #7
0
void JDCommands::mkDir(const QString& dir)
{
    sendStanza("mkdir "+dir, CommandMkDir);
}
Beispiel #8
0
void JDCommands::lang(const QString& l)
{
    sendStanza("lang "+l, CommandLang);
}
Beispiel #9
0
void JDCommands::rm(const QString& path)
{
    sendStanza("rm "+path, CommandRm);
}
Beispiel #10
0
void JDCommands::du()
{
    sendStanza("du", CommandDu);
}
Beispiel #11
0
void JDCommands::intro()
{
    sendStanza("intro", CommandIntro);
}
Beispiel #12
0
void JDCommands::hash(const QString& file)
{
    sendStanza("hash "+file, CommandHash);
}
Beispiel #13
0
void JDCommands::pwd()
{
    sendStanza("pwd", CommandPwd);
}
Beispiel #14
0
void JDCommands::cd(const QString& dir)
{
    sendStanza("cd "+dir, CommandCd);
}
Beispiel #15
0
void JDCommands::get(const QString& file)
{
    sendStanza("get "+file, CommandGet);
}
Beispiel #16
0
void JDCommands::link(const QString &file)
{
    sendStanza("link "+file, CommandLink);
}
Beispiel #17
0
void JDCommands::mv(const QString& oldFile, const QString& newFile)
{
    sendStanza("mv "+oldFile+" "+newFile, CommandMv);
}