diff --git a/OSX-Migrater.sh b/OSX-Migrater.sh new file mode 100755 index 000000000..891fd6e9c --- /dev/null +++ b/OSX-Migrater.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# A qTox profile migrater for OSX +now=$(date +"%m_%d_%Y-%H.%M.%S") +bak="~/.Tox-Backup-$now" + +echo "Figuring out if action is required ..." +if [ -d ~/Library/Preferences/tox ]; then + echo "Moving profile(s) ..." + cp -r ~/Library/Preferences/tox ~/Library/Application\ Support/ + mv ~/Library/Application\ Support/tox/ ~/Library/Application\ Support/Tox + mv ~/Library/Preferences/tox ~/.Tox-Backup-$now + echo "Done! You profile(s) have been moved! A back up coppy still exists at:" + echo "$bak" +else + echo "Cannot locate old profile directory, profile migration not performed" +fi +exit 0 \ No newline at end of file diff --git a/osx/info.plist b/osx/info.plist index a6ff7ab5d..f9b22ce8a 100644 --- a/osx/info.plist +++ b/osx/info.plist @@ -1,102 +1,113 @@ - - NSPrincipalClass - NSApplication - CFBundleIconFile - qtox.icns - CFBundlePackageType - APPL - CFBundleSignature - ???? - CFBundleExecutable - qtox - CFBundleDisplayName - qTox - CFBundleName - qTox - CFBundleVersion - 1.0.0 - CFBundleShortVersionString - 1.0.0-EXPERIMENTIAL - CFBundleIdentifier - chat.tox.qtox - CFBundleURLTypes - - - CFBundleURLName - Tox URL - CFBundleTypeRole - Viewer - CFBundleURLSchemes - - tox - - CFBundleURLIconFile - qtox_profile.icns - - - CFBundleDocumentTypes - - - CFBundleTypeExtensions - - tox - - CFBundleTypeName - Tox profile - CFBundleTypeRole - Editor - CFBundleTypeIconFile - qtox_profile.icns - CFBundleTypeMIMETypes - - application/x-tox.profile - - LSHandlerRank - Owner - LSItemContentTypes - - public.tox - - - - UTImportedTypeDeclarations - - - UTTypeConformsTo - - public.data - - UTTypeIdentifier - public.tox - UTTypeTagSpecification - - com.apple.ostype - TOX - public.filename-extension - - tox - - public.mime-type - tox/x-profile - - - - CFBundleLocalizations - - en_US - en - bg_BG - de_DE - fi_FI - fr_FR - it_IT - pl_PL - ru_RU - uk_UA - sv - - + + NSPrincipalClass + NSApplication + CFBundleIconFile + qtox.icns + CFBundlePackageType + APPL + CFBundleSignature + toxq + CFBundleExecutable + qtox + CFBundleDisplayName + qTox + CFBundleName + qTox + CFBundleVersion + 1.2.2 + CFBundleShortVersionString + @SHORT_VERSION@ + CFBundleIdentifier + chat.tox.qtox + CFBundleURLTypes + + + CFBundleURLName + Tox URL + CFBundleTypeRole + Viewer + CFBundleURLSchemes + + tox + + CFBundleURLIconFile + qtox_profile + + + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + tox + + CFBundleTypeName + Tox profile + CFBundleTypeRole + Editor + CFBundleTypeIconFile + qtox_profile + CFBundleTypeMIMETypes + + application/x-tox.profile + + LSHandlerRank + Owner + LSItemContentTypes + + public.tox + + + + UTImportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeIdentifier + public.tox + UTTypeTagSpecification + + com.apple.ostype + TOX + public.filename-extension + + tox + + public.mime-type + tox/x-profile + + + + CFBundleLocalizations + + en_US + bg_BG + cs + de_DE + el + es_MX + fi_FI + fr_FR + hr_HR + hu_HU + it_IT + lt_LT + nl_NL + nb_NO + pl_PL + pt_BR + ru_RU + sl + sv + tr_TR + uk_UA + zh_CH + + diff --git a/qtox.pro b/qtox.pro index 84ffa9dc8..e73351388 100644 --- a/qtox.pro +++ b/qtox.pro @@ -164,6 +164,14 @@ win32 { LIBS += -lqrencode -lsqlcipher contains(DEFINES, QTOX_PLATFORM_EXT) { LIBS += -framework IOKit -framework CoreFoundation } contains(DEFINES, QTOX_FILTER_AUDIO) { LIBS += -lfilteraudio } + #Files to be includes into the qTox.app/Contents/Resources folder + #OSX-Migrater.sh part of migrateProfiles() compatabilty code + APP_RESOURCE.files = img/icons/qtox_profile.icns OSX-Migrater.sh + APP_RESOURCE.path = Contents/Resources + QMAKE_BUNDLE_DATA += APP_RESOURCE + #Dynamic versioning for Info.plist + INFO_PLIST_PATH = $$shell_quote($${OUT_PWD}/$${TARGET}.app/Contents/Info.plist) + QMAKE_POST_LINK += /usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $${GIT_DESCRIBE}\" $${INFO_PLIST_PATH} } else { android { LIBS += -ltoxcore -ltoxav -ltoxencryptsave -ltoxdns diff --git a/src/main.cpp b/src/main.cpp index 324dc418c..05abac6e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,7 +38,7 @@ #include -#if defined(Q_OS_MACX) && defined(QT_RELEASE) +#if defined(Q_OS_OSX) #include "platform/install_osx.h" #endif @@ -98,6 +98,11 @@ int main(int argc, char *argv[]) a.setOrganizationName("Tox"); a.setApplicationVersion("\nGit commit: " + QString(GIT_VERSION)); +#if defined(Q_OS_OSX) + //osx::moveToAppFolder(); TODO: Add setting to enable this feature. + osx::migrateProfiles(); +#endif + #ifdef HIGH_DPI a.setAttribute(Qt::AA_UseHighDpiPixmaps, true); #endif @@ -143,10 +148,6 @@ int main(int argc, char *argv[]) qDebug() << "built on: " << __TIME__ << __DATE__ << "(" << TIMESTAMP << ")"; qDebug() << "commit: " << GIT_VERSION << "\n"; -#if defined(Q_OS_MACX) && defined(QT_RELEASE) - osx::moveToAppFolder(); -#endif - // Install Unicode 6.1 supporting font QFontDatabase::addApplicationFont("://DejaVuSans.ttf"); diff --git a/src/persistence/settings.cpp b/src/persistence/settings.cpp index 5ea0716b2..0839e4303 100644 --- a/src/persistence/settings.cpp +++ b/src/persistence/settings.cpp @@ -537,6 +537,9 @@ QString Settings::getSettingsDirPath() #ifdef Q_OS_WIN return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() + "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator(); +#elif defined(Q_OS_OSX) + return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() + + "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox")+QDir::separator(); #else return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QDir::separator() + "tox")+QDir::separator(); diff --git a/src/platform/autorun_osx.cpp b/src/platform/autorun_osx.cpp index 99362e236..62344d6ad 100644 --- a/src/platform/autorun_osx.cpp +++ b/src/platform/autorun_osx.cpp @@ -19,16 +19,38 @@ #if defined(__APPLE__) && defined(__MACH__) #include "src/platform/autorun.h" +#include +#include +#include +#include +#include +int state ; bool Platform::setAutorun(bool on) { - return false; + QString qtoxPlist = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() + + "Library" + QDir::separator() + "LaunchAgents" + QDir::separator() + "chat.tox.qtox.autorun.plist"); + QString qtoxDir = QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() + "qtox"); + QSettings autoRun(qtoxPlist, QSettings::NativeFormat); + autoRun.setValue("Label","chat.tox.qtox.autorun"); + autoRun.setValue("Program", qtoxDir); + + if (on) + { + autoRun.setValue("RunAtLoad",true); + state = true; + } + else + { + autoRun.setValue("RunAtLoad",false); + state = false; + } } bool Platform::getAutorun() { - return false; + return state; } #endif // defined(__APPLE__) && defined(__MACH__) diff --git a/src/platform/install_osx.cpp b/src/platform/install_osx.cpp index 4638a0168..a5a832bdd 100644 --- a/src/platform/install_osx.cpp +++ b/src/platform/install_osx.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include @@ -82,3 +84,36 @@ void osx::moveToAppFolder() } } } +// migrateProfiles() is compatabilty code that can be removed down the line when the time seems right. +void osx::migrateProfiles() +{ + QString oldPath = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() + + "Library" + QDir::separator() + "Preferences" + QDir::separator() + "tox"); + QFileInfo checkDir(oldPath); + + QString newPath = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() + + "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox"); + QDir dir; + + if (checkDir.exists() && checkDir.isDir()) + { + qDebug() << "OS X: Old settings directory detected migrating to default"; + if( !dir.rename(oldPath, newPath) ) + { + qDebug() << "OS X: Profile migration failed. ~/Library/Application Support/Tox already exists. Using alternate migration method."; + QString OSXMigrater = "../Resources/OSX-Migrater.sh" ; + QProcess::execute(OSXMigrater); + QMessageBox MigrateProfile; + MigrateProfile.setIcon(QMessageBox::Information); + MigrateProfile.setWindowModality(Qt::ApplicationModal); + MigrateProfile.setText("Alternate profile migration method used."); + MigrateProfile.setInformativeText("It has been detected that your profiles \nwhere migrated to the new settings directory; \nusing the alternate migration method. \n\nA backup can be found in your: \n/Users/[USER]/.Tox-Backup[DATE-TIME] \n\nJust in case. \r\n"); + MigrateProfile.exec(); + } + } + else + { + qDebug() << "OS X: Old settings directory not detected"; + } +} +// End migrateProfiles() compatibility code diff --git a/src/platform/install_osx.h b/src/platform/install_osx.h index 115fabd60..aaab8dde9 100644 --- a/src/platform/install_osx.h +++ b/src/platform/install_osx.h @@ -21,7 +21,7 @@ #include -#ifndef Q_OS_MACX +#ifndef Q_OS_OSX #error "This file is only meant to be compiled for Mac OSX targets" #endif @@ -31,6 +31,7 @@ namespace osx static constexpr int EXIT_UPDATE_MACX_FAIL = 216; void moveToAppFolder(); + void migrateProfiles(); } #endif // INSTALLOSX_H diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index 8c88843ce..851c3057b 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -104,9 +104,6 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation())); bodyUI->cbAutorun->setChecked(Settings::getInstance().getAutorun()); -#if defined(__APPLE__) && defined(__MACH__) - bodyUI->cbAutorun->setEnabled(false); -#endif bool showSystemTray = Settings::getInstance().getShowSystemTray();