Merge pull request #592 from csoler/v0.6-GXS-LimitedSync2

V0.6 gxs limited sync2
This commit is contained in:
csoler 2016-12-14 00:09:54 +01:00 committed by GitHub
commit 12023397ee
25 changed files with 1169 additions and 990 deletions

View file

@ -64,8 +64,8 @@ QString PostedDialog::getHelpString() const
<p>Links can be commented by subscribed users. A promotion system also gives the opportunity to \
enlight important links.</p> \
<p>There is no restriction on which links are shared. Be careful when clicking on them.</p>\
<p>Posted links get deleted after %1 months.</p>\
").arg(QString::number(rsPosted->getStoragePeriod()));
<p>Posted links are kept for %1 days, and sync-ed over the last %2 days, unless you change this.</p>\
").arg(QString::number(rsPosted->getDefaultStoragePeriod()/86400)).arg(QString::number(rsPosted->getDefaultSyncPeriod()/86400));
return hlp_str ;
}

View file

@ -347,7 +347,6 @@ void GxsGroupDialog::setupVisibility()
ui.commentGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS);
ui.commentsLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS);
ui.commentsValueLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS);
//ui.commentslabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS);
ui.extraFrame->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_EXTRA);
}

View file

@ -285,15 +285,35 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails()));
action->setEnabled (!mGroupId.isNull() && isAdmin);
uint32_t current_store_time = mInterface->getStoragePeriod(mGroupId)/86400 ;
uint32_t current_sync_time = mInterface->getSyncPeriod(mGroupId)/86400 ;
std::cerr << "Got sync=" << current_sync_time << ". store=" << current_store_time << std::endl;
QAction *actnn = NULL;
QMenu *ctxMenu2 = contextMnu.addMenu(tr("Synchronise posts of last...")) ;
actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ;
actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
if (shareKeyType()) {
action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share publish permissions"), this, SLOT(sharePublishKey()));
action->setEnabled(!mGroupId.isNull() && isPublisher);
}
//if (!mGroupId.isNull() && isPublisher && !isAdmin) {
// contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights" ), this, SLOT(restoreGroupKeys()));
//}
if (getLinkType() != RetroShareLink::TYPE_UNKNOWN) {
action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink()));
action->setEnabled(!mGroupId.isNull());
@ -318,6 +338,70 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
contextMnu.exec(QCursor::pos());
}
void GxsGroupFrameDialog::setStorePostsDelay()
{
QAction *action = dynamic_cast<QAction*>(sender()) ;
if(!action || mGroupId.isNull())
{
std::cerr << "(EE) Cannot find action/group that called me! Group is " << mGroupId << ", action is " << (void*)action << " " << __PRETTY_FUNCTION__ << std::endl;
return;
}
uint32_t duration = action->data().toUInt() ;
std::cerr << "Data is " << duration << std::endl;
mInterface->setStoragePeriod(mGroupId,duration * 86400) ;
// If the sync is larger, we reduce it. No need to sync more than we store. The machinery below also takes care of this.
//
uint32_t sync_period = mInterface->getSyncPeriod(mGroupId);
if(duration > 0) // the >0 test is to discard the indefinitly test. Basically, if we store for less than indefinitly, the sync is reduced accordingly.
{
if(sync_period == 0 || sync_period > duration*86400)
{
mInterface->setSyncPeriod(mGroupId,duration * 86400) ;
std::cerr << "(II) auto adjusting sync period to " << duration<< " days as well." << std::endl;
}
}
}
void GxsGroupFrameDialog::setSyncPostsDelay()
{
QAction *action = dynamic_cast<QAction*>(sender()) ;
if(!action || mGroupId.isNull())
{
std::cerr << "(EE) Cannot find action/group that called me! Group is " << mGroupId << ", action is " << (void*)action << " " << __PRETTY_FUNCTION__ << std::endl;
return;
}
uint32_t duration = action->data().toUInt() ;
std::cerr << "Data is " << duration << std::endl;
mInterface->setSyncPeriod(mGroupId,duration * 86400) ;
// If the store is smaller, we increase it accordingly. No need to sync more than we store. The machinery below also takes care of this.
//
uint32_t store_period = mInterface->getStoragePeriod(mGroupId);
if(duration == 0)
mInterface->setStoragePeriod(mGroupId,duration * 86400) ; // indefinite sync => indefinite storage
else
{
if(store_period != 0 && store_period < duration*86400)
{
mInterface->setStoragePeriod(mGroupId,duration * 86400) ; // indefinite sync => indefinite storage
std::cerr << "(II) auto adjusting storage period to " << duration<< " days as well." << std::endl;
}
}
}
void GxsGroupFrameDialog::restoreGroupKeys(void)
{
QMessageBox::warning(this, "RetroShare", "ToDo");

View file

@ -99,6 +99,8 @@ private slots:
/** Create the context popup menu and it's submenus */
void groupTreeCustomPopupMenu(QPoint point);
void settingsChanged();
void setSyncPostsDelay();
void setStorePostsDelay();
void restoreGroupKeys();
void newGroup();

View file

@ -65,8 +65,8 @@ QString GxsChannelDialog::getHelpString() const
the posting rights or the reading rights with friend Retroshare nodes.</p>\
<p>Channels can be made anonymous, or attached to a Retroshare identity so that readers can contact you if needed.\
Enable \"Allow Comments\" if you want to let users comment on your posts.</p>\
<p>Channel posts get deleted after %1 months.</p>\
").arg(QString::number(rsGxsChannels->getStoragePeriod()));
<p>Channel posts are kept for %1 days, and sync-ed over the last %2 days, unless you change this.</p>\
").arg(QString::number(rsGxsChannels->getDefaultStoragePeriod()/86400)).arg(QString::number(rsGxsChannels->getDefaultSyncPeriod()/86400));
return hlp_str ;
}

View file

@ -746,6 +746,22 @@ void GxsForumThreadWidget::insertGroupData()
calculateIconsAndFonts();
}
static QString getDurationString(uint32_t days)
{
switch(days)
{
case 0: return QObject::tr("Indefinitely") ;
case 5: return QObject::tr("5 days") ;
case 15: return QObject::tr("2 weeks") ;
case 30: return QObject::tr("1 month") ;
case 60: return QObject::tr("2 month") ;
case 180: return QObject::tr("6 month") ;
case 365: return QObject::tr("1 year") ;
default:
return QString::number(days)+" " + QObject::tr("days") ;
}
}
/*static*/ void GxsForumThreadWidget::loadAuthorIdCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &)
{
GxsForumThreadWidget *tw = dynamic_cast<GxsForumThreadWidget*>(object);
@ -784,7 +800,9 @@ void GxsForumThreadWidget::insertGroupData()
tw->mForumDescription = QString("<b>%1: \t</b>%2<br/>").arg(tr("Forum name"), QString::fromUtf8( group.mMeta.mGroupName.c_str()));
tw->mForumDescription += QString("<b>%1: \t</b>%2<br/>").arg(tr("Subscribers")).arg(group.mMeta.mPop);
tw->mForumDescription += QString("<b>%1: \t</b>%2<br/>").arg(tr("Posts (at neighbor nodes)")).arg(group.mMeta.mVisibleMsgCount);
tw->mForumDescription += QString("<b>%1: \t</b>%2<br/>").arg(tr("Synchronization")).arg(getDurationString( rsGxsForums->getSyncPeriod(group.mMeta.mGroupId)/86400 )) ;
tw->mForumDescription += QString("<b>%1: \t</b>%2<br/>").arg(tr("Storage")).arg(getDurationString( rsGxsForums->getStoragePeriod(group.mMeta.mGroupId)/86400));
QString distrib_string = tr("[unknown]");
switch(group.mMeta.mCircleType)
{

View file

@ -54,16 +54,8 @@ QString GxsForumsDialog::getHelpString() const
<p>Retroshare Forums look like internet forums, but they work in a decentralized way</p> \
<p>You see forums your friends are subscribed to, and you forward subscribed forums to \
your friends. This automatically promotes interesting forums in the network.</p> \
<p>Forum messages get deleted after %1 months.</p>\
").arg(QString::number(rsGxsForums->getStoragePeriod()));
// not true anymore in v0.6
/*
<p>Forums are either Authenticated (<img src=\":/images/konv_message2.png\" width=\"12\"/>) \
or anonymous (<img src=\":/images/konversation.png\" width=\"12\"/>). The former \
class is more resistant to spamming because posts are \
cryptographically signed using a Retroshare pseudo-identity.</p>") ;
*/
<p>Forum messages are kept for %1 days and sync-ed over the last %2 days, unless you configure it otherwise.</p>\
").arg(QString::number(rsGxsForums->getDefaultStoragePeriod()/86400)).arg(QString::number(rsGxsForums->getDefaultSyncPeriod()/86400));
return hlp_str ;
}