diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bcb704366cb5e333a626c18c308c7e0448a8e69f (patch) | |
tree | f0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/protocols/msn/msninvitation.cpp | |
download | tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/msn/msninvitation.cpp')
-rw-r--r-- | kopete/protocols/msn/msninvitation.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/kopete/protocols/msn/msninvitation.cpp b/kopete/protocols/msn/msninvitation.cpp new file mode 100644 index 00000000..ddc8136a --- /dev/null +++ b/kopete/protocols/msn/msninvitation.cpp @@ -0,0 +1,100 @@ +/* + msninvitation.cpp + + Copyright (c) 2003 by Olivier Goffart <ogoffart @ kde.org> + + Kopete (c) 2003 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ************************************************************************* +*/ +#include "msninvitation.h" +#include <stdlib.h> +#include <qregexp.h> + +MSNInvitation::MSNInvitation(bool incoming, const QString &applicationID , const QString &applicationName) +{ + m_incoming=incoming; + m_applicationId=applicationID; + m_applicationName=applicationName; + m_cookie= (rand()%(999999))+1; + m_state = Nothing; +} + + +MSNInvitation::~MSNInvitation() +{ +} + +QCString MSNInvitation::unimplemented(long unsigned int cookie) +{ + return QString( "MIME-Version: 1.0\r\n" + "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n" + "\r\n" + "Invitation-Command: CANCEL\r\n" + "Cancel-Code: REJECT_NOT_INSTALLED\r\n" + "Invitation-Cookie: " + QString::number(cookie) + "\r\n" + "Session-ID: {120019D9-C3F5-4F94-978D-CB33534C3309}\r\n\r\n").utf8(); + //FIXME: i don't know at all what Seession-ID is +} + +QString MSNInvitation::invitationHead() +{ + setState(Invited); + return QString( "MIME-Version: 1.0\r\n" + "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n" + "\r\n" + "Application-Name: " + m_applicationName + "\r\n" + "Application-GUID: {" + m_applicationId + "}\r\n" + "Invitation-Command: INVITE\r\n" + "Invitation-Cookie: " +QString::number(m_cookie) +"\r\n"); +} + +QCString MSNInvitation::rejectMessage(const QString & rejectcode) +{ + return QString( "MIME-Version: 1.0\r\n" + "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n" + "\r\n" + "Invitation-Command: CANCEL\r\n" + "Invitation-Cookie: " + QString::number(cookie()) + "\r\n" + "Cancel-Code: "+ rejectcode +"\r\n").utf8(); +} + +void MSNInvitation::parseInvitation(const QString& msg) +{ + QRegExp rx("Invitation-Command: ([A-Z]*)"); + rx.search(msg); + QString command=rx.cap(1); + + if(command=="INVITE") + { + rx=QRegExp("Invitation-Cookie: ([0-9]*)"); + rx.search(msg); + m_cookie=rx.cap(1).toUInt(); + } + else if(command=="CANCEL") + { + /*rx=QRegExp("Cancel-Code: ([0-9]*)"); + rx.search(msg); + QString code=rx.cap(1).toUInt(); + //TODO: parse the code*/ + } +// else if(command=="ACCEPT") +} + +MSNInvitation::State MSNInvitation::state() +{ + return m_state; +} + +void MSNInvitation::setState(MSNInvitation::State s) +{ + m_state=s; +} + |