From: ishmal Date: Fri, 24 Nov 2006 00:00:16 +0000 (+0000) Subject: remove 'from=' from messages, to work better with googletalk. It mangles the JID. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2f6208d6244b3600ef750c7cbd14cdcf5cb6d72e;p=inkscape.git remove 'from=' from messages, to work better with googletalk. It mangles the JID. --- diff --git a/src/pedro/pedroxmpp.cpp b/src/pedro/pedroxmpp.cpp index 17c7ef3ba..2e6f74c6a 100644 --- a/src/pedro/pedroxmpp.cpp +++ b/src/pedro/pedroxmpp.cpp @@ -763,6 +763,15 @@ static int strIndex(const DOMString &str, char *key) } +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) { @@ -975,7 +984,7 @@ static bool isGroupChat(Element *root) static bool parseJid(const DOMString &fullJid, DOMString &jid, DOMString &resource) { - int p = strIndex(fullJid, "/"); + int p = strRIndex(fullJid, "/"); if (p < 0) { jid = fullJid; @@ -983,7 +992,7 @@ static bool parseJid(const DOMString &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; } @@ -1067,11 +1076,11 @@ bool XmppClient::processMessage(Element *root) { printf("LOCKED!! ;)\n"); char *fmt = - "" + "" "" "" "\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 = - "" + "" " " " " " " @@ -1654,7 +1663,7 @@ bool XmppClient::inBandRegistrationChangePassword(const DOMString &newpassword) " " "\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; @@ -1672,10 +1681,10 @@ bool XmppClient::inBandRegistrationCancel() Parser parser; char *fmt = - "" + "" "" "\n\n"; - if (!write(fmt, msgId++, jid.c_str())) + if (!write(fmt, msgId++)) return false; return true; @@ -2418,8 +2427,8 @@ bool XmppClient::disconnect() if (connected) { char *fmt = - "\n"; - write(fmt, jid.c_str()); + "\n"; + write(fmt); } keepGoing = false; connected = false; @@ -2451,11 +2460,11 @@ bool XmppClient::rosterAdd(const DOMString &rosterGroup, if (!checkConnect()) return false; char *fmt = - "" + "" "" "%s" "\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; @@ -2473,11 +2482,11 @@ bool XmppClient::rosterDelete(const DOMString &otherJid) if (!checkConnect()) return false; char *fmt = - "" + "" "" "%s" "\n"; - if (!write(fmt, jid.c_str(), msgId++, otherJid.c_str())) + if (!write(fmt, msgId++, otherJid.c_str())) { return false; } @@ -2565,18 +2574,18 @@ bool XmppClient::message(const DOMString &user, const DOMString &subj, if (xmlSubj.size() > 0) { char *fmt = - "" + "" "%s%s\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 = - "" + "" "%s\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; @@ -2605,8 +2614,8 @@ bool XmppClient::presence(const DOMString &presence) DOMString xmlPres = toXml(presence); char *fmt = - "%s\n"; - if (!write(fmt, jid.c_str(), xmlPres.c_str())) + "%s\n"; + if (!write(fmt, xmlPres.c_str())) return false; return true; } @@ -2857,11 +2866,18 @@ bool XmppClient::groupChatMessage(const DOMString &groupJid, DOMString xmlMsg = toXml(msg); + /* char *fmt = "" "%s\n"; if (!write(fmt, jid.c_str(), groupJid.c_str(), xmlMsg.c_str())) return false; + */ + char *fmt = + "" + "%s\n"; + if (!write(fmt, groupJid.c_str(), xmlMsg.c_str())) + return false; return true; } @@ -2880,12 +2896,20 @@ bool XmppClient::groupChatPrivateMessage(const DOMString &groupJid, DOMString xmlMsg = toXml(msg); + /* char *fmt = "" "%s\n"; if (!write(fmt, jid.c_str(), groupJid.c_str(), toNick.c_str(), xmlMsg.c_str())) return false; + */ + char *fmt = + "" + "%s\n"; + if (!write(fmt, groupJid.c_str(), + toNick.c_str(), xmlMsg.c_str())) + return false; return true; } @@ -2909,9 +2933,9 @@ bool XmppClient::groupChatPresence(const DOMString &groupJid, DOMString xmlPresence = toXml(presence); char *fmt = - "" + "" "\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; @@ -2961,10 +2985,10 @@ int XmppClient::outputStreamOpen(const DOMString &destId, outs->setPeerId(destId); char *fmt = - "" + "" "\n"; - if (!write(fmt, jid.c_str(), + if (!write(fmt, destId.c_str(), iqId.c_str(), streamId.c_str())) { @@ -3020,7 +3044,7 @@ int XmppClient::outputStreamWrite(int streamNr, outLen += chunksize; char *fmt = - "" + "" "" "%s" "" @@ -3029,7 +3053,7 @@ int XmppClient::outputStreamWrite(int streamNr, "" "" "\n"; - if (!write(fmt, jid.c_str(), + if (!write(fmt, outs->getPeerId().c_str(), getMsgId(), outs->getStreamId().c_str(), @@ -3058,9 +3082,9 @@ int XmppClient::outputStreamClose(int streamNr) outs->setState(STREAM_CLOSING); char *fmt = - "" + "" "\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 = - "\n"; - if (!write(fmt, jid.c_str(), fromJid.c_str(), ins->getIqId().c_str())) + "\n"; + if (!write(fmt, fromJid.c_str(), ins->getIqId().c_str())) { return -1; } @@ -3189,8 +3213,8 @@ int XmppClient::inputStreamClose(int streamNr) if (ins->getState() == STREAM_CLOSING) { char *fmt = - "\n"; - if (!write(fmt, jid.c_str(), ins->getPeerId().c_str(), + "\n"; + if (!write(fmt, ins->getPeerId().c_str(), ins->getIqId().c_str())) { ret = -1;