2012-06-08 09:55:00 -04:00
|
|
|
/*
|
|
|
|
* Token Queue.
|
|
|
|
*
|
|
|
|
* Copyright 2012-2012 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-09-14 20:26:33 -04:00
|
|
|
#ifndef MRK_VEG_TOKEN_QUEUE_H
|
|
|
|
#define MRK_VEG_TOKEN_QUEUE_H
|
2012-06-08 09:55:00 -04:00
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
#include <sys/time.h>
|
2012-08-03 02:39:50 -04:00
|
|
|
#include <inttypes.h>
|
2012-09-14 20:26:33 -04:00
|
|
|
#include <retroshare/rsidentityVEG.h>
|
2012-06-08 09:55:00 -04:00
|
|
|
|
|
|
|
#define COMPLETED_REQUEST 4
|
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
#define TOKENREQ_GROUPINFO 1
|
|
|
|
#define TOKENREQ_MSGINFO 2
|
|
|
|
#define TOKENREQ_MSGRELATEDINFO 3
|
2012-06-08 09:55:00 -04:00
|
|
|
|
2012-09-14 20:26:33 -04:00
|
|
|
class TokenQueueVEG;
|
2012-06-08 09:55:00 -04:00
|
|
|
|
2012-09-14 20:26:33 -04:00
|
|
|
class TokenRequestVEG
|
2012-06-08 09:55:00 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
uint32_t mToken;
|
|
|
|
uint32_t mType;
|
2012-06-13 20:36:25 -04:00
|
|
|
uint32_t mAnsType;
|
2012-06-08 09:55:00 -04:00
|
|
|
uint32_t mUserType;
|
|
|
|
struct timeval mRequestTs;
|
|
|
|
struct timeval mPollTs;
|
|
|
|
};
|
|
|
|
|
2012-09-14 20:26:33 -04:00
|
|
|
class TokenResponseVEG
|
2012-06-08 09:55:00 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
//virtual ~TokenResponse() { return; }
|
|
|
|
// These Functions are overloaded to get results out.
|
2012-09-25 17:04:04 -04:00
|
|
|
virtual void loadRequest(const TokenQueueVEG *queue, const TokenRequestVEG &req) = 0;
|
2012-06-08 09:55:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-09-14 20:26:33 -04:00
|
|
|
class TokenQueueVEG: public QWidget
|
2012-06-08 09:55:00 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-09-14 20:26:33 -04:00
|
|
|
TokenQueueVEG(RsTokenServiceVEG *service, TokenResponseVEG *resp);
|
2012-06-08 09:55:00 -04:00
|
|
|
|
|
|
|
/* generic handling of token / response update behaviour */
|
2012-09-14 20:26:33 -04:00
|
|
|
bool requestGroupInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptionsVEG &opts,
|
2012-06-13 20:36:25 -04:00
|
|
|
std::list<std::string> ids, uint32_t usertype);
|
2012-09-14 20:26:33 -04:00
|
|
|
bool requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptionsVEG &opts,
|
2012-06-13 20:36:25 -04:00
|
|
|
std::list<std::string> ids, uint32_t usertype);
|
2012-09-14 20:26:33 -04:00
|
|
|
bool requestMsgRelatedInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptionsVEG &opts,
|
2012-06-13 20:36:25 -04:00
|
|
|
std::list<std::string> ids, uint32_t usertype);
|
|
|
|
bool cancelRequest(const uint32_t token);
|
|
|
|
|
|
|
|
void queueRequest(uint32_t token, uint32_t basictype, uint32_t anstype, uint32_t usertype);
|
2012-06-08 09:55:00 -04:00
|
|
|
bool checkForRequest(uint32_t token);
|
2012-09-14 20:26:33 -04:00
|
|
|
void loadRequest(const TokenRequestVEG &req);
|
2012-06-08 09:55:00 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void doPoll(float dt);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void pollRequests();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/* Info for Data Requests */
|
2012-09-14 20:26:33 -04:00
|
|
|
std::list<TokenRequestVEG> mRequests;
|
2012-06-08 09:55:00 -04:00
|
|
|
|
2012-09-14 20:26:33 -04:00
|
|
|
RsTokenServiceVEG *mService;
|
|
|
|
TokenResponseVEG *mResponder;
|
2012-06-08 09:55:00 -04:00
|
|
|
|
|
|
|
QTimer *mTrigger;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-06-13 20:36:25 -04:00
|
|
|
|