Comparar commits
2 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 75f5026404 | |||
| a640384d3a |
+1
-1
@@ -3,7 +3,7 @@
|
||||
url = https://github.com/owncloud/documentation
|
||||
[submodule "src/3rdparty/qtmacgoodies"]
|
||||
path = src/3rdparty/qtmacgoodies
|
||||
url = https://github.com/guruz/qtmacgoodies.git
|
||||
url = git://github.com/guruz/qtmacgoodies.git
|
||||
[submodule "binary"]
|
||||
path = binary
|
||||
url = git://github.com/owncloud/owncloud-client-binary.git
|
||||
|
||||
+29
-6
@@ -20,11 +20,6 @@ if (NOT DEFINED APPLICATION_SHORTNAME)
|
||||
set ( APPLICATION_SHORTNAME ${APPLICATION_NAME} )
|
||||
endif()
|
||||
|
||||
# For usage in XML files we preprocess
|
||||
string(REPLACE "&" "&" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME}")
|
||||
string(REPLACE "<" "<" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
|
||||
string(REPLACE ">" ">" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
|
||||
|
||||
set(PACKAGE "${APPLICATION_SHORTNAME}-client")
|
||||
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
|
||||
|
||||
@@ -35,7 +30,7 @@ endif()
|
||||
include(Warnings)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/src/mirall/")
|
||||
|
||||
# disable the crashreporter if libcrashreporter-qt is not available or we're building for ARM
|
||||
if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libcrashreporter-qt/CMakeLists.txt")
|
||||
@@ -56,7 +51,9 @@ endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(DefineInstallationPaths)
|
||||
include(QtVersionAbstraction)
|
||||
|
||||
setup_qt()
|
||||
|
||||
include(GetGitRevisionDescription)
|
||||
|
||||
@@ -129,8 +126,34 @@ if(APPLE)
|
||||
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
|
||||
endif()
|
||||
|
||||
#### find libs
|
||||
#find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest QtWebkit REQUIRED )
|
||||
#if( UNIX AND NOT APPLE ) # Fdo notifications
|
||||
# find_package(Qt4 4.7.0 COMPONENTS QtDBus REQUIRED )
|
||||
#endif()
|
||||
|
||||
|
||||
if(HAVE_QT5)
|
||||
if (${Qt5Core_VERSION_MAJOR} EQUAL "5")
|
||||
if (${Qt5Core_VERSION_MINOR} EQUAL "4" OR ${Qt5Core_VERSION_MINOR} GREATER 4)
|
||||
else()
|
||||
message(STATUS "If possible compile me with Qt 5.4 or higher.")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "If possible compile me with Qt 5.4 or higher.")
|
||||
endif()
|
||||
|
||||
find_package(OpenSSL 1.0.0 REQUIRED)
|
||||
|
||||
if(NOT TOKEN_AUTH_ONLY)
|
||||
if (Qt5Core_DIR)
|
||||
find_package(Qt5Keychain REQUIRED)
|
||||
else()
|
||||
find_package(QtKeychain REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
find_package(Sparkle)
|
||||
endif(APPLE)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ set( MIRALL_VERSION_YEAR 2016 )
|
||||
set( MIRALL_SOVERSION 0 )
|
||||
|
||||
if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
set( MIRALL_VERSION_SUFFIX "beta1") #e.g. beta1, beta2, rc1
|
||||
set( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1
|
||||
endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
|
||||
if( NOT DEFINED MIRALL_VERSION_BUILD )
|
||||
|
||||
@@ -497,7 +497,7 @@
|
||||
<key>IDENTIFIER</key>
|
||||
<string>@APPLICATION_REV_DOMAIN_INSTALLER@</string>
|
||||
<key>NAME</key>
|
||||
<string>@APPLICATION_NAME_XML_ESCAPED@</string>
|
||||
<string>@APPLICATION_NAME@</string>
|
||||
<key>OVERWRITE_PERMISSIONS</key>
|
||||
<false/>
|
||||
<key>VERSION</key>
|
||||
@@ -1245,7 +1245,7 @@
|
||||
<key>LANGUAGE</key>
|
||||
<string>English</string>
|
||||
<key>VALUE</key>
|
||||
<string>@APPLICATION_NAME_XML_ESCAPED@ Client</string>
|
||||
<string>@APPLICATION_NAME@ Client</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
@@ -1445,7 +1445,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>NAME</key>
|
||||
<string>@APPLICATION_NAME_XML_ESCAPED@ Installer</string>
|
||||
<string>@APPLICATION_NAME@ Installer</string>
|
||||
<key>REFERENCE_FOLDER_PATH</key>
|
||||
<string>@CMAKE_INSTALL_DIR@</string>
|
||||
</dict>
|
||||
|
||||
@@ -12,10 +12,8 @@ EOF
|
||||
if [ -x "$(command -v pluginkit)" ]; then
|
||||
# add it to DB. This happens automatically too but we try to push it a bit harder for issue #3463
|
||||
pluginkit -a "/Applications/@APPLICATION_EXECUTABLE@.app/Contents/PlugIns/FinderSyncExt.appex/"
|
||||
# Since El Capitan we need to sleep #4650
|
||||
sleep 10s
|
||||
# enable it
|
||||
pluginkit -e use -i @APPLICATION_REV_DOMAIN@.FinderSyncExt
|
||||
fi
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
@@ -5,11 +5,11 @@ MAINTAINER Daniel Molkentin <danimo@owncloud.com>
|
||||
ENV TERM ansi
|
||||
ENV HOME /root
|
||||
|
||||
ENV REFRESHED_AT 20160421
|
||||
ENV REFRESHED_AT 20160202
|
||||
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys refresh
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys ar http://download.opensuse.org/repositories/windows:/mingw/openSUSE_42.1/windows:mingw.repo
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys ar http://download.opensuse.org/repositories/isv:ownCloud:toolchains:mingw:win32:2.2/openSUSE_Leap_42.1/isv:ownCloud:toolchains:mingw:win32:2.2.repo
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys ar http://download.opensuse.org/repositories/isv:ownCloud:toolchains:mingw:win32:2.1/openSUSE_Leap_42.1/isv:ownCloud:toolchains:mingw:win32:2.1.repo
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys install cmake make mingw32-cross-binutils mingw32-cross-cpp mingw32-cross-gcc \
|
||||
mingw32-cross-gcc-c++ mingw32-cross-pkg-config mingw32-filesystem \
|
||||
mingw32-headers mingw32-runtime site-config mingw32-libwebp \
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# Auto-generated - do not modify
|
||||
StrCpy $MUI_FINISHPAGE_SHOWREADME_TEXT_STRING "Toon opmerkingen bij deze uitgave"
|
||||
StrCpy $MUI_FINISHPAGE_SHOWREADME_TEXT_STRING "Toon releaseopmerkingen"
|
||||
StrCpy $ConfirmEndProcess_MESSAGEBOX_TEXT "Gevonden ${APPLICATION_EXECUTABLE} proces(sen) moet worden gestopt.$\nWilt u dat het installatieprogramma dat voor u doet?"
|
||||
StrCpy $ConfirmEndProcess_KILLING_PROCESSES_TEXT "Stoppen ${APPLICATION_EXECUTABLE} processen."
|
||||
StrCpy $ConfirmEndProcess_KILL_NOT_FOUND_TEXT "Het te stoppen proces is niet gevonden!"
|
||||
StrCpy $PageReinstall_NEW_Field_1 "Er is een oudere versie van ${APPLICATION_NAME} geïnstalleerd op uw systeem. geadviseerd wordt om de huidige versie te de-installeren voordat de nieuwe versie wordt geïnstalleerd. Selecteer de uit te voeren actie en klik op Verder om door te gaan."
|
||||
StrCpy $PageReinstall_NEW_Field_2 "Verwijder oude versie"
|
||||
StrCpy $PageReinstall_NEW_Field_3 "Behoud oude versie"
|
||||
StrCpy $PageReinstall_NEW_Field_2 "De-installeren voor installeren"
|
||||
StrCpy $PageReinstall_NEW_Field_3 "Niet de-installeren"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_TITLE "Al geïnstalleerd"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_SUBTITLE "Kies hoe u ${APPLICATION_NAME} wilt installeren."
|
||||
StrCpy $PageReinstall_OLD_Field_1 "Er is al een recentere versie van ${APPLICATION_NAME} geïnstalleerd! Installeren van een oudere versie wordt niet aangeraden. Als u echt de oudere versie wilt installeren, adviseren we de huidige versie eerst te verwijderen. Kies de actie die u wilt uitvoeren en druk op Verder om door te gaan."
|
||||
|
||||
@@ -7,7 +7,7 @@ StrCpy $PageReinstall_NEW_Field_1 "Az ${APPLICATION_NAME} alkalmazás egy régeb
|
||||
StrCpy $PageReinstall_NEW_Field_2 "Eltávolítás telepítés előtt"
|
||||
StrCpy $PageReinstall_NEW_Field_3 "Ne távolítsa el"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_TITLE "Már telepítve"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_SUBTITLE "Válassza ki, hogy szeretné telepíteni a következő alkalmazást: ${APPLICATION_NAME}."
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_SUBTITLE "Válaszd ki, hogy szeretnéd telepíteni a következő alkalmazást ${APPLICATION_NAME}."
|
||||
StrCpy $PageReinstall_OLD_Field_1 "Az ${APPLICATION_NAME} alkalmazás egy újabb verziója már megtalálható a rendszeren. Nem ajánlott egy régebbi verzió telepítése. Ha valóban szeretné a régebbi verziót telepíteni, akkor ajánlott a jelenleg telepített verzió eltávolítása. Válassza ki milyen műveletet szeretne végrehajtani, és nyomja meg a $\"Következő$\" gombot a folytatáshoz."
|
||||
StrCpy $PageReinstall_SAME_Field_1 "Az ${APPLICATION_NAME} alkalmazás ${VERSION} verziója már telepítve van.$↩$\nKérjük válaszd ki milyen műveletet szeretnél végrehajtani, és nyomd meg a „Következő” gombot."
|
||||
StrCpy $PageReinstall_SAME_Field_2 "Komponens hozzáadása/újratelepítése"
|
||||
@@ -31,13 +31,13 @@ StrCpy $UNINSTALLER_FILE_Detail "Elltávolító írása"
|
||||
StrCpy $UNINSTALLER_REGISTRY_Detail "Telepítési registry kulcsok írása"
|
||||
StrCpy $UNINSTALLER_FINISHED_Detail "Befejezve!"
|
||||
StrCpy $UNINSTALL_MESSAGEBOX "Nem sikerült az ${APPLICATION_NAME} alkalmazás telepítése a '$INSTDIR' könyvtárba.$\n$\nSzeretné mindenképpen folytatni (nem ajánlott)?"
|
||||
StrCpy $UNINSTALL_ABORT "Az eltávolítást a felhasználó megszakította"
|
||||
StrCpy $UNINSTALL_ABORT "Az eltávolítást egy felhasználó megszakította"
|
||||
StrCpy $INIT_NO_QUICK_LAUNCH "Gyorsindító hivatkozás (N/A)"
|
||||
StrCpy $INIT_NO_DESKTOP "Asztali hivatkozás (felülírja a meglévőt)"
|
||||
StrCpy $UAC_ERROR_ELEVATE "Nem sikerült felemelni, hiba:"
|
||||
StrCpy $UAC_INSTALLER_REQUIRE_ADMIN "A telepítő futtatásához adminisztrátori hozzáférés szükséges, próbálja újra."
|
||||
StrCpy $UAC_INSTALLER_REQUIRE_ADMIN "A telepítő futtatásához adminisztrátori hozzáférés szükséges, próbáld újra."
|
||||
StrCpy $INIT_INSTALLER_RUNNING "A telepítő már fut."
|
||||
StrCpy $UAC_UNINSTALLER_REQUIRE_ADMIN "Az eltávolító futtatásához adminisztrátori hozzáférés szükséges, próbálja újra."
|
||||
StrCpy $UAC_UNINSTALLER_REQUIRE_ADMIN "Az eltávolító futtatásához adminisztrátori hozzáférés szükséges, próbáld újra."
|
||||
StrCpy $UAC_ERROR_LOGON_SERVICE "A bejelentkező szolgáltatás nem fut, megszakítás!"
|
||||
StrCpy $INIT_UNINSTALLER_RUNNING "Az eltávolító már fut."
|
||||
StrCpy $SectionGroup_Shortcuts "Parancsikonok"
|
||||
|
||||
@@ -9,7 +9,6 @@ StrCpy $PageReinstall_NEW_Field_3 "Nie usuwaj "
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_TITLE "Ju¿ zainstalowane"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_SUBTITLE "Wybierz jak chcesz zainstalowaæ ${APPLICATION_NAME}."
|
||||
StrCpy $PageReinstall_OLD_Field_1 "Zainstalowana jest nowsza wersja ${APPLICATION_NAME}! Niezalecane jest instalowanie starszej wersji. Jeœli naprawdê chcesz zainstalowaæ starsz¹ wersjê lepiej najpierw odinstalowaæ obecn¹ aplikacjê. Wybierz operacjê któr¹ chcesz wykonaæ i naciœnij przycisk Dalej."
|
||||
StrCpy $PageReinstall_SAME_Field_1 "${APPLICATION_NAME} ${VERSION} jest ju¿ zainstalowany.$\nWybierz operacjê któr¹ chcesz wykonaæ i naciœnij przycisk Dalej."
|
||||
StrCpy $PageReinstall_SAME_Field_2 "Doda/Przeinstaluj komponenty"
|
||||
StrCpy $PageReinstall_SAME_Field_3 "Odinstaluj ${APPLICATION_NAME}"
|
||||
StrCpy $UNINSTALLER_APPDATA_TITLE "Odinstaluj ${APPLICATION_NAME}"
|
||||
@@ -38,6 +37,7 @@ StrCpy $UAC_ERROR_ELEVATE "Niemo
|
||||
StrCpy $UAC_INSTALLER_REQUIRE_ADMIN "Ten instalator potrzebuje uprawnieñ administratora, spróbuj ponownie"
|
||||
StrCpy $INIT_INSTALLER_RUNNING "Instalator ju¿ jest uruchomiony."
|
||||
StrCpy $UAC_UNINSTALLER_REQUIRE_ADMIN "Ten dezinstalator potrzebuje uprawnieñ administratora, spróbuj ponownie"
|
||||
StrCpy $UAC_ERROR_LOGON_SERVICE "Proces logowania nie jest uruchomiony, przerywam !"
|
||||
StrCpy $INIT_UNINSTALLER_RUNNING "Dezinstalator ju¿ jest uruchomiony."
|
||||
StrCpy $SectionGroup_Shortcuts "Skróty"
|
||||
StrCpy $PageReinstall_SAME_Field_1 "${APPLICATION_NAME} ${VERSION} is already installed.$\r$\nSelect the operation you want to perform and click Next to continue."
|
||||
StrCpy $UAC_ERROR_LOGON_SERVICE "Logon service is not running, aborting!"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Auto-generated - do not modify
|
||||
StrCpy $MUI_FINISHPAGE_SHOWREADME_TEXT_STRING "Mostrar notas de lançamento"
|
||||
StrCpy $ConfirmEndProcess_MESSAGEBOX_TEXT "Existem ${APPLICATION_EXECUTABLE} processo(s) em execução que precisa(m) de ser interrompido(s).$\nDeseja que o instalador o(s) termine automaticamente?"
|
||||
StrCpy $ConfirmEndProcess_MESSAGEBOX_TEXT "Processos(s) ${APPLICATION_EXECUTABLE} em execução. Estes processos precisam de ser interrompidos.$\nDeseja que o instalador os termine automaticamente?"
|
||||
StrCpy $ConfirmEndProcess_KILLING_PROCESSES_TEXT "A terminar os processos ${APPLICATION_EXECUTABLE}."
|
||||
StrCpy $ConfirmEndProcess_KILL_NOT_FOUND_TEXT "Não foi encontrado o processo a terminar!"
|
||||
StrCpy $PageReinstall_NEW_Field_1 "Uma versão antiga de ${APPLICATION_NAME} está instalada no sistema. É recomendado que você desinstale a versão atual antes de instalar a mais recente. Selecione a operação que deseja executar e clique em $\"Avançar$\" para continuar."
|
||||
|
||||
@@ -14,8 +14,6 @@ StrCpy $PageReinstall_SAME_Field_3 "Avinstallera ${APPLICATION_NAME}"
|
||||
StrCpy $UNINSTALLER_APPDATA_TITLE "Avinstallera ${APPLICATION_NAME}"
|
||||
StrCpy $PageReinstall_SAME_MUI_HEADER_TEXT_SUBTITLE "Välj underhålls alternativ att utföra."
|
||||
StrCpy $SEC_APPLICATION_DETAILS "Installerar ${APPLICATION_NAME} väsentligheter."
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_SECTION "Integration för Windows Explorer"
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_DetailPrint "Installerar integration för Windows Explorer"
|
||||
StrCpy $OPTION_SECTION_SC_START_MENU_SECTION "Start-meny program genväg"
|
||||
StrCpy $OPTION_SECTION_SC_START_MENU_DetailPrint "Lägger till genväg för ${APPLICATION_NAME} till Start-menyn."
|
||||
StrCpy $OPTION_SECTION_SC_DESKTOP_SECTION "Skrivbordsgenväg"
|
||||
@@ -37,7 +35,9 @@ StrCpy $UAC_ERROR_ELEVATE "Kunde inte få förhöjda rättigheter, fel:"
|
||||
StrCpy $UAC_INSTALLER_REQUIRE_ADMIN "Detta installationsprogram kräver adminstratörs rättigheter, försök igen"
|
||||
StrCpy $INIT_INSTALLER_RUNNING "Installationsprogrammet körs redan."
|
||||
StrCpy $UAC_UNINSTALLER_REQUIRE_ADMIN "Detta avinstallationsprogram kräver administratörsrättigheter, försök igen"
|
||||
StrCpy $UAC_ERROR_LOGON_SERVICE "Login-service körs inte, avbryter!"
|
||||
StrCpy $INIT_UNINSTALLER_RUNNING "Avinstallationsprogrammet körs redan."
|
||||
StrCpy $SectionGroup_Shortcuts "Genvägar"
|
||||
StrCpy $PageReinstall_SAME_Field_1 "${APPLICATION_NAME} ${VERSION} is already installed.$\r$\nSelect the operation you want to perform and click Next to continue."
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_SECTION "Integration for Windows Explorer"
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_DetailPrint "Installing Integration for Windows Explorer"
|
||||
StrCpy $UAC_ERROR_LOGON_SERVICE "Logon service is not running, aborting!"
|
||||
|
||||
@@ -3,13 +3,13 @@ StrCpy $MUI_FINISHPAGE_SHOWREADME_TEXT_STRING "แสดงบันทึกป
|
||||
StrCpy $ConfirmEndProcess_MESSAGEBOX_TEXT "พบว่ากระบวนการ ${APPLICATION_EXECUTABLE} จะต้องหยุดทำงาน$\nคุณต้องการติดตั้งเพื่อหยุดการทำงานเหล่านี้ของคุณ?"
|
||||
StrCpy $ConfirmEndProcess_KILLING_PROCESSES_TEXT "ฆ่ากระบวนการทำงาน ${APPLICATION_EXECUTABLE}"
|
||||
StrCpy $ConfirmEndProcess_KILL_NOT_FOUND_TEXT "ไม่พบการฆ่ากระบวนการ!"
|
||||
StrCpy $PageReinstall_NEW_Field_1 "รุ่นเก่าของ ${APPLICATION_NAME} ได้ถูกติดตั้งในระบบของคุณ ขอแนะนำให้คุณถอนการติดตั้งรุ่นปัจจุบันออกก่อน แล้วเลือกการดำเนินการที่คุณต้องการหลังจากนั้นคลิกถัดไปเพื่อดำเนินการต่อ"
|
||||
StrCpy $PageReinstall_NEW_Field_1 "รุ่นเก่าของ ${APPLICATION_NAME} มีการติดตั้งในระบบของคุณ ขอแนะนำให้คุณถอนการติดตั้งรุ่นปัจจุบันออกก่อน เลือกการดำเนินการที่คุณต้องการที่จะดำเนินการและคลิกถัดไปเพื่อดำเนินการต่อ"
|
||||
StrCpy $PageReinstall_NEW_Field_2 "ถอนการติดตั้งก่อนการติดตั้ง"
|
||||
StrCpy $PageReinstall_NEW_Field_3 "อย่าถอนการติดตั้ง"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_TITLE "ติดตั้งแล้ว"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_SUBTITLE "เลือกวิธีที่คุณต้องการติดตั้ง ${APPLICATION_NAME}"
|
||||
StrCpy $PageReinstall_OLD_Field_1 "รุ่นใหม่ของ ${APPLICATION_NAME} ถูกติดตั้งแล้ว! เราไม่แนะนำให้คุณติดตั้งรุ่นที่เก่ากว่า ถ้าคุณอยากจะติดตั้งรุ่นเก่าก็สามารถถอนการติดตั้งได้"
|
||||
StrCpy $PageReinstall_SAME_Field_1 "${APPLICATION_NAME} รุ่น ${VERSION} ถูกติดตั้งไปแล้ว$ $\nเลือกดำเนินงานที่คุณต้องการและคลิกถัดไปเพื่อดำเนินการต่อ"
|
||||
StrCpy $PageReinstall_OLD_Field_1 "รุ่นใหม่ของ ${APPLICATION_NAME} ถูกติดตั้งแล้ว! เราไม่แนะนำให้คุณติดตั้งรุ่นเก่า ถ้าคุณอยากจะติดตั้งรุ่นเก่าก็สามารถสอนการติดตั้งได้"
|
||||
StrCpy $PageReinstall_SAME_Field_1 "${APPLICATION_NAME} ${VERSION} ถูกติดตั้งไปแล้ว$ $\nเลือกดำเนินงานที่คุณต้องการและคลิกถัดไปเพื่อดำเนินการต่อ"
|
||||
StrCpy $PageReinstall_SAME_Field_2 "ส่วนประกอบ เพิ่ม/ติดตั้งใหม่ "
|
||||
StrCpy $PageReinstall_SAME_Field_3 "ถอนการติดตั้ง ${APPLICATION_NAME}"
|
||||
StrCpy $UNINSTALLER_APPDATA_TITLE "ถอนการติดตั้ง ${APPLICATION_NAME}"
|
||||
|
||||
@@ -9,7 +9,6 @@ StrCpy $PageReinstall_NEW_Field_3 "Не видаляти"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_TITLE "Установлено"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_SUBTITLE "Оберіть, як ви хочете установити ${APPLICATION_NAME}."
|
||||
StrCpy $PageReinstall_OLD_Field_1 "Знайдено новішу версію ${APPLICATION_NAME}! Ми не рекомендуємо встановлювати стару версію. Якщо ви все ж бажаєте встановити цю версію, спочатку видаліть поточну версію. Оберіть подальшу дію та натисніть $\"Далі$\"."
|
||||
StrCpy $PageReinstall_SAME_Field_1 "${APPLICATION_NAME} ${VERSION} вже встановлено.$\n$\nОберіть подальшу дію та натисніть $\"Далі$\" для продовження."
|
||||
StrCpy $PageReinstall_SAME_Field_2 "Додати/Перевстановити компоненти"
|
||||
StrCpy $PageReinstall_SAME_Field_3 "Видалити ${APPLICATION_NAME}"
|
||||
StrCpy $UNINSTALLER_APPDATA_TITLE "Видалити ${APPLICATION_NAME}"
|
||||
@@ -38,6 +37,7 @@ StrCpy $UAC_ERROR_ELEVATE "Неможливо підняти, помилка:"
|
||||
StrCpy $UAC_INSTALLER_REQUIRE_ADMIN "Для установки потрібні права адміністратора, спробуйте ще раз"
|
||||
StrCpy $INIT_INSTALLER_RUNNING "Установка вже запущена."
|
||||
StrCpy $UAC_UNINSTALLER_REQUIRE_ADMIN "Для видалення потрібні права адміністратора, спробуйте ще раз"
|
||||
StrCpy $UAC_ERROR_LOGON_SERVICE "Сервіс авторизації не запущений, припиняю!"
|
||||
StrCpy $INIT_UNINSTALLER_RUNNING "Програма видалення вже запущено."
|
||||
StrCpy $SectionGroup_Shortcuts "Ярлики"
|
||||
StrCpy $PageReinstall_SAME_Field_1 "${APPLICATION_NAME} ${VERSION} is already installed.$\r$\nSelect the operation you want to perform and click Next to continue."
|
||||
StrCpy $UAC_ERROR_LOGON_SERVICE "Logon service is not running, aborting!"
|
||||
|
||||
+1
-1
Submodule binary updated: ac42257499...71633edc9a
@@ -22,6 +22,5 @@
|
||||
<file>resources/account.png</file>
|
||||
<file>resources/more.png</file>
|
||||
<file>resources/delete.png</file>
|
||||
<file>resources/bell.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string>@APPLICATION_NAME_XML_ESCAPED@ @MIRALL_VERSION_STRING@</string>
|
||||
<string>@APPLICATION_NAME@ @MIRALL_VERSION_STRING@</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
|
||||
@@ -757,12 +757,6 @@ Function .onInit
|
||||
|
||||
;Shutdown ${APPLICATION_NAME} in case Add/Remove re-installer option used.
|
||||
Call EnsureOwncloudShutdown
|
||||
|
||||
ReadRegStr $R0 ${MEMENTO_REGISTRY_ROOT} "${MEMENTO_REGISTRY_KEY}" "InstallLocation"
|
||||
${If} ${Silent}
|
||||
${AndIf} $R0 != ""
|
||||
ExecWait '"$R0\Uninstall.exe" /S _?=$R0'
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function .onInstSuccess
|
||||
@@ -772,11 +766,6 @@ Function .onInstSuccess
|
||||
WriteRegDWORD HKLM "Software\${APPLICATION_VENDOR}\${APPLICATION_NAME}" "skipUpdateCheck" "1"
|
||||
${EndIf}
|
||||
|
||||
; TODO: Only needed to when updating from 2.1.{0,1}. Remove in due time.
|
||||
Delete /REBOOTOK $INSTDIR\bearer\qgenericbearer.dll
|
||||
Delete /REBOOTOK $INSTDIR\bearer\qnativewifibearer.dll
|
||||
RMDir /REBOOTOK $INSTDIR\bearer
|
||||
|
||||
${If} ${Silent}
|
||||
${AndIf} $InstallRunIfSilent == "yes"
|
||||
Call LaunchApplication
|
||||
|
||||
@@ -18,9 +18,6 @@ if( Qt5Core_FOUND )
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5Xml REQUIRED)
|
||||
find_package(Qt5Concurrent REQUIRED)
|
||||
if(UNIT_TESTING)
|
||||
find_package(Qt5Test REQUIRED)
|
||||
endif()
|
||||
if(NOT TOKEN_AUTH_ONLY)
|
||||
find_package(Qt5WebKitWidgets REQUIRED)
|
||||
find_package(Qt5WebKit REQUIRED)
|
||||
|
||||
@@ -128,4 +128,10 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
# INSTALL(
|
||||
# FILES
|
||||
# ${csync_HDRS}
|
||||
# DESTINATION
|
||||
# ${INCLUDE_INSTALL_DIR}/${APPLICATION_NAME}
|
||||
# )
|
||||
|
||||
|
||||
+70
-10
@@ -25,7 +25,6 @@
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -90,11 +89,14 @@ static int _data_cmp(const void *key, const void *data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void csync_create(CSYNC **csync, const char *local, const char *remote) {
|
||||
int csync_create(CSYNC **csync, const char *local, const char *remote) {
|
||||
CSYNC *ctx;
|
||||
size_t len = 0;
|
||||
|
||||
ctx = c_malloc(sizeof(CSYNC));
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->status_code = CSYNC_STATUS_OK;
|
||||
|
||||
@@ -119,21 +121,46 @@ void csync_create(CSYNC **csync, const char *local, const char *remote) {
|
||||
ctx->ignore_hidden_files = true;
|
||||
|
||||
*csync = ctx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void csync_init(CSYNC *ctx) {
|
||||
assert(ctx);
|
||||
/* Do not initialize twice */
|
||||
int csync_init(CSYNC *ctx) {
|
||||
int rc;
|
||||
|
||||
if (ctx == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(!(ctx->status & CSYNC_STATUS_INIT));
|
||||
ctx->status_code = CSYNC_STATUS_OK;
|
||||
|
||||
/* Do not initialize twice */
|
||||
if (ctx->status & CSYNC_STATUS_INIT) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* check for uri */
|
||||
if (csync_fnmatch("owncloud://*", ctx->remote.uri, 0) == 0 && csync_fnmatch("ownclouds://*", ctx->remote.uri, 0) == 0) {
|
||||
ctx->status_code = CSYNC_STATUS_NO_MODULE;
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ctx->local.type = LOCAL_REPLICA;
|
||||
|
||||
ctx->remote.type = REMOTE_REPLICA;
|
||||
|
||||
c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp);
|
||||
c_rbtree_create(&ctx->remote.tree, _key_cmp, _data_cmp);
|
||||
if (c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp) < 0) {
|
||||
ctx->status_code = CSYNC_STATUS_TREE_ERROR;
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (c_rbtree_create(&ctx->remote.tree, _key_cmp, _data_cmp) < 0) {
|
||||
ctx->status_code = CSYNC_STATUS_TREE_ERROR;
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ctx->remote.root_perms = 0;
|
||||
|
||||
@@ -141,6 +168,11 @@ void csync_init(CSYNC *ctx) {
|
||||
|
||||
/* initialize random generator */
|
||||
srand(time(NULL));
|
||||
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int csync_update(CSYNC *ctx) {
|
||||
@@ -548,17 +580,29 @@ int csync_commit(CSYNC *ctx) {
|
||||
ctx->remote.read_from_db = 0;
|
||||
ctx->read_remote_from_db = true;
|
||||
ctx->db_is_empty = false;
|
||||
ctx->ignore_hidden_files = true; // do NOT sync hidden files by default.
|
||||
|
||||
|
||||
/* Create new trees */
|
||||
c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp);
|
||||
c_rbtree_create(&ctx->remote.tree, _key_cmp, _data_cmp);
|
||||
rc = c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp);
|
||||
if (rc < 0) {
|
||||
ctx->status_code = CSYNC_STATUS_TREE_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rc = c_rbtree_create(&ctx->remote.tree, _key_cmp, _data_cmp);
|
||||
if (rc < 0) {
|
||||
ctx->status_code = CSYNC_STATUS_TREE_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
ctx->status = CSYNC_STATUS_INIT;
|
||||
SAFE_FREE(ctx->error_string);
|
||||
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -578,6 +622,9 @@ int csync_destroy(CSYNC *ctx) {
|
||||
}
|
||||
ctx->statedb.db = NULL;
|
||||
|
||||
/* destroy exclude list */
|
||||
csync_exclude_destroy(ctx);
|
||||
|
||||
_csync_clean_ctx(ctx);
|
||||
|
||||
SAFE_FREE(ctx->local.uri);
|
||||
@@ -593,6 +640,19 @@ int csync_destroy(CSYNC *ctx) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
int csync_add_exclude_list(CSYNC *ctx, const char *path) {
|
||||
if (ctx == NULL || path == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return csync_exclude_load(path, &ctx->excludes);
|
||||
}
|
||||
|
||||
void csync_clear_exclude_list(CSYNC *ctx)
|
||||
{
|
||||
csync_exclude_clear(ctx);
|
||||
}
|
||||
|
||||
void *csync_get_userdata(CSYNC *ctx) {
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
|
||||
+24
-2
@@ -316,8 +316,10 @@ typedef const char* (*csync_checksum_hook) (
|
||||
* @brief Allocate a csync context.
|
||||
*
|
||||
* @param csync The context variable to allocate.
|
||||
*
|
||||
* @return 0 on success, less than 0 if an error occurred.
|
||||
*/
|
||||
void csync_create(CSYNC **csync, const char *local, const char *remote);
|
||||
int csync_create(CSYNC **csync, const char *local, const char *remote);
|
||||
|
||||
/**
|
||||
* @brief Initialize the file synchronizer.
|
||||
@@ -325,8 +327,10 @@ void csync_create(CSYNC **csync, const char *local, const char *remote);
|
||||
* This function loads the configuration
|
||||
*
|
||||
* @param ctx The context to initialize.
|
||||
*
|
||||
* @return 0 on success, less than 0 if an error occurred.
|
||||
*/
|
||||
void csync_init(CSYNC *ctx);
|
||||
int csync_init(CSYNC *ctx);
|
||||
|
||||
/**
|
||||
* @brief Update detection
|
||||
@@ -366,6 +370,24 @@ int csync_commit(CSYNC *ctx);
|
||||
*/
|
||||
int csync_destroy(CSYNC *ctx);
|
||||
|
||||
/**
|
||||
* @brief Add an additional exclude list.
|
||||
*
|
||||
* @param ctx The context to add the exclude list.
|
||||
*
|
||||
* @param path The path pointing to the file.
|
||||
*
|
||||
* @return 0 on success, less than 0 if an error occurred.
|
||||
*/
|
||||
int csync_add_exclude_list(CSYNC *ctx, const char *path);
|
||||
|
||||
/**
|
||||
* @brief Removes all items imported from exclude lists.
|
||||
*
|
||||
* @param ctx The context to add the exclude list.
|
||||
*/
|
||||
void csync_clear_exclude_list(CSYNC *ctx);
|
||||
|
||||
/**
|
||||
* @brief Get the userdata saved in the context.
|
||||
*
|
||||
|
||||
+19
-43
@@ -47,45 +47,6 @@ int _csync_exclude_add(c_strlist_t **inList, const char *string) {
|
||||
return c_strlist_add_grow(inList, string);
|
||||
}
|
||||
|
||||
/** Expands C-like escape sequences.
|
||||
*
|
||||
* The returned string is heap-allocated and owned by the caller.
|
||||
*/
|
||||
static const char *csync_exclude_expand_escapes(const char * input)
|
||||
{
|
||||
size_t i_len = strlen(input) + 1;
|
||||
char *out = c_malloc(i_len); // out can only be shorter
|
||||
|
||||
size_t i = 0;
|
||||
size_t o = 0;
|
||||
for (; i < i_len; ++i) {
|
||||
if (input[i] == '\\') {
|
||||
// at worst input[i+1] is \0
|
||||
switch (input[i+1]) {
|
||||
case '\'': out[o++] = '\''; break;
|
||||
case '"': out[o++] = '"'; break;
|
||||
case '?': out[o++] = '?'; break;
|
||||
case '\\': out[o++] = '\\'; break;
|
||||
case 'a': out[o++] = '\a'; break;
|
||||
case 'b': out[o++] = '\b'; break;
|
||||
case 'f': out[o++] = '\f'; break;
|
||||
case 'n': out[o++] = '\n'; break;
|
||||
case 'r': out[o++] = '\r'; break;
|
||||
case 't': out[o++] = '\t'; break;
|
||||
case 'v': out[o++] = '\v'; break;
|
||||
default:
|
||||
out[o++] = input[i];
|
||||
out[o++] = input[i+1];
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
} else {
|
||||
out[o++] = input[i];
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
int csync_exclude_load(const char *fname, c_strlist_t **list) {
|
||||
int fd = -1;
|
||||
int i = 0;
|
||||
@@ -138,10 +99,8 @@ int csync_exclude_load(const char *fname, c_strlist_t **list) {
|
||||
if (entry != buf + i) {
|
||||
buf[i] = '\0';
|
||||
if (*entry != '#') {
|
||||
const char *unescaped = csync_exclude_expand_escapes(entry);
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Adding entry: %s", unescaped);
|
||||
rc = _csync_exclude_add(list, unescaped);
|
||||
SAFE_FREE(unescaped);
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Adding entry: %s", entry);
|
||||
rc = _csync_exclude_add(list, entry);
|
||||
if (rc < 0) {
|
||||
goto out;
|
||||
}
|
||||
@@ -158,6 +117,23 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
void csync_exclude_clear(CSYNC *ctx) {
|
||||
c_strlist_clear(ctx->excludes);
|
||||
}
|
||||
|
||||
void csync_exclude_destroy(CSYNC *ctx) {
|
||||
c_strlist_destroy(ctx->excludes);
|
||||
}
|
||||
|
||||
CSYNC_EXCLUDE_TYPE csync_excluded(CSYNC *ctx, const char *path, int filetype) {
|
||||
|
||||
CSYNC_EXCLUDE_TYPE match = CSYNC_NOT_EXCLUDED;
|
||||
|
||||
match = csync_excluded_no_ctx( ctx->excludes, path, filetype );
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
// See http://support.microsoft.com/kb/74496 and
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
||||
// Additionally, we ignore '$Recycle.Bin', see https://github.com/owncloud/client/issues/2955
|
||||
|
||||
@@ -47,6 +47,37 @@ int _csync_exclude_add(c_strlist_t **inList, const char *string);
|
||||
*/
|
||||
int csync_exclude_load(const char *fname, c_strlist_t **list);
|
||||
|
||||
/**
|
||||
* @brief Clear the exclude list in memory.
|
||||
*
|
||||
* @param ctx The synchronizer context.
|
||||
*/
|
||||
void csync_exclude_clear(CSYNC *ctx);
|
||||
|
||||
/**
|
||||
* @brief Destroy the exclude list in memory.
|
||||
*
|
||||
* @param ctx The synchronizer context.
|
||||
*/
|
||||
void csync_exclude_destroy(CSYNC *ctx);
|
||||
|
||||
/**
|
||||
* @brief Check if the given path should be excluded.
|
||||
*
|
||||
* This excludes also paths which can't be used without unix extensions.
|
||||
*
|
||||
* The exclude list is checked against the full path, each component of
|
||||
* the path and all leading directory strings, e.g.
|
||||
* '/foo/bar/file' checks ('/foo/bar/file', 'foo', 'bar', 'file',
|
||||
* '/foo/bar', '/foo').
|
||||
*
|
||||
* @param ctx The synchronizer context.
|
||||
* @param path The patch to check.
|
||||
*
|
||||
* @return 2 if excluded and needs cleanup, 1 if excluded, 0 if not.
|
||||
*/
|
||||
CSYNC_EXCLUDE_TYPE csync_excluded(CSYNC *ctx, const char *path, int filetype);
|
||||
|
||||
/**
|
||||
* @brief Check if the given path should be excluded in a traversal situation.
|
||||
*
|
||||
|
||||
@@ -245,9 +245,33 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
st->etag = NULL;
|
||||
st->child_modified = 0;
|
||||
st->has_ignored_files = 0;
|
||||
|
||||
/* FIXME: Under which conditions are the following two ifs true and the code
|
||||
* is executed? */
|
||||
if (type == CSYNC_FTW_TYPE_FILE ) {
|
||||
if (fs->mtime == 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s - mtime is zero!", path);
|
||||
|
||||
tmp = csync_statedb_get_stat_by_hash(ctx, h);
|
||||
if(_last_db_return_error(ctx)) {
|
||||
SAFE_FREE(st);
|
||||
SAFE_FREE(tmp);
|
||||
ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tmp == NULL) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s - not found in db, IGNORE!", path);
|
||||
st->instruction = CSYNC_INSTRUCTION_IGNORE;
|
||||
} else {
|
||||
SAFE_FREE(st);
|
||||
st = tmp;
|
||||
st->instruction = CSYNC_INSTRUCTION_NONE;
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s - tmp non zero, mtime %lu", path, st->modtime );
|
||||
tmp = NULL;
|
||||
}
|
||||
goto fastout; /* Skip copying of the etag. That's an important difference to upstream
|
||||
* without etags. */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +333,6 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
checksumIdentical = strncmp(st->checksum, tmp->checksum, 1000) == 0;
|
||||
}
|
||||
if (checksumIdentical) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "NOTE: Checksums are identical, file did not actually change: %s", path);
|
||||
st->instruction = CSYNC_INSTRUCTION_NONE;
|
||||
st->should_update_metadata = true;
|
||||
goto out;
|
||||
@@ -512,6 +535,7 @@ out:
|
||||
strncpy(st->remotePerm, fs->remotePerm, REMOTE_PERM_BUF_SIZE);
|
||||
}
|
||||
|
||||
fastout: /* target if the file information is read from database into st */
|
||||
st->phash = h;
|
||||
st->pathlen = len;
|
||||
memcpy(st->path, (len ? path : ""), len + 1);
|
||||
@@ -556,11 +580,7 @@ int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs,
|
||||
switch (flag) {
|
||||
case CSYNC_FTW_FLAG_FILE:
|
||||
if (ctx->current == REMOTE_REPLICA) {
|
||||
if (fs->fields & CSYNC_VIO_FILE_STAT_FIELDS_SIZE) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s [file_id=%s size=%" PRIu64 "]", file, fs->file_id, fs->size);
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s [file_id=%s size=UNKNOWN]", file, fs->file_id);
|
||||
}
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s [file_id=%s size=%" PRIu64 "]", file, fs->file_id, fs->size);
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s [inode=%" PRIu64 " size=%" PRIu64 "]", file, fs->inode, fs->size);
|
||||
}
|
||||
|
||||
@@ -38,13 +38,14 @@
|
||||
#define NIL &_sentinel /* all leafs are sentinels */
|
||||
static c_rbnode_t _sentinel = {NULL, NIL, NIL, NULL, NULL, BLACK};
|
||||
|
||||
void c_rbtree_create(c_rbtree_t **rbtree, c_rbtree_compare_func *key_compare, c_rbtree_compare_func *data_compare) {
|
||||
assert(rbtree);
|
||||
assert(key_compare);
|
||||
assert(data_compare);
|
||||
|
||||
int c_rbtree_create(c_rbtree_t **rbtree, c_rbtree_compare_func *key_compare, c_rbtree_compare_func *data_compare) {
|
||||
c_rbtree_t *tree = NULL;
|
||||
|
||||
if (rbtree == NULL || key_compare == NULL || data_compare == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tree = c_malloc(sizeof(*tree));
|
||||
tree->root = NIL;
|
||||
tree->key_compare = key_compare;
|
||||
@@ -52,6 +53,8 @@ void c_rbtree_create(c_rbtree_t **rbtree, c_rbtree_compare_func *key_compare, c_
|
||||
tree->size = 0;
|
||||
|
||||
*rbtree = tree;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static c_rbnode_t *_rbtree_subtree_dup(const c_rbnode_t *node, c_rbtree_t *new_tree, c_rbnode_t *new_parent) {
|
||||
|
||||
@@ -135,8 +135,10 @@ struct c_rbnode_s {
|
||||
*
|
||||
* @param data_compare Callback function to compare a key as data with thee
|
||||
* data inside a red-black tree node.
|
||||
*
|
||||
* @return 0 on success, -1 if an error occurred with errno set.
|
||||
*/
|
||||
void c_rbtree_create(c_rbtree_t **rbtree, c_rbtree_compare_func *key_compare, c_rbtree_compare_func *data_compare);
|
||||
int c_rbtree_create(c_rbtree_t **rbtree, c_rbtree_compare_func *key_compare, c_rbtree_compare_func *data_compare);
|
||||
|
||||
/**
|
||||
* @brief Duplicate a red-black tree.
|
||||
|
||||
@@ -139,6 +139,7 @@ csync_vio_file_stat_t *csync_vio_local_readdir(csync_vio_handle_t *dhandle) {
|
||||
|
||||
dhandle_t *handle = NULL;
|
||||
csync_vio_file_stat_t *file_stat = NULL;
|
||||
ULARGE_INTEGER FileIndex;
|
||||
DWORD rem;
|
||||
|
||||
handle = (dhandle_t *) dhandle;
|
||||
@@ -167,14 +168,9 @@ csync_vio_file_stat_t *csync_vio_local_readdir(csync_vio_handle_t *dhandle) {
|
||||
}
|
||||
file_stat->name = c_utf8_from_locale(handle->ffd.cFileName);
|
||||
|
||||
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
|
||||
if ( (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||
&& (handle->ffd.dwReserved0 & IO_REPARSE_TAG_SYMLINK)
|
||||
// The SIS or DEDUP flag points to a MS deduplication feature of
|
||||
// certain file storage products. It is not a normal symlink
|
||||
// that should be ignored.
|
||||
&& (! (handle->ffd.dwReserved0 & IO_REPARSE_TAG_SIS))
|
||||
&& (! (handle->ffd.dwReserved0 & IO_REPARSE_TAG_DEDUP)) ) {
|
||||
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
|
||||
if (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT
|
||||
&& handle->ffd.dwReserved0 & IO_REPARSE_TAG_SYMLINK) {
|
||||
file_stat->flags = CSYNC_VIO_FILE_FLAGS_SYMLINK;
|
||||
file_stat->type = CSYNC_VIO_FILE_TYPE_SYMBOLIC_LINK;
|
||||
} else if (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE
|
||||
|
||||
@@ -33,7 +33,8 @@ static void setup(void **state) {
|
||||
rc = system("mkdir -p /tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
*state = csync;
|
||||
}
|
||||
@@ -48,9 +49,10 @@ static void setup_module(void **state) {
|
||||
rc = system("mkdir -p /tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync_create(&csync, "/tmp/check_csync1", "dummy://foo/bar");
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "dummy://foo/bar");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync_init(csync);
|
||||
rc = csync_init(csync);
|
||||
*state = csync;
|
||||
}
|
||||
|
||||
@@ -72,6 +74,16 @@ static void teardown(void **state) {
|
||||
*state = NULL;
|
||||
}
|
||||
|
||||
static void check_csync_commit_null(void **state)
|
||||
{
|
||||
int rc;
|
||||
|
||||
(void) state; /* unused */
|
||||
|
||||
rc = csync_commit(NULL);
|
||||
assert_int_equal(rc, -1);
|
||||
}
|
||||
|
||||
static void check_csync_commit(void **state)
|
||||
{
|
||||
CSYNC *csync = *state;
|
||||
@@ -98,6 +110,7 @@ static void check_csync_commit_dummy(void **state)
|
||||
int torture_run_tests(void)
|
||||
{
|
||||
const UnitTest tests[] = {
|
||||
unit_test_setup_teardown(check_csync_commit_null, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_commit, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_commit_dummy, setup_module, teardown),
|
||||
};
|
||||
|
||||
@@ -42,7 +42,8 @@ static void check_csync_create(void **state)
|
||||
|
||||
(void) state; /* unused */
|
||||
|
||||
csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
rc = csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
rc = csync_destroy(csync);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
@@ -32,7 +32,8 @@ static void setup(void **state) {
|
||||
CSYNC *csync;
|
||||
int rc;
|
||||
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
*state = csync;
|
||||
}
|
||||
@@ -41,7 +42,8 @@ static void setup_init(void **state) {
|
||||
CSYNC *csync;
|
||||
int rc;
|
||||
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
rc = csync_exclude_load(EXCLUDE_LIST_FILE, &(csync->excludes));
|
||||
assert_int_equal(rc, 0);
|
||||
@@ -100,84 +102,84 @@ static void check_csync_excluded(void **state)
|
||||
CSYNC *csync = *state;
|
||||
int rc;
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "/", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "krawel_krawel", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "krawel_krawel", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, ".kde/share/config/kwin.eventsrc", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, ".kde/share/config/kwin.eventsrc", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, ".htaccess/cache-maximegalon/cache1.txt", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, ".htaccess/cache-maximegalon/cache1.txt", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "mozilla/.htaccess", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "mozilla/.htaccess", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
/*
|
||||
* Test for patterns in subdirs. '.beagle' is defined as a pattern and has
|
||||
* to be found in top dir as well as in directories underneath.
|
||||
*/
|
||||
rc = csync_excluded_no_ctx(csync->excludes, ".apdisk", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, ".apdisk", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "foo/.apdisk", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "foo/.apdisk", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "foo/bar/.apdisk", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "foo/bar/.apdisk", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, ".java", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, ".java", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
/* Files in the ignored dir .java will also be ignored. */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, ".apdisk/totally_amazing.jar", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, ".apdisk/totally_amazing.jar", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
/* and also in subdirs */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "projects/.apdisk/totally_amazing.jar", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "projects/.apdisk/totally_amazing.jar", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
/* csync-journal is ignored in general silently. */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, ".csync_journal.db", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, ".csync_journal.db", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, ".csync_journal.db.ctmp", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, ".csync_journal.db.ctmp", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "subdir/.csync_journal.db", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "subdir/.csync_journal.db", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
|
||||
|
||||
/* pattern ]*.directory - ignore and remove */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "my.~directory", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "my.~directory", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_AND_REMOVE);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/a_folder/my.~directory", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "/a_folder/my.~directory", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_AND_REMOVE);
|
||||
|
||||
/* Not excluded because the pattern .netscape/cache requires directory. */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, ".netscape/cache", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, ".netscape/cache", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
/* Not excluded */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "unicode/中文.hé", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "unicode/中文.hé", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
/* excluded */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "unicode/пятницы.txt", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "unicode/пятницы.txt", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "unicode/中文.💩", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "unicode/中文.💩", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
/* path wildcards */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "foobar/my_manuscript.out", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "foobar/my_manuscript.out", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "latex_tmp/my_manuscript.run.xml", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "latex_tmp/my_manuscript.run.xml", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "word_tmp/my_manuscript.run.xml", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "word_tmp/my_manuscript.run.xml", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "latex/my_manuscript.tex.tmp", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "latex/my_manuscript.tex.tmp", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "latex/songbook/my_manuscript.tex.tmp", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "latex/songbook/my_manuscript.tex.tmp", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
}
|
||||
|
||||
@@ -239,45 +241,45 @@ static void check_csync_pathes(void **state)
|
||||
_csync_exclude_add( &(csync->excludes), "/exclude" );
|
||||
|
||||
/* Check toplevel dir, the pattern only works for toplevel dir. */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/exclude", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "/exclude", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/foo/exclude", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "/foo/exclude", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
/* check for a file called exclude. Must still work */
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/exclude", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "/exclude", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/foo/exclude", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "/foo/exclude", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
/* Add an exclude for directories only: excl/ */
|
||||
_csync_exclude_add( &(csync->excludes), "excl/" );
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/excl", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "/excl", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "meep/excl", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "meep/excl", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "meep/excl/file", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "meep/excl/file", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/excl", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "/excl", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
_csync_exclude_add(&csync->excludes, "/excludepath/withsubdir");
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/excludepath/withsubdir", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "/excludepath/withsubdir", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/excludepath/withsubdir", CSYNC_FTW_TYPE_FILE);
|
||||
rc = csync_excluded(csync, "/excludepath/withsubdir", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/excludepath/withsubdir2", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "/excludepath/withsubdir2", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
|
||||
rc = csync_excluded_no_ctx(csync->excludes, "/excludepath/withsubdir/foo", CSYNC_FTW_TYPE_DIR);
|
||||
rc = csync_excluded(csync, "/excludepath/withsubdir/foo", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
}
|
||||
|
||||
@@ -312,8 +314,8 @@ static void check_csync_excluded_performance(void **state)
|
||||
gettimeofday(&before, 0);
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
totalRc += csync_excluded_no_ctx(csync->excludes, "/this/is/quite/a/long/path/with/many/components", CSYNC_FTW_TYPE_DIR);
|
||||
totalRc += csync_excluded_no_ctx(csync->excludes, "/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/29", CSYNC_FTW_TYPE_FILE);
|
||||
totalRc += csync_excluded(csync, "/this/is/quite/a/long/path/with/many/components", CSYNC_FTW_TYPE_DIR);
|
||||
totalRc += csync_excluded(csync, "/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/29", CSYNC_FTW_TYPE_FILE);
|
||||
}
|
||||
assert_int_equal(totalRc, CSYNC_NOT_EXCLUDED); // mainly to avoid optimization
|
||||
|
||||
@@ -344,25 +346,6 @@ static void check_csync_excluded_performance(void **state)
|
||||
}
|
||||
}
|
||||
|
||||
static void check_csync_exclude_expand_escapes(void **state)
|
||||
{
|
||||
(void)state;
|
||||
|
||||
const char *str = csync_exclude_expand_escapes(
|
||||
"keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z");
|
||||
assert_true(0 == strcmp(
|
||||
str, "keep ' \" ? \\ \a \b \f \n \r \t \v \\z"));
|
||||
SAFE_FREE(str);
|
||||
|
||||
str = csync_exclude_expand_escapes("");
|
||||
assert_true(0 == strcmp(str, ""));
|
||||
SAFE_FREE(str);
|
||||
|
||||
str = csync_exclude_expand_escapes("\\");
|
||||
assert_true(0 == strcmp(str, "\\"));
|
||||
SAFE_FREE(str);
|
||||
}
|
||||
|
||||
int torture_run_tests(void)
|
||||
{
|
||||
const UnitTest tests[] = {
|
||||
@@ -373,7 +356,6 @@ int torture_run_tests(void)
|
||||
unit_test_setup_teardown(check_csync_pathes, setup_init, teardown),
|
||||
unit_test_setup_teardown(check_csync_is_windows_reserved_word, setup_init, teardown),
|
||||
unit_test_setup_teardown(check_csync_excluded_performance, setup_init, teardown),
|
||||
unit_test(check_csync_exclude_expand_escapes),
|
||||
};
|
||||
|
||||
return run_tests(tests);
|
||||
|
||||
@@ -33,7 +33,8 @@ static void setup(void **state) {
|
||||
rc = system("mkdir -p /tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
*state = csync;
|
||||
}
|
||||
@@ -48,7 +49,8 @@ static void setup_module(void **state) {
|
||||
rc = system("mkdir -p /tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync_create(&csync, "/tmp/check_csync1", "dummy://foo/bar");
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "dummy://foo/bar");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
*state = csync;
|
||||
}
|
||||
@@ -71,19 +73,34 @@ static void teardown(void **state) {
|
||||
*state = NULL;
|
||||
}
|
||||
|
||||
static void check_csync_init_null(void **state)
|
||||
{
|
||||
int rc;
|
||||
|
||||
(void) state; /* unused */
|
||||
|
||||
rc = csync_init(NULL);
|
||||
assert_int_equal(rc, -1);
|
||||
}
|
||||
|
||||
static void check_csync_init(void **state)
|
||||
{
|
||||
CSYNC *csync = *state;
|
||||
int rc;
|
||||
|
||||
csync_init(csync);
|
||||
rc = csync_init(csync);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
assert_int_equal(csync->status & CSYNC_STATUS_INIT, 1);
|
||||
|
||||
rc = csync_init(csync);
|
||||
assert_int_equal(rc, 1);
|
||||
}
|
||||
|
||||
int torture_run_tests(void)
|
||||
{
|
||||
const UnitTest tests[] = {
|
||||
unit_test_setup_teardown(check_csync_init_null, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_init, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_init, setup_module, teardown),
|
||||
};
|
||||
|
||||
@@ -37,7 +37,8 @@ static void setup(void **state) {
|
||||
rc = system("mkdir -p /tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
*state = csync;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ static void setup(void **state) {
|
||||
rc = system("mkdir -p /tmp/check_csync1");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync->statedb.file = c_strdup( TESTDB );
|
||||
*state = csync;
|
||||
|
||||
@@ -42,8 +42,10 @@ static void setup(void **state)
|
||||
assert_int_equal(rc, 0);
|
||||
rc = system("mkdir -p /tmp/check_csync");
|
||||
assert_int_equal(rc, 0);
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
csync_init(csync);
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = csync_init(csync);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
sqlite3 *db = NULL;
|
||||
rc = sqlite3_open_v2(TESTDB, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL);
|
||||
|
||||
@@ -93,8 +93,10 @@ static void setup(void **state)
|
||||
assert_int_equal(rc, 0);
|
||||
rc = system("mkdir -p /tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
csync_init(csync);
|
||||
rc = csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = csync_init(csync);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
/* Create a new db with metadata */
|
||||
sqlite3 *db;
|
||||
@@ -124,8 +126,10 @@ static void setup_ftw(void **state)
|
||||
assert_int_equal(rc, 0);
|
||||
rc = system("mkdir -p /tmp/check_csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
csync_create(&csync, "/tmp", "/tmp");
|
||||
csync_init(csync);
|
||||
rc = csync_create(&csync, "/tmp", "/tmp");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = csync_init(csync);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
sqlite3 *db = NULL;
|
||||
rc = sqlite3_open_v2(TESTDB, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL);
|
||||
|
||||
@@ -84,8 +84,10 @@ static void destructor(void *data) {
|
||||
|
||||
static void setup(void **state) {
|
||||
c_rbtree_t *tree = NULL;
|
||||
int rc;
|
||||
|
||||
c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
rc = c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
*state = tree;
|
||||
}
|
||||
@@ -95,7 +97,8 @@ static void setup_complete_tree(void **state) {
|
||||
int i = 0;
|
||||
int rc;
|
||||
|
||||
c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
rc = c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
test_t *testdata = NULL;
|
||||
@@ -128,13 +131,31 @@ static void check_c_rbtree_create_free(void **state)
|
||||
|
||||
(void) state; /* unused */
|
||||
|
||||
c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
rc = c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
assert_int_equal(rc, 0);
|
||||
assert_int_equal(tree->size, 0);
|
||||
|
||||
rc = c_rbtree_free(tree);
|
||||
assert_int_equal(rc, 0);
|
||||
}
|
||||
|
||||
static void check_c_rbtree_create_null(void **state)
|
||||
{
|
||||
c_rbtree_t *tree = NULL;
|
||||
int rc;
|
||||
|
||||
(void) state; /* unused */
|
||||
|
||||
rc = c_rbtree_create(NULL, key_cmp, data_cmp);
|
||||
assert_int_equal(rc, -1);
|
||||
|
||||
rc = c_rbtree_create(&tree, NULL, data_cmp);
|
||||
assert_int_equal(rc, -1);
|
||||
|
||||
rc = c_rbtree_create(&tree, key_cmp, NULL);
|
||||
assert_int_equal(rc, -1);
|
||||
}
|
||||
|
||||
static void check_c_rbtree_free_null(void **state)
|
||||
{
|
||||
int rc;
|
||||
@@ -154,7 +175,8 @@ static void check_c_rbtree_insert_delete(void **state)
|
||||
|
||||
(void) state; /* unused */
|
||||
|
||||
c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
rc = c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
testdata = malloc(sizeof(test_t));
|
||||
testdata->key = 42;
|
||||
@@ -347,6 +369,7 @@ int torture_run_tests(void)
|
||||
{
|
||||
const UnitTest tests[] = {
|
||||
unit_test(check_c_rbtree_create_free),
|
||||
unit_test(check_c_rbtree_create_null),
|
||||
unit_test(check_c_rbtree_free_null),
|
||||
unit_test(check_c_rbtree_insert_delete),
|
||||
unit_test_setup_teardown(check_c_rbtree_insert_random, setup, teardown),
|
||||
|
||||
@@ -49,7 +49,8 @@ static void setup(void **state)
|
||||
rc = system("rm -rf /tmp/csync_test");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
rc = csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
csync->replica = LOCAL_REPLICA;
|
||||
|
||||
|
||||
@@ -97,7 +97,8 @@ static void setup_testenv(void **state) {
|
||||
statevar *mystate = malloc( sizeof(statevar) );
|
||||
mystate->result = NULL;
|
||||
|
||||
csync_create(&(mystate->csync), "/tmp/csync1", "/tmp/csync2");
|
||||
rc = csync_create(&(mystate->csync), "/tmp/csync1", "/tmp/csync2");
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
mystate->csync->replica = LOCAL_REPLICA;
|
||||
|
||||
|
||||
@@ -18,8 +18,3 @@ ownCloud Command Line Client
|
||||
----------------------------
|
||||
.. index:: owncloudcmd
|
||||
.. include:: owncloudcmd.rst
|
||||
|
||||
Low Disk Space
|
||||
--------------
|
||||
.. index:: disk space
|
||||
.. include:: lowdiskspace.rst
|
||||
|
||||
@@ -87,7 +87,7 @@ To manually override this key, use the same value in ``HKEY_CURRENT_USER``.
|
||||
|
||||
To prevent automatic updates and disallow manual overrides:
|
||||
|
||||
.. note:: This is the preferred method of controlling the updater behavior using
|
||||
.. note::This is the preferred method of controlling the updater behavior using
|
||||
Group Policies.
|
||||
|
||||
1. Edit this Registry key:
|
||||
@@ -98,14 +98,6 @@ To prevent automatic updates and disallow manual overrides:
|
||||
|
||||
3. Specify a value of ``1`` to the machine.
|
||||
|
||||
.. note:: Enterprise branded clients
|
||||
(see `Building Branded ownCloud Clients
|
||||
<https://doc.owncloud.org/branded_clients/>`_) have different key names,
|
||||
which are set in ownBrander using the Application Vendor and Application
|
||||
Name fields. Your key names look like this::
|
||||
|
||||
``HKEY_LOCAL_MACHINE\Software\Policies\myCompanyName\myAppName``
|
||||
|
||||
|
||||
Preventing Automatic Updates in Mac OS X Environments
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
+16
-41
@@ -11,44 +11,22 @@ desktop client.
|
||||
.. note:: Build instructions are subject to change as development proceeds.
|
||||
Please check the version for which you want to build.
|
||||
|
||||
These instructions are updated to work with version 2.2 of the ownCloud Client.
|
||||
|
||||
Getting Source Code
|
||||
-------------------
|
||||
|
||||
The :ref:`generic-build-instructions` pull the latest code directly from
|
||||
GitHub, and work on Linux, Mac OS X, and Windows.
|
||||
|
||||
See the next section for instructions on getting source code from Linux
|
||||
packages.
|
||||
The instructions contained in this topic were updated to work with version 1.7 of the ownCloud Client.
|
||||
|
||||
Linux
|
||||
-----
|
||||
|
||||
You may wish to use source packages for your Linux distribution, as these give
|
||||
you the exact sources from which the binary packages are built. These are
|
||||
hosted on the `ownCloud repository from OBS`_. Go to the `Index of
|
||||
repositories`_ to see all the Linux client repos.
|
||||
|
||||
1. At the `bottom of the page for each distribution
|
||||
<https://software.opensuse.org/download/package?project=isv:ownCloud:desktop&
|
||||
package=owncloud-client>`_ is a "Grab binary packages directly" section.
|
||||
These contain source RPMs for CentOS, RHEL, Fedora, SLES, and openSUSE.
|
||||
|
||||
To get the .deb source packages add the source
|
||||
repo for your Debian or Ubuntu version, like this example for Debian 8
|
||||
(run as root)::
|
||||
|
||||
echo 'deb-src
|
||||
http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/Debian_8.0/ /' >> /etc/apt/sources.list.d/owncloud-client.list
|
||||
|
||||
2. Install the dependencies using the following commands for your specific Linux distribution:
|
||||
1. Add the `ownCloud repository from OBS`_.
|
||||
2. Install the dependencies (as root, or using ``sudo``) using the following
|
||||
commands for your specific Linux distribution:
|
||||
|
||||
* Debian/Ubuntu: ``apt-get update; apt-get build-dep owncloud-client``
|
||||
* openSUSE/SLES: ``zypper ref; zypper si -d owncloud-client``
|
||||
* Fedora/CentOS/RHEL: ``yum install yum-utils; yum-builddep owncloud-client``
|
||||
* openSUSE: ``zypper ref; zypper si -d owncloud-client``
|
||||
* Fedora/CentOS: ``yum install yum-utils; yum-builddep owncloud-client``
|
||||
|
||||
3. Follow the :ref:`generic-build-instructions`, starting with step 2.
|
||||
3. Follow the :ref:`generic-build-instructions`.
|
||||
|
||||
4. (Optional) Call ``make install`` to install the client to the ``/usr/local/bin`` directory.
|
||||
|
||||
Mac OS X
|
||||
--------
|
||||
@@ -209,7 +187,9 @@ Compared to previous versions, building the desktop sync client has become easie
|
||||
earlier versions, CSync, which is the sync engine library of the client, is now
|
||||
part of the client source repository and not a separate module.
|
||||
|
||||
To build the most up-to-date version of the client:
|
||||
You can download the desktop sync client from the ownCloud `Client Download Page`_.
|
||||
|
||||
To build the most up to date version of the client:
|
||||
|
||||
1. Clone the latest versions of the client from Git_ as follows::
|
||||
|
||||
@@ -237,9 +217,6 @@ To build the most up-to-date version of the client:
|
||||
4. Call ``make``.
|
||||
|
||||
The owncloud binary will appear in the ``bin`` directory.
|
||||
|
||||
5. (Optional) Call ``make install`` to install the client to the
|
||||
``/usr/local/bin`` directory.
|
||||
|
||||
The following are known cmake parameters:
|
||||
|
||||
@@ -252,17 +229,15 @@ The following are known cmake parameters:
|
||||
* ``BUILD_WITH_QT4=ON``: Builds using Qt4 (even if Qt5 is found).
|
||||
* ``CMAKE_INSTALL_PREFIX=path``: Set an install prefix. This is mandatory on Mac OS
|
||||
|
||||
.. _ownCloud repository from OBS: http://software.opensuse.org/download/package?
|
||||
project=isv:ownCloud:desktop&package=owncloud-client
|
||||
.. _`ownCloud repository from OBS`: http://software.opensuse.org/download/package?project=isv:ownCloud:desktop&package=owncloud-client
|
||||
.. _CMake: http://www.cmake.org/download
|
||||
.. _CSync: http://www.csync.org
|
||||
.. _Client Download Page: https://owncloud.org/install/#desktop
|
||||
.. _`Client Download Page`: http://owncloud.org/sync-clients/
|
||||
.. _Git: http://git-scm.com
|
||||
.. _MacPorts: http://www.macports.org
|
||||
.. _Homebrew: http://mxcl.github.com/homebrew/
|
||||
.. _OpenSSL Windows Build: http://slproweb.com/products/Win32OpenSSL.html
|
||||
.. _`OpenSSL Windows Build`: http://slproweb.com/products/Win32OpenSSL.html
|
||||
.. _Qt: http://www.qt.io/download
|
||||
.. _Microsoft Authenticode: https://msdn.microsoft.com/en-us/library/ie/ms537361%28v=vs.85%29.aspx
|
||||
.. _`Microsoft Authenticode`: https://msdn.microsoft.com/en-us/library/ie/ms537361%28v=vs.85%29.aspx
|
||||
.. _QtKeychain: https://github.com/frankosterfeld/qtkeychain
|
||||
.. _Packages: http://s.sudre.free.fr/Software/Packages/about.html
|
||||
.. _Index of repositories: http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/
|
||||
|
||||
@@ -23,8 +23,3 @@ You can change the following configuration settings (must be under the ``[ownClo
|
||||
- ``maxLogLines`` (default: ``20000``) -- Specifies the maximum number of log lines displayed in the log window.
|
||||
|
||||
- ``chunkSize`` (default: ``5242880``) -- Specifies the chunk size of uploaded files in bytes.
|
||||
|
||||
- ``promptDeleteAllFiles`` (default: ``true``) -- If a UI prompt should ask for confirmation if it was detected that all files and folders were deleted.
|
||||
|
||||
- ``notificationRefreshInterval`` (default``300,000``) -- Specifies the default interval of checking for new server notifications in milliseconds.
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
When disk space is low the ownCloud Client will be unable to synchronize all files. This section describes its behavior in a low disk space situation as well as the options that influence it.
|
||||
|
||||
1. Synchronization of a folder aborts entirely if the remaining disk space falls below 50 MB. This threshold can be adjusted with the ``OWNCLOUD_CRITICAL_FREE_SPACE_BYTES`` environment variable.
|
||||
|
||||
2. Downloads that would reduce the free disk space below 250 MB will be skipped or aborted. The download will be retried regularly and other synchronization is unaffected. This threshold can be adjusted with the ``OWNCLOUD_FREE_SPACE_BYTES`` environment variable.
|
||||
+2
-35
@@ -11,7 +11,7 @@ in the system tray (Windows, KDE), status bar (Mac OS X), or notification area
|
||||
.. figure:: images/icon.png
|
||||
:alt: Status icon, little cloud with green circle and white checkmark
|
||||
|
||||
The status indicator uses icons to indicate the current status of your
|
||||
The status indicator uses overlay icons to indicate the current status of your
|
||||
synchronization. The green circle with the white checkmark tells you that your
|
||||
synchronization is current and you are connected to your ownCloud server.
|
||||
|
||||
@@ -24,7 +24,7 @@ The blue icon with the white semi-circles means synchronization is in progress.
|
||||
:alt: Status icon, little cloud with yellow circle and vertical parallel
|
||||
lines
|
||||
|
||||
The yellow icon with the parallel lines tells you your synchronization
|
||||
The yellow overlay icon with the parallel lines tells you your synchronization
|
||||
has been paused. (Most likely by you.)
|
||||
|
||||
.. figure:: images/icon-offline.png
|
||||
@@ -133,39 +133,6 @@ appear as a new tab in the settings dialog, where you can adjust its settings
|
||||
at
|
||||
any time. Use **Account** > **Remove** to delete accounts.
|
||||
|
||||
File Manager Overlay Icons
|
||||
--------------------------
|
||||
|
||||
The ownCloud sync client provides overlay icons, in addition to the normal file
|
||||
type icons, for your system file manager (Explorer on Windows, Finder on Mac and
|
||||
Nautilus on Linux) to indicate the sync status of your ownCloud files.
|
||||
|
||||
The overlay icons are similar to the systray icons introduced above. They
|
||||
behave differently on files and directories according to sync status
|
||||
and errors.
|
||||
|
||||
The overlay icon of an individual file indicates its current sync state. If the
|
||||
file is in sync with the server version, it displays a green checkmark.
|
||||
|
||||
If the file is ignored from syncing, for example because it is on your
|
||||
exclude list, or because it is a symbolic link, it displays a warning icon.
|
||||
|
||||
If there is a sync error, or the file is blacklisted, it displays an
|
||||
eye-catching red X.
|
||||
|
||||
If the file is waiting to be synced, or is currently syncing, the overlay
|
||||
icon displays a blue cycling icon.
|
||||
|
||||
When the client is offline, no icons are shown to reflect that the
|
||||
folder is currently out of sync and no changes are synced to the server.
|
||||
|
||||
The overlay icon of a synced directory indicates the status of the files in the
|
||||
directory. If there are any sync errors, the directory is marked with a warning
|
||||
icon.
|
||||
|
||||
If a directory includes ignored files that are marked with warning icons
|
||||
that does not change the status of the parent directories.
|
||||
|
||||
Sharing From Your Desktop
|
||||
-------------------------
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ Other command line switches supported by ``owncloudcmd`` include the following:
|
||||
Exclude list file
|
||||
|
||||
``--unsyncedfolders [file]``
|
||||
File containing the list of unsynced remote folders (selective sync)
|
||||
File containing the list of unsynced folders (selective sync)
|
||||
|
||||
``--max-sync-retries [n]``
|
||||
Retries maximum n times (defaults to 3)
|
||||
|
||||
@@ -78,7 +78,7 @@ Other issues can affect synchronization of your ownCloud files:
|
||||
- If you are operating your own server, and use the local storage backend (the
|
||||
default), make sure that ownCloud has exclusive access to the directory.
|
||||
|
||||
.. warning:: The data directory on the server is exclusive to ownCloud and must not be modified manually.
|
||||
.. note:: The data directory on the server is exclusive to ownCloud and must not be modified manually.
|
||||
|
||||
- If you are using a different file backend on the server, you can try to exclude a bug in the
|
||||
backend by reverting to the built-in backend.
|
||||
|
||||
@@ -8,14 +8,3 @@ GenericName=Folder Sync
|
||||
Icon=@APPLICATION_EXECUTABLE@
|
||||
Keywords=@APPLICATION_NAME@;syncing;file;sharing;
|
||||
X-GNOME-Autostart-Delay=3
|
||||
|
||||
|
||||
# Translations
|
||||
Comment[sq]=Klient njëkohësimesh @APPLICATION_NAME@ për desktop
|
||||
GenericName[sq]=Njëkohësim Dosjesh
|
||||
Name[sq]=Klient njëkohësimesh @APPLICATION_NAME@ për desktop
|
||||
Icon[sq]=@APPLICATION_EXECUTABLE@
|
||||
Comment[nl]=@APPLICATION_NAME@ desktop synchronisatie client
|
||||
GenericName[nl]=Mappen sync
|
||||
Name[nl]=@APPLICATION_NAME@ desktop sync client
|
||||
Icon[nl]=@APPLICATION_EXECUTABLE@
|
||||
|
||||
Arquivo binário não exibido.
|
Antes Largura: | Altura: | Tamanho: 900 B |
@@ -7,9 +7,6 @@ add_custom_target( legacy_mac_overlayplugin ALL
|
||||
OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}
|
||||
COMMENT building Legacy Mac Overlay icons)
|
||||
|
||||
# Contrary to popular belief, this is called like this no matter what theme/OEM.
|
||||
set(OC_OEM_SHARE_ICNS "${CMAKE_BINARY_DIR}/src/gui/ownCloud.icns")
|
||||
|
||||
# The bundle identifier and application group need to have compatible values with the client
|
||||
# to be able to open a Mach port across the extension's sandbox boundary.
|
||||
# Pass the info through the xcodebuild command line and make sure that the project uses
|
||||
@@ -17,21 +14,15 @@ set(OC_OEM_SHARE_ICNS "${CMAKE_BINARY_DIR}/src/gui/ownCloud.icns")
|
||||
add_custom_target( mac_overlayplugin ALL
|
||||
xcodebuild -project ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/OwnCloudFinderSync/OwnCloudFinderSync.xcodeproj
|
||||
-target FinderSyncExt -configuration Release SYMROOT=${CMAKE_CURRENT_BINARY_DIR}
|
||||
OC_OEM_SHARE_ICNS=${OC_OEM_SHARE_ICNS}
|
||||
OC_APPLICATION_NAME="${APPLICATION_NAME}"
|
||||
OC_APPLICATION_NAME=${APPLICATION_NAME}
|
||||
OC_APPLICATION_REV_DOMAIN=${APPLICATION_REV_DOMAIN}
|
||||
OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}
|
||||
COMMENT building Mac Overlay icons)
|
||||
add_dependencies(mac_overlayplugin ${APPLICATION_EXECUTABLE}) # for the ownCloud.icns to be generated
|
||||
|
||||
|
||||
# legacy
|
||||
INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/SyncStateFinder.osax/Contents
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/ScriptingAdditions/SyncStateFinder.osax/ )
|
||||
|
||||
# >= 10.10.x
|
||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/FinderSyncExt.appex
|
||||
DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/PlugIns
|
||||
DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Plugins
|
||||
USE_SOURCE_PERMISSIONS)
|
||||
endif(APPLE)
|
||||
|
||||
|
||||
@@ -103,8 +103,7 @@
|
||||
|
||||
if (_shareMenuTitle && !onlyRootsSelected) {
|
||||
NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
|
||||
NSMenuItem *item = [menu addItemWithTitle:_shareMenuTitle action:@selector(shareMenuAction:) keyEquivalent:@"title"];
|
||||
item.image = [[NSBundle mainBundle] imageForResource:@"app.icns"];
|
||||
[menu addItemWithTitle:_shareMenuTitle action:@selector(shareMenuAction:) keyEquivalent:@"title"];
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
-20
@@ -178,7 +178,6 @@
|
||||
C2B573D31B1CD9CE00303B36 /* Sources */,
|
||||
C2B573D41B1CD9CE00303B36 /* Frameworks */,
|
||||
C2B573D51B1CD9CE00303B36 /* Resources */,
|
||||
5B3335471CA058E200E11A45 /* ShellScript */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -254,23 +253,6 @@
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
5B3335471CA058E200E11A45 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "if [[ ${OC_OEM_SHARE_ICNS} ]]; then\n cp ${OC_OEM_SHARE_ICNS} ${BUILT_PRODUCTS_DIR}/FinderSyncExt.appex/Contents/Resources/app.icns\nfi";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
C2B573AD1B1CD91E00303B36 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
@@ -447,7 +429,6 @@
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
OC_APPLICATION_NAME = ownCloud;
|
||||
OC_APPLICATION_REV_DOMAIN = com.owncloud.desktopclient;
|
||||
OC_OEM_SHARE_ICNS = "";
|
||||
OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX = "";
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -495,7 +476,6 @@
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
OC_APPLICATION_NAME = ownCloud;
|
||||
OC_APPLICATION_REV_DOMAIN = com.owncloud.desktopclient;
|
||||
OC_OEM_SHARE_ICNS = "";
|
||||
OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX = "";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
|
||||
@@ -28,26 +28,19 @@ include(GenerateExportHeader)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
|
||||
|
||||
if (NOT DEFINED APPLICATION_EXECUTABLE )
|
||||
set ( APPLICATION_EXECUTABLE "owncloud" )
|
||||
endif()
|
||||
|
||||
#---HELPER---
|
||||
set(OWNCLOUDDOLPHINHELPER ${APPLICATION_EXECUTABLE}dolphinpluginhelper)
|
||||
add_library(${OWNCLOUDDOLPHINHELPER} SHARED ownclouddolphinpluginhelper.cpp)
|
||||
target_link_libraries(${OWNCLOUDDOLPHINHELPER} Qt5::Network)
|
||||
generate_export_header(${OWNCLOUDDOLPHINHELPER})
|
||||
install(TARGETS ${OWNCLOUDDOLPHINHELPER} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
add_library(ownclouddolphinpluginhelper SHARED ownclouddolphinpluginhelper.cpp)
|
||||
target_link_libraries(ownclouddolphinpluginhelper Qt5::Network)
|
||||
generate_export_header(ownclouddolphinpluginhelper)
|
||||
install(TARGETS ownclouddolphinpluginhelper LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
#---OVERLAY PLUGIN---
|
||||
set(OWNCLOUDDOLPHINOVERLAYPLUGIN ${APPLICATION_EXECUTABLE}dolphinoverlayplugin)
|
||||
kcoreaddons_add_plugin(${OWNCLOUDDOLPHINOVERLAYPLUGIN} INSTALL_NAMESPACE "kf5/overlayicon"
|
||||
kcoreaddons_add_plugin(ownclouddolphinoverlayplugin INSTALL_NAMESPACE "kf5/overlayicon"
|
||||
JSON ownclouddolphinoverlayplugin.json SOURCES ownclouddolphinoverlayplugin.cpp)
|
||||
target_link_libraries(${OWNCLOUDDOLPHINOVERLAYPLUGIN} KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets ${OWNCLOUDDOLPHINHELPER})
|
||||
target_link_libraries(ownclouddolphinoverlayplugin KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets ownclouddolphinpluginhelper)
|
||||
|
||||
#---ACTION PLUGIN---
|
||||
set(OWNCLOUDDOLPHINACTIONPLUGIN ${APPLICATION_EXECUTABLE}dolphinactionplugin)
|
||||
add_library(${OWNCLOUDDOLPHINACTIONPLUGIN} MODULE ownclouddolphinactionplugin.cpp)
|
||||
target_link_libraries(${OWNCLOUDDOLPHINACTIONPLUGIN} KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets ${OWNCLOUDDOLPHINHELPER})
|
||||
install(FILES ownclouddolphinactionplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} RENAME ${OWNCLOUDDOLPHINACTIONPLUGIN}.desktop)
|
||||
install(TARGETS ${OWNCLOUDDOLPHINACTIONPLUGIN} DESTINATION ${KDE_INSTALL_PLUGINDIR})
|
||||
add_library(ownclouddolphinactionplugin MODULE ownclouddolphinactionplugin.cpp)
|
||||
target_link_libraries(ownclouddolphinactionplugin KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets ownclouddolphinpluginhelper)
|
||||
install(FILES ownclouddolphinactionplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
|
||||
install(TARGETS ownclouddolphinactionplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
|
||||
|
||||
@@ -225,10 +225,10 @@ class SyncStateExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.Info
|
||||
for p in socketConnect.nautilusVFSFile_table:
|
||||
if p == path or p.startswith(path):
|
||||
item = socketConnect.nautilusVFSFile_table[p]['item']
|
||||
update_items.append(p)
|
||||
update_items.append(item)
|
||||
|
||||
for path1 in update_items:
|
||||
socketConnect.nautilusVFSFile_table[path1]['item'].invalidate_extension_info()
|
||||
for item in update_items:
|
||||
item.invalidate_extension_info()
|
||||
|
||||
# Handles a single line of server response and sets the emblem
|
||||
def handle_commands(self, action, args):
|
||||
@@ -242,16 +242,14 @@ class SyncStateExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.Info
|
||||
'NEW+SWM' : appname +'_sync_shared',
|
||||
'IGNORE+SWM': appname +'_warn_shared',
|
||||
'ERROR+SWM' : appname +'_error_shared',
|
||||
'NOP' : ''
|
||||
'NOP' : appname +'_error'
|
||||
}
|
||||
|
||||
# file = args[0] # For debug only
|
||||
# print("Action for " + file + ": " + args[0]) # For debug only
|
||||
if action == 'STATUS':
|
||||
newState = args[0]
|
||||
emblem = 'NOP' # Show nothing if no emblem si defined.
|
||||
if newState in Emblems:
|
||||
emblem = Emblems[newState]
|
||||
emblem = Emblems[newState]
|
||||
filename = ':'.join(args[1:])
|
||||
|
||||
if emblem:
|
||||
|
||||
@@ -108,6 +108,31 @@ HRESULT RegisterCLSID(LPCOLESTR guidStr, PCWSTR overlayStr, PCWSTR szModule)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT _stdcall DllRegisterServer(void)
|
||||
{
|
||||
HRESULT hResult = S_OK;
|
||||
|
||||
wchar_t szModule[MAX_PATH];
|
||||
|
||||
if (GetModuleFileName(instanceHandle, szModule, ARRAYSIZE(szModule)) == 0) {
|
||||
hResult = HRESULT_FROM_WIN32(GetLastError());
|
||||
return hResult;
|
||||
}
|
||||
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_ERROR, OVERLAY_NAME_ERROR, szModule);
|
||||
if (!SUCCEEDED(hResult)) { return hResult; }
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_OK, OVERLAY_NAME_OK, szModule);
|
||||
if (!SUCCEEDED(hResult)) { return hResult; }
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_OK_SHARED, OVERLAY_NAME_OK_SHARED, szModule);
|
||||
if (!SUCCEEDED(hResult)) { return hResult; }
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_SYNC, OVERLAY_NAME_SYNC, szModule);
|
||||
if (!SUCCEEDED(hResult)) { return hResult; }
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_WARNING, OVERLAY_NAME_WARNING, szModule);
|
||||
|
||||
return hResult;
|
||||
}
|
||||
|
||||
|
||||
HRESULT UnregisterCLSID(LPCOLESTR guidStr, PCWSTR overlayStr)
|
||||
{
|
||||
HRESULT hResult = S_OK;
|
||||
@@ -130,37 +155,6 @@ HRESULT UnregisterCLSID(LPCOLESTR guidStr, PCWSTR overlayStr)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT _stdcall DllRegisterServer(void)
|
||||
{
|
||||
HRESULT hResult = S_OK;
|
||||
|
||||
wchar_t szModule[MAX_PATH];
|
||||
|
||||
if (GetModuleFileName(instanceHandle, szModule, ARRAYSIZE(szModule)) == 0) {
|
||||
hResult = HRESULT_FROM_WIN32(GetLastError());
|
||||
return hResult;
|
||||
}
|
||||
|
||||
// Unregister any obsolete CLSID when we register here
|
||||
// Those CLSID were removed in 2.1, but we need to make sure to prevent any previous version
|
||||
// of the extension on the system from loading at the same time as a new version to avoid crashing explorer.
|
||||
UnregisterCLSID(OVERLAY_GUID_ERROR_SHARED, OVERLAY_NAME_ERROR_SHARED);
|
||||
UnregisterCLSID(OVERLAY_GUID_SYNC_SHARED, OVERLAY_NAME_SYNC_SHARED);
|
||||
UnregisterCLSID(OVERLAY_GUID_WARNING_SHARED, OVERLAY_NAME_WARNING_SHARED);
|
||||
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_ERROR, OVERLAY_NAME_ERROR, szModule);
|
||||
if (!SUCCEEDED(hResult)) { return hResult; }
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_OK, OVERLAY_NAME_OK, szModule);
|
||||
if (!SUCCEEDED(hResult)) { return hResult; }
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_OK_SHARED, OVERLAY_NAME_OK_SHARED, szModule);
|
||||
if (!SUCCEEDED(hResult)) { return hResult; }
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_SYNC, OVERLAY_NAME_SYNC, szModule);
|
||||
if (!SUCCEEDED(hResult)) { return hResult; }
|
||||
hResult = RegisterCLSID(OVERLAY_GUID_WARNING, OVERLAY_NAME_WARNING, szModule);
|
||||
|
||||
return hResult;
|
||||
}
|
||||
|
||||
STDAPI DllUnregisterServer(void)
|
||||
{
|
||||
HRESULT hResult = S_OK;
|
||||
|
||||
@@ -14,25 +14,19 @@
|
||||
|
||||
|
||||
#define OVERLAY_GUID_ERROR L"{0960F090-F328-48A3-B746-276B1E3C3722}"
|
||||
#define OVERLAY_GUID_ERROR_SHARED L"{0960F091-F328-48A3-B746-276B1E3C3722}"
|
||||
#define OVERLAY_GUID_OK L"{0960F092-F328-48A3-B746-276B1E3C3722}"
|
||||
#define OVERLAY_GUID_OK_SHARED L"{0960F093-F328-48A3-B746-276B1E3C3722}"
|
||||
#define OVERLAY_GUID_SYNC L"{0960F094-F328-48A3-B746-276B1E3C3722}"
|
||||
#define OVERLAY_GUID_SYNC_SHARED L"{0960F095-F328-48A3-B746-276B1E3C3722}"
|
||||
#define OVERLAY_GUID_WARNING L"{0960F096-F328-48A3-B746-276B1E3C3722}"
|
||||
#define OVERLAY_GUID_WARNING_SHARED L"{0960F097-F328-48A3-B746-276B1E3C3722}"
|
||||
|
||||
#define OVERLAY_GENERIC_NAME L"OC Overlay Handler"
|
||||
|
||||
// two spaces to put us ahead of the competition :/
|
||||
#define OVERLAY_NAME_ERROR L" OCError"
|
||||
#define OVERLAY_NAME_ERROR_SHARED L" OCErrorShared"
|
||||
#define OVERLAY_NAME_OK L" OCOK"
|
||||
#define OVERLAY_NAME_OK_SHARED L" OCOKShared"
|
||||
#define OVERLAY_NAME_SYNC L" OCSync"
|
||||
#define OVERLAY_NAME_SYNC_SHARED L" OCSyncShared"
|
||||
#define OVERLAY_NAME_WARNING L" OCWarning"
|
||||
#define OVERLAY_NAME_WARNING_SHARED L" OCWarningShared"
|
||||
|
||||
#define REGISTRY_OVERLAY_KEY L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers"
|
||||
#define REGISTRY_CLSID L"CLSID"
|
||||
|
||||
+353
@@ -0,0 +1,353 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "fancylineedit.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QLabel>
|
||||
#include <QAbstractButton>
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#include <QPaintEvent>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
/*! Opens a menu at the specified widget position.
|
||||
* This functions computes the position where to show the menu, and opens it with
|
||||
* QMenu::exec().
|
||||
* \param menu The menu to open
|
||||
* \param widget The widget next to which to open the menu
|
||||
*/
|
||||
static void execMenuAtWidget(QMenu *menu, QWidget *widget)
|
||||
{
|
||||
QPoint p;
|
||||
QRect screen = qApp->desktop()->availableGeometry(widget);
|
||||
QSize sh = menu->sizeHint();
|
||||
QRect rect = widget->rect();
|
||||
if (widget->isRightToLeft()) {
|
||||
if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height())
|
||||
p = widget->mapToGlobal(rect.bottomRight());
|
||||
else
|
||||
p = widget->mapToGlobal(rect.topRight() - QPoint(0, sh.height()));
|
||||
p.rx() -= sh.width();
|
||||
} else {
|
||||
if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height())
|
||||
p = widget->mapToGlobal(rect.bottomLeft());
|
||||
else
|
||||
p = widget->mapToGlobal(rect.topLeft() - QPoint(0, sh.height()));
|
||||
}
|
||||
p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width()));
|
||||
p.ry() += 1;
|
||||
|
||||
menu->exec(p);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class Utils::FancyLineEdit
|
||||
|
||||
\brief A line edit with an embedded pixmap on one side that is connected to
|
||||
a menu.
|
||||
|
||||
Additionally, it can display a grayed hintText (like "Type Here to")
|
||||
when not focused and empty. When connecting to the changed signals and
|
||||
querying text, one has to be aware that the text is set to that hint
|
||||
text if isShowingHintText() returns true (that is, does not contain
|
||||
valid user input).
|
||||
*/
|
||||
|
||||
enum { margin = 6 };
|
||||
|
||||
#define ICONBUTTON_HEIGHT 18
|
||||
#define FADE_TIME 160
|
||||
|
||||
namespace Utils {
|
||||
|
||||
// --------- FancyLineEditPrivate
|
||||
class FancyLineEditPrivate : public QObject
|
||||
{
|
||||
public:
|
||||
explicit FancyLineEditPrivate(FancyLineEdit *parent);
|
||||
|
||||
virtual bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
FancyLineEdit *m_lineEdit;
|
||||
QPixmap m_pixmap[2];
|
||||
QMenu *m_menu[2];
|
||||
bool m_menuTabFocusTrigger[2];
|
||||
IconButton *m_iconbutton[2];
|
||||
bool m_iconEnabled[2];
|
||||
};
|
||||
|
||||
|
||||
FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
|
||||
QObject(parent), m_lineEdit(parent)
|
||||
{
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
m_menu[i] = 0;
|
||||
m_menuTabFocusTrigger[i] = false;
|
||||
m_iconbutton[i] = new IconButton(parent);
|
||||
m_iconbutton[i]->installEventFilter(this);
|
||||
m_iconbutton[i]->hide();
|
||||
m_iconbutton[i]->setAutoHide(false);
|
||||
m_iconEnabled[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
int buttonIndex = -1;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (obj == m_iconbutton[i]) {
|
||||
buttonIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (buttonIndex == -1)
|
||||
return QObject::eventFilter(obj, event);
|
||||
switch (event->type()) {
|
||||
case QEvent::FocusIn:
|
||||
if (m_menuTabFocusTrigger[buttonIndex] && m_menu[buttonIndex]) {
|
||||
m_lineEdit->setFocus();
|
||||
execMenuAtWidget(m_menu[buttonIndex], m_iconbutton[buttonIndex]);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
|
||||
// --------- FancyLineEdit
|
||||
FancyLineEdit::FancyLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent),
|
||||
d(new FancyLineEditPrivate(this))
|
||||
{
|
||||
ensurePolished();
|
||||
updateMargins();
|
||||
|
||||
connect(this, SIGNAL(textChanged(QString)), this, SLOT(checkButtons(QString)));
|
||||
connect(d->m_iconbutton[Left], SIGNAL(clicked()), this, SLOT(iconClicked()));
|
||||
connect(d->m_iconbutton[Right], SIGNAL(clicked()), this, SLOT(iconClicked()));
|
||||
}
|
||||
|
||||
void FancyLineEdit::checkButtons(const QString &text)
|
||||
{
|
||||
if (m_oldText.isEmpty() || text.isEmpty()) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (d->m_iconbutton[i]->hasAutoHide())
|
||||
d->m_iconbutton[i]->animateShow(!text.isEmpty());
|
||||
}
|
||||
m_oldText = text;
|
||||
}
|
||||
}
|
||||
|
||||
FancyLineEdit::~FancyLineEdit()
|
||||
{
|
||||
}
|
||||
|
||||
void FancyLineEdit::setButtonVisible(Side side, bool visible)
|
||||
{
|
||||
d->m_iconbutton[side]->setVisible(visible);
|
||||
d->m_iconEnabled[side] = visible;
|
||||
updateMargins();
|
||||
}
|
||||
|
||||
bool FancyLineEdit::isButtonVisible(Side side) const
|
||||
{
|
||||
return d->m_iconEnabled[side];
|
||||
}
|
||||
|
||||
void FancyLineEdit::iconClicked()
|
||||
{
|
||||
IconButton *button = qobject_cast<IconButton *>(sender());
|
||||
int index = -1;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
if (d->m_iconbutton[i] == button)
|
||||
index = i;
|
||||
if (index == -1)
|
||||
return;
|
||||
if (d->m_menu[index]) {
|
||||
execMenuAtWidget(d->m_menu[index], button);
|
||||
} else {
|
||||
emit buttonClicked((Side)index);
|
||||
if (index == Left)
|
||||
emit leftButtonClicked();
|
||||
else if (index == Right)
|
||||
emit rightButtonClicked();
|
||||
}
|
||||
}
|
||||
|
||||
void FancyLineEdit::updateMargins()
|
||||
{
|
||||
bool leftToRight = (layoutDirection() == Qt::LeftToRight);
|
||||
Side realLeft = (leftToRight ? Left : Right);
|
||||
Side realRight = (leftToRight ? Right : Left);
|
||||
|
||||
int leftMargin = d->m_iconbutton[realLeft]->pixmap().width() + 8;
|
||||
int rightMargin = d->m_iconbutton[realRight]->pixmap().width() + 8;
|
||||
// Note KDE does not reserve space for the highlight color
|
||||
if (style()->inherits("OxygenStyle")) {
|
||||
leftMargin = qMax(24, leftMargin);
|
||||
rightMargin = qMax(24, rightMargin);
|
||||
}
|
||||
|
||||
QMargins margins((d->m_iconEnabled[realLeft] ? leftMargin : 0), 0,
|
||||
(d->m_iconEnabled[realRight] ? rightMargin : 0), 0);
|
||||
|
||||
setTextMargins(margins);
|
||||
}
|
||||
|
||||
void FancyLineEdit::updateButtonPositions()
|
||||
{
|
||||
QRect contentRect = rect();
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
Side iconpos = (Side)i;
|
||||
if (layoutDirection() == Qt::RightToLeft)
|
||||
iconpos = (iconpos == Left ? Right : Left);
|
||||
|
||||
if (iconpos == FancyLineEdit::Right) {
|
||||
const int iconoffset = textMargins().right() + 4;
|
||||
d->m_iconbutton[i]->setGeometry(contentRect.adjusted(width() - iconoffset, 0, 0, 0));
|
||||
} else {
|
||||
const int iconoffset = textMargins().left() + 4;
|
||||
d->m_iconbutton[i]->setGeometry(contentRect.adjusted(0, 0, -width() + iconoffset, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FancyLineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
updateButtonPositions();
|
||||
}
|
||||
|
||||
void FancyLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap)
|
||||
{
|
||||
d->m_iconbutton[side]->setPixmap(buttonPixmap);
|
||||
updateMargins();
|
||||
updateButtonPositions();
|
||||
update();
|
||||
}
|
||||
|
||||
QPixmap FancyLineEdit::buttonPixmap(Side side) const
|
||||
{
|
||||
return d->m_pixmap[side];
|
||||
}
|
||||
|
||||
void FancyLineEdit::setButtonMenu(Side side, QMenu *buttonMenu)
|
||||
{
|
||||
d->m_menu[side] = buttonMenu;
|
||||
d->m_iconbutton[side]->setIconOpacity(1.0);
|
||||
}
|
||||
|
||||
QMenu *FancyLineEdit::buttonMenu(Side side) const
|
||||
{
|
||||
return d->m_menu[side];
|
||||
}
|
||||
|
||||
bool FancyLineEdit::hasMenuTabFocusTrigger(Side side) const
|
||||
{
|
||||
return d->m_menuTabFocusTrigger[side];
|
||||
}
|
||||
|
||||
void FancyLineEdit::setMenuTabFocusTrigger(Side side, bool v)
|
||||
{
|
||||
if (d->m_menuTabFocusTrigger[side] == v)
|
||||
return;
|
||||
|
||||
d->m_menuTabFocusTrigger[side] = v;
|
||||
d->m_iconbutton[side]->setFocusPolicy(v ? Qt::TabFocus : Qt::NoFocus);
|
||||
}
|
||||
|
||||
bool FancyLineEdit::hasAutoHideButton(Side side) const
|
||||
{
|
||||
return d->m_iconbutton[side]->hasAutoHide();
|
||||
}
|
||||
|
||||
void FancyLineEdit::setAutoHideButton(Side side, bool h)
|
||||
{
|
||||
d->m_iconbutton[side]->setAutoHide(h);
|
||||
if (h)
|
||||
d->m_iconbutton[side]->setIconOpacity(text().isEmpty() ? 0.0 : 1.0);
|
||||
else
|
||||
d->m_iconbutton[side]->setIconOpacity(1.0);
|
||||
}
|
||||
|
||||
void FancyLineEdit::setButtonToolTip(Side side, const QString &tip)
|
||||
{
|
||||
d->m_iconbutton[side]->setToolTip(tip);
|
||||
}
|
||||
|
||||
void FancyLineEdit::setButtonFocusPolicy(Side side, Qt::FocusPolicy policy)
|
||||
{
|
||||
d->m_iconbutton[side]->setFocusPolicy(policy);
|
||||
}
|
||||
|
||||
// IconButton - helper class to represent a clickable icon
|
||||
|
||||
IconButton::IconButton(QWidget *parent)
|
||||
: QAbstractButton(parent), m_iconOpacity(0), m_autoHide(false)
|
||||
{
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
|
||||
void IconButton::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
QRect pixmapRect = QRect(0, 0, m_pixmap.width(), m_pixmap.height());
|
||||
pixmapRect.moveCenter(rect().center());
|
||||
|
||||
if (m_autoHide)
|
||||
painter.setOpacity(m_iconOpacity);
|
||||
|
||||
painter.drawPixmap(pixmapRect, m_pixmap);
|
||||
}
|
||||
|
||||
void IconButton::animateShow(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "iconOpacity");
|
||||
animation->setDuration(FADE_TIME);
|
||||
animation->setEndValue(1.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
} else {
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "iconOpacity");
|
||||
animation->setDuration(FADE_TIME);
|
||||
animation->setEndValue(0.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef FANCYLINEEDIT_H
|
||||
#define FANCYLINEEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QAbstractButton>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
class FancyLineEditPrivate;
|
||||
|
||||
class IconButton: public QAbstractButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float iconOpacity READ iconOpacity WRITE setIconOpacity)
|
||||
Q_PROPERTY(bool autoHide READ hasAutoHide WRITE setAutoHide)
|
||||
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
|
||||
public:
|
||||
explicit IconButton(QWidget *parent = 0);
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
void setPixmap(const QPixmap &pixmap) { m_pixmap = pixmap; update(); }
|
||||
QPixmap pixmap() const { return m_pixmap; }
|
||||
float iconOpacity() { return m_iconOpacity; }
|
||||
void setIconOpacity(float value) { m_iconOpacity = value; update(); }
|
||||
void animateShow(bool visible);
|
||||
|
||||
void setAutoHide(bool hide) { m_autoHide = hide; }
|
||||
bool hasAutoHide() const { return m_autoHide; }
|
||||
|
||||
private:
|
||||
float m_iconOpacity;
|
||||
bool m_autoHide;
|
||||
QPixmap m_pixmap;
|
||||
};
|
||||
|
||||
class FancyLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Side)
|
||||
|
||||
public:
|
||||
enum Side {Left = 0, Right = 1};
|
||||
|
||||
explicit FancyLineEdit(QWidget *parent = 0);
|
||||
~FancyLineEdit();
|
||||
|
||||
QPixmap buttonPixmap(Side side) const;
|
||||
void setButtonPixmap(Side side, const QPixmap &pixmap);
|
||||
|
||||
QMenu *buttonMenu(Side side) const;
|
||||
void setButtonMenu(Side side, QMenu *menu);
|
||||
|
||||
void setButtonVisible(Side side, bool visible);
|
||||
bool isButtonVisible(Side side) const;
|
||||
|
||||
void setButtonToolTip(Side side, const QString &);
|
||||
void setButtonFocusPolicy(Side side, Qt::FocusPolicy policy);
|
||||
|
||||
// Set whether tabbing in will trigger the menu.
|
||||
void setMenuTabFocusTrigger(Side side, bool v);
|
||||
bool hasMenuTabFocusTrigger(Side side) const;
|
||||
|
||||
// Set if icon should be hidden when text is empty
|
||||
void setAutoHideButton(Side side, bool h);
|
||||
bool hasAutoHideButton(Side side) const;
|
||||
#if QT_VERSION <= 0x040700
|
||||
void setPlaceholderText( const QString& ) { }
|
||||
#endif
|
||||
|
||||
signals:
|
||||
void buttonClicked(Utils::FancyLineEdit::Side side);
|
||||
void leftButtonClicked();
|
||||
void rightButtonClicked();
|
||||
|
||||
private slots:
|
||||
void checkButtons(const QString &);
|
||||
void iconClicked();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void updateMargins();
|
||||
void updateButtonPositions();
|
||||
friend class Utils::FancyLineEditPrivate;
|
||||
|
||||
FancyLineEditPrivate *d;
|
||||
QString m_oldText;
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
#endif // FANCYLINEEDIT_H
|
||||
-264
@@ -1,264 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 Daniel Molkentin <daniel@molkentin.de>
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef TOKENIZER_H
|
||||
#define TOKENIZER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QSharedPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
template <class T, class const_iterator>
|
||||
struct QTokenizerPrivate {
|
||||
typedef typename T::value_type char_type;
|
||||
|
||||
struct State {
|
||||
bool inQuote;
|
||||
bool inEscape;
|
||||
char_type quoteChar;
|
||||
State() : inQuote(false), inEscape(false), quoteChar('\0') {}
|
||||
};
|
||||
|
||||
QTokenizerPrivate(const T& _string, const T& _delims) :
|
||||
string(_string)
|
||||
, begin(string.begin())
|
||||
, end(string.end())
|
||||
, tokenBegin(end)
|
||||
, tokenEnd(begin)
|
||||
, delimiters(_delims)
|
||||
, isDelim(false)
|
||||
, returnDelimiters(false)
|
||||
, returnQuotes(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool isDelimiter(char_type c) const {
|
||||
return delimiters.contains(c);
|
||||
}
|
||||
|
||||
bool isQuote(char_type c) const {
|
||||
return quotes.contains(c);
|
||||
}
|
||||
|
||||
// Returns true if a delimiter was not hit
|
||||
bool nextChar(State* state, char_type c) {
|
||||
if (state->inQuote) {
|
||||
if (state->inEscape) {
|
||||
state->inEscape = false;
|
||||
} else if (c == '\\') {
|
||||
state->inEscape = true;
|
||||
} else if (c == state->quoteChar) {
|
||||
state->inQuote = false;
|
||||
}
|
||||
} else {
|
||||
if (isDelimiter(c))
|
||||
return false;
|
||||
state->inQuote = isQuote(state->quoteChar = c);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
T string;
|
||||
// ### copies begin and end for performance, premature optimization?
|
||||
const_iterator begin;
|
||||
const_iterator end;
|
||||
const_iterator tokenBegin;
|
||||
const_iterator tokenEnd;
|
||||
T delimiters;
|
||||
T quotes;
|
||||
bool isDelim;
|
||||
bool returnDelimiters;
|
||||
bool returnQuotes;
|
||||
};
|
||||
|
||||
template <class T, class const_iterator>
|
||||
class QTokenizer {
|
||||
public:
|
||||
typedef typename T::value_type char_type;
|
||||
|
||||
/*!
|
||||
\class QTokenizer
|
||||
\inmodule QtNetwork
|
||||
\brief QTokenizer tokenizes Strings on QString, QByteArray,
|
||||
std::string or std::wstring
|
||||
|
||||
Example Usage:
|
||||
|
||||
\code
|
||||
QString str = ...;
|
||||
QByteArrayTokenizer tokenizer(str, "; ");
|
||||
tokenizer.setQuoteCharacters("\"'");
|
||||
tokenizer.setReturnDelimiters(true);
|
||||
while (tokenizer.hasNext()) {
|
||||
QByteArray token = tokenizer.next();
|
||||
bool isDelimiter = tokenizer.isDelimiter();
|
||||
...
|
||||
}
|
||||
\endcode
|
||||
|
||||
\param string The string to tokenize
|
||||
\param delimiters A string containing delimiters
|
||||
|
||||
\sa QStringTokenizer, QByteArrayTokenizer, StringTokenizer, WStringTokenizer
|
||||
*/
|
||||
QTokenizer(const T& string, const T& delimiters) {
|
||||
d.reset(new QTokenizerPrivate<T, const_iterator>(string, delimiters));
|
||||
}
|
||||
|
||||
/*!
|
||||
Whether or not to return delimiters as tokens
|
||||
\see setQuoteCharacters
|
||||
*/
|
||||
void setReturnDelimiters(bool enable) { d->returnDelimiters = enable; }
|
||||
|
||||
|
||||
/*!
|
||||
Sets characters that are considered to start and end quotes.
|
||||
|
||||
When between two characters considered a quote, delimiters will
|
||||
be ignored.
|
||||
|
||||
When between quotes, blackslash characters will cause the QTokenizer
|
||||
to skip the next character.
|
||||
|
||||
\param quotes Characters that delimit quotes.
|
||||
*/
|
||||
void setQuoteCharacters(const T& quotes) { d->quotes = quotes; }
|
||||
|
||||
|
||||
/*!
|
||||
Whether or not to return delimiters as tokens
|
||||
\see setQuoteCharacters
|
||||
*/
|
||||
void setReturnQuoteCharacters(bool enable) { d->returnQuotes = enable; }
|
||||
|
||||
|
||||
/*!
|
||||
Retrieve next token.
|
||||
|
||||
Returns true if there are more tokens, false otherwise.
|
||||
|
||||
\sa next()
|
||||
*/
|
||||
bool hasNext()
|
||||
{
|
||||
typename QTokenizerPrivate<T, const_iterator>::State state;
|
||||
d->isDelim = false;
|
||||
for (;;) {
|
||||
d->tokenBegin = d->tokenEnd;
|
||||
if (d->tokenEnd == d->end)
|
||||
return false;
|
||||
d->tokenEnd++;
|
||||
if (d->nextChar(&state, *d->tokenBegin))
|
||||
break;
|
||||
if (d->returnDelimiters) {
|
||||
d->isDelim = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
while (d->tokenEnd != d->end && d->nextChar(&state, *d->tokenEnd)) {
|
||||
d->tokenEnd++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Resets the tokenizer to the starting position.
|
||||
*/
|
||||
void reset() {
|
||||
d->tokenEnd = d->begin;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the current token is a delimiter,
|
||||
if one more more delimiting characters have been set.
|
||||
*/
|
||||
bool isDelimiter() const { return d->isDelim; }
|
||||
|
||||
/*!
|
||||
Returns the current token.
|
||||
|
||||
Use \c hasNext() to fetch the next token.
|
||||
*/
|
||||
T next() const {
|
||||
int len = d->tokenEnd-d->tokenBegin;
|
||||
const_iterator tmpStart = d->tokenBegin;
|
||||
if (!d->returnQuotes && len > 1 && d->isQuote(*d->tokenBegin)) {
|
||||
tmpStart++;
|
||||
len -= 2;
|
||||
}
|
||||
return T(tmpStart, len);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class QStringTokenizer;
|
||||
QSharedPointer<QTokenizerPrivate<T, const_iterator> > d;
|
||||
};
|
||||
|
||||
class QStringTokenizer : public QTokenizer<QString, QString::const_iterator> {
|
||||
public:
|
||||
QStringTokenizer(const QString &string, const QString &delim) :
|
||||
QTokenizer<QString, QString::const_iterator>(string, delim) {}
|
||||
/**
|
||||
* @brief Like \see next(), but returns a lightweight string reference
|
||||
* @return A reference to the token within the string
|
||||
*/
|
||||
QStringRef stringRef() {
|
||||
int begin = d->tokenBegin-d->begin;
|
||||
int end = d->tokenEnd-d->tokenBegin;
|
||||
if (!d->returnQuotes && d->isQuote(*d->tokenBegin)) {
|
||||
begin++;
|
||||
end -= 2;
|
||||
}
|
||||
return QStringRef(&d->string, begin, end);
|
||||
}
|
||||
};
|
||||
|
||||
typedef QTokenizer<QByteArray, QByteArray::const_iterator> QByteArrayTokenizer;
|
||||
typedef QTokenizer<std::string, std::string::const_iterator> StringTokenizer;
|
||||
typedef QTokenizer<std::wstring, std::wstring::const_iterator> WStringTokenizer;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // TOKENIZER_H
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = test
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
TEMPLATE = app
|
||||
QT += testlib
|
||||
CONFIG += testlib
|
||||
TARGET = test
|
||||
INCLUDEPATH += . ..
|
||||
|
||||
# Input
|
||||
SOURCES += tst_qtokenizer.cpp
|
||||
@@ -1,139 +0,0 @@
|
||||
#include <QtTest>
|
||||
|
||||
#include "qtokenizer.h"
|
||||
|
||||
namespace {
|
||||
const QString simple = QLatin1String("A simple tokenizer test");
|
||||
const QString quoted = QLatin1String("\"Wait for me!\" he shouted");
|
||||
}
|
||||
|
||||
class TestTokenizer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void tokenizeQStringSimple() {
|
||||
QStringTokenizer tokenizer(simple, " ");
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("A"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("simple"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("tokenizer"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("test"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), false);
|
||||
}
|
||||
|
||||
void tokenizeQStringSimpleRef() {
|
||||
QStringTokenizer tokenizer(simple, " ");
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QVERIFY(tokenizer.stringRef() == QLatin1String("A"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QVERIFY(tokenizer.stringRef() == QLatin1String("simple"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QVERIFY(tokenizer.stringRef() == QLatin1String("tokenizer"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QVERIFY(tokenizer.stringRef() == QLatin1String("test"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), false);
|
||||
}
|
||||
|
||||
void tokenizeQStringQuoted() {
|
||||
const QString multiquote(QLatin1String("\"'Billy - the Kid' is dead!\""));
|
||||
QStringTokenizer tokenizer(multiquote, " -");
|
||||
tokenizer.setQuoteCharacters("\"");
|
||||
tokenizer.setReturnQuoteCharacters(true);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("\"'Billy - the Kid' is dead!\""));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), false);
|
||||
}
|
||||
|
||||
void tokenizeQStringSkipQuotes() {
|
||||
const QString multiquote(QLatin1String("\"'Billy - the Kid' is dead!\""));
|
||||
QStringTokenizer tokenizer(multiquote, " ");
|
||||
tokenizer.setQuoteCharacters("\"");
|
||||
tokenizer.setReturnQuoteCharacters(false);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("'Billy - the Kid' is dead!"));
|
||||
QCOMPARE(tokenizer.stringRef().toString(), QLatin1String("'Billy - the Kid' is dead!"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), false);
|
||||
}
|
||||
|
||||
|
||||
void tokenizeQStringWithDelims() {
|
||||
const QString delims(QLatin1String("I;Insist,On/a-Delimiter"));
|
||||
QStringTokenizer tokenizer(delims, ";,/-");
|
||||
tokenizer.setReturnDelimiters(true);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), false);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), true);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), false);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), true);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), false);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), true);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), false);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), true);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.isDelimiter(), false);
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), false);
|
||||
}
|
||||
|
||||
void resetTokenizer() {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
QStringTokenizer tokenizer(simple, " ");
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("A"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("simple"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("tokenizer"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), true);
|
||||
QCOMPARE(tokenizer.next(), QLatin1String("test"));
|
||||
|
||||
QCOMPARE(tokenizer.hasNext(), false);
|
||||
|
||||
tokenizer.reset();
|
||||
}
|
||||
}
|
||||
|
||||
// ### QByteArray, other types
|
||||
};
|
||||
|
||||
QTEST_APPLESS_MAIN(TestTokenizer)
|
||||
|
||||
#include "tst_qtokenizer.moc"
|
||||
|
||||
externo
+8765
-13838
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
externo
+46
-336
@@ -111,9 +111,9 @@ extern "C" {
|
||||
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
||||
** [sqlite_version()] and [sqlite_source_id()].
|
||||
*/
|
||||
#define SQLITE_VERSION "3.12.1"
|
||||
#define SQLITE_VERSION_NUMBER 3012001
|
||||
#define SQLITE_SOURCE_ID "2016-04-08 15:09:49 fe7d3b75fe1bde41511b323925af8ae1b910bc4d"
|
||||
#define SQLITE_VERSION "3.9.1"
|
||||
#define SQLITE_VERSION_NUMBER 3009001
|
||||
#define SQLITE_SOURCE_ID "2015-10-16 17:31:12 767c1727fec4ce11b83f25b3f1bfcfe68a2c8b02"
|
||||
|
||||
/*
|
||||
** CAPI3REF: Run-Time Library Version Numbers
|
||||
@@ -347,7 +347,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
|
||||
** from [sqlite3_malloc()] and passed back through the 5th parameter.
|
||||
** To avoid memory leaks, the application should invoke [sqlite3_free()]
|
||||
** on error message strings returned through the 5th parameter of
|
||||
** sqlite3_exec() after the error message string is no longer needed.
|
||||
** of sqlite3_exec() after the error message string is no longer needed.
|
||||
** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
|
||||
** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
|
||||
** NULL before returning.
|
||||
@@ -478,7 +478,6 @@ SQLITE_API int SQLITE_STDCALL sqlite3_exec(
|
||||
#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
|
||||
#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
|
||||
#define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8))
|
||||
#define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8))
|
||||
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
|
||||
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
|
||||
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
|
||||
@@ -794,13 +793,8 @@ struct sqlite3_io_methods {
|
||||
** <li>[[SQLITE_FCNTL_FILE_POINTER]]
|
||||
** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
|
||||
** to the [sqlite3_file] object associated with a particular database
|
||||
** connection. See also [SQLITE_FCNTL_JOURNAL_POINTER].
|
||||
**
|
||||
** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
|
||||
** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
|
||||
** to the [sqlite3_file] object associated with the journal file (either
|
||||
** the [rollback journal] or the [write-ahead log]) for a particular database
|
||||
** connection. See also [SQLITE_FCNTL_FILE_POINTER].
|
||||
** connection. See the [sqlite3_file_control()] documentation for
|
||||
** additional information.
|
||||
**
|
||||
** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
|
||||
** No longer in use.
|
||||
@@ -887,15 +881,6 @@ struct sqlite3_io_methods {
|
||||
** pointer in case this file-control is not implemented. This file-control
|
||||
** is intended for diagnostic use only.
|
||||
**
|
||||
** <li>[[SQLITE_FCNTL_VFS_POINTER]]
|
||||
** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
|
||||
** [VFSes] currently in use. ^(The argument X in
|
||||
** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
|
||||
** of type "[sqlite3_vfs] **". This opcodes will set *X
|
||||
** to a pointer to the top-level VFS.)^
|
||||
** ^When there are multiple VFS shims in the stack, this opcode finds the
|
||||
** upper-most shim only.
|
||||
**
|
||||
** <li>[[SQLITE_FCNTL_PRAGMA]]
|
||||
** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
|
||||
** file control is sent to the open [sqlite3_file] object corresponding
|
||||
@@ -1014,8 +999,6 @@ struct sqlite3_io_methods {
|
||||
#define SQLITE_FCNTL_WAL_BLOCK 24
|
||||
#define SQLITE_FCNTL_ZIPVFS 25
|
||||
#define SQLITE_FCNTL_RBU 26
|
||||
#define SQLITE_FCNTL_VFS_POINTER 27
|
||||
#define SQLITE_FCNTL_JOURNAL_POINTER 28
|
||||
|
||||
/* deprecated names */
|
||||
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
|
||||
@@ -1228,7 +1211,7 @@ struct sqlite3_vfs {
|
||||
const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
|
||||
/*
|
||||
** The methods above are in versions 1 through 3 of the sqlite_vfs object.
|
||||
** New fields may be appended in future versions. The iVersion
|
||||
** New fields may be appended in figure versions. The iVersion
|
||||
** value will increment whenever this happens.
|
||||
*/
|
||||
};
|
||||
@@ -1615,34 +1598,29 @@ struct sqlite3_mem_methods {
|
||||
** </dd>
|
||||
**
|
||||
** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
|
||||
** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
|
||||
** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a static memory buffer
|
||||
** that SQLite can use for the database page cache with the default page
|
||||
** cache implementation.
|
||||
** This configuration option is a no-op if an application-define page
|
||||
** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
|
||||
** This configuration should not be used if an application-define page
|
||||
** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]
|
||||
** configuration option.
|
||||
** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
|
||||
** 8-byte aligned memory (pMem), the size of each page cache line (sz),
|
||||
** and the number of cache lines (N).
|
||||
** 8-byte aligned
|
||||
** memory, the size of each page buffer (sz), and the number of pages (N).
|
||||
** The sz argument should be the size of the largest database page
|
||||
** (a power of two between 512 and 65536) plus some extra bytes for each
|
||||
** page header. ^The number of extra bytes needed by the page header
|
||||
** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].
|
||||
** can be determined using the [SQLITE_CONFIG_PCACHE_HDRSZ] option
|
||||
** to [sqlite3_config()].
|
||||
** ^It is harmless, apart from the wasted memory,
|
||||
** for the sz parameter to be larger than necessary. The pMem
|
||||
** argument must be either a NULL pointer or a pointer to an 8-byte
|
||||
** aligned block of memory of at least sz*N bytes, otherwise
|
||||
** subsequent behavior is undefined.
|
||||
** ^When pMem is not NULL, SQLite will strive to use the memory provided
|
||||
** to satisfy page cache needs, falling back to [sqlite3_malloc()] if
|
||||
** a page cache line is larger than sz bytes or if all of the pMem buffer
|
||||
** is exhausted.
|
||||
** ^If pMem is NULL and N is non-zero, then each database connection
|
||||
** does an initial bulk allocation for page cache memory
|
||||
** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or
|
||||
** of -1024*N bytes if N is negative, . ^If additional
|
||||
** page cache memory is needed beyond what is provided by the initial
|
||||
** allocation, then SQLite goes to [sqlite3_malloc()] separately for each
|
||||
** additional cache line. </dd>
|
||||
** for the sz parameter to be larger than necessary. The first
|
||||
** argument should pointer to an 8-byte aligned block of memory that
|
||||
** is at least sz*N bytes of memory, otherwise subsequent behavior is
|
||||
** undefined.
|
||||
** ^SQLite will use the memory provided by the first argument to satisfy its
|
||||
** memory needs for the first N pages that it adds to cache. ^If additional
|
||||
** page cache memory is needed beyond what is provided by this option, then
|
||||
** SQLite goes to [sqlite3_malloc()] for the additional storage space.</dd>
|
||||
**
|
||||
** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
|
||||
** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer
|
||||
@@ -1820,20 +1798,6 @@ struct sqlite3_mem_methods {
|
||||
** is enabled (using the [PRAGMA threads] command) and the amount of content
|
||||
** to be sorted exceeds the page size times the minimum of the
|
||||
** [PRAGMA cache_size] setting and this value.
|
||||
**
|
||||
** [[SQLITE_CONFIG_STMTJRNL_SPILL]]
|
||||
** <dt>SQLITE_CONFIG_STMTJRNL_SPILL
|
||||
** <dd>^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which
|
||||
** becomes the [statement journal] spill-to-disk threshold.
|
||||
** [Statement journals] are held in memory until their size (in bytes)
|
||||
** exceeds this threshold, at which point they are written to disk.
|
||||
** Or if the threshold is -1, statement journals are always held
|
||||
** exclusively in memory.
|
||||
** Since many statement journals never become large, setting the spill
|
||||
** threshold to a value such as 64KiB can greatly reduce the amount of
|
||||
** I/O required to support statement rollback.
|
||||
** The default value for this setting is controlled by the
|
||||
** [SQLITE_STMTJRNL_SPILL] compile-time option.
|
||||
** </dl>
|
||||
*/
|
||||
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
|
||||
@@ -1861,7 +1825,6 @@ struct sqlite3_mem_methods {
|
||||
#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
|
||||
#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
|
||||
#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
|
||||
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
|
||||
|
||||
/*
|
||||
** CAPI3REF: Database Connection Configuration Options
|
||||
@@ -1919,25 +1882,11 @@ struct sqlite3_mem_methods {
|
||||
** following this call. The second parameter may be a NULL pointer, in
|
||||
** which case the trigger setting is not reported back. </dd>
|
||||
**
|
||||
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
|
||||
** <dd> ^This option is used to enable or disable the two-argument
|
||||
** version of the [fts3_tokenizer()] function which is part of the
|
||||
** [FTS3] full-text search engine extension.
|
||||
** There should be two additional arguments.
|
||||
** The first argument is an integer which is 0 to disable fts3_tokenizer() or
|
||||
** positive to enable fts3_tokenizer() or negative to leave the setting
|
||||
** unchanged.
|
||||
** The second parameter is a pointer to an integer into which
|
||||
** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
|
||||
** following this call. The second parameter may be a NULL pointer, in
|
||||
** which case the new setting is not reported back. </dd>
|
||||
**
|
||||
** </dl>
|
||||
*/
|
||||
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
|
||||
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
|
||||
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
|
||||
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
|
||||
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
|
||||
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
|
||||
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
|
||||
|
||||
|
||||
/*
|
||||
@@ -4440,8 +4389,8 @@ SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_subtype(sqlite3_value*);
|
||||
** previously obtained from [sqlite3_value_dup()]. ^If V is a NULL pointer
|
||||
** then sqlite3_value_free(V) is a harmless no-op.
|
||||
*/
|
||||
SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_value_dup(const sqlite3_value*);
|
||||
SQLITE_API void SQLITE_STDCALL sqlite3_value_free(sqlite3_value*);
|
||||
SQLITE_API SQLITE_EXPERIMENTAL sqlite3_value *SQLITE_STDCALL sqlite3_value_dup(const sqlite3_value*);
|
||||
SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_value_free(sqlite3_value*);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Obtain Aggregate Function Context
|
||||
@@ -5660,17 +5609,6 @@ struct sqlite3_module {
|
||||
** ^Information about the ORDER BY clause is stored in aOrderBy[].
|
||||
** ^Each term of aOrderBy records a column of the ORDER BY clause.
|
||||
**
|
||||
** The colUsed field indicates which columns of the virtual table may be
|
||||
** required by the current scan. Virtual table columns are numbered from
|
||||
** zero in the order in which they appear within the CREATE TABLE statement
|
||||
** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),
|
||||
** the corresponding bit is set within the colUsed mask if the column may be
|
||||
** required by SQLite. If the table has at least 64 columns and any column
|
||||
** to the right of the first 63 is required, then bit 63 of colUsed is also
|
||||
** set. In other words, column iCol may be required if the expression
|
||||
** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to
|
||||
** non-zero.
|
||||
**
|
||||
** The [xBestIndex] method must fill aConstraintUsage[] with information
|
||||
** about what parameters to pass to xFilter. ^If argvIndex>0 then
|
||||
** the right-hand side of the corresponding aConstraint[] is evaluated
|
||||
@@ -5726,7 +5664,7 @@ struct sqlite3_index_info {
|
||||
/* Inputs */
|
||||
int nConstraint; /* Number of entries in aConstraint */
|
||||
struct sqlite3_index_constraint {
|
||||
int iColumn; /* Column constrained. -1 for ROWID */
|
||||
int iColumn; /* Column on left-hand side of constraint */
|
||||
unsigned char op; /* Constraint operator */
|
||||
unsigned char usable; /* True if this constraint is usable */
|
||||
int iTermOffset; /* Used internally - xBestIndex should ignore */
|
||||
@@ -5750,8 +5688,6 @@ struct sqlite3_index_info {
|
||||
sqlite3_int64 estimatedRows; /* Estimated number of rows returned */
|
||||
/* Fields below are only available in SQLite 3.9.0 and later */
|
||||
int idxFlags; /* Mask of SQLITE_INDEX_SCAN_* flags */
|
||||
/* Fields below are only available in SQLite 3.10.0 and later */
|
||||
sqlite3_uint64 colUsed; /* Input: Mask of columns used by statement */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -5767,15 +5703,12 @@ struct sqlite3_index_info {
|
||||
** an operator that is part of a constraint term in the wHERE clause of
|
||||
** a query that uses a [virtual table].
|
||||
*/
|
||||
#define SQLITE_INDEX_CONSTRAINT_EQ 2
|
||||
#define SQLITE_INDEX_CONSTRAINT_GT 4
|
||||
#define SQLITE_INDEX_CONSTRAINT_LE 8
|
||||
#define SQLITE_INDEX_CONSTRAINT_LT 16
|
||||
#define SQLITE_INDEX_CONSTRAINT_GE 32
|
||||
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
|
||||
#define SQLITE_INDEX_CONSTRAINT_LIKE 65
|
||||
#define SQLITE_INDEX_CONSTRAINT_GLOB 66
|
||||
#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
|
||||
#define SQLITE_INDEX_CONSTRAINT_EQ 2
|
||||
#define SQLITE_INDEX_CONSTRAINT_GT 4
|
||||
#define SQLITE_INDEX_CONSTRAINT_LE 8
|
||||
#define SQLITE_INDEX_CONSTRAINT_LT 16
|
||||
#define SQLITE_INDEX_CONSTRAINT_GE 32
|
||||
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
|
||||
|
||||
/*
|
||||
** CAPI3REF: Register A Virtual Table Implementation
|
||||
@@ -6639,8 +6572,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_status64(
|
||||
** The value written into the *pCurrent parameter is undefined.</dd>)^
|
||||
**
|
||||
** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
|
||||
** <dd>The *pHighwater parameter records the deepest parser stack.
|
||||
** The *pCurrent value is undefined. The *pHighwater value is only
|
||||
** <dd>This parameter records the deepest parser stack. It is only
|
||||
** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
|
||||
** </dl>
|
||||
**
|
||||
@@ -7426,43 +7358,18 @@ SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
|
||||
/*
|
||||
** CAPI3REF: String Globbing
|
||||
*
|
||||
** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if
|
||||
** string X matches the [GLOB] pattern P.
|
||||
** ^The definition of [GLOB] pattern matching used in
|
||||
** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
|
||||
** the glob pattern P, and it returns non-zero if string X does not match
|
||||
** the glob pattern P. ^The definition of glob pattern matching used in
|
||||
** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the
|
||||
** SQL dialect understood by SQLite. ^The [sqlite3_strglob(P,X)] function
|
||||
** is case sensitive.
|
||||
** SQL dialect used by SQLite. ^The sqlite3_strglob(P,X) function is case
|
||||
** sensitive.
|
||||
**
|
||||
** Note that this routine returns zero on a match and non-zero if the strings
|
||||
** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
|
||||
**
|
||||
** See also: [sqlite3_strlike()].
|
||||
*/
|
||||
SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
|
||||
|
||||
/*
|
||||
** CAPI3REF: String LIKE Matching
|
||||
*
|
||||
** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if
|
||||
** string X matches the [LIKE] pattern P with escape character E.
|
||||
** ^The definition of [LIKE] pattern matching used in
|
||||
** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E"
|
||||
** operator in the SQL dialect understood by SQLite. ^For "X LIKE P" without
|
||||
** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.
|
||||
** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case
|
||||
** insensitive - equivalent upper and lower case ASCII characters match
|
||||
** one another.
|
||||
**
|
||||
** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though
|
||||
** only ASCII characters are case folded.
|
||||
**
|
||||
** Note that this routine returns zero on a match and non-zero if the strings
|
||||
** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
|
||||
**
|
||||
** See also: [sqlite3_strglob()].
|
||||
*/
|
||||
SQLITE_API int SQLITE_STDCALL sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Error Logging Interface
|
||||
**
|
||||
@@ -7518,7 +7425,7 @@ SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...)
|
||||
** previously registered write-ahead log callback. ^Note that the
|
||||
** [sqlite3_wal_autocheckpoint()] interface and the
|
||||
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
|
||||
** overwrite any prior [sqlite3_wal_hook()] settings.
|
||||
** those overwrite any prior [sqlite3_wal_hook()] settings.
|
||||
*/
|
||||
SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
|
||||
sqlite3*,
|
||||
@@ -7883,145 +7790,6 @@ SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
|
||||
*/
|
||||
SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Flush caches to disk mid-transaction
|
||||
**
|
||||
** ^If a write-transaction is open on [database connection] D when the
|
||||
** [sqlite3_db_cacheflush(D)] interface invoked, any dirty
|
||||
** pages in the pager-cache that are not currently in use are written out
|
||||
** to disk. A dirty page may be in use if a database cursor created by an
|
||||
** active SQL statement is reading from it, or if it is page 1 of a database
|
||||
** file (page 1 is always "in use"). ^The [sqlite3_db_cacheflush(D)]
|
||||
** interface flushes caches for all schemas - "main", "temp", and
|
||||
** any [attached] databases.
|
||||
**
|
||||
** ^If this function needs to obtain extra database locks before dirty pages
|
||||
** can be flushed to disk, it does so. ^If those locks cannot be obtained
|
||||
** immediately and there is a busy-handler callback configured, it is invoked
|
||||
** in the usual manner. ^If the required lock still cannot be obtained, then
|
||||
** the database is skipped and an attempt made to flush any dirty pages
|
||||
** belonging to the next (if any) database. ^If any databases are skipped
|
||||
** because locks cannot be obtained, but no other error occurs, this
|
||||
** function returns SQLITE_BUSY.
|
||||
**
|
||||
** ^If any other error occurs while flushing dirty pages to disk (for
|
||||
** example an IO error or out-of-memory condition), then processing is
|
||||
** abandoned and an SQLite [error code] is returned to the caller immediately.
|
||||
**
|
||||
** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.
|
||||
**
|
||||
** ^This function does not set the database handle error code or message
|
||||
** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.
|
||||
*/
|
||||
SQLITE_API int SQLITE_STDCALL sqlite3_db_cacheflush(sqlite3*);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Low-level system error code
|
||||
**
|
||||
** ^Attempt to return the underlying operating system error code or error
|
||||
** number that caused the most reason I/O error or failure to open a file.
|
||||
** The return value is OS-dependent. For example, on unix systems, after
|
||||
** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be
|
||||
** called to get back the underlying "errno" that caused the problem, such
|
||||
** as ENOSPC, EAUTH, EISDIR, and so forth.
|
||||
*/
|
||||
SQLITE_API int SQLITE_STDCALL sqlite3_system_errno(sqlite3*);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Database Snapshot
|
||||
** KEYWORDS: {snapshot}
|
||||
** EXPERIMENTAL
|
||||
**
|
||||
** An instance of the snapshot object records the state of a [WAL mode]
|
||||
** database for some specific point in history.
|
||||
**
|
||||
** In [WAL mode], multiple [database connections] that are open on the
|
||||
** same database file can each be reading a different historical version
|
||||
** of the database file. When a [database connection] begins a read
|
||||
** transaction, that connection sees an unchanging copy of the database
|
||||
** as it existed for the point in time when the transaction first started.
|
||||
** Subsequent changes to the database from other connections are not seen
|
||||
** by the reader until a new read transaction is started.
|
||||
**
|
||||
** The sqlite3_snapshot object records state information about an historical
|
||||
** version of the database file so that it is possible to later open a new read
|
||||
** transaction that sees that historical version of the database rather than
|
||||
** the most recent version.
|
||||
**
|
||||
** The constructor for this object is [sqlite3_snapshot_get()]. The
|
||||
** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
|
||||
** to an historical snapshot (if possible). The destructor for
|
||||
** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
|
||||
*/
|
||||
typedef struct sqlite3_snapshot sqlite3_snapshot;
|
||||
|
||||
/*
|
||||
** CAPI3REF: Record A Database Snapshot
|
||||
** EXPERIMENTAL
|
||||
**
|
||||
** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
|
||||
** new [sqlite3_snapshot] object that records the current state of
|
||||
** schema S in database connection D. ^On success, the
|
||||
** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
|
||||
** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
|
||||
** ^If schema S of [database connection] D is not a [WAL mode] database
|
||||
** that is in a read transaction, then [sqlite3_snapshot_get(D,S,P)]
|
||||
** leaves the *P value unchanged and returns an appropriate [error code].
|
||||
**
|
||||
** The [sqlite3_snapshot] object returned from a successful call to
|
||||
** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
|
||||
** to avoid a memory leak.
|
||||
**
|
||||
** The [sqlite3_snapshot_get()] interface is only available when the
|
||||
** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
|
||||
*/
|
||||
SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_get(
|
||||
sqlite3 *db,
|
||||
const char *zSchema,
|
||||
sqlite3_snapshot **ppSnapshot
|
||||
);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Start a read transaction on an historical snapshot
|
||||
** EXPERIMENTAL
|
||||
**
|
||||
** ^The [sqlite3_snapshot_open(D,S,P)] interface attempts to move the
|
||||
** read transaction that is currently open on schema S of
|
||||
** [database connection] D so that it refers to historical [snapshot] P.
|
||||
** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
|
||||
** or an appropriate [error code] if it fails.
|
||||
**
|
||||
** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
|
||||
** the first operation, apart from other sqlite3_snapshot_open() calls,
|
||||
** following the [BEGIN] that starts a new read transaction.
|
||||
** ^A [snapshot] will fail to open if it has been overwritten by a
|
||||
** [checkpoint].
|
||||
** ^A [snapshot] will fail to open if the database connection D has not
|
||||
** previously completed at least one read operation against the database
|
||||
** file. (Hint: Run "[PRAGMA application_id]" against a newly opened
|
||||
** database connection in order to make it ready to use snapshots.)
|
||||
**
|
||||
** The [sqlite3_snapshot_open()] interface is only available when the
|
||||
** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
|
||||
*/
|
||||
SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_open(
|
||||
sqlite3 *db,
|
||||
const char *zSchema,
|
||||
sqlite3_snapshot *pSnapshot
|
||||
);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Destroy a snapshot
|
||||
** EXPERIMENTAL
|
||||
**
|
||||
** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
|
||||
** The application must eventually free every [sqlite3_snapshot] object
|
||||
** using this routine to avoid a memory leak.
|
||||
**
|
||||
** The [sqlite3_snapshot_free()] interface is only available when the
|
||||
** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
|
||||
*/
|
||||
SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot*);
|
||||
|
||||
/*
|
||||
** Undo the hack that converts floating point types to integer for
|
||||
@@ -8238,9 +8006,6 @@ struct Fts5PhraseIter {
|
||||
** an OOM condition or IO error), an appropriate SQLite error code is
|
||||
** returned.
|
||||
**
|
||||
** This function may be quite inefficient if used with an FTS5 table
|
||||
** created with the "columnsize=0" option.
|
||||
**
|
||||
** xColumnText:
|
||||
** This function attempts to retrieve the text of column iCol of the
|
||||
** current document. If successful, (*pz) is set to point to a buffer
|
||||
@@ -8261,29 +8026,15 @@ struct Fts5PhraseIter {
|
||||
** the query within the current row. Return SQLITE_OK if successful, or
|
||||
** an error code (i.e. SQLITE_NOMEM) if an error occurs.
|
||||
**
|
||||
** This API can be quite slow if used with an FTS5 table created with the
|
||||
** "detail=none" or "detail=column" option. If the FTS5 table is created
|
||||
** with either "detail=none" or "detail=column" and "content=" option
|
||||
** (i.e. if it is a contentless table), then this API always returns 0.
|
||||
**
|
||||
** xInst:
|
||||
** Query for the details of phrase match iIdx within the current row.
|
||||
** Phrase matches are numbered starting from zero, so the iIdx argument
|
||||
** should be greater than or equal to zero and smaller than the value
|
||||
** output by xInstCount().
|
||||
**
|
||||
** Usually, output parameter *piPhrase is set to the phrase number, *piCol
|
||||
** to the column in which it occurs and *piOff the token offset of the
|
||||
** first token of the phrase. The exception is if the table was created
|
||||
** with the offsets=0 option specified. In this case *piOff is always
|
||||
** set to -1.
|
||||
**
|
||||
** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM)
|
||||
** if an error occurs.
|
||||
**
|
||||
** This API can be quite slow if used with an FTS5 table created with the
|
||||
** "detail=none" or "detail=column" option.
|
||||
**
|
||||
** xRowid:
|
||||
** Returns the rowid of the current row.
|
||||
**
|
||||
@@ -8367,7 +8118,7 @@ struct Fts5PhraseIter {
|
||||
** Fts5PhraseIter iter;
|
||||
** int iCol, iOff;
|
||||
** for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);
|
||||
** iCol>=0;
|
||||
** iOff>=0;
|
||||
** pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)
|
||||
** ){
|
||||
** // An instance of phrase iPhrase at offset iOff of column iCol
|
||||
@@ -8375,51 +8126,13 @@ struct Fts5PhraseIter {
|
||||
**
|
||||
** The Fts5PhraseIter structure is defined above. Applications should not
|
||||
** modify this structure directly - it should only be used as shown above
|
||||
** with the xPhraseFirst() and xPhraseNext() API methods (and by
|
||||
** xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).
|
||||
**
|
||||
** This API can be quite slow if used with an FTS5 table created with the
|
||||
** "detail=none" or "detail=column" option. If the FTS5 table is created
|
||||
** with either "detail=none" or "detail=column" and "content=" option
|
||||
** (i.e. if it is a contentless table), then this API always iterates
|
||||
** through an empty set (all calls to xPhraseFirst() set iCol to -1).
|
||||
** with the xPhraseFirst() and xPhraseNext() API methods.
|
||||
**
|
||||
** xPhraseNext()
|
||||
** See xPhraseFirst above.
|
||||
**
|
||||
** xPhraseFirstColumn()
|
||||
** This function and xPhraseNextColumn() are similar to the xPhraseFirst()
|
||||
** and xPhraseNext() APIs described above. The difference is that instead
|
||||
** of iterating through all instances of a phrase in the current row, these
|
||||
** APIs are used to iterate through the set of columns in the current row
|
||||
** that contain one or more instances of a specified phrase. For example:
|
||||
**
|
||||
** Fts5PhraseIter iter;
|
||||
** int iCol;
|
||||
** for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);
|
||||
** iCol>=0;
|
||||
** pApi->xPhraseNextColumn(pFts, &iter, &iCol)
|
||||
** ){
|
||||
** // Column iCol contains at least one instance of phrase iPhrase
|
||||
** }
|
||||
**
|
||||
** This API can be quite slow if used with an FTS5 table created with the
|
||||
** "detail=none" option. If the FTS5 table is created with either
|
||||
** "detail=none" "content=" option (i.e. if it is a contentless table),
|
||||
** then this API always iterates through an empty set (all calls to
|
||||
** xPhraseFirstColumn() set iCol to -1).
|
||||
**
|
||||
** The information accessed using this API and its companion
|
||||
** xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext
|
||||
** (or xInst/xInstCount). The chief advantage of this API is that it is
|
||||
** significantly more efficient than those alternatives when used with
|
||||
** "detail=column" tables.
|
||||
**
|
||||
** xPhraseNextColumn()
|
||||
** See xPhraseFirstColumn above.
|
||||
*/
|
||||
struct Fts5ExtensionApi {
|
||||
int iVersion; /* Currently always set to 3 */
|
||||
int iVersion; /* Currently always set to 1 */
|
||||
|
||||
void *(*xUserData)(Fts5Context*);
|
||||
|
||||
@@ -8449,11 +8162,8 @@ struct Fts5ExtensionApi {
|
||||
int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));
|
||||
void *(*xGetAuxdata)(Fts5Context*, int bClear);
|
||||
|
||||
int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);
|
||||
void (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);
|
||||
void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);
|
||||
|
||||
int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
|
||||
void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -5,32 +5,10 @@ set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
set(synclib_NAME ${APPLICATION_EXECUTABLE}sync)
|
||||
|
||||
include(QtVersionAbstraction)
|
||||
setup_qt()
|
||||
if(HAVE_QT5 AND NOT BUILD_WITH_QT4)
|
||||
if (${Qt5Core_VERSION_MAJOR} EQUAL "5")
|
||||
if (${Qt5Core_VERSION_MINOR} EQUAL "4" OR ${Qt5Core_VERSION_MINOR} GREATER 4)
|
||||
else()
|
||||
message(STATUS "If possible compile me with Qt 5.4 or higher.")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "If possible compile me with Qt 5.4 or higher.")
|
||||
endif()
|
||||
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
|
||||
if(NOT TOKEN_AUTH_ONLY)
|
||||
if (Qt5Core_DIR)
|
||||
find_package(Qt5Keychain REQUIRED)
|
||||
else()
|
||||
find_package(QtKeychain REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(libsync)
|
||||
if (NOT BUILD_LIBRARIES_ONLY)
|
||||
add_subdirectory(gui)
|
||||
|
||||
@@ -17,9 +17,6 @@ include_directories(${CMAKE_SOURCE_DIR}/csync/src
|
||||
${CMAKE_BINARY_DIR}/csync/src
|
||||
)
|
||||
|
||||
# Need tokenizer for netrc parser
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/qtokenizer)
|
||||
|
||||
if(NOT BUILD_LIBRARIES_ONLY)
|
||||
add_executable(${cmd_NAME} ${cmd_SRC})
|
||||
qt5_use_modules(${cmd_NAME} Network Sql)
|
||||
|
||||
+50
-24
@@ -153,7 +153,7 @@ void help()
|
||||
std::cout << " Proxy is http://server:port" << std::endl;
|
||||
std::cout << " --trust Trust the SSL certification." << std::endl;
|
||||
std::cout << " --exclude [file] Exclude list file" << std::endl;
|
||||
std::cout << " --unsyncedfolders [file] File containing the list of unsynced remote folders (selective sync)" << std::endl;
|
||||
std::cout << " --unsyncedfolders [file] File containing the list of unsynced folders (selective sync)" << std::endl;
|
||||
std::cout << " --user, -u [name] Use [name] as the login name" << std::endl;
|
||||
std::cout << " --password, -p [pass] Use [pass] as password" << std::endl;
|
||||
std::cout << " -n Use netrc (5) for login" << std::endl;
|
||||
@@ -249,23 +249,23 @@ void parseOptions( const QStringList& app_args, CmdOptions *options )
|
||||
*/
|
||||
void selectiveSyncFixup(OCC::SyncJournalDb *journal, const QStringList &newList)
|
||||
{
|
||||
if (!journal->exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SqlDatabase db;
|
||||
if (!db.openOrCreateReadWrite(journal->databaseFilePath())) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
|
||||
auto oldBlackListSet = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok).toSet();
|
||||
if( ok ) {
|
||||
auto blackListSet = newList.toSet();
|
||||
auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
|
||||
foreach(const auto &it, changes) {
|
||||
journal->avoidReadFromDbOnNextSync(it);
|
||||
}
|
||||
|
||||
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, newList);
|
||||
auto oldBlackListSet = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList).toSet();
|
||||
auto blackListSet = newList.toSet();
|
||||
auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
|
||||
foreach(const auto &it, changes) {
|
||||
journal->avoidReadFromDbOnNextSync(it);
|
||||
}
|
||||
|
||||
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, newList);
|
||||
}
|
||||
|
||||
|
||||
@@ -385,10 +385,26 @@ int main(int argc, char **argv) {
|
||||
int restartCount = 0;
|
||||
restart_sync:
|
||||
|
||||
CSYNC *_csync_ctx;
|
||||
|
||||
if( csync_create( &_csync_ctx, options.source_dir.toUtf8(),
|
||||
remUrl.constData()) < 0 ) {
|
||||
qFatal("Unable to create csync-context!");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
csync_set_log_level(options.silent ? 1 : 11);
|
||||
|
||||
opts = &options;
|
||||
|
||||
if( csync_init( _csync_ctx ) < 0 ) {
|
||||
qFatal("Could not initialize csync!");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// ignore hidden files or not
|
||||
_csync_ctx->ignore_hidden_files = options.ignoreHiddenFiles;
|
||||
|
||||
if( !options.proxy.isNull() ) {
|
||||
QString host;
|
||||
int port = 0;
|
||||
@@ -415,6 +431,18 @@ restart_sync:
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude lists
|
||||
QString systemExcludeListFn = ConfigFile::excludeFileFromSystem();
|
||||
int loadedSystemExcludeList = false;
|
||||
if (!systemExcludeListFn.isEmpty()) {
|
||||
loadedSystemExcludeList = csync_add_exclude_list(_csync_ctx, systemExcludeListFn.toLocal8Bit());
|
||||
}
|
||||
|
||||
int loadedUserExcludeList = false;
|
||||
if (!options.exclude.isEmpty()) {
|
||||
loadedUserExcludeList = csync_add_exclude_list(_csync_ctx, options.exclude.toLocal8Bit());
|
||||
}
|
||||
|
||||
QStringList selectiveSyncList;
|
||||
if (!options.unsyncedfolders.isEmpty()) {
|
||||
QFile f(options.unsyncedfolders);
|
||||
@@ -432,32 +460,30 @@ restart_sync:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (loadedSystemExcludeList != 0 && loadedUserExcludeList != 0) {
|
||||
// Always make sure at least one list has been loaded
|
||||
qFatal("Cannot load system exclude list or list supplied via --exclude");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Cmd cmd;
|
||||
SyncJournalDb db(options.source_dir);
|
||||
if (!selectiveSyncList.empty()) {
|
||||
selectiveSyncFixup(&db, selectiveSyncList);
|
||||
}
|
||||
|
||||
SyncEngine engine(account, options.source_dir, QUrl(options.target_url), folder, &db);
|
||||
engine.setIgnoreHiddenFiles(options.ignoreHiddenFiles);
|
||||
SyncEngine engine(account, _csync_ctx, options.source_dir, QUrl(options.target_url).path(), folder, &db);
|
||||
QObject::connect(&engine, SIGNAL(finished(bool)), &app, SLOT(quit()));
|
||||
QObject::connect(&engine, SIGNAL(transmissionProgress(ProgressInfo)), &cmd, SLOT(transmissionProgressSlot()));
|
||||
|
||||
// Exclude lists
|
||||
engine.excludedFiles().addExcludeFilePath(ConfigFile::excludeFileFromSystem());
|
||||
if( QFile::exists(options.exclude) )
|
||||
engine.excludedFiles().addExcludeFilePath(options.exclude);
|
||||
if (!engine.excludedFiles().reloadExcludes()) {
|
||||
// Always make sure at least one list has been loaded
|
||||
qFatal("Cannot load system exclude list or list supplied via --exclude");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Have to be done async, else, an error before exec() does not terminate the event loop.
|
||||
QMetaObject::invokeMethod(&engine, "startSync", Qt::QueuedConnection);
|
||||
|
||||
app.exec();
|
||||
|
||||
csync_destroy(_csync_ctx);
|
||||
|
||||
if (engine.isAnotherSyncNeeded()) {
|
||||
if (restartCount < options.restartTimes) {
|
||||
restartCount++;
|
||||
|
||||
+16
-30
@@ -16,10 +16,6 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <qtokenizer.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "netrcparser.h"
|
||||
|
||||
namespace OCC {
|
||||
@@ -32,11 +28,11 @@ QString passwordKeyword = QLatin1String("password");
|
||||
|
||||
}
|
||||
|
||||
NetrcParser::NetrcParser(const QString &file)
|
||||
NetrcParser::NetrcParser(const QString &fileName)
|
||||
: _fileName(fileName)
|
||||
{
|
||||
_netrcLocation = file;
|
||||
if (_netrcLocation.isEmpty()) {
|
||||
_netrcLocation = QDir::homePath()+QLatin1String("/.netrc");
|
||||
if (_fileName.isEmpty()) {
|
||||
_fileName = QDir::homePath()+QLatin1String("/.netrc");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,39 +49,29 @@ void NetrcParser::tryAddEntryAndClear(QString& machine, LoginPair& pair, bool& i
|
||||
|
||||
bool NetrcParser::parse()
|
||||
{
|
||||
QFile netrc(_netrcLocation);
|
||||
QFile netrc(_fileName);
|
||||
if (!netrc.open(QIODevice::ReadOnly)) {
|
||||
return false;
|
||||
}
|
||||
QString content = netrc.readAll();
|
||||
|
||||
QStringTokenizer tokenizer(content, " \n\t");
|
||||
tokenizer.setQuoteCharacters("\"'");
|
||||
|
||||
QTextStream ts(&netrc);
|
||||
LoginPair pair;
|
||||
QString machine;
|
||||
bool isDefault = false;
|
||||
while (tokenizer.hasNext()) {
|
||||
QString key = tokenizer.next();
|
||||
if (key == defaultKeyword) {
|
||||
while (!ts.atEnd()) {
|
||||
QString next;
|
||||
ts >> next;
|
||||
if (next == defaultKeyword) {
|
||||
tryAddEntryAndClear(machine, pair, isDefault);
|
||||
isDefault = true;
|
||||
continue; // don't read a value
|
||||
}
|
||||
|
||||
if (!tokenizer.hasNext()) {
|
||||
qDebug() << "error fetching value for" << key;
|
||||
return false;
|
||||
}
|
||||
QString value = tokenizer.next();
|
||||
|
||||
if (key == machineKeyword) {
|
||||
if (next == machineKeyword) {
|
||||
tryAddEntryAndClear(machine, pair, isDefault);
|
||||
machine = value;
|
||||
} else if (key == loginKeyword) {
|
||||
pair.first = value;
|
||||
} else if (key == passwordKeyword) {
|
||||
pair.second = value;
|
||||
ts >> machine;
|
||||
} else if (next == loginKeyword) {
|
||||
ts >> pair.first;
|
||||
} else if (next == passwordKeyword) {
|
||||
ts >> pair.second;
|
||||
} // ignore unsupported tokens
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class NetrcParser
|
||||
public:
|
||||
typedef QPair<QString, QString> LoginPair;
|
||||
|
||||
NetrcParser(const QString &file = QString());
|
||||
NetrcParser(const QString &fileName = QString::null);
|
||||
bool parse();
|
||||
LoginPair find(const QString &machine);
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
void tryAddEntryAndClear(QString &machine, LoginPair &pair, bool &isDefault);
|
||||
QHash<QString, LoginPair> _entries;
|
||||
LoginPair _default;
|
||||
QString _netrcLocation;
|
||||
QString _fileName;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -32,7 +32,6 @@ set(client_UI
|
||||
owncloudsetuppage.ui
|
||||
addcertificatedialog.ui
|
||||
proxyauthdialog.ui
|
||||
notificationwidget.ui
|
||||
wizard/owncloudadvancedsetuppage.ui
|
||||
wizard/owncloudconnectionmethoddialog.ui
|
||||
wizard/owncloudhttpcredspage.ui
|
||||
@@ -63,8 +62,6 @@ set(client_SRCS
|
||||
owncloudgui.cpp
|
||||
owncloudsetupwizard.cpp
|
||||
protocolwidget.cpp
|
||||
activitydata.cpp
|
||||
activitylistmodel.cpp
|
||||
activitywidget.cpp
|
||||
activityitemdelegate.cpp
|
||||
selectivesyncdialog.cpp
|
||||
@@ -87,16 +84,11 @@ set(client_SRCS
|
||||
proxyauthhandler.cpp
|
||||
proxyauthdialog.cpp
|
||||
synclogdialog.cpp
|
||||
tooltipupdater.cpp
|
||||
notificationwidget.cpp
|
||||
notificationconfirmjob.cpp
|
||||
servernotificationhandler.cpp
|
||||
creds/credentialsfactory.cpp
|
||||
creds/httpcredentialsgui.cpp
|
||||
creds/shibbolethcredentials.cpp
|
||||
creds/shibboleth/shibbolethwebview.cpp
|
||||
creds/shibboleth/shibbolethuserjob.cpp
|
||||
wizard/postfixlineedit.cpp
|
||||
wizard/abstractcredswizardpage.cpp
|
||||
wizard/owncloudadvancedsetuppage.cpp
|
||||
wizard/owncloudconnectionmethoddialog.cpp
|
||||
@@ -141,6 +133,7 @@ list(APPEND client_SRCS folderwatcher_mac.cpp)
|
||||
ENDIF()
|
||||
|
||||
set(3rdparty_SRC
|
||||
../3rdparty/fancylineedit/fancylineedit.cpp
|
||||
../3rdparty/QProgressIndicator/QProgressIndicator.cpp
|
||||
../3rdparty/qtlockedfile/qtlockedfile.cpp
|
||||
../3rdparty/qtsingleapplication/qtlocalpeer.cpp
|
||||
@@ -164,6 +157,7 @@ else()
|
||||
endif()
|
||||
|
||||
set(3rdparty_INC
|
||||
${CMAKE_SOURCE_DIR}/src/3rdparty/fancylineedit
|
||||
${CMAKE_SOURCE_DIR}/src/3rdparty/qjson
|
||||
${CMAKE_SOURCE_DIR}/src/3rdparty/QProgressIndicator
|
||||
${CMAKE_SOURCE_DIR}/src/3rdparty/qtlockedfile
|
||||
|
||||
@@ -30,7 +30,6 @@ static const char httpUserC[] = "http_user";
|
||||
static const char caCertsKeyC[] = "CaCertificates";
|
||||
static const char accountsC[] = "Accounts";
|
||||
static const char versionC[] = "version";
|
||||
static const char serverVersionC[] = "serverVersion";
|
||||
}
|
||||
|
||||
|
||||
@@ -54,11 +53,9 @@ bool AccountManager::restore()
|
||||
|
||||
foreach (const auto& accountId, settings->childGroups()) {
|
||||
settings->beginGroup(accountId);
|
||||
if (auto acc = loadAccountHelper(*settings)) {
|
||||
if (auto acc = load(*settings)) {
|
||||
acc->_id = accountId;
|
||||
if (auto accState = AccountState::loadFromSettings(acc, *settings)) {
|
||||
addAccountState(accState);
|
||||
}
|
||||
addAccount(acc);
|
||||
}
|
||||
settings->endGroup();
|
||||
}
|
||||
@@ -113,7 +110,7 @@ bool AccountManager::restoreFromLegacySettings()
|
||||
|
||||
// Try to load the single account.
|
||||
if (!settings->childKeys().isEmpty()) {
|
||||
if (auto acc = loadAccountHelper(*settings)) {
|
||||
if (auto acc = load(*settings)) {
|
||||
if (migratedCreds) {
|
||||
acc->setMigrated(true);
|
||||
}
|
||||
@@ -130,8 +127,7 @@ void AccountManager::save(bool saveCredentials)
|
||||
settings->setValue(QLatin1String(versionC), 2);
|
||||
foreach (const auto &acc, _accounts) {
|
||||
settings->beginGroup(acc->account()->id());
|
||||
saveAccountHelper(acc->account().data(), *settings, saveCredentials);
|
||||
acc->writeToSettings(*settings);
|
||||
save(acc->account(), *settings, saveCredentials);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -139,34 +135,21 @@ void AccountManager::save(bool saveCredentials)
|
||||
qDebug() << "Saved all account settings, status:" << settings->status();
|
||||
}
|
||||
|
||||
void AccountManager::saveAccount(Account* a)
|
||||
void AccountManager::wantsAccountSavedSlot(AccountPtr a)
|
||||
{
|
||||
qDebug() << "Saving account" << a->url().toString();
|
||||
auto settings = Account::settingsWithGroup(QLatin1String(accountsC));
|
||||
settings->beginGroup(a->id());
|
||||
saveAccountHelper(a, *settings, false); // don't save credentials they might not have been loaded yet
|
||||
save(a, *settings, false); // don't save credentials they might not have been loaded yet
|
||||
settings->endGroup();
|
||||
|
||||
settings->sync();
|
||||
qDebug() << "Saved account settings, status:" << settings->status();
|
||||
}
|
||||
|
||||
void AccountManager::saveAccountState(AccountState* a)
|
||||
{
|
||||
qDebug() << "Saving account state" << a->account()->url().toString();
|
||||
auto settings = Account::settingsWithGroup(QLatin1String(accountsC));
|
||||
settings->beginGroup(a->account()->id());
|
||||
a->writeToSettings(*settings);
|
||||
settings->endGroup();
|
||||
|
||||
settings->sync();
|
||||
qDebug() << "Saved account state settings, status:" << settings->status();
|
||||
}
|
||||
|
||||
void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool saveCredentials)
|
||||
void AccountManager::save(const AccountPtr& acc, QSettings& settings, bool saveCredentials)
|
||||
{
|
||||
settings.setValue(QLatin1String(urlC), acc->_url.toString());
|
||||
settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion);
|
||||
if (acc->_credentials) {
|
||||
if (saveCredentials) {
|
||||
// Only persist the credentials if the parameter is set, on migration from 1.8.x
|
||||
@@ -207,35 +190,22 @@ void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool s
|
||||
}
|
||||
}
|
||||
|
||||
AccountPtr AccountManager::loadAccountHelper(QSettings& settings)
|
||||
AccountPtr AccountManager::load(QSettings& settings)
|
||||
{
|
||||
auto acc = createAccount();
|
||||
|
||||
QString authType = settings.value(QLatin1String(authTypeC)).toString();
|
||||
QString overrideUrl = Theme::instance()->overrideServerUrl();
|
||||
if( !overrideUrl.isEmpty() ) {
|
||||
// if there is a overrideUrl, don't even bother reading from the config as all the accounts
|
||||
// must use the overrideUrl
|
||||
acc->setUrl(overrideUrl);
|
||||
auto forceAuth = Theme::instance()->forceConfigAuthType();
|
||||
if (!forceAuth.isEmpty()) {
|
||||
authType = forceAuth;
|
||||
}
|
||||
} else {
|
||||
acc->setUrl(settings.value(QLatin1String(urlC)).toUrl());
|
||||
}
|
||||
acc->_serverVersion = settings.value(QLatin1String(serverVersionC)).toString();
|
||||
acc->setUrl(settings.value(QLatin1String(urlC)).toUrl());
|
||||
|
||||
// We want to only restore settings for that auth type and the user value
|
||||
acc->_settingsMap.insert(QLatin1String(userC), settings.value(userC));
|
||||
QString authTypePrefix = authType + "_";
|
||||
QString authTypePrefix = settings.value(authTypeC).toString() + "_";
|
||||
Q_FOREACH(QString key, settings.childKeys()) {
|
||||
if (!key.startsWith(authTypePrefix))
|
||||
continue;
|
||||
acc->_settingsMap.insert(key, settings.value(key));
|
||||
}
|
||||
|
||||
acc->setCredentials(CredentialsFactory::create(authType));
|
||||
acc->setCredentials(CredentialsFactory::create(settings.value(QLatin1String(authTypeC)).toString()));
|
||||
|
||||
// now the cert, it is in the general group
|
||||
settings.beginGroup(QLatin1String("General"));
|
||||
@@ -263,9 +233,13 @@ AccountState *AccountManager::addAccount(const AccountPtr& newAccount)
|
||||
}
|
||||
newAccount->_id = id;
|
||||
|
||||
auto newAccountState = new AccountState(newAccount);
|
||||
addAccountState(newAccountState);
|
||||
return newAccountState;
|
||||
QObject::connect(newAccount.data(), SIGNAL(wantsAccountSaved(AccountPtr)),
|
||||
this, SLOT(wantsAccountSavedSlot(AccountPtr)));
|
||||
|
||||
AccountStatePtr newAccountState(new AccountState(newAccount));
|
||||
_accounts << newAccountState;
|
||||
emit accountAdded(newAccountState.data());
|
||||
return newAccountState.data();
|
||||
}
|
||||
|
||||
void AccountManager::deleteAccount(AccountState* account)
|
||||
@@ -322,15 +296,4 @@ QString AccountManager::generateFreeAccountId() const
|
||||
}
|
||||
}
|
||||
|
||||
void AccountManager::addAccountState(AccountState* accountState)
|
||||
{
|
||||
QObject::connect(accountState->account().data(),
|
||||
SIGNAL(wantsAccountSaved(Account*)),
|
||||
SLOT(saveAccount(Account*)));
|
||||
|
||||
AccountStatePtr ptr(accountState);
|
||||
_accounts << ptr;
|
||||
emit accountAdded(accountState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
namespace OCC {
|
||||
|
||||
typedef QSharedPointer<AccountState> AccountStatePtr;
|
||||
|
||||
/**
|
||||
@brief The AccountManager class
|
||||
@ingroup gui
|
||||
@@ -74,24 +76,15 @@ public:
|
||||
static AccountPtr createAccount();
|
||||
|
||||
private:
|
||||
// saving and loading Account to settings
|
||||
void saveAccountHelper(Account* account, QSettings& settings, bool saveCredentials = true);
|
||||
AccountPtr loadAccountHelper(QSettings& settings);
|
||||
|
||||
void save(const AccountPtr& account, QSettings& settings, bool saveCredentials = true);
|
||||
AccountPtr load(QSettings& settings);
|
||||
bool restoreFromLegacySettings();
|
||||
|
||||
bool isAccountIdAvailable(const QString& id) const;
|
||||
QString generateFreeAccountId() const;
|
||||
|
||||
// Adds an account to the tracked list, emitting accountAdded()
|
||||
void addAccountState(AccountState* accountState);
|
||||
|
||||
public slots:
|
||||
/// Saves account data, not including the credentials
|
||||
void saveAccount(Account* a);
|
||||
|
||||
/// Saves account state data, not including the account
|
||||
void saveAccountState(AccountState* a);
|
||||
void wantsAccountSavedSlot(AccountPtr a);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
@@ -29,13 +29,11 @@
|
||||
#include "accountmanager.h"
|
||||
#include "owncloudsetupwizard.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
#include "tooltipupdater.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QListWidgetItem>
|
||||
#include <QMessageBox>
|
||||
#include <QAction>
|
||||
@@ -89,8 +87,6 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
|
||||
#else
|
||||
ui->_folderList->setMinimumWidth( 300 );
|
||||
#endif
|
||||
new ToolTipUpdater(ui->_folderList);
|
||||
|
||||
createAccountToolbox();
|
||||
connect(AccountManager::instance(), SIGNAL(accountAdded(AccountState*)),
|
||||
SLOT(slotAccountAdded(AccountState*)));
|
||||
@@ -334,13 +330,10 @@ void AccountSettings::slotRemoveCurrentFolder()
|
||||
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
||||
qDebug() << "Remove Folder alias " << alias;
|
||||
if( !alias.isEmpty() ) {
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
QString aliasGui = folderMan->folder(alias)->aliasGui();
|
||||
|
||||
QMessageBox messageBox(QMessageBox::Question,
|
||||
tr("Confirm Folder Sync Connection Removal"),
|
||||
tr("<p>Do you really want to stop syncing the folder <i>%1</i>?</p>"
|
||||
"<p><b>Note:</b> This will <b>not</b> delete any files.</p>").arg(aliasGui),
|
||||
"<p><b>Note:</b> This will <b>not</b> delete any files.</p>").arg(alias),
|
||||
QMessageBox::NoButton,
|
||||
this);
|
||||
QPushButton* yesButton =
|
||||
@@ -352,6 +345,7 @@ void AccountSettings::slotRemoveCurrentFolder()
|
||||
return;
|
||||
}
|
||||
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
folderMan->slotRemoveFolder( folderMan->folder(alias) );
|
||||
_model->removeRow(row);
|
||||
|
||||
@@ -443,7 +437,8 @@ void AccountSettings::slotEnableCurrentFolder()
|
||||
if ( f->isBusy() && terminate ) {
|
||||
f->slotTerminateSync();
|
||||
}
|
||||
f->setSyncPaused(!currentlyPaused);
|
||||
f->setSyncPaused(!currentlyPaused); // toggle the pause setting
|
||||
folderMan->slotSetFolderPaused( f, !currentlyPaused );
|
||||
|
||||
// keep state for the icon setting.
|
||||
if( currentlyPaused ) _wasDisabledBefore = true;
|
||||
@@ -518,11 +513,7 @@ void AccountSettings::slotAccountStateChanged(int state)
|
||||
}
|
||||
|
||||
if (state == AccountState::Connected) {
|
||||
QStringList errors;
|
||||
if (account->serverVersionUnsupported()) {
|
||||
errors << tr("The server version %1 is old and unsupported! Proceed at your own risk.").arg(account->serverVersion());
|
||||
}
|
||||
showConnectionLabel( tr("Connected to %1.").arg(serverWithUser), errors );
|
||||
showConnectionLabel( tr("Connected to %1.").arg(serverWithUser) );
|
||||
} else if (state == AccountState::ServiceUnavailable) {
|
||||
showConnectionLabel( tr("Server %1 is temporarily unavailable.").arg(server) );
|
||||
} else if (state == AccountState::SignedOut) {
|
||||
@@ -550,10 +541,11 @@ void AccountSettings::slotAccountStateChanged(int state)
|
||||
}
|
||||
/* set the correct label for the Account toolbox button */
|
||||
if( _accountState ) {
|
||||
if( _accountState->isSignedOut() ) {
|
||||
_toggleSignInOutAction->setText(tr("Log in"));
|
||||
} else {
|
||||
bool isConnected = _accountState->isConnected();
|
||||
if( isConnected ) {
|
||||
_toggleSignInOutAction->setText(tr("Log out"));
|
||||
} else {
|
||||
_toggleSignInOutAction->setText(tr("Log in"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -608,8 +600,7 @@ void AccountSettings::refreshSelectiveSyncStatus()
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
|
||||
auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
|
||||
QString p;
|
||||
foreach(const auto &it, undecidedList) {
|
||||
// FIXME: add the folder alias in a hoover hint.
|
||||
|
||||
@@ -46,16 +46,6 @@ AccountState::~AccountState()
|
||||
{
|
||||
}
|
||||
|
||||
AccountState *AccountState::loadFromSettings(AccountPtr account, QSettings& /*settings*/)
|
||||
{
|
||||
auto accountState = new AccountState(account);
|
||||
return accountState;
|
||||
}
|
||||
|
||||
void AccountState::writeToSettings(QSettings& /*settings*/)
|
||||
{
|
||||
}
|
||||
|
||||
AccountPtr AccountState::account() const
|
||||
{
|
||||
return _account;
|
||||
@@ -149,11 +139,6 @@ bool AccountState::isConnectedOrTemporarilyUnavailable() const
|
||||
return isConnected() || _state == ServiceUnavailable;
|
||||
}
|
||||
|
||||
bool AccountState::canSync() const
|
||||
{
|
||||
return isConnected();
|
||||
}
|
||||
|
||||
void AccountState::tagLastSuccessfullETagRequest()
|
||||
{
|
||||
_timeSinceLastETagCheck.restart();
|
||||
|
||||
@@ -29,13 +29,11 @@ namespace OCC {
|
||||
class AccountState;
|
||||
class Account;
|
||||
|
||||
typedef QExplicitlySharedDataPointer<AccountState> AccountStatePtr;
|
||||
|
||||
/**
|
||||
* @brief Extra info about an ownCloud server account.
|
||||
* @ingroup gui
|
||||
*/
|
||||
class AccountState : public QObject, public QSharedData {
|
||||
class AccountState : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum State {
|
||||
@@ -66,21 +64,9 @@ public:
|
||||
typedef ConnectionValidator::Status ConnectionStatus;
|
||||
|
||||
/// Use the account as parent
|
||||
explicit AccountState(AccountPtr account);
|
||||
AccountState(AccountPtr account);
|
||||
~AccountState();
|
||||
|
||||
/** Creates an account state from settings and an Account object.
|
||||
*
|
||||
* Use from AccountManager with a prepared QSettings object only.
|
||||
*/
|
||||
static AccountState* loadFromSettings(AccountPtr account, QSettings& settings);
|
||||
|
||||
/** Writes account state information to settings.
|
||||
*
|
||||
* It does not write the Account data.
|
||||
*/
|
||||
void writeToSettings(QSettings& settings);
|
||||
|
||||
AccountPtr account() const;
|
||||
|
||||
ConnectionStatus connectionStatus() const;
|
||||
@@ -102,9 +88,6 @@ public:
|
||||
bool isConnected() const;
|
||||
bool isConnectedOrTemporarilyUnavailable() const;
|
||||
|
||||
/// Returns whether sync actions are allowed to run.
|
||||
bool canSync() const;
|
||||
|
||||
/// Triggers a ping to the server to update state and
|
||||
/// connection status and errors.
|
||||
void checkConnectivity();
|
||||
@@ -150,6 +133,6 @@ private:
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(OCC::AccountState*)
|
||||
Q_DECLARE_METATYPE(OCC::AccountStatePtr)
|
||||
Q_DECLARE_METATYPE(QSharedPointer<OCC::AccountState>)
|
||||
|
||||
#endif //ACCOUNTINFO_H
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
#include "activitydata.h"
|
||||
|
||||
|
||||
namespace OCC
|
||||
{
|
||||
|
||||
bool operator<( const Activity& rhs, const Activity& lhs ) {
|
||||
return rhs._dateTime.toMSecsSinceEpoch() > lhs._dateTime.toMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
bool operator==( const Activity& rhs, const Activity& lhs ) {
|
||||
return (rhs._type == lhs._type && rhs._id== lhs._id && rhs._accName == lhs._accName);
|
||||
}
|
||||
|
||||
Activity::Identifier Activity::ident() const {
|
||||
return Identifier( _id, _accName );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef ACTIVITYDATA_H
|
||||
#define ACTIVITYDATA_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
namespace OCC {
|
||||
/**
|
||||
* @brief The ActivityLink class describes actions of an activity
|
||||
*
|
||||
* These are part of notifications which are mapped into activities.
|
||||
*/
|
||||
|
||||
class ActivityLink
|
||||
{
|
||||
public:
|
||||
QString _label;
|
||||
QString _link;
|
||||
QByteArray _verb;
|
||||
bool _isPrimary;
|
||||
};
|
||||
|
||||
/* ==================================================================== */
|
||||
/**
|
||||
* @brief Activity Structure
|
||||
* @ingroup gui
|
||||
*
|
||||
* contains all the information describing a single activity.
|
||||
*/
|
||||
|
||||
class Activity
|
||||
{
|
||||
public:
|
||||
typedef QPair<qlonglong, QString> Identifier;
|
||||
|
||||
enum Type {
|
||||
ActivityType,
|
||||
NotificationType
|
||||
};
|
||||
|
||||
Type _type;
|
||||
qlonglong _id;
|
||||
QString _subject;
|
||||
QString _message;
|
||||
QString _file;
|
||||
QUrl _link;
|
||||
QDateTime _dateTime;
|
||||
QString _accName;
|
||||
|
||||
QVector <ActivityLink> _links;
|
||||
/**
|
||||
* @brief Sort operator to sort the list youngest first.
|
||||
* @param val
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
||||
Identifier ident() const;
|
||||
};
|
||||
|
||||
bool operator==( const Activity& rhs, const Activity& lhs );
|
||||
bool operator<( const Activity& rhs, const Activity& lhs );
|
||||
|
||||
/* ==================================================================== */
|
||||
/**
|
||||
* @brief The ActivityList
|
||||
* @ingroup gui
|
||||
*
|
||||
* A QList based list of Activities
|
||||
*/
|
||||
|
||||
typedef QList<Activity> ActivityList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // ACTIVITYDATA_H
|
||||
@@ -1,228 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <QtCore>
|
||||
#include <QAbstractListModel>
|
||||
#include <QWidget>
|
||||
#include <QIcon>
|
||||
|
||||
#include "account.h"
|
||||
#include "accountstate.h"
|
||||
#include "accountmanager.h"
|
||||
#include "folderman.h"
|
||||
#include "accessmanager.h"
|
||||
#include "activityitemdelegate.h"
|
||||
|
||||
#include "activitydata.h"
|
||||
#include "activitylistmodel.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
ActivityListModel::ActivityListModel(QWidget *parent)
|
||||
:QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
Activity a;
|
||||
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
a = _finalList.at(index.row());
|
||||
AccountStatePtr ast = AccountManager::instance()->account(a._accName);
|
||||
QStringList list;
|
||||
|
||||
switch (role) {
|
||||
case ActivityItemDelegate::PathRole:
|
||||
list = FolderMan::instance()->findFileInLocalFolders(a._file, ast->account());
|
||||
if( list.count() > 0 ) {
|
||||
return QVariant(list.at(0));
|
||||
}
|
||||
// File does not exist anymore? Let's try to open its path
|
||||
list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(a._file).path(), ast->account());
|
||||
if( list.count() > 0 ) {
|
||||
return QVariant(list.at(0));
|
||||
}
|
||||
return QVariant();
|
||||
break;
|
||||
case ActivityItemDelegate::ActionIconRole:
|
||||
return QVariant(); // FIXME once the action can be quantified, display on Icon
|
||||
break;
|
||||
case ActivityItemDelegate::UserIconRole:
|
||||
return QIcon(QLatin1String(":/client/resources/account.png"));
|
||||
break;
|
||||
case Qt::ToolTipRole:
|
||||
case ActivityItemDelegate::ActionTextRole:
|
||||
return a._subject;
|
||||
break;
|
||||
case ActivityItemDelegate::LinkRole:
|
||||
return a._link;
|
||||
break;
|
||||
case ActivityItemDelegate::AccountRole:
|
||||
return a._accName;
|
||||
break;
|
||||
case ActivityItemDelegate::PointInTimeRole:
|
||||
return Utility::timeAgoInWords(a._dateTime);
|
||||
break;
|
||||
case ActivityItemDelegate::AccountConnectedRole:
|
||||
return (ast && ast->isConnected());
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
|
||||
int ActivityListModel::rowCount(const QModelIndex&) const
|
||||
{
|
||||
return _finalList.count();
|
||||
}
|
||||
|
||||
// current strategy: Fetch 100 items per Account
|
||||
// ATTENTION: This method is const and thus it is not possible to modify
|
||||
// the _activityLists hash or so. Doesn't make it easier...
|
||||
bool ActivityListModel::canFetchMore(const QModelIndex& ) const
|
||||
{
|
||||
if( _activityLists.count() == 0 ) return true;
|
||||
|
||||
for(auto i = _activityLists.begin() ; i != _activityLists.end(); ++i) {
|
||||
AccountState *ast = i.key();
|
||||
if( ast && ast->isConnected() ) {
|
||||
ActivityList activities = i.value();
|
||||
if( activities.count() == 0 &&
|
||||
! _currentlyFetching.contains(ast) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ActivityListModel::startFetchJob(AccountState* s)
|
||||
{
|
||||
if( !s->isConnected() ) {
|
||||
return;
|
||||
}
|
||||
JsonApiJob *job = new JsonApiJob(s->account(), QLatin1String("ocs/v1.php/cloud/activity"), this);
|
||||
QObject::connect(job, SIGNAL(jsonReceived(QVariantMap, int)),
|
||||
this, SLOT(slotActivitiesReceived(QVariantMap, int)));
|
||||
job->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(s));
|
||||
|
||||
QList< QPair<QString,QString> > params;
|
||||
params.append(qMakePair(QString::fromLatin1("page"), QString::fromLatin1("0")));
|
||||
params.append(qMakePair(QString::fromLatin1("pagesize"), QString::fromLatin1("100")));
|
||||
job->addQueryParams(params);
|
||||
|
||||
_currentlyFetching.insert(s);
|
||||
qDebug() << Q_FUNC_INFO << "Start fetching activities for " << s->account()->displayName();
|
||||
job->start();
|
||||
}
|
||||
|
||||
void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int statusCode)
|
||||
{
|
||||
auto activities = json.value("ocs").toMap().value("data").toList();
|
||||
|
||||
ActivityList list;
|
||||
AccountState* ast = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
|
||||
_currentlyFetching.remove(ast);
|
||||
|
||||
foreach( auto activ, activities ) {
|
||||
auto json = activ.toMap();
|
||||
|
||||
Activity a;
|
||||
a._type = Activity::ActivityType;
|
||||
a._accName = ast->account()->displayName();
|
||||
a._id = json.value("id").toLongLong();
|
||||
a._subject = json.value("subject").toString();
|
||||
a._message = json.value("message").toString();
|
||||
a._file = json.value("file").toString();
|
||||
a._link = json.value("link").toUrl();
|
||||
a._dateTime = json.value("date").toDateTime();
|
||||
list.append(a);
|
||||
}
|
||||
|
||||
_activityLists[ast] = list;
|
||||
|
||||
emit activityJobStatusCode(ast, statusCode);
|
||||
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
|
||||
void ActivityListModel::combineActivityLists()
|
||||
{
|
||||
ActivityList resultList;
|
||||
|
||||
foreach( ActivityList list, _activityLists.values() ) {
|
||||
resultList.append(list);
|
||||
}
|
||||
|
||||
std::sort( resultList.begin(), resultList.end() );
|
||||
|
||||
beginResetModel();
|
||||
_finalList.clear();
|
||||
endResetModel();
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, resultList.count());
|
||||
_finalList = resultList;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void ActivityListModel::fetchMore(const QModelIndex &)
|
||||
{
|
||||
QList<AccountStatePtr> accounts = AccountManager::instance()->accounts();
|
||||
|
||||
foreach (const AccountStatePtr& asp, accounts) {
|
||||
|
||||
if( !_activityLists.contains(asp.data()) && asp->isConnected() ) {
|
||||
_activityLists[asp.data()] = ActivityList();
|
||||
startFetchJob(asp.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityListModel::slotRefreshActivity(AccountState *ast)
|
||||
{
|
||||
if(ast && _activityLists.contains(ast)) {
|
||||
_activityLists.remove(ast);
|
||||
}
|
||||
startFetchJob(ast);
|
||||
}
|
||||
|
||||
void ActivityListModel::slotRemoveAccount(AccountState *ast )
|
||||
{
|
||||
if( _activityLists.contains(ast) ) {
|
||||
int i = 0;
|
||||
const QString accountToRemove = ast->account()->displayName();
|
||||
|
||||
QMutableListIterator<Activity> it(_finalList);
|
||||
|
||||
while (it.hasNext()) {
|
||||
Activity activity = it.next();
|
||||
if( activity._accName == accountToRemove ) {
|
||||
beginRemoveRows(QModelIndex(), i, i+1);
|
||||
it.remove();
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
_activityLists.remove(ast);
|
||||
_currentlyFetching.remove(ast);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef ACTIVITYLISTMODEL_H
|
||||
#define ACTIVITYLISTMODEL_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
#include "activitydata.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class AccountState;
|
||||
|
||||
/**
|
||||
* @brief The ActivityListModel
|
||||
* @ingroup gui
|
||||
*
|
||||
* Simple list model to provide the list view with data.
|
||||
*/
|
||||
|
||||
class ActivityListModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActivityListModel(QWidget *parent=0);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
|
||||
bool canFetchMore(const QModelIndex& ) const Q_DECL_OVERRIDE;
|
||||
void fetchMore(const QModelIndex&) Q_DECL_OVERRIDE;
|
||||
|
||||
ActivityList activityList() { return _finalList; }
|
||||
|
||||
public slots:
|
||||
void slotRefreshActivity(AccountState* ast);
|
||||
void slotRemoveAccount( AccountState *ast );
|
||||
|
||||
private slots:
|
||||
void slotActivitiesReceived(const QVariantMap& json, int statusCode);
|
||||
|
||||
signals:
|
||||
void activityJobStatusCode(AccountState* ast, int statusCode);
|
||||
|
||||
private:
|
||||
void startFetchJob(AccountState* s);
|
||||
void combineActivityLists();
|
||||
|
||||
QMap<AccountState*, ActivityList> _activityLists;
|
||||
ActivityList _finalList;
|
||||
QSet<AccountState*> _currentlyFetching;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif // ACTIVITYLISTMODEL_H
|
||||
+235
-402
@@ -16,8 +16,8 @@
|
||||
#include <QtWidgets>
|
||||
#endif
|
||||
|
||||
#include "activitylistmodel.h"
|
||||
#include "activitywidget.h"
|
||||
#include "configfile.h"
|
||||
#include "syncresult.h"
|
||||
#include "logger.h"
|
||||
#include "utility.h"
|
||||
@@ -33,28 +33,237 @@
|
||||
#include "activityitemdelegate.h"
|
||||
#include "protocolwidget.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include "notificationwidget.h"
|
||||
#include "notificationconfirmjob.h"
|
||||
#include "servernotificationhandler.h"
|
||||
#include "theme.h"
|
||||
#include "ocsjob.h"
|
||||
|
||||
#include "ui_activitywidget.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
// time span in milliseconds which has to be between two
|
||||
// refreshes of the notifications
|
||||
#define NOTIFICATION_REQUEST_FREE_PERIOD 15000
|
||||
|
||||
namespace OCC {
|
||||
|
||||
void ActivityList::setAccountName( const QString& name )
|
||||
{
|
||||
_accountName = name;
|
||||
}
|
||||
|
||||
QString ActivityList::accountName() const
|
||||
{
|
||||
return _accountName;
|
||||
}
|
||||
|
||||
/* ==================================================================== */
|
||||
|
||||
ActivityListModel::ActivityListModel(QWidget *parent)
|
||||
:QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
Activity a;
|
||||
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
a = _finalList.at(index.row());
|
||||
AccountStatePtr ast = AccountManager::instance()->account(a._accName);
|
||||
QStringList list;
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
return QVariant();
|
||||
|
||||
switch (role) {
|
||||
case ActivityItemDelegate::PathRole:
|
||||
list = FolderMan::instance()->findFileInLocalFolders(a._file, ast->account());
|
||||
if( list.count() > 0 ) {
|
||||
return QVariant(list.at(0));
|
||||
}
|
||||
// File does not exist anymore? Let's try to open its path
|
||||
list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(a._file).path(), ast->account());
|
||||
if( list.count() > 0 ) {
|
||||
return QVariant(list.at(0));
|
||||
}
|
||||
return QVariant();
|
||||
break;
|
||||
case ActivityItemDelegate::ActionIconRole:
|
||||
return QVariant(); // FIXME once the action can be quantified, display on Icon
|
||||
break;
|
||||
case ActivityItemDelegate::UserIconRole:
|
||||
return QIcon(QLatin1String(":/client/resources/account.png"));
|
||||
break;
|
||||
case Qt::ToolTipRole:
|
||||
case ActivityItemDelegate::ActionTextRole:
|
||||
return a._subject;
|
||||
break;
|
||||
case ActivityItemDelegate::LinkRole:
|
||||
return a._link;
|
||||
break;
|
||||
case ActivityItemDelegate::AccountRole:
|
||||
return a._accName;
|
||||
break;
|
||||
case ActivityItemDelegate::PointInTimeRole:
|
||||
return Utility::timeAgoInWords(a._dateTime);
|
||||
break;
|
||||
case ActivityItemDelegate::AccountConnectedRole:
|
||||
return (ast && ast->isConnected());
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
|
||||
int ActivityListModel::rowCount(const QModelIndex&) const
|
||||
{
|
||||
return _finalList.count();
|
||||
}
|
||||
|
||||
// current strategy: Fetch 100 items per Account
|
||||
bool ActivityListModel::canFetchMore(const QModelIndex& ) const
|
||||
{
|
||||
if( _activityLists.count() == 0 ) return true;
|
||||
|
||||
QMap<AccountState*, ActivityList>::const_iterator i = _activityLists.begin();
|
||||
while (i != _activityLists.end()) {
|
||||
AccountState *ast = i.key();
|
||||
if( !ast->isConnected() ) {
|
||||
return false;
|
||||
}
|
||||
ActivityList activities = i.value();
|
||||
if( activities.count() == 0 &&
|
||||
! _currentlyFetching.contains(ast) ) {
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ActivityListModel::startFetchJob(AccountState* s)
|
||||
{
|
||||
if( !s->isConnected() ) {
|
||||
return;
|
||||
}
|
||||
JsonApiJob *job = new JsonApiJob(s->account(), QLatin1String("ocs/v1.php/cloud/activity"), this);
|
||||
QObject::connect(job, SIGNAL(jsonReceived(QVariantMap, int)),
|
||||
this, SLOT(slotActivitiesReceived(QVariantMap, int)));
|
||||
job->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(s));
|
||||
|
||||
QList< QPair<QString,QString> > params;
|
||||
params.append(qMakePair(QString::fromLatin1("page"), QString::fromLatin1("0")));
|
||||
params.append(qMakePair(QString::fromLatin1("pagesize"), QString::fromLatin1("100")));
|
||||
job->addQueryParams(params);
|
||||
|
||||
_currentlyFetching.insert(s);
|
||||
qDebug() << "Start fetching activities for " << s->account()->displayName();
|
||||
job->start();
|
||||
}
|
||||
|
||||
void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int statusCode)
|
||||
{
|
||||
auto activities = json.value("ocs").toMap().value("data").toList();
|
||||
qDebug() << "*** activities" << activities;
|
||||
|
||||
ActivityList list;
|
||||
AccountState* ai = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
|
||||
_currentlyFetching.remove(ai);
|
||||
list.setAccountName( ai->account()->displayName());
|
||||
|
||||
foreach( auto activ, activities ) {
|
||||
auto json = activ.toMap();
|
||||
|
||||
Activity a;
|
||||
a._accName = ai->account()->displayName();
|
||||
a._id = json.value("id").toLongLong();
|
||||
a._subject = json.value("subject").toString();
|
||||
a._message = json.value("message").toString();
|
||||
a._file = json.value("file").toString();
|
||||
a._link = json.value("link").toUrl();
|
||||
a._dateTime = json.value("date").toDateTime();
|
||||
a._dateTime.setTimeSpec(Qt::UTC);
|
||||
list.append(a);
|
||||
}
|
||||
|
||||
_activityLists[ai] = list;
|
||||
|
||||
if( statusCode == 999 ) {
|
||||
emit accountWithoutActivityApp(ai);
|
||||
}
|
||||
|
||||
combineActivityLists();
|
||||
}
|
||||
|
||||
|
||||
void ActivityListModel::combineActivityLists()
|
||||
{
|
||||
ActivityList resultList;
|
||||
|
||||
foreach( ActivityList list, _activityLists.values() ) {
|
||||
resultList.append(list);
|
||||
}
|
||||
|
||||
std::sort( resultList.begin(), resultList.end() );
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, resultList.count()-1);
|
||||
_finalList = resultList;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void ActivityListModel::fetchMore(const QModelIndex &)
|
||||
{
|
||||
QList<AccountStatePtr> accounts = AccountManager::instance()->accounts();
|
||||
|
||||
foreach (AccountStatePtr asp, accounts) {
|
||||
bool newItem = false;
|
||||
// if the account is not yet managed, add an empty list.
|
||||
if( !_activityLists.contains(asp.data()) ) {
|
||||
_activityLists[asp.data()] = ActivityList();
|
||||
newItem = true;
|
||||
}
|
||||
ActivityList activities = _activityLists[asp.data()];
|
||||
if( newItem ) {
|
||||
startFetchJob(asp.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityListModel::slotRefreshActivity(AccountState *ast)
|
||||
{
|
||||
if(ast && _activityLists.contains(ast)) {
|
||||
qDebug() << "**** Refreshing Activity list for" << ast->account()->displayName();
|
||||
_activityLists.remove(ast);
|
||||
}
|
||||
startFetchJob(ast);
|
||||
}
|
||||
|
||||
void ActivityListModel::slotRemoveAccount(AccountState *ast )
|
||||
{
|
||||
if( _activityLists.contains(ast) ) {
|
||||
int i = 0;
|
||||
const QString accountToRemove = ast->account()->displayName();
|
||||
|
||||
QMutableListIterator<Activity> it(_finalList);
|
||||
|
||||
while (it.hasNext()) {
|
||||
Activity activity = it.next();
|
||||
if( activity._accName == accountToRemove ) {
|
||||
beginRemoveRows(QModelIndex(), i, i+1);
|
||||
it.remove();
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
_activityLists.remove(ast);
|
||||
_currentlyFetching.remove(ast);
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================================================================== */
|
||||
|
||||
ActivityWidget::ActivityWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_ui(new Ui::ActivityWidget),
|
||||
_notificationRequestsRunning(0)
|
||||
_ui(new Ui::ActivityWidget)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
@@ -70,22 +279,10 @@ ActivityWidget::ActivityWidget(QWidget *parent) :
|
||||
_ui->_activityList->setAlternatingRowColors(true);
|
||||
_ui->_activityList->setModel(_model);
|
||||
|
||||
_ui->_notifyLabel->hide();
|
||||
_ui->_notifyScroll->hide();
|
||||
|
||||
// Create a widget container for the notifications. The ui file defines
|
||||
// a scroll area that get a widget with a layout as children
|
||||
QWidget *w = new QWidget;
|
||||
_notificationsLayout = new QVBoxLayout;
|
||||
w->setLayout(_notificationsLayout);
|
||||
_notificationsLayout->setAlignment(Qt::AlignTop);
|
||||
_ui->_notifyScroll->setAlignment(Qt::AlignTop);
|
||||
_ui->_notifyScroll->setWidget(w);
|
||||
|
||||
showLabels();
|
||||
|
||||
connect(_model, SIGNAL(activityJobStatusCode(AccountState*,int)),
|
||||
this, SLOT(slotAccountActivityStatus(AccountState*,int)));
|
||||
connect(_model, SIGNAL(accountWithoutActivityApp(AccountState*)),
|
||||
this, SLOT(slotAccountWithoutActivityApp(AccountState*)));
|
||||
|
||||
_copyBtn = _ui->_dialogButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
|
||||
_copyBtn->setToolTip( tr("Copy the activity list to the clipboard."));
|
||||
@@ -95,9 +292,6 @@ ActivityWidget::ActivityWidget(QWidget *parent) :
|
||||
|
||||
connect( _ui->_activityList, SIGNAL(activated(QModelIndex)), this,
|
||||
SLOT(slotOpenFile(QModelIndex)));
|
||||
|
||||
connect( &_removeTimer, SIGNAL(timeout()), this, SLOT(slotCheckToCleanWidgets()) );
|
||||
_removeTimer.setInterval(1000);
|
||||
}
|
||||
|
||||
ActivityWidget::~ActivityWidget()
|
||||
@@ -105,26 +299,11 @@ ActivityWidget::~ActivityWidget()
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ActivityWidget::slotRefreshActivities(AccountState *ptr)
|
||||
void ActivityWidget::slotRefresh(AccountState *ptr)
|
||||
{
|
||||
_model->slotRefreshActivity(ptr);
|
||||
}
|
||||
|
||||
void ActivityWidget::slotRefreshNotifications(AccountState *ptr)
|
||||
{
|
||||
// start a server notification handler if no notification requests
|
||||
// are running
|
||||
if( _notificationRequestsRunning == 0 ) {
|
||||
ServerNotificationHandler *snh = new ServerNotificationHandler;
|
||||
connect(snh, SIGNAL(newNotificationList(ActivityList)), this,
|
||||
SLOT(slotBuildNotificationDisplay(ActivityList)));
|
||||
|
||||
snh->slotFetchNotifications(ptr);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "========> notification request counter not zero.";
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotRemoveAccount( AccountState *ptr )
|
||||
{
|
||||
_model->slotRemoveAccount(ptr);
|
||||
@@ -136,8 +315,6 @@ void ActivityWidget::showLabels()
|
||||
_ui->_headerLabel->setTextFormat(Qt::RichText);
|
||||
_ui->_headerLabel->setText(t);
|
||||
|
||||
_ui->_notifyLabel->setText(tr("Action Required: Notifications"));
|
||||
|
||||
t.clear();
|
||||
QSetIterator<QString> i(_accountsWithoutActivities);
|
||||
while (i.hasNext() ) {
|
||||
@@ -147,18 +324,12 @@ void ActivityWidget::showLabels()
|
||||
_ui->_bottomLabel->setText(t);
|
||||
}
|
||||
|
||||
void ActivityWidget::slotAccountActivityStatus(AccountState *ast, int statusCode)
|
||||
void ActivityWidget::slotAccountWithoutActivityApp(AccountState *ast)
|
||||
{
|
||||
if( !(ast && ast->account()) ) {
|
||||
return;
|
||||
}
|
||||
if( statusCode == 999 ) {
|
||||
if( ast && ast->account() ) {
|
||||
_accountsWithoutActivities.insert(ast->account()->displayName());
|
||||
} else {
|
||||
_accountsWithoutActivities.remove(ast->account()->displayName());
|
||||
}
|
||||
|
||||
checkActivityTabVisibility();
|
||||
showLabels();
|
||||
}
|
||||
|
||||
@@ -211,25 +382,9 @@ void ActivityWidget::storeActivityList( QTextStream& ts )
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::checkActivityTabVisibility()
|
||||
{
|
||||
int accountCount = AccountManager::instance()->accounts().count();
|
||||
bool hasAccountsWithActivity =
|
||||
_accountsWithoutActivities.count() != accountCount;
|
||||
bool hasNotifications = !_widgetForNotifId.isEmpty();
|
||||
|
||||
_ui->_headerLabel->setVisible( hasAccountsWithActivity );
|
||||
_ui->_activityList->setVisible( hasAccountsWithActivity );
|
||||
|
||||
_ui->_notifyLabel->setVisible( hasNotifications );
|
||||
_ui->_notifyScroll->setVisible( hasNotifications );
|
||||
|
||||
emit hideActivityTab(!hasAccountsWithActivity && !hasNotifications);
|
||||
}
|
||||
|
||||
void ActivityWidget::slotOpenFile(QModelIndex indx)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
|
||||
qDebug() << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
|
||||
if( indx.isValid() ) {
|
||||
QString fullPath = indx.data(ActivityItemDelegate::PathRole).toString();
|
||||
|
||||
@@ -239,268 +394,6 @@ void ActivityWidget::slotOpenFile(QModelIndex indx)
|
||||
}
|
||||
}
|
||||
|
||||
// GUI: Display the notifications.
|
||||
// All notifications in list are coming from the same account
|
||||
// but in the _widgetForNotifId hash widgets for all accounts are
|
||||
// collected.
|
||||
void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
|
||||
{
|
||||
QHash<QString, int> accNotified;
|
||||
QString listAccountName;
|
||||
|
||||
foreach( auto activity, list ) {
|
||||
if( _blacklistedNotifications.contains(activity)) {
|
||||
qDebug() << Q_FUNC_INFO << "Activity in blacklist, skip";
|
||||
continue;
|
||||
}
|
||||
|
||||
NotificationWidget *widget = 0;
|
||||
|
||||
if( _widgetForNotifId.contains( activity.ident()) ) {
|
||||
widget = _widgetForNotifId[activity.ident()];
|
||||
} else {
|
||||
widget = new NotificationWidget(this);
|
||||
connect(widget, SIGNAL(sendNotificationRequest(QString, QString, QByteArray)),
|
||||
this, SLOT(slotSendNotificationRequest(QString, QString, QByteArray)));
|
||||
connect(widget, SIGNAL(requestCleanupAndBlacklist(Activity)),
|
||||
this, SLOT(slotRequestCleanupAndBlacklist(Activity)));
|
||||
|
||||
_notificationsLayout->addWidget(widget);
|
||||
// _ui->_notifyScroll->setMinimumHeight( widget->height());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
_ui->_notifyScroll->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
|
||||
#endif
|
||||
_widgetForNotifId[activity.ident()] = widget;
|
||||
}
|
||||
|
||||
widget->setActivity( activity );
|
||||
|
||||
// remember the list account name for the strayCat handling below.
|
||||
listAccountName = activity._accName;
|
||||
|
||||
// handle gui logs. In order to NOT annoy the user with every fetching of the
|
||||
// notifications the notification id is stored in a Set. Only if an id
|
||||
// is not in the set, it qualifies for guiLog.
|
||||
// Important: The _guiLoggedNotifications set must be wiped regularly which
|
||||
// will repeat the gui log.
|
||||
|
||||
// after one hour, clear the gui log notification store
|
||||
if( _guiLogTimer.elapsed() > 60*60*1000 ) {
|
||||
_guiLoggedNotifications.clear();
|
||||
}
|
||||
if( !_guiLoggedNotifications.contains(activity._id)) {
|
||||
QString host = activity._accName;
|
||||
// store the name of the account that sends the notification to be
|
||||
// able to add it to the tray notification
|
||||
// remove the user name from the account as that is not accurate here.
|
||||
int indx = host.indexOf(QChar('@'));
|
||||
if( indx>-1 ) {
|
||||
host.remove(0, 1+indx);
|
||||
}
|
||||
if( !host.isEmpty() ) {
|
||||
if( accNotified.contains(host)) {
|
||||
accNotified[host] = accNotified[host]+1;
|
||||
} else {
|
||||
accNotified[host] = 1;
|
||||
}
|
||||
}
|
||||
_guiLoggedNotifications.insert(activity._id);
|
||||
}
|
||||
}
|
||||
|
||||
// check if there are widgets that have no corresponding activity from
|
||||
// the server any more. Collect them in a list
|
||||
QList< Activity::Identifier > strayCats;
|
||||
foreach( auto id, _widgetForNotifId.keys() ) {
|
||||
NotificationWidget *widget = _widgetForNotifId[id];
|
||||
|
||||
bool found = false;
|
||||
// do not mark widgets of other accounts to delete.
|
||||
if( widget->activity()._accName != listAccountName ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach( auto activity, list ) {
|
||||
if( activity.ident() == id ) {
|
||||
// found an activity
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ! found ) {
|
||||
// the activity does not exist any more.
|
||||
strayCats.append(id);
|
||||
}
|
||||
}
|
||||
|
||||
// .. and now delete all these stray cat widgets.
|
||||
foreach( auto strayCatId, strayCats ) {
|
||||
NotificationWidget *widgetToGo = _widgetForNotifId[strayCatId];
|
||||
scheduleWidgetToRemove(widgetToGo, 0);
|
||||
}
|
||||
|
||||
checkActivityTabVisibility();
|
||||
|
||||
int newGuiLogCount = accNotified.count();
|
||||
|
||||
if( newGuiLogCount > 0 ) {
|
||||
// restart the gui log timer now that we show a notification
|
||||
_guiLogTimer.restart();
|
||||
|
||||
// Assemble a tray notification
|
||||
QString msg = tr("You received %n new notification(s) from %2.", "", accNotified[accNotified.keys().at(0)]).
|
||||
arg(accNotified.keys().at(0));
|
||||
|
||||
if( newGuiLogCount >= 2 ) {
|
||||
QString acc1 = accNotified.keys().at(0);
|
||||
QString acc2 = accNotified.keys().at(1);
|
||||
if( newGuiLogCount == 2 ) {
|
||||
int notiCount = accNotified[ acc1 ] + accNotified[ acc2 ];
|
||||
msg = tr("You received %n new notification(s) from %1 and %2.", "", notiCount).arg(acc1, acc2);
|
||||
} else {
|
||||
msg = tr("You received new notifications from %1, %2 and other accounts.").arg(acc1, acc2);
|
||||
}
|
||||
}
|
||||
|
||||
const QString log = tr("%1 Notifications - Action Required").arg(Theme::instance()->appNameGUI());
|
||||
emit guiLog( log, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotSendNotificationRequest(const QString& accountName, const QString& link, const QByteArray& verb)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Server Notification Request " << verb << link << "on account" << accountName;
|
||||
NotificationWidget *theSender = qobject_cast<NotificationWidget*>(sender());
|
||||
|
||||
const QStringList validVerbs = QStringList() << "GET" << "PUT" << "POST" << "DELETE";
|
||||
|
||||
if( validVerbs.contains(verb)) {
|
||||
AccountStatePtr acc = AccountManager::instance()->account(accountName);
|
||||
if( acc ) {
|
||||
NotificationConfirmJob *job = new NotificationConfirmJob(acc->account());
|
||||
QUrl l(link);
|
||||
job->setLinkAndVerb(l, verb);
|
||||
job->setWidget(theSender);
|
||||
connect( job, SIGNAL( networkError(QNetworkReply*)),
|
||||
this, SLOT(slotNotifyNetworkError(QNetworkReply*)));
|
||||
connect( job, SIGNAL( jobFinished(QString, int)),
|
||||
this, SLOT(slotNotifyServerFinished(QString, int)) );
|
||||
job->start();
|
||||
|
||||
// count the number of running notification requests. If this member var
|
||||
// is larger than zero, no new fetching of notifications is started
|
||||
_notificationRequestsRunning++;
|
||||
}
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "Notification Links: Invalid verb:" << verb;
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::endNotificationRequest( NotificationWidget *widget, int replyCode )
|
||||
{
|
||||
_notificationRequestsRunning--;
|
||||
if( widget ) {
|
||||
widget->slotNotificationRequestFinished(replyCode);
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotNotifyNetworkError( QNetworkReply *reply)
|
||||
{
|
||||
NotificationConfirmJob *job = qobject_cast<NotificationConfirmJob*>(sender());
|
||||
if( !job ) {
|
||||
return;
|
||||
}
|
||||
|
||||
int resultCode =0;
|
||||
if( reply ) {
|
||||
resultCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
}
|
||||
|
||||
endNotificationRequest(job->widget(), resultCode);
|
||||
qDebug() << Q_FUNC_INFO << "Server notify job failed with code " << resultCode;
|
||||
|
||||
}
|
||||
|
||||
void ActivityWidget::slotNotifyServerFinished( const QString& reply, int replyCode )
|
||||
{
|
||||
NotificationConfirmJob *job = qobject_cast<NotificationConfirmJob*>(sender());
|
||||
if( !job ) {
|
||||
return;
|
||||
}
|
||||
|
||||
endNotificationRequest(job->widget(), replyCode);
|
||||
// FIXME: remove the widget after a couple of seconds
|
||||
qDebug() << Q_FUNC_INFO << "Server Notification reply code"<< replyCode << reply;
|
||||
|
||||
// if the notification was successful start a timer that triggers
|
||||
// removal of the done widgets in a few seconds
|
||||
// Add 200 millisecs to the predefined value to make sure that the timer in
|
||||
// widget's method readyToClose() has elapsed.
|
||||
if( replyCode == OCS_SUCCESS_STATUS_CODE ) {
|
||||
scheduleWidgetToRemove( job->widget() );
|
||||
}
|
||||
}
|
||||
|
||||
// blacklist the activity coming in here.
|
||||
void ActivityWidget::slotRequestCleanupAndBlacklist(const Activity& blacklistActivity)
|
||||
{
|
||||
if ( ! _blacklistedNotifications.contains(blacklistActivity) ) {
|
||||
_blacklistedNotifications.append(blacklistActivity);
|
||||
}
|
||||
|
||||
NotificationWidget *widget = _widgetForNotifId[ blacklistActivity.ident() ];
|
||||
scheduleWidgetToRemove(widget);
|
||||
}
|
||||
|
||||
void ActivityWidget::scheduleWidgetToRemove(NotificationWidget *widget, int milliseconds)
|
||||
{
|
||||
if( !widget ) {
|
||||
return;
|
||||
}
|
||||
// in five seconds from now, remove the widget.
|
||||
QDateTime removeTime = QDateTime::currentDateTimeUtc().addMSecs(milliseconds);
|
||||
QDateTime &it = _widgetsToRemove[widget];
|
||||
if (!it.isValid() || it > removeTime) {
|
||||
it = removeTime;
|
||||
}
|
||||
if( !_removeTimer.isActive() ) {
|
||||
_removeTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
// Called every second to see if widgets need to be removed.
|
||||
void ActivityWidget::slotCheckToCleanWidgets()
|
||||
{
|
||||
auto currentTime = QDateTime::currentDateTimeUtc();
|
||||
auto it = _widgetsToRemove.begin();
|
||||
while (it != _widgetsToRemove.end()) {
|
||||
// loop over all widgets in the to-remove queue
|
||||
QDateTime t = it.value();
|
||||
NotificationWidget *widget = it.key();
|
||||
|
||||
if( currentTime > t ) {
|
||||
// found one to remove!
|
||||
Activity::Identifier id = widget->activity().ident();
|
||||
_widgetForNotifId.remove(id);
|
||||
widget->deleteLater();
|
||||
it = _widgetsToRemove.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
if( _widgetsToRemove.isEmpty() ) {
|
||||
_removeTimer.stop();
|
||||
}
|
||||
|
||||
// check to see if the whole notification pane should be hidden
|
||||
if( _widgetForNotifId.isEmpty() ) {
|
||||
_ui->_notifyLabel->setHidden(true);
|
||||
_ui->_notifyScroll->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ==================================================================== */
|
||||
|
||||
ActivitySettings::ActivitySettings(QWidget *parent)
|
||||
@@ -513,16 +406,13 @@ ActivitySettings::ActivitySettings(QWidget *parent)
|
||||
_tab = new QTabWidget(this);
|
||||
hbox->addWidget(_tab);
|
||||
_activityWidget = new ActivityWidget(this);
|
||||
_activityTabId = _tab->insertTab(0, _activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
|
||||
_tab->addTab(_activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
|
||||
connect(_activityWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard()));
|
||||
connect(_activityWidget, SIGNAL(hideActivityTab(bool)), this, SLOT(setActivityTabHidden(bool)));
|
||||
connect(_activityWidget, SIGNAL(guiLog(QString,QString)), this, SIGNAL(guiLog(QString,QString)));
|
||||
|
||||
|
||||
_protocolWidget = new ProtocolWidget(this);
|
||||
_tab->insertTab(1, _protocolWidget, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol"));
|
||||
_tab->addTab(_protocolWidget, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol"));
|
||||
connect(_protocolWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard()));
|
||||
connect(_protocolWidget, SIGNAL(issueItemCountUpdated(int)),
|
||||
this, SLOT(slotShowIssueItemCount(int)));
|
||||
|
||||
// Add the not-synced list into the tab
|
||||
QWidget *w = new QWidget;
|
||||
@@ -537,49 +427,14 @@ ActivitySettings::ActivitySettings(QWidget *parent)
|
||||
connect(_copyBtn, SIGNAL(clicked()), this, SLOT(slotCopyToClipboard()));
|
||||
|
||||
w->setLayout(vbox2);
|
||||
_syncIssueTabId = _tab->insertTab(2, w, Theme::instance()->syncStateIcon(SyncResult::Problem), QString());
|
||||
slotShowIssueItemCount(0); // to display the label.
|
||||
_tab->addTab(w, Theme::instance()->syncStateIcon(SyncResult::Problem), tr("Not Synced"));
|
||||
|
||||
// Add a progress indicator to spin if the acitivity list is updated.
|
||||
_progressIndicator = new QProgressIndicator(this);
|
||||
_tab->setCornerWidget(_progressIndicator);
|
||||
|
||||
connect(&_notificationCheckTimer, SIGNAL(timeout()),
|
||||
this, SLOT(slotRegularNotificationCheck()));
|
||||
|
||||
// connect a model signal to stop the animation.
|
||||
connect(_activityWidget, SIGNAL(rowsInserted()), _progressIndicator, SLOT(stopAnimation()));
|
||||
|
||||
// We want the protocol be the default
|
||||
_tab->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void ActivitySettings::setNotificationRefreshInterval( quint64 interval )
|
||||
{
|
||||
qDebug() << "Starting Notification refresh timer with " << interval/1000 << " sec interval";
|
||||
_notificationCheckTimer.start(interval);
|
||||
}
|
||||
|
||||
void ActivitySettings::setActivityTabHidden(bool hidden)
|
||||
{
|
||||
if( hidden && _activityTabId > -1 ) {
|
||||
_tab->removeTab(_activityTabId);
|
||||
_activityTabId = -1;
|
||||
}
|
||||
|
||||
if( !hidden && _activityTabId == -1 ) {
|
||||
_activityTabId = _tab->insertTab(0, _activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
|
||||
}
|
||||
}
|
||||
|
||||
void ActivitySettings::slotShowIssueItemCount(int cnt)
|
||||
{
|
||||
QString cntText = tr("Not Synced");
|
||||
if( cnt ) {
|
||||
//: %1 is the number of not synced files.
|
||||
cntText = tr("Not Synced (%1)").arg(cnt);
|
||||
}
|
||||
_tab->setTabText(_syncIssueTabId, cntText);
|
||||
}
|
||||
|
||||
void ActivitySettings::slotCopyToClipboard()
|
||||
@@ -615,32 +470,10 @@ void ActivitySettings::slotRemoveAccount( AccountState *ptr )
|
||||
|
||||
void ActivitySettings::slotRefresh( AccountState* ptr )
|
||||
{
|
||||
// QElapsedTimer isn't actually constructed as invalid.
|
||||
if ( !_timeSinceLastCheck.contains(ptr) ) {
|
||||
_timeSinceLastCheck[ptr].invalidate();
|
||||
}
|
||||
QElapsedTimer & timer = _timeSinceLastCheck[ptr];
|
||||
|
||||
// Fetch Activities only if visible and if last check is longer than 15 secs ago
|
||||
if( timer.isValid() && timer.elapsed() < NOTIFICATION_REQUEST_FREE_PERIOD ) {
|
||||
qDebug() << Q_FUNC_INFO << "do not check as last check is only secs ago: " << timer.elapsed() / 1000;
|
||||
return;
|
||||
}
|
||||
if( ptr && ptr->isConnected() ) {
|
||||
if( isVisible() || !timer.isValid() ) {
|
||||
_progressIndicator->startAnimation();
|
||||
_activityWidget->slotRefreshActivities( ptr);
|
||||
}
|
||||
_activityWidget->slotRefreshNotifications(ptr);
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivitySettings::slotRegularNotificationCheck()
|
||||
{
|
||||
AccountManager *am = AccountManager::instance();
|
||||
foreach (AccountStatePtr a, am->accounts()) {
|
||||
slotRefresh(a.data());
|
||||
if( ptr && ptr->isConnected() && isVisible()) {
|
||||
qDebug() << "Refreshing Activity list for " << ptr->account()->displayName();
|
||||
_progressIndicator->startAnimation();
|
||||
_activityWidget->slotRefresh(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+88
-51
@@ -22,7 +22,6 @@
|
||||
#include "progressdispatcher.h"
|
||||
#include "owncloudgui.h"
|
||||
#include "account.h"
|
||||
#include "activitydata.h"
|
||||
|
||||
#include "ui_activitywidget.h"
|
||||
|
||||
@@ -34,15 +33,97 @@ namespace OCC {
|
||||
class Account;
|
||||
class AccountStatusPtr;
|
||||
class ProtocolWidget;
|
||||
class JsonApiJob;
|
||||
class NotificationWidget;
|
||||
class ActivityListModel;
|
||||
|
||||
namespace Ui {
|
||||
class ActivityWidget;
|
||||
}
|
||||
class Application;
|
||||
|
||||
/**
|
||||
* @brief Activity Structure
|
||||
* @ingroup gui
|
||||
*
|
||||
* contains all the information describing a single activity.
|
||||
*/
|
||||
|
||||
class Activity
|
||||
{
|
||||
public:
|
||||
qlonglong _id;
|
||||
QString _subject;
|
||||
QString _message;
|
||||
QString _file;
|
||||
QUrl _link;
|
||||
QDateTime _dateTime;
|
||||
QString _accName;
|
||||
|
||||
/**
|
||||
* @brief Sort operator to sort the list youngest first.
|
||||
* @param val
|
||||
* @return
|
||||
*/
|
||||
bool operator<( const Activity& val ) const {
|
||||
return _dateTime.toMSecsSinceEpoch() > val._dateTime.toMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The ActivityList
|
||||
* @ingroup gui
|
||||
*
|
||||
* A QList based list of Activities
|
||||
*/
|
||||
class ActivityList:public QList<Activity>
|
||||
{
|
||||
public:
|
||||
void setAccountName( const QString& name );
|
||||
QString accountName() const;
|
||||
|
||||
private:
|
||||
QString _accountName;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The ActivityListModel
|
||||
* @ingroup gui
|
||||
*
|
||||
* Simple list model to provide the list view with data.
|
||||
*/
|
||||
class ActivityListModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActivityListModel(QWidget *parent=0);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
|
||||
bool canFetchMore(const QModelIndex& ) const Q_DECL_OVERRIDE;
|
||||
void fetchMore(const QModelIndex&) Q_DECL_OVERRIDE;
|
||||
|
||||
ActivityList activityList() { return _finalList; }
|
||||
|
||||
public slots:
|
||||
void slotRefreshActivity(AccountState* ast);
|
||||
void slotRemoveAccount( AccountState *ast );
|
||||
|
||||
private slots:
|
||||
void slotActivitiesReceived(const QVariantMap& json, int statusCode);
|
||||
|
||||
signals:
|
||||
void accountWithoutActivityApp(AccountState* ast);
|
||||
|
||||
private:
|
||||
void startFetchJob(AccountState* s);
|
||||
void combineActivityLists();
|
||||
|
||||
QMap<AccountState*, ActivityList> _activityLists;
|
||||
ActivityList _finalList;
|
||||
QSet<AccountState*> _currentlyFetching;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The ActivityWidget class
|
||||
* @ingroup gui
|
||||
@@ -60,37 +141,16 @@ public:
|
||||
QSize sizeHint() const Q_DECL_OVERRIDE { return ownCloudGui::settingsDialogSize(); }
|
||||
void storeActivityList(QTextStream &ts);
|
||||
|
||||
/**
|
||||
* Adjusts the activity tab's and some widgets' visibility
|
||||
*
|
||||
* Based on whether activities are enabled and whether notifications are
|
||||
* available.
|
||||
*/
|
||||
void checkActivityTabVisibility();
|
||||
|
||||
public slots:
|
||||
void slotOpenFile(QModelIndex indx);
|
||||
void slotRefreshActivities(AccountState* ptr);
|
||||
void slotRefreshNotifications(AccountState *ptr);
|
||||
void slotRefresh(AccountState* ptr);
|
||||
void slotRemoveAccount( AccountState *ptr );
|
||||
void slotAccountActivityStatus(AccountState *ast, int statusCode);
|
||||
void slotRequestCleanupAndBlacklist(const Activity& blacklistActivity);
|
||||
void slotAccountWithoutActivityApp(AccountState *ast);
|
||||
|
||||
signals:
|
||||
void guiLog(const QString&, const QString&);
|
||||
void copyToClipboard();
|
||||
void rowsInserted();
|
||||
void hideActivityTab(bool);
|
||||
void newNotificationList(const ActivityList& list);
|
||||
|
||||
private slots:
|
||||
void slotBuildNotificationDisplay(const ActivityList& list);
|
||||
void slotSendNotificationRequest(const QString &accountName, const QString& link, const QByteArray &verb);
|
||||
void slotNotifyNetworkError( QNetworkReply* );
|
||||
void slotNotifyServerFinished( const QString& reply, int replyCode );
|
||||
void endNotificationRequest(NotificationWidget *widget , int replyCode);
|
||||
void scheduleWidgetToRemove(NotificationWidget *widget, int milliseconds = 4500);
|
||||
void slotCheckToCleanWidgets();
|
||||
|
||||
private:
|
||||
void showLabels();
|
||||
@@ -99,21 +159,8 @@ private:
|
||||
QPushButton *_copyBtn;
|
||||
|
||||
QSet<QString> _accountsWithoutActivities;
|
||||
QMap<Activity::Identifier, NotificationWidget*> _widgetForNotifId;
|
||||
QElapsedTimer _guiLogTimer;
|
||||
QSet<int> _guiLoggedNotifications;
|
||||
ActivityList _blacklistedNotifications;
|
||||
|
||||
QHash<NotificationWidget*, QDateTime> _widgetsToRemove;
|
||||
QTimer _removeTimer;
|
||||
|
||||
// number of currently running notification requests. If non zero,
|
||||
// no query for notifications is started.
|
||||
int _notificationRequestsRunning;
|
||||
|
||||
ActivityListModel *_model;
|
||||
QVBoxLayout *_notificationsLayout;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -136,13 +183,7 @@ public slots:
|
||||
void slotRefresh( AccountState* ptr );
|
||||
void slotRemoveAccount( AccountState *ptr );
|
||||
|
||||
void setNotificationRefreshInterval( quint64 interval );
|
||||
|
||||
private slots:
|
||||
void slotCopyToClipboard();
|
||||
void setActivityTabHidden(bool hidden);
|
||||
void slotRegularNotificationCheck();
|
||||
void slotShowIssueItemCount(int cnt);
|
||||
|
||||
signals:
|
||||
void guiLog(const QString&, const QString&);
|
||||
@@ -151,14 +192,10 @@ private:
|
||||
bool event(QEvent* e) Q_DECL_OVERRIDE;
|
||||
|
||||
QTabWidget *_tab;
|
||||
int _activityTabId;
|
||||
int _syncIssueTabId;
|
||||
|
||||
ActivityWidget *_activityWidget;
|
||||
ProtocolWidget *_protocolWidget;
|
||||
QProgressIndicator *_progressIndicator;
|
||||
QTimer _notificationCheckTimer;
|
||||
QHash<AccountState*, QElapsedTimer> _timeSinceLastCheck;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -15,81 +15,23 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="_notifyLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QLabel" name="_headerLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="_notifyScroll">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="_scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>677</width>
|
||||
<height>70</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QListView" name="_activityList"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="_headerLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QLabel" name="_bottomLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QListView" name="_activityList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="_bottomLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QDialogButtonBox" name="_dialogButtonBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -219,14 +219,10 @@ void Application::slotAccountStateRemoved(AccountState *accountState)
|
||||
if (_gui) {
|
||||
disconnect(accountState, SIGNAL(stateChanged(int)),
|
||||
_gui, SLOT(slotAccountStateChanged()));
|
||||
disconnect(accountState->account().data(), SIGNAL(serverVersionChanged(Account*,QString,QString)),
|
||||
_gui, SLOT(slotTrayMessageIfServerUnsupported(Account*)));
|
||||
}
|
||||
if (_folderManager) {
|
||||
disconnect(accountState, SIGNAL(stateChanged(int)),
|
||||
_folderManager.data(), SLOT(slotAccountStateChanged()));
|
||||
disconnect(accountState->account().data(), SIGNAL(serverVersionChanged(Account*,QString,QString)),
|
||||
_folderManager.data(), SLOT(slotServerVersionChanged(Account*)));
|
||||
}
|
||||
|
||||
// if there is no more account, show the wizard.
|
||||
@@ -241,14 +237,8 @@ void Application::slotAccountStateAdded(AccountState *accountState)
|
||||
{
|
||||
connect(accountState, SIGNAL(stateChanged(int)),
|
||||
_gui, SLOT(slotAccountStateChanged()));
|
||||
connect(accountState->account().data(), SIGNAL(serverVersionChanged(Account*,QString,QString)),
|
||||
_gui, SLOT(slotTrayMessageIfServerUnsupported(Account*)));
|
||||
connect(accountState, SIGNAL(stateChanged(int)),
|
||||
_folderManager.data(), SLOT(slotAccountStateChanged()));
|
||||
connect(accountState->account().data(), SIGNAL(serverVersionChanged(Account*,QString,QString)),
|
||||
_folderManager.data(), SLOT(slotServerVersionChanged(Account*)));
|
||||
|
||||
_gui->slotTrayMessageIfServerUnsupported(accountState->account().data());
|
||||
}
|
||||
|
||||
void Application::slotCleanup()
|
||||
|
||||
+342
-132
@@ -56,10 +56,9 @@ static void csyncLogCatcher(int /*verbosity*/,
|
||||
|
||||
|
||||
Folder::Folder(const FolderDefinition& definition,
|
||||
AccountState* accountState,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, _accountState(accountState)
|
||||
, _accountState(0)
|
||||
, _definition(definition)
|
||||
, _csyncError(false)
|
||||
, _csyncUnavail(false)
|
||||
@@ -70,10 +69,8 @@ Folder::Folder(const FolderDefinition& definition,
|
||||
, _consecutiveFailingSyncs(0)
|
||||
, _consecutiveFollowUpSyncs(0)
|
||||
, _journal(definition.localPath)
|
||||
, _csync_ctx(0)
|
||||
{
|
||||
qRegisterMetaType<SyncFileItemVector>("SyncFileItemVector");
|
||||
qRegisterMetaType<SyncFileItem::Direction>("SyncFileItem::Direction");
|
||||
|
||||
qsrand(QTime::currentTime().msec());
|
||||
_timeSinceLastSyncStart.start();
|
||||
_timeSinceLastSyncDone.start();
|
||||
@@ -88,37 +85,68 @@ Folder::Folder(const FolderDefinition& definition,
|
||||
checkLocalPath();
|
||||
|
||||
_syncResult.setFolder(_definition.alias);
|
||||
}
|
||||
|
||||
_engine.reset(new SyncEngine(_accountState->account(), path(), remoteUrl(), remotePath(), &_journal));
|
||||
// pass the setting if hidden files are to be ignored, will be read in csync_update
|
||||
_engine->setIgnoreHiddenFiles(_definition.ignoreHiddenFiles);
|
||||
bool Folder::init()
|
||||
{
|
||||
// We need to reconstruct the url because the path needs to be fully decoded, as csync will re-encode the path:
|
||||
// Remember that csync will just append the filename to the path and pass it to the vio plugin.
|
||||
// csync_owncloud will then re-encode everything.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
QUrl url = remoteUrl();
|
||||
QString url_string = url.scheme() + QLatin1String("://") + url.authority(QUrl::EncodeDelimiters) + url.path(QUrl::FullyDecoded);
|
||||
#else
|
||||
// Qt4 was broken anyway as it did not encode the '#' as it should have done (it was actually a problem when parsing the path from QUrl::setPath
|
||||
QString url_string = remoteUrl().toString();
|
||||
#endif
|
||||
url_string = Utility::toCSyncScheme(url_string);
|
||||
|
||||
if (!setIgnoredFiles())
|
||||
qWarning("Could not read system exclude file");
|
||||
QString localpath = path();
|
||||
|
||||
connect(_engine.data(), SIGNAL(rootEtag(QString)), this, SLOT(etagRetreivedFromSyncEngine(QString)));
|
||||
connect(_engine.data(), SIGNAL(treeWalkResult(const SyncFileItemVector&)),
|
||||
this, SLOT(slotThreadTreeWalkResult(const SyncFileItemVector&)), Qt::QueuedConnection);
|
||||
if( csync_create( &_csync_ctx, localpath.toUtf8().data(), url_string.toUtf8().data() ) < 0 ) {
|
||||
qDebug() << "Unable to create csync-context!";
|
||||
slotSyncError(tr("Unable to create csync-context"));
|
||||
_csync_ctx = 0;
|
||||
} else {
|
||||
csync_set_log_callback( csyncLogCatcher );
|
||||
csync_set_log_level( Logger::instance()->isNoop() ? 0 : 11 );
|
||||
|
||||
connect(_engine.data(), SIGNAL(started()), SLOT(slotSyncStarted()), Qt::QueuedConnection);
|
||||
connect(_engine.data(), SIGNAL(finished(bool)), SLOT(slotSyncFinished(bool)), Qt::QueuedConnection);
|
||||
connect(_engine.data(), SIGNAL(csyncError(QString)), SLOT(slotSyncError(QString)), Qt::QueuedConnection);
|
||||
connect(_engine.data(), SIGNAL(csyncUnavailable()), SLOT(slotCsyncUnavailable()), Qt::QueuedConnection);
|
||||
Q_ASSERT( _accountState );
|
||||
|
||||
//direct connection so the message box is blocking the sync.
|
||||
connect(_engine.data(), SIGNAL(aboutToRemoveAllFiles(SyncFileItem::Direction,bool*)),
|
||||
SLOT(slotAboutToRemoveAllFiles(SyncFileItem::Direction,bool*)));
|
||||
connect(_engine.data(), SIGNAL(aboutToRestoreBackup(bool*)),
|
||||
SLOT(slotAboutToRestoreBackup(bool*)));
|
||||
connect(_engine.data(), SIGNAL(folderDiscovered(bool,QString)), this, SLOT(slotFolderDiscovered(bool,QString)));
|
||||
connect(_engine.data(), SIGNAL(transmissionProgress(ProgressInfo)), this, SLOT(slotTransmissionProgress(ProgressInfo)));
|
||||
connect(_engine.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SLOT(slotItemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
connect(_engine.data(), SIGNAL(newBigFolder(QString)), this, SLOT(slotNewBigFolderDiscovered(QString)));
|
||||
if( csync_init( _csync_ctx ) < 0 ) {
|
||||
qDebug() << "Could not initialize csync!" << csync_get_status(_csync_ctx) << csync_get_status_string(_csync_ctx);
|
||||
QString errStr = SyncEngine::csyncErrorToString(CSYNC_STATUS(csync_get_status(_csync_ctx)));
|
||||
const char *errMsg = csync_get_status_string(_csync_ctx);
|
||||
if( errMsg ) {
|
||||
errStr += QLatin1String("<br/>");
|
||||
errStr += QString::fromUtf8(errMsg);
|
||||
}
|
||||
slotSyncError(errStr);
|
||||
csync_destroy(_csync_ctx);
|
||||
_csync_ctx = 0;
|
||||
}
|
||||
}
|
||||
return _csync_ctx;
|
||||
}
|
||||
|
||||
Folder::~Folder()
|
||||
{
|
||||
if( _engine ) {
|
||||
_engine->abort();
|
||||
_engine.reset(0);
|
||||
}
|
||||
// Destroy csync here.
|
||||
csync_destroy(_csync_ctx);
|
||||
}
|
||||
|
||||
void Folder::setAccountState( AccountState *account )
|
||||
{
|
||||
_accountState = account;
|
||||
}
|
||||
|
||||
AccountState* Folder::accountState() const
|
||||
{
|
||||
return _accountState;
|
||||
}
|
||||
|
||||
void Folder::checkLocalPath()
|
||||
@@ -209,7 +237,7 @@ QString Folder::cleanPath()
|
||||
|
||||
bool Folder::isBusy() const
|
||||
{
|
||||
return _engine->isSyncRunning();
|
||||
return !_engine.isNull();
|
||||
}
|
||||
|
||||
QString Folder::remotePath() const
|
||||
@@ -219,6 +247,9 @@ QString Folder::remotePath() const
|
||||
|
||||
QUrl Folder::remoteUrl() const
|
||||
{
|
||||
if (!_accountState) {
|
||||
return QUrl("http://deleted-account");
|
||||
}
|
||||
return Account::concatUrlPath(_accountState->account()->davUrl(), remotePath());
|
||||
}
|
||||
|
||||
@@ -229,25 +260,24 @@ bool Folder::syncPaused() const
|
||||
|
||||
bool Folder::canSync() const
|
||||
{
|
||||
return !syncPaused() && accountState()->canSync();
|
||||
return !syncPaused() && accountState()->isConnected();
|
||||
}
|
||||
|
||||
void Folder::setSyncPaused( bool paused )
|
||||
{
|
||||
if (paused == _definition.paused) {
|
||||
return;
|
||||
if (paused != _definition.paused) {
|
||||
_definition.paused = paused;
|
||||
saveToSettings();
|
||||
}
|
||||
|
||||
_definition.paused = paused;
|
||||
saveToSettings();
|
||||
|
||||
if( !paused ) {
|
||||
setSyncState(SyncResult::NotYetStarted);
|
||||
// qDebug() << "Syncing enabled on folder " << name();
|
||||
} else {
|
||||
// do not stop or start the watcher here, that is done internally by
|
||||
// folder class. Even if the watcher fires, the folder does not
|
||||
// schedule itself because it checks the var. _enabled before.
|
||||
setSyncState(SyncResult::Paused);
|
||||
}
|
||||
emit syncPausedChanged(this, paused);
|
||||
emit syncStateChange();
|
||||
}
|
||||
|
||||
void Folder::setSyncState(SyncResult::Status state)
|
||||
@@ -270,6 +300,11 @@ void Folder::slotRunEtagJob()
|
||||
{
|
||||
qDebug() << "* Trying to check" << remoteUrl().toString() << "for changes via ETag check. (time since last sync:" << (_timeSinceLastSyncDone.elapsed() / 1000) << "s)";
|
||||
|
||||
if (!_accountState) {
|
||||
qDebug() << "Can't run EtagJob, account is deleted";
|
||||
return;
|
||||
}
|
||||
|
||||
AccountPtr account = _accountState->account();
|
||||
|
||||
if (!_requestEtagJob.isNull()) {
|
||||
@@ -277,7 +312,7 @@ void Folder::slotRunEtagJob()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canSync()) {
|
||||
if (_definition.paused || !_accountState->isConnected()) {
|
||||
qDebug() << "Not syncing. :" << remoteUrl().toString() << _definition.paused << AccountState::stateString(_accountState->state());
|
||||
return;
|
||||
}
|
||||
@@ -337,7 +372,9 @@ void Folder::etagRetreived(const QString& etag)
|
||||
emit scheduleToSync(this);
|
||||
}
|
||||
|
||||
_accountState->tagLastSuccessfullETagRequest();
|
||||
if( _accountState ) {
|
||||
_accountState->tagLastSuccessfullETagRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void Folder::etagRetreivedFromSyncEngine(const QString& etag)
|
||||
@@ -356,19 +393,17 @@ void Folder::bubbleUpSyncResult()
|
||||
int updatedItems = 0;
|
||||
int ignoredItems = 0;
|
||||
int renamedItems = 0;
|
||||
int conflictItems = 0;
|
||||
int errorItems = 0;
|
||||
|
||||
SyncFileItemPtr firstItemNew;
|
||||
SyncFileItemPtr firstItemDeleted;
|
||||
SyncFileItemPtr firstItemUpdated;
|
||||
SyncFileItemPtr firstItemRenamed;
|
||||
SyncFileItemPtr firstConflictItem;
|
||||
SyncFileItemPtr firstItemError;
|
||||
|
||||
SyncRunFileLog syncFileLog;
|
||||
|
||||
syncFileLog.start(path(), _engine->isSyncRunning() ? _engine->stopWatch() : Utility::StopWatch() );
|
||||
syncFileLog.start(path(), _engine ? _engine->stopWatch() : Utility::StopWatch() );
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
@@ -379,7 +414,6 @@ void Folder::bubbleUpSyncResult()
|
||||
|
||||
// and process the item to the gui
|
||||
if( item->_status == SyncFileItem::FatalError || item->_status == SyncFileItem::NormalError ) {
|
||||
//: this displays an error string (%2) for a file %1
|
||||
slotSyncError( tr("%1: %2").arg(item->_file, item->_errorString) );
|
||||
errorItems++;
|
||||
if (!firstItemError) {
|
||||
@@ -388,11 +422,6 @@ void Folder::bubbleUpSyncResult()
|
||||
} else if( item->_status == SyncFileItem::FileIgnored ) {
|
||||
// ignored files don't show up in notifications
|
||||
continue;
|
||||
} else if( item->_status == SyncFileItem::Conflict ) {
|
||||
conflictItems++;
|
||||
if (!firstConflictItem) {
|
||||
firstConflictItem = item;
|
||||
}
|
||||
} else {
|
||||
// add new directories or remove gone away dirs to the watcher
|
||||
if (item->_isDirectory && item->_instruction == CSYNC_INSTRUCTION_NEW ) {
|
||||
@@ -415,6 +444,7 @@ void Folder::bubbleUpSyncResult()
|
||||
if (!firstItemDeleted)
|
||||
firstItemDeleted = item;
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_CONFLICT:
|
||||
case CSYNC_INSTRUCTION_SYNC:
|
||||
if (!item->_isDirectory) {
|
||||
updatedItems++;
|
||||
@@ -448,35 +478,32 @@ void Folder::bubbleUpSyncResult()
|
||||
_syncResult.setWarnCount(ignoredItems);
|
||||
|
||||
if( firstItemNew ) {
|
||||
createGuiLog( firstItemNew->_file, LogStatusNew, newItems );
|
||||
createGuiLog( firstItemNew->_file, SyncFileStatus::STATUS_NEW, newItems );
|
||||
}
|
||||
if( firstItemDeleted ) {
|
||||
createGuiLog( firstItemDeleted->_file, LogStatusRemove, removedItems );
|
||||
createGuiLog( firstItemDeleted->_file, SyncFileStatus::STATUS_REMOVE, removedItems );
|
||||
}
|
||||
if( firstItemUpdated ) {
|
||||
createGuiLog( firstItemUpdated->_file, LogStatusUpdated, updatedItems );
|
||||
createGuiLog( firstItemUpdated->_file, SyncFileStatus::STATUS_UPDATED, updatedItems );
|
||||
}
|
||||
|
||||
if( firstItemRenamed ) {
|
||||
LogStatus status(LogStatusRename);
|
||||
SyncFileStatus status(SyncFileStatus::STATUS_RENAME);
|
||||
// if the path changes it's rather a move
|
||||
QDir renTarget = QFileInfo(firstItemRenamed->_renameTarget).dir();
|
||||
QDir renSource = QFileInfo(firstItemRenamed->_file).dir();
|
||||
if(renTarget != renSource) {
|
||||
status = LogStatusMove;
|
||||
status.set(SyncFileStatus::STATUS_MOVE);
|
||||
}
|
||||
createGuiLog( firstItemRenamed->_originalFile, status, renamedItems, firstItemRenamed->_renameTarget );
|
||||
}
|
||||
|
||||
if( firstConflictItem ) {
|
||||
createGuiLog( firstConflictItem->_file, LogStatusConflict, conflictItems );
|
||||
}
|
||||
createGuiLog( firstItemError->_file, LogStatusError, errorItems );
|
||||
createGuiLog( firstItemError->_file, SyncFileStatus::STATUS_ERROR, errorItems );
|
||||
|
||||
qDebug() << "OO folder slotSyncFinished: result: " << int(_syncResult.status());
|
||||
}
|
||||
|
||||
void Folder::createGuiLog( const QString& filename, LogStatus status, int count,
|
||||
void Folder::createGuiLog( const QString& filename, SyncFileStatus status, int count,
|
||||
const QString& renameTarget )
|
||||
{
|
||||
if(count > 0) {
|
||||
@@ -485,56 +512,53 @@ void Folder::createGuiLog( const QString& filename, LogStatus status, int count,
|
||||
QString file = QDir::toNativeSeparators(filename);
|
||||
QString text;
|
||||
|
||||
switch (status) {
|
||||
case LogStatusRemove:
|
||||
// not all possible values of status are evaluated here because the others
|
||||
// are not used in the calling function. Please check there.
|
||||
switch (status.tag()) {
|
||||
case SyncFileStatus::STATUS_REMOVE:
|
||||
if( count > 1 ) {
|
||||
text = tr("%1 and %n other file(s) have been removed.", "", count-1).arg(file);
|
||||
text = tr("%1 and %2 other files have been removed.", "%1 names a file.").arg(file).arg(count-1);
|
||||
} else {
|
||||
text = tr("%1 has been removed.", "%1 names a file.").arg(file);
|
||||
}
|
||||
break;
|
||||
case LogStatusNew:
|
||||
case SyncFileStatus::STATUS_NEW:
|
||||
if( count > 1 ) {
|
||||
text = tr("%1 and %n other file(s) have been downloaded.", "", count-1).arg(file);
|
||||
text = tr("%1 and %2 other files have been downloaded.", "%1 names a file.").arg(file).arg(count-1);
|
||||
} else {
|
||||
text = tr("%1 has been downloaded.", "%1 names a file.").arg(file);
|
||||
}
|
||||
break;
|
||||
case LogStatusUpdated:
|
||||
case SyncFileStatus::STATUS_UPDATED:
|
||||
if( count > 1 ) {
|
||||
text = tr("%1 and %n other file(s) have been updated.", "", count-1).arg(file);
|
||||
text = tr("%1 and %2 other files have been updated.").arg(file).arg(count-1);
|
||||
} else {
|
||||
text = tr("%1 has been updated.", "%1 names a file.").arg(file);
|
||||
}
|
||||
break;
|
||||
case LogStatusRename:
|
||||
case SyncFileStatus::STATUS_RENAME:
|
||||
if( count > 1 ) {
|
||||
text = tr("%1 has been renamed to %2 and %n other file(s) have been renamed.", "", count-1).arg(file).arg(renameTarget);
|
||||
text = tr("%1 has been renamed to %2 and %3 other files have been renamed.").arg(file).arg(renameTarget).arg(count-1);
|
||||
} else {
|
||||
text = tr("%1 has been renamed to %2.", "%1 and %2 name files.").arg(file).arg(renameTarget);
|
||||
}
|
||||
break;
|
||||
case LogStatusMove:
|
||||
case SyncFileStatus::STATUS_MOVE:
|
||||
if( count > 1 ) {
|
||||
text = tr("%1 has been moved to %2 and %n other file(s) have been moved.", "", count-1).arg(file).arg(renameTarget);
|
||||
text = tr("%1 has been moved to %2 and %3 other files have been moved.").arg(file).arg(renameTarget).arg(count-1);
|
||||
} else {
|
||||
text = tr("%1 has been moved to %2.").arg(file).arg(renameTarget);
|
||||
}
|
||||
break;
|
||||
case LogStatusConflict:
|
||||
case SyncFileStatus::STATUS_ERROR:
|
||||
if( count > 1 ) {
|
||||
text = tr("%1 has and %n other file(s) have sync conflicts.", "", count-1).arg(file);
|
||||
} else {
|
||||
text = tr("%1 has a sync conflict. Please check the conflict file!").arg(file);
|
||||
}
|
||||
break;
|
||||
case LogStatusError:
|
||||
if( count > 1 ) {
|
||||
text = tr("%1 and %n other file(s) could not be synced due to errors. See the log for details.", "", count-1).arg(file);
|
||||
text = tr("%1 and %2 other files could not be synced due to errors. See the log for details.", "%1 names a file.").arg(file).arg(count-1);
|
||||
} else {
|
||||
text = tr("%1 could not be synced due to an error. See the log for details.").arg(file);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if( !text.isEmpty() ) {
|
||||
@@ -577,7 +601,7 @@ void Folder::slotWatchedPathChanged(const QString& path)
|
||||
{
|
||||
// When no sync is running or it's in the prepare phase, we can
|
||||
// always schedule a new sync.
|
||||
if (! _engine->isSyncRunning() || _syncResult.status() == SyncResult::SyncPrepare) {
|
||||
if (! _engine || _syncResult.status() == SyncResult::SyncPrepare) {
|
||||
emit scheduleToSync(this);
|
||||
return;
|
||||
}
|
||||
@@ -605,14 +629,91 @@ void Folder::slotWatchedPathChanged(const QString& path)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this item should get an ERROR icon through the Socket API.
|
||||
*
|
||||
* The Socket API should only present serious, permanent errors to the user.
|
||||
* In particular SoftErrors should just retain their 'needs to be synced'
|
||||
* icon as the problem is most likely going to resolve itself quickly and
|
||||
* automatically.
|
||||
*/
|
||||
static bool showErrorInSocketApi(const SyncFileItem& item)
|
||||
{
|
||||
const auto status = item._status;
|
||||
return status == SyncFileItem::NormalError
|
||||
|| status == SyncFileItem::FatalError;
|
||||
}
|
||||
|
||||
static void addErroredSyncItemPathsToList(const SyncFileItemVector& items, QSet<QString>* set) {
|
||||
foreach (const SyncFileItemPtr &item, items) {
|
||||
if (showErrorInSocketApi(*item)) {
|
||||
set->insert(item->_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Folder::slotThreadTreeWalkResult(const SyncFileItemVector& items)
|
||||
{
|
||||
addErroredSyncItemPathsToList(items, &this->_stateLastSyncItemsWithErrorNew);
|
||||
_syncResult.setSyncFileItemVector(items);
|
||||
}
|
||||
|
||||
void Folder::slotAboutToPropagate(SyncFileItemVector& items)
|
||||
{
|
||||
// empty the tainted list since the status generation code will use the _syncedItems
|
||||
// (which imply the folder) to generate the syncing state icon now.
|
||||
_stateTaintedFolders.clear();
|
||||
|
||||
addErroredSyncItemPathsToList(items, &this->_stateLastSyncItemsWithErrorNew);
|
||||
}
|
||||
|
||||
|
||||
bool Folder::estimateState(QString fn, csync_ftw_type_e t, SyncFileStatus* s)
|
||||
{
|
||||
if (t == CSYNC_FTW_TYPE_DIR) {
|
||||
if (Utility::doesSetContainPrefix(_stateLastSyncItemsWithError, fn)) {
|
||||
qDebug() << Q_FUNC_INFO << "Folder has error" << fn;
|
||||
s->set(SyncFileStatus::STATUS_ERROR);
|
||||
return true;
|
||||
}
|
||||
// If sync is running, check _syncedItems, possibly give it STATUS_EVAL (=syncing down)
|
||||
if (!_engine.isNull()) {
|
||||
if (_engine->estimateState(fn, t, s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(!fn.endsWith(QLatin1Char('/'))) {
|
||||
fn.append(QLatin1Char('/'));
|
||||
}
|
||||
if (Utility::doesSetContainPrefix(_stateTaintedFolders, fn)) {
|
||||
qDebug() << Q_FUNC_INFO << "Folder is tainted, EVAL!" << fn;
|
||||
s->set(SyncFileStatus::STATUS_EVAL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if ( t== CSYNC_FTW_TYPE_FILE) {
|
||||
// check if errorList has the directory/file
|
||||
if (Utility::doesSetContainPrefix(_stateLastSyncItemsWithError, fn)) {
|
||||
s->set(SyncFileStatus::STATUS_ERROR);
|
||||
return true;
|
||||
}
|
||||
// If sync running: _syncedItems -> SyncingState
|
||||
if (!_engine.isNull()) {
|
||||
if (_engine->estimateState(fn, t, s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Folder::saveToSettings() const
|
||||
{
|
||||
if (!_accountState) {
|
||||
qDebug() << "Can't save folder to settings, account is deleted";
|
||||
return;
|
||||
}
|
||||
|
||||
auto settings = _accountState->settings();
|
||||
settings->beginGroup(QLatin1String("Folders"));
|
||||
FolderDefinition::save(*settings, _definition);
|
||||
@@ -623,6 +724,11 @@ void Folder::saveToSettings() const
|
||||
|
||||
void Folder::removeFromSettings() const
|
||||
{
|
||||
if (!_accountState) {
|
||||
qDebug() << "Can't remove folder from settings, account is deleted";
|
||||
return;
|
||||
}
|
||||
|
||||
auto settings = _accountState->settings();
|
||||
settings->beginGroup(QLatin1String("Folders"));
|
||||
settings->remove(_definition.alias);
|
||||
@@ -630,19 +736,56 @@ void Folder::removeFromSettings() const
|
||||
|
||||
bool Folder::isFileExcludedAbsolute(const QString& fullPath) const
|
||||
{
|
||||
return _engine->excludedFiles().isExcluded(fullPath, path(), _definition.ignoreHiddenFiles);
|
||||
if (!fullPath.startsWith(path())) {
|
||||
// Mark paths we're not responsible for as excluded...
|
||||
return true;
|
||||
}
|
||||
|
||||
QString myFullPath = fullPath;
|
||||
if (myFullPath.endsWith(QLatin1Char('/'))) {
|
||||
myFullPath.chop(1);
|
||||
}
|
||||
|
||||
QString relativePath = myFullPath.mid(path().size());
|
||||
auto excl = ExcludedFiles::instance().isExcluded(myFullPath, relativePath, _definition.ignoreHiddenFiles);
|
||||
return excl != CSYNC_NOT_EXCLUDED;
|
||||
}
|
||||
|
||||
bool Folder::isFileExcludedRelative(const QString& relativePath) const
|
||||
{
|
||||
return _engine->excludedFiles().isExcluded(path() + relativePath, path(), _definition.ignoreHiddenFiles);
|
||||
return isFileExcludedAbsolute(path() + relativePath);
|
||||
}
|
||||
|
||||
void Folder::watcherSlot(QString fn)
|
||||
{
|
||||
// FIXME: On OS X we could not do this "if" since on OS X the file watcher ignores events for ourselves
|
||||
// however to have the same behaviour atm on all platforms, we don't do it
|
||||
if (!_engine.isNull()) {
|
||||
qDebug() << Q_FUNC_INFO << "Sync running, IGNORE event for " << fn;
|
||||
return;
|
||||
}
|
||||
QFileInfo fi(fn);
|
||||
if (fi.isFile()) {
|
||||
fn = fi.path(); // depending on OS, file watcher might be for dir or file
|
||||
}
|
||||
// Make it a relative path depending on the folder
|
||||
QString relativePath = fn.remove(0, path().length());
|
||||
if( !relativePath.endsWith(QLatin1Char('/'))) {
|
||||
relativePath.append(QLatin1Char('/'));
|
||||
}
|
||||
qDebug() << Q_FUNC_INFO << fi.canonicalFilePath() << fn << relativePath;
|
||||
_stateTaintedFolders.insert(relativePath);
|
||||
|
||||
// Notify the SocketAPI?
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Folder::slotTerminateSync()
|
||||
{
|
||||
qDebug() << "folder " << alias() << " Terminating!";
|
||||
|
||||
if( _engine->isSyncRunning() ) {
|
||||
if( _engine ) {
|
||||
_engine->abort();
|
||||
|
||||
// Do not display an error message, user knows his own actions.
|
||||
@@ -688,19 +831,25 @@ void Folder::wipe()
|
||||
|
||||
bool Folder::setIgnoredFiles()
|
||||
{
|
||||
ConfigFile cfg;
|
||||
QString systemList = cfg.excludeFile(ConfigFile::SystemScope);
|
||||
if( QFile::exists(systemList) ) {
|
||||
qDebug() << "==== adding system ignore list to csync:" << systemList;
|
||||
_engine->excludedFiles().addExcludeFilePath(systemList);
|
||||
bool ok = false;
|
||||
|
||||
ConfigFile cfgFile;
|
||||
csync_clear_exclude_list( _csync_ctx );
|
||||
QString excludeList = cfgFile.excludeFile( ConfigFile::SystemScope );
|
||||
if( !excludeList.isEmpty() ) {
|
||||
qDebug() << "==== added system ignore list to csync:" << excludeList.toUtf8();
|
||||
if (csync_add_exclude_list( _csync_ctx, excludeList.toUtf8() ) == 0) {
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
QString userList = cfg.excludeFile(ConfigFile::UserScope);
|
||||
if( QFile::exists(userList) ) {
|
||||
qDebug() << "==== adding user defined ignore list to csync:" << userList;
|
||||
_engine->excludedFiles().addExcludeFilePath(userList);
|
||||
excludeList = cfgFile.excludeFile( ConfigFile::UserScope );
|
||||
if( !excludeList.isEmpty() ) {
|
||||
qDebug() << "==== added user defined ignore list to csync:" << excludeList.toUtf8();
|
||||
csync_add_exclude_list( _csync_ctx, excludeList.toUtf8() );
|
||||
// reading the user exclude file is optional
|
||||
}
|
||||
|
||||
return _engine->excludedFiles().reloadExcludes();
|
||||
return ok;
|
||||
}
|
||||
|
||||
void Folder::setProxyDirty(bool value)
|
||||
@@ -715,11 +864,25 @@ bool Folder::proxyDirty()
|
||||
|
||||
void Folder::startSync(const QStringList &pathList)
|
||||
{
|
||||
if (!_accountState) {
|
||||
qDebug() << "Can't startSync, account is deleted";
|
||||
return;
|
||||
}
|
||||
|
||||
Q_UNUSED(pathList)
|
||||
if (proxyDirty()) {
|
||||
if (!_csync_ctx) {
|
||||
// no _csync_ctx yet, initialize it.
|
||||
init();
|
||||
|
||||
if (!_csync_ctx) {
|
||||
qDebug() << Q_FUNC_INFO << "init failed.";
|
||||
// the error should already be set
|
||||
QMetaObject::invokeMethod(this, "slotSyncFinished", Qt::QueuedConnection, Q_ARG(bool, false));
|
||||
return;
|
||||
}
|
||||
} else if (proxyDirty()) {
|
||||
setProxyDirty(false);
|
||||
}
|
||||
csync_set_log_callback( csyncLogCatcher );
|
||||
csync_set_log_level( Logger::instance()->isNoop() ? 0 : 11 );
|
||||
|
||||
if (isBusy()) {
|
||||
@@ -739,13 +902,44 @@ void Folder::startSync(const QStringList &pathList)
|
||||
qDebug() << "*** Start syncing " << remoteUrl().toString() << " - client version"
|
||||
<< qPrintable(Theme::instance()->version());
|
||||
|
||||
if (!setIgnoredFiles())
|
||||
if (! setIgnoredFiles())
|
||||
{
|
||||
slotSyncError(tr("Could not read system exclude file"));
|
||||
QMetaObject::invokeMethod(this, "slotSyncFinished", Qt::QueuedConnection, Q_ARG(bool, false));
|
||||
return;
|
||||
}
|
||||
|
||||
// pass the setting if hidden files are to be ignored, will be read in csync_update
|
||||
_csync_ctx->ignore_hidden_files = _definition.ignoreHiddenFiles;
|
||||
|
||||
_engine.reset(new SyncEngine( _accountState->account(), _csync_ctx, path(), remoteUrl().path(), remotePath(), &_journal));
|
||||
|
||||
qRegisterMetaType<SyncFileItemVector>("SyncFileItemVector");
|
||||
qRegisterMetaType<SyncFileItem::Direction>("SyncFileItem::Direction");
|
||||
|
||||
connect(_engine.data(), SIGNAL(rootEtag(QString)), this, SLOT(etagRetreivedFromSyncEngine(QString)));
|
||||
connect( _engine.data(), SIGNAL(treeWalkResult(const SyncFileItemVector&)),
|
||||
this, SLOT(slotThreadTreeWalkResult(const SyncFileItemVector&)), Qt::QueuedConnection);
|
||||
connect( _engine.data(), SIGNAL(aboutToPropagate(SyncFileItemVector&)),
|
||||
this, SLOT(slotAboutToPropagate(SyncFileItemVector&)));
|
||||
|
||||
connect(_engine.data(), SIGNAL(started()), SLOT(slotSyncStarted()), Qt::QueuedConnection);
|
||||
connect(_engine.data(), SIGNAL(finished(bool)), SLOT(slotSyncFinished(bool)), Qt::QueuedConnection);
|
||||
connect(_engine.data(), SIGNAL(csyncError(QString)), SLOT(slotSyncError(QString)), Qt::QueuedConnection);
|
||||
connect(_engine.data(), SIGNAL(csyncUnavailable()), SLOT(slotCsyncUnavailable()), Qt::QueuedConnection);
|
||||
|
||||
//direct connection so the message box is blocking the sync.
|
||||
connect(_engine.data(), SIGNAL(aboutToRemoveAllFiles(SyncFileItem::Direction,bool*)),
|
||||
SLOT(slotAboutToRemoveAllFiles(SyncFileItem::Direction,bool*)));
|
||||
connect(_engine.data(), SIGNAL(aboutToRestoreBackup(bool*)),
|
||||
SLOT(slotAboutToRestoreBackup(bool*)));
|
||||
connect(_engine.data(), SIGNAL(folderDiscovered(bool,QString)), this, SLOT(slotFolderDiscovered(bool,QString)));
|
||||
connect(_engine.data(), SIGNAL(transmissionProgress(ProgressInfo)), this, SLOT(slotTransmissionProgress(ProgressInfo)));
|
||||
connect(_engine.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SLOT(slotItemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
connect(_engine.data(), SIGNAL(syncItemDiscovered(const SyncFileItem &)), this, SLOT(slotSyncItemDiscovered(const SyncFileItem &)));
|
||||
connect(_engine.data(), SIGNAL(newBigFolder(QString)), this, SLOT(slotNewBigFolderDiscovered(QString)));
|
||||
|
||||
setDirtyNetworkLimits();
|
||||
|
||||
ConfigFile cfgFile;
|
||||
@@ -753,8 +947,6 @@ void Folder::startSync(const QStringList &pathList)
|
||||
quint64 limit = newFolderLimit.first ? newFolderLimit.second * 1000 * 1000 : -1; // convert from MB to B
|
||||
_engine->setNewBigFolderSizeLimit(limit);
|
||||
|
||||
_engine->setIgnoreHiddenFiles(_definition.ignoreHiddenFiles);
|
||||
|
||||
QMetaObject::invokeMethod(_engine.data(), "startSync", Qt::QueuedConnection);
|
||||
|
||||
// disable events until syncing is done
|
||||
@@ -764,24 +956,27 @@ void Folder::startSync(const QStringList &pathList)
|
||||
|
||||
void Folder::setDirtyNetworkLimits()
|
||||
{
|
||||
ConfigFile cfg;
|
||||
int downloadLimit = -75; // 75%
|
||||
int useDownLimit = cfg.useDownloadLimit();
|
||||
if (useDownLimit >= 1) {
|
||||
downloadLimit = cfg.downloadLimit() * 1000;
|
||||
} else if (useDownLimit == 0) {
|
||||
downloadLimit = 0;
|
||||
}
|
||||
if (_engine) {
|
||||
|
||||
int uploadLimit = -75; // 75%
|
||||
int useUpLimit = cfg.useUploadLimit();
|
||||
if ( useUpLimit >= 1) {
|
||||
uploadLimit = cfg.uploadLimit() * 1000;
|
||||
} else if (useUpLimit == 0) {
|
||||
uploadLimit = 0;
|
||||
}
|
||||
ConfigFile cfg;
|
||||
int downloadLimit = -75; // 75%
|
||||
int useDownLimit = cfg.useDownloadLimit();
|
||||
if (useDownLimit >= 1) {
|
||||
downloadLimit = cfg.downloadLimit() * 1000;
|
||||
} else if (useDownLimit == 0) {
|
||||
downloadLimit = 0;
|
||||
}
|
||||
|
||||
_engine->setNetworkLimits(uploadLimit, downloadLimit);
|
||||
int uploadLimit = -75; // 75%
|
||||
int useUpLimit = cfg.useUploadLimit();
|
||||
if ( useUpLimit >= 1) {
|
||||
uploadLimit = cfg.uploadLimit() * 1000;
|
||||
} else if (useUpLimit == 0) {
|
||||
uploadLimit = 0;
|
||||
}
|
||||
|
||||
_engine->setNetworkLimits(uploadLimit, downloadLimit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -820,11 +1015,20 @@ void Folder::slotSyncFinished(bool success)
|
||||
}
|
||||
bubbleUpSyncResult();
|
||||
|
||||
bool anotherSyncNeeded = _engine->isAnotherSyncNeeded();
|
||||
bool anotherSyncNeeded = false;
|
||||
if (_engine) {
|
||||
anotherSyncNeeded = _engine->isAnotherSyncNeeded();
|
||||
_engine.reset(0);
|
||||
}
|
||||
// _watcher->setEventsEnabledDelayed(2000);
|
||||
|
||||
|
||||
|
||||
// This is for sync state calculation
|
||||
_stateLastSyncItemsWithError = _stateLastSyncItemsWithErrorNew;
|
||||
_stateLastSyncItemsWithErrorNew.clear();
|
||||
_stateTaintedFolders.clear(); // heuristic: assume the sync had been done, new file watches needed to taint dirs
|
||||
|
||||
if (_csyncError) {
|
||||
_syncResult.setStatus(SyncResult::Error);
|
||||
qDebug() << " ** error Strings: " << _errors;
|
||||
@@ -920,6 +1124,10 @@ void Folder::slotTransmissionProgress(const ProgressInfo &pi)
|
||||
// a item is completed: count the errors and forward to the ProgressDispatcher
|
||||
void Folder::slotItemCompleted(const SyncFileItem &item, const PropagatorJob& job)
|
||||
{
|
||||
if (showErrorInSocketApi(item)) {
|
||||
_stateLastSyncItemsWithErrorNew.insert(item._file);
|
||||
}
|
||||
|
||||
if (Progress::isWarningKind(item._status)) {
|
||||
// Count all error conditions.
|
||||
_syncResult.setWarnCount(_syncResult.warnCount()+1);
|
||||
@@ -927,6 +1135,11 @@ void Folder::slotItemCompleted(const SyncFileItem &item, const PropagatorJob& jo
|
||||
emit ProgressDispatcher::instance()->itemCompleted(alias(), item, job);
|
||||
}
|
||||
|
||||
void Folder::slotSyncItemDiscovered(const SyncFileItem & item)
|
||||
{
|
||||
emit ProgressDispatcher::instance()->syncItemDiscovered(alias(), item);
|
||||
}
|
||||
|
||||
void Folder::slotNewBigFolderDiscovered(const QString &newF)
|
||||
{
|
||||
auto newFolder = newF;
|
||||
@@ -936,29 +1149,26 @@ void Folder::slotNewBigFolderDiscovered(const QString &newF)
|
||||
auto journal = journalDb();
|
||||
|
||||
// Add the entry to the blacklist if it is neither in the blacklist or whitelist already
|
||||
bool ok1, ok2;
|
||||
auto blacklist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok1);
|
||||
auto whitelist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, &ok2);
|
||||
if (ok1 && ok2 && !blacklist.contains(newFolder) && !whitelist.contains(newFolder)) {
|
||||
auto blacklist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
|
||||
auto whitelist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList);
|
||||
if (!blacklist.contains(newFolder) && !whitelist.contains(newFolder)) {
|
||||
blacklist.append(newFolder);
|
||||
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blacklist);
|
||||
}
|
||||
|
||||
// And add the entry to the undecided list and signal the UI
|
||||
auto undecidedList = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok1);
|
||||
if( ok1 ) {
|
||||
if (!undecidedList.contains(newFolder)) {
|
||||
undecidedList.append(newFolder);
|
||||
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList);
|
||||
emit newBigFolderDiscovered(newFolder);
|
||||
}
|
||||
QString message = tr("A new folder larger than %1 MB has been added: %2.\n"
|
||||
"Please go in the settings to select it if you wish to download it.")
|
||||
auto undecidedList = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
|
||||
if (!undecidedList.contains(newFolder)) {
|
||||
undecidedList.append(newFolder);
|
||||
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList);
|
||||
emit newBigFolderDiscovered(newFolder);
|
||||
}
|
||||
QString message = tr("A new folder larger than %1 MB has been added: %2.\n"
|
||||
"Please go in the settings to select it if you wish to download it.")
|
||||
.arg(ConfigFile().newBigFolderSizeLimit().second).arg(newF);
|
||||
|
||||
auto logger = Logger::instance();
|
||||
logger->postOptionalGuiLog(Theme::instance()->appNameGUI(), message);
|
||||
}
|
||||
auto logger = Logger::instance();
|
||||
logger->postOptionalGuiLog(Theme::instance()->appNameGUI(), message);
|
||||
}
|
||||
|
||||
|
||||
@@ -975,7 +1185,7 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *cancel)
|
||||
"the files were manually removed.\n"
|
||||
"Are you sure you want to perform this operation?");
|
||||
QMessageBox msgBox(QMessageBox::Warning, tr("Remove All Files?"),
|
||||
msg.arg(aliasGui()));
|
||||
msg.arg(alias()));
|
||||
msgBox.addButton(tr("Remove all files"), QMessageBox::DestructiveRole);
|
||||
QPushButton* keepBtn = msgBox.addButton(tr("Keep files"), QMessageBox::AcceptRole);
|
||||
if (msgBox.exec() == -1) {
|
||||
@@ -1001,7 +1211,7 @@ void Folder::slotAboutToRestoreBackup(bool *restore)
|
||||
"file in an earlier state. "
|
||||
"Do you want to keep your local most recent files as conflict files?");
|
||||
QMessageBox msgBox(QMessageBox::Warning, tr("Backup detected"),
|
||||
msg.arg(aliasGui()));
|
||||
msg.arg(alias()));
|
||||
msgBox.addButton(tr("Normal Synchronisation"), QMessageBox::DestructiveRole);
|
||||
QPushButton* keepBtn = msgBox.addButton(tr("Keep Local Files as Conflict"), QMessageBox::AcceptRole);
|
||||
|
||||
|
||||
+34
-17
@@ -21,13 +21,21 @@
|
||||
#include "progressdispatcher.h"
|
||||
#include "syncjournaldb.h"
|
||||
#include "clientproxy.h"
|
||||
#include "syncfilestatus.h"
|
||||
#include "networkjobs.h"
|
||||
|
||||
#include <csync.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <qelapsedtimer.h>
|
||||
|
||||
class QThread;
|
||||
class QSettings;
|
||||
|
||||
@@ -79,7 +87,7 @@ class Folder : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Folder(const FolderDefinition& definition, AccountState* accountState, QObject* parent = 0L);
|
||||
Folder(const FolderDefinition& definition, QObject* parent = 0L);
|
||||
|
||||
~Folder();
|
||||
|
||||
@@ -89,7 +97,8 @@ public:
|
||||
/**
|
||||
* The account the folder is configured on.
|
||||
*/
|
||||
AccountState* accountState() const { return _accountState.data(); }
|
||||
void setAccountState( AccountState *account );
|
||||
AccountState* accountState() const;
|
||||
|
||||
/**
|
||||
* alias or nickname
|
||||
@@ -124,6 +133,8 @@ public:
|
||||
|
||||
/**
|
||||
* switch sync on or off
|
||||
* If the sync is switched off, the startSync method is not going to
|
||||
* be called.
|
||||
*/
|
||||
void setSyncPaused( bool );
|
||||
|
||||
@@ -132,7 +143,7 @@ public:
|
||||
/**
|
||||
* Returns true when the folder may sync.
|
||||
*
|
||||
* !syncPaused() && accountState->canSync().
|
||||
* !syncPaused() && accountState->isConnected().
|
||||
*/
|
||||
bool canSync() const;
|
||||
|
||||
@@ -173,7 +184,8 @@ public:
|
||||
|
||||
// Used by the Socket API
|
||||
SyncJournalDb *journalDb() { return &_journal; }
|
||||
SyncEngine &syncEngine() { return *_engine; }
|
||||
|
||||
bool estimateState(QString fn, csync_ftw_type_e t, SyncFileStatus* s);
|
||||
|
||||
RequestEtagJob *etagJob() { return _requestEtagJob; }
|
||||
qint64 msecSinceLastSync() const { return _timeSinceLastSyncDone.elapsed(); }
|
||||
@@ -202,7 +214,6 @@ signals:
|
||||
void scheduleToSync(Folder*);
|
||||
void progressInfo(const ProgressInfo& progress);
|
||||
void newBigFolderDiscovered(const QString &); // A new folder bigger than the threshold was discovered
|
||||
void syncPausedChanged(Folder*, bool paused);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -247,38 +258,33 @@ private slots:
|
||||
void slotFolderDiscovered(bool local, QString folderName);
|
||||
void slotTransmissionProgress(const ProgressInfo& pi);
|
||||
void slotItemCompleted(const SyncFileItem&, const PropagatorJob&);
|
||||
void slotSyncItemDiscovered(const SyncFileItem & item);
|
||||
|
||||
void slotRunEtagJob();
|
||||
void etagRetreived(const QString &);
|
||||
void etagRetreivedFromSyncEngine(const QString &);
|
||||
|
||||
void slotAboutToPropagate(SyncFileItemVector& );
|
||||
void slotThreadTreeWalkResult(const SyncFileItemVector& ); // after sync is done
|
||||
|
||||
void slotEmitFinishedDelayed();
|
||||
|
||||
void watcherSlot(QString);
|
||||
void slotNewBigFolderDiscovered(const QString &);
|
||||
|
||||
private:
|
||||
bool init();
|
||||
|
||||
bool setIgnoredFiles();
|
||||
|
||||
void bubbleUpSyncResult();
|
||||
|
||||
void checkLocalPath();
|
||||
|
||||
enum LogStatus {
|
||||
LogStatusRemove,
|
||||
LogStatusRename,
|
||||
LogStatusMove,
|
||||
LogStatusNew,
|
||||
LogStatusError,
|
||||
LogStatusConflict,
|
||||
LogStatusUpdated
|
||||
};
|
||||
|
||||
void createGuiLog(const QString& filename, LogStatus status, int count,
|
||||
void createGuiLog(const QString& filename, SyncFileStatus status, int count,
|
||||
const QString& renameTarget = QString::null );
|
||||
|
||||
AccountStatePtr _accountState;
|
||||
QPointer<AccountState> _accountState;
|
||||
FolderDefinition _definition;
|
||||
|
||||
SyncResult _syncResult;
|
||||
@@ -303,9 +309,20 @@ private:
|
||||
/// Reset when no follow-up is requested.
|
||||
int _consecutiveFollowUpSyncs;
|
||||
|
||||
// SocketAPI: Cache files and folders that had errors so that they can
|
||||
// get a red ERROR icon.
|
||||
QSet<QString> _stateLastSyncItemsWithErrorNew; // gets moved to _stateLastSyncItemsWithError at end of sync
|
||||
QSet<QString> _stateLastSyncItemsWithError;
|
||||
|
||||
// SocketAPI: A folder is tained if we got a file watcher notification
|
||||
// for it. It's displayed as EVAL.
|
||||
QSet<QString> _stateTaintedFolders;
|
||||
|
||||
SyncJournalDb _journal;
|
||||
|
||||
ClientProxy _clientProxy;
|
||||
|
||||
CSYNC *_csync_ctx;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+46
-43
@@ -32,6 +32,7 @@
|
||||
#endif
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QtCore>
|
||||
#include <QMutableSetIterator>
|
||||
#include <QSet>
|
||||
@@ -49,7 +50,7 @@ FolderMan::FolderMan(QObject *parent) :
|
||||
Q_ASSERT(!_instance);
|
||||
_instance = this;
|
||||
|
||||
_socketApi.reset(new SocketApi);
|
||||
_socketApi = new SocketApi(this);
|
||||
|
||||
ConfigFile cfg;
|
||||
int polltime = cfg.remotePollInterval();
|
||||
@@ -88,7 +89,9 @@ void FolderMan::unloadFolder( Folder *f )
|
||||
return;
|
||||
}
|
||||
|
||||
_socketApi->slotUnregisterPath(f->alias());
|
||||
if( _socketApi ) {
|
||||
_socketApi->slotUnregisterPath(f->alias());
|
||||
}
|
||||
|
||||
if( _folderWatchers.contains(f->alias())) {
|
||||
_folderWatchers.remove(f->alias());
|
||||
@@ -103,10 +106,6 @@ void FolderMan::unloadFolder( Folder *f )
|
||||
this, SLOT(slotFolderSyncFinished(SyncResult)));
|
||||
disconnect(f, SIGNAL(syncStateChange()),
|
||||
this, SLOT(slotForwardFolderSyncStateChange()));
|
||||
disconnect(f, SIGNAL(syncPausedChanged(Folder*,bool)),
|
||||
this, SLOT(slotFolderSyncPaused(Folder*,bool)));
|
||||
disconnect(&f->syncEngine().syncFileStatusTracker(), SIGNAL(fileStatusChanged(const QString &, SyncFileStatus)),
|
||||
_socketApi.data(), SLOT(slotFileStatusChanged(const QString &, SyncFileStatus)));
|
||||
}
|
||||
|
||||
int FolderMan::unloadAndDeleteAllFolders()
|
||||
@@ -146,10 +145,15 @@ void FolderMan::registerFolderMonitor( Folder *folder )
|
||||
// is lost this way, but we do not need it for the current implementation.
|
||||
connect(fw, SIGNAL(pathChanged(QString)), folder, SLOT(slotWatchedPathChanged(QString)));
|
||||
_folderWatchers.insert(folder->alias(), fw);
|
||||
|
||||
// This is at the moment only for the behaviour of the SocketApi.
|
||||
connect(fw, SIGNAL(pathChanged(QString)), folder, SLOT(watcherSlot(QString)));
|
||||
}
|
||||
|
||||
// register the folder with the socket API
|
||||
_socketApi->slotRegisterPath(folder->alias());
|
||||
if( _socketApi ) {
|
||||
_socketApi->slotRegisterPath(folder->alias());
|
||||
}
|
||||
}
|
||||
|
||||
void FolderMan::addMonitorPath( const QString& alias, const QString& path )
|
||||
@@ -200,8 +204,9 @@ int FolderMan::setupFolders()
|
||||
foreach (const auto& folderAlias, settings->childGroups()) {
|
||||
FolderDefinition folderDefinition;
|
||||
if (FolderDefinition::load(*settings, folderAlias, &folderDefinition)) {
|
||||
Folder* f = addFolderInternal(folderDefinition, account.data());
|
||||
Folder* f = addFolderInternal(folderDefinition);
|
||||
if (f) {
|
||||
f->setAccountState( account.data() );
|
||||
slotScheduleSync(f);
|
||||
emit folderSyncStateChange(f);
|
||||
}
|
||||
@@ -300,7 +305,7 @@ QString FolderMan::escapeAlias( const QString& alias )
|
||||
|
||||
SocketApi *FolderMan::socketApi()
|
||||
{
|
||||
return this->_socketApi.data();
|
||||
return this->_socketApi;
|
||||
}
|
||||
|
||||
QString FolderMan::unescapeAlias( const QString& alias )
|
||||
@@ -388,8 +393,10 @@ Folder* FolderMan::setupFolderFromOldConfigFile(const QString &file, AccountStat
|
||||
folderDefinition.paused = paused;
|
||||
folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles();
|
||||
|
||||
folder = addFolderInternal(folderDefinition, accountState);
|
||||
folder = addFolderInternal(folderDefinition);
|
||||
if (folder) {
|
||||
folder->setAccountState(accountState);
|
||||
|
||||
QStringList blackList = settings.value( QLatin1String("blackList")).toStringList();
|
||||
if (!blackList.empty()) {
|
||||
//migrate settings
|
||||
@@ -404,19 +411,21 @@ Folder* FolderMan::setupFolderFromOldConfigFile(const QString &file, AccountStat
|
||||
return folder;
|
||||
}
|
||||
|
||||
void FolderMan::slotFolderSyncPaused( Folder *f, bool paused )
|
||||
void FolderMan::slotSetFolderPaused( Folder *f, bool paused )
|
||||
{
|
||||
if( !f ) {
|
||||
qWarning() << "!! slotFolderSyncPaused called with empty folder";
|
||||
qWarning() << "!! slotSetFolderPaused called with empty folder";
|
||||
return;
|
||||
}
|
||||
|
||||
f->setSyncPaused(paused);
|
||||
if (!paused) {
|
||||
_disabledFolders.remove(f);
|
||||
slotScheduleSync(f);
|
||||
} else {
|
||||
_disabledFolders.insert(f);
|
||||
}
|
||||
emit folderSyncStateChange(f);
|
||||
}
|
||||
|
||||
// this really terminates the current sync process
|
||||
@@ -469,12 +478,21 @@ void FolderMan::slotScheduleSync( Folder *f )
|
||||
}
|
||||
auto alias = f->alias();
|
||||
|
||||
if( _socketApi ) {
|
||||
// We want the SocketAPI to already now update so that it can show the EVAL icon
|
||||
// for files/folders. Only do this when not syncing, else we might get a lot
|
||||
// of those notifications.
|
||||
_socketApi->slotUpdateFolderView(f);
|
||||
}
|
||||
|
||||
qDebug() << "Schedule folder " << alias << " to sync!";
|
||||
|
||||
if( ! _scheduleQueue.contains(f) ) {
|
||||
if( !f->canSync() ) {
|
||||
qDebug() << "Folder is not ready to sync, not scheduled!";
|
||||
_socketApi->slotUpdateFolderView(f);
|
||||
if( _socketApi ) {
|
||||
_socketApi->slotUpdateFolderView(f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
f->prepareToSync();
|
||||
@@ -536,7 +554,7 @@ void FolderMan::slotAccountStateChanged()
|
||||
}
|
||||
QString accountName = accountState->account()->displayName();
|
||||
|
||||
if (accountState->canSync()) {
|
||||
if (accountState->isConnected()) {
|
||||
qDebug() << "Account" << accountName << "connected, scheduling its folders";
|
||||
|
||||
foreach (Folder *f, _folderMap.values()) {
|
||||
@@ -547,7 +565,7 @@ void FolderMan::slotAccountStateChanged()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Account" << accountName << "disconnected or paused, "
|
||||
qDebug() << "Account" << accountName << "disconnected, "
|
||||
"terminating or descheduling sync folders";
|
||||
|
||||
if (_currentSyncFolder
|
||||
@@ -726,21 +744,6 @@ void FolderMan::slotForwardFolderSyncStateChange()
|
||||
}
|
||||
}
|
||||
|
||||
void FolderMan::slotServerVersionChanged(Account *account)
|
||||
{
|
||||
// Pause folders if the server version is unsupported
|
||||
if (account->serverVersionUnsupported()) {
|
||||
qDebug() << "The server version is unsupported:" << account->serverVersion()
|
||||
<< "pausing all folders on the account";
|
||||
|
||||
foreach (auto& f, _folderMap) {
|
||||
if (f->accountState()->account().data() == account) {
|
||||
f->setSyncPaused(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FolderMan::slotFolderSyncStarted( )
|
||||
{
|
||||
qDebug() << ">===================================== sync started for " << _currentSyncFolder->remoteUrl().toString();
|
||||
@@ -768,8 +771,9 @@ Folder* FolderMan::addFolder(AccountState* accountState, const FolderDefinition&
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto folder = addFolderInternal(folderDefinition, accountState);
|
||||
if(folder) {
|
||||
auto folder = addFolderInternal(folderDefinition);
|
||||
if(folder && accountState) {
|
||||
folder->setAccountState(accountState);
|
||||
folder->saveToSettings();
|
||||
emit folderSyncStateChange(folder);
|
||||
emit folderListChanged(_folderMap);
|
||||
@@ -777,9 +781,9 @@ Folder* FolderMan::addFolder(AccountState* accountState, const FolderDefinition&
|
||||
return folder;
|
||||
}
|
||||
|
||||
Folder* FolderMan::addFolderInternal(const FolderDefinition& folderDefinition, AccountState* accountState)
|
||||
Folder* FolderMan::addFolderInternal(const FolderDefinition& folderDefinition)
|
||||
{
|
||||
auto folder = new Folder(folderDefinition, accountState, this );
|
||||
auto folder = new Folder(folderDefinition, this );
|
||||
|
||||
qDebug() << "Adding folder to Folder Map " << folder;
|
||||
_folderMap[folder->alias()] = folder;
|
||||
@@ -792,9 +796,6 @@ Folder* FolderMan::addFolderInternal(const FolderDefinition& folderDefinition, A
|
||||
connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
|
||||
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
|
||||
connect(folder, SIGNAL(syncStateChange()), SLOT(slotForwardFolderSyncStateChange()));
|
||||
connect(folder, SIGNAL(syncPausedChanged(Folder*,bool)), SLOT(slotFolderSyncPaused(Folder*,bool)));
|
||||
connect(&folder->syncEngine().syncFileStatusTracker(), SIGNAL(fileStatusChanged(const QString &, SyncFileStatus)),
|
||||
_socketApi.data(), SLOT(slotFileStatusChanged(const QString &, SyncFileStatus)));
|
||||
|
||||
registerFolderMonitor(folder);
|
||||
return folder;
|
||||
@@ -918,13 +919,15 @@ bool FolderMan::startFromScratch( const QString& localFolder )
|
||||
}
|
||||
// Disconnect the socket api from the database to avoid that locking of the
|
||||
// db file does not allow to move this dir.
|
||||
Folder *f = folderForPath(localFolder);
|
||||
if(f) {
|
||||
if( localFolder.startsWith(f->path()) ) {
|
||||
_socketApi->slotUnregisterPath(f->alias());
|
||||
if( _socketApi ) {
|
||||
Folder *f = folderForPath(localFolder);
|
||||
if(f) {
|
||||
if( localFolder.startsWith(f->path()) ) {
|
||||
_socketApi->slotUnregisterPath(f->alias());
|
||||
}
|
||||
f->journalDb()->close();
|
||||
f->slotTerminateSync(); // Normally it should not be running, but viel hilft viel
|
||||
}
|
||||
f->journalDb()->close();
|
||||
f->slotTerminateSync(); // Normally it should not be running, but viel hilft viel
|
||||
}
|
||||
|
||||
// Make a backup of the folder/file.
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <QObject>
|
||||
#include <QQueue>
|
||||
#include <QList>
|
||||
#include <QPointer>
|
||||
|
||||
#include "folder.h"
|
||||
#include "folderwatcher.h"
|
||||
@@ -142,7 +143,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
void slotRemoveFolder( Folder* );
|
||||
void slotFolderSyncPaused(Folder *, bool paused);
|
||||
void slotSetFolderPaused(Folder *, bool paused);
|
||||
|
||||
void slotFolderSyncStarted();
|
||||
void slotFolderSyncFinished( const SyncResult& );
|
||||
@@ -195,13 +196,11 @@ private slots:
|
||||
// FolderMan::folderSyncStateChange(Folder*) signal.
|
||||
void slotForwardFolderSyncStateChange();
|
||||
|
||||
void slotServerVersionChanged(Account* account);
|
||||
|
||||
private:
|
||||
/** Adds a new folder, does not add it to the account settings and
|
||||
* does not set an account on the new folder.
|
||||
*/
|
||||
Folder* addFolderInternal(const FolderDefinition& folderDefinition, AccountState* accountState);
|
||||
Folder* addFolderInternal(const FolderDefinition& folderDefinition);
|
||||
|
||||
/* unloads a folder object, does not delete it */
|
||||
void unloadFolder( Folder * );
|
||||
@@ -227,7 +226,7 @@ private:
|
||||
QPointer<RequestEtagJob> _currentEtagJob; // alias of Folder running the current RequestEtagJob
|
||||
|
||||
QMap<QString, FolderWatcher*> _folderWatchers;
|
||||
QScopedPointer<SocketApi> _socketApi;
|
||||
QPointer<SocketApi> _socketApi;
|
||||
|
||||
/** The aliases of folders that shall be synced. */
|
||||
QQueue<Folder*> _scheduleQueue;
|
||||
|
||||
@@ -237,12 +237,17 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
const bool showProgess = !overallString.isEmpty() || !itemString.isEmpty();
|
||||
if(!showProgess) {
|
||||
painter->setFont(subFont);
|
||||
QString elidedRemotePathText = subFm.elidedText(
|
||||
tr("Synchronizing with local folder"),
|
||||
Qt::ElideRight, remotePathRect.width());
|
||||
QString elidedRemotePathText;
|
||||
|
||||
if (remotePath.isEmpty() || remotePath == QLatin1String("/")) {
|
||||
elidedRemotePathText = subFm.elidedText(tr("Syncing selected files in your account with"),
|
||||
Qt::ElideRight, remotePathRect.width());
|
||||
} else {
|
||||
elidedRemotePathText = subFm.elidedText(tr("Remote path: %1").arg(remotePath),
|
||||
Qt::ElideMiddle, remotePathRect.width());
|
||||
}
|
||||
painter->drawText(QStyle::visualRect(option.direction, option.rect, remotePathRect),
|
||||
textAlign, elidedRemotePathText);
|
||||
|
||||
QString elidedPathText = subFm.elidedText(pathText, Qt::ElideMiddle, localPathRect.width());
|
||||
painter->drawText(QStyle::visualRect(option.direction, option.rect, localPathRect),
|
||||
textAlign, elidedPathText);
|
||||
@@ -283,17 +288,21 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
// Sync File Progress Bar: Show it if syncFile is not empty.
|
||||
if (showProgess) {
|
||||
int fileNameTextHeight = subFm.boundingRect(tr("File")).height();
|
||||
int barHeight = 7; // same height as quota bar
|
||||
int barHeight = qMax(fileNameTextHeight, aliasFm.height()+4);
|
||||
int overallWidth = option.rect.right() - aliasMargin - optionsButtonVisualRect.width() - nextToIcon;
|
||||
|
||||
painter->save();
|
||||
|
||||
// Sizes-Text
|
||||
QRect octetRect = progressFm.boundingRect(QRect(), 0, overallString );
|
||||
int progressTextWidth = octetRect.width() + 5;
|
||||
|
||||
// Overall Progress Bar.
|
||||
QRect pBRect;
|
||||
pBRect.setTop( remotePathRect.top() );
|
||||
pBRect.setLeft( nextToIcon );
|
||||
pBRect.setHeight(barHeight);
|
||||
pBRect.setWidth( overallWidth - 2 * margin );
|
||||
pBRect.setWidth( overallWidth - progressTextWidth - 2 * margin );
|
||||
|
||||
QStyleOptionProgressBarV2 pBarOpt;
|
||||
|
||||
@@ -308,16 +317,27 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
|
||||
// Overall Progress Text
|
||||
QRect overallProgressRect;
|
||||
overallProgressRect.setTop( pBRect.bottom() + margin );
|
||||
overallProgressRect.setHeight( fileNameTextHeight );
|
||||
overallProgressRect.setLeft( pBRect.left() );
|
||||
overallProgressRect.setWidth( pBRect.width() );
|
||||
overallProgressRect.setTop( pBRect.top() );
|
||||
overallProgressRect.setHeight( pBRect.height() );
|
||||
overallProgressRect.setLeft( pBRect.right()+margin);
|
||||
overallProgressRect.setWidth( progressTextWidth );
|
||||
painter->setFont(progressFont);
|
||||
|
||||
painter->drawText(QStyle::visualRect(option.direction, option.rect, overallProgressRect),
|
||||
Qt::AlignLeft | Qt::AlignVCenter, overallString);
|
||||
Qt::AlignRight | Qt::AlignVCenter, overallString);
|
||||
// painter->drawRect(overallProgressRect);
|
||||
|
||||
// Individual File Progress
|
||||
QRect fileRect;
|
||||
fileRect.setTop( pBRect.bottom() + margin);
|
||||
fileRect.setLeft(pBRect.left());
|
||||
fileRect.setWidth(overallWidth);
|
||||
fileRect.setHeight(fileNameTextHeight);
|
||||
QString elidedText = progressFm.elidedText(itemString, Qt::ElideLeft, fileRect.width());
|
||||
|
||||
painter->drawText(QStyle::visualRect(option.direction, option.rect, fileRect),
|
||||
Qt::AlignLeft | Qt::AlignVCenter, elidedText);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
@@ -195,9 +195,6 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
|
||||
case FolderStatusDelegate::FolderAccountConnected : return accountConnected;
|
||||
case Qt::ToolTipRole: {
|
||||
QString toolTip;
|
||||
if (!progress.isNull()) {
|
||||
return progress._progressString;
|
||||
}
|
||||
if ( accountConnected )
|
||||
toolTip = Theme::instance()->statusHeaderText(f->syncResult().status());
|
||||
else
|
||||
@@ -562,18 +559,10 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
|
||||
pathToRemove += '/';
|
||||
|
||||
QStringList selectiveSyncBlackList;
|
||||
bool ok1 = true;
|
||||
bool ok2 = true;
|
||||
if (parentInfo->_checked == Qt::PartiallyChecked) {
|
||||
selectiveSyncBlackList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok1);
|
||||
selectiveSyncBlackList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
|
||||
}
|
||||
auto selectiveSyncUndecidedList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok2);
|
||||
|
||||
if( !(ok1 && ok2) ) {
|
||||
qDebug() << Q_FUNC_INFO << "Could not retrieve selective sync info from journal";
|
||||
return;
|
||||
}
|
||||
|
||||
auto selectiveSyncUndecidedList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
|
||||
QVarLengthArray<int, 10> undecidedIndexes;
|
||||
QVector<SubFolderInfo> newSubs;
|
||||
|
||||
@@ -735,12 +724,7 @@ void FolderStatusModel::slotApplySelectiveSync()
|
||||
}
|
||||
auto folder = _folders.at(i)._folder;
|
||||
|
||||
bool ok;
|
||||
auto oldBlackList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
|
||||
if( !ok ) {
|
||||
qDebug() << Q_FUNC_INFO << "Could not read selective sync list from db.";
|
||||
return;
|
||||
}
|
||||
auto oldBlackList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
|
||||
QStringList blackList = createBlackList(&_folders[i], oldBlackList);
|
||||
folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList);
|
||||
|
||||
@@ -750,14 +734,12 @@ void FolderStatusModel::slotApplySelectiveSync()
|
||||
// The folders that were undecided or blacklisted and that are now checked should go on the white list.
|
||||
// The user confirmed them already just now.
|
||||
QStringList toAddToWhiteList = ((oldBlackListSet + folder->journalDb()->getSelectiveSyncList(
|
||||
SyncJournalDb::SelectiveSyncUndecidedList, &ok).toSet()) - blackListSet).toList();
|
||||
SyncJournalDb::SelectiveSyncUndecidedList).toSet()) - blackListSet).toList();
|
||||
|
||||
if (!toAddToWhiteList.isEmpty()) {
|
||||
auto whiteList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, &ok);
|
||||
if (ok) {
|
||||
whiteList += toAddToWhiteList;
|
||||
folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, whiteList);
|
||||
}
|
||||
auto whiteList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList);
|
||||
whiteList += toAddToWhiteList;
|
||||
folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, whiteList);
|
||||
}
|
||||
// clear the undecided list
|
||||
folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList());
|
||||
@@ -821,12 +803,10 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
|
||||
auto *pi = &_folders[folderIndex]._progress;
|
||||
|
||||
QVector<int> roles;
|
||||
roles << FolderStatusDelegate::SyncProgressItemString
|
||||
<< FolderStatusDelegate::WarningCount
|
||||
<< Qt::ToolTipRole;
|
||||
roles << FolderStatusDelegate::SyncProgressItemString << FolderStatusDelegate::WarningCount;
|
||||
|
||||
if (!progress._currentDiscoveredFolder.isEmpty()) {
|
||||
pi->_overallSyncString = tr("Checking for changes in '%1'").arg(progress._currentDiscoveredFolder);
|
||||
pi->_progressString = tr("Checking for changes in '%1'").arg(progress._currentDiscoveredFolder);
|
||||
emit dataChanged(index(folderIndex), index(folderIndex), roles);
|
||||
return;
|
||||
}
|
||||
@@ -931,11 +911,11 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
|
||||
if (totalSize > 0) {
|
||||
QString s1 = Utility::octetsToString( completedSize );
|
||||
QString s2 = Utility::octetsToString( totalSize );
|
||||
//: Example text: "5 minutes left, 12 MB of 345 MB, file 6 of 7"
|
||||
overallSyncString = tr("%5 left, %1 of %2, file %3 of %4")
|
||||
//: Example text: "12 MB of 345 MB, file 6 of 7\nTotal time left 12 minutes"
|
||||
overallSyncString = tr("%1 of %2, file %3 of %4\nTotal time left %5")
|
||||
.arg(s1, s2)
|
||||
.arg(currentFile).arg(totalFileCount)
|
||||
.arg( Utility::durationToDescriptiveString1(progress.totalProgress().estimatedEta) );
|
||||
.arg( Utility::durationToDescriptiveString(progress.totalProgress().estimatedEta) );
|
||||
} else if (totalFileCount > 0) {
|
||||
// Don't attempt to estimate the time left if there is no kb to transfer.
|
||||
overallSyncString = tr("file %1 of %2") .arg(currentFile).arg(totalFileCount);
|
||||
@@ -983,10 +963,10 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
|
||||
message = tr("Waiting for %n other folder(s)...", "", pos);
|
||||
}
|
||||
_folders[folderIndex]._progress = SubFolderInfo::Progress();
|
||||
_folders[folderIndex]._progress._overallSyncString = message;
|
||||
_folders[folderIndex]._progress._progressString = message;
|
||||
} else if (state == SyncResult::SyncPrepare) {
|
||||
_folders[folderIndex]._progress = SubFolderInfo::Progress();
|
||||
_folders[folderIndex]._progress._overallSyncString = tr("Preparing to sync...");
|
||||
_folders[folderIndex]._progress._progressString = tr("Preparing to sync...");
|
||||
} else if (state == SyncResult::Problem || state == SyncResult::Success) {
|
||||
// Reset the progress info after a sync.
|
||||
_folders[folderIndex]._progress = SubFolderInfo::Progress();
|
||||
@@ -1015,7 +995,9 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
|
||||
void FolderStatusModel::slotFolderScheduleQueueChanged()
|
||||
{
|
||||
// Update messages on waiting folders.
|
||||
foreach (Folder* f, FolderMan::instance()->map()) {
|
||||
// It's ok to only update folders currently in the queue, because folders
|
||||
// are only removed from the queue if they are deleted.
|
||||
foreach (Folder* f, FolderMan::instance()->scheduleQueue()) {
|
||||
slotFolderSyncStateChange(f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ bool FolderWatcherPrivate::findFoldersBelow( const QDir& dir, QStringList& fullL
|
||||
} else {
|
||||
QStringList nameFilter;
|
||||
nameFilter << QLatin1String("*");
|
||||
QDir::Filters filter = QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Hidden;
|
||||
QDir::Filters filter = QDir::Dirs | QDir::NoDotAndDotDot|QDir::NoSymLinks;
|
||||
const QStringList pathes = dir.entryList(nameFilter, filter);
|
||||
|
||||
QStringList::const_iterator constIterator;
|
||||
|
||||
+65
-112
@@ -31,27 +31,24 @@ void WatcherThread::watchChanges(size_t fileNotifyBufferSize,
|
||||
*increaseBufferSize = false;
|
||||
QString longPath = FileSystem::longWinPath(_path);
|
||||
|
||||
_directory = CreateFileW(
|
||||
_handle = CreateFileW(
|
||||
(wchar_t*) longPath.utf16(),
|
||||
FILE_LIST_DIRECTORY,
|
||||
FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
|
||||
FILE_FLAG_BACKUP_SEMANTICS,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (_directory == INVALID_HANDLE_VALUE)
|
||||
if (_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD errorCode = GetLastError();
|
||||
qDebug() << Q_FUNC_INFO << "Failed to create handle for" << _path << ", error:" << errorCode;
|
||||
_directory = 0;
|
||||
_handle = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
OVERLAPPED overlapped;
|
||||
overlapped.hEvent = _resultEvent;
|
||||
|
||||
// QVarLengthArray ensures the stack-buffer is aligned like double and qint64.
|
||||
QVarLengthArray<char, 4096*10> fileNotifyBuffer;
|
||||
fileNotifyBuffer.resize(fileNotifyBufferSize);
|
||||
@@ -59,129 +56,88 @@ void WatcherThread::watchChanges(size_t fileNotifyBufferSize,
|
||||
const size_t fileNameBufferSize = 4096;
|
||||
TCHAR fileNameBuffer[fileNameBufferSize];
|
||||
|
||||
|
||||
while (!_done) {
|
||||
ResetEvent(_resultEvent);
|
||||
|
||||
forever {
|
||||
FILE_NOTIFY_INFORMATION *pFileNotifyBuffer =
|
||||
(FILE_NOTIFY_INFORMATION*)fileNotifyBuffer.data();
|
||||
DWORD dwBytesReturned = 0;
|
||||
SecureZeroMemory(pFileNotifyBuffer, fileNotifyBufferSize);
|
||||
if(! ReadDirectoryChangesW( _directory, (LPVOID)pFileNotifyBuffer,
|
||||
fileNotifyBufferSize, true,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME |
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME |
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE,
|
||||
&dwBytesReturned,
|
||||
&overlapped,
|
||||
NULL))
|
||||
if(ReadDirectoryChangesW( _handle, (LPVOID)pFileNotifyBuffer,
|
||||
fileNotifyBufferSize, true,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME |
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME |
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE,
|
||||
&dwBytesReturned, NULL, NULL))
|
||||
{
|
||||
DWORD errorCode = GetLastError();
|
||||
if (errorCode == ERROR_NOTIFY_ENUM_DIR) {
|
||||
qDebug() << Q_FUNC_INFO << "The buffer for changes overflowed! Triggering a generic change and resizing";
|
||||
emit changed(_path);
|
||||
*increaseBufferSize = true;
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "ReadDirectoryChangesW error" << errorCode;
|
||||
}
|
||||
break;
|
||||
}
|
||||
FILE_NOTIFY_INFORMATION *curEntry = pFileNotifyBuffer;
|
||||
forever {
|
||||
size_t len = curEntry->FileNameLength / 2;
|
||||
QString file = _path + "\\" + QString::fromWCharArray(curEntry->FileName, len);
|
||||
|
||||
HANDLE handles[] = {_resultEvent, _stopEvent};
|
||||
DWORD result = WaitForMultipleObjects(
|
||||
2, handles,
|
||||
false, // awake once one of them arrives
|
||||
INFINITE);
|
||||
if (result == 1) {
|
||||
qDebug() << "Received stop event, aborting folder watcher thread";
|
||||
break;
|
||||
}
|
||||
if (result != 0) {
|
||||
qDebug() << "WaitForMultipleObjects failed" << result << GetLastError();
|
||||
break;
|
||||
}
|
||||
|
||||
bool ok = GetOverlappedResult(_directory, &overlapped, &dwBytesReturned, false);
|
||||
if (! ok) {
|
||||
DWORD errorCode = GetLastError();
|
||||
if (errorCode == ERROR_NOTIFY_ENUM_DIR) {
|
||||
qDebug() << Q_FUNC_INFO << "The buffer for changes overflowed! Triggering a generic change and resizing";
|
||||
emit changed(_path);
|
||||
*increaseBufferSize = true;
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "GetOverlappedResult error" << errorCode;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
FILE_NOTIFY_INFORMATION *curEntry = pFileNotifyBuffer;
|
||||
forever {
|
||||
size_t len = curEntry->FileNameLength / 2;
|
||||
QString file = _path + "\\" + QString::fromWCharArray(curEntry->FileName, len);
|
||||
|
||||
// Unless the file was removed or renamed, get its full long name
|
||||
// TODO: We could still try expanding the path in the tricky cases...
|
||||
QString longfile = file;
|
||||
if (curEntry->Action != FILE_ACTION_REMOVED
|
||||
&& curEntry->Action != FILE_ACTION_RENAMED_OLD_NAME) {
|
||||
size_t longNameSize = GetLongPathNameW(reinterpret_cast<LPCWSTR>(file.utf16()), fileNameBuffer, fileNameBufferSize);
|
||||
if (longNameSize > 0) {
|
||||
longfile = QString::fromUtf16(reinterpret_cast<const ushort *>(fileNameBuffer), longNameSize);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "Error converting file name to full length, keeping original name.";
|
||||
// Unless the file was removed or renamed, get its full long name
|
||||
// TODO: We could still try expanding the path in the tricky cases...
|
||||
QString longfile = file;
|
||||
if (curEntry->Action != FILE_ACTION_REMOVED
|
||||
&& curEntry->Action != FILE_ACTION_RENAMED_OLD_NAME) {
|
||||
size_t longNameSize = GetLongPathNameW(reinterpret_cast<LPCWSTR>(file.utf16()), fileNameBuffer, fileNameBufferSize);
|
||||
if (longNameSize > 0) {
|
||||
longfile = QString::fromUtf16(reinterpret_cast<const ushort *>(fileNameBuffer), longNameSize);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "Error converting file name to full length, keeping original name.";
|
||||
}
|
||||
}
|
||||
longfile = QDir::cleanPath(longfile);
|
||||
|
||||
// Skip modifications of folders: One of these is triggered for changes
|
||||
// and new files in a folder, probably because of the folder's mtime
|
||||
// changing. We don't need them.
|
||||
bool skip = curEntry->Action == FILE_ACTION_MODIFIED
|
||||
&& QFileInfo(longfile).isDir();
|
||||
|
||||
if (!skip) {
|
||||
//qDebug() << Q_FUNC_INFO << "Found change in" << longfile
|
||||
// << "action:" << curEntry->Action;
|
||||
emit changed(longfile);
|
||||
}
|
||||
|
||||
if (curEntry->NextEntryOffset == 0) {
|
||||
break;
|
||||
}
|
||||
curEntry = (FILE_NOTIFY_INFORMATION*)(
|
||||
(char*)curEntry + curEntry->NextEntryOffset);
|
||||
}
|
||||
longfile = QDir::cleanPath(longfile);
|
||||
|
||||
// Skip modifications of folders: One of these is triggered for changes
|
||||
// and new files in a folder, probably because of the folder's mtime
|
||||
// changing. We don't need them.
|
||||
bool skip = curEntry->Action == FILE_ACTION_MODIFIED
|
||||
&& QFileInfo(longfile).isDir();
|
||||
|
||||
if (!skip) {
|
||||
//qDebug() << Q_FUNC_INFO << "Found change in" << longfile
|
||||
// << "action:" << curEntry->Action;
|
||||
emit changed(longfile);
|
||||
}
|
||||
|
||||
if (curEntry->NextEntryOffset == 0) {
|
||||
} else {
|
||||
DWORD errorCode = GetLastError();
|
||||
switch(errorCode) {
|
||||
case ERROR_NOTIFY_ENUM_DIR:
|
||||
qDebug() << Q_FUNC_INFO << "The buffer for changes overflowed! Triggering a generic change and resizing";
|
||||
emit changed(_path);
|
||||
*increaseBufferSize = true;
|
||||
break;
|
||||
default:
|
||||
qDebug() << Q_FUNC_INFO << "General error" << errorCode << "while watching. Exiting.";
|
||||
break;
|
||||
}
|
||||
curEntry = (FILE_NOTIFY_INFORMATION*)(
|
||||
(char*)curEntry + curEntry->NextEntryOffset);
|
||||
CloseHandle(_handle);
|
||||
_handle = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CancelIo(_directory);
|
||||
closeHandle();
|
||||
}
|
||||
|
||||
void WatcherThread::closeHandle()
|
||||
{
|
||||
if (_directory) {
|
||||
CloseHandle(_directory);
|
||||
_directory = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void WatcherThread::run()
|
||||
{
|
||||
_resultEvent = CreateEvent(NULL, true, false, NULL);
|
||||
_stopEvent = CreateEvent(NULL, true, false, NULL);
|
||||
|
||||
// If this buffer fills up before we've extracted its data we will lose
|
||||
// change information. Therefore start big.
|
||||
size_t bufferSize = 4096*10;
|
||||
size_t maxBuffer = 64*1024;
|
||||
|
||||
while (!_done) {
|
||||
forever {
|
||||
bool increaseBufferSize = false;
|
||||
watchChanges(bufferSize, &increaseBufferSize);
|
||||
|
||||
if (increaseBufferSize) {
|
||||
bufferSize = qMin(bufferSize*2, maxBuffer);
|
||||
} else if (!_done) {
|
||||
} else {
|
||||
// Other errors shouldn't actually happen,
|
||||
// so sleep a bit to avoid running into the same error case in a
|
||||
// tight loop.
|
||||
@@ -192,13 +148,10 @@ void WatcherThread::run()
|
||||
|
||||
WatcherThread::~WatcherThread()
|
||||
{
|
||||
closeHandle();
|
||||
}
|
||||
|
||||
void WatcherThread::stop()
|
||||
{
|
||||
_done = 1;
|
||||
SetEvent(_stopEvent);
|
||||
if (_handle) {
|
||||
CloseHandle(_handle);
|
||||
_handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
FolderWatcherPrivate::FolderWatcherPrivate(FolderWatcher *p, const QString& path)
|
||||
@@ -212,7 +165,7 @@ FolderWatcherPrivate::FolderWatcherPrivate(FolderWatcher *p, const QString& path
|
||||
|
||||
FolderWatcherPrivate::~FolderWatcherPrivate()
|
||||
{
|
||||
_thread->stop();
|
||||
_thread->terminate();
|
||||
_thread->wait();
|
||||
delete _thread;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#define MIRALL_FOLDERWATCHER_WIN_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QAtomicInt>
|
||||
#include <windows.h>
|
||||
|
||||
namespace OCC {
|
||||
@@ -30,33 +29,21 @@ class WatcherThread : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
WatcherThread(const QString &path) :
|
||||
QThread(),
|
||||
_path(path),
|
||||
_directory(0),
|
||||
_resultEvent(0),
|
||||
_stopEvent(0),
|
||||
_done(false)
|
||||
{}
|
||||
QThread(), _path(path), _handle(0) {}
|
||||
|
||||
~WatcherThread();
|
||||
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
void run();
|
||||
void watchChanges(size_t fileNotifyBufferSize,
|
||||
bool* increaseBufferSize);
|
||||
void closeHandle();
|
||||
|
||||
signals:
|
||||
void changed(const QString &path);
|
||||
|
||||
private:
|
||||
QString _path;
|
||||
HANDLE _directory;
|
||||
HANDLE _resultEvent;
|
||||
HANDLE _stopEvent;
|
||||
QAtomicInt _done;
|
||||
HANDLE _handle;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,13 +68,17 @@ FolderWizardLocalPath::FolderWizardLocalPath()
|
||||
_ui.localFolderLineEdit->setText( QDir::toNativeSeparators( defaultPath ) );
|
||||
_ui.localFolderLineEdit->setToolTip(tr("Enter the path to the local folder."));
|
||||
|
||||
registerField(QLatin1String("alias*"), _ui.aliasLineEdit);
|
||||
|
||||
QString newAlias = Theme::instance()->appName();
|
||||
int count = 0;
|
||||
while (FolderMan::instance()->folder(newAlias)) {
|
||||
// There is already a folder configured with this name and folder names need to be unique
|
||||
newAlias = Theme::instance()->appName() + QString::number(++count);
|
||||
}
|
||||
_ui.aliasLineEdit->setText( newAlias );
|
||||
|
||||
_ui.aliasLineEdit->setToolTip(tr("The folder alias is a descriptive name for this sync connection."));
|
||||
_ui.warnLabel->setTextFormat(Qt::RichText);
|
||||
_ui.warnLabel->hide();
|
||||
}
|
||||
@@ -105,6 +109,29 @@ bool FolderWizardLocalPath::isComplete() const
|
||||
warnStrings << errorStr;
|
||||
}
|
||||
|
||||
// check if the alias is unique.
|
||||
QString alias = _ui.aliasLineEdit->text();
|
||||
if( alias.isEmpty() ) {
|
||||
warnStrings.append( tr("The alias can not be empty. Please provide a descriptive alias word.") );
|
||||
isOk = false;
|
||||
}
|
||||
|
||||
auto map = FolderMan::instance()->map();
|
||||
Folder::Map::const_iterator i = map.constBegin();
|
||||
bool goon = true;
|
||||
while( goon && i != map.constEnd() ) {
|
||||
Folder *f = i.value();
|
||||
if( f ) {
|
||||
qDebug() << "Checking local alias: " << f->alias();
|
||||
if( f->alias() == alias ) {
|
||||
warnStrings.append( tr("The alias <i>%1</i> is already in use. Please pick another alias.").arg(alias) );
|
||||
isOk = false;
|
||||
goon = false;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
_ui.warnLabel->setWordWrap(true);
|
||||
if( isOk ) {
|
||||
_ui.warnLabel->hide();
|
||||
@@ -143,6 +170,9 @@ void FolderWizardLocalPath::slotChooseLocalFolder()
|
||||
// There is already a folder configured with this name and folder names need to be unique
|
||||
newAlias = pickedDir.dirName() + QString::number(++count);
|
||||
}
|
||||
if( !newAlias.isEmpty() ) {
|
||||
_ui.aliasLineEdit->setText(newAlias);
|
||||
}
|
||||
}
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>423</width>
|
||||
<height>174</height>
|
||||
<height>155</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -47,6 +47,23 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>&Directory alias name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>aliasLineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="aliasLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -109,12 +109,7 @@ void GeneralSettings::loadMiscSettings()
|
||||
|
||||
void GeneralSettings::slotUpdateInfo()
|
||||
{
|
||||
OCUpdater *updater = dynamic_cast<OCUpdater*>(Updater::instance());
|
||||
if (ConfigFile().skipUpdateCheck()) {
|
||||
updater = 0; // don't show update info if updates are disabled
|
||||
}
|
||||
|
||||
if (updater) {
|
||||
if (OCUpdater *updater = dynamic_cast<OCUpdater*>(Updater::instance())) {
|
||||
connect(updater, SIGNAL(downloadStateChanged()), SLOT(slotUpdateInfo()), Qt::UniqueConnection);
|
||||
connect(_ui->restartButton, SIGNAL(clicked()), updater, SLOT(slotStartInstaller()), Qt::UniqueConnection);
|
||||
connect(_ui->restartButton, SIGNAL(clicked()), qApp, SLOT(quit()), Qt::UniqueConnection);
|
||||
|
||||
+3
-3
@@ -47,18 +47,18 @@ int main(int argc, char **argv)
|
||||
{
|
||||
Q_INIT_RESOURCE(client);
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
#ifdef Q_OS_WIN
|
||||
// If the font size ratio is set on Windows, we need to
|
||||
// enable the auto pixelRatio in Qt since we don't
|
||||
// want to use sizes relative to the font size everywhere.
|
||||
// This is automatic on OS X, but opt-in on Windows and Linux
|
||||
// This is automatic on OS X, but opt-in on Windows
|
||||
// https://doc-snapshots.qt.io/qt5-5.6/highdpi.html#qt-support
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
|
||||
qputenv("QT_DEVICE_PIXEL_RATIO", "auto");
|
||||
#else
|
||||
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
|
||||
#endif
|
||||
#endif // !Q_OS_MAC
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
Mac::CocoaInitializer cocoaInit; // RIIA
|
||||
|
||||
@@ -86,11 +86,6 @@ QSize NetworkSettings::sizeHint() const {
|
||||
|
||||
void NetworkSettings::loadProxySettings()
|
||||
{
|
||||
if (Theme::instance()->forceSystemNetworkProxy()) {
|
||||
_ui->systemProxyRadioButton->setChecked(true);
|
||||
_ui->proxyGroupBox->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
// load current proxy settings
|
||||
OCC::ConfigFile cfgFile;
|
||||
int type = cfgFile.proxyType();
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "notificationconfirmjob.h"
|
||||
#include "networkjobs.h"
|
||||
#include "account.h"
|
||||
#include "json.h"
|
||||
|
||||
#include <QBuffer>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
NotificationConfirmJob::NotificationConfirmJob(AccountPtr account)
|
||||
: AbstractNetworkJob(account, ""),
|
||||
_widget(0)
|
||||
{
|
||||
setIgnoreCredentialFailure(true);
|
||||
}
|
||||
|
||||
void NotificationConfirmJob::setLinkAndVerb(const QUrl& link, const QByteArray &verb)
|
||||
{
|
||||
_link = link;
|
||||
_verb = verb;
|
||||
}
|
||||
|
||||
void NotificationConfirmJob::setWidget( NotificationWidget *widget )
|
||||
{
|
||||
_widget = widget;
|
||||
}
|
||||
|
||||
NotificationWidget *NotificationConfirmJob::widget()
|
||||
{
|
||||
return _widget;
|
||||
}
|
||||
|
||||
void NotificationConfirmJob::start()
|
||||
{
|
||||
if( !_link.isValid() ) {
|
||||
qDebug() << "Attempt to trigger invalid URL: " << _link.toString();
|
||||
return;
|
||||
}
|
||||
QNetworkRequest req;
|
||||
req.setRawHeader("Ocs-APIREQUEST", "true");
|
||||
req.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
QIODevice *iodevice = 0;
|
||||
setReply(davRequest(_verb, _link, req, iodevice));
|
||||
setupConnections(reply());
|
||||
|
||||
AbstractNetworkJob::start();
|
||||
}
|
||||
|
||||
bool NotificationConfirmJob::finished()
|
||||
{
|
||||
int replyCode = 0;
|
||||
// FIXME: check for the reply code!
|
||||
const QString replyStr = reply()->readAll();
|
||||
|
||||
if( replyStr.contains( "<?xml version=\"1.0\"?>") ) {
|
||||
QRegExp rex("<statuscode>(\\d+)</statuscode>");
|
||||
if( replyStr.contains(rex) ) {
|
||||
// this is a error message coming back from ocs.
|
||||
replyCode = rex.cap(1).toInt();
|
||||
}
|
||||
}
|
||||
emit jobFinished(replyStr, replyCode);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef NOTIFICATIONCONFIRMJOB_H
|
||||
#define NOTIFICATIONCONFIRMJOB_H
|
||||
|
||||
#include "accountfwd.h"
|
||||
#include "abstractnetworkjob.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QUrl>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class NotificationWidget;
|
||||
|
||||
/**
|
||||
* @brief The NotificationConfirmJob class
|
||||
* @ingroup gui
|
||||
*
|
||||
* Class to call an action-link of a notification coming from the server.
|
||||
* All the communication logic is handled in this class.
|
||||
*
|
||||
*/
|
||||
class NotificationConfirmJob : public AbstractNetworkJob {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit NotificationConfirmJob(AccountPtr account);
|
||||
|
||||
/**
|
||||
* @brief Set the verb and link for the job
|
||||
*
|
||||
* @param verb currently supported GET PUT POST DELETE
|
||||
*/
|
||||
void setLinkAndVerb(const QUrl& link, const QByteArray &verb);
|
||||
|
||||
/**
|
||||
* @brief Start the OCS request
|
||||
*/
|
||||
void start() Q_DECL_OVERRIDE;
|
||||
|
||||
/**
|
||||
* @brief setWidget stores the associated widget to be able to use
|
||||
* it when the job has finished
|
||||
* @param widget pointer to the notification widget to store
|
||||
*/
|
||||
void setWidget( NotificationWidget *widget );
|
||||
|
||||
/**
|
||||
* @brief widget - get the associated notification widget as stored
|
||||
* with setWidget method.
|
||||
* @return widget pointer to the notification widget
|
||||
*/
|
||||
NotificationWidget *widget();
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* Result of the OCS request
|
||||
*
|
||||
* @param reply the reply
|
||||
*/
|
||||
void jobFinished(QString reply, int replyCode);
|
||||
|
||||
private slots:
|
||||
virtual bool finished() Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
QByteArray _verb;
|
||||
QUrl _link;
|
||||
NotificationWidget *_widget;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NotificationConfirmJob_H
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "notificationwidget.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include "ocsjob.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
NotificationWidget::NotificationWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
_ui.setupUi(this);
|
||||
_progressIndi = new QProgressIndicator(this);
|
||||
_ui.horizontalLayout->addWidget(_progressIndi);
|
||||
}
|
||||
|
||||
void NotificationWidget::setActivity(const Activity& activity)
|
||||
{
|
||||
_myActivity = activity;
|
||||
|
||||
Q_ASSERT( !activity._accName.isEmpty() );
|
||||
_accountName = activity._accName;
|
||||
|
||||
// _ui._headerLabel->setText( );
|
||||
_ui._subjectLabel->setVisible( !activity._subject.isEmpty() );
|
||||
_ui._messageLabel->setVisible( !activity._message.isEmpty() );
|
||||
|
||||
_ui._subjectLabel->setText(activity._subject);
|
||||
_ui._messageLabel->setText(activity._message);
|
||||
|
||||
_ui._notifIcon->setPixmap(QPixmap(":/client/resources/bell.png"));
|
||||
_ui._notifIcon->setMinimumWidth(64);
|
||||
_ui._notifIcon->setMinimumHeight(64);
|
||||
_ui._notifIcon->show();
|
||||
|
||||
QString tText = tr("Created at %1").arg(Utility::timeAgoInWords(activity._dateTime));
|
||||
_ui._timeLabel->setText(tText);
|
||||
|
||||
// always remove the buttons
|
||||
foreach( auto button, _ui._buttonBox->buttons() ) {
|
||||
_ui._buttonBox->removeButton(button);
|
||||
}
|
||||
_buttons.clear();
|
||||
|
||||
// display buttons for the links
|
||||
if( activity._links.isEmpty() ) {
|
||||
// in case there is no action defined, do a close button.
|
||||
QPushButton *b = _ui._buttonBox->addButton( QDialogButtonBox::Close );
|
||||
b->setDefault(true);
|
||||
connect(b, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
|
||||
_buttons.append(b);
|
||||
} else {
|
||||
foreach( auto link, activity._links ) {
|
||||
QPushButton *b = _ui._buttonBox->addButton(link._label, QDialogButtonBox::AcceptRole);
|
||||
b->setDefault(link._isPrimary);
|
||||
connect(b, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
|
||||
_buttons.append(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Activity NotificationWidget::activity() const
|
||||
{
|
||||
return _myActivity;
|
||||
}
|
||||
|
||||
void NotificationWidget::slotButtonClicked()
|
||||
{
|
||||
QObject *buttonWidget = QObject::sender();
|
||||
int index = -1;
|
||||
if( buttonWidget ) {
|
||||
// find the button that was clicked, it has to be in the list
|
||||
// of buttons that were added to the button box before.
|
||||
for( int i = 0; i < _buttons.count(); i++ ) {
|
||||
if( _buttons.at(i) == buttonWidget ) {
|
||||
index = i;
|
||||
}
|
||||
_buttons.at(i)->setEnabled(false);
|
||||
}
|
||||
|
||||
// if the button was found, the link must be called
|
||||
if( index > -1 && _myActivity._links.count() == 0 ) {
|
||||
// no links, that means it was the close button
|
||||
// empty link. Just close and remove the widget.
|
||||
QString doneText = tr("Closing in a few seconds...");
|
||||
_ui._timeLabel->setText(doneText);
|
||||
emit requestCleanupAndBlacklist(_myActivity);
|
||||
return;
|
||||
}
|
||||
|
||||
if( index > -1 && index < _myActivity._links.count() ) {
|
||||
ActivityLink triggeredLink = _myActivity._links.at(index);
|
||||
_actionLabel = triggeredLink._label;
|
||||
|
||||
if( ! triggeredLink._link.isEmpty() ) {
|
||||
qDebug() << Q_FUNC_INFO << "Notification Link: "<< triggeredLink._verb << triggeredLink._link;
|
||||
_progressIndi->startAnimation();
|
||||
emit sendNotificationRequest( _accountName, triggeredLink._link, triggeredLink._verb );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NotificationWidget::slotNotificationRequestFinished(int statusCode)
|
||||
{
|
||||
int i = 0;
|
||||
QString doneText;
|
||||
QLocale locale;
|
||||
|
||||
QString timeStr = locale.toString(QTime::currentTime());
|
||||
|
||||
// the ocs API returns stat code 100 if it succeeded.
|
||||
if( statusCode != OCS_SUCCESS_STATUS_CODE ) {
|
||||
qDebug() << Q_FUNC_INFO << "Notification Request to Server failed, leave button visible.";
|
||||
for( i = 0; i < _buttons.count(); i++ ) {
|
||||
_buttons.at(i)->setEnabled(true);
|
||||
}
|
||||
//: The second parameter is a time, such as 'failed at 09:58pm'
|
||||
doneText = tr("%1 request failed at %2").arg(_actionLabel, timeStr);
|
||||
} else {
|
||||
// the call to the ocs API succeeded.
|
||||
_ui._buttonBox->hide();
|
||||
|
||||
//: The second parameter is a time, such as 'selected at 09:58pm'
|
||||
doneText = tr("'%1' selected at %2").arg(_actionLabel, timeStr);
|
||||
}
|
||||
_ui._timeLabel->setText( doneText );
|
||||
|
||||
_progressIndi->stopAnimation();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef NOTIFICATIONWIDGET_H
|
||||
#define NOTIFICATIONWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "activitydata.h"
|
||||
|
||||
#include "ui_notificationwidget.h"
|
||||
|
||||
#define NOTIFICATION_WIDGET_CLOSE_AFTER_MILLISECS 4800
|
||||
|
||||
class QProgressIndicator;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class NotificationWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NotificationWidget(QWidget *parent = 0);
|
||||
|
||||
bool readyToClose();
|
||||
Activity activity() const;
|
||||
|
||||
signals:
|
||||
void sendNotificationRequest( const QString&, const QString& link, const QByteArray& verb);
|
||||
void requestCleanupAndBlacklist( const Activity& activity );
|
||||
|
||||
public slots:
|
||||
void setActivity(const Activity& activity);
|
||||
void slotNotificationRequestFinished(int statusCode);
|
||||
|
||||
private slots:
|
||||
void slotButtonClicked();
|
||||
|
||||
private:
|
||||
Ui_NotificationWidget _ui;
|
||||
Activity _myActivity;
|
||||
QList<QPushButton*> _buttons;
|
||||
QString _accountName;
|
||||
QProgressIndicator *_progressIndi;
|
||||
QString _actionLabel;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NOTIFICATIONWIDGET_H
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário