mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 23:36:59 -05:00
Major rewrite of New Cache Interface from the GUI side:
- Basics of Wiki, Photo, Id are working with Local Test interface. - Duplicated existing Forum : ForumV2Dialog + forumv2/* - Modified ForumV2Dialog to use Request / Response Data retrieval. - Switched Id to use TokenQueue request system. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5220 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4ba7130884
commit
a8676302ce
@ -1,7 +1,9 @@
|
||||
CONFIG += qt gui uic qrc resources uitools idle bitdht
|
||||
CONFIG += photoshare wikipoos
|
||||
CONFIG += photoshare
|
||||
CONFIG += wikipoos
|
||||
CONFIG += thewire
|
||||
CONFIG += identities
|
||||
CONFIG += forumsv2
|
||||
CONFIG += unfinished
|
||||
|
||||
QT += network xml script
|
||||
@ -912,16 +914,38 @@ thewire {
|
||||
|
||||
identities {
|
||||
|
||||
HEADERS += gui/Identity/IdDialog.h \
|
||||
HEADERS += util/TokenQueue.h \
|
||||
gui/Identity/IdDialog.h \
|
||||
gui/Identity/IdEditDialog.h \
|
||||
util/TokenQueue.h \
|
||||
|
||||
FORMS += gui/Identity/IdDialog.ui \
|
||||
gui/Identity/IdEditDialog.ui \
|
||||
|
||||
SOURCES += gui/Identity/IdDialog.cpp \
|
||||
SOURCES += util/TokenQueue.cpp \
|
||||
gui/Identity/IdDialog.cpp \
|
||||
gui/Identity/IdEditDialog.cpp \
|
||||
util/TokenQueue.cpp \
|
||||
|
||||
}
|
||||
|
||||
|
||||
forumsv2 {
|
||||
|
||||
HEADERS += gui/ForumsV2Dialog.h \
|
||||
gui/forumsv2/ForumV2Details.h \
|
||||
gui/forumsv2/EditForumV2Details.h \
|
||||
gui/forumsv2/CreateForumV2.h \
|
||||
gui/forumsv2/CreateForumV2Msg.h \
|
||||
|
||||
FORMS += gui/ForumsV2Dialog.ui \
|
||||
gui/forumsv2/ForumV2Details.ui \
|
||||
gui/forumsv2/EditForumV2Details.ui \
|
||||
gui/forumsv2/CreateForumV2.ui \
|
||||
gui/forumsv2/CreateForumV2Msg.ui \
|
||||
|
||||
SOURCES += gui/ForumsV2Dialog.cpp \
|
||||
gui/forumsv2/ForumV2Details.cpp \
|
||||
gui/forumsv2/EditForumV2Details.cpp \
|
||||
gui/forumsv2/CreateForumV2.cpp \
|
||||
gui/forumsv2/CreateForumV2Msg.cpp \
|
||||
|
||||
}
|
||||
|
2295
retroshare-gui/src/gui/ForumsV2Dialog.cpp
Normal file
2295
retroshare-gui/src/gui/ForumsV2Dialog.cpp
Normal file
File diff suppressed because it is too large
Load Diff
265
retroshare-gui/src/gui/ForumsV2Dialog.h
Normal file
265
retroshare-gui/src/gui/ForumsV2Dialog.h
Normal file
@ -0,0 +1,265 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _FORUMSV2DIALOG_H
|
||||
#define _FORUMSV2DIALOG_H
|
||||
|
||||
#include <QThread>
|
||||
|
||||
#include "mainpage.h"
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "ui_ForumsV2Dialog.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
#include <retroshare/rsforumsv2.h>
|
||||
|
||||
class ForumInfo;
|
||||
|
||||
|
||||
/* These are all the parameters that are required for thread loading.
|
||||
* They are kept static for the load duration.
|
||||
*/
|
||||
|
||||
class ForumsV2ThreadLoadParameters
|
||||
{
|
||||
public:
|
||||
|
||||
std::string ForumId;
|
||||
std::string FocusMsgId;
|
||||
|
||||
uint32_t SubscribeFlags;
|
||||
int ViewType;
|
||||
uint32_t FilterColumn;
|
||||
|
||||
std::map<uint32_t, QTreeWidgetItem *> MsgTokens;
|
||||
QList<QTreeWidgetItem*> Items;
|
||||
QList<QTreeWidgetItem*> ItemToExpand;
|
||||
|
||||
bool FillComplete;
|
||||
bool FlatView;
|
||||
bool UseChildTS;
|
||||
bool ExpandNewMessages;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ForumsV2Dialog : public RsAutoUpdatePage, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ForumsV2Dialog(QWidget *parent = 0);
|
||||
~ForumsV2Dialog();
|
||||
|
||||
bool navigate(const std::string& forumId, const std::string& msgId);
|
||||
|
||||
/* overloaded from RsAuthUpdatePage */
|
||||
virtual void updateDisplay();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
|
||||
private slots:
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void forumListCustomPopupMenu( QPoint point );
|
||||
void threadListCustomPopupMenu( QPoint point );
|
||||
void restoreForumKeys();
|
||||
void newforum();
|
||||
|
||||
void changedForum(const QString &id);
|
||||
void changedThread();
|
||||
void clickedThread (QTreeWidgetItem *item, int column);
|
||||
|
||||
void replytomessage();
|
||||
void replyMessageData(const RsForumV2Msg &msg);
|
||||
|
||||
//void print();
|
||||
//void printpreview();
|
||||
|
||||
//void removemessage();
|
||||
void markMsgAsRead();
|
||||
void markMsgAsReadChildren();
|
||||
void markMsgAsReadAll();
|
||||
void markMsgAsUnread();
|
||||
void markMsgAsUnreadAll();
|
||||
void markMsgAsUnreadChildren();
|
||||
void copyForumLink();
|
||||
void copyMessageLink();
|
||||
|
||||
/* handle splitter */
|
||||
void togglethreadview();
|
||||
|
||||
void createthread();
|
||||
void createmessage();
|
||||
|
||||
void subscribeToForum();
|
||||
void unsubscribeToForum();
|
||||
|
||||
void showForumDetails();
|
||||
void editForumDetails();
|
||||
|
||||
void previousMessage ();
|
||||
void nextMessage ();
|
||||
void nextUnreadMessage();
|
||||
void downloadAllFiles();
|
||||
|
||||
void changedViewBox();
|
||||
|
||||
void filterColumnChanged();
|
||||
void filterRegExpChanged();
|
||||
void clearFilter();
|
||||
|
||||
void generateMassData();
|
||||
|
||||
void fillThreadFinished();
|
||||
void fillThreadProgress(int current, int count);
|
||||
|
||||
void shareKey();
|
||||
|
||||
private:
|
||||
void insertForums();
|
||||
void insertThreads();
|
||||
void insertPost();
|
||||
void insertPostData(const RsForumV2Msg &msg); // Second Half.
|
||||
|
||||
void updateMessageSummaryList(std::string forumId);
|
||||
//void forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo);
|
||||
void forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo);
|
||||
|
||||
void forumSubscribe(bool subscribe);
|
||||
void FillThreads(QList<QTreeWidgetItem *> &ThreadList, bool bExpandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
|
||||
void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool bExpandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
|
||||
|
||||
int getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTreeWidgetItem*> *pRowsRead, QList<QTreeWidgetItem*> *pRowsUnread);
|
||||
void setMsgAsReadUnread(QList<QTreeWidgetItem*> &Rows, bool bRead);
|
||||
void markMsgAsReadUnread(bool bRead, bool bChildren, bool bForum);
|
||||
void CalculateIconsAndFonts(QTreeWidgetItem *pItem = NULL);
|
||||
void CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren);
|
||||
|
||||
void processSettings(bool bLoad);
|
||||
void togglethreadview_internal();
|
||||
|
||||
void FilterItems();
|
||||
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int filterColumn);
|
||||
|
||||
|
||||
// New Request/Response Loading Functions.
|
||||
void insertForumsData(const std::list<RsGroupMetaData> &forumList);
|
||||
void insertForumThreads(const RsGroupMetaData &fi);
|
||||
|
||||
void requestGroupSummary();
|
||||
void loadGroupSummary(const uint32_t &token);
|
||||
|
||||
void requestGroupSummary_CurrentForum(const std::string &forumId);
|
||||
void loadGroupSummary_CurrentForum(const uint32_t &token);
|
||||
|
||||
void loadCurrentForumThreads(const std::string &forumId);
|
||||
void requestGroupThreadData_InsertThreads(const std::string &forumId);
|
||||
void loadGroupThreadData_InsertThreads(const uint32_t &token);
|
||||
void loadForumBaseThread(const RsForumV2Msg &msg);
|
||||
|
||||
void requestChildData_InsertThreads(uint32_t &token, const std::string &parentId);
|
||||
void loadChildData_InsertThreads(const uint32_t &token);
|
||||
void loadForumChildMsg(const RsForumV2Msg &msg, QTreeWidgetItem *parent);
|
||||
|
||||
void requestMsgData_InsertPost(const std::string &msgId);
|
||||
void loadMsgData_InsertPost(const uint32_t &token);
|
||||
void requestMsgData_ReplyMessage(const std::string &msgId);
|
||||
void loadMsgData_ReplyMessage(const uint32_t &token);
|
||||
|
||||
bool convertMsgToThreadWidget(const RsForumV2Msg &msgInfo, std::string authorName,
|
||||
bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item);
|
||||
|
||||
// Callback for all Loads.
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
TokenQueue *mForumQueue;
|
||||
|
||||
|
||||
bool m_bProcessSettings;
|
||||
|
||||
QTreeWidgetItem *yourForums;
|
||||
QTreeWidgetItem *subscribedForums;
|
||||
QTreeWidgetItem *popularForums;
|
||||
QTreeWidgetItem *otherForums;
|
||||
|
||||
std::string mCurrForumId;
|
||||
std::string mCurrThreadId;
|
||||
int subscribeFlags;
|
||||
|
||||
QFont m_ForumNameFont;
|
||||
int lastViewType;
|
||||
std::string lastForumID;
|
||||
|
||||
//ForumsV2FillThread *fillThread;
|
||||
|
||||
// New Datatypes to replace the FillThread.
|
||||
bool mThreadLoading;
|
||||
ForumsV2ThreadLoadParameters mThreadLoad;
|
||||
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::ForumsV2Dialog ui;
|
||||
};
|
||||
|
||||
#if 0
|
||||
class ForumsV2FillThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ForumsV2FillThread(ForumsV2Dialog *parent);
|
||||
~ForumsV2FillThread();
|
||||
|
||||
void run();
|
||||
void stop();
|
||||
bool wasStopped() { return stopped; }
|
||||
|
||||
signals:
|
||||
void progress(int current, int count);
|
||||
|
||||
public:
|
||||
std::string forumId;
|
||||
int filterColumn;
|
||||
int subscribeFlags;
|
||||
bool fillComplete;
|
||||
int viewType;
|
||||
bool expandNewMessages;
|
||||
std::string focusMsgId;
|
||||
|
||||
QList<QTreeWidgetItem*> Items;
|
||||
QList<QTreeWidgetItem*> ItemToExpand;
|
||||
|
||||
private:
|
||||
volatile bool stopped;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
1299
retroshare-gui/src/gui/ForumsV2Dialog.ui
Normal file
1299
retroshare-gui/src/gui/ForumsV2Dialog.ui
Normal file
File diff suppressed because it is too large
Load Diff
@ -35,6 +35,9 @@
|
||||
* #define ID_DEBUG 1
|
||||
*****/
|
||||
|
||||
// Data Requests.
|
||||
#define IDDIALOG_IDLIST 1
|
||||
#define IDDIALOG_IDDETAILS 2
|
||||
|
||||
/****************************************************************
|
||||
*/
|
||||
@ -76,7 +79,9 @@ IdDialog::IdDialog(QWidget *parent)
|
||||
timer->start(1000);
|
||||
|
||||
rsIdentity->generateDummyData();
|
||||
mWaitingForRequest = false;
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity, this);
|
||||
|
||||
}
|
||||
|
||||
void IdDialog::ListTypeToggled(bool checked)
|
||||
@ -123,24 +128,25 @@ void IdDialog::blankSelection()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void IdDialog::requestIdDetails(std::string &id)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
|
||||
uint32_t token;
|
||||
std::list<std::string> groupIds;
|
||||
groupIds.push_back(id);
|
||||
|
||||
std::list<std::string> ids;
|
||||
ids.push_back(id);
|
||||
|
||||
rsIdentity->requestIdentities(token, ids);
|
||||
lockForRequest(token, RSID_REQ_IDDETAILS);
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_IDDETAILS);
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::insertIdDetails(uint32_t token)
|
||||
{
|
||||
/* get details from libretroshare */
|
||||
RsIdData data;
|
||||
if (!rsIdentity->getIdentity(token, data))
|
||||
RsIdGroup data;
|
||||
if (!rsIdentity->getGroupData(token, data))
|
||||
{
|
||||
ui.lineEdit_KeyId->setText("ERROR GETTING KEY!");
|
||||
return;
|
||||
@ -151,8 +157,10 @@ void IdDialog::insertIdDetails(uint32_t token)
|
||||
RsPeerDetails details;
|
||||
rsPeers->getPeerDetails(gpgid, details);
|
||||
|
||||
ui.lineEdit_Nickname->setText(QString::fromStdString(data.mNickname));
|
||||
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mKeyId));
|
||||
//ui.lineEdit_Nickname->setText(QString::fromStdString(data.mNickname));
|
||||
ui.lineEdit_Nickname->setText(QString::fromStdString(data.mMeta.mGroupName));
|
||||
//ui.lineEdit_KeyId->setText(QString::fromStdString(data.mKeyId));
|
||||
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId));
|
||||
ui.lineEdit_GpgHash->setText(QString::fromStdString(data.mGpgIdHash));
|
||||
ui.lineEdit_GpgId->setText(QString::fromStdString(data.mGpgId));
|
||||
ui.lineEdit_GpgName->setText(QString::fromStdString(data.mGpgName));
|
||||
@ -200,8 +208,6 @@ void IdDialog::checkUpdate()
|
||||
if (!rsIdentity)
|
||||
return;
|
||||
|
||||
checkForRequest();
|
||||
|
||||
if (rsIdentity->updated())
|
||||
{
|
||||
requestIdList();
|
||||
@ -243,57 +249,25 @@ void IdDialog::OpenOrShowEditDialog()
|
||||
}
|
||||
|
||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
||||
requestIdEdit(keyId);
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::requestIdEdit(std::string &id)
|
||||
{
|
||||
uint32_t token;
|
||||
|
||||
std::list<std::string> ids;
|
||||
ids.push_back(id);
|
||||
|
||||
rsIdentity->requestIdentities(token, ids);
|
||||
lockForRequest(token, RSID_REQ_IDEDIT);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::showIdEdit(uint32_t token)
|
||||
{
|
||||
if (mEditDialog)
|
||||
{
|
||||
mEditDialog->setupExistingId(token);
|
||||
|
||||
mEditDialog->setupExistingId(keyId);
|
||||
mEditDialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IdDialog::requestIdList()
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
|
||||
uint32_t token;
|
||||
std::list<std::string> groupIds;
|
||||
|
||||
rsIdentity->requestIdentityList(token);
|
||||
|
||||
lockForRequest(token, RSID_REQ_IDLIST);
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_IDLIST);
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::requestIdData(std::list<std::string> &ids)
|
||||
{
|
||||
uint32_t token;
|
||||
|
||||
rsIdentity->requestIdentities(token, ids);
|
||||
|
||||
lockForRequest(token, RSID_REQ_IDLISTDATA);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void IdDialog::insertIdList(uint32_t token)
|
||||
{
|
||||
QTreeWidget *tree = ui.treeWidget_IdList;
|
||||
@ -313,8 +287,8 @@ void IdDialog::insertIdList(uint32_t token)
|
||||
|
||||
//for(it = ids.begin(); it != ids.end(); it++)
|
||||
//{
|
||||
RsIdData data;
|
||||
while(rsIdentity->getIdentity(token, data))
|
||||
RsIdGroup data;
|
||||
while(rsIdentity->getGroupData(token, data))
|
||||
{
|
||||
|
||||
/* do filtering */
|
||||
@ -367,8 +341,10 @@ void IdDialog::insertIdList(uint32_t token)
|
||||
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(NULL);
|
||||
item->setText(RSID_COL_NICKNAME, QString::fromStdString(data.mNickname));
|
||||
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mKeyId));
|
||||
//item->setText(RSID_COL_NICKNAME, QString::fromStdString(data.mNickname));
|
||||
//item->setText(RSID_COL_KEYID, QString::fromStdString(data.mKeyId));
|
||||
item->setText(RSID_COL_NICKNAME, QString::fromStdString(data.mMeta.mGroupName));
|
||||
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId));
|
||||
item->setText(RSID_COL_IDTYPE, QString::fromStdString(rsIdTypeToString(data.mIdType)));
|
||||
|
||||
tree->addTopLevelItem(item);
|
||||
@ -378,102 +354,29 @@ void IdDialog::insertIdList(uint32_t token)
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void IdDialog::lockForRequest(uint32_t token, uint32_t reqtype)
|
||||
void IdDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
|
||||
/* store token for later results retrival */
|
||||
if (mWaitingForRequest)
|
||||
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
||||
switch(req.mUserType)
|
||||
{
|
||||
std::cerr << "IdDialog::lockForRequest() LOCKED ALREADY - BIG ERROR";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
mWaitingForRequest = true;
|
||||
mRequestToken = token;
|
||||
mRequestType = reqtype;
|
||||
|
||||
std::cerr << "IdDialog::lockForRequest() Token: " << token << " ReqType: " << reqtype;
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::checkForRequest()
|
||||
{
|
||||
|
||||
if (mWaitingForRequest)
|
||||
{
|
||||
/* check token */
|
||||
if (4 == rsIdentity->requestStatus(mRequestToken))
|
||||
loadRequest();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::loadRequest()
|
||||
{
|
||||
if (!mWaitingForRequest)
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() NOT LOCKED - BIG ERROR";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
/* unlock gui */
|
||||
mWaitingForRequest = false;
|
||||
|
||||
|
||||
switch (mRequestType)
|
||||
{
|
||||
case RSID_REQ_IDLIST:
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() RSID_REQ_IDLIST";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<std::string> ids;
|
||||
rsIdentity->getIdentityList(mRequestToken, ids);
|
||||
|
||||
/* request data - straight away */
|
||||
|
||||
requestIdData(ids);
|
||||
}
|
||||
break;
|
||||
|
||||
case RSID_REQ_IDLISTDATA:
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() RSID_REQ_IDLISTDATA";
|
||||
std::cerr << std::endl;
|
||||
insertIdList(mRequestToken);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case RSID_REQ_IDDETAILS:
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() RSID_REQ_IDDETAILS";
|
||||
std::cerr << std::endl;
|
||||
insertIdDetails(mRequestToken);
|
||||
}
|
||||
break;
|
||||
|
||||
case RSID_REQ_IDEDIT:
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() RSID_REQ_IDEDIT";
|
||||
std::cerr << std::endl;
|
||||
showIdEdit(mRequestToken);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDDIALOG_IDLIST:
|
||||
insertIdList(req.mToken);
|
||||
break;
|
||||
|
||||
case IDDIALOG_IDDETAILS:
|
||||
insertIdDetails(req.mToken);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
std::cerr << "IdDialog::loadRequest() ERROR";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -27,20 +27,22 @@
|
||||
#include "gui/mainpage.h"
|
||||
#include "ui_IdDialog.h"
|
||||
|
||||
#include <retroshare/rsphoto.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "gui/Identity/IdEditDialog.h"
|
||||
//#include "gui/TheWire/PulseAddDialog.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class IdDialog : public MainPage
|
||||
class IdDialog : public MainPage, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IdDialog(QWidget *parent = 0);
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
@ -64,15 +66,9 @@ private:
|
||||
void requestIdEdit(std::string &id);
|
||||
void showIdEdit(uint32_t token);
|
||||
|
||||
void lockForRequest(uint32_t token, uint32_t reqtype);
|
||||
void checkForRequest();
|
||||
void loadRequest();
|
||||
|
||||
IdEditDialog *mEditDialog;
|
||||
|
||||
bool mWaitingForRequest;
|
||||
uint32_t mRequestToken;
|
||||
uint32_t mRequestType;
|
||||
TokenQueue *mIdQueue;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::IdDialog ui;
|
||||
|
@ -22,12 +22,15 @@
|
||||
*/
|
||||
|
||||
#include "gui/Identity/IdEditDialog.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define IDEDITDIALOG_LOADID 1
|
||||
|
||||
/** Constructor */
|
||||
IdEditDialog::IdEditDialog(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@ -39,6 +42,7 @@ IdEditDialog::IdEditDialog(QWidget *parent)
|
||||
connect(ui.pushButton_Update, SIGNAL( clicked( void ) ), this, SLOT( updateId( void ) ) );
|
||||
connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelId( void ) ) );
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity, this);
|
||||
}
|
||||
|
||||
void IdEditDialog::setupNewId(bool pseudo)
|
||||
@ -98,7 +102,19 @@ void IdEditDialog::updateIdType(bool pseudo)
|
||||
}
|
||||
|
||||
|
||||
void IdEditDialog::setupExistingId(uint32_t token)
|
||||
void IdEditDialog::setupExistingId(std::string keyId)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
|
||||
std::list<std::string> groupIds;
|
||||
groupIds.push_back(keyId);
|
||||
|
||||
uint32_t token;
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDEDITDIALOG_LOADID);
|
||||
}
|
||||
|
||||
|
||||
void IdEditDialog::loadExistingId(uint32_t token)
|
||||
{
|
||||
ui.checkBox_NewId->setChecked(false);
|
||||
ui.checkBox_NewId->setEnabled(false);
|
||||
@ -106,8 +122,8 @@ void IdEditDialog::setupExistingId(uint32_t token)
|
||||
ui.radioButton_Pseudo->setEnabled(false);
|
||||
|
||||
/* get details from libretroshare */
|
||||
RsIdData data;
|
||||
if (!rsIdentity->getIdentity(token, data))
|
||||
RsIdGroup data;
|
||||
if (!rsIdentity->getGroupData(token, data))
|
||||
{
|
||||
ui.lineEdit_KeyId->setText("ERROR KEYID INVALID");
|
||||
ui.lineEdit_Nickname->setText("");
|
||||
@ -133,8 +149,10 @@ void IdEditDialog::setupExistingId(uint32_t token)
|
||||
// force - incase it wasn't triggered.
|
||||
IdTypeToggled(true);
|
||||
|
||||
ui.lineEdit_Nickname->setText(QString::fromStdString(data.mNickname));
|
||||
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mKeyId));
|
||||
//ui.lineEdit_Nickname->setText(QString::fromStdString(data.mNickname));
|
||||
//ui.lineEdit_KeyId->setText(QString::fromStdString(data.mKeyId));
|
||||
ui.lineEdit_Nickname->setText(QString::fromStdString(data.mMeta.mGroupName));
|
||||
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId));
|
||||
|
||||
if (pseudo)
|
||||
{
|
||||
@ -166,12 +184,12 @@ void IdEditDialog::setupExistingId(uint32_t token)
|
||||
|
||||
void IdEditDialog::updateId()
|
||||
{
|
||||
RsIdData rid;
|
||||
RsIdGroup rid;
|
||||
// Must set, Nickname, KeyId(if existing), mIdType, GpgId.
|
||||
|
||||
rid.mNickname = ui.lineEdit_Nickname->text().toStdString();
|
||||
rid.mMeta.mGroupName = ui.lineEdit_Nickname->text().toStdString();
|
||||
|
||||
if (rid.mNickname.size() < 2)
|
||||
if (rid.mMeta.mGroupName.size() < 2)
|
||||
{
|
||||
std::cerr << "IdEditDialog::updateId() Nickname too short";
|
||||
std::cerr << std::endl;
|
||||
@ -181,11 +199,11 @@ void IdEditDialog::updateId()
|
||||
rid.mIdType = RSID_RELATION_YOURSELF;
|
||||
if (ui.checkBox_NewId->isChecked())
|
||||
{
|
||||
rid.mKeyId = "";
|
||||
rid.mMeta.mGroupId = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
rid.mKeyId = ui.lineEdit_KeyId->text().toStdString();
|
||||
rid.mMeta.mGroupId = ui.lineEdit_KeyId->text().toStdString();
|
||||
}
|
||||
|
||||
if (ui.radioButton_GpgId->isChecked())
|
||||
@ -207,7 +225,8 @@ void IdEditDialog::updateId()
|
||||
rid.mGpgEmail = "";
|
||||
}
|
||||
|
||||
rsIdentity->updateIdentity(rid);
|
||||
// TODO.
|
||||
//rsIdentity->updateIdentity(rid);
|
||||
|
||||
hide();
|
||||
return;
|
||||
@ -225,4 +244,13 @@ void IdEditDialog::clearDialog()
|
||||
}
|
||||
|
||||
|
||||
void IdEditDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
||||
// only one here!
|
||||
loadExistingId(req.mToken);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,9 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
class IdEditDialog : public QWidget
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class IdEditDialog : public QWidget, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -36,7 +38,10 @@ public:
|
||||
IdEditDialog(QWidget *parent = 0);
|
||||
|
||||
void setupNewId(bool pseudo);
|
||||
void setupExistingId(uint32_t token);
|
||||
void setupExistingId(std::string keyId);
|
||||
void loadExistingId(uint32_t token);
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
private slots:
|
||||
|
||||
@ -52,6 +57,7 @@ protected:
|
||||
|
||||
Ui::IdEditDialog ui;
|
||||
|
||||
TokenQueue *mIdQueue;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -107,7 +107,7 @@ void PhotoAddDialog::publishAlbum()
|
||||
album.mShareOptions.mCommentMode = 0;
|
||||
album.mShareOptions.mResizeMode = 0;
|
||||
|
||||
album.mTitle = ui.lineEdit_Title->text().toStdString();
|
||||
album.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString();
|
||||
album.mCategory = "Unknown";
|
||||
album.mCaption = ui.lineEdit_Caption->text().toStdString();
|
||||
album.mWhere = ui.lineEdit_Where->text().toStdString();
|
||||
@ -122,10 +122,17 @@ void PhotoAddDialog::publishAlbum()
|
||||
{
|
||||
RsPhotoPhoto photo;
|
||||
PhotoItem *item = ui.scrollAreaWidgetContents->getPhotoIdx(i);
|
||||
photo = item->mDetails;
|
||||
|
||||
if (!item->mIsPhoto)
|
||||
{
|
||||
std::cerr << "PhotoAddDialog::publishAlbum() MAJOR ERROR!";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
photo = item->mPhotoDetails;
|
||||
item->getPhotoThumbnail(photo.mThumbnail);
|
||||
|
||||
photo.mAlbumId = album.mAlbumId;
|
||||
photo.mMeta.mGroupId = album.mMeta.mGroupId;
|
||||
photo.mOrder = i;
|
||||
|
||||
/* scale photo if needed */
|
||||
|
@ -60,14 +60,28 @@ void PhotoDetailsDialog::refreshDetails()
|
||||
|
||||
//ui.comboBox_Category= mPhotoItem->mDetails.mCaption;
|
||||
|
||||
ui.lineEdit_Caption->setText(QString::fromStdString(mPhotoItem->mDetails.mCaption));
|
||||
ui.textEdit_Description->setText(QString::fromStdString(mPhotoItem->mDetails.mDescription));
|
||||
ui.lineEdit_Photographer->setText(QString::fromStdString(mPhotoItem->mDetails.mPhotographer));
|
||||
ui.lineEdit_Where->setText(QString::fromStdString(mPhotoItem->mDetails.mWhere));
|
||||
ui.lineEdit_When->setText(QString::fromStdString(mPhotoItem->mDetails.mWhen));
|
||||
ui.lineEdit_Other->setText(QString::fromStdString(mPhotoItem->mDetails.mOther));
|
||||
ui.lineEdit_Title->setText(QString::fromStdString(mPhotoItem->mDetails.mTitle));
|
||||
ui.lineEdit_HashTags->setText(QString::fromStdString(mPhotoItem->mDetails.mHashTags));
|
||||
if (mPhotoItem->mIsPhoto)
|
||||
{
|
||||
ui.lineEdit_Caption->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mCaption));
|
||||
ui.textEdit_Description->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mDescription));
|
||||
ui.lineEdit_Photographer->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mPhotographer));
|
||||
ui.lineEdit_Where->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mWhere));
|
||||
ui.lineEdit_When->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mWhen));
|
||||
ui.lineEdit_Other->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mOther));
|
||||
ui.lineEdit_Title->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mMeta.mMsgName));
|
||||
ui.lineEdit_HashTags->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mHashTags));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.lineEdit_Caption->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mCaption));
|
||||
ui.textEdit_Description->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mDescription));
|
||||
ui.lineEdit_Photographer->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mPhotographer));
|
||||
ui.lineEdit_Where->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mWhere));
|
||||
ui.lineEdit_When->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mWhen));
|
||||
ui.lineEdit_Other->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mOther));
|
||||
ui.lineEdit_Title->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mMeta.mGroupName));
|
||||
ui.lineEdit_HashTags->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mHashTags));
|
||||
}
|
||||
|
||||
const QPixmap *qtn = mPhotoItem->getPixmap();
|
||||
QPixmap cpy(*qtn);
|
||||
@ -111,14 +125,28 @@ void PhotoDetailsDialog::saveDetails()
|
||||
|
||||
//mPhotoItem->mDetails.mCaption = ui.comboBox_Category;
|
||||
|
||||
mPhotoItem->mDetails.mCaption = ui.lineEdit_Caption->text().toStdString();
|
||||
mPhotoItem->mDetails.mDescription = ui.textEdit_Description->toPlainText().toStdString();
|
||||
mPhotoItem->mDetails.mPhotographer = ui.lineEdit_Photographer->text().toStdString();
|
||||
mPhotoItem->mDetails.mWhere = ui.lineEdit_Where->text().toStdString();
|
||||
mPhotoItem->mDetails.mWhen = ui.lineEdit_When->text().toStdString();
|
||||
mPhotoItem->mDetails.mOther = ui.lineEdit_Other->text().toStdString();
|
||||
mPhotoItem->mDetails.mTitle = ui.lineEdit_Title->text().toStdString();
|
||||
mPhotoItem->mDetails.mHashTags = ui.lineEdit_HashTags->text().toStdString();
|
||||
if (mPhotoItem->mIsPhoto)
|
||||
{
|
||||
mPhotoItem->mPhotoDetails.mCaption = ui.lineEdit_Caption->text().toStdString();
|
||||
mPhotoItem->mPhotoDetails.mDescription = ui.textEdit_Description->toPlainText().toStdString();
|
||||
mPhotoItem->mPhotoDetails.mPhotographer = ui.lineEdit_Photographer->text().toStdString();
|
||||
mPhotoItem->mPhotoDetails.mWhere = ui.lineEdit_Where->text().toStdString();
|
||||
mPhotoItem->mPhotoDetails.mWhen = ui.lineEdit_When->text().toStdString();
|
||||
mPhotoItem->mPhotoDetails.mOther = ui.lineEdit_Other->text().toStdString();
|
||||
mPhotoItem->mPhotoDetails.mMeta.mMsgName = ui.lineEdit_Title->text().toStdString();
|
||||
mPhotoItem->mPhotoDetails.mHashTags = ui.lineEdit_HashTags->text().toStdString();
|
||||
}
|
||||
else
|
||||
{
|
||||
mPhotoItem->mAlbumDetails.mCaption = ui.lineEdit_Caption->text().toStdString();
|
||||
mPhotoItem->mAlbumDetails.mDescription = ui.textEdit_Description->toPlainText().toStdString();
|
||||
mPhotoItem->mAlbumDetails.mPhotographer = ui.lineEdit_Photographer->text().toStdString();
|
||||
mPhotoItem->mAlbumDetails.mWhere = ui.lineEdit_Where->text().toStdString();
|
||||
mPhotoItem->mAlbumDetails.mWhen = ui.lineEdit_When->text().toStdString();
|
||||
mPhotoItem->mAlbumDetails.mOther = ui.lineEdit_Other->text().toStdString();
|
||||
mPhotoItem->mAlbumDetails.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString();
|
||||
mPhotoItem->mAlbumDetails.mHashTags = ui.lineEdit_HashTags->text().toStdString();
|
||||
}
|
||||
|
||||
//QPixmap qtn = mPhotoItem->getPixmap();
|
||||
//ui.label_Photo->setPixmap(qtn);
|
||||
|
@ -197,7 +197,13 @@ void PhotoDialog::insertPhotosForSelectedAlbum()
|
||||
//std::list<std::string> albumIds;
|
||||
if (mAlbumSelected)
|
||||
{
|
||||
std::string albumId = mAlbumSelected->mDetails.mAlbumId;
|
||||
if (mAlbumSelected->mIsPhoto)
|
||||
{
|
||||
std::cerr << "PhotoDialog::insertPhotosForSelectedAlbum() MAJOR ERROR!";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
std::string albumId = mAlbumSelected->mAlbumDetails.mMeta.mGroupId;
|
||||
//albumIds.push_back(albumId);
|
||||
|
||||
std::cerr << "PhotoDialog::insertPhotosForSelectedAlbum() AlbumId: " << albumId;
|
||||
@ -300,7 +306,7 @@ void PhotoDialog::clearPhotos()
|
||||
|
||||
void PhotoDialog::addAlbum(const RsPhotoAlbum &album)
|
||||
{
|
||||
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mAlbumId << std::endl;
|
||||
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
||||
|
||||
PhotoItem *item = new PhotoItem(this, album);
|
||||
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||
@ -310,8 +316,8 @@ void PhotoDialog::addAlbum(const RsPhotoAlbum &album)
|
||||
|
||||
void PhotoDialog::addPhoto(const RsPhotoPhoto &photo)
|
||||
{
|
||||
std::cerr << "PhotoDialog::addPhoto() AlbumId: " << photo.mAlbumId;
|
||||
std::cerr << " PhotoId: " << photo.mId;
|
||||
std::cerr << "PhotoDialog::addPhoto() AlbumId: " << photo.mMeta.mGroupId;
|
||||
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
PhotoItem *item = new PhotoItem(this, photo);
|
||||
@ -336,7 +342,8 @@ void PhotoDialog::requestAlbumList()
|
||||
|
||||
std::list<std::string> ids;
|
||||
RsTokReqOptions opts;
|
||||
mPhotoQueue->genericRequest(TOKENREQ_GROUPLIST, opts, ids, 0);
|
||||
uint32_t token;
|
||||
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -364,7 +371,8 @@ void PhotoDialog::loadAlbumList(const uint32_t &token)
|
||||
void PhotoDialog::requestAlbumData(const std::list<std::string> &ids)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
mPhotoQueue->genericRequest(TOKENREQ_GROUPDATA, opts, ids, 0);
|
||||
uint32_t token;
|
||||
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -381,7 +389,7 @@ bool PhotoDialog::loadAlbumData(const uint32_t &token)
|
||||
RsPhotoAlbum album;
|
||||
if (rsPhoto->getAlbum(token, album))
|
||||
{
|
||||
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mAlbumId << std::endl;
|
||||
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
||||
|
||||
PhotoItem *item = new PhotoItem(this, album);
|
||||
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||
@ -403,7 +411,8 @@ void PhotoDialog::requestPhotoList(const std::string &albumId)
|
||||
std::list<std::string> ids;
|
||||
ids.push_back(albumId);
|
||||
RsTokReqOptions opts;
|
||||
mPhotoQueue->genericRequest(TOKENREQ_MSGLIST, opts, ids, 0);
|
||||
uint32_t token;
|
||||
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -425,7 +434,8 @@ void PhotoDialog::loadPhotoList(const uint32_t &token)
|
||||
void PhotoDialog::requestPhotoData(const std::list<std::string> &photoIds)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
mPhotoQueue->genericRequest(TOKENREQ_MSGDATA, opts, photoIds, 0);
|
||||
uint32_t token;
|
||||
mPhotoQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, photoIds, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -442,8 +452,8 @@ void PhotoDialog::loadPhotoData(const uint32_t &token)
|
||||
if (rsPhoto->getPhoto(token, photo))
|
||||
{
|
||||
|
||||
std::cerr << "PhotoDialog::addPhoto() AlbumId: " << photo.mAlbumId;
|
||||
std::cerr << " PhotoId: " << photo.mId;
|
||||
std::cerr << "PhotoDialog::addPhoto() AlbumId: " << photo.mMeta.mGroupId;
|
||||
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
PhotoItem *item = new PhotoItem(this, photo);
|
||||
@ -470,17 +480,47 @@ void PhotoDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
/* now switch on req */
|
||||
switch(req.mType)
|
||||
{
|
||||
case TOKENREQ_GROUPLIST:
|
||||
loadAlbumList(req.mToken);
|
||||
case TOKENREQ_GROUPINFO:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_LIST:
|
||||
loadAlbumList(req.mToken);
|
||||
break;
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadAlbumData(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "PhotoDialog::loadRequest() ERROR: GROUP: INVALID ANS TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TOKENREQ_GROUPDATA:
|
||||
loadAlbumData(req.mToken);
|
||||
case TOKENREQ_MSGINFO:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_LIST:
|
||||
loadPhotoList(req.mToken);
|
||||
break;
|
||||
//case RS_TOKREQ_ANSTYPE_DATA:
|
||||
// loadPhotoData(req.mToken);
|
||||
// break;
|
||||
default:
|
||||
std::cerr << "PhotoDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TOKENREQ_MSGLIST:
|
||||
loadPhotoList(req.mToken);
|
||||
break;
|
||||
case TOKENREQ_MSGDATA:
|
||||
loadPhotoData(req.mToken);
|
||||
case TOKENREQ_MSGRELATEDINFO:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadPhotoData(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "PhotoDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
std::cerr << "PhotoDialog::loadRequest() ERROR: INVALID TYPE";
|
||||
|
@ -46,7 +46,8 @@ PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoAlbum &album)
|
||||
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
mDetails = *( (RsPhotoPhoto *) &(album));
|
||||
mIsPhoto = false;
|
||||
mAlbumDetails = album;
|
||||
updateAlbumText(album);
|
||||
updateImage(album.mThumbnail);
|
||||
|
||||
@ -61,7 +62,8 @@ PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo)
|
||||
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
mDetails = *( (RsPhotoPhoto *) &(photo));
|
||||
mIsPhoto = true;
|
||||
mPhotoDetails = photo;
|
||||
|
||||
updatePhotoText(photo);
|
||||
updateImage(photo.mThumbnail);
|
||||
@ -80,6 +82,8 @@ PhotoItem::PhotoItem(PhotoHolder *parent, std::string path) // for new photos.
|
||||
QString dummyString("dummytext");
|
||||
titleLabel->setText(QString("NEW PHOTO"));
|
||||
|
||||
mIsPhoto = true;
|
||||
|
||||
fromBoldLabel->setText(QString("From:"));
|
||||
fromLabel->setText(QString("Ourselves"));
|
||||
|
||||
|
@ -61,7 +61,9 @@ public:
|
||||
const QPixmap *getPixmap();
|
||||
|
||||
// details are public - so that can be easily edited.
|
||||
RsPhotoPhoto mDetails;
|
||||
bool mIsPhoto;
|
||||
RsPhotoPhoto mPhotoDetails;
|
||||
RsPhotoAlbum mAlbumDetails;
|
||||
|
||||
//private slots:
|
||||
|
||||
|
@ -61,7 +61,7 @@ void WikiAddDialog::createGroup()
|
||||
group.mShareOptions.mCommentMode = 0;
|
||||
group.mShareOptions.mResizeMode = 0;
|
||||
|
||||
group.mName = ui.lineEdit_Name->text().toStdString();
|
||||
group.mMeta.mGroupName = ui.lineEdit_Name->text().toStdString();
|
||||
group.mCategory = "Unknown";
|
||||
|
||||
rsWiki->createGroup(group);
|
||||
|
@ -509,7 +509,8 @@ void WikiDialog::requestGroupList()
|
||||
|
||||
std::list<std::string> ids;
|
||||
RsTokReqOptions opts;
|
||||
mWikiQueue->genericRequest(TOKENREQ_GROUPLIST, opts, ids, WIKIDIALOG_LISTING_GROUPLIST);
|
||||
uint32_t token;
|
||||
mWikiQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, WIKIDIALOG_LISTING_GROUPLIST);
|
||||
}
|
||||
|
||||
void WikiDialog::loadGroupList(const uint32_t &token)
|
||||
@ -534,7 +535,8 @@ void WikiDialog::loadGroupList(const uint32_t &token)
|
||||
void WikiDialog::requestGroupData(const std::list<std::string> &groupIds)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
mWikiQueue->genericRequest(TOKENREQ_GROUPDATA, opts, groupIds, WIKIDIALOG_LISTING_GROUPDATA);
|
||||
uint32_t token;
|
||||
mWikiQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, WIKIDIALOG_LISTING_GROUPDATA);
|
||||
}
|
||||
|
||||
void WikiDialog::loadGroupData(const uint32_t &token)
|
||||
@ -552,18 +554,18 @@ void WikiDialog::loadGroupData(const uint32_t &token)
|
||||
{
|
||||
/* Add Widget, and request Pages */
|
||||
|
||||
std::cerr << "WikiDialog::addGroup() GroupId: " << group.mGroupId;
|
||||
std::cerr << " Group: " << group.mName;
|
||||
std::cerr << "WikiDialog::addGroup() GroupId: " << group.mMeta.mGroupId;
|
||||
std::cerr << " Group: " << group.mMeta.mGroupName;
|
||||
std::cerr << std::endl;
|
||||
|
||||
QTreeWidgetItem *groupItem = new QTreeWidgetItem(NULL);
|
||||
groupItem->setText(WIKI_GROUP_COL_GROUPNAME, QString::fromStdString(group.mName));
|
||||
groupItem->setText(WIKI_GROUP_COL_GROUPID, QString::fromStdString(group.mGroupId));
|
||||
groupItem->setText(WIKI_GROUP_COL_GROUPNAME, QString::fromStdString(group.mMeta.mGroupName));
|
||||
groupItem->setText(WIKI_GROUP_COL_GROUPID, QString::fromStdString(group.mMeta.mGroupId));
|
||||
ui.treeWidget_Pages->addTopLevelItem(groupItem);
|
||||
|
||||
/* request pages */
|
||||
std::list<std::string> groupIds;
|
||||
groupIds.push_back(group.mGroupId);
|
||||
groupIds.push_back(group.mMeta.mGroupId);
|
||||
|
||||
requestOriginalPages(groupIds);
|
||||
}
|
||||
@ -579,7 +581,8 @@ void WikiDialog::requestOriginalPages(const std::list<std::string> &groupIds)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_ORIGMSG;
|
||||
mWikiQueue->genericRequest(TOKENREQ_MSGLIST, opts, groupIds, WIKIDIALOG_LISTING_ORIGINALPAGES);
|
||||
uint32_t token;
|
||||
mWikiQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, groupIds, WIKIDIALOG_LISTING_ORIGINALPAGES);
|
||||
}
|
||||
|
||||
void WikiDialog::loadOriginalPages(const uint32_t &token)
|
||||
@ -609,7 +612,8 @@ void WikiDialog::requestLatestPages(const std::list<std::string> &msgIds)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
||||
mWikiQueue->genericRequest(TOKENREQ_MSGRELATEDLIST, opts, msgIds, WIKIDIALOG_LISTING_LATESTPAGES);
|
||||
uint32_t token;
|
||||
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, msgIds, WIKIDIALOG_LISTING_LATESTPAGES);
|
||||
}
|
||||
|
||||
void WikiDialog::loadLatestPages(const uint32_t &token)
|
||||
@ -638,7 +642,8 @@ void WikiDialog::loadLatestPages(const uint32_t &token)
|
||||
void WikiDialog::requestPages(const std::list<std::string> &msgIds)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
mWikiQueue->genericRequest(TOKENREQ_MSGDATA, opts, msgIds, WIKIDIALOG_LISTING_PAGES);
|
||||
uint32_t token;
|
||||
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_LISTING_PAGES);
|
||||
}
|
||||
|
||||
void WikiDialog::loadPages(const uint32_t &token)
|
||||
@ -666,7 +671,7 @@ void WikiDialog::loadPages(const uint32_t &token)
|
||||
QTreeWidgetItem *tmpItem = ui.treeWidget_Pages->topLevelItem(nIndex);
|
||||
std::string tmpid = tmpItem->data(WIKI_GROUP_COL_GROUPID,
|
||||
Qt::DisplayRole).toString().toStdString();
|
||||
if (tmpid == page.mGroupId)
|
||||
if (tmpid == page.mMeta.mGroupId)
|
||||
{
|
||||
groupItem = tmpItem;
|
||||
break;
|
||||
@ -683,14 +688,14 @@ void WikiDialog::loadPages(const uint32_t &token)
|
||||
}
|
||||
|
||||
|
||||
std::cerr << "WikiDialog::loadPages() PageId: " << page.mPageId;
|
||||
std::cerr << " Page: " << page.mName;
|
||||
std::cerr << "WikiDialog::loadPages() PageId: " << page.mMeta.mMsgId;
|
||||
std::cerr << " Page: " << page.mMeta.mMsgName;
|
||||
std::cerr << std::endl;
|
||||
|
||||
QTreeWidgetItem *pageItem = new QTreeWidgetItem(NULL);
|
||||
pageItem->setText(WIKI_GROUP_COL_PAGENAME, QString::fromStdString(page.mName));
|
||||
pageItem->setText(WIKI_GROUP_COL_PAGEID, QString::fromStdString(page.mPageId));
|
||||
pageItem->setText(WIKI_GROUP_COL_ORIGPAGEID, QString::fromStdString(page.mOrigPageId));
|
||||
pageItem->setText(WIKI_GROUP_COL_PAGENAME, QString::fromStdString(page.mMeta.mMsgName));
|
||||
pageItem->setText(WIKI_GROUP_COL_PAGEID, QString::fromStdString(page.mMeta.mMsgId));
|
||||
pageItem->setText(WIKI_GROUP_COL_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId));
|
||||
|
||||
groupItem->addChild(pageItem);
|
||||
|
||||
@ -719,7 +724,8 @@ void WikiDialog::requestModPageList(const std::string &origMsgId)
|
||||
std::list<std::string> msgIds;
|
||||
msgIds.push_back(origMsgId);
|
||||
|
||||
mWikiQueue->genericRequest(TOKENREQ_MSGRELATEDLIST, opts, msgIds, WIKIDIALOG_MOD_LIST);
|
||||
uint32_t token;
|
||||
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, msgIds, WIKIDIALOG_MOD_LIST);
|
||||
}
|
||||
|
||||
|
||||
@ -749,8 +755,9 @@ void WikiDialog::loadModPageList(const uint32_t &token)
|
||||
void WikiDialog::requestModPages(const std::list<std::string> &msgIds)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
||||
mWikiQueue->genericRequest(TOKENREQ_MSGDATA, opts, msgIds, WIKIDIALOG_MOD_PAGES);
|
||||
|
||||
uint32_t token;
|
||||
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_MOD_PAGES);
|
||||
}
|
||||
|
||||
|
||||
@ -765,13 +772,13 @@ void WikiDialog::loadModPages(const uint32_t &token)
|
||||
RsWikiPage page;
|
||||
if (rsWiki->getMsgData(token, page))
|
||||
{
|
||||
std::cerr << "WikiDialog::loadModPages() PageId: " << page.mPageId;
|
||||
std::cerr << " Page: " << page.mName;
|
||||
std::cerr << "WikiDialog::loadModPages() PageId: " << page.mMeta.mMsgId;
|
||||
std::cerr << " Page: " << page.mMeta.mMsgName;
|
||||
std::cerr << std::endl;
|
||||
|
||||
QTreeWidgetItem *modItem = new QTreeWidgetItem(NULL);
|
||||
modItem->setText(WIKI_MODS_COL_ORIGPAGEID, QString::fromStdString(page.mOrigPageId));
|
||||
modItem->setText(WIKI_MODS_COL_PAGEID, QString::fromStdString(page.mPageId));
|
||||
modItem->setText(WIKI_MODS_COL_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId));
|
||||
modItem->setText(WIKI_MODS_COL_PAGEID, QString::fromStdString(page.mMeta.mMsgId));
|
||||
ui.treeWidget_Mods->addTopLevelItem(modItem);
|
||||
|
||||
}
|
||||
@ -794,7 +801,8 @@ void WikiDialog::requestWikiPage(const std::string &msgId)
|
||||
std::list<std::string> msgIds;
|
||||
msgIds.push_back(msgId);
|
||||
|
||||
mWikiQueue->genericRequest(TOKENREQ_MSGDATA, opts, msgIds, WIKIDIALOG_WIKI_PAGE);
|
||||
uint32_t token;
|
||||
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_WIKI_PAGE);
|
||||
}
|
||||
|
||||
|
||||
@ -810,8 +818,8 @@ void WikiDialog::loadWikiPage(const uint32_t &token)
|
||||
RsWikiPage page;
|
||||
if (rsWiki->getMsgData(token, page))
|
||||
{
|
||||
std::cerr << "WikiDialog::loadModPages() PageId: " << page.mPageId;
|
||||
std::cerr << " Page: " << page.mName;
|
||||
std::cerr << "WikiDialog::loadModPages() PageId: " << page.mMeta.mMsgId;
|
||||
std::cerr << " Page: " << page.mMeta.mMsgName;
|
||||
std::cerr << std::endl;
|
||||
|
||||
updateWikiPage(page);
|
||||
|
@ -43,7 +43,7 @@ void WikiEditDialog::setGroup(RsWikiGroup &group)
|
||||
{
|
||||
mWikiGroup = group;
|
||||
|
||||
ui.lineEdit_Group->setText(QString::fromStdString(mWikiGroup.mName));
|
||||
ui.lineEdit_Group->setText(QString::fromStdString(mWikiGroup.mMeta.mGroupName));
|
||||
}
|
||||
|
||||
|
||||
@ -52,8 +52,8 @@ void WikiEditDialog::setPreviousPage(RsWikiPage &page)
|
||||
mNewPage = false;
|
||||
mWikiPage = page;
|
||||
|
||||
ui.lineEdit_Page->setText(QString::fromStdString(mWikiPage.mName));
|
||||
ui.lineEdit_PrevVersion->setText(QString::fromStdString(mWikiPage.mPageId));
|
||||
ui.lineEdit_Page->setText(QString::fromStdString(mWikiPage.mMeta.mMsgName));
|
||||
ui.lineEdit_PrevVersion->setText(QString::fromStdString(mWikiPage.mMeta.mMsgId));
|
||||
ui.textEdit->setPlainText(QString::fromStdString(mWikiPage.mPage));
|
||||
}
|
||||
|
||||
@ -90,18 +90,18 @@ void WikiEditDialog::submitEdit()
|
||||
{
|
||||
if (mNewPage)
|
||||
{
|
||||
mWikiPage.mGroupId = mWikiGroup.mGroupId;
|
||||
mWikiPage.mOrigPageId = "";
|
||||
mWikiPage.mPageId = "";
|
||||
mWikiPage.mMeta.mGroupId = mWikiGroup.mMeta.mGroupId;
|
||||
mWikiPage.mMeta.mOrigMsgId = "";
|
||||
mWikiPage.mMeta.mMsgId = "";
|
||||
mWikiPage.mPrevId = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
mWikiPage.mPrevId = mWikiPage.mPageId;
|
||||
mWikiPage.mPageId = "";
|
||||
mWikiPage.mPrevId = mWikiPage.mMeta.mMsgId;
|
||||
mWikiPage.mMeta.mMsgId = "";
|
||||
}
|
||||
|
||||
mWikiPage.mName = ui.lineEdit_Page->text().toStdString();
|
||||
mWikiPage.mMeta.mMsgName = ui.lineEdit_Page->text().toStdString();
|
||||
mWikiPage.mPage = ui.textEdit->toPlainText().toStdString();
|
||||
|
||||
rsWiki->createPage(mWikiPage);
|
||||
@ -133,7 +133,8 @@ void WikiEditDialog::requestGroup(const std::string &groupId)
|
||||
ids.push_back(groupId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
mWikiQueue->genericRequest(TOKENREQ_GROUPDATA, opts, ids, 0);
|
||||
uint32_t token;
|
||||
mWikiQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0);
|
||||
}
|
||||
|
||||
void WikiEditDialog::loadGroup(const uint32_t &token)
|
||||
@ -156,7 +157,9 @@ void WikiEditDialog::requestPage(const std::string &msgId)
|
||||
std::list<std::string> ids;
|
||||
ids.push_back(msgId);
|
||||
RsTokReqOptions opts;
|
||||
mWikiQueue->genericRequest(TOKENREQ_MSGDATA, opts, ids, 0);
|
||||
|
||||
uint32_t token;
|
||||
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0);
|
||||
}
|
||||
|
||||
void WikiEditDialog::loadPage(const uint32_t &token)
|
||||
@ -181,10 +184,10 @@ void WikiEditDialog::loadRequest(const TokenQueue *queue, const TokenRequest &re
|
||||
/* now switch on req */
|
||||
switch(req.mType)
|
||||
{
|
||||
case TOKENREQ_GROUPDATA:
|
||||
case TOKENREQ_GROUPINFO:
|
||||
loadGroup(req.mToken);
|
||||
break;
|
||||
case TOKENREQ_MSGDATA:
|
||||
case TOKENREQ_MSGRELATEDINFO:
|
||||
loadPage(req.mToken);
|
||||
break;
|
||||
default:
|
||||
|
227
retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp
Normal file
227
retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp
Normal file
@ -0,0 +1,227 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "util/misc.h"
|
||||
#include "CreateForumV2.h"
|
||||
#include "gui/common/PeerDefs.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <retroshare/rsforums.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
/** Constructor */
|
||||
CreateForumV2::CreateForumV2(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
// connect up the buttons.
|
||||
connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelForum( ) ) );
|
||||
connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createForum( ) ) );
|
||||
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
|
||||
connect( ui.keyShareList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
|
||||
this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) ));
|
||||
|
||||
if(!ui.pubKeyShare_cb->isChecked()){
|
||||
|
||||
ui.contactsdockWidget->hide();
|
||||
this->resize(this->size().width() - ui.contactsdockWidget->size().width(),
|
||||
this->size().height());
|
||||
}
|
||||
|
||||
newForum();
|
||||
}
|
||||
|
||||
void CreateForumV2::newForum()
|
||||
{
|
||||
/* enforce Public for the moment */
|
||||
ui.typePublic->setChecked(true);
|
||||
|
||||
ui.typePrivate->setEnabled(false);
|
||||
ui.typeEncrypted->setEnabled(true);
|
||||
|
||||
#ifdef RS_RELEASE_VERSION
|
||||
ui.typePrivate->setVisible(false);
|
||||
ui.typeEncrypted->setVisible(true);
|
||||
#endif
|
||||
|
||||
ui.msgAnon->setChecked(true);
|
||||
//ui.msgAuth->setEnabled(false);
|
||||
|
||||
ui.forumName->clear();
|
||||
ui.forumDesc->clear();
|
||||
}
|
||||
|
||||
void CreateForumV2::togglePersonItem( QTreeWidgetItem *item, int /*col*/ )
|
||||
{
|
||||
|
||||
/* extract id */
|
||||
std::string id = (item -> text(1)).toStdString();
|
||||
|
||||
/* get state */
|
||||
bool checked = (Qt::Checked == item -> checkState(0)); /* alway column 0 */
|
||||
|
||||
/* call control fns */
|
||||
std::list<std::string>::iterator lit = std::find(mShareList.begin(), mShareList.end(), id);
|
||||
|
||||
if(checked && (lit == mShareList.end())){
|
||||
|
||||
// make sure ids not added already
|
||||
mShareList.push_back(id);
|
||||
|
||||
}else
|
||||
if(lit != mShareList.end()){
|
||||
|
||||
mShareList.erase(lit);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CreateForumV2::createForum()
|
||||
{
|
||||
QString name = misc::removeNewLine(ui.forumName->text());
|
||||
QString desc = ui.forumDesc->toPlainText(); //toHtml();
|
||||
uint32_t flags = 0;
|
||||
|
||||
if(name.isEmpty())
|
||||
{ /* error message */
|
||||
QMessageBox::warning(this, "RetroShare",
|
||||
tr("Please add a Name"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
return; //Don't add a empty name!!
|
||||
}
|
||||
else
|
||||
|
||||
if (ui.typePublic->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_PUBLIC;
|
||||
}
|
||||
else if (ui.typePrivate->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_PRIVATE;
|
||||
}
|
||||
else if (ui.typeEncrypted->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_ENCRYPTED;
|
||||
}
|
||||
|
||||
if (ui.msgAuth->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_AUTHEN_REQ;
|
||||
}
|
||||
else if (ui.msgAnon->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_AUTHEN_ANON;
|
||||
}
|
||||
|
||||
if (rsForums)
|
||||
{
|
||||
std::string forumId = rsForums->createForum(name.toStdWString(),
|
||||
desc.toStdWString(), flags);
|
||||
|
||||
if(ui.pubKeyShare_cb->isChecked())
|
||||
rsForums->forumShareKeys(forumId, mShareList);
|
||||
}
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void CreateForumV2::setShareList(){
|
||||
|
||||
if(ui.pubKeyShare_cb->isChecked()){
|
||||
this->resize(this->size().width() + ui.contactsdockWidget->size().width(),
|
||||
this->size().height());
|
||||
ui.contactsdockWidget->show();
|
||||
|
||||
|
||||
if (!rsPeers)
|
||||
{
|
||||
/* not ready yet! */
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<std::string> peers;
|
||||
std::list<std::string>::iterator it;
|
||||
|
||||
rsPeers->getFriendList(peers);
|
||||
|
||||
/* get a link to the table */
|
||||
QTreeWidget *shareWidget = ui.keyShareList;
|
||||
|
||||
QList<QTreeWidgetItem *> items;
|
||||
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*it, detail))
|
||||
{
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
/* make a widget per friend */
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
item -> setText(0, PeerDefs::nameWithLocation(detail));
|
||||
if (detail.state & RS_PEER_STATE_CONNECTED) {
|
||||
item -> setTextColor(0,(Qt::darkBlue));
|
||||
}
|
||||
item -> setSizeHint(0, QSize( 17,17 ) );
|
||||
|
||||
item -> setText(1, QString::fromStdString(detail.id));
|
||||
|
||||
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
item -> setCheckState(0, Qt::Unchecked);
|
||||
|
||||
|
||||
/* add to the list */
|
||||
items.append(item);
|
||||
}
|
||||
|
||||
/* remove old items */
|
||||
shareWidget->clear();
|
||||
shareWidget->setColumnCount(1);
|
||||
|
||||
/* add the items in! */
|
||||
shareWidget->insertTopLevelItems(0, items);
|
||||
|
||||
shareWidget->update(); /* update display */
|
||||
|
||||
}else{ // hide share widget
|
||||
ui.contactsdockWidget->hide();
|
||||
this->resize(this->size().width() - ui.contactsdockWidget->size().width(),
|
||||
this->size().height());
|
||||
mShareList.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CreateForumV2::cancelForum()
|
||||
{
|
||||
close();
|
||||
}
|
61
retroshare-gui/src/gui/forumsv2/CreateForumV2.h
Normal file
61
retroshare-gui/src/gui/forumsv2/CreateForumV2.h
Normal file
@ -0,0 +1,61 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _CREATE_FORUMV2_DIALOG_H
|
||||
#define _CREATE_FORUMV2_DIALOG_H
|
||||
|
||||
#include "ui_CreateForumV2.h"
|
||||
|
||||
class CreateForumV2 : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CreateForumV2(QWidget *parent = 0);
|
||||
|
||||
void newForum(); /* cleanup */
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateForumV2 ui;
|
||||
|
||||
QPixmap picture;
|
||||
|
||||
private slots:
|
||||
|
||||
/* actions to take.... */
|
||||
void createForum();
|
||||
void cancelForum();
|
||||
|
||||
// set private forum key share list
|
||||
void setShareList();
|
||||
|
||||
// when user checks a person in share list checkboxes
|
||||
void togglePersonItem(QTreeWidgetItem* item, int col);
|
||||
|
||||
private:
|
||||
|
||||
std::list<std::string> mShareList;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
374
retroshare-gui/src/gui/forumsv2/CreateForumV2.ui
Normal file
374
retroshare-gui/src/gui/forumsv2/CreateForumV2.ui
Normal file
@ -0,0 +1,374 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CreateForumV2</class>
|
||||
<widget class="QDialog" name="CreateForumV2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>672</width>
|
||||
<height>495</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create new Forum</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#frame_2{background-image: url(:/images/connect/connectFriendBanner.png);}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelicon">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../images.qrc">:/images/konversation64.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="textlabelcreatforums">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:24pt; font-weight:600; color:#ffffff;">New Forum</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="forumName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="3" rowspan="6">
|
||||
<widget class="QDockWidget" name="contactsdockWidget">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>524287</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>220</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>check peers you would like to share private publish key with</string>
|
||||
</property>
|
||||
<property name="floating">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Share Key With</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QGridLayout" name="_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="keyShareList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>4</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>220</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Contacts:</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="forumDesc"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="tyoeGroupBox">
|
||||
<property name="title">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="typePublic">
|
||||
<property name="text">
|
||||
<string>Public - Anyone can read and publish (Shared Publish Key)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="typePrivate">
|
||||
<property name="text">
|
||||
<string>Restricted - Anyone can read, limited publishing (Private Publish Key)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="typeEncrypted">
|
||||
<property name="text">
|
||||
<string>Private - (Private Publish Key required to view Messages)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="msgGroupBox_2">
|
||||
<property name="title">
|
||||
<string>Key Sharing</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="_5">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="pubKeyShare_cb">
|
||||
<property name="toolTip">
|
||||
<string>Key recipients can publish to restricted-type channels, and can view and publish for private-type channels </string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Share Private Publish Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="msgGroupBox">
|
||||
<property name="title">
|
||||
<string>Allowed Messages</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="_4">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="msgAuth">
|
||||
<property name="text">
|
||||
<string>Authenticated Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="msgAnon">
|
||||
<property name="text">
|
||||
<string>Anonymous Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>238</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="createButton">
|
||||
<property name="text">
|
||||
<string>Create</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
247
retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp
Normal file
247
retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp
Normal file
@ -0,0 +1,247 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "CreateForumV2Msg.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QFile>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDropEvent>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <retroshare/rsforums.h>
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/common/Emoticons.h"
|
||||
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
/** Constructor */
|
||||
CreateForumV2Msg::CreateForumV2Msg(std::string fId, std::string pId)
|
||||
: QMainWindow(NULL), mForumId(fId), mParentId(pId)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
Settings->loadWidgetInformation(this);
|
||||
|
||||
connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) );
|
||||
|
||||
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
|
||||
|
||||
// connect up the buttons.
|
||||
connect( ui.postmessage_action, SIGNAL( triggered (bool) ), this, SLOT( createMsg( ) ) );
|
||||
connect( ui.close_action, SIGNAL( triggered (bool) ), this, SLOT( cancelMsg( ) ) );
|
||||
connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
|
||||
connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile()));
|
||||
connect( ui.pastersButton, SIGNAL(clicked() ), this , SLOT(pasteLink()));
|
||||
|
||||
setAcceptDrops(true);
|
||||
ui.hashBox->setDropWidget(this);
|
||||
ui.hashBox->setAutoHide(false);
|
||||
|
||||
newMsg();
|
||||
}
|
||||
|
||||
/** context menu searchTablewidget2 **/
|
||||
void CreateForumV2Msg::forumMessageCostumPopupMenu( QPoint /*point*/ )
|
||||
{
|
||||
QMenu *contextMnu = ui.forumMessage->createStandardContextMenu();
|
||||
|
||||
contextMnu->addSeparator();
|
||||
QAction *pasteLinkAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
|
||||
QAction *pasteLinkFullAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste full RetroShare Link"), this, SLOT(pasteLinkFull()));
|
||||
|
||||
if (RSLinkClipboard::empty()) {
|
||||
pasteLinkAct->setDisabled (true);
|
||||
pasteLinkFullAct->setDisabled (true);
|
||||
}
|
||||
|
||||
contextMnu->exec(QCursor::pos());
|
||||
delete(contextMnu);
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::newMsg()
|
||||
{
|
||||
/* clear all */
|
||||
ForumInfo fi;
|
||||
if (rsForums->getForumInfo(mForumId, fi))
|
||||
{
|
||||
ForumMsgInfo msg;
|
||||
|
||||
QString name = QString::fromStdWString(fi.forumName);
|
||||
QString subj;
|
||||
if ((mParentId != "") && (rsForums->getForumMessage(mForumId, mParentId, msg)))
|
||||
{
|
||||
QString title = QString::fromStdWString(msg.title);
|
||||
name += " " + tr("In Reply to") + ": ";
|
||||
name += title;
|
||||
|
||||
QString text = title;
|
||||
|
||||
if (text.startsWith("Re:", Qt::CaseInsensitive))
|
||||
{
|
||||
subj = title;
|
||||
}
|
||||
else
|
||||
{
|
||||
subj = "Re: " + title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui.forumName->setText(misc::removeNewLine(name));
|
||||
ui.forumSubject->setText(misc::removeNewLine(subj));
|
||||
|
||||
if (!ui.forumSubject->text().isEmpty())
|
||||
{
|
||||
ui.forumMessage->setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.forumSubject->setFocus();
|
||||
}
|
||||
|
||||
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||
{
|
||||
ui.signBox->setChecked(true);
|
||||
ui.signBox->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Uncheck sign box by default for anonymous forums */
|
||||
ui.signBox->setChecked(false);
|
||||
ui.signBox->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
ui.forumMessage->setText("");
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::createMsg()
|
||||
{
|
||||
QString name = misc::removeNewLine(ui.forumSubject->text());
|
||||
QString desc = ui.forumMessage->toHtml();
|
||||
|
||||
if(desc == QTextDocument(ui.forumMessage->toPlainText()).toHtml())
|
||||
desc = ui.forumMessage->toPlainText() ;
|
||||
|
||||
if(name.isEmpty())
|
||||
{ /* error message */
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return; //Don't add a empty Subject!!
|
||||
}
|
||||
|
||||
ForumMsgInfo msgInfo;
|
||||
|
||||
msgInfo.forumId = mForumId;
|
||||
msgInfo.threadId = "";
|
||||
msgInfo.parentId = mParentId;
|
||||
msgInfo.msgId = "";
|
||||
|
||||
msgInfo.title = name.toStdWString();
|
||||
msgInfo.msg = desc.toStdWString();
|
||||
msgInfo.msgflags = 0;
|
||||
|
||||
if (ui.signBox->isChecked())
|
||||
{
|
||||
msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ;
|
||||
}
|
||||
|
||||
if ((msgInfo.msg == L"") && (msgInfo.title == L""))
|
||||
return; /* do nothing */
|
||||
|
||||
if (rsForums->ForumMessageSend(msgInfo) == true) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::closeEvent (QCloseEvent * /*event*/)
|
||||
{
|
||||
Settings->saveWidgetInformation(this);
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::cancelMsg()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::smileyWidgetForums()
|
||||
{
|
||||
Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false);
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::addSmileys()
|
||||
{
|
||||
ui.forumMessage->textCursor().insertText(qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::addFile()
|
||||
{
|
||||
QStringList files;
|
||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
|
||||
ui.hashBox->addAttachments(files);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::fileHashingFinished(QList<HashedFile> hashedFiles)
|
||||
{
|
||||
std::cerr << "CreateForumV2Msg::fileHashingFinished() started." << std::endl;
|
||||
|
||||
QString mesgString;
|
||||
|
||||
QList<HashedFile>::iterator it;
|
||||
for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) {
|
||||
HashedFile& hashedFile = *it;
|
||||
RetroShareLink link;
|
||||
if (link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash))) {
|
||||
mesgString += link.toHtmlSize() + "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "CreateForumV2Msg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
if (!mesgString.isEmpty()) {
|
||||
ui.forumMessage->textCursor().insertHtml(mesgString);
|
||||
}
|
||||
|
||||
ui.forumMessage->setFocus( Qt::OtherFocusReason );
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::pasteLink()
|
||||
{
|
||||
ui.forumMessage->insertHtml(RSLinkClipboard::toHtml()) ;
|
||||
}
|
||||
|
||||
void CreateForumV2Msg::pasteLinkFull()
|
||||
{
|
||||
ui.forumMessage->insertHtml(RSLinkClipboard::toHtmlFull()) ;
|
||||
}
|
64
retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h
Normal file
64
retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _CREATE_FORUMV2_MSG_DIALOG_H
|
||||
#define _CREATE_FORUMV2_MSG_DIALOG_H
|
||||
|
||||
#include "ui_CreateForumV2Msg.h"
|
||||
|
||||
class CreateForumV2Msg : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CreateForumV2Msg(std::string fId, std::string pId);
|
||||
|
||||
void newMsg(); /* cleanup */
|
||||
|
||||
private slots:
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void forumMessageCostumPopupMenu( QPoint point );
|
||||
|
||||
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
||||
/* actions to take.... */
|
||||
void createMsg();
|
||||
void cancelMsg();
|
||||
void pasteLink();
|
||||
void pasteLinkFull();
|
||||
|
||||
void smileyWidgetForums();
|
||||
void addSmileys();
|
||||
void addFile();
|
||||
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
private:
|
||||
std::string mForumId;
|
||||
std::string mParentId;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateForumV2Msg ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
333
retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.ui
Normal file
333
retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.ui
Normal file
@ -0,0 +1,333 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CreateForumV2Msg</class>
|
||||
<widget class="QMainWindow" name="CreateForumV2Msg">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>482</width>
|
||||
<height>448</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Post Forum Message</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QToolBar#toolBar{background-image: url(:/images/connect/connectFriendBanner.png)}</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame_4">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Forum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="forumName">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Subject</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="forumSubject"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>38</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#frame_2{
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||
stop:0 #FEFEFE, stop:1 #E8E8E8);
|
||||
|
||||
border: 1px solid #CCCCCC;}</string>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="attachFileButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Attach File</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="emoticonButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/emoticons/kopete/kopete020.png</normaloff>:/images/emoticons/kopete/kopete020.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="signBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sign Message</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/pgp.png</normaloff>:/images/pgp.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pastersButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Paste RetroShare Link</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/pasterslink.png</normaloff>:/images/pasterslink.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QFrame" name="frame_3">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Forum Post</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="forumMessage">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Attach files via drag and drop</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="HashBox" name="hashBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>You can attach files via drag and drop here in this window</string>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string notr="true">toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="postmessage_action"/>
|
||||
<addaction name="close_action"/>
|
||||
</widget>
|
||||
<action name="postmessage_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/mail_send24.png</normaloff>:/images/mail_send24.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Post Forum Msg</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="close_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/button_cancel.png</normaloff>:/images/button_cancel.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>HashBox</class>
|
||||
<extends>QScrollArea</extends>
|
||||
<header location="global">gui/common/HashBox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
81
retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp
Normal file
81
retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2010 RetroShare Team
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "EditForumV2Details.h"
|
||||
|
||||
#include <retroshare/rsforums.h>
|
||||
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
/** Default constructor */
|
||||
EditForumV2Details::EditForumV2Details(std::string forumId, QWidget *parent, Qt::WFlags flags)
|
||||
: QDialog(parent, flags), m_forumId(forumId)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
|
||||
|
||||
loadForum();
|
||||
}
|
||||
|
||||
void EditForumV2Details::loadForum()
|
||||
{
|
||||
if (!rsForums) {
|
||||
return;
|
||||
}
|
||||
|
||||
ForumInfo info;
|
||||
rsForums->getForumInfo(m_forumId, info);
|
||||
|
||||
// set name
|
||||
ui.nameline->setText(QString::fromStdWString(info.forumName));
|
||||
|
||||
// set description
|
||||
ui.DescriptiontextEdit->setText(QString::fromStdWString(info.forumDesc));
|
||||
}
|
||||
|
||||
void EditForumV2Details::applyDialog()
|
||||
{
|
||||
if (!rsForums) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if text boxes have not been edited leave alone
|
||||
if (!ui.nameline->isModified() && !ui.DescriptiontextEdit->document()->isModified()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ForumInfo info;
|
||||
|
||||
info.forumName = misc::removeNewLine(ui.nameline->text()).toStdWString();
|
||||
info.forumDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString();
|
||||
|
||||
rsForums->setForumInfo(m_forumId, info);
|
||||
|
||||
/* close the Dialog after the Changes applied */
|
||||
close();
|
||||
}
|
53
retroshare-gui/src/gui/forumsv2/EditForumV2Details.h
Normal file
53
retroshare-gui/src/gui/forumsv2/EditForumV2Details.h
Normal file
@ -0,0 +1,53 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2010 RetroShare Team
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _EDITFORUMV2DETAILS_H
|
||||
#define _EDITFORUMV2DETAILS_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_EditForumV2Details.h"
|
||||
|
||||
class EditForumV2Details : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default constructor */
|
||||
EditForumV2Details(std::string forumId = "", QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
||||
signals:
|
||||
void configChanged();
|
||||
|
||||
private slots:
|
||||
void applyDialog();
|
||||
|
||||
private:
|
||||
void loadForum();
|
||||
|
||||
std::string m_forumId;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::EditForumV2Details ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
130
retroshare-gui/src/gui/forumsv2/EditForumV2Details.ui
Normal file
130
retroshare-gui/src/gui/forumsv2/EditForumV2Details.ui
Normal file
@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditForumV2Details</class>
|
||||
<widget class="QDialog" name="EditForumV2Details">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>436</width>
|
||||
<height>355</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Forum Details</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="_2">
|
||||
<item row="0" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>311</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="applyButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="stabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/info16.png</normaloff>:/images/info16.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Edit Forum Details</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Forum Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Forum Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="nameline"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Forum Description</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="DescriptiontextEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>cancelButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>EditForumDetails</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>307</x>
|
||||
<y>333</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>217</x>
|
||||
<y>177</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
143
retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp
Normal file
143
retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2009 RetroShare Team
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
#include "ForumV2Details.h"
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsdisc.h>
|
||||
#include <retroshare/rsforums.h>
|
||||
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
/* Define the format used for displaying the date and time */
|
||||
#define DATETIME_FMT "MMM dd hh:mm:ss"
|
||||
|
||||
/** Default constructor */
|
||||
ForumV2Details::ForumV2Details(QWidget *parent, Qt::WFlags flags)
|
||||
: QDialog(parent, flags)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
|
||||
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
|
||||
|
||||
ui.applyButton->setToolTip(tr("Apply and Close"));
|
||||
|
||||
ui.nameline ->setReadOnly(true);
|
||||
ui.popline ->setReadOnly(true);
|
||||
ui.postline ->setReadOnly(true);
|
||||
ui.IDline ->setReadOnly(true);
|
||||
ui.DescriptiontextEdit ->setReadOnly(true);
|
||||
|
||||
ui.radioButton_authd->setEnabled(false);
|
||||
ui.radioButton_anonymous->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Overloads the default show() slot so we can set opacity*/
|
||||
|
||||
void
|
||||
ForumV2Details::show()
|
||||
{
|
||||
//loadSettings();
|
||||
if(!this->isVisible()) {
|
||||
QDialog::show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ForumV2Details::closeEvent (QCloseEvent * event)
|
||||
{
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
void ForumV2Details::closeinfodlg()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void ForumV2Details::showDetails(std::string mCurrForumId)
|
||||
{
|
||||
fId = mCurrForumId;
|
||||
loadDialog();
|
||||
}
|
||||
|
||||
void ForumV2Details::loadDialog()
|
||||
{
|
||||
if (!rsForums)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ForumInfo fi;
|
||||
rsForums->getForumInfo(fId, fi);
|
||||
|
||||
// Set Forum Name
|
||||
ui.nameline->setText(QString::fromStdWString(fi.forumName));
|
||||
|
||||
// Set Popularity
|
||||
ui.popline->setText(QString::number(fi.pop));
|
||||
|
||||
// Set Last Post Date
|
||||
if (fi.lastPost) {
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(fi.lastPost);
|
||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
ui.postline->setText(timestamp);
|
||||
}
|
||||
|
||||
// Set Forum ID
|
||||
ui.IDline->setText(QString::fromStdString(fi.forumId));
|
||||
|
||||
// Set Forum Description
|
||||
ui.DescriptiontextEdit->setText(QString::fromStdWString(fi.forumDesc));
|
||||
|
||||
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||
{
|
||||
ui.radioButton_authd->setChecked(true);
|
||||
ui.radioButton_anonymous->setChecked(false);
|
||||
}
|
||||
if (fi.forumFlags & RS_DISTRIB_AUTHEN_ANON)
|
||||
{
|
||||
ui.radioButton_authd->setChecked(false);
|
||||
ui.radioButton_anonymous->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ForumV2Details::applyDialog()
|
||||
{
|
||||
|
||||
/* reload now */
|
||||
loadDialog();
|
||||
|
||||
/* close the Dialog after the Changes applied */
|
||||
closeinfodlg();
|
||||
|
||||
}
|
67
retroshare-gui/src/gui/forumsv2/ForumV2Details.h
Normal file
67
retroshare-gui/src/gui/forumsv2/ForumV2Details.h
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2009 RetroShare Team
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _FORUMV2DETAILS_H
|
||||
#define _FORUMV2DETAILS_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_ForumV2Details.h"
|
||||
|
||||
class ForumV2Details : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/** Default constructor */
|
||||
ForumV2Details(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
|
||||
void showDetails(std::string mCurrForumId);
|
||||
|
||||
signals:
|
||||
void configChanged() ;
|
||||
|
||||
public slots:
|
||||
/** Overloaded QWidget.show */
|
||||
void show();
|
||||
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
private slots:
|
||||
|
||||
void closeinfodlg();
|
||||
void applyDialog();
|
||||
|
||||
private:
|
||||
|
||||
void loadDialog();
|
||||
|
||||
std::string fId;
|
||||
/** Qt Designer generated object */
|
||||
Ui::ForumV2Details ui;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
201
retroshare-gui/src/gui/forumsv2/ForumV2Details.ui
Normal file
201
retroshare-gui/src/gui/forumsv2/ForumV2Details.ui
Normal file
@ -0,0 +1,201 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ForumV2Details</class>
|
||||
<widget class="QDialog" name="ForumV2Details">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>436</width>
|
||||
<height>355</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Forum Details</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="stabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/info16.png</normaloff>:/images/info16.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Forum Details</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Forum Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Forum Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="nameline"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Popularity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="popline">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Last Post</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="postline">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Forum ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="IDline"/>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Forum Description</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="DescriptiontextEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Seite">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/encrypted22.png</normaloff>:/images/encrypted22.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Security</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Allowed Messages</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_authd">
|
||||
<property name="text">
|
||||
<string>Authemticated Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_anonymous">
|
||||
<property name="text">
|
||||
<string>Anonymous Messages</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>358</width>
|
||||
<height>172</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>311</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="applyButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -36,6 +36,7 @@
|
||||
#include "gui/WikiPoos/WikiDialog.h"
|
||||
#include "gui/TheWire/WireDialog.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
#include "gui/ForumsV2Dialog.h"
|
||||
|
||||
//#include "GamesDialog.h"
|
||||
//#include "CalDialog.h"
|
||||
@ -55,7 +56,7 @@
|
||||
#define IMAGE_CALENDAR ":/images/calendar.png"
|
||||
#define IMAGE_LIBRARY ":/images/library.png"
|
||||
#define IMAGE_PLUGINS ":/images/extension_32.png"
|
||||
|
||||
#define IMAGE_FORUMSV2 ":/images/konversation.png"
|
||||
|
||||
/** Constructor */
|
||||
ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
|
||||
@ -91,7 +92,6 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
|
||||
//ui.stackPages->add(calDialog = new CalDialog(ui.stackPages),
|
||||
// createPageAction(QIcon(IMAGE_CALENDAR), tr("Shared Calendars"), grp));
|
||||
|
||||
|
||||
IdDialog *idDialog = NULL;
|
||||
ui.stackPages->add(idDialog = new IdDialog(ui.stackPages),
|
||||
createPageAction(QIcon(IMAGE_LIBRARY), tr("Identities"), grp));
|
||||
@ -108,6 +108,10 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
|
||||
ui.stackPages->add(wireDialog = new WireDialog(ui.stackPages),
|
||||
createPageAction(QIcon(IMAGE_BWGRAPH), tr("The Wire"), grp));
|
||||
|
||||
ForumsV2Dialog *forumsV2Dialog = NULL;
|
||||
ui.stackPages->add(forumsV2Dialog = new ForumsV2Dialog(ui.stackPages),
|
||||
createPageAction(QIcon(IMAGE_FORUMSV2), tr("ForumsV2"), grp));
|
||||
|
||||
/* Create the toolbar */
|
||||
ui.toolBar->addActions(grp->actions());
|
||||
ui.toolBar->addSeparator();
|
||||
@ -142,7 +146,7 @@ void ApplicationWindow::show()
|
||||
QMainWindow::show();
|
||||
} else {
|
||||
QMainWindow::activateWindow();
|
||||
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
|
||||
setWindowState(windowState() & (~Qt::WindowMinimized | Qt::WindowActive));
|
||||
QMainWindow::raise();
|
||||
}
|
||||
}
|
||||
|
@ -34,54 +34,49 @@
|
||||
TokenQueue::TokenQueue(RsTokenService *service, TokenResponse *resp)
|
||||
:QWidget(NULL), mService(service), mResponder(resp)
|
||||
{
|
||||
//mTrigger = new QTimer(this);
|
||||
//mTrigger->connect(mTrigger, SIGNAL(timeout()), this, SLOT(pollRequests()));
|
||||
return;
|
||||
}
|
||||
|
||||
bool TokenQueue::genericRequest(uint32_t basictype, const RsTokReqOptions &opts, std::list<std::string> ids, uint32_t usertype)
|
||||
bool TokenQueue::requestGroupInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, std::list<std::string> ids, uint32_t usertype)
|
||||
{
|
||||
uint32_t token;
|
||||
switch(basictype)
|
||||
{
|
||||
case TOKENREQ_GROUPLIST:
|
||||
mService->requestGroupList(token, opts);
|
||||
break;
|
||||
|
||||
case TOKENREQ_GROUPDATA:
|
||||
mService->requestGroupData(token, ids);
|
||||
break;
|
||||
|
||||
case TOKENREQ_MSGLIST:
|
||||
mService->requestMsgList(token, opts, ids);
|
||||
break;
|
||||
|
||||
case TOKENREQ_MSGRELATEDLIST:
|
||||
mService->requestMsgRelatedList(token, opts, ids);
|
||||
break;
|
||||
|
||||
case TOKENREQ_MSGDATA:
|
||||
mService->requestMsgData(token, ids);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
queueRequest(token, basictype, usertype);
|
||||
uint32_t basictype = TOKENREQ_GROUPINFO;
|
||||
mService->requestGroupInfo(token, anstype, opts, ids);
|
||||
queueRequest(token, basictype, anstype, usertype);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TokenQueue::queueRequest(uint32_t token, uint32_t basictype, uint32_t usertype)
|
||||
bool TokenQueue::requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, std::list<std::string> ids, uint32_t usertype)
|
||||
{
|
||||
std::cerr << "TokenQueue::queueRequest() Token: " << token << " Type: " << basictype << " UserType: " << usertype;
|
||||
uint32_t basictype = TOKENREQ_MSGINFO;
|
||||
mService->requestMsgInfo(token, anstype, opts, ids);
|
||||
queueRequest(token, basictype, anstype, usertype);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TokenQueue::requestMsgRelatedInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, std::list<std::string> ids, uint32_t usertype)
|
||||
{
|
||||
uint32_t basictype = TOKENREQ_MSGRELATEDINFO;
|
||||
mService->requestMsgRelatedInfo(token, anstype, opts, ids);
|
||||
queueRequest(token, basictype, anstype, usertype);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TokenQueue::queueRequest(uint32_t token, uint32_t basictype, uint32_t anstype, uint32_t usertype)
|
||||
{
|
||||
std::cerr << "TokenQueue::queueRequest() Token: " << token << " Type: " << basictype;
|
||||
std::cerr << " AnsType: " << anstype << " UserType: " << usertype;
|
||||
std::cerr << std::endl;
|
||||
|
||||
TokenRequest req;
|
||||
req.mToken = token;
|
||||
req.mType = basictype;
|
||||
req.mAnsType = anstype;
|
||||
req.mUserType = usertype;
|
||||
|
||||
gettimeofday(&req.mRequestTs, NULL);
|
||||
@ -143,9 +138,9 @@ bool TokenQueue::checkForRequest(uint32_t token)
|
||||
|
||||
void TokenQueue::loadRequest(const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "TokenQueue::loadRequest() Dummy Function - please Implement";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Token: " << req.mToken << " Type: " << req.mType << " UserType: " << req.mUserType;
|
||||
std::cerr << "TokenQueue::loadRequest(): ";
|
||||
std::cerr << "Token: " << req.mToken << " Type: " << req.mType;
|
||||
std::cerr << " AnsType: " << req.mAnsType << " UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
||||
mResponder->loadRequest(this, req);
|
||||
@ -154,6 +149,32 @@ void TokenQueue::loadRequest(const TokenRequest &req)
|
||||
}
|
||||
|
||||
|
||||
bool TokenQueue::cancelRequest(const uint32_t token)
|
||||
{
|
||||
/* cancel at lower level first */
|
||||
mService->cancelRequest(token);
|
||||
|
||||
std::list<TokenRequest>::iterator it;
|
||||
|
||||
for(it = mRequests.begin(); it != mRequests.end(); it++)
|
||||
{
|
||||
if (it->mToken == token)
|
||||
{
|
||||
mRequests.erase(it);
|
||||
|
||||
std::cerr << "TokenQueue::cancelRequest() Cleared Request: " << token;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << "TokenQueue::cancelRequest() Failed to Find Request: " << token;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -35,13 +35,9 @@
|
||||
|
||||
#define COMPLETED_REQUEST 4
|
||||
|
||||
|
||||
#define TOKENREQ_GROUPLIST 1
|
||||
#define TOKENREQ_GROUPDATA 2
|
||||
#define TOKENREQ_MSGLIST 3
|
||||
#define TOKENREQ_MSGRELATEDLIST 4
|
||||
#define TOKENREQ_MSGDATA 5
|
||||
|
||||
#define TOKENREQ_GROUPINFO 1
|
||||
#define TOKENREQ_MSGINFO 2
|
||||
#define TOKENREQ_MSGRELATEDINFO 3
|
||||
|
||||
class TokenQueue;
|
||||
|
||||
@ -50,6 +46,7 @@ class TokenRequest
|
||||
public:
|
||||
uint32_t mToken;
|
||||
uint32_t mType;
|
||||
uint32_t mAnsType;
|
||||
uint32_t mUserType;
|
||||
struct timeval mRequestTs;
|
||||
struct timeval mPollTs;
|
||||
@ -72,8 +69,15 @@ public:
|
||||
TokenQueue(RsTokenService *service, TokenResponse *resp);
|
||||
|
||||
/* generic handling of token / response update behaviour */
|
||||
bool genericRequest(uint32_t basictype, const RsTokReqOptions &opt, std::list<std::string> ids, uint32_t usertype);
|
||||
void queueRequest(uint32_t token, uint32_t basictype, uint32_t usertype);
|
||||
bool requestGroupInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts,
|
||||
std::list<std::string> ids, uint32_t usertype);
|
||||
bool requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts,
|
||||
std::list<std::string> ids, uint32_t usertype);
|
||||
bool requestMsgRelatedInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts,
|
||||
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);
|
||||
bool checkForRequest(uint32_t token);
|
||||
void loadRequest(const TokenRequest &req);
|
||||
|
||||
@ -95,3 +99,4 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user