Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement proper sandboxing (SailJail) configuration #77

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion flowplayer.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ Exec=flowplayer
Name=FlowPlayer

[X-Sailjail]
Sandboxing=Disabled
OrganizationName=sailfishos-applications
# ApplicationName does not have to be identical to Name
ApplicationName=flowplayer
# Add the required permissions here
Permissions=UserDirs;Audio;Bluetooth;Internet;RemovableMedia
59 changes: 0 additions & 59 deletions src/FlowPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,6 @@
bool isDBOpened;
bool databaseWorking;

static void migrateSettings()
{
const QString oldSettings = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/cepiperez/flowplayer.conf";
const QString newSettings = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + ".conf";
if (QFile::exists(oldSettings)) {
if (QDir().mkpath(QFileInfo(newSettings).path())
&& !QFile::rename(oldSettings, newSettings)) {
qWarning() << "unable to move old configuration from" << oldSettings << "to" << newSettings;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("cepiperez");
}
}

static void migrateDatabase()
{
const QString olderDb = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/cepiperez/flowplayer.db";
const QString oldDb = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/flowplayer/flowplayer/flowplayer.db";
const QString newDb = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.db";
if (QFile::exists(oldDb)) {
if (QDir().mkpath(QFileInfo(newDb).path())
&& !QFile::rename(oldDb, newDb)) {
qWarning() << "unable to move old database from" << oldDb << "to" << newDb;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/flowplayer").rmdir("flowplayer");
QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("flowplayer");
} else if (QFile::exists(olderDb)) {
if (QDir().mkpath(QFileInfo(newDb).path())
&& !QFile::rename(olderDb, newDb)) {
qWarning() << "unable to move old database from" << olderDb << "to" << newDb;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("cepiperez");
}
}

static void migrateCache()
{
const QString olderCache = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer";
const QString oldCache = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer/flowplayer";
const QString newCache = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
if (QFileInfo(oldCache).isDir()) {
if (QDir().mkpath(QFileInfo(newCache).path())
&& !QDir().rename(oldCache, newCache)) {
qWarning() << "unable to move old cache from" << oldCache << "to" << newCache;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer").rmdir("flowplayer");
QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).rmdir("flowplayer");
} else if (QFileInfo(olderCache).isDir()) {
if (QDir().mkpath(QFileInfo(newCache).path())
&& !QDir().rename(olderCache, newCache)) {
qWarning() << "unable to move old cache from" << olderCache << "to" << newCache;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).rmdir("flowplayer");
}
}

int main(int argc, char *argv[])
{
QTextCodec *linuxCodec = QTextCodec::codecForName("UTF-8");
Expand All @@ -86,10 +31,6 @@ int main(int argc, char *argv[])
app->setOrganizationName("sailfishos-applications");
app->setApplicationName("flowplayer");

migrateSettings();
migrateDatabase();
migrateCache();

QString lang;
QTranslator translator;

Expand Down
Loading