| @@ -0,0 +1,84 @@ | ||
| /* | ||
| * Copyright 2010 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! | ||
| * \file Session.cpp | ||
| * \brief Implementation of the class Session | ||
| * | ||
| * PROJ: OSLL/geo2tag | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #include "Session.h" | ||
|
|
||
| Session::Session(const QString &sessionToken, const QDateTime &lastAccessTime, const QSharedPointer<common::User> &user) | ||
| : m_sessionToken(sessionToken), | ||
| m_lastAccessTime(lastAccessTime), | ||
| m_user(user) | ||
| { | ||
| } | ||
|
|
||
| void Session::setSessionToken(const QString &sessionToken) | ||
| { | ||
| m_sessionToken = sessionToken; | ||
| } | ||
|
|
||
| void Session::setLastAccessTime(const QDateTime lastAccessTime) | ||
| { | ||
| m_lastAccessTime = lastAccessTime; | ||
| } | ||
|
|
||
| void Session::setUser(const QSharedPointer<common::User> &user) | ||
| { | ||
| m_user = user; | ||
| } | ||
|
|
||
| const QString& Session::getSessionToken() const | ||
| { | ||
| return m_sessionToken; | ||
| } | ||
|
|
||
| const QDateTime& Session::getLastAccessTime() const | ||
| { | ||
| return m_lastAccessTime; | ||
| } | ||
|
|
||
| const QSharedPointer<common::User>& Session::getUser() const | ||
| { | ||
| return m_user; | ||
| } | ||
|
|
||
| qlonglong Session::getId() const | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
| Session::~Session() | ||
| { | ||
| } |
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright 2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! | ||
| * \file JsonSession.h | ||
| * \brief Header of JsonSession | ||
| * | ||
| * PROJ: OSLL/geo2tag | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #ifndef JSONSESSION_H | ||
| #define JSONSESSION_H | ||
|
|
||
| #include "Session.h" | ||
|
|
||
| class JsonSession: public Session | ||
| { | ||
| static qlonglong globalSessionId; | ||
| qlonglong m_id; | ||
|
|
||
| public: | ||
| JsonSession(const QString& sessionToken, | ||
| const QDateTime& lastAccessTime, | ||
| const QSharedPointer<common::User>& user); | ||
|
|
||
| qlonglong getId() const; | ||
| void setId(qlonglong); | ||
|
|
||
| ~JsonSession(); | ||
| }; | ||
|
|
||
| #endif // JSONSESSION_H |
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Copyright 2010-2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*----------------------------------------------------------------- ! | ||
| * PROJ: OSLL/geo2tag | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #ifndef QUITSESSIONREQUESTJSON_H | ||
| #define QUITSESSIONREQUESTJSON_H | ||
|
|
||
| #include "JsonSerializer.h" | ||
|
|
||
| #include <QString> | ||
|
|
||
| class QuitSessionRequestJSON: public JsonSerializer | ||
| { | ||
| private: | ||
| QString m_sessionToken; | ||
|
|
||
| public: | ||
| QuitSessionRequestJSON(QString sessionToken, QObject *parent = 0); | ||
| QuitSessionRequestJSON(QObject *parent = 0); | ||
|
|
||
| void setSessionToken(QString sessionToken); | ||
| QString getSessionToken() const; | ||
|
|
||
| QByteArray getJson() const; | ||
| bool parseJson(const QByteArray&); | ||
|
|
||
| ~QuitSessionRequestJSON(); | ||
| }; | ||
|
|
||
| #endif // QUITSESSIONREQUESTJSON_H |
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright 2010-2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*----------------------------------------------------------------- ! | ||
| * PROJ: OSLL/geo2tag | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #ifndef QUITSESSIONRESPONSEJSON_H | ||
| #define QUITSESSIONRESPONSEJSON_H | ||
|
|
||
| #include "JsonSerializer.h" | ||
|
|
||
| #include <QString> | ||
|
|
||
| class QuitSessionResponseJSON: public JsonSerializer | ||
| { | ||
| private: | ||
| QString m_sessionToken; | ||
|
|
||
| public: | ||
| QuitSessionResponseJSON(QObject *parent = 0); | ||
|
|
||
| QByteArray getJson() const; | ||
| bool parseJson(const QByteArray&); | ||
|
|
||
| ~QuitSessionResponseJSON(); | ||
| }; | ||
|
|
||
| #endif // QUITSESSIONRESPONSEJSON_H |
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright 2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! --------------------------------------------------------------- | ||
| * \file JsonSession.cpp | ||
| * \brief JsonSession implementation | ||
| * | ||
| * PROJ: OSLL/geo2tag | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #include "JsonSession.h" | ||
|
|
||
| qlonglong JsonSession::globalSessionId = 0; | ||
|
|
||
| JsonSession::JsonSession(const QString &sessionToken, const QDateTime &lastAccessTime, const QSharedPointer<common::User> &user) | ||
| : Session(sessionToken, lastAccessTime, user), | ||
| m_id(globalSessionId++) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| qlonglong JsonSession::getId() const | ||
| { | ||
| return m_id; | ||
| } | ||
|
|
||
|
|
||
| void JsonSession::setId(qlonglong id) | ||
| { | ||
| m_id = id; | ||
| } | ||
|
|
||
|
|
||
| JsonSession::~JsonSession() | ||
| { | ||
| } |
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * Copyright 2010-2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*----------------------------------------------------------------- ! | ||
| * PROJ: OSLL/geo2tag | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #include "QuitSessionRequestJSON.h" | ||
| #include "JsonUser.h" | ||
|
|
||
| #if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_SIMULATOR) | ||
| #include <qjson/parser.h> | ||
| #include <qjson/serializer.h> | ||
| #else | ||
| #include "parser.h" | ||
| #include "serializer.h" | ||
| #endif | ||
|
|
||
| QuitSessionRequestJSON::QuitSessionRequestJSON(QString sessionToken, QObject *parent) | ||
| : JsonSerializer(parent), | ||
| m_sessionToken(sessionToken) | ||
|
|
||
| { | ||
| } | ||
|
|
||
| QuitSessionRequestJSON::QuitSessionRequestJSON(QObject *parent) | ||
| : JsonSerializer(parent) | ||
| { | ||
| } | ||
|
|
||
| void QuitSessionRequestJSON::setSessionToken(QString sessionToken) | ||
| { | ||
| m_sessionToken = sessionToken; | ||
| } | ||
|
|
||
| QString QuitSessionRequestJSON::getSessionToken() const | ||
| { | ||
| return m_sessionToken; | ||
| } | ||
|
|
||
| QByteArray QuitSessionRequestJSON::getJson() const | ||
| { | ||
| QJson::Serializer serializer; | ||
| QVariantMap obj; | ||
| obj.insert("auth_token", m_sessionToken); | ||
| return serializer.serialize(obj); | ||
| } | ||
|
|
||
| bool QuitSessionRequestJSON::parseJson(const QByteArray&data) | ||
| { | ||
| QJson::Parser parser; | ||
| bool ok; | ||
| QVariantMap result = parser.parse(data, &ok).toMap(); | ||
| if (!ok) return false; | ||
|
|
||
| m_sessionToken = result["auth_token"].toString(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| QuitSessionRequestJSON::~QuitSessionRequestJSON() | ||
| { | ||
| } |
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Copyright 2010-2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*----------------------------------------------------------------- ! | ||
| * PROJ: OSLL/geo2tag | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #include "QuitSessionResponseJSON.h" | ||
| #include "JsonUser.h" | ||
|
|
||
| #if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_SIMULATOR) | ||
| #include <qjson/parser.h> | ||
| #include <qjson/serializer.h> | ||
| #else | ||
| #include "parser.h" | ||
| #include "serializer.h" | ||
| #endif | ||
|
|
||
| QuitSessionResponseJSON::QuitSessionResponseJSON(QObject *parent) | ||
| : JsonSerializer(parent) | ||
| { | ||
| } | ||
|
|
||
| QByteArray QuitSessionResponseJSON::getJson() const | ||
| { | ||
| QJson::Serializer serializer; | ||
| QVariantMap obj; | ||
| obj.insert("errno", m_errno); | ||
| return serializer.serialize(obj); | ||
| } | ||
|
|
||
| bool QuitSessionResponseJSON::parseJson(const QByteArray&data) | ||
| { | ||
| QJson::Parser parser; | ||
| bool ok; | ||
| QVariantMap result = parser.parse(data, &ok).toMap(); | ||
| if (!ok) return false; | ||
|
|
||
| m_errno = result["errno"].toInt(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| QuitSessionResponseJSON::~QuitSessionResponseJSON() | ||
| { | ||
| } |
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Copyright 2010-2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! | ||
| * \file Test_QuitSessionRequestJSON_Test.cpp | ||
| * \brief Test suite for QuitSessionRequestJSON class | ||
| * | ||
| * PROJ: OSLL/geo2tag | ||
| * ----------------------------------------------------------- */ | ||
|
|
||
| #include "Test_QuitSessionRequestJSON.h" | ||
| #include <qjson/parser.h> | ||
| #include <qjson/serializer.h> | ||
|
|
||
|
|
||
| namespace Test | ||
| { | ||
| void Test_QuitSessionRequestJSON::getJson() | ||
| { | ||
| QuitSessionRequestJSON request; | ||
| QByteArray data; | ||
| QJson::Serializer serializer; | ||
| QVariantMap obj; | ||
|
|
||
| data = QString("{\"auth_token\":\"MMMMMMMMMM\"}").toAscii(); | ||
| obj.insert("auth_token", QString("MMMMMMMMMM")); | ||
|
|
||
| QByteArray true_json = serializer.serialize(obj); | ||
|
|
||
| request.parseJson(data); | ||
| QCOMPARE(request.getJson(), true_json); | ||
| } | ||
|
|
||
| void Test_QuitSessionRequestJSON::parseJson() | ||
| { | ||
| QuitSessionRequestJSON request; | ||
| QByteArray data; | ||
|
|
||
| data = QString("{\"auth_token\":\"MMMMMMMMMM\"}").toAscii(); | ||
| QCOMPARE(request.parseJson(data), true); | ||
| QCOMPARE(request.getSessionToken(), QString("MMMMMMMMMM")); | ||
| } | ||
|
|
||
| } // end of namespace Test |
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Copyright 2010-2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! | ||
| * \file QuitSessionRequestJSON_Test.h | ||
| * \brief Test suite for QuitSessionRequestJSON class | ||
| * | ||
| * PROJ: OSLL/geo2tag | ||
| * ----------------------------------------------------------- */ | ||
|
|
||
| #ifndef TEST_QUITSESSIONREQUESTJSON_H | ||
| #define TEST_QUITSESSIONREQUESTJSON_H | ||
|
|
||
| #include <QObject> | ||
| #include <QtTest> | ||
| #include "../inc/QuitSessionRequestJSON.h" | ||
|
|
||
| namespace Test | ||
| { | ||
| class Test_QuitSessionRequestJSON : public QObject | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| private slots: | ||
| void getJson(); | ||
| void parseJson(); | ||
| }; | ||
| } | ||
|
|
||
| #endif // TEST_QUITSESSIONREQUESTJSON_H |
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright 2010-2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! | ||
| * \file Test_QuitSessionResponseJSON.cpp | ||
| * \brief Test suite for QuitSessionResponseJSON class | ||
| * | ||
| * PROJ: OSLL/geo2tag | ||
| * ----------------------------------------------------------- */ | ||
|
|
||
| #include "Test_QuitSessionResponseJSON.h" | ||
| #include <qjson/parser.h> | ||
| #include <qjson/serializer.h> | ||
|
|
||
| namespace Test | ||
| { | ||
| void Test_QuitSessionResponseJSON::getJson() | ||
| { | ||
| QuitSessionResponseJSON response; | ||
| QByteArray data; | ||
| QJson::Serializer serializer; | ||
| QVariantMap obj; | ||
|
|
||
| data = QString("{\"errno\":\"0\"}").toAscii(); | ||
| obj.insert("errno", 0); | ||
|
|
||
| QByteArray true_json = serializer.serialize(obj); | ||
|
|
||
| response.parseJson(data); | ||
| QCOMPARE(response.getJson(), true_json); | ||
| } | ||
|
|
||
| void Test_QuitSessionResponseJSON::parseJson() | ||
| { | ||
| QuitSessionResponseJSON response; | ||
| QByteArray data; | ||
|
|
||
| data = QString("{\"errno\":\"0\"}").toAscii(); | ||
| QCOMPARE(response.parseJson(data), true); | ||
| QCOMPARE(response.getErrno(), 0); | ||
| } | ||
|
|
||
| } // end of namespace Test |
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Copyright 2010-2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! | ||
| * \file Test_QuitSessionResponseJSON.h | ||
| * \brief Test suite for QuitSessionResponseJSON class | ||
| * | ||
| * PROJ: OSLL/geo2tag | ||
| * ----------------------------------------------------------- */ | ||
|
|
||
| #ifndef TEST_QUITSESSIONRESPONSEJSON_H | ||
| #define TEST_QUITSESSIONRESPONSEJSON_H | ||
|
|
||
| #include <QObject> | ||
| #include <QtTest> | ||
| #include "../inc/QuitSessionResponseJSON.h" | ||
|
|
||
| namespace Test | ||
| { | ||
| class Test_QuitSessionResponseJSON : public QObject | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| private slots: | ||
| void getJson(); | ||
| void parseJson(); | ||
| }; | ||
| } | ||
|
|
||
| #endif // TEST_QUITSESSIONRESPONSEJSON_H |
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright 2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! | ||
| * \file SessionInternal.h | ||
| * \brief Header of SessionInternal | ||
| * | ||
| * PROJ: OSLL/geo2tag | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #ifndef SESSIONINTERNAL_H | ||
| #define SESSIONINTERNAL_H | ||
|
|
||
| #include "Session.h" | ||
|
|
||
| class DbSession: public Session | ||
| { | ||
| qlonglong m_id; | ||
|
|
||
| public: | ||
| DbSession(qlonglong id, const QString& sessionToken, const QDateTime& lastAccessTime, const QSharedPointer<common::User>& user); | ||
|
|
||
| qlonglong getId() const; | ||
| void setId(qlonglong); | ||
|
|
||
| ~DbSession(); | ||
| }; | ||
|
|
||
| #endif // SESSIONINTERNAL_H |
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Copyright 2012 OSLL osll@osll.spb.ru | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * 3. The name of the author may not be used to endorse or promote | ||
| * products derived from this software without specific prior written | ||
| * permission. | ||
| * | ||
| * The advertising clause requiring mention in adverts must never be included. | ||
| */ | ||
| /*! --------------------------------------------------------------- | ||
| * \file SessionInternal.cpp | ||
| * \brief SessionInternal implementation | ||
| * | ||
| * PROJ: OSLL/geoblog | ||
| * ---------------------------------------------------------------- */ | ||
|
|
||
| #include "SessionInternal.h" | ||
|
|
||
| DbSession::DbSession(qlonglong id, | ||
| const QString &sessionToken, | ||
| const QDateTime &lastAccessTime, | ||
| const QSharedPointer<common::User> &user) | ||
| : Session(sessionToken, lastAccessTime, user), | ||
| m_id(id) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| qlonglong DbSession::getId() const | ||
| { | ||
| return m_id; | ||
| } | ||
|
|
||
|
|
||
| void DbSession::setId(qlonglong id) | ||
| { | ||
| m_id = id; | ||
| } | ||
|
|
||
|
|
||
| DbSession::~DbSession() | ||
| { | ||
| } |