mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-24 15:05:35 -04:00
started cleaning the mess with rsAccounts: only exposed useful functionality of rsAccount beyond a static class and removed all references to rsAccounts in the code
This commit is contained in:
parent
e2bb3aef1b
commit
0f758902cd
19 changed files with 279 additions and 214 deletions
|
@ -620,7 +620,7 @@ void GenCertDialog::genPerson()
|
|||
std::string err;
|
||||
this->hide();//To show dialog asking password PGP Key.
|
||||
std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl;
|
||||
bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err);
|
||||
bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err);
|
||||
|
||||
if (okGen)
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ SoundManager::SoundManager() : QObject()
|
|||
|
||||
void SoundManager::soundEvents(SoundEvents &events)
|
||||
{
|
||||
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds");
|
||||
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/sounds");
|
||||
|
||||
events.mDefaultPath = baseDir.absolutePath();
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ static QStringList getBaseDirList()
|
|||
// Search chat styles in config dir and data dir (is application dir for portable)
|
||||
QStringList baseDirs;
|
||||
baseDirs.append(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()));
|
||||
baseDirs.append(QString::fromUtf8(RsAccounts::DataDirectory().c_str()));
|
||||
baseDirs.append(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()));
|
||||
|
||||
return baseDirs;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
|
|||
if(fi.exists() && fi.isFile()) {
|
||||
QString cpath = fi.canonicalFilePath();
|
||||
if (cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive)
|
||||
|| cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive))
|
||||
|| cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive))
|
||||
return QTextBrowser::loadResource(type, name);
|
||||
}}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
static QMap<RsPlugin*, QTranslator*> translatorPlugins;
|
||||
|
||||
#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsAccounts::DataDirectory().c_str())
|
||||
#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsAccounts::systemDataDirectory().c_str())
|
||||
|
||||
/** Initializes the list of available languages. */
|
||||
QMap<QString, QString>
|
||||
|
|
|
@ -349,48 +349,57 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||
|
||||
SoundManager::create();
|
||||
|
||||
#ifdef RETROTOR
|
||||
// Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service
|
||||
bool is_hidden_node = false;
|
||||
bool is_auto_tor = false ;
|
||||
bool is_first_time = false ;
|
||||
|
||||
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
|
||||
RsAccounts::getCurrentAccountOptions(is_hidden_node,is_auto_tor,is_first_time);
|
||||
|
||||
Tor::TorManager *torManager = Tor::TorManager::instance();
|
||||
torManager->setDataDirectory(Rshare::dataDirectory() + QString("/tor/"));
|
||||
torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run
|
||||
|
||||
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
|
||||
|
||||
torManager->setupHiddenService();
|
||||
|
||||
if(! torManager->start() || torManager->hasError())
|
||||
#ifdef UNFINISHED
|
||||
if(RsAccounts::AccountType() == RS_ACCOUNT_TYPE_HIDDEN_TOR_AUTO)
|
||||
{
|
||||
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor Manager!"),QObject::tr("Tor cannot be started on your system: \n\n")+torManager->errorMessage()) ;
|
||||
return 1 ;
|
||||
}
|
||||
// Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service
|
||||
|
||||
{
|
||||
TorControlDialog tcd(torManager) ;
|
||||
QString error_msg ;
|
||||
tcd.show();
|
||||
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
|
||||
|
||||
while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
|
||||
Tor::TorManager *torManager = Tor::TorManager::instance();
|
||||
torManager->setDataDirectory(Rshare::dataDirectory() + QString("/tor/"));
|
||||
torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run
|
||||
|
||||
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
|
||||
|
||||
torManager->setupHiddenService();
|
||||
|
||||
if(! torManager->start() || torManager->hasError())
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
rstime::rs_usleep(0.2*1000*1000) ;
|
||||
|
||||
if(!error_msg.isNull())
|
||||
{
|
||||
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ;
|
||||
return 1;
|
||||
}
|
||||
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor Manager!"),QObject::tr("Tor cannot be started on your system: \n\n")+torManager->errorMessage()) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
tcd.hide();
|
||||
|
||||
if(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK)
|
||||
{
|
||||
QMessageBox::critical(NULL,QObject::tr("Cannot start a hidden tor service!"),QObject::tr("It was not possible to start a hidden service.")) ;
|
||||
return 1 ;
|
||||
TorControlDialog tcd(torManager) ;
|
||||
QString error_msg ;
|
||||
tcd.show();
|
||||
|
||||
while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
rstime::rs_usleep(0.2*1000*1000) ;
|
||||
|
||||
if(!error_msg.isNull())
|
||||
{
|
||||
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
tcd.hide();
|
||||
|
||||
if(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK)
|
||||
{
|
||||
QMessageBox::critical(NULL,QObject::tr("Cannot start a hidden tor service!"),QObject::tr("It was not possible to start a hidden service.")) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -748,7 +748,7 @@ void Rshare::loadStyleSheet(const QString &sheetName)
|
|||
/* external stylesheet */
|
||||
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()), name, sheetName));
|
||||
if (!file.exists()) {
|
||||
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::DataDirectory().c_str()), name, sheetName));
|
||||
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()), name, sheetName));
|
||||
}
|
||||
}
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
|
@ -787,7 +787,7 @@ void Rshare::getAvailableStyleSheets(QMap<QString, QString> &styleSheets)
|
|||
styleSheets.insert(name, name);
|
||||
}
|
||||
}
|
||||
fileInfoList = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss"));
|
||||
fileInfoList = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss"));
|
||||
foreach (fileInfo, fileInfoList) {
|
||||
if (fileInfo.isFile()) {
|
||||
QString name = fileInfo.baseName();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue