summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6f8c8cf)
raw | patch | inline | side by side (parent: 6f8c8cf)
author | ishmal <ishmal@users.sourceforge.net> | |
Fri, 24 Nov 2006 00:00:16 +0000 (00:00 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Fri, 24 Nov 2006 00:00:16 +0000 (00:00 +0000) |
src/pedro/pedroxmpp.cpp | patch | blob | history |
index 17c7ef3ba94e97e12118272ca4357328d947bd9e..2e6f74c6a0e8c49e573ea42685b20fa208b7de5c 100644 (file)
--- a/src/pedro/pedroxmpp.cpp
+++ b/src/pedro/pedroxmpp.cpp
}
+static int strRIndex(const DOMString &str, char *key)
+{
+ unsigned int p = str.find_last_of(key);
+ if (p == str.npos)
+ return -1;
+ return p;
+}
+
+
DOMString XmppClient::toXml(const DOMString &str)
{
static bool parseJid(const DOMString &fullJid,
DOMString &jid, DOMString &resource)
{
- int p = strIndex(fullJid, "/");
+ int p = strRIndex(fullJid, "/");
if (p < 0)
{
jid = fullJid;
return true;
}
jid = fullJid.substr(0, p);
- resource = fullJid.substr(p+1, fullJid.size()-p-1);
+ resource = fullJid.substr(p+1, fullJid.size()-(p+1));
return true;
}
{
printf("LOCKED!! ;)\n");
char *fmt =
- "<iq from='%s' id='create%d' to='%s' type='set'>"
+ "<iq id='create%d' to='%s' type='set'>"
"<query xmlns='http://jabber.org/protocol/muc#owner'>"
"<x xmlns='jabber:x:data' type='submit'/>"
"</query></iq>\n";
- if (!write(fmt, jid.c_str(), msgId++, fromGid.c_str()))
+ if (!write(fmt, msgId++, fromGid.c_str()))
return false;
}
}
@@ -1635,7 +1644,7 @@ bool XmppClient::inBandRegistrationChangePassword(const DOMString &newpassword)
//# Let's try it form-style to allow the common old/new password thing
char *fmt =
- "<iq type='set' id='regpass%d' from='%s' to='%s'>"
+ "<iq type='set' id='regpass%d' to='%s'>"
" <query xmlns='jabber:iq:register'>"
" <x xmlns='jabber:x:data' type='form'>"
" <field type='hidden' var='FORM_TYPE'>"
@@ -1654,7 +1663,7 @@ bool XmppClient::inBandRegistrationChangePassword(const DOMString &newpassword)
" </query>"
"</iq>\n\n";
- if (!write(fmt, msgId++, jid.c_str(), host.c_str(),
+ if (!write(fmt, msgId++, host.c_str(),
username.c_str(), password.c_str(), newpassword.c_str()))
return false;
Parser parser;
char *fmt =
- "<iq type='set' id='regcancel%d' from='%s'>"
+ "<iq type='set' id='regcancel%d'>"
"<query xmlns='jabber:iq:register'><remove/></query>"
"</iq>\n\n";
- if (!write(fmt, msgId++, jid.c_str()))
+ if (!write(fmt, msgId++))
return false;
return true;
if (connected)
{
char *fmt =
- "<presence from='%s' type='unavailable'/>\n";
- write(fmt, jid.c_str());
+ "<presence type='unavailable'/>\n";
+ write(fmt);
}
keepGoing = false;
connected = false;
if (!checkConnect())
return false;
char *fmt =
- "<iq from='%s' type='set' id='roster_%d'>"
+ "<iq type='set' id='roster_%d'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='%s' name='%s'><group>%s</group></item>"
"</query></iq>\n";
- if (!write(fmt, jid.c_str(), msgId++, otherJid.c_str(),
+ if (!write(fmt, msgId++, otherJid.c_str(),
name.c_str(), rosterGroup.c_str()))
{
return false;
if (!checkConnect())
return false;
char *fmt =
- "<iq from='%s' type='set' id='roster_%d'>"
+ "<iq type='set' id='roster_%d'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='%s' subscription='remove'><group>%s</group></item>"
"</query></iq>\n";
- if (!write(fmt, jid.c_str(), msgId++, otherJid.c_str()))
+ if (!write(fmt, msgId++, otherJid.c_str()))
{
return false;
}
if (xmlSubj.size() > 0)
{
char *fmt =
- "<message from='%s' to='%s' type='chat'>"
+ "<message to='%s' type='chat'>"
"<subject>%s</subject><body>%s</body></message>\n";
- if (!write(fmt, jid.c_str(), user.c_str(),
+ if (!write(fmt, user.c_str(),
xmlSubj.c_str(), xmlMsg.c_str()))
return false;
}
else
{
char *fmt =
- "<message from='%s' to='%s'>"
+ "<message to='%s'>"
"<body>%s</body></message>\n";
- if (!write(fmt, jid.c_str(), user.c_str(), xmlMsg.c_str()))
+ if (!write(fmt, user.c_str(), xmlMsg.c_str()))
return false;
}
return true;
DOMString xmlPres = toXml(presence);
char *fmt =
- "<presence from='%s'><show>%s</show></presence>\n";
- if (!write(fmt, jid.c_str(), xmlPres.c_str()))
+ "<presence><show>%s</show></presence>\n";
+ if (!write(fmt, xmlPres.c_str()))
return false;
return true;
}
DOMString xmlMsg = toXml(msg);
+ /*
char *fmt =
"<message from='%s' to='%s' type='groupchat'>"
"<body>%s</body></message>\n";
if (!write(fmt, jid.c_str(), groupJid.c_str(), xmlMsg.c_str()))
return false;
+ */
+ char *fmt =
+ "<message to='%s' type='groupchat'>"
+ "<body>%s</body></message>\n";
+ if (!write(fmt, groupJid.c_str(), xmlMsg.c_str()))
+ return false;
return true;
}
DOMString xmlMsg = toXml(msg);
+ /*
char *fmt =
"<message from='%s' to='%s/%s' type='chat'>"
"<body>%s</body></message>\n";
if (!write(fmt, jid.c_str(), groupJid.c_str(),
toNick.c_str(), xmlMsg.c_str()))
return false;
+ */
+ char *fmt =
+ "<message to='%s/%s' type='chat'>"
+ "<body>%s</body></message>\n";
+ if (!write(fmt, groupJid.c_str(),
+ toNick.c_str(), xmlMsg.c_str()))
+ return false;
return true;
}
DOMString xmlPresence = toXml(presence);
char *fmt =
- "<presence from='%s' to='%s/%s' type='unavailable'>"
+ "<presence to='%s/%s' type='%s'>"
"<x xmlns='http://jabber.org/protocol/muc'/></presence>\n";
- if (!write(fmt, jid.c_str(), groupJid.c_str(),
+ if (!write(fmt, groupJid.c_str(),
user.c_str(), xmlPresence.c_str()))
return true;
return true;
outs->setPeerId(destId);
char *fmt =
- "<iq type='set' from='%s' to='%s' id='%s'>"
+ "<iq type='set' to='%s' id='%s'>"
"<open sid='%s' block-size='4096'"
" xmlns='http://jabber.org/protocol/ibb'/></iq>\n";
- if (!write(fmt, jid.c_str(),
+ if (!write(fmt,
destId.c_str(), iqId.c_str(),
streamId.c_str()))
{
outLen += chunksize;
char *fmt =
- "<message from='%s' to='%s' id='msg%d'>"
+ "<message to='%s' id='msg%d'>"
"<data xmlns='http://jabber.org/protocol/ibb' sid='%s' seq='%d'>"
"%s"
"</data>"
"<rule condition='match-resource' value='exact' action='error'/>"
"</amp>"
"</message>\n";
- if (!write(fmt, jid.c_str(),
+ if (!write(fmt,
outs->getPeerId().c_str(),
getMsgId(),
outs->getStreamId().c_str(),
outs->setState(STREAM_CLOSING);
char *fmt =
- "<iq type='set' from='%s' to='%s' id='%s'>"
+ "<iq type='set' to='%s' id='%s'>"
"<close sid='%s' xmlns='http://jabber.org/protocol/ibb'/></iq>\n";
- if (!write(fmt, jid.c_str(),
+ if (!write(fmt,
outs->getPeerId().c_str(),
iqId.c_str(),
outs->getStreamId().c_str()))
@@ -3137,8 +3161,8 @@ int XmppClient::inputStreamOpen(const DOMString &fromJid, const DOMString &strea
return -1;
}
char *fmt =
- "<iq type='result' from='%s' to='%s' id='%s'/>\n";
- if (!write(fmt, jid.c_str(), fromJid.c_str(), ins->getIqId().c_str()))
+ "<iq type='result' to='%s' id='%s'/>\n";
+ if (!write(fmt, fromJid.c_str(), ins->getIqId().c_str()))
{
return -1;
}
if (ins->getState() == STREAM_CLOSING)
{
char *fmt =
- "<iq type='result' from='%s' to='%s' id='%s'/>\n";
- if (!write(fmt, jid.c_str(), ins->getPeerId().c_str(),
+ "<iq type='result' to='%s' id='%s'/>\n";
+ if (!write(fmt, ins->getPeerId().c_str(),
ins->getIqId().c_str()))
{
ret = -1;