diff --git a/libretroshare/src/dbase/fimonitor.cc b/libretroshare/src/dbase/fimonitor.cc index 7067cfa4f..c3487308b 100644 --- a/libretroshare/src/dbase/fimonitor.cc +++ b/libretroshare/src/dbase/fimonitor.cc @@ -1036,7 +1036,13 @@ void FileIndexMonitor::locked_saveFileIndexes() std::set forbidden_dirs ; for(std::map::const_iterator dit(directoryMap.begin());dit!=directoryMap.end();++dit) { - std::cerr << " dir=" << dit->first << " : " ; +#ifdef FIM_DEBUG + std::cerr << " dir=" << dit->first << ", " ; + std::cerr << "parent groups: " ; + for(std::list::const_iterator mit(dit->second.parent_groups.begin());mit!=dit->second.parent_groups.end();++mit) + std::cerr << (*mit) << ", " ; + std::cerr << std::endl;; +#endif FileSearchFlags permission_flags = rsPeers->computePeerPermissionFlags(*it,dit->second.shareflags,dit->second.parent_groups) ; @@ -1132,6 +1138,7 @@ void FileIndexMonitor::updateShareFlags(const SharedDirInfo& dir) { std::cerr << "** Updating to " << (*it).shareflags << "!!" << std::endl ; (*it).shareflags = dir.shareflags ; + (*it).parent_groups = dir.parent_groups ; break ; } } @@ -1143,6 +1150,7 @@ void FileIndexMonitor::updateShareFlags(const SharedDirInfo& dir) { std::cerr << "** Updating from " << it->second.shareflags << "!!" << std::endl ; (*it).second.shareflags = dir.shareflags ; + (*it).second.parent_groups = dir.parent_groups ; fimods = true ; break ; } diff --git a/libretroshare/src/ft/ftdbase.cc b/libretroshare/src/ft/ftdbase.cc index adcdfd3d0..506f7e582 100644 --- a/libretroshare/src/ft/ftdbase.cc +++ b/libretroshare/src/ft/ftdbase.cc @@ -247,6 +247,7 @@ bool ftFiMonitor::saveList(bool &cleanup, std::list& sList) fi->file.path = (*it).filename ; fi->file.name = (*it).virtualname ; fi->flags = (*it).shareflags.toUInt32() ; + fi->parent_groups = (*it).parent_groups ; sList.push_back(fi); } @@ -347,6 +348,7 @@ bool ftFiMonitor::loadList(std::list& load) SharedDirInfo info ; info.filename = RsDirUtil::convertPathToUnix(fi->file.path); info.virtualname = fi->file.name; + info.parent_groups = fi->parent_groups; info.shareflags = FileStorageFlags(fi->flags) ; info.shareflags &= PERMISSION_MASK ; diff --git a/libretroshare/src/serialiser/rsconfigitems.cc b/libretroshare/src/serialiser/rsconfigitems.cc index f572c93b0..067ba2ee6 100644 --- a/libretroshare/src/serialiser/rsconfigitems.cc +++ b/libretroshare/src/serialiser/rsconfigitems.cc @@ -170,20 +170,24 @@ void RsFileConfigItem::clear() file.TlvClear(); flags = 0; + parent_groups.clear() ; } std::ostream &RsFileConfigItem::print(std::ostream &out, uint16_t indent) { - printRsItemBase(out, "RsFileConfigItem", indent); + printRsItemBase(out, "RsFileConfigItem", indent); uint16_t int_Indent = indent + 2; file.print(out, int_Indent); - printIndent(out, int_Indent); - out << "flags: " << flags << std::endl; + printIndent(out, int_Indent); out << "flags: " << flags << std::endl; + printIndent(out, int_Indent); out << "groups:" ; - printRsItemEnd(out, "RsFileConfigItem", indent); - return out; + for(std::list::const_iterator it(parent_groups.begin());it!=parent_groups.end();++it) + out << (*it) << " " ; + out << std::endl; + printRsItemEnd(out, "RsFileConfigItem", indent); + return out; } /*************************************************************************/ @@ -348,7 +352,10 @@ uint32_t RsFileConfigSerialiser::sizeFileItem(RsFileConfigItem *item) { uint32_t s = 8; /* header */ s += item->file.TlvSize(); - s += 4; + s += 4; // flags + + for(std::list::const_iterator it(item->parent_groups.begin());it!=item->parent_groups.end();++it) // parent groups + s += GetTlvStringSize(*it); return s; } @@ -377,9 +384,11 @@ bool RsFileConfigSerialiser::serialiseFileItem(RsFileConfigItem *item, void /* add mandatory parts first */ ok &= item->file.SetTlv(data, tlvsize, &offset); - ok &= setRawUInt32(data, tlvsize, &offset, item->flags); + for(std::list::const_iterator it(item->parent_groups.begin());ok && it!=item->parent_groups.end();++it) // parent groups + ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GROUPID, *it); + if (offset != tlvsize) { ok = false; @@ -427,6 +436,15 @@ RsFileConfigItem *RsFileConfigSerialiser::deserialiseFileItem(void *data, uint32 ok &= item->file.GetTlv(data, rssize, &offset); ok &= getRawUInt32(data, rssize, &offset, &(item->flags)); + while(offset < rssize) + { + std::string tmp ; + if(GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GROUPID, tmp)) + item->parent_groups.push_back(tmp) ; + else + break ; + } + if (offset != rssize) { /* error */ diff --git a/libretroshare/src/serialiser/rsconfigitems.h b/libretroshare/src/serialiser/rsconfigitems.h index 71d5cfff9..9d4642110 100644 --- a/libretroshare/src/serialiser/rsconfigitems.h +++ b/libretroshare/src/serialiser/rsconfigitems.h @@ -300,6 +300,7 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0); RsTlvFileItem file; uint32_t flags; + std::list parent_groups ; }; /**************************************************************************/ diff --git a/retroshare-gui/src/gui/ShareDialog.cpp b/retroshare-gui/src/gui/ShareDialog.cpp index 397415df4..39ec3354b 100644 --- a/retroshare-gui/src/gui/ShareDialog.cpp +++ b/retroshare-gui/src/gui/ShareDialog.cpp @@ -131,9 +131,10 @@ void ShareDialog::addDirectory() rsFiles->addSharedDirectory(sdi); break; } - if (it->shareflags != sdi.shareflags) { + if (it->shareflags != sdi.shareflags || it->parent_groups != sdi.parent_groups) { /* modifies the flags */ it->shareflags = sdi.shareflags; + it->parent_groups = sdi.parent_groups; rsFiles->updateShareFlags(*it); break; } diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index cdfaeb3c2..952b809a4 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -133,7 +133,17 @@ void ShareManager::load() listWidget->setRowHeight(row, 32); listWidget->setCellWidget(row, COLUMN_SHARE_FLAGS, widget); - listWidget->setItem(row, COLUMN_GROUPS, new QTableWidgetItem(QString(" - "))) ; // no groups! + QString group_string ; + int n=0; + for(std::list::const_iterator it2((*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2,++n) + { + if(n>0) + group_string += ", " ; + + group_string += QString::fromStdString(*it2) ; + } + + listWidget->setItem(row, COLUMN_GROUPS, new QTableWidgetItem(group_string)) ; listWidget->item(row,COLUMN_GROUPS)->setBackgroundColor(QColor(183,236,181)) ; connect(widget,SIGNAL(flagsChanged(FileStorageFlags)),this,SLOT(updateFlags())) ; diff --git a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp index a7bcdab8b..c83a18ae1 100644 --- a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp +++ b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp @@ -22,7 +22,10 @@ std::list GroupSelectionBox::selectedGroups() const std::list out ; for(QList::const_iterator it(selected_items.begin());it!=selected_items.end();++it) + { out.push_back((*it)->text().toStdString()) ; + std::cerr << "Addign selected item " << out.back() << std::endl; + } return out ; }