- Enabled generate of mass data for forums and channels

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6521 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-07-19 21:06:19 +00:00
parent 5090913630
commit 024479d518
8 changed files with 134 additions and 121 deletions

View File

@ -34,6 +34,8 @@
#include <iostream> #include <iostream>
//#define ENABLE_GENERATE
#define CREATEMSG_CHANNELINFO 0x002 #define CREATEMSG_CHANNELINFO 0x002
/** Constructor */ /** Constructor */
@ -58,6 +60,9 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(std::string cId)
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail())); connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool))); connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool)));
connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint))); connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool)));
generateSpinBox->setEnabled(false);
thumbNailCb->setVisible(false); thumbNailCb->setVisible(false);
thumbNailCb->setEnabled(false); thumbNailCb->setEnabled(false);
@ -71,6 +76,11 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(std::string cId)
setAcceptDrops(true); setAcceptDrops(true);
newChannelMsg(); newChannelMsg();
#ifndef ENABLE_GENERATE
generateCheckBox->hide();
generateSpinBox->hide();
#endif
} }
void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) void CreateGxsChannelMsg::contextMenu(QPoint /*point*/)
@ -628,9 +638,31 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str
post.mThumbnail.copy((uint8_t *) ba.data(), ba.size()); post.mThumbnail.copy((uint8_t *) ba.data(), ba.size());
} }
int generateCount = 0;
#ifdef ENABLE_GENERATE
if (generateCheckBox->isChecked()) {
generateCount = generateSpinBox->value();
if (QMessageBox::question(this, "Generate mass data", QString("Do you really want to generate %1 messages ?").arg(generateCount), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
return;
}
}
#endif
uint32_t token; uint32_t token;
if (generateCount) {
#ifdef ENABLE_GENERATE
for (int count = 0; count < generateCount; ++count) {
RsGxsChannelPost generatePost = post;
generatePost.mMeta.mMsgName = QString("%1 %2").arg(QString::fromUtf8(post.mMeta.mMsgName.c_str())).arg(count + 1, 3, 10, QChar('0')).toUtf8().constData();
rsGxsChannels->createPost(token, generatePost);
}
#endif
} else {
rsGxsChannels->createPost(token, post); rsGxsChannels->createPost(token, post);
} }
}
accept(); accept();
} }

View File

@ -161,8 +161,8 @@ p, li { white-space: pre-wrap; }
<property name="title"> <property name="title">
<string>Message</string> <string>Message</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item row="1" column="0" colspan="2"> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
@ -182,7 +182,7 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0" colspan="2"> <item>
<widget class="QTextEdit" name="msgEdit"/> <widget class="QTextEdit" name="msgEdit"/>
</item> </item>
</layout> </layout>
@ -293,7 +293,7 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>98</width> <width>518</width>
<height>24</height> <height>24</height>
</rect> </rect>
</property> </property>
@ -336,6 +336,25 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="generateCheckBox">
<property name="text">
<string>Generate mass data</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="generateSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -346,6 +365,8 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -338,12 +338,6 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ )
QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
action->setEnabled(!mChannelId.empty()); action->setEnabled(!mChannelId.empty());
#ifdef DEBUG_CHANNEL
contextMnu.addSeparator();
action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData()));
action->setEnabled (!mChannelId.empty() && (ci.channelFlags & RS_DISTRIB_PUBLISH));
#endif
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
#endif #endif

View File

@ -86,8 +86,6 @@ private slots:
// void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status); // void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
//void generateMassData();
//void fillThreadFinished(); //void fillThreadFinished();
//void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count); //void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);

View File

@ -45,6 +45,8 @@
#define CREATEGXSFORUMMSG_FORUMINFO 1 #define CREATEGXSFORUMMSG_FORUMINFO 1
#define CREATEGXSFORUMMSG_PARENTMSG 2 #define CREATEGXSFORUMMSG_PARENTMSG 2
//#define ENABLE_GENERATE
/** Constructor */ /** Constructor */
CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &pId) CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &pId)
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId) : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId)
@ -77,6 +79,8 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &
ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png")); ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png"));
ui.headerFrame->setHeaderText(text); ui.headerFrame->setHeaderText(text);
ui.generateSpinBox->setEnabled(false);
Settings->loadWidgetInformation(this); Settings->loadWidgetInformation(this);
connect(ui.forumMessage, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT(forumMessageCostumPopupMenu(QPoint))); connect(ui.forumMessage, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT(forumMessageCostumPopupMenu(QPoint)));
@ -89,6 +93,7 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &
connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile())); connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile()));
connect(ui.pastersButton, SIGNAL(clicked()), this, SLOT(pasteLink())); connect(ui.pastersButton, SIGNAL(clicked()), this, SLOT(pasteLink()));
connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool)));
setAcceptDrops(true); setAcceptDrops(true);
ui.hashBox->setDropWidget(this); ui.hashBox->setDropWidget(this);
@ -98,6 +103,11 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &
mForumMetaLoaded = false; mForumMetaLoaded = false;
newMsg(); newMsg();
#ifndef ENABLE_GENERATE
ui.generateCheckBox->hide();
ui.generateSpinBox->hide();
#endif
} }
CreateGxsForumMsg::~CreateGxsForumMsg() CreateGxsForumMsg::~CreateGxsForumMsg()
@ -277,8 +287,7 @@ void CreateGxsForumMsg::createMsg()
if(name.isEmpty()) if(name.isEmpty())
{ /* error message */ { /* error message */
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"), QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"), QMessageBox::Ok, QMessageBox::Ok);
QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty Subject!! return; //Don't add a empty Subject!!
} }
@ -314,8 +323,7 @@ void CreateGxsForumMsg::createMsg()
{ {
std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!"; std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!";
std::cerr << std::endl; std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id"), QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id"), QMessageBox::Ok, QMessageBox::Ok);
QMessageBox::Ok, QMessageBox::Ok);
return; return;
} }
@ -324,13 +332,35 @@ void CreateGxsForumMsg::createMsg()
{ {
std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)"; std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)";
std::cerr << std::endl; std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id, it is required"), QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id, it is required"), QMessageBox::Ok, QMessageBox::Ok);
QMessageBox::Ok, QMessageBox::Ok);
return; return;
} }
int generateCount = 0;
#ifdef ENABLE_GENERATE
if (ui.generateCheckBox->isChecked()) {
generateCount = ui.generateSpinBox->value();
if (QMessageBox::question(this, "Generate mass data", QString("Do you really want to generate %1 messages ?").arg(generateCount), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
return;
}
}
#endif
uint32_t token; uint32_t token;
if (generateCount) {
#ifdef ENABLE_GENERATE
for (int count = 0; count < generateCount; ++count) {
RsGxsForumMsg generateMsg = msg;
generateMsg.mMeta.mMsgName = QString("%1 %2").arg(QString::fromUtf8(msg.mMeta.mMsgName.c_str())).arg(count + 1, 3, 10, QChar('0')).toUtf8().constData();
rsGxsForums->createMsg(token, generateMsg);
}
#endif
} else {
rsGxsForums->createMsg(token, msg); rsGxsForums->createMsg(token, msg);
}
close(); close();
} }

View File

@ -21,22 +21,11 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="HeaderFrame" name="headerFrame"> <widget class="HeaderFrame" name="headerFrame"/>
<zorder>buttonBox</zorder>
</widget>
</item> </item>
<item> <item>
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame">
@ -50,16 +39,7 @@
<item> <item>
<widget class="QFrame" name="innerFrame"> <widget class="QFrame" name="innerFrame">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin"> <property name="margin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -71,16 +51,7 @@
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin"> <property name="margin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
@ -125,16 +96,7 @@
<enum>QFrame::Sunken</enum> <enum>QFrame::Sunken</enum>
</property> </property>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<property name="leftMargin"> <property name="margin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
@ -299,6 +261,25 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="generateCheckBox">
<property name="text">
<string>Generate mass data</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="generateSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
@ -307,6 +288,8 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -239,12 +239,6 @@ void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/)
action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread()));
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags));
#ifdef DEBUG_FORUMS
contextMnu.addSeparator();
action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData()));
action->setEnabled (!mCurrForumId.empty() && IS_GROUP_SUBSCRIBED(mSubscribeFlags));
#endif
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
} }
@ -650,43 +644,6 @@ bool GxsForumsDialog::navigate(const std::string& forumId, const std::string& ms
return false; return false;
} }
void GxsForumsDialog::generateMassData()
{
#ifdef DEBUG_FORUMS
if (mCurrForumId.empty ()) {
return;
}
if (QMessageBox::question(this, "Generate mass data", "Do you really want to generate mass data ?", QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
return;
}
for (int thread = 1; thread < 1000; thread++) {
ForumMsgInfo threadInfo;
threadInfo.forumId = mCurrForumId;
threadInfo.title = QString("Test %1").arg(thread, 3, 10, QChar('0')).toStdWString();
threadInfo.msg = QString("That is only a test").toStdWString();
if (rsGxsForums->ForumMessageSend(threadInfo) == false) {
return;
}
for (int msg = 1; msg < 3; msg++) {
ForumMsgInfo msgInfo;
msgInfo.forumId = mCurrForumId;
msgInfo.threadId = threadInfo.msgId;
msgInfo.parentId = threadInfo.msgId;
msgInfo.title = threadInfo.title;
msgInfo.msg = threadInfo.msg;
if (rsGxsForums->ForumMessageSend(msgInfo) == false) {
return;
}
}
}
#endif
}
/*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/
/** Request / Response of Data ********************************/ /** Request / Response of Data ********************************/
/*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/

View File

@ -85,8 +85,6 @@ private slots:
void markMsgAsRead(); void markMsgAsRead();
void markMsgAsUnread(); void markMsgAsUnread();
void generateMassData();
void shareKey(); void shareKey();
private: private: