Removed member ftController::mShareDownloadDir and calculate the value from the shared directories.

Combined the two methods for share and unshare of the download dir.
Added share incoming directory to the QuickStartWizard.
Recompile of the GUI needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4089 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-03-08 20:05:36 +00:00
parent 4779d83ab7
commit af4dd635e3
11 changed files with 68 additions and 143 deletions

View File

@ -100,7 +100,6 @@ ftController::ftController(CacheStrapper *cs, ftDataMultiplex *dm, std::string c
mDataplex(dm), mDataplex(dm),
mTurtle(NULL), mTurtle(NULL),
mFtActive(false), mFtActive(false),
mShareDownloadDir(true),
mDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM) mDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM)
{ {
_max_active_downloads = 5 ; // default queue size _max_active_downloads = 5 ; // default queue size
@ -1845,7 +1844,6 @@ bool ftController::CancelCacheFile(RsPeerId id, std::string path, std::string ha
const std::string active_downloads_size_ss("MAX_ACTIVE_DOWNLOADS"); const std::string active_downloads_size_ss("MAX_ACTIVE_DOWNLOADS");
const std::string download_dir_ss("DOWN_DIR"); const std::string download_dir_ss("DOWN_DIR");
const std::string partial_dir_ss("PART_DIR"); const std::string partial_dir_ss("PART_DIR");
const std::string share_dwl_dir("SHARE_DWL_DIR");
const std::string default_chunk_strategy_ss("DEFAULT_CHUNK_STRATEGY"); const std::string default_chunk_strategy_ss("DEFAULT_CHUNK_STRATEGY");
const std::string free_space_limit_ss("FREE_SPACE_LIMIT"); const std::string free_space_limit_ss("FREE_SPACE_LIMIT");
@ -1880,7 +1878,6 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
configMap[active_downloads_size_ss] = strm.str() ; configMap[active_downloads_size_ss] = strm.str() ;
configMap[download_dir_ss] = getDownloadDirectory(); configMap[download_dir_ss] = getDownloadDirectory();
configMap[partial_dir_ss] = getPartialsDirectory(); configMap[partial_dir_ss] = getPartialsDirectory();
configMap[share_dwl_dir] = mShareDownloadDir ? "YES" : "NO";
configMap[default_chunk_strategy_ss] = (mDefaultChunkStrategy==FileChunksInfo::CHUNK_STRATEGY_STREAMING) ? "STREAMING" : "RANDOM"; configMap[default_chunk_strategy_ss] = (mDefaultChunkStrategy==FileChunksInfo::CHUNK_STRATEGY_STREAMING) ? "STREAMING" : "RANDOM";
std::ostringstream s ; std::ostringstream s ;
@ -2074,18 +2071,6 @@ bool ftController::loadConfigMap(std::map<std::string, std::string> &configMap)
setPartialsDirectory(mit->second); setPartialsDirectory(mit->second);
} }
if (configMap.end() != (mit = configMap.find(share_dwl_dir)))
{
if (mit->second == "YES")
{
setShareDownloadDirectory(true);
}
else if (mit->second == "NO")
{
setShareDownloadDirectory(false);
}
}
if (configMap.end() != (mit = configMap.find(default_chunk_strategy_ss))) if (configMap.end() != (mit = configMap.find(default_chunk_strategy_ss)))
{ {
if(mit->second == "STREAMING") if(mit->second == "STREAMING")
@ -2143,17 +2128,3 @@ void ftController::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy S)
mDefaultChunkStrategy = S ; mDefaultChunkStrategy = S ;
IndicateConfigChanged() ; IndicateConfigChanged() ;
} }
void ftController::setShareDownloadDirectory(bool value)
{
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
mShareDownloadDir = value;
IndicateConfigChanged() ;
}
bool ftController::getShareDownloadDirectory()
{
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
return mShareDownloadDir;
}

View File

@ -126,9 +126,6 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
bool activate(); bool activate();
bool isActiveAndNoPending(); bool isActiveAndNoPending();
void setShareDownloadDirectory(bool value);
bool getShareDownloadDirectory();
virtual void run(); virtual void run();
/***************************************************************/ /***************************************************************/
@ -259,8 +256,6 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
std::list<ftPendingRequest> mPendingRequests; std::list<ftPendingRequest> mPendingRequests;
std::map<std::string,RsFileTransfer*> mPendingChunkMaps ; std::map<std::string,RsFileTransfer*> mPendingChunkMaps ;
/* share incoming directory */
bool mShareDownloadDir;
FileChunksInfo::ChunkStrategy mDefaultChunkStrategy ; FileChunksInfo::ChunkStrategy mDefaultChunkStrategy ;
uint32_t _max_active_downloads ; // maximum number of simultaneous downloads uint32_t _max_active_downloads ; // maximum number of simultaneous downloads

View File

@ -665,27 +665,33 @@ void ftServer::clearHashCache()
mFiMon->clearHashCache() ; mFiMon->clearHashCache() ;
} }
void ftServer::setShareDownloadDirectory(bool value)
{
mFtController->setShareDownloadDirectory(value);
}
bool ftServer::getShareDownloadDirectory() bool ftServer::getShareDownloadDirectory()
{ {
return mFtController->getShareDownloadDirectory(); std::list<SharedDirInfo> dirList;
mFiMon->getSharedDirectories(dirList);
std::string dir = mFtController->getDownloadDirectory();
// check if the download directory is in the list.
for (std::list<SharedDirInfo>::const_iterator it(dirList.begin()); it != dirList.end(); ++it)
if ((*it).filename == dir)
return true;
return false;
} }
bool ftServer::shareDownloadDirectory() bool ftServer::shareDownloadDirectory(bool share)
{ {
SharedDirInfo inf ; if (share) {
inf.filename = mFtController->getDownloadDirectory(); /* Share */
inf.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ; SharedDirInfo inf ;
inf.filename = mFtController->getDownloadDirectory();
inf.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
return addSharedDirectory(inf); return addSharedDirectory(inf);
} }
bool ftServer::unshareDownloadDirectory() /* Unshare */
{
std::string dir = mFtController->getDownloadDirectory(); std::string dir = mFtController->getDownloadDirectory();
return removeSharedDirectory(dir); return removeSharedDirectory(dir);
} }

View File

@ -197,10 +197,8 @@ virtual bool addSharedDirectory(const SharedDirInfo& dir);
virtual bool updateShareFlags(const SharedDirInfo& dir); // updates the flags. The directory should already exist ! virtual bool updateShareFlags(const SharedDirInfo& dir); // updates the flags. The directory should already exist !
virtual bool removeSharedDirectory(std::string dir); virtual bool removeSharedDirectory(std::string dir);
virtual void setShareDownloadDirectory(bool value);
virtual bool getShareDownloadDirectory(); virtual bool getShareDownloadDirectory();
virtual bool shareDownloadDirectory(); virtual bool shareDownloadDirectory(bool share);
virtual bool unshareDownloadDirectory();
virtual void setRememberHashFilesDuration(uint32_t days) ; virtual void setRememberHashFilesDuration(uint32_t days) ;
virtual uint32_t rememberHashFilesDuration() const ; virtual uint32_t rememberHashFilesDuration() const ;

View File

@ -190,10 +190,8 @@ class RsFiles
virtual bool rememberHashFiles() const =0; virtual bool rememberHashFiles() const =0;
virtual void setRememberHashFiles(bool) =0; virtual void setRememberHashFiles(bool) =0;
virtual void setShareDownloadDirectory(bool value) = 0;
virtual bool getShareDownloadDirectory() = 0; virtual bool getShareDownloadDirectory() = 0;
virtual bool shareDownloadDirectory() = 0; virtual bool shareDownloadDirectory(bool share) = 0;
virtual bool unshareDownloadDirectory() = 0;
}; };

View File

@ -244,6 +244,12 @@ void QuickStartWizard::on_pushButtonSharesRemove_clicked()
} }
} }
void QuickStartWizard::on_shareIncomingDirectory_clicked()
{
rsFiles->shareDownloadDirectory(ui.shareIncomingDirectory->isChecked());
loadShare();
}
void QuickStartWizard::loadShare() void QuickStartWizard::loadShare()
{ {
std::cerr << "ShareManager:: In load !!!!!" << std::endl ; std::cerr << "ShareManager:: In load !!!!!" << std::endl ;
@ -252,6 +258,8 @@ void QuickStartWizard::loadShare()
std::list<SharedDirInfo> dirs; std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs); rsFiles->getSharedDirectories(dirs);
ui.shareIncomingDirectory->setChecked(rsFiles->getShareDownloadDirectory());
/* get a link to the table */ /* get a link to the table */
QTableWidget *listWidget = ui.shareddirList; QTableWidget *listWidget = ui.shareddirList;

View File

@ -51,6 +51,7 @@ private:
bool messageBoxOk(QString); bool messageBoxOk(QString);
private Q_SLOTS: private Q_SLOTS:
void on_shareIncomingDirectory_clicked();
void on_pushButtonSharesRemove_clicked(); void on_pushButtonSharesRemove_clicked();
void on_pushButtonSharesAdd_clicked(); void on_pushButtonSharesAdd_clicked();
void on_pushButtonSystemExit_clicked(); void on_pushButtonSystemExit_clicked();

View File

@ -158,7 +158,7 @@ p, li { white-space: pre-wrap; }
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="pageWelcome"> <widget class="QWidget" name="pageWelcome">
<property name="styleSheet"> <property name="styleSheet">
@ -681,21 +681,21 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QPushButton" name="pushButtonSharesAdd"> <widget class="QPushButton" name="pushButtonSharesAdd">
<property name="text"> <property name="text">
<string>Add</string> <string>Add</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QPushButton" name="pushButtonSharesRemove"> <widget class="QPushButton" name="pushButtonSharesRemove">
<property name="text"> <property name="text">
<string>Remove</string> <string>Remove</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="3" column="2">
<spacer name="horizontalSpacer_16"> <spacer name="horizontalSpacer_16">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -708,7 +708,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="0" colspan="3"> <item row="4" column="0" colspan="3">
<spacer name="verticalSpacer_4"> <spacer name="verticalSpacer_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -721,6 +721,13 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="shareIncomingDirectory">
<property name="text">
<string>Automatically share incoming directory (Recommended)</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -34,20 +34,13 @@ DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags)
ui.setupUi(this); ui.setupUi(this);
setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_QuitOnClose, false);
if (rsFiles->getShareDownloadDirectory()) ui.checkBox->setChecked(rsFiles->getShareDownloadDirectory()); /* signal not emitted */
{
ui.checkBox->setChecked(true); /* signal not emitted */
}
else
{
ui.checkBox->setChecked(false); /* signal not emitted */
}
uint32_t t = rsFiles->rememberHashFilesDuration() ; uint32_t t = rsFiles->rememberHashFilesDuration() ;
bool b = rsFiles->rememberHashFiles() ; bool b = rsFiles->rememberHashFiles() ;
ui.rememberHashesSB->setValue(t) ; ui.rememberHashesSB->setValue(t) ;
ui.rememberHashesCB->setChecked(b) ; ui.rememberHashesCB->setChecked(b) ;
connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) ); connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) ); connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
@ -57,7 +50,7 @@ DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags)
connect(ui.rememberHashesCB, SIGNAL(toggled(bool)), this, SLOT(toggleRememberHashes(bool))); connect(ui.rememberHashesCB, SIGNAL(toggled(bool)), this, SLOT(toggleRememberHashes(bool)));
connect(ui.rememberHashesSB, SIGNAL(valueChanged(int)), this, SLOT(setRememberHashesDuration(int))); connect(ui.rememberHashesSB, SIGNAL(valueChanged(int)), this, SLOT(setRememberHashesDuration(int)));
/* Hide platform specific features */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#endif #endif
@ -114,29 +107,7 @@ bool DirectoriesPage::save(QString &errmsg)
/* this is usefull especially when shared incoming files is /* this is usefull especially when shared incoming files is
* default option and when the user don't check/uncheck the * default option and when the user don't check/uncheck the
* checkBox, so no signal is emitted to update the shared list */ * checkBox, so no signal is emitted to update the shared list */
if (ui.checkBox->isChecked()) rsFiles->shareDownloadDirectory(ui.checkBox->isChecked());
{
std::list<SharedDirInfo>::const_iterator it;
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
bool found = false ;
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
if((*it).filename == rsFiles->getDownloadDirectory())
{
found=true ;
break ;
}
if(!found)
rsFiles->shareDownloadDirectory();
rsFiles->setShareDownloadDirectory(true);
}
else
{
rsFiles->unshareDownloadDirectory();
rsFiles->setShareDownloadDirectory(false);
}
return true; return true;
} }
@ -182,19 +153,7 @@ void DirectoriesPage::setIncomingDirectory()
rsFiles->setDownloadDirectory(dir); rsFiles->setDownloadDirectory(dir);
if (ui.checkBox->isChecked()) if (ui.checkBox->isChecked())
{ {
std::list<SharedDirInfo>::const_iterator it; rsFiles->shareDownloadDirectory(true);
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
bool found = false ;
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
if((*it).filename == rsFiles->getDownloadDirectory())
{
found=true ;
break ;
}
if(!found)
rsFiles->shareDownloadDirectory();
} }
} }
load(); load();
@ -214,29 +173,6 @@ void DirectoriesPage::setPartialsDirectory()
void DirectoriesPage::shareDownloadDirectory(int state) void DirectoriesPage::shareDownloadDirectory(int state)
{ {
if (state == Qt::Checked) rsFiles->shareDownloadDirectory(state == Qt::Checked);
{
std::list<SharedDirInfo>::const_iterator it;
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
bool found = false ;
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
if((*it).filename == rsFiles->getDownloadDirectory())
{
found=true ;
break ;
}
if(!found)
rsFiles->shareDownloadDirectory();
rsFiles->setShareDownloadDirectory(true);
}
else
{
rsFiles->unshareDownloadDirectory();
rsFiles->setShareDownloadDirectory(false);
}
load(); load();
} }

View File

@ -2782,12 +2782,12 @@ p, li { white-space: pre-wrap; }
<translation>Durchsuchen</translation> <translation>Durchsuchen</translation>
</message> </message>
<message> <message>
<location filename="../gui/settings/DirectoriesPage.cpp" line="+179"/> <location filename="../gui/settings/DirectoriesPage.cpp" line="+148"/>
<source>Set Incoming Directory</source> <source>Set Incoming Directory</source>
<translation>Ordner für eingehende Dateien</translation> <translation>Ordner für eingehende Dateien</translation>
</message> </message>
<message> <message>
<location line="+28"/> <location line="+16"/>
<source>Set Partials Directory</source> <source>Set Partials Directory</source>
<translation>Ordner für temporäre Dateien</translation> <translation>Ordner für temporäre Dateien</translation>
</message> </message>
@ -2838,7 +2838,7 @@ Das ist nützlich, wenn Du eine externe Festplatte freigibst und die Datei nicht
<message> <message>
<location line="+62"/> <location line="+62"/>
<source>Automatically share incoming directory (Recommended)</source> <source>Automatically share incoming directory (Recommended)</source>
<translation>Eingehende Ordner automatisch freigeben</translation> <translation>Eingehende Ordner automatisch freigeben (Empfohlen)</translation>
</message> </message>
</context> </context>
<context> <context>
@ -8893,20 +8893,20 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location line="+120"/> <location line="+120"/>
<location line="+269"/> <location line="+269"/>
<location line="+235"/> <location line="+242"/>
<source>Next &gt;</source> <source>Next &gt;</source>
<translation>Weiter &gt;</translation> <translation>Weiter &gt;</translation>
</message> </message>
<message> <message>
<location line="-494"/> <location line="-501"/>
<location line="+269"/> <location line="+269"/>
<location line="+235"/> <location line="+242"/>
<location line="+205"/> <location line="+205"/>
<source>Exit</source> <source>Exit</source>
<translation>Beenden</translation> <translation>Beenden</translation>
</message> </message>
<message> <message>
<location line="-649"/> <location line="-656"/>
<source>For best performance, RetroShare needs to know a little about your connection to the internet.</source> <source>For best performance, RetroShare needs to know a little about your connection to the internet.</source>
<translation>Für die beste Leistung muß RetroShare ein wenig über Deine Internetverbindung wissen.</translation> <translation>Für die beste Leistung muß RetroShare ein wenig über Deine Internetverbindung wissen.</translation>
</message> </message>
@ -8953,13 +8953,13 @@ p, li { white-space: pre-wrap; }
</message> </message>
<message> <message>
<location line="+94"/> <location line="+94"/>
<location line="+235"/> <location line="+242"/>
<location line="+205"/> <location line="+205"/>
<source>&lt; Back</source> <source>&lt; Back</source>
<translation>&lt; Zurück</translation> <translation>&lt; Zurück</translation>
</message> </message>
<message> <message>
<location line="-358"/> <location line="-365"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
@ -9004,7 +9004,12 @@ p, li { white-space: pre-wrap; }
<translation>Entfernen</translation> <translation>Entfernen</translation>
</message> </message>
<message> <message>
<location line="+137"/> <location line="+33"/>
<source>Automatically share incoming directory (Recommended)</source>
<translation>Eingehende Ordner automatisch freigeben (Empfohlen)</translation>
</message>
<message>
<location line="+111"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
@ -9085,7 +9090,7 @@ p, li { white-space: pre-wrap; }
<translation>Warnung!</translation> <translation>Warnung!</translation>
</message> </message>
<message> <message>
<location filename="../gui/QuickStartWizard.ui" line="-775"/> <location filename="../gui/QuickStartWizard.ui" line="-782"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }