From f7c262fb07a749b254bf95b7e4b88db707542f6b Mon Sep 17 00:00:00 2001 From: Rowen Stipe Date: Mon, 18 Jan 2016 14:36:35 -0500 Subject: [PATCH 1/5] Touchups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit has several touch ups that only effect the OS X clients. `info.plist` and `qt.pro` are now configured to create an automatic short version to help distinguish between clients clearly and include a referenced file not put into the build when compiled. `./img/icon/qtox_profile.icns’ `info.plist` also had it’s bundle version to be updated to the 1.2.2 tag and supported languages added and fixed referenced file. The default save location has also been moved to comply with the Tox Client Standard. (Previous location was ~/Library/Prefrences/tox ) A basic bash profile mover has also been included to show I did think of that. --- OSX-Migrater.sh | 15 +++++++++++ osx/info.plist | 49 ++++++++++++++++++++++-------------- qtox.pro | 7 ++++++ src/persistence/settings.cpp | 3 +++ 4 files changed, 55 insertions(+), 19 deletions(-) create mode 100755 OSX-Migrater.sh diff --git a/OSX-Migrater.sh b/OSX-Migrater.sh new file mode 100755 index 000000000..b63eb0134 --- /dev/null +++ b/OSX-Migrater.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# A qTox profile migrater for OSX +echo "Figuring out if action is required ..." +if [ -d ~/Library/Prefrences/tox] + 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 + echo "Done! You profile(s) have been moved! A back up coppy still exists at:" + echo "~/.Tox-Backup" +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..d6138ae2e 100644 --- a/osx/info.plist +++ b/osx/info.plist @@ -9,7 +9,7 @@ CFBundlePackageType APPL CFBundleSignature - ???? + toxq CFBundleExecutable qtox CFBundleDisplayName @@ -17,9 +17,9 @@ CFBundleName qTox CFBundleVersion - 1.0.0 + 1.2.2 CFBundleShortVersionString - 1.0.0-EXPERIMENTIAL + @SHORT_VERSION@ CFBundleIdentifier chat.tox.qtox CFBundleURLTypes @@ -34,7 +34,7 @@ tox CFBundleURLIconFile - qtox_profile.icns + qtox_profile CFBundleDocumentTypes @@ -49,7 +49,7 @@ CFBundleTypeRole Editor CFBundleTypeIconFile - qtox_profile.icns + qtox_profile CFBundleTypeMIMETypes application/x-tox.profile @@ -84,19 +84,30 @@ - CFBundleLocalizations - - en_US - en - bg_BG - de_DE - fi_FI - fr_FR - it_IT - pl_PL - ru_RU - uk_UA - sv - + 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..5924e62cd 100644 --- a/qtox.pro +++ b/qtox.pro @@ -164,6 +164,13 @@ 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 + APP_RESOURCE.files = img/icons/qtox_profile.icns + 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/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(); From e05e736d336f7ab2c48c68765b7178e9156fcdaf Mon Sep 17 00:00:00 2001 From: Rowen Stipe Date: Tue, 19 Jan 2016 04:36:41 -0500 Subject: [PATCH 2/5] Performed auto-indentation Ran an auto indentation script included in one of my text editors (TextMate:greenheart:) --- osx/info.plist | 218 ++++++++++++++++++++++++------------------------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/osx/info.plist b/osx/info.plist index d6138ae2e..f9b22ce8a 100644 --- a/osx/info.plist +++ b/osx/info.plist @@ -1,113 +1,113 @@ - - 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 - - + + 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 + + From 27fda2e579f7da5cdf82afa67999df4fdede3b28 Mon Sep 17 00:00:00 2001 From: Rowen Stipe Date: Tue, 19 Jan 2016 06:36:15 -0500 Subject: [PATCH 3/5] Added basic migration compatibility code. This code works if the ~/Library/Application Support/Tox directory does not already exist. --- src/main.cpp | 11 ++++++----- src/platform/install_osx.cpp | 26 ++++++++++++++++++++++++++ src/platform/install_osx.h | 3 ++- 3 files changed, 34 insertions(+), 6 deletions(-) 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/platform/install_osx.cpp b/src/platform/install_osx.cpp index 4638a0168..86e11cdbb 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,27 @@ void osx::moveToAppFolder() } } } + +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."; + } + } + else + { + qDebug() << "OS X: Old settings directory not detected"; + } +} 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 From a05310e15509627f68a0181ec0a27c197ce8231b Mon Sep 17 00:00:00 2001 From: Rowen Stipe Date: Wed, 20 Jan 2016 01:22:25 -0500 Subject: [PATCH 4/5] Added case for `/Application Support/Tox` already existing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I tried to get it done without bash… But this was the simplest method that works for this special case scenerio. --- OSX-Migrater.sh | 9 ++++++--- qtox.pro | 3 ++- src/platform/install_osx.cpp | 13 +++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/OSX-Migrater.sh b/OSX-Migrater.sh index b63eb0134..891fd6e9c 100755 --- a/OSX-Migrater.sh +++ b/OSX-Migrater.sh @@ -1,14 +1,17 @@ #!/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/Prefrences/tox] +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 + mv ~/Library/Preferences/tox ~/.Tox-Backup-$now echo "Done! You profile(s) have been moved! A back up coppy still exists at:" - echo "~/.Tox-Backup" + echo "$bak" else echo "Cannot locate old profile directory, profile migration not performed" fi diff --git a/qtox.pro b/qtox.pro index 5924e62cd..e73351388 100644 --- a/qtox.pro +++ b/qtox.pro @@ -165,7 +165,8 @@ win32 { 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 - APP_RESOURCE.files = img/icons/qtox_profile.icns + #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 diff --git a/src/platform/install_osx.cpp b/src/platform/install_osx.cpp index 86e11cdbb..a5a832bdd 100644 --- a/src/platform/install_osx.cpp +++ b/src/platform/install_osx.cpp @@ -84,7 +84,7 @@ 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() + @@ -100,7 +100,15 @@ void osx::migrateProfiles() 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."; + 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 @@ -108,3 +116,4 @@ void osx::migrateProfiles() qDebug() << "OS X: Old settings directory not detected"; } } +// End migrateProfiles() compatibility code From df584531c847730ca186f2e6264e822e9f524fce Mon Sep 17 00:00:00 2001 From: Rowen Stipe Date: Wed, 20 Jan 2016 05:17:03 -0500 Subject: [PATCH 5/5] Enable OS X Auto-run at login --- src/platform/autorun_osx.cpp | 26 ++++++++++++++++++++++-- src/widget/form/settings/generalform.cpp | 3 --- 2 files changed, 24 insertions(+), 5 deletions(-) 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/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();