mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
added channels file clean up warning
added channels private key notification, and new private channel key behaviour (must subscribe to accept a private key) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3756 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0f05f8d85e
commit
885d71370c
@ -42,7 +42,7 @@ const uint8_t RS_PKT_SUBTYPE_DISTRIB_CONFIG_DATA = 0x04;
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This should be derived from to store RsDistrib child objects
|
* This should be subclassed by p3distrib subclass's to store their data
|
||||||
* save data
|
* save data
|
||||||
*/
|
*/
|
||||||
class RsDistribChildConfig: public RsItem
|
class RsDistribChildConfig: public RsItem
|
||||||
|
@ -65,7 +65,6 @@ RsChannels *rsChannels = NULL;
|
|||||||
/* remember 2^16 = 64K max units in store period.
|
/* remember 2^16 = 64K max units in store period.
|
||||||
* PUBPERIOD * 2^16 = max STORE PERIOD */
|
* PUBPERIOD * 2^16 = max STORE PERIOD */
|
||||||
#define CHANNEL_STOREPERIOD (30*24*3600) /* 30 * 24 * 3600 - secs in a 30 day month */
|
#define CHANNEL_STOREPERIOD (30*24*3600) /* 30 * 24 * 3600 - secs in a 30 day month */
|
||||||
#define TEST_CHANNEL_STOREPERIOD (24*3600) /* one day */
|
|
||||||
#define CHANNEL_PUBPERIOD 600 /* 10 minutes ... (max = 455 days) */
|
#define CHANNEL_PUBPERIOD 600 /* 10 minutes ... (max = 455 days) */
|
||||||
#define MAX_AUTO_DL 1E9 /* auto download of attachment limit; 1 GIG */
|
#define MAX_AUTO_DL 1E9 /* auto download of attachment limit; 1 GIG */
|
||||||
|
|
||||||
@ -603,6 +602,14 @@ bool p3Channels::channelEditInfo(std::string chId, ChannelInfo& info){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void p3Channels::getPubKeysAvailableGrpIds(std::list<std::string>& grpIds)
|
||||||
|
{
|
||||||
|
|
||||||
|
getGrpListPubKeyAvailable(grpIds);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
@ -795,7 +802,41 @@ void p3Channels::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags)
|
|||||||
return p3GroupDistrib::locked_notifyGroupChanged(grp, flags);
|
return p3GroupDistrib::locked_notifyGroupChanged(grp, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3Channels::cleanUpOldFiles(){
|
bool p3Channels::getCleanUpList(std::map<std::string, uint32_t>& warnings,const std::string& chId,uint32_t limit)
|
||||||
|
{
|
||||||
|
|
||||||
|
time_t now = time(NULL);
|
||||||
|
uint32_t timeLeft = 0;
|
||||||
|
bool first = true;
|
||||||
|
std::list<ChannelMsgSummary> msgList;
|
||||||
|
std::list<ChannelMsgSummary>::iterator msg_it;
|
||||||
|
ChannelMsgInfo chMsgInfo;
|
||||||
|
|
||||||
|
if(!getChannelMsgList(chId, msgList))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for(msg_it = msgList.begin(); msg_it != msgList.end(); msg_it++){
|
||||||
|
|
||||||
|
|
||||||
|
if(!getChannelMessage(chId, msg_it->msgId, chMsgInfo))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// if msg not close to warning limit leave it alone
|
||||||
|
if( chMsgInfo.ts > (now - CHANNEL_STOREPERIOD + limit))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
timeLeft = CHANNEL_STOREPERIOD - (now - chMsgInfo.ts);
|
||||||
|
warnings.insert(std::pair<std::string, uint32_t>(msg_it->msgId, timeLeft));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void p3Channels::cleanUpOldFiles()
|
||||||
|
{
|
||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
std::list<ChannelInfo> chList;
|
std::list<ChannelInfo> chList;
|
||||||
|
@ -78,6 +78,8 @@ virtual bool channelExtraFileRemove(std::string hash, std::string chId);
|
|||||||
virtual bool channelRestoreKeys(std::string chId);
|
virtual bool channelRestoreKeys(std::string chId);
|
||||||
virtual bool channelShareKeys(std::string chId, std::list<std::string>& peers);
|
virtual bool channelShareKeys(std::string chId, std::list<std::string>& peers);
|
||||||
virtual bool channelEditInfo(std::string chId, ChannelInfo &ci);
|
virtual bool channelEditInfo(std::string chId, ChannelInfo &ci);
|
||||||
|
virtual void getPubKeysAvailableGrpIds(std::list<std::string>& grpIds);
|
||||||
|
virtual bool getCleanUpList(std::map<std::string, uint32_t>& warnings,const std::string& chId, uint32_t limit);
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
|
@ -1230,6 +1230,9 @@ bool p3GroupDistrib::subscribeToGroup(std::string grpId, bool subscribe)
|
|||||||
{
|
{
|
||||||
git->second.flags |= RS_DISTRIB_SUBSCRIBED;
|
git->second.flags |= RS_DISTRIB_SUBSCRIBED;
|
||||||
|
|
||||||
|
if(attemptPublishKeysRecvd(git->second))
|
||||||
|
git->second.flags |= RS_DISTRIB_PUBLISH;
|
||||||
|
|
||||||
locked_notifyGroupChanged(git->second, GRP_SUBSCRIBED);
|
locked_notifyGroupChanged(git->second, GRP_SUBSCRIBED);
|
||||||
mGroupsRepublish = true;
|
mGroupsRepublish = true;
|
||||||
|
|
||||||
@ -1268,6 +1271,24 @@ bool p3GroupDistrib::subscribeToGroup(std::string grpId, bool subscribe)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool p3GroupDistrib::attemptPublishKeysRecvd(GroupInfo& info)
|
||||||
|
{
|
||||||
|
|
||||||
|
std::map<std::string, RsDistribGrpKey*>::iterator mit;
|
||||||
|
mit = mRecvdPubKeys.find(info.grpId);
|
||||||
|
|
||||||
|
if(mit == mRecvdPubKeys.end())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(locked_updateGroupPublishKey(info, mit->second))
|
||||||
|
mRecvdPubKeys.erase(mit);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************* p3Config *************************************/
|
/************************************* p3Config *************************************/
|
||||||
|
|
||||||
RsSerialiser *p3GroupDistrib::setupSerialiser()
|
RsSerialiser *p3GroupDistrib::setupSerialiser()
|
||||||
@ -2083,30 +2104,39 @@ void p3GroupDistrib::locked_receivePubKeys(){
|
|||||||
void p3GroupDistrib::locked_loadRecvdPubKeys(){
|
void p3GroupDistrib::locked_loadRecvdPubKeys(){
|
||||||
|
|
||||||
std::map<std::string, RsDistribGrpKey* >::iterator mit;
|
std::map<std::string, RsDistribGrpKey* >::iterator mit;
|
||||||
|
std::list<std::string>::iterator lit;
|
||||||
GroupInfo *gi;
|
GroupInfo *gi;
|
||||||
std::list<std::string> toDelete;
|
bool cont = false;
|
||||||
|
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::locked_loadRecvdPubKeys() " << std::endl;
|
std::cerr << "p3GroupDistrib::locked_loadRecvdPubKeys() " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool ok = false;
|
|
||||||
|
|
||||||
// load received keys
|
// look for keys to add to private publish key received notify list
|
||||||
for(mit = mRecvdPubKeys.begin(); mit != mRecvdPubKeys.end(); mit++ ){
|
for(mit = mRecvdPubKeys.begin(); mit != mRecvdPubKeys.end(); mit++ ){
|
||||||
|
|
||||||
gi = locked_getGroupInfo(mit->second->grpId);
|
gi = locked_getGroupInfo(mit->second->grpId);
|
||||||
|
|
||||||
if(gi != NULL){
|
if(gi != NULL){
|
||||||
|
|
||||||
|
/* ensure grpId not added already */
|
||||||
|
for(lit=mPubKeyAvailableGrpId.begin(); lit != mPubKeyAvailableGrpId.end(); lit++){
|
||||||
|
|
||||||
|
if(mit->second->grpId == *lit){
|
||||||
if(locked_updateGroupPublishKey(*gi, mit->second)){
|
cont = true;
|
||||||
toDelete.push_back(mit->first);
|
break;
|
||||||
ok |= true;
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
std::cerr << "p3GroupDistrib::locked_loadRecvdPubKeys(): Failed to load" << std::endl;
|
|
||||||
|
if(cont)
|
||||||
|
{
|
||||||
|
cont = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPubKeyAvailableGrpId.push_back(mit->second->grpId);
|
||||||
|
locked_notifyGroupChanged(*gi, GRP_UPDATE);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
@ -2118,16 +2148,6 @@ void p3GroupDistrib::locked_loadRecvdPubKeys(){
|
|||||||
|
|
||||||
mLastRecvdKeyTime = time(NULL);
|
mLastRecvdKeyTime = time(NULL);
|
||||||
|
|
||||||
|
|
||||||
if(ok)
|
|
||||||
IndicateConfigChanged();
|
|
||||||
|
|
||||||
std::list<std::string >::iterator lit;
|
|
||||||
|
|
||||||
// delete keys that have been loaded to groups
|
|
||||||
for(lit = toDelete.begin(); lit != toDelete.end(); lit++)
|
|
||||||
mRecvdPubKeys.erase(*lit);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3146,6 +3166,13 @@ RsDistribMsg *p3GroupDistrib::unpackDistribSignedMsg(RsDistribSignedMsg *newMsg)
|
|||||||
return distribMsg;
|
return distribMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void p3GroupDistrib::getGrpListPubKeyAvailable(std::list<std::string>& grpList)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(distribMtx);
|
||||||
|
grpList = mPubKeyAvailableGrpId;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3GroupDistrib::locked_checkDistribMsg(
|
bool p3GroupDistrib::locked_checkDistribMsg(
|
||||||
GroupInfo &gi, RsDistribMsg *msg)
|
GroupInfo &gi, RsDistribMsg *msg)
|
||||||
|
@ -277,6 +277,12 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
|||||||
bool backUpKeys(const std::list<RsDistribGrpKey* > &keysToBackUp, std::string grpId);
|
bool backUpKeys(const std::list<RsDistribGrpKey* > &keysToBackUp, std::string grpId);
|
||||||
void locked_sharePubKey();
|
void locked_sharePubKey();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Attempt to load public key from recvd list if it exists for grpId
|
||||||
|
* @param grpId the id for the group for which private publish key is wanted
|
||||||
|
*/
|
||||||
|
bool attemptPublishKeysRecvd(GroupInfo& info);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/* load cache msgs */
|
/* load cache msgs */
|
||||||
@ -341,6 +347,7 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
|||||||
bool subscribeToGroup(std::string grpId, bool subscribe);
|
bool subscribeToGroup(std::string grpId, bool subscribe);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
|
|
||||||
@ -377,6 +384,11 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
|||||||
GroupInfo *locked_getGroupInfo(std::string grpId);
|
GroupInfo *locked_getGroupInfo(std::string grpId);
|
||||||
RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
|
RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* for retrieving the grpList for which public keys are available
|
||||||
|
*/
|
||||||
|
void getGrpListPubKeyAvailable(std::list<std::string>& grpList);
|
||||||
|
|
||||||
/* Filter Messages */
|
/* Filter Messages */
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
@ -497,9 +509,9 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
|||||||
*/
|
*/
|
||||||
virtual void locked_receivePubKeys();
|
virtual void locked_receivePubKeys();
|
||||||
|
|
||||||
/**
|
/*!
|
||||||
* This loads received pub keys
|
* utility function to check whether grps exist
|
||||||
*
|
* for private publish keys received
|
||||||
*/
|
*/
|
||||||
virtual void locked_loadRecvdPubKeys();
|
virtual void locked_loadRecvdPubKeys();
|
||||||
|
|
||||||
@ -510,7 +522,7 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
|||||||
*/
|
*/
|
||||||
virtual bool locked_editGroup(std::string grpId, GroupInfo& gi);
|
virtual bool locked_editGroup(std::string grpId, GroupInfo& gi);
|
||||||
|
|
||||||
/**
|
/*!
|
||||||
* Encrypts data using envelope encryption (taken from open ssl's evp_sealinit )
|
* Encrypts data using envelope encryption (taken from open ssl's evp_sealinit )
|
||||||
* only full publish key holders can encrypt data for given group
|
* only full publish key holders can encrypt data for given group
|
||||||
*@param out
|
*@param out
|
||||||
@ -671,6 +683,7 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
|||||||
|
|
||||||
std::map<std::string, RsDistribGrpKey* > mRecvdPubKeys; /// full publishing keys received from users
|
std::map<std::string, RsDistribGrpKey* > mRecvdPubKeys; /// full publishing keys received from users
|
||||||
std::map<std::string, std::list<std::string> > mPendingPubKeyRecipients; /// peers to receive publics key for a given grp
|
std::map<std::string, std::list<std::string> > mPendingPubKeyRecipients; /// peers to receive publics key for a given grp
|
||||||
|
std::list<std::string> mPubKeyAvailableGrpId; // groups id for which public keys are available
|
||||||
time_t mLastKeyPublishTime, mLastRecvdKeyTime;
|
time_t mLastKeyPublishTime, mLastRecvdKeyTime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <set>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "ChannelFeed.h"
|
#include "ChannelFeed.h"
|
||||||
|
|
||||||
@ -56,6 +58,8 @@
|
|||||||
#define COMBO_TITLE_INDEX 0
|
#define COMBO_TITLE_INDEX 0
|
||||||
#define COMBO_DESC_INDEX 1
|
#define COMBO_DESC_INDEX 1
|
||||||
|
|
||||||
|
#define WARNING_LIMIT 3600*24*2
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* #define CHAN_DEBUG
|
* #define CHAN_DEBUG
|
||||||
***/
|
***/
|
||||||
@ -181,7 +185,7 @@ void ChannelFeed::channelListCustomPopupMenu( QPoint point )
|
|||||||
contextMnu.addAction( shareKeyAct );
|
contextMnu.addAction( shareKeyAct );
|
||||||
contextMnu.addAction( channeldetailsAct );
|
contextMnu.addAction( channeldetailsAct );
|
||||||
}
|
}
|
||||||
else if (ci.channelFlags & RS_DISTRIB_PUBLISH) {
|
else if ((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) {
|
||||||
contextMnu.addAction( postchannelAct );
|
contextMnu.addAction( postchannelAct );
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
contextMnu.addAction( channeldetailsAct );
|
contextMnu.addAction( channeldetailsAct );
|
||||||
@ -350,10 +354,9 @@ void ChannelFeed::updateChannelList()
|
|||||||
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
||||||
uint32_t flags = it->channelFlags;
|
uint32_t flags = it->channelFlags;
|
||||||
|
|
||||||
if ((flags & (RS_DISTRIB_ADMIN | RS_DISTRIB_PUBLISH)) && (flags & RS_DISTRIB_SUBSCRIBED)
|
if ((flags & RS_DISTRIB_ADMIN) && (flags & RS_DISTRIB_PUBLISH) && (flags & RS_DISTRIB_SUBSCRIBED)) {
|
||||||
) {
|
|
||||||
adminList.push_back(*it);
|
adminList.push_back(*it);
|
||||||
} else if (flags & RS_DISTRIB_SUBSCRIBED) {
|
} else if ((flags & RS_DISTRIB_SUBSCRIBED) || ((flags & RS_DISTRIB_SUBSCRIBED) && (flags &RS_DISTRIB_PUBLISH)) ) {
|
||||||
subList.push_back(*it);
|
subList.push_back(*it);
|
||||||
} else {
|
} else {
|
||||||
/* rate the others by popularity */
|
/* rate the others by popularity */
|
||||||
@ -394,6 +397,11 @@ void ChannelFeed::updateChannelList()
|
|||||||
fillChannelList(POPULAR, popList);
|
fillChannelList(POPULAR, popList);
|
||||||
fillChannelList(OTHER, otherList);
|
fillChannelList(OTHER, otherList);
|
||||||
|
|
||||||
|
// place notices for channel with private keys available
|
||||||
|
highlightPrivateKeys(SUBSCRIBED);
|
||||||
|
highlightPrivateKeys(POPULAR);
|
||||||
|
highlightPrivateKeys(OTHER);
|
||||||
|
|
||||||
updateMessageSummaryList("");
|
updateMessageSummaryList("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,8 +436,44 @@ void ChannelFeed::filterChannelList(std::list<ChannelInfo> &ci){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &channelInfos)
|
void ChannelFeed::highlightPrivateKeys(int group){
|
||||||
{
|
|
||||||
|
QStandardItem *groupItem = model->item(group);
|
||||||
|
QStandardItem *item = NULL;
|
||||||
|
std::list<std::string> keysAvailable;
|
||||||
|
std::list<std::string>::iterator it;
|
||||||
|
int rowCount = 0;
|
||||||
|
QBrush brush;
|
||||||
|
|
||||||
|
brush.setColor(Qt::blue);
|
||||||
|
|
||||||
|
if((groupItem == NULL) || (rsChannels == NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
rowCount = groupItem->rowCount();
|
||||||
|
rsChannels->getPubKeysAvailableGrpIds(keysAvailable);
|
||||||
|
|
||||||
|
|
||||||
|
for(it= keysAvailable.begin(); it != keysAvailable.end(); it++)
|
||||||
|
|
||||||
|
for (int row = 0; row < rowCount; row++) {
|
||||||
|
if (groupItem->child(row, COLUMN_DATA)->data(ROLE_ID).toString() == QString::fromStdString(*it)) {
|
||||||
|
/* found channel */
|
||||||
|
item = groupItem->child(row, COLUMN_NAME);
|
||||||
|
|
||||||
|
/* set title text to bold and colored blue */
|
||||||
|
QFont chanFont = item->font();
|
||||||
|
chanFont.setBold(true);
|
||||||
|
item->setFont(chanFont);
|
||||||
|
item->setForeground(brush);
|
||||||
|
item->setToolTip(item->toolTip() + QString("\nPrivate Key Available"));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &channelInfos){
|
||||||
std::list<ChannelInfo>::iterator iit;
|
std::list<ChannelInfo>::iterator iit;
|
||||||
|
|
||||||
/* remove rows with groups before adding new ones */
|
/* remove rows with groups before adding new ones */
|
||||||
@ -485,7 +529,7 @@ void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &chann
|
|||||||
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QDateTime::fromTime_t(ci.lastPost), ROLE_CHANNEL_TS);
|
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QDateTime::fromTime_t(ci.lastPost), ROLE_CHANNEL_TS);
|
||||||
|
|
||||||
|
|
||||||
chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3").arg(QString::number(ci.pop)).arg(9999).arg(9999));
|
chNameItem->setToolTip(tr("Popularity: %1").arg(QString::number(ci.pop)));
|
||||||
|
|
||||||
QPixmap chanImage;
|
QPixmap chanImage;
|
||||||
if (ci.pngImageLen != 0) {
|
if (ci.pngImageLen != 0) {
|
||||||
@ -545,6 +589,8 @@ void ChannelFeed::updateMessageSummaryList(const std::string &channelId)
|
|||||||
{
|
{
|
||||||
int channelItems[2] = { OWN, SUBSCRIBED };
|
int channelItems[2] = { OWN, SUBSCRIBED };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int channelItem = 0; channelItem < 2; channelItem++) {
|
for (int channelItem = 0; channelItem < 2; channelItem++) {
|
||||||
QStandardItem *groupItem = model->item(channelItems[channelItem]);
|
QStandardItem *groupItem = model->item(channelItems[channelItem]);
|
||||||
if (groupItem == NULL) {
|
if (groupItem == NULL) {
|
||||||
@ -658,14 +704,23 @@ void ChannelFeed::updateChannelMsgs()
|
|||||||
|
|
||||||
std::list<ChannelMsgSummary> msgs;
|
std::list<ChannelMsgSummary> msgs;
|
||||||
std::list<ChannelMsgSummary>::iterator it;
|
std::list<ChannelMsgSummary>::iterator it;
|
||||||
|
|
||||||
rsChannels->getChannelMsgList(mChannelId, msgs);
|
rsChannels->getChannelMsgList(mChannelId, msgs);
|
||||||
|
|
||||||
msgs.sort(sortChannelMsgSummary);
|
msgs.sort(sortChannelMsgSummary);
|
||||||
|
|
||||||
|
/* set get warning list for channel */
|
||||||
|
std::map<std::string, uint32_t> warningList;
|
||||||
|
std::map<std::string, uint32_t>::iterator msgId_it;
|
||||||
|
|
||||||
|
rsChannels->getCleanUpList(warningList, mChannelId, WARNING_LIMIT);
|
||||||
|
|
||||||
for(it = msgs.begin(); it != msgs.end(); it++) {
|
for(it = msgs.begin(); it != msgs.end(); it++) {
|
||||||
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
|
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
|
||||||
|
|
||||||
|
msgId_it = warningList.find(it->msgId);
|
||||||
|
if(msgId_it != warningList.end())
|
||||||
|
cmi->setFileCleanUpWarning(msgId_it->second);
|
||||||
|
|
||||||
mChanMsgItems.push_back(cmi);
|
mChanMsgItems.push_back(cmi);
|
||||||
verticalLayout_2->addWidget(cmi);
|
verticalLayout_2->addWidget(cmi);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ private slots:
|
|||||||
void finishSearching();
|
void finishSearching();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void highlightPrivateKeys(int group);
|
||||||
void updateChannelList();
|
void updateChannelList();
|
||||||
void fillChannelList(int channelItem, std::list<ChannelInfo> &channelInfos);
|
void fillChannelList(int channelItem, std::list<ChannelInfo> &channelInfos);
|
||||||
void filterChannelList(std::list<ChannelInfo>&);
|
void filterChannelList(std::list<ChannelInfo>&);
|
||||||
|
@ -64,10 +64,13 @@ ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, std::string chanId
|
|||||||
|
|
||||||
downloadButton->hide();
|
downloadButton->hide();
|
||||||
playButton->hide();
|
playButton->hide();
|
||||||
|
warn_image_label->hide();
|
||||||
|
warning_label->hide();
|
||||||
|
|
||||||
titleLabel->setMinimumWidth(100);
|
titleLabel->setMinimumWidth(100);
|
||||||
subjectLabel->setMinimumWidth(100);
|
subjectLabel->setMinimumWidth(100);
|
||||||
|
|
||||||
|
|
||||||
small();
|
small();
|
||||||
updateItemStatic();
|
updateItemStatic();
|
||||||
updateItem();
|
updateItem();
|
||||||
@ -90,6 +93,8 @@ void ChanMsgItem::updateItemStatic()
|
|||||||
if (!rsChannels->getChannelMessage(mChanId, mMsgId, cmi))
|
if (!rsChannels->getChannelMessage(mChanId, mMsgId, cmi))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_inUpdateItemStatic = true;
|
m_inUpdateItemStatic = true;
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
@ -201,6 +206,25 @@ void ChanMsgItem::updateItemStatic()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ChanMsgItem::setFileCleanUpWarning(uint32_t time_left)
|
||||||
|
{
|
||||||
|
int hours = (int)time_left/3600;
|
||||||
|
int minutes = (time_left - hours*3600)%60;
|
||||||
|
|
||||||
|
warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is delted Consider saving it.").arg(
|
||||||
|
QString::number(hours)).arg(QString::number(minutes)));
|
||||||
|
|
||||||
|
QFont warnFont = warning_label->font();
|
||||||
|
warnFont.setBold(true);
|
||||||
|
warning_label->setFont(warnFont);
|
||||||
|
|
||||||
|
warn_image_label->setVisible(true);
|
||||||
|
warning_label->setVisible(true);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChanMsgItem::updateItem()
|
void ChanMsgItem::updateItem()
|
||||||
{
|
{
|
||||||
/* fill in */
|
/* fill in */
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
|
|
||||||
void updateItemStatic();
|
void updateItemStatic();
|
||||||
void small();
|
void small();
|
||||||
|
void setFileCleanUpWarning(uint32_t time_left);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/* default stuff */
|
/* default stuff */
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>518</width>
|
<width>528</width>
|
||||||
<height>208</height>
|
<height>208</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -211,7 +211,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QPushButton" name="readButton">
|
<widget class="QPushButton" name="readButton">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -241,7 +241,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QLabel" name="newLabel">
|
<widget class="QLabel" name="newLabel">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -265,7 +265,7 @@ border-radius: 3px}</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="4" column="2">
|
||||||
<widget class="QPushButton" name="downloadButton">
|
<widget class="QPushButton" name="downloadButton">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
@ -281,7 +281,7 @@ border-radius: 3px}</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="4" column="3">
|
||||||
<widget class="QPushButton" name="playButton">
|
<widget class="QPushButton" name="playButton">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
@ -297,7 +297,7 @@ border-radius: 3px}</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="4">
|
<item row="4" column="4">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -313,7 +313,7 @@ border-radius: 3px}</string>
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="5" colspan="2">
|
<item row="4" column="5" colspan="2">
|
||||||
<widget class="QPushButton" name="unsubscribeButton">
|
<widget class="QPushButton" name="unsubscribeButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
@ -339,7 +339,7 @@ border-radius: 3px}</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="7">
|
<item row="4" column="7">
|
||||||
<widget class="QPushButton" name="clearButton">
|
<widget class="QPushButton" name="clearButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
@ -365,7 +365,7 @@ border-radius: 3px}</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="8">
|
<item row="4" column="8">
|
||||||
<widget class="QPushButton" name="expandButton">
|
<widget class="QPushButton" name="expandButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
@ -394,6 +394,23 @@ border-radius: 3px}</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="warn_image_label">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="../images.qrc">:/images/status_unknown.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="warning_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -432,8 +449,7 @@ border-radius: 10px;}</string>
|
|||||||
border-radius: 10px;}</string>
|
border-radius: 10px;}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">Long
|
<string notr="true"/>
|
||||||
message here</string>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
Loading…
Reference in New Issue
Block a user