mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2026-04-04 12:11:33 +02:00
Compare commits
369 Commits
v1.7.0-bet
...
v1.7.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21c8e65d13 | ||
|
|
86d8079739 | ||
|
|
d2be45bce1 | ||
|
|
5d048c18bc | ||
|
|
0fb779d363 | ||
|
|
d0ed82a686 | ||
|
|
d33b68ccc9 | ||
|
|
26f068bcab | ||
|
|
f0dc3725e8 | ||
|
|
2de22b408b | ||
|
|
04b62b139d | ||
|
|
2f20f3c65d | ||
|
|
53b3e5af1b | ||
|
|
7dbb98c2e5 | ||
|
|
8b35cda4c6 | ||
|
|
cb36a37779 | ||
|
|
704c5f2de7 | ||
|
|
3fcb0d2d6b | ||
|
|
2dfe0ed42e | ||
|
|
ac48fbae9c | ||
|
|
6048a7143a | ||
|
|
7c24db07c2 | ||
|
|
271cdac474 | ||
|
|
79e2c132cc | ||
|
|
b5736fb5a7 | ||
|
|
7822a6b000 | ||
|
|
306b63599c | ||
|
|
3021fb546e | ||
|
|
a5bd437d48 | ||
|
|
08156186fa | ||
|
|
f1006ca8b0 | ||
|
|
93c85711d1 | ||
|
|
e5ef5f2410 | ||
|
|
52a5729298 | ||
|
|
b9849580f8 | ||
|
|
4525161e7c | ||
|
|
dee6d18d69 | ||
|
|
d44179142f | ||
|
|
c66c01245b | ||
|
|
681c43631b | ||
|
|
2f740fe471 | ||
|
|
b1c10c8454 | ||
|
|
1d5b3aadea | ||
|
|
2d420cd72c | ||
|
|
707d6880a8 | ||
|
|
dbad1a8d45 | ||
|
|
36eaff92e5 | ||
|
|
e51c299937 | ||
|
|
8c7953a47c | ||
|
|
4527784905 | ||
|
|
ee8a93ae9a | ||
|
|
6096362052 | ||
|
|
89c51e7649 | ||
|
|
6c92076ec3 | ||
|
|
2bba4134fb | ||
|
|
10175c8d57 | ||
|
|
7804bf0a9a | ||
|
|
336c95ce5b | ||
|
|
babe891242 | ||
|
|
bb37e93f52 | ||
|
|
aa0f2c64ff | ||
|
|
e66ca267f4 | ||
|
|
eeb5ca42e0 | ||
|
|
74ec90c725 | ||
|
|
03ee742981 | ||
|
|
b4c86bcf40 | ||
|
|
0094c1ecf5 | ||
|
|
6b5fcf53eb | ||
|
|
4b001a77b3 | ||
|
|
357c08c5b3 | ||
|
|
e7d9ec50dc | ||
|
|
09b0ba31ef | ||
|
|
8231bc931b | ||
|
|
26ffa078ef | ||
|
|
eb60aca34f | ||
|
|
4d3020421a | ||
|
|
f1ce0a1cf3 | ||
|
|
dd28a645a1 | ||
|
|
561e3c780d | ||
|
|
8371e34d87 | ||
|
|
46fd79604d | ||
|
|
d08c2de619 | ||
|
|
a452a05e52 | ||
|
|
0a96aa3aaf | ||
|
|
07bcaaebf9 | ||
|
|
0cde7c8ac1 | ||
|
|
b285e98988 | ||
|
|
ab40ba2f75 | ||
|
|
bbcb8ba3e7 | ||
|
|
ef48de34f7 | ||
|
|
7e898cf60c | ||
|
|
2f5cea0e73 | ||
|
|
282abdd804 | ||
|
|
9b178c5bb2 | ||
|
|
d491663143 | ||
|
|
8eaeba6486 | ||
|
|
631e67949e | ||
|
|
77d2cba155 | ||
|
|
2149092c7a | ||
|
|
100d1361b6 | ||
|
|
76f5266fa1 | ||
|
|
3ebe3b1196 | ||
|
|
c4f96c2fba | ||
|
|
d880f2ffbc | ||
|
|
f8f5a7ceaa | ||
|
|
b01839e9a4 | ||
|
|
75dbf12ae6 | ||
|
|
9bb89dced5 | ||
|
|
661fe5df66 | ||
|
|
8a93437e55 | ||
|
|
b20752f13e | ||
|
|
61967f6e1b | ||
|
|
f0fef4f232 | ||
|
|
7eb10a08b8 | ||
|
|
4c83653d5d | ||
|
|
3149cd03be | ||
|
|
5314765410 | ||
|
|
621a37be15 | ||
|
|
6de104a03a | ||
|
|
97560509ea | ||
|
|
32aaecd832 | ||
|
|
dfba8fbe5e | ||
|
|
32fea6523f | ||
|
|
d1c1a18226 | ||
|
|
04558beabe | ||
|
|
425d0d77c5 | ||
|
|
edf7cd29dd | ||
|
|
27318dded6 | ||
|
|
11fe0c5b4b | ||
|
|
886f9d82f2 | ||
|
|
4f2fb4af5d | ||
|
|
6c8eab734e | ||
|
|
9d5d6aff38 | ||
|
|
705cd571a5 | ||
|
|
48d3c75745 | ||
|
|
6fbd28d228 | ||
|
|
285cb78962 | ||
|
|
708655d9b2 | ||
|
|
9bd7ffe952 | ||
|
|
51109ea485 | ||
|
|
1579c23ff1 | ||
|
|
961df010cb | ||
|
|
103986b320 | ||
|
|
764c0cdb03 | ||
|
|
12b09fab67 | ||
|
|
ed5a8ab090 | ||
|
|
41fa562dce | ||
|
|
6c2ce06fea | ||
|
|
ef019cdbfa | ||
|
|
1b02a1a6f3 | ||
|
|
1d8900dc19 | ||
|
|
171fd22d91 | ||
|
|
78d50f4033 | ||
|
|
fee18dd457 | ||
|
|
81d3ce8257 | ||
|
|
5213970c3d | ||
|
|
bcc06af904 | ||
|
|
a98242a2b8 | ||
|
|
5f715ca063 | ||
|
|
0ceeff62d6 | ||
|
|
f53a7c0e4a | ||
|
|
41b07d045a | ||
|
|
0d303f1d1f | ||
|
|
b6d97cfffb | ||
|
|
3e982ad34c | ||
|
|
dafd9c308f | ||
|
|
7f836cc01b | ||
|
|
147fa60f81 | ||
|
|
a1b9405e2e | ||
|
|
db02d44c6a | ||
|
|
dff1f77dfa | ||
|
|
1a2fff8ed8 | ||
|
|
52c12b33c3 | ||
|
|
29987ca2aa | ||
|
|
02f971b534 | ||
|
|
479b340d75 | ||
|
|
06c48f58cc | ||
|
|
0ee81a2865 | ||
|
|
e78c251832 | ||
|
|
efbc495f79 | ||
|
|
f8b73eb9d9 | ||
|
|
f25a590af5 | ||
|
|
0539098371 | ||
|
|
788c27bf2f | ||
|
|
a587148c73 | ||
|
|
9acd3a58ee | ||
|
|
449f5adaba | ||
|
|
2380b7af3d | ||
|
|
10989d13e4 | ||
|
|
fe1653ede6 | ||
|
|
b4071cec01 | ||
|
|
b1c842373d | ||
|
|
a3d70b3cf6 | ||
|
|
70912c44de | ||
|
|
98d9f7924d | ||
|
|
172295289e | ||
|
|
8ba08d7e87 | ||
|
|
8915f94931 | ||
|
|
31bf844452 | ||
|
|
0c8b74a025 | ||
|
|
dad8c1c27c | ||
|
|
2e12acdf32 | ||
|
|
d6156dd755 | ||
|
|
2c67a7ca71 | ||
|
|
688b8dcc38 | ||
|
|
280edee1db | ||
|
|
b9ea72f189 | ||
|
|
8f8265b219 | ||
|
|
00ae3c3120 | ||
|
|
1e49f152be | ||
|
|
f72ca4d83e | ||
|
|
5b10a9f3a7 | ||
|
|
d0fb1acebb | ||
|
|
09be4d22ee | ||
|
|
11a64320f0 | ||
|
|
4eac66b84a | ||
|
|
497b7808b6 | ||
|
|
b10c2b5946 | ||
|
|
fa881ba1c7 | ||
|
|
eb1b17e8e4 | ||
|
|
2eec85a97c | ||
|
|
c85b6193d5 | ||
|
|
fc36e7eccf | ||
|
|
0cc2bbf5d9 | ||
|
|
d2669debb9 | ||
|
|
637fb449c6 | ||
|
|
e82b319ee7 | ||
|
|
e9248066df | ||
|
|
819472d366 | ||
|
|
21bbdd6f49 | ||
|
|
a88ac00115 | ||
|
|
30683b38a8 | ||
|
|
45aefeb146 | ||
|
|
580ecbff0c | ||
|
|
db3318886e | ||
|
|
54eb837950 | ||
|
|
0bd73788f4 | ||
|
|
e395282e0e | ||
|
|
1f129d0bcb | ||
|
|
c2ae5e5fd1 | ||
|
|
292a7357bd | ||
|
|
99aa2cdf2a | ||
|
|
0eb9401c62 | ||
|
|
ab14a589c8 | ||
|
|
122fa596b3 | ||
|
|
5406407ed6 | ||
|
|
b72cee2783 | ||
|
|
fe023e2229 | ||
|
|
1dae928a7c | ||
|
|
9b1779bb06 | ||
|
|
97cc05eeea | ||
|
|
20dd3b0a69 | ||
|
|
f348eabf19 | ||
|
|
5870a57002 | ||
|
|
278bc5a8cd | ||
|
|
3c89415df1 | ||
|
|
5981f700f5 | ||
|
|
af5e8ee18c | ||
|
|
52e8343f76 | ||
|
|
a4dbf5942c | ||
|
|
ada1d42ebf | ||
|
|
f27182ae05 | ||
|
|
2fddf05515 | ||
|
|
91d1864840 | ||
|
|
79052ba7c6 | ||
|
|
0edd4d3c02 | ||
|
|
71516c480d | ||
|
|
1304c2c4ab | ||
|
|
a84b7dc27e | ||
|
|
927af0adec | ||
|
|
2dfbc2058f | ||
|
|
79ee6c2f3b | ||
|
|
f59a6862ca | ||
|
|
fa962b7f53 | ||
|
|
71408bab60 | ||
|
|
9e015eb654 | ||
|
|
4ce03e8b61 | ||
|
|
68b7f412b6 | ||
|
|
20011f3a84 | ||
|
|
2d020b5989 | ||
|
|
1909b465dc | ||
|
|
88b7f2e0ee | ||
|
|
531d586460 | ||
|
|
2630a73a1c | ||
|
|
4decd15ca9 | ||
|
|
3a59dd24f3 | ||
|
|
1cf1f6edcb | ||
|
|
5d36a27893 | ||
|
|
da94533647 | ||
|
|
db08d5021e | ||
|
|
69066013c1 | ||
|
|
aef569ee9d | ||
|
|
cf881aa6dc | ||
|
|
a48bf3142c | ||
|
|
33d9f4b882 | ||
|
|
49c40a4b11 | ||
|
|
d1eff0ae24 | ||
|
|
c0131695c5 | ||
|
|
fcbadda40f | ||
|
|
2455faa6fe | ||
|
|
7da8a5e374 | ||
|
|
b3950165c4 | ||
|
|
b8ab859c59 | ||
|
|
99a3cb0eab | ||
|
|
0be4b59cff | ||
|
|
ddfc7c75df | ||
|
|
7618f29657 | ||
|
|
291231c561 | ||
|
|
68792ee9db | ||
|
|
7ce2a93c63 | ||
|
|
4d33773cef | ||
|
|
5d19426930 | ||
|
|
1b51a10b19 | ||
|
|
aab870af32 | ||
|
|
7c70ada423 | ||
|
|
12e2bac16b | ||
|
|
34a27c748a | ||
|
|
a73fbccf8c | ||
|
|
7f1d707d23 | ||
|
|
f1fb36bcb8 | ||
|
|
25c274a0bd | ||
|
|
d4bbd28757 | ||
|
|
98b7248df0 | ||
|
|
0fb0f2c204 | ||
|
|
79d13d9242 | ||
|
|
b6f42a91f4 | ||
|
|
cc5f5cf3a6 | ||
|
|
79f00c2a2a | ||
|
|
e5068e7543 | ||
|
|
858218ac34 | ||
|
|
d69049ce10 | ||
|
|
59a9cc7c12 | ||
|
|
2f34b046d0 | ||
|
|
a73316306d | ||
|
|
928652e4cf | ||
|
|
7950b49cb1 | ||
|
|
f8b1b243c1 | ||
|
|
cc6aa66ab0 | ||
|
|
ea381392a7 | ||
|
|
bb7f63dcfd | ||
|
|
253d65727b | ||
|
|
61138b58bf | ||
|
|
5490063b7e | ||
|
|
d2e1489fe7 | ||
|
|
eb898646bc | ||
|
|
79b547b83b | ||
|
|
2356601bb3 | ||
|
|
9b88c7d3c1 | ||
|
|
302499b483 | ||
|
|
03dc27a327 | ||
|
|
9291ace558 | ||
|
|
15c11ea172 | ||
|
|
cd6950d984 | ||
|
|
de96350bee | ||
|
|
753aa9132e | ||
|
|
cfdfd6a860 | ||
|
|
0c9d57228d | ||
|
|
5254c9785c | ||
|
|
0f37484b8a | ||
|
|
e17243bc1f | ||
|
|
0e45dd7a3d | ||
|
|
65f313f1b4 | ||
|
|
da4958c716 | ||
|
|
653b8494f5 | ||
|
|
6ed6f84f6e | ||
|
|
ff0ba56bc3 | ||
|
|
e795d04f30 | ||
|
|
8d3806b080 | ||
|
|
5597ebe455 |
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -2,4 +2,4 @@
|
||||
.gitignore export-ignore
|
||||
.gitattributes export-ignore
|
||||
.commit-template export-ignore
|
||||
/binary export-ignore
|
||||
binary/ export-ignore
|
||||
|
||||
@@ -123,11 +123,22 @@ find_package(Sphinx)
|
||||
find_package(PdfLatex)
|
||||
|
||||
|
||||
find_package(SQLite3 3.8.0 REQUIRED)
|
||||
# On some OS, we want to use our own, not the system sqlite
|
||||
if (USE_OUR_OWN_SQLITE3)
|
||||
include_directories(BEFORE ${SQLITE3_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
configure_file(test/test_journal.db "${CMAKE_BINARY_DIR}/test/test_journal.db" COPYONLY)
|
||||
|
||||
# Copy that logo, the installer uses it later
|
||||
if(BUILD_OWNCLOUD_OSX_BUNDLE)
|
||||
install(FILES resources/owncloud_logo_blue.png DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
|
||||
endif()
|
||||
|
||||
include(OwnCloudCPack.cmake)
|
||||
|
||||
add_definitions(-DUNICODE)
|
||||
@@ -144,6 +155,7 @@ add_subdirectory(csync)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(shell_integration)
|
||||
add_subdirectory(doc)
|
||||
add_subdirectory(admin)
|
||||
|
||||
if(UNIT_TESTING)
|
||||
include(CTest)
|
||||
@@ -155,4 +167,5 @@ if(BUILD_OWNCLOUD_OSX_BUNDLE)
|
||||
configure_file(sync-exclude.lst ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
|
||||
else()
|
||||
install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
|
||||
configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
|
||||
endif()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
ChangeLog
|
||||
=========
|
||||
version 1.6.2 (release 2014-07-x )
|
||||
version 1.6.2 (release 2014-07-28 )
|
||||
* Limit the HTTP buffer size when downloading to limit memory consumption.
|
||||
* Another small mem leak fixed in HTTP Credentials.
|
||||
* Fix local file name clash detection for MacOSX.
|
||||
* Limit maximum wait time to ten seconds in network limiting.
|
||||
|
||||
@@ -4,7 +4,7 @@ set( MIRALL_VERSION_PATCH 0 )
|
||||
set( MIRALL_SOVERSION 0 )
|
||||
|
||||
if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
set( MIRALL_VERSION_SUFFIX "beta1") #e.g. beta1, beta2, rc1
|
||||
set( MIRALL_VERSION_SUFFIX "beta4") #e.g. beta1, beta2, rc1
|
||||
endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
|
||||
if( NOT DEFINED MIRALL_VERSION_BUILD )
|
||||
|
||||
2
admin/CMakeLists.txt
Normal file
2
admin/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
# traverse into osx subdirectory to install and patch the create-pack script
|
||||
add_subdirectory(osx)
|
||||
3
admin/osx/CMakeLists.txt
Normal file
3
admin/osx/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
configure_file(create_mac_pkg.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/create_mac.sh)
|
||||
configure_file(macosx.pkgproj ${CMAKE_CURRENT_BINARY_DIR}/macosx.pkgproj)
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to create the Mac installer using the packages tool from
|
||||
# http://s.sudre.free.fr/Software/Packages/about.html
|
||||
#
|
||||
|
||||
# the path of installation must be given as parameter
|
||||
if [ -z "$1" ]; then
|
||||
echo "ERROR: Provide the CMAKE_INSTALL_DIR to this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prjfile="admin/osx/macosx.pkgproj"
|
||||
if [ ! -f $prjfile ]; then
|
||||
echo "ERROR: macosx.pkgproj not in admin dir, start from CMAKE_SOURCE_DIR!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
pack="admin/ownCloud Installer.pkg"
|
||||
rm -f $pack
|
||||
|
||||
install_path=$1
|
||||
|
||||
# The name of the installer package
|
||||
installer=ownCloud\ Installer.pkg
|
||||
|
||||
# The command line tool of the "Packages" tool, see link above.
|
||||
pkgbuild=/usr/local/bin/packagesbuild
|
||||
|
||||
$pkgbuild -F $install_path $prjfile
|
||||
rc=$?
|
||||
|
||||
if [ $rc == 0 ]; then
|
||||
echo "Successfully created $pack"
|
||||
else
|
||||
echo "Failed to create $pack"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# FIXME: Sign the finished package.
|
||||
# See http://s.sudre.free.fr/Software/documentation/Packages/en/Project_Configuration.html#5
|
||||
# certname=gdbsign
|
||||
# productsign --cert $certname admin/$installer ./$installer
|
||||
|
||||
|
||||
74
admin/osx/create_mac_pkg.sh.cmake
Executable file
74
admin/osx/create_mac_pkg.sh.cmake
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to create the Mac installer using the packages tool from
|
||||
# http://s.sudre.free.fr/Software/Packages/about.html
|
||||
#
|
||||
|
||||
[ "$#" -lt 2 ] && echo "Usage: create_mac_pkg.sh <CMAKE_INSTALL_DIR> <build dir> <installer sign identity>" && exit
|
||||
|
||||
# the path of installation must be given as parameter
|
||||
if [ -z "$1" ]; then
|
||||
echo "ERROR: Provide the path to CMAKE_INSTALL_DIR to this script as first parameter."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
echo "ERROR: Provide the path to build directory as second parameter."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_path="$1"
|
||||
build_path="$2"
|
||||
identity="$3"
|
||||
prjfile=$build_path/admin/osx/macosx.pkgproj
|
||||
|
||||
# The name of the installer package
|
||||
installer="@APPLICATION_NAME@-@MIRALL_VERSION_FULL@@MIRALL_VERSION_SUFFIX@"
|
||||
installer_file="$installer.pkg"
|
||||
installer_file_tar="$installer.pkg.tar"
|
||||
installer_file_tar_bz2="$installer.pkg.tar.bz2"
|
||||
installer_file_tbz="$installer.pkg.tbz"
|
||||
|
||||
# set the installer name to the copied prj config file
|
||||
/usr/local/bin/packagesutil --file $prjfile set project name "$installer"
|
||||
|
||||
# The command line tool of the "Packages" tool, see link above.
|
||||
pkgbuild=/usr/local/bin/packagesbuild
|
||||
|
||||
$pkgbuild -F $install_path $prjfile
|
||||
rc=$?
|
||||
|
||||
if [ $rc == 0 ]; then
|
||||
echo "Successfully created $installer_file"
|
||||
else
|
||||
echo "Failed to create $installer_file"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Sign the finished package if desired.
|
||||
if [ ! -z "$identity" ]; then
|
||||
echo "Will try to sign the installer"
|
||||
pushd $install_path
|
||||
productsign --sign "$identity" "$installer_file" "$installer_file.new"
|
||||
mv "$installer_file".new $installer_file
|
||||
popd
|
||||
else
|
||||
echo "No certificate given, will not sign the pkg"
|
||||
fi
|
||||
|
||||
# FIXME: OEMs?
|
||||
# they will need to do their own signing..
|
||||
|
||||
|
||||
# Sparkle wants a tbz, it cannot install raw pkg
|
||||
cd $install_path
|
||||
tar cf "$installer_file_tar" "$installer_file"
|
||||
bzip2 -9 "$installer_file_tar"
|
||||
mv "$installer_file_tar_bz2" "$installer_file_tbz"
|
||||
rc=$?
|
||||
if [ $rc == 0 ]; then
|
||||
echo "Successfully created $installer_file"
|
||||
else
|
||||
echo "Failed to create $installer_file"
|
||||
exit 3
|
||||
fi
|
||||
334
admin/osx/macdeployqt.py
Executable file
334
admin/osx/macdeployqt.py
Executable file
@@ -0,0 +1,334 @@
|
||||
#!/usr/bin/python
|
||||
# This file is part of ownCloud.
|
||||
# It was inspired in large part by the macdeploy script in Clementine
|
||||
# and Tomahawk
|
||||
#
|
||||
# ownCloud 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.
|
||||
#
|
||||
# ownCLoud 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.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with ownCloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import commands
|
||||
import sys
|
||||
from glob import glob
|
||||
|
||||
def QueryQMake(attrib):
|
||||
return subprocess.check_output([qmake_path, '-query', attrib]).rstrip('\n')
|
||||
|
||||
FRAMEWORK_SEARCH_PATH=[
|
||||
'/Library/Frameworks',
|
||||
os.path.join(os.environ['HOME'], 'Library/Frameworks')
|
||||
]
|
||||
|
||||
LIBRARY_SEARCH_PATH=['/usr/local/lib', '.']
|
||||
|
||||
QT_PLUGINS = [
|
||||
'accessible/libqtaccessiblewidgets.dylib',
|
||||
'sqldrivers/libqsqlite.dylib',
|
||||
'platforms/libqcocoa.dylib',
|
||||
'imageformats/libqgif.dylib',
|
||||
'imageformats/libqico.dylib',
|
||||
'imageformats/libqjpeg.dylib',
|
||||
'imageformats/libqsvg.dylib',
|
||||
'imageformats/libqmng.dylib',
|
||||
]
|
||||
|
||||
QT_PLUGINS_SEARCH_PATH=[
|
||||
# os.path.join(os.environ['QTDIR'], 'plugins'),
|
||||
'/usr/local/Cellar/qt/5.2.1/plugins',
|
||||
]
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CouldNotFindQtPluginErrorFindFrameworkError(Error):
|
||||
pass
|
||||
|
||||
|
||||
class InstallNameToolError(Error):
|
||||
pass
|
||||
|
||||
|
||||
class CouldNotFindQtPluginError(Error):
|
||||
pass
|
||||
|
||||
|
||||
class CouldNotFindScriptPluginError(Error):
|
||||
pass
|
||||
|
||||
class CouldNotFindFrameworkError(Error):
|
||||
pass
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print 'Usage: %s <bundle.app> <path-to-qmake>' % sys.argv[0]
|
||||
exit()
|
||||
|
||||
def is_exe(fpath):
|
||||
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
||||
|
||||
bundle_dir = sys.argv[1]
|
||||
qmake_path = sys.argv[2]
|
||||
|
||||
bundle_name = os.path.basename(bundle_dir).split('.')[0]
|
||||
|
||||
commands = []
|
||||
|
||||
binary_dir = os.path.join(bundle_dir, 'Contents', 'MacOS')
|
||||
frameworks_dir = os.path.join(bundle_dir, 'Contents', 'Frameworks')
|
||||
commands.append(['mkdir', '-p', frameworks_dir])
|
||||
resources_dir = os.path.join(bundle_dir, 'Contents', 'Resources')
|
||||
commands.append(['mkdir', '-p', resources_dir])
|
||||
plugins_dir = os.path.join(bundle_dir, 'Contents', 'PlugIns')
|
||||
binaries = [i for i in glob(os.path.join(bundle_dir, 'Contents', 'MacOS', "*")) if is_exe(i)];
|
||||
|
||||
|
||||
fixed_libraries = []
|
||||
fixed_frameworks = []
|
||||
|
||||
def WriteQtConf():
|
||||
print "Writing qt.conf..."
|
||||
with open(os.path.join(resources_dir, 'qt.conf'), 'w') as f:
|
||||
f.write("[Paths]\nPlugins = PlugIns\n");
|
||||
f.close()
|
||||
|
||||
def GetBrokenLibraries(binary):
|
||||
#print "Checking libs for binary: %s" % binary
|
||||
output = subprocess.Popen(['otool', '-L', binary], stdout=subprocess.PIPE).communicate()[0]
|
||||
broken_libs = {
|
||||
'frameworks': [],
|
||||
'libs': []}
|
||||
for line in [x.split(' ')[0].lstrip() for x in output.split('\n')[1:]]:
|
||||
#print "Checking line: %s" % line
|
||||
if not line: # skip empty lines
|
||||
continue
|
||||
if os.path.basename(binary) == os.path.basename(line):
|
||||
#print "mnope %s-%s" % (os.path.basename(binary), os.path.basename(line))
|
||||
continue
|
||||
if re.match(r'^\s*/System/', line):
|
||||
continue # System framework
|
||||
elif re.match(r'^\s*/usr/lib/', line):
|
||||
#print "unix style system lib"
|
||||
continue # unix style system library
|
||||
elif re.match(r'Breakpad', line):
|
||||
continue # Manually added by cmake.
|
||||
elif re.match(r'^\s*@executable_path', line) or re.match(r'^\s*@loader_path', line):
|
||||
# Potentially already fixed library
|
||||
if '.framework' in line:
|
||||
relative_path = os.path.join(*line.split('/')[3:])
|
||||
if not os.path.exists(os.path.join(frameworks_dir, relative_path)):
|
||||
broken_libs['frameworks'].append(relative_path)
|
||||
else:
|
||||
relative_path = os.path.join(*line.split('/')[1:])
|
||||
#print "RELPATH %s %s" % (relative_path, os.path.join(binary_dir, relative_path))
|
||||
if not os.path.exists(os.path.join(binary_dir, relative_path)):
|
||||
broken_libs['libs'].append(relative_path)
|
||||
elif re.search(r'\w+\.framework', line):
|
||||
broken_libs['frameworks'].append(line)
|
||||
else:
|
||||
broken_libs['libs'].append(line)
|
||||
|
||||
return broken_libs
|
||||
|
||||
def FindFramework(path):
|
||||
search_pathes = FRAMEWORK_SEARCH_PATH
|
||||
search_pathes.insert(0, QueryQMake('QT_INSTALL_LIBS'))
|
||||
for search_path in search_pathes:
|
||||
abs_path = os.path.join(search_path, path)
|
||||
if os.path.exists(abs_path):
|
||||
return abs_path
|
||||
|
||||
raise CouldNotFindFrameworkError(path)
|
||||
|
||||
def FindLibrary(path):
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
search_pathes = LIBRARY_SEARCH_PATH
|
||||
search_pathes.insert(0, QueryQMake('QT_INSTALL_LIBS'))
|
||||
for search_path in search_pathes:
|
||||
abs_path = os.path.join(search_path, path)
|
||||
if os.path.exists(abs_path):
|
||||
return abs_path
|
||||
else: # try harder---look for lib name in library folders
|
||||
newpath = os.path.join(search_path,os.path.basename(path))
|
||||
if os.path.exists(newpath):
|
||||
return newpath
|
||||
|
||||
return ""
|
||||
#raise CouldNotFindFrameworkError(path)
|
||||
|
||||
def FixAllLibraries(broken_libs):
|
||||
for framework in broken_libs['frameworks']:
|
||||
FixFramework(framework)
|
||||
for lib in broken_libs['libs']:
|
||||
FixLibrary(lib)
|
||||
|
||||
def FixFramework(path):
|
||||
if path in fixed_libraries:
|
||||
return
|
||||
else:
|
||||
fixed_libraries.append(path)
|
||||
abs_path = FindFramework(path)
|
||||
broken_libs = GetBrokenLibraries(abs_path)
|
||||
FixAllLibraries(broken_libs)
|
||||
|
||||
new_path = CopyFramework(abs_path)
|
||||
id = os.sep.join(new_path.split(os.sep)[3:])
|
||||
FixFrameworkId(new_path, id)
|
||||
for framework in broken_libs['frameworks']:
|
||||
FixFrameworkInstallPath(framework, new_path)
|
||||
for library in broken_libs['libs']:
|
||||
FixLibraryInstallPath(library, new_path)
|
||||
|
||||
def FixLibrary(path):
|
||||
if path in fixed_libraries or FindSystemLibrary(os.path.basename(path)) is not None:
|
||||
return
|
||||
else:
|
||||
fixed_libraries.append(path)
|
||||
abs_path = FindLibrary(path)
|
||||
if abs_path == "":
|
||||
print "Could not resolve %s, not fixing!" % path
|
||||
return
|
||||
broken_libs = GetBrokenLibraries(abs_path)
|
||||
FixAllLibraries(broken_libs)
|
||||
|
||||
new_path = CopyLibrary(abs_path)
|
||||
FixLibraryId(new_path)
|
||||
for framework in broken_libs['frameworks']:
|
||||
FixFrameworkInstallPath(framework, new_path)
|
||||
for library in broken_libs['libs']:
|
||||
FixLibraryInstallPath(library, new_path)
|
||||
|
||||
def FixPlugin(abs_path, subdir):
|
||||
broken_libs = GetBrokenLibraries(abs_path)
|
||||
FixAllLibraries(broken_libs)
|
||||
|
||||
new_path = CopyPlugin(abs_path, subdir)
|
||||
for framework in broken_libs['frameworks']:
|
||||
FixFrameworkInstallPath(framework, new_path)
|
||||
for library in broken_libs['libs']:
|
||||
FixLibraryInstallPath(library, new_path)
|
||||
|
||||
def FixBinary(path):
|
||||
broken_libs = GetBrokenLibraries(path)
|
||||
FixAllLibraries(broken_libs)
|
||||
for framework in broken_libs['frameworks']:
|
||||
FixFrameworkInstallPath(framework, path)
|
||||
for library in broken_libs['libs']:
|
||||
FixLibraryInstallPath(library, path)
|
||||
|
||||
def CopyLibrary(path):
|
||||
new_path = os.path.join(binary_dir, os.path.basename(path))
|
||||
args = ['ditto', '--arch=x86_64', path, new_path]
|
||||
commands.append(args)
|
||||
args = ['chmod', 'u+w', new_path]
|
||||
commands.append(args)
|
||||
return new_path
|
||||
|
||||
def CopyPlugin(path, subdir):
|
||||
new_path = os.path.join(plugins_dir, subdir, os.path.basename(path))
|
||||
args = ['mkdir', '-p', os.path.dirname(new_path)]
|
||||
commands.append(args)
|
||||
args = ['ditto', '--arch=x86_64', path, new_path]
|
||||
commands.append(args)
|
||||
args = ['chmod', 'u+w', new_path]
|
||||
commands.append(args)
|
||||
return new_path
|
||||
|
||||
def CopyFramework(path):
|
||||
parts = path.split(os.sep)
|
||||
print "CopyFramework:", path
|
||||
for i, part in enumerate(parts):
|
||||
if re.match(r'\w+\.framework', part):
|
||||
full_path = os.path.join(frameworks_dir, *parts[i:-1])
|
||||
break
|
||||
args = ['mkdir', '-p', full_path]
|
||||
commands.append(args)
|
||||
args = ['ditto', '--arch=x86_64', path, full_path]
|
||||
commands.append(args)
|
||||
args = ['chmod', 'u+w', os.path.join(full_path, parts[-1])]
|
||||
commands.append(args)
|
||||
|
||||
info_plist = os.path.join(os.path.split(path)[0], '..', '..', 'Contents', 'Info.plist')
|
||||
if os.path.exists(info_plist):
|
||||
args = ['cp', '-r', info_plist, resources_dir]
|
||||
commands.append(args)
|
||||
|
||||
return os.path.join(full_path, parts[-1])
|
||||
|
||||
def FixId(path, library_name):
|
||||
id = '@executable_path/../Frameworks/%s' % library_name
|
||||
args = ['install_name_tool', '-id', id, path]
|
||||
commands.append(args)
|
||||
|
||||
def FixLibraryId(path):
|
||||
library_name = os.path.basename(path)
|
||||
FixId(path, library_name)
|
||||
|
||||
def FixFrameworkId(path, id):
|
||||
FixId(path, id)
|
||||
|
||||
def FixInstallPath(library_path, library, new_path):
|
||||
args = ['install_name_tool', '-change', library_path, new_path, library]
|
||||
commands.append(args)
|
||||
|
||||
def FindSystemLibrary(library_name):
|
||||
for path in ['/lib', '/usr/lib']:
|
||||
full_path = os.path.join(path, library_name)
|
||||
if os.path.exists(full_path):
|
||||
return full_path
|
||||
return None
|
||||
|
||||
def FixLibraryInstallPath(library_path, library):
|
||||
system_library = FindSystemLibrary(os.path.basename(library_path))
|
||||
if system_library is None:
|
||||
new_path = '@executable_path/../MacOS/%s' % os.path.basename(library_path)
|
||||
FixInstallPath(library_path, library, new_path)
|
||||
else:
|
||||
FixInstallPath(library_path, library, system_library)
|
||||
|
||||
def FixFrameworkInstallPath(library_path, library):
|
||||
parts = library_path.split(os.sep)
|
||||
for i, part in enumerate(parts):
|
||||
if re.match(r'\w+\.framework', part):
|
||||
full_path = os.path.join(*parts[i:])
|
||||
break
|
||||
new_path = '@executable_path/../Frameworks/%s' % full_path
|
||||
FixInstallPath(library_path, library, new_path)
|
||||
|
||||
def FindQtPlugin(name):
|
||||
search_path = QT_PLUGINS_SEARCH_PATH
|
||||
search_path.insert(0, QueryQMake('QT_INSTALL_PLUGINS'))
|
||||
for path in search_path:
|
||||
if os.path.exists(path):
|
||||
if os.path.exists(os.path.join(path, name)):
|
||||
return os.path.join(path, name)
|
||||
raise CouldNotFindQtPluginError(name)
|
||||
|
||||
for binary in binaries:
|
||||
FixBinary(binary)
|
||||
|
||||
for plugin in QT_PLUGINS:
|
||||
FixPlugin(FindQtPlugin(plugin), os.path.dirname(plugin))
|
||||
|
||||
if len(sys.argv) <= 2:
|
||||
print 'Will run %d commands:' % len(commands)
|
||||
for command in commands:
|
||||
print ' '.join(command)
|
||||
|
||||
for command in commands:
|
||||
p = subprocess.Popen(command)
|
||||
os.waitpid(p.pid, 0)
|
||||
|
||||
WriteQtConf()
|
||||
@@ -22,7 +22,7 @@
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>owncloud.app</string>
|
||||
<string>@APPLICATION_EXECUTABLE@.app</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>3</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
@@ -1054,10 +1054,10 @@
|
||||
<integer>6</integer>
|
||||
<key>BACKGROUND_PATH</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/Users/mackie/owncloud.com/mirall/resources/owncloud_logo_blue.png</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>./@APPLICATION_EXECUTABLE@.app/Contents/Resources/owncloud_logo_blue.png</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
<key>CUSTOM</key>
|
||||
<integer>1</integer>
|
||||
@@ -1240,9 +1240,9 @@
|
||||
<key>BUILD_PATH</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/Users/mackie/owncloud.com/mirall/admin</string>
|
||||
<string>../install/.</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
<key>EXCLUDED_FILES</key>
|
||||
<array>
|
||||
|
||||
32
admin/osx/sign_app.sh
Executable file
32
admin/osx/sign_app.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh -x
|
||||
|
||||
[ "$#" -lt 2 ] && echo "Usage: sign_app.sh <app> <identity>" && exit
|
||||
|
||||
src_app="$1"
|
||||
identity="$2"
|
||||
|
||||
QT_FMWK_VERSION="5"
|
||||
|
||||
fix_frameworks() {
|
||||
TMP_APP=$1
|
||||
QT_FMWK_PATH=$2
|
||||
QT_FMWKS=$3/Qt*.framework
|
||||
|
||||
echo "Patching Qt frameworks..."
|
||||
for FMWK in $QT_FMWKS; do
|
||||
FMWK_NAME=`basename -s .framework $FMWK`
|
||||
FMWK=`basename $FMWK`
|
||||
FMWK_PATH="${TMP_APP}/Contents/Frameworks/${FMWK}"
|
||||
mkdir -p "${FMWK_PATH}/Versions/${QT_FMWK_VERSION}/Resources/"
|
||||
cp -avf "${QT_FMWK_PATH}/${FMWK}/Contents/Info.plist" "${FMWK_PATH}/Versions/${QT_FMWK_VERSION}/Resources"
|
||||
(cd "${FMWK_PATH}" && ln -sf "Versions/${QT_FMWK_VERSION}/Resources" "Resources")
|
||||
perl -pi -e "s/${FMWK_NAME}_debug/${FMWK_NAME}/" "${FMWK_PATH}/Resources/Info.plist"
|
||||
done
|
||||
}
|
||||
|
||||
fix_frameworks "$src_app" `qmake -query QT_INSTALL_LIBS` "$src_app"/Contents/Frameworks
|
||||
codesign -s "$identity" --force --verbose=4 --deep "$src_app"
|
||||
|
||||
# Just for our debug purposes:
|
||||
spctl -a -t exec -vv $src_app
|
||||
codesign -dv $src_app
|
||||
@@ -15,6 +15,8 @@ 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 "Statusikoner för Windows Explorer"
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_DetailPrint "Installerar statusikoner 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"
|
||||
@@ -42,5 +44,3 @@ StrCpy $INIT_INSTALLER_RUNNING "Installationsprogrammet körs redan."
|
||||
StrCpy $UAC_UNINSTALLER_REQUIRE_ADMIN "Detta avinstallationsprogram kräver administratörs rättigheter, försök igen"
|
||||
StrCpy $INIT_UNINSTALLER_RUNNING "Avinstallationsprogrammet körs redan."
|
||||
StrCpy $SectionGroup_Shortcuts "Genvägar"
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_SECTION "Status icons for Windows Explorer"
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_DetailPrint "Installing status icons for Windows Explorer"
|
||||
|
||||
2
binary
2
binary
Submodule binary updated: 82d72bc62d...18d9ac810b
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# Always include srcdir and builddir in include path
|
||||
# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
|
||||
# about every subdir
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# define system dependent compiler flags
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
@@ -10,7 +14,8 @@ if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
|
||||
|
||||
# add -Wconversion ?
|
||||
# cannot be pedantic with sqlite3 directly linked
|
||||
if (NOT CSYNC_STATIC_COMPILE_DIR)
|
||||
# FIXME Can we somehow not use those flags for sqlite3.* but use them for the rest of csync?
|
||||
if (NOT USE_OUR_OWN_SQLITE3)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -pedantic-errors")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes")
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
if (UNIX)
|
||||
# Suffix for Linux
|
||||
SET(LIB_SUFFIX
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# Set system vars
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# This module defines
|
||||
# INOTIFY_INCLUDE_DIR, where to find inotify.h, etc.
|
||||
# INOTIFY_FOUND, If false, do not try to use inotify.
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# FIND_PACKAGE_VERSION_CHECK(NAME (DEFAULT_MSG|"Custom failure message"))
|
||||
# This function is intended to be used in FindXXX.cmake modules files.
|
||||
# It handles NAME_FIND_VERSION and NAME_VERSION variables in a Module.
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
find_program(PDFLATEX_EXECUTABLE NAMES pdflatex
|
||||
HINTS
|
||||
$ENV{PDFLATEX_DIR}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# - Try to find QtKeychain
|
||||
# Once done this will define
|
||||
# QTKEYCHAIN_FOUND - System has QtKeychain
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# - Try to find QtKeychain
|
||||
# Once done this will define
|
||||
# QTKEYCHAIN_FOUND - System has QtKeychain
|
||||
|
||||
@@ -50,8 +50,18 @@ if (SQLite3_FIND_VERSION AND _SQLITE3_VERSION)
|
||||
set(SQLite3_VERSION _SQLITE3_VERSION)
|
||||
endif (SQLite3_FIND_VERSION AND _SQLITE3_VERSION)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SQLite3 DEFAULT_MSG SQLITE3_LIBRARIES SQLITE3_INCLUDE_DIRS)
|
||||
if (APPLE OR WIN32)
|
||||
set(USE_OUR_OWN_SQLITE3 TRUE)
|
||||
set(SQLITE3_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite3)
|
||||
set(SQLITE3_LIBRARIES "")
|
||||
set(SQLITE3_SOURCE ${SQLITE3_INCLUDE_DIR}/sqlite3.c)
|
||||
MESSAGE(STATUS "Using own sqlite3 from " ${SQLITE3_INCLUDE_DIR})
|
||||
else()
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SQLite3 DEFAULT_MSG SQLITE3_LIBRARIES SQLITE3_INCLUDE_DIRS)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
|
||||
HINTS
|
||||
$ENV{SPHINX_DIR}
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
<string>(C) 2014 @APPLICATION_VENDOR@</string>
|
||||
<key>SUShowReleaseNotes</key>
|
||||
<false/>
|
||||
<key>LSMinimumBundleVersion</key>
|
||||
<string>10.7.0</string>
|
||||
<key>SUPublicDSAKeyFile</key>
|
||||
<string>dsa_pub.pem</string>
|
||||
</dict>
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# - macro_copy_file(_src _dst)
|
||||
# Copies a file to ${_dst} only if ${_src} is different (newer) than ${_dst}
|
||||
#
|
||||
|
||||
@@ -391,6 +391,7 @@ Section "${APPLICATION_NAME}" SEC_APPLICATION
|
||||
; Make sure only to copy qt, not qt_help, etc
|
||||
File "${MING_SHARE}\qt5\translations\qt_??.qm"
|
||||
File "${MING_SHARE}\qt5\translations\qt_??_??.qm"
|
||||
File "${MING_SHARE}\qt5\translations\qtbase_*.qm"
|
||||
File "${MING_SHARE}\qt5\translations\qtkeychain_*.qm"
|
||||
|
||||
SetOutPath "$INSTDIR\platforms"
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
include (MacroOptionalFindPackage)
|
||||
include (MacroLogFeature)
|
||||
|
||||
@@ -149,7 +153,18 @@ if(NOT Qt5Core_FOUND)
|
||||
include( ${QT_USE_FILE} )
|
||||
endmacro()
|
||||
|
||||
add_definitions("-DQ_DECL_OVERRIDE=override")
|
||||
if (CMAKE_COMPILER_IS_GNUCC)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GCC_VERSION)
|
||||
if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
|
||||
add_definitions("-DQ_DECL_OVERRIDE=override")
|
||||
else()
|
||||
add_definitions("-DQ_DECL_OVERRIDE=")
|
||||
endif()
|
||||
else() #clang or others
|
||||
add_definitions("-DQ_DECL_OVERRIDE=override")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if( Qt5Core_DIR )
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
# -helper macro to add a "doc" target with CMake build system.
|
||||
# and configure doxy.config.in to doxy.config
|
||||
#
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# (c) 2014 Copyright ownCloud, Inc.
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING* file.
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GCC_VERSION)
|
||||
|
||||
@@ -4,13 +4,6 @@ add_subdirectory(std)
|
||||
add_subdirectory(httpbf)
|
||||
|
||||
# Statically include sqlite
|
||||
if (CSYNC_STATIC_COMPILE_DIR)
|
||||
set(SQLITE3_INCLUDE_DIRS "")
|
||||
set(SQLITE3_LIBRARIES "")
|
||||
include_directories(${CSYNC_STATIC_COMPILE_DIR})
|
||||
else (CSYNC_STATIC_COMPILE_DIR)
|
||||
find_package(SQLite3 3.3.9 REQUIRED)
|
||||
endif()
|
||||
|
||||
set(CSYNC_PUBLIC_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
@@ -86,8 +79,8 @@ set(csync_HDRS
|
||||
)
|
||||
|
||||
# Statically include sqlite
|
||||
if (CSYNC_STATIC_COMPILE_DIR)
|
||||
list(APPEND csync_SRCS ${CSYNC_STATIC_COMPILE_DIR}/dictionary.c ${CSYNC_STATIC_COMPILE_DIR}/sqlite3.c)
|
||||
if (USE_OUR_OWN_SQLITE3)
|
||||
list(APPEND csync_SRCS ${SQLITE3_SOURCE})
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
|
||||
@@ -254,6 +254,13 @@ int csync_update(CSYNC *ctx) {
|
||||
|
||||
csync_gettime(&finish);
|
||||
|
||||
/* Finalize the sql precompiled statements after the update run since
|
||||
* it runs in its own thread. Precompiled statements shoult not be shared
|
||||
* across thread borders according to
|
||||
* http://www.sqlite.org/cvstrac/wiki?p=MultiThreading
|
||||
*/
|
||||
csync_statedb_finalize_statements(ctx);
|
||||
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
|
||||
"Update detection for remote replica took %.2f seconds "
|
||||
"walking %zu files.",
|
||||
@@ -522,8 +529,6 @@ static void _tree_destructor(void *data) {
|
||||
* used by csync_commit and csync_destroy */
|
||||
static void _csync_clean_ctx(CSYNC *ctx)
|
||||
{
|
||||
c_list_t * walk;
|
||||
|
||||
/* destroy the rbtrees */
|
||||
if (c_rbtree_size(ctx->local.tree) > 0) {
|
||||
c_rbtree_destroy(ctx->local.tree, _tree_destructor);
|
||||
@@ -535,25 +540,14 @@ static void _csync_clean_ctx(CSYNC *ctx)
|
||||
|
||||
csync_rename_destroy(ctx);
|
||||
|
||||
for (walk = c_list_last(ctx->local.ignored_cleanup); walk != NULL; walk = c_list_prev(walk)) {
|
||||
SAFE_FREE(walk->data);
|
||||
}
|
||||
for (walk = c_list_last(ctx->remote.ignored_cleanup); walk != NULL; walk = c_list_prev(walk)) {
|
||||
SAFE_FREE(walk->data);
|
||||
}
|
||||
|
||||
/* free memory */
|
||||
c_rbtree_free(ctx->local.tree);
|
||||
c_list_free(ctx->local.list);
|
||||
c_list_free(ctx->local.ignored_cleanup);
|
||||
c_rbtree_free(ctx->remote.tree);
|
||||
c_list_free(ctx->remote.list);
|
||||
c_list_free(ctx->remote.ignored_cleanup);
|
||||
|
||||
ctx->remote.list = 0;
|
||||
ctx->local.list = 0;
|
||||
ctx->remote.ignored_cleanup = 0;
|
||||
ctx->local.ignored_cleanup = 0;
|
||||
|
||||
SAFE_FREE(ctx->statedb.file);
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ enum csync_status_codes_e {
|
||||
CSYNC_STATUS_ABORTED,
|
||||
/* Codes for file individual status: */
|
||||
CSYNC_STATUS_INDIVIDUAL_IS_SYMLINK,
|
||||
CSYNC_STATUS_INDIVIDUAL_IS_HARDLINK,
|
||||
CSYNC_STATUS_INDIVIDUAL_IGNORE_LIST,
|
||||
CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS,
|
||||
CYSNC_STATUS_FILE_LOCKED_OR_OPEN
|
||||
|
||||
@@ -40,7 +40,10 @@
|
||||
#define CSYNC_LOG_CATEGORY_NAME "csync.exclude"
|
||||
#include "csync_log.h"
|
||||
|
||||
static int _csync_exclude_add(c_strlist_t **inList, const char *string) {
|
||||
#ifndef NDEBUG
|
||||
static
|
||||
#endif
|
||||
int _csync_exclude_add(c_strlist_t **inList, const char *string) {
|
||||
c_strlist_t *list;
|
||||
|
||||
if (*inList == NULL) {
|
||||
@@ -150,12 +153,6 @@ CSYNC_EXCLUDE_TYPE csync_excluded(CSYNC *ctx, const char *path, int filetype) {
|
||||
|
||||
match = csync_excluded_no_ctx( ctx->excludes, path, filetype );
|
||||
|
||||
if (match == CSYNC_NOT_EXCLUDED && ctx->checkBlackListHook) {
|
||||
if (ctx->checkBlackListHook(ctx->checkBlackListData, path)) {
|
||||
match = CSYNC_FILE_EXCLUDE_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
@@ -205,6 +202,20 @@ CSYNC_EXCLUDE_TYPE csync_excluded_no_ctx(c_strlist_t *excludes, const char *path
|
||||
goto out;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Windows cannot sync files ending in spaces (#2176). It also cannot
|
||||
// distinguish files ending in '.' from files without an ending,
|
||||
// as '.' is a separator that is not stored internally, so let's
|
||||
// not allow to sync those to avoid file loss/ambiguities (#416)
|
||||
size_t blen = strlen(bname);
|
||||
if (blen > 1 && (bname[blen-1]== ' ' || bname[blen-1]== '.' )) {
|
||||
match = CSYNC_FILE_EXCLUDE_INVALID_CHAR;
|
||||
SAFE_FREE(bname);
|
||||
SAFE_FREE(dname);
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = csync_fnmatch(".owncloudsync.log*", bname, 0);
|
||||
if (rc == 0) {
|
||||
match = CSYNC_FILE_SILENTLY_EXCLUDED;
|
||||
|
||||
@@ -29,6 +29,11 @@ enum csync_exclude_type_e {
|
||||
CSYNC_FILE_EXCLUDE_INVALID_CHAR
|
||||
};
|
||||
typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE;
|
||||
|
||||
#ifdef NDEBUG
|
||||
int _csync_exclude_add(c_strlist_t **inList, const char *string);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Load exclude list
|
||||
*
|
||||
|
||||
@@ -110,7 +110,7 @@ static int ssl_callback_by_neon(void *userdata, int failures,
|
||||
}
|
||||
}
|
||||
DEBUG_WEBDAV("## VERIFY_SSL CERT: %d", ret );
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -761,6 +761,7 @@ int owncloud_commit(CSYNC* ctx) {
|
||||
}
|
||||
|
||||
ctx->owncloud_context->is_first_propfind = true;
|
||||
ctx->owncloud_context->dav_session.no_recursive_propfind = true;
|
||||
/* DEBUG_WEBDAV( "********** vio_module_shutdown" ); */
|
||||
|
||||
ctx->owncloud_context->dav_session.ctx = 0;
|
||||
|
||||
@@ -339,6 +339,8 @@ void fill_webdav_properties_into_resource(struct resource* newres, const ne_prop
|
||||
file_id = ne_propset_value( set, &ls_props[4] );
|
||||
directDownloadUrl = ne_propset_value( set, &ls_props[5] );
|
||||
directDownloadCookies = ne_propset_value( set, &ls_props[6] );
|
||||
|
||||
// permission flags: Defined in https://github.com/owncloud/core/issues/8322
|
||||
perm = ne_propset_value( set, &ls_props[7] );
|
||||
|
||||
if( resourcetype && strncmp( resourcetype, "<DAV:collection>", 16 ) == 0) {
|
||||
|
||||
@@ -100,6 +100,8 @@ struct csync_s {
|
||||
sqlite3_stmt* by_hash_stmt;
|
||||
sqlite3_stmt* by_fileid_stmt;
|
||||
sqlite3_stmt* by_inode_stmt;
|
||||
|
||||
int lastReturnValue;
|
||||
} statedb;
|
||||
|
||||
struct {
|
||||
@@ -107,7 +109,6 @@ struct csync_s {
|
||||
c_rbtree_t *tree;
|
||||
c_list_t *list;
|
||||
enum csync_replica_e type;
|
||||
c_list_t *ignored_cleanup;
|
||||
} local;
|
||||
|
||||
struct {
|
||||
@@ -116,7 +117,6 @@ struct csync_s {
|
||||
c_list_t *list;
|
||||
enum csync_replica_e type;
|
||||
int read_from_db;
|
||||
c_list_t *ignored_cleanup;
|
||||
} remote;
|
||||
|
||||
#if defined(HAVE_ICONV) && defined(WITH_ICONV)
|
||||
@@ -148,8 +148,8 @@ struct csync_s {
|
||||
struct csync_owncloud_ctx_s *owncloud_context;
|
||||
|
||||
/* hooks for checking the white list */
|
||||
void *checkBlackListData;
|
||||
int (*checkBlackListHook)(void*, const char*);
|
||||
void *checkSelectiveSyncBlackListData;
|
||||
int (*checkSelectiveSyncBlackListHook)(void*, const char*);
|
||||
};
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ struct csync_file_stat_s {
|
||||
int type; /* u32 */
|
||||
int child_modified;/*bool*/
|
||||
int should_update_etag; /*bool */
|
||||
int has_ignored_files; /*bool: specify that a directory, or child directory contains ignored files */
|
||||
|
||||
char *destpath; /* for renames */
|
||||
const char *etag;
|
||||
|
||||
@@ -134,6 +134,16 @@ static int _csync_merge_algorithm_visitor(void *obj, void *data) {
|
||||
break;
|
||||
/* file has been removed on the opposite replica */
|
||||
case CSYNC_INSTRUCTION_NONE:
|
||||
if (cur->has_ignored_files) {
|
||||
/* Do not remove a directory that has ignored files */
|
||||
break;
|
||||
}
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Will Remove %s %d", cur->path, cur->child_modified);
|
||||
if (cur->child_modified) {
|
||||
/* re-create directory that has modified contents */
|
||||
cur->instruction = CSYNC_INSTRUCTION_NEW;
|
||||
break;
|
||||
}
|
||||
cur->instruction = CSYNC_INSTRUCTION_REMOVE;
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_EVAL_RENAME:
|
||||
|
||||
@@ -50,6 +50,22 @@
|
||||
|
||||
#define BUF_SIZE 16
|
||||
|
||||
#define sqlite_open(A, B) sqlite3_open_v2(A,B, SQLITE_OPEN_READONLY+SQLITE_OPEN_NOMUTEX, NULL)
|
||||
|
||||
#define SQLTM_TIME 150000
|
||||
#define SQLTM_COUNT 10
|
||||
|
||||
#define SQLITE_BUSY_HANDLED(F) if(1) { \
|
||||
int n = 0; \
|
||||
do { rc = F ; \
|
||||
if( (rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED) ) { \
|
||||
n++; \
|
||||
usleep(SQLTM_TIME); \
|
||||
} \
|
||||
}while( (n < SQLTM_COUNT) && ((rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED))); \
|
||||
}
|
||||
|
||||
|
||||
void csync_set_statedb_exists(CSYNC *ctx, int val) {
|
||||
ctx->statedb.exists = val;
|
||||
}
|
||||
@@ -73,6 +89,10 @@ static int _csync_check_db_integrity(sqlite3 *db) {
|
||||
c_strlist_destroy(result);
|
||||
}
|
||||
|
||||
if( sqlite3_threadsafe() == 0 ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "* WARNING: SQLite module is not threadsafe!");
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
@@ -111,7 +131,7 @@ static int _csync_statedb_check(const char *statedb) {
|
||||
if (r >= 0) {
|
||||
buf[BUF_SIZE - 1] = '\0';
|
||||
if (c_streq(buf, "SQLite format 3")) {
|
||||
if (sqlite3_open(statedb, &db ) == SQLITE_OK) {
|
||||
if( sqlite_open(statedb, &db ) == SQLITE_OK ) {
|
||||
rc = _csync_check_db_integrity(db);
|
||||
if( sqlite3_close(db) != 0 ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_NOTICE, "WARN: sqlite3_close error!");
|
||||
@@ -142,7 +162,9 @@ static int _csync_statedb_check(const char *statedb) {
|
||||
|
||||
c_free_locale_string(wstatedb);
|
||||
|
||||
/* create database */
|
||||
/* create database, use the original sqlite3_open function here as opening
|
||||
* read only is not sufficient because that does not create a new db but
|
||||
* bails out with error. */
|
||||
rc = sqlite3_open(statedb, &db);
|
||||
if (rc == SQLITE_OK) {
|
||||
sqlite3_close(db);
|
||||
@@ -187,6 +209,8 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->statedb.lastReturnValue = SQLITE_OK;
|
||||
|
||||
/* csync_statedb_check tries to open the statedb and creates it in case
|
||||
* its not there.
|
||||
*/
|
||||
@@ -199,7 +223,7 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) {
|
||||
}
|
||||
|
||||
/* Open or create the temporary database */
|
||||
if (sqlite3_open(statedb, &db) != SQLITE_OK) {
|
||||
if (sqlite_open(statedb, &db) != SQLITE_OK) {
|
||||
const char *errmsg= sqlite3_errmsg(ctx->statedb.db);
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_NOTICE, "ERR: Failed to sqlite3 open statedb - bail out: %s.",
|
||||
errmsg ? errmsg : "<no sqlite3 errormsg>");
|
||||
@@ -216,8 +240,16 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) {
|
||||
csync_set_statedb_exists(ctx, 1);
|
||||
}
|
||||
|
||||
/* Print out the version */
|
||||
//
|
||||
result = csync_statedb_query(db, "SELECT sqlite_version();");
|
||||
if (result && result->count >= 1) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_NOTICE, "sqlite3 version \"%s\"", *result->vector);
|
||||
}
|
||||
c_strlist_destroy(result);
|
||||
|
||||
/* optimization for speeding up SQLite */
|
||||
result = csync_statedb_query(db, "PRAGMA synchronous = FULL;");
|
||||
result = csync_statedb_query(db, "PRAGMA synchronous = NORMAL;");
|
||||
c_strlist_destroy(result);
|
||||
result = csync_statedb_query(db, "PRAGMA case_sensitive_like = ON;");
|
||||
c_strlist_destroy(result);
|
||||
@@ -243,21 +275,7 @@ int csync_statedb_close(CSYNC *ctx) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* deallocate query resources */
|
||||
if( ctx->statedb.by_hash_stmt ) {
|
||||
rc = sqlite3_finalize(ctx->statedb.by_hash_stmt);
|
||||
ctx->statedb.by_hash_stmt = NULL;
|
||||
}
|
||||
|
||||
if( ctx->statedb.by_fileid_stmt ) {
|
||||
rc = sqlite3_finalize(ctx->statedb.by_fileid_stmt);
|
||||
ctx->statedb.by_fileid_stmt = NULL;
|
||||
}
|
||||
|
||||
if( ctx->statedb.by_inode_stmt ) {
|
||||
rc = sqlite3_finalize(ctx->statedb.by_inode_stmt);
|
||||
ctx->statedb.by_inode_stmt = NULL;
|
||||
}
|
||||
csync_statedb_finalize_statements(ctx);
|
||||
|
||||
sqlite3_close(ctx->statedb.db);
|
||||
|
||||
@@ -281,7 +299,7 @@ static int _csync_file_stat_from_metadata_table( csync_file_stat_t **st, sqlite3
|
||||
|
||||
column_count = sqlite3_column_count(stmt);
|
||||
|
||||
rc = sqlite3_step(stmt);
|
||||
SQLITE_BUSY_HANDLED( sqlite3_step(stmt) );
|
||||
|
||||
if( rc == SQLITE_ROW ) {
|
||||
if(column_count > 7) {
|
||||
@@ -344,7 +362,8 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
|
||||
if( ctx->statedb.by_hash_stmt == NULL ) {
|
||||
const char *hash_query = "SELECT * FROM metadata WHERE phash=?1";
|
||||
|
||||
rc = sqlite3_prepare_v2(ctx->statedb.db, hash_query, strlen(hash_query), &ctx->statedb.by_hash_stmt, NULL);
|
||||
SQLITE_BUSY_HANDLED(sqlite3_prepare_v2(ctx->statedb.db, hash_query, strlen(hash_query), &ctx->statedb.by_hash_stmt, NULL));
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
if( rc != SQLITE_OK ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Unable to create stmt for hash query.");
|
||||
return NULL;
|
||||
@@ -358,6 +377,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
|
||||
sqlite3_bind_int64(ctx->statedb.by_hash_stmt, 1, (long long signed int)phash);
|
||||
|
||||
rc = _csync_file_stat_from_metadata_table(&st, ctx->statedb.by_hash_stmt);
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
if( !(rc == SQLITE_ROW || rc == SQLITE_DONE) ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Could not get line from metadata: %d!", rc);
|
||||
}
|
||||
@@ -366,6 +386,28 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
|
||||
return st;
|
||||
}
|
||||
|
||||
void csync_statedb_finalize_statements(CSYNC *ctx) {
|
||||
if( !ctx ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* deallocate query resources */
|
||||
if( ctx->statedb.by_fileid_stmt ) {
|
||||
sqlite3_finalize(ctx->statedb.by_fileid_stmt);
|
||||
ctx->statedb.by_fileid_stmt = NULL;
|
||||
}
|
||||
if( ctx->statedb.by_hash_stmt ) {
|
||||
sqlite3_finalize(ctx->statedb.by_hash_stmt);
|
||||
ctx->statedb.by_hash_stmt = NULL;
|
||||
}
|
||||
if( ctx->statedb.by_inode_stmt) {
|
||||
sqlite3_finalize(ctx->statedb.by_inode_stmt);
|
||||
ctx->statedb.by_inode_stmt = NULL;
|
||||
}
|
||||
|
||||
ctx->statedb.lastReturnValue = SQLITE_OK;
|
||||
}
|
||||
|
||||
csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx,
|
||||
const char *file_id ) {
|
||||
csync_file_stat_t *st = NULL;
|
||||
@@ -385,7 +427,8 @@ csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx,
|
||||
if( ctx->statedb.by_fileid_stmt == NULL ) {
|
||||
const char *query = "SELECT * FROM metadata WHERE fileid=?1";
|
||||
|
||||
rc = sqlite3_prepare_v2(ctx->statedb.db, query, strlen(query), &ctx->statedb.by_fileid_stmt, NULL);
|
||||
SQLITE_BUSY_HANDLED(sqlite3_prepare_v2(ctx->statedb.db, query, strlen(query), &ctx->statedb.by_fileid_stmt, NULL));
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
if( rc != SQLITE_OK ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Unable to create stmt for file id query.");
|
||||
return NULL;
|
||||
@@ -396,6 +439,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx,
|
||||
sqlite3_bind_text(ctx->statedb.by_fileid_stmt, 1, file_id, -1, SQLITE_STATIC);
|
||||
|
||||
rc = _csync_file_stat_from_metadata_table(&st, ctx->statedb.by_fileid_stmt);
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
if( !(rc == SQLITE_ROW || rc == SQLITE_DONE) ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Could not get line from metadata: %d!", rc);
|
||||
}
|
||||
@@ -423,7 +467,8 @@ csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
|
||||
if( ctx->statedb.by_inode_stmt == NULL ) {
|
||||
const char *inode_query = "SELECT * FROM metadata WHERE inode=?1";
|
||||
|
||||
rc = sqlite3_prepare_v2(ctx->statedb.db, inode_query, strlen(inode_query), &ctx->statedb.by_inode_stmt, NULL);
|
||||
SQLITE_BUSY_HANDLED(sqlite3_prepare_v2(ctx->statedb.db, inode_query, strlen(inode_query), &ctx->statedb.by_inode_stmt, NULL));
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
if( rc != SQLITE_OK ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Unable to create stmt for inode query.");
|
||||
return NULL;
|
||||
@@ -437,6 +482,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
|
||||
sqlite3_bind_int64(ctx->statedb.by_inode_stmt, 1, (long long signed int)inode);
|
||||
|
||||
rc = _csync_file_stat_from_metadata_table(&st, ctx->statedb.by_inode_stmt);
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
if( !(rc == SQLITE_ROW || rc == SQLITE_DONE) ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Could not get line from metadata by inode: %d!", rc);
|
||||
}
|
||||
@@ -485,7 +531,8 @@ int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = sqlite3_prepare_v2(ctx->statedb.db, BELOW_PATH_QUERY, -1, &stmt, NULL);
|
||||
SQLITE_BUSY_HANDLED(sqlite3_prepare_v2(ctx->statedb.db, BELOW_PATH_QUERY, -1, &stmt, NULL));
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
if( rc != SQLITE_OK ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Unable to create stmt for below path query.");
|
||||
return -1;
|
||||
@@ -507,6 +554,7 @@ int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
|
||||
|
||||
cnt = 0;
|
||||
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
do {
|
||||
csync_file_stat_t *st = NULL;
|
||||
|
||||
@@ -522,6 +570,7 @@ int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
|
||||
}
|
||||
} while( rc == SQLITE_ROW );
|
||||
|
||||
ctx->statedb.lastReturnValue = rc;
|
||||
if( rc != SQLITE_DONE ) {
|
||||
ctx->status_code = CSYNC_STATUS_TREE_ERROR;
|
||||
} else {
|
||||
|
||||
@@ -99,25 +99,10 @@ int csync_statedb_get_below_path(CSYNC *ctx, const char *path);
|
||||
c_strlist_t *csync_statedb_query(sqlite3 *db, const char *statement);
|
||||
|
||||
/**
|
||||
* @brief Insert function for the statedb.
|
||||
*
|
||||
* @param ctx The csync context.
|
||||
* @param statement The SQL statement to insert into the statedb.
|
||||
*
|
||||
* @return The rowid of the most recent INSERT on success, 0 if the query
|
||||
* wasn't successful.
|
||||
* @brief csync_statedb_finalize_statements - Clear prepared statements
|
||||
* @param ctx The csync context
|
||||
*/
|
||||
typedef struct csync_progressinfo_s {
|
||||
struct csync_progressinfo_s *next;
|
||||
uint64_t phash;
|
||||
uint64_t modtime;
|
||||
char *md5;
|
||||
int error;
|
||||
int chunk;
|
||||
int transferId;
|
||||
char *tmpfile;
|
||||
char *error_string;
|
||||
} csync_progressinfo_t;
|
||||
void csync_statedb_finalize_statements(CSYNC *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -100,6 +100,10 @@ static bool _csync_sameextension(const char *p1, const char *p2) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool _last_db_return_error(CSYNC* ctx) {
|
||||
return ctx->statedb.lastReturnValue != SQLITE_OK && ctx->statedb.lastReturnValue != SQLITE_DONE && ctx->statedb.lastReturnValue != SQLITE_ROW;
|
||||
}
|
||||
|
||||
static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
const csync_vio_file_stat_t *fs, const int type) {
|
||||
uint64_t h = 0;
|
||||
@@ -146,21 +150,21 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
if (excluded != CSYNC_NOT_EXCLUDED) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "%s excluded (%d)", path, excluded);
|
||||
if (excluded == CSYNC_FILE_EXCLUDE_AND_REMOVE) {
|
||||
switch (ctx->current) {
|
||||
case LOCAL_REPLICA:
|
||||
ctx->local.ignored_cleanup = c_list_append(ctx->local.ignored_cleanup, c_strdup(path));
|
||||
break;
|
||||
case REMOTE_REPLICA:
|
||||
ctx->remote.ignored_cleanup = c_list_append(ctx->remote.ignored_cleanup, c_strdup(path));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
if (excluded == CSYNC_FILE_SILENTLY_EXCLUDED) {
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ctx->current_fs) {
|
||||
ctx->current_fs->has_ignored_files = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->current == REMOTE_REPLICA && ctx->checkSelectiveSyncBlackListHook) {
|
||||
if (ctx->checkSelectiveSyncBlackListHook(ctx->checkSelectiveSyncBlackListData, path)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
h = _hash_of_file(ctx, file );
|
||||
@@ -179,17 +183,26 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
st->instruction = CSYNC_INSTRUCTION_NONE;
|
||||
st->etag = NULL;
|
||||
st->child_modified = 0;
|
||||
st->has_ignored_files = 0;
|
||||
|
||||
/* check hardlink count */
|
||||
if (type == CSYNC_FTW_TYPE_FILE ) {
|
||||
if( fs->nlink > 1) {
|
||||
st->instruction = CSYNC_INSTRUCTION_IGNORE;
|
||||
st->error_status = CSYNC_STATUS_INDIVIDUAL_IS_HARDLINK;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fs->mtime == 0) {
|
||||
tmp = csync_statedb_get_stat_by_hash(ctx, h);
|
||||
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);
|
||||
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;
|
||||
@@ -226,16 +239,24 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
if (csync_get_statedb_exists(ctx)) {
|
||||
tmp = csync_statedb_get_stat_by_hash(ctx, h);
|
||||
|
||||
if(_last_db_return_error(ctx)) {
|
||||
SAFE_FREE(st);
|
||||
ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(tmp && tmp->phash == h ) { /* there is an entry in the database */
|
||||
/* we have an update! */
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Database entry found, compare: %" PRId64 " <-> %" PRId64 ", etag: %s <-> %s, inode: %" PRId64 " <-> %" PRId64,
|
||||
((int64_t) fs->mtime), ((int64_t) tmp->modtime), fs->etag, tmp->etag, (uint64_t) fs->inode, (uint64_t) tmp->inode);
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Database entry found, compare: %" PRId64 " <-> %" PRId64 ", etag: %s <-> %s, inode: %" PRId64 " <-> %" PRId64 ", size: %" PRId64 " <-> %" PRId64,
|
||||
((int64_t) fs->mtime), ((int64_t) tmp->modtime), fs->etag, tmp->etag, (uint64_t) fs->inode, (uint64_t) tmp->inode, (uint64_t) fs->size, (uint64_t) tmp->size);
|
||||
if( !fs->etag) {
|
||||
st->instruction = CSYNC_INSTRUCTION_EVAL;
|
||||
goto out;
|
||||
}
|
||||
if((ctx->current == REMOTE_REPLICA && !c_streq(fs->etag, tmp->etag ))
|
||||
|| (ctx->current == LOCAL_REPLICA && (fs->mtime != tmp->modtime
|
||||
// zero size in statedb can happen during migration
|
||||
|| (tmp->size != 0 && fs->size != tmp->size)
|
||||
#if 0
|
||||
|| fs->inode != tmp->inode
|
||||
#endif
|
||||
@@ -285,6 +306,12 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
|
||||
tmp = csync_statedb_get_stat_by_inode(ctx, fs->inode);
|
||||
|
||||
if(_last_db_return_error(ctx)) {
|
||||
SAFE_FREE(st);
|
||||
ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* translate the file type between the two stat types csync has. */
|
||||
if( tmp && tmp->type == 0 ) {
|
||||
tmp_vio_type = CSYNC_VIO_FILE_TYPE_REGULAR;
|
||||
@@ -315,6 +342,12 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
} else {
|
||||
/* Remote Replica Rename check */
|
||||
tmp = csync_statedb_get_stat_by_file_id(ctx, fs->file_id);
|
||||
|
||||
if(_last_db_return_error(ctx)) {
|
||||
SAFE_FREE(st);
|
||||
ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
|
||||
return -1;
|
||||
}
|
||||
if(tmp ) { /* tmp existing at all */
|
||||
if ((tmp->type == CSYNC_FTW_TYPE_DIR && fs->type != CSYNC_VIO_FILE_TYPE_DIRECTORY) ||
|
||||
(tmp->type == CSYNC_FTW_TYPE_FILE && fs->type != CSYNC_VIO_FILE_TYPE_REGULAR)) {
|
||||
@@ -431,11 +464,19 @@ int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs,
|
||||
|
||||
switch (flag) {
|
||||
case CSYNC_FTW_FLAG_FILE:
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s [file_id=%s]", file, fs->file_id);
|
||||
if (ctx->current == REMOTE_REPLICA) {
|
||||
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);
|
||||
}
|
||||
type = CSYNC_FTW_TYPE_FILE;
|
||||
break;
|
||||
case CSYNC_FTW_FLAG_DIR: /* enter directory */
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "directory: %s [file_id=%s]", file, fs->file_id);
|
||||
if (ctx->current == REMOTE_REPLICA) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "directory: %s [file_id=%s]", file, fs->file_id);
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "directory: %s [inode=%" PRIu64 "]", file, fs->inode);
|
||||
}
|
||||
type = CSYNC_FTW_TYPE_DIR;
|
||||
break;
|
||||
case CSYNC_FTW_FLAG_NSTAT: /* not statable file */
|
||||
@@ -591,10 +632,13 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
|
||||
path = filename + ulen;
|
||||
|
||||
/* skip ".csync_journal.db" and ".csync_journal.db.ctmp" */
|
||||
/* Isn't this done via csync_exclude already? */
|
||||
if (c_streq(path, ".csync_journal.db")
|
||||
|| c_streq(path, ".csync_journal.db.ctmp")
|
||||
|| c_streq(path, ".csync_journal.db.ctmp-journal")
|
||||
|| c_streq(path, ".csync-progressdatabase")) {
|
||||
|| c_streq(path, ".csync-progressdatabase")
|
||||
|| c_streq(path, ".csync_journal.db-shm")
|
||||
|| c_streq(path, ".csync_journal.db-wal")) {
|
||||
csync_vio_file_stat_destroy(dirent);
|
||||
dirent = NULL;
|
||||
SAFE_FREE(filename);
|
||||
@@ -640,6 +684,11 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
|
||||
uint64_t h = c_jhash64((uint8_t *) path, len, 0);
|
||||
etag = csync_statedb_get_etag( ctx, h );
|
||||
|
||||
if(_last_db_return_error(ctx)) {
|
||||
ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if( etag ) {
|
||||
SAFE_FREE(fs->etag);
|
||||
fs->etag = etag;
|
||||
@@ -659,10 +708,6 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
|
||||
rc = fn(ctx, filename, fs, flag);
|
||||
/* this function may update ctx->current and ctx->read_from_db */
|
||||
|
||||
if (ctx->current_fs && previous_fs && ctx->current_fs->child_modified) {
|
||||
previous_fs->child_modified = ctx->current_fs->child_modified;
|
||||
}
|
||||
|
||||
/* Only for the local replica we have to destroy stat(), for the remote one it is a pointer to dirent */
|
||||
if (ctx->replica == LOCAL_REPLICA) {
|
||||
csync_vio_file_stat_destroy(fs);
|
||||
@@ -677,7 +722,7 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (flag == CSYNC_FTW_FLAG_DIR && depth
|
||||
if (flag == CSYNC_FTW_FLAG_DIR && depth && rc == 0
|
||||
&& (!ctx->current_fs || ctx->current_fs->instruction != CSYNC_INSTRUCTION_IGNORE)) {
|
||||
rc = csync_ftw(ctx, filename, fn, depth - 1);
|
||||
if (rc < 0) {
|
||||
@@ -690,6 +735,16 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
|
||||
ctx->current_fs->instruction = CSYNC_INSTRUCTION_NONE;
|
||||
ctx->current_fs->should_update_etag = true;
|
||||
}
|
||||
|
||||
if (ctx->current_fs && previous_fs && ctx->current_fs->has_ignored_files) {
|
||||
/* If a directory has ignored files, put the flag on the parent directory as well */
|
||||
previous_fs->has_ignored_files = ctx->current_fs->has_ignored_files;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->current_fs && previous_fs && ctx->current_fs->child_modified) {
|
||||
/* If a directory has modified files, put the flag on the parent directory as well */
|
||||
previous_fs->child_modified = ctx->current_fs->child_modified;
|
||||
}
|
||||
|
||||
if (flag == CSYNC_FTW_FLAG_DIR && ctx->current_fs
|
||||
|
||||
@@ -237,7 +237,7 @@ int csync_vio_local_stat(const char *uri, csync_vio_file_stat_t *buf) {
|
||||
/* printf("Index: %I64i\n", FileIndex.QuadPart); */
|
||||
buf->inode = FileIndex.QuadPart;
|
||||
|
||||
buf->size = (fileInfo.nFileSizeHigh * (int64_t)(MAXDWORD+1)) + fileInfo.nFileSizeLow;
|
||||
buf->size = (fileInfo.nFileSizeHigh * ((int64_t)(MAXDWORD)+1)) + fileInfo.nFileSizeLow;
|
||||
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_SIZE;
|
||||
|
||||
/* Get the file time with a win32 call rather than through stat. See
|
||||
|
||||
@@ -141,6 +141,38 @@ static void check_csync_excluded(void **state)
|
||||
|
||||
}
|
||||
|
||||
static void check_csync_pathes(void **state)
|
||||
{
|
||||
CSYNC *csync = *state;
|
||||
int rc;
|
||||
|
||||
_csync_exclude_add( &(csync->excludes), "/exclude" );
|
||||
|
||||
/* Check toplevel dir, the pattern only works for toplevel dir. */
|
||||
rc = csync_excluded(csync, "/exclude", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
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(csync, "/exclude", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
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(csync, "/excl", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded(csync, "meep/excl", CSYNC_FTW_TYPE_DIR);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded(csync, "/excl", CSYNC_FTW_TYPE_FILE);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
}
|
||||
|
||||
int torture_run_tests(void)
|
||||
{
|
||||
@@ -148,6 +180,7 @@ int torture_run_tests(void)
|
||||
unit_test_setup_teardown(check_csync_exclude_add, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_exclude_load, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_excluded, setup_init, teardown),
|
||||
unit_test_setup_teardown(check_csync_pathes, setup_init, teardown),
|
||||
};
|
||||
|
||||
return run_tests(tests);
|
||||
|
||||
@@ -55,19 +55,11 @@ static void setup(void **state)
|
||||
|
||||
static void setup_db(void **state)
|
||||
{
|
||||
CSYNC *csync;
|
||||
char *stmt = NULL;
|
||||
char *errmsg;
|
||||
int rc = 0;
|
||||
c_strlist_t *result = NULL;
|
||||
sqlite3 *db = NULL;
|
||||
|
||||
setup(state);
|
||||
csync = *state;
|
||||
|
||||
// rc = csync_statedb_create_tables(csync->statedb.db);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
result = csync_statedb_query(csync->statedb.db,
|
||||
"CREATE TABLE IF NOT EXISTS metadata ("
|
||||
const char *sql = "CREATE TABLE IF NOT EXISTS metadata ("
|
||||
"phash INTEGER(8),"
|
||||
"pathlen INTEGER,"
|
||||
"path VARCHAR(4096),"
|
||||
@@ -79,29 +71,25 @@ static void setup_db(void **state)
|
||||
"type INTEGER,"
|
||||
"md5 VARCHAR(32),"
|
||||
"PRIMARY KEY(phash)"
|
||||
");"
|
||||
);
|
||||
");";
|
||||
|
||||
assert_non_null(result);
|
||||
c_strlist_destroy(result);
|
||||
|
||||
|
||||
stmt = sqlite3_mprintf("INSERT INTO metadata"
|
||||
const char *sql2 = "INSERT INTO metadata"
|
||||
"(phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5) VALUES"
|
||||
"(%lu, %d, '%q', %d, %d, %d, %d, %lu, %d, %lu);",
|
||||
42,
|
||||
42,
|
||||
"It's a rainy day",
|
||||
23,
|
||||
42,
|
||||
42,
|
||||
42,
|
||||
42,
|
||||
2,
|
||||
43);
|
||||
"(42, 42, 'Its funny stuff', 23, 42, 43, 55, 66, 2, 54);";
|
||||
|
||||
|
||||
setup(state);
|
||||
rc = sqlite3_open( TESTDB, &db);
|
||||
assert_int_equal(rc, SQLITE_OK);
|
||||
|
||||
rc = sqlite3_exec( db, sql, NULL, NULL, &errmsg );
|
||||
assert_int_equal(rc, SQLITE_OK);
|
||||
|
||||
rc = sqlite3_exec( db, sql2, NULL, NULL, &errmsg );
|
||||
assert_int_equal(rc, SQLITE_OK);
|
||||
|
||||
sqlite3_close(db);
|
||||
|
||||
// rc = csync_statedb_insert(csync->statedb.db, stmt);
|
||||
sqlite3_free(stmt);
|
||||
}
|
||||
|
||||
static void teardown(void **state) {
|
||||
@@ -139,41 +127,6 @@ static void check_csync_statedb_query_statement(void **state)
|
||||
}
|
||||
}
|
||||
|
||||
static void check_csync_statedb_create_error(void **state)
|
||||
{
|
||||
CSYNC *csync = *state;
|
||||
c_strlist_t *result;
|
||||
|
||||
result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
|
||||
assert_non_null(result);
|
||||
c_strlist_destroy(result);
|
||||
|
||||
result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
|
||||
assert_null(result);
|
||||
|
||||
c_strlist_destroy(result);
|
||||
}
|
||||
|
||||
static void check_csync_statedb_insert_statement(void **state)
|
||||
{
|
||||
CSYNC *csync = *state;
|
||||
c_strlist_t *result;
|
||||
int rc = 0;
|
||||
|
||||
result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
|
||||
assert_non_null(result);
|
||||
c_strlist_destroy(result);
|
||||
|
||||
// rc = csync_statedb_insert(csync->statedb.db, "INSERT;");
|
||||
assert_int_equal(rc, 0);
|
||||
// rc = csync_statedb_insert(csync->statedb.db, "INSERT");
|
||||
assert_int_equal(rc, 0);
|
||||
// rc = csync_statedb_insert(csync->statedb.db, "");
|
||||
assert_int_equal(rc, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void check_csync_statedb_drop_tables(void **state)
|
||||
{
|
||||
// CSYNC *csync = *state;
|
||||
@@ -255,8 +208,6 @@ int torture_run_tests(void)
|
||||
{
|
||||
const UnitTest tests[] = {
|
||||
unit_test_setup_teardown(check_csync_statedb_query_statement, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_statedb_create_error, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_statedb_insert_statement, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_statedb_drop_tables, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_statedb_insert_metadata, setup, teardown),
|
||||
unit_test_setup_teardown(check_csync_statedb_write, setup, teardown),
|
||||
|
||||
@@ -23,11 +23,64 @@
|
||||
|
||||
#define TESTDB "/tmp/check_csync/journal.db"
|
||||
|
||||
static int firstrun = 1;
|
||||
|
||||
static void statedb_create_metadata_table(sqlite3 *db)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if( db ) {
|
||||
const char *sql = "CREATE TABLE IF NOT EXISTS metadata("
|
||||
"phash INTEGER(8),"
|
||||
"pathlen INTEGER,"
|
||||
"path VARCHAR(4096),"
|
||||
"inode INTEGER,"
|
||||
"uid INTEGER,"
|
||||
"gid INTEGER,"
|
||||
"mode INTEGER,"
|
||||
"modtime INTEGER(8),"
|
||||
"type INTEGER,"
|
||||
"md5 VARCHAR(32),"
|
||||
"PRIMARY KEY(phash));";
|
||||
|
||||
rc = sqlite3_exec(db, sql, NULL, NULL, NULL);
|
||||
const char *msg = sqlite3_errmsg(db);
|
||||
assert_int_equal( rc, SQLITE_OK );
|
||||
}
|
||||
}
|
||||
|
||||
static void statedb_insert_metadata(sqlite3 *db)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if( db ) {
|
||||
char *stmt = sqlite3_mprintf("INSERT INTO metadata"
|
||||
"(phash, pathlen, path, inode, uid, gid, mode, modtime,type,md5) VALUES"
|
||||
"(%lld, %d, '%q', %d, %d, %d, %d, %lld, %d, '%q');",
|
||||
(long long signed int)42,
|
||||
42,
|
||||
"I_was_wurst_before_I_became_wurstsalat",
|
||||
619070,
|
||||
42,
|
||||
42,
|
||||
42,
|
||||
(long long signed int)42,
|
||||
0,
|
||||
"4711");
|
||||
|
||||
char *errmsg;
|
||||
rc = sqlite3_exec(db, stmt, NULL, NULL, &errmsg);
|
||||
sqlite3_free(stmt);
|
||||
assert_int_equal( rc, SQLITE_OK );
|
||||
}
|
||||
}
|
||||
|
||||
static void setup(void **state)
|
||||
{
|
||||
CSYNC *csync;
|
||||
int rc;
|
||||
|
||||
unlink(TESTDB);
|
||||
rc = system("mkdir -p /tmp/check_csync");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = system("mkdir -p /tmp/check_csync1");
|
||||
@@ -38,10 +91,21 @@ static void setup(void **state)
|
||||
assert_int_equal(rc, 0);
|
||||
rc = csync_init(csync);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
/* Create a new db with metadata */
|
||||
sqlite3 *db;
|
||||
csync->statedb.file = c_strdup(TESTDB);
|
||||
rc = sqlite3_open(csync->statedb.file, &db);
|
||||
statedb_create_metadata_table(db);
|
||||
if( firstrun ) {
|
||||
statedb_insert_metadata(db);
|
||||
firstrun = 0;
|
||||
}
|
||||
sqlite3_close(db);
|
||||
|
||||
rc = csync_statedb_load(csync, TESTDB, &csync->statedb.db);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
|
||||
*state = csync;
|
||||
}
|
||||
|
||||
@@ -71,6 +135,7 @@ static void teardown(void **state)
|
||||
CSYNC *csync = *state;
|
||||
int rc;
|
||||
|
||||
unlink( csync->statedb.file);
|
||||
rc = csync_destroy(csync);
|
||||
assert_int_equal(rc, 0);
|
||||
|
||||
@@ -249,6 +314,7 @@ static void check_csync_detect_update_db_eval(void **state)
|
||||
csync_vio_file_stat_destroy(fs);
|
||||
}
|
||||
|
||||
|
||||
static void check_csync_detect_update_db_rename(void **state)
|
||||
{
|
||||
CSYNC *csync = *state;
|
||||
@@ -256,27 +322,6 @@ static void check_csync_detect_update_db_rename(void **state)
|
||||
|
||||
csync_vio_file_stat_t *fs;
|
||||
int rc = 0;
|
||||
char *stmt = NULL;
|
||||
|
||||
// rc = csync_statedb_create_tables(csync->statedb.db);
|
||||
|
||||
assert_int_equal(rc, 0);
|
||||
stmt = sqlite3_mprintf("INSERT INTO metadata"
|
||||
"(phash, pathlen, path, inode, uid, gid, mode, modtime,type,md5) VALUES"
|
||||
"(%lld, %d, '%q', %d, %d, %d, %d, %lld, %d, '%q');",
|
||||
(long long signed int)42,
|
||||
42,
|
||||
"I_was_wurst_before_I_became_wurstsalat",
|
||||
619070,
|
||||
42,
|
||||
42,
|
||||
42,
|
||||
(long long signed int)42,
|
||||
0,
|
||||
"4711");
|
||||
|
||||
// rc = csync_statedb_insert(csync->statedb.db, stmt);
|
||||
sqlite3_free(stmt);
|
||||
|
||||
fs = create_fstat("wurst.txt", 0, 1, 42);
|
||||
assert_non_null(fs);
|
||||
|
||||
1
csync/tests/ownCloud/.gitignore
vendored
Normal file
1
csync/tests/ownCloud/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
t1.cfg
|
||||
@@ -1,12 +1,7 @@
|
||||
t1 - an integration test script for csync syncing to ownCloud.
|
||||
|
||||
Note: This test script uses perl HTTP::DAV. This package needs to
|
||||
be in version 0.46 at least. Many distros deliver older versions.
|
||||
A working version is part of the github checkout.
|
||||
|
||||
Note: This test script uses perl HTTP::DAV. This package needs to
|
||||
be in version 0.46 at least. Many distros deliver older versions.
|
||||
Update than.
|
||||
be in version 0.47 at least. Many distros deliver older versions.
|
||||
|
||||
t1 uses a perl WebDAV client lib to sync to an existing instance of
|
||||
ownCloud. For that, various files are copied around, synced and the
|
||||
@@ -20,10 +15,6 @@ First, configure the script. For that, create a file t1.cfg. There
|
||||
is t1.cfg.in as an example. Yeah, this test script is not secure,
|
||||
make sure to run it with a weak account and in a save environment.
|
||||
|
||||
Second, unpack the test file collection with
|
||||
tar xf testfiles.tar.xz
|
||||
in the directory where the tarball can be found.
|
||||
|
||||
To start the script, call ./t1.pl on the commandline. A lot of
|
||||
output is generated. If the script does not fail, everything works.
|
||||
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
*_conflict-*
|
||||
*.part
|
||||
]*.directory
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ use Exporter;
|
||||
use HTTP::DAV 0.47;
|
||||
use Data::Dumper;
|
||||
use File::Glob ':glob';
|
||||
use Carp::Assert;
|
||||
use Digest::MD5;
|
||||
use Unicode::Normalize;
|
||||
use LWP::UserAgent;
|
||||
@@ -36,6 +35,7 @@ use HTTP::Request::Common qw( POST GET DELETE );
|
||||
use File::Basename;
|
||||
use IO::Handle;
|
||||
use POSIX qw/strftime/;
|
||||
use Carp;
|
||||
|
||||
use Encode qw(from_to);
|
||||
use utf8;
|
||||
@@ -63,22 +63,22 @@ our %config;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw( initTesting createRemoteDir removeRemoteDir createLocalDir cleanup csync
|
||||
assertLocalDirs assertLocalAndRemoteDir glob_put put_to_dir
|
||||
assertLocalDirs assertLocalAndRemoteDir glob_put put_to_dir
|
||||
putToDirLWP localDir remoteDir localCleanup createLocalFile md5OfFile
|
||||
remoteCleanup server initLocalDir initRemoteDir moveRemoteFile
|
||||
printInfo remoteFileId createShare removeShare
|
||||
printInfo remoteFileId createShare removeShare assert
|
||||
configValue testDirUrl getToFileLWP getToFileCurl);
|
||||
|
||||
sub server
|
||||
{
|
||||
return $owncloud;
|
||||
}
|
||||
|
||||
|
||||
sub fromFileName($)
|
||||
{
|
||||
my ($file) = @_;
|
||||
if ( $^O eq "darwin" ) {
|
||||
my $fromFileName = NFC( Encode::decode('utf-8', $file) );
|
||||
my $fromFileName = NFC( Encode::decode('utf-8', $file) );
|
||||
return $fromFileName;
|
||||
} else {
|
||||
return $file;
|
||||
@@ -89,7 +89,7 @@ sub fromFileName($)
|
||||
sub initTesting(;$)
|
||||
{
|
||||
my ($prefix) = @_;
|
||||
|
||||
|
||||
my $cfgFile = "./t1.cfg";
|
||||
$cfgFile = "/etc/ownCloud/t1.cfg" if( -r "/etc/ownCloud/t1.cfg" );
|
||||
|
||||
@@ -115,6 +115,8 @@ sub initTesting(;$)
|
||||
|
||||
$owncloud .= "/" unless( $owncloud =~ /\/$/ );
|
||||
|
||||
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
|
||||
|
||||
print "Connecting to ownCloud at ". $owncloud ."\n";
|
||||
|
||||
# For SSL set the environment variable needed by the LWP module for SSL
|
||||
@@ -129,15 +131,15 @@ sub initTesting(;$)
|
||||
-pass=> $passwd );
|
||||
# $d->DebugLevel(3);
|
||||
$prefix = "t1" unless( defined $prefix );
|
||||
|
||||
|
||||
my $dirId = sprintf("%02d", rand(100));
|
||||
my $dateTime = strftime('%Y%m%d%H%M%S',localtime);
|
||||
my $dir = sprintf( "%s-%s-%s/", $prefix, $dateTime, $dirId );
|
||||
|
||||
|
||||
$localDir = $dir;
|
||||
$localDir .= "/" unless( $localDir =~ /\/$/ );
|
||||
$remoteDir = $dir;
|
||||
|
||||
|
||||
initRemoteDir();
|
||||
initLocalDir();
|
||||
printf( "Test directory name is %s\n", $dir );
|
||||
@@ -166,7 +168,9 @@ sub testDirUrl()
|
||||
# the global var $remoteDir;
|
||||
sub initRemoteDir
|
||||
{
|
||||
$d->open( $owncloud );
|
||||
$d->open( $owncloud )
|
||||
or die("Couldn't open $owncloud: " .$d->message . "\n");
|
||||
|
||||
my $url = testDirUrl();
|
||||
|
||||
my $re = $d->mkcol( $url );
|
||||
@@ -204,7 +208,7 @@ sub removeRemoteDir($;$)
|
||||
if( $re == 0 ) {
|
||||
print "Failed to remove directory <$url>:" . $d->message() ."\n";
|
||||
}
|
||||
|
||||
|
||||
return $re;
|
||||
}
|
||||
|
||||
@@ -305,7 +309,7 @@ sub csync( ;$ )
|
||||
|
||||
print "CSync URL: $url\n";
|
||||
|
||||
my $args = "--trust"; # Trust crappy SSL certificates
|
||||
my $args = "--trust --exclude exclude.cfg"; # Trust crappy SSL certificates
|
||||
my $cmd = "LD_LIBRARY_PATH=$ld_libpath $csync $args $localDir $url";
|
||||
print "Starting: $cmd\n";
|
||||
|
||||
@@ -336,7 +340,7 @@ sub localDir()
|
||||
return $localDir;
|
||||
}
|
||||
|
||||
sub remoteDir()
|
||||
sub remoteDir()
|
||||
{
|
||||
return $remoteDir;
|
||||
}
|
||||
@@ -381,7 +385,7 @@ sub traverse( $$;$ )
|
||||
{
|
||||
my ($remote, $acceptConflicts, $aurl) = @_;
|
||||
$remote .= '/' unless $remote =~ /(^|\/)$/;
|
||||
|
||||
|
||||
my $url = testDirUrl() . $remote;
|
||||
if( $aurl ) {
|
||||
$url = $aurl . $remote;
|
||||
@@ -489,13 +493,13 @@ sub glob_put( $$;$ )
|
||||
print " *** Putting $lfile to $puturl\n";
|
||||
# putToDirLWP( $lfile, $puturl );
|
||||
put_to_dir($lfile, $puturl, $optionsRef);
|
||||
|
||||
|
||||
# if( ! $d->put( -local=>$lfile, -url=> $puturl ) ) {
|
||||
#print " ### FAILED to put: ". $d->message . '\n';
|
||||
# s}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +529,7 @@ sub put_to_dir( $$;$ )
|
||||
}
|
||||
}
|
||||
|
||||
# The HTTP DAV module often does a PROPFIND before it really PUTs. That
|
||||
# The HTTP DAV module often does a PROPFIND before it really PUTs. That
|
||||
# is not neccessary if we know that the directory is really there.
|
||||
# Use this function in this case:
|
||||
sub putToDirLWP($$)
|
||||
@@ -545,13 +549,13 @@ sub putToDirLWP($$)
|
||||
my $string = <FILE>;
|
||||
close FILE;
|
||||
|
||||
my $ua = LWP::UserAgent->new();
|
||||
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 });
|
||||
$ua->agent( "ownCloudTest_$localDir");
|
||||
my $req = PUT $puturl, Content_Type => 'application/octet-stream',
|
||||
Content => $string;
|
||||
$req->authorization_basic($user, $passwd);
|
||||
my $response = $ua->request($req);
|
||||
|
||||
|
||||
if ($response->is_success()) {
|
||||
# print "OK: ", $response->content;
|
||||
} else {
|
||||
@@ -579,7 +583,7 @@ sub getToFileLWP( $$ )
|
||||
my $geturl = testDirUrl() . $file;
|
||||
print "GETting $geturl to $localFile\n";
|
||||
|
||||
my $ua = LWP::UserAgent->new();
|
||||
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 });
|
||||
$ua->agent( "ownCloudTest_$localDir");
|
||||
$ua->credentials( server(), "foo", $user, $passwd);
|
||||
my $req = $ua->get($geturl, ":content_file" => $localFile);
|
||||
@@ -594,15 +598,15 @@ sub getToFileLWP( $$ )
|
||||
}
|
||||
}
|
||||
|
||||
sub createLocalFile( $$ )
|
||||
sub createLocalFile( $$ )
|
||||
{
|
||||
my ($fname, $size) = @_;
|
||||
$size = 1024 unless( $size );
|
||||
|
||||
|
||||
my $md5 = Digest::MD5->new;
|
||||
|
||||
open(FILE, ">", $fname) or die "Can't open $fname for writing ($!)";
|
||||
|
||||
|
||||
my $minimum = 32;
|
||||
my $range = 96;
|
||||
|
||||
@@ -620,20 +624,20 @@ sub createLocalFile( $$ )
|
||||
print FILE $s;
|
||||
$md5->add($s);
|
||||
close FILE;
|
||||
return $md5->hexdigest;
|
||||
return $md5->hexdigest;
|
||||
}
|
||||
|
||||
sub md5OfFile( $ )
|
||||
sub md5OfFile( $ )
|
||||
{
|
||||
my ($file) = @_;
|
||||
|
||||
|
||||
open FILE, "$file";
|
||||
|
||||
my $ctx = Digest::MD5->new;
|
||||
$ctx->addfile (*FILE);
|
||||
my $hash = $ctx->hexdigest;
|
||||
close (FILE);
|
||||
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
@@ -647,27 +651,27 @@ sub moveRemoteFile($$;$)
|
||||
|
||||
my $fromUrl = testDirUrl(). $from;
|
||||
my $toUrl = testDirUrl() . $to;
|
||||
|
||||
|
||||
if( $no_testdir ) {
|
||||
$fromUrl = $from;
|
||||
$toUrl = $to;
|
||||
}
|
||||
|
||||
|
||||
$d->move($fromUrl, $toUrl);
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub printInfo($)
|
||||
{
|
||||
my ($info) = @_;
|
||||
my $tt = 6+length( $info );
|
||||
|
||||
|
||||
print "#" x $tt;
|
||||
printf( "\n# %2d. %s", $infoCnt, $info );
|
||||
print "\n" unless $info =~ /\n$/;
|
||||
print "#" x $tt;
|
||||
print "\n";
|
||||
|
||||
|
||||
$infoCnt++;
|
||||
}
|
||||
|
||||
@@ -718,16 +722,15 @@ sub createShare($$)
|
||||
my $re = $dd->mkcol( $url );
|
||||
if( $re == 0 ) {
|
||||
print "Failed to create test dir $url\n";
|
||||
|
||||
}
|
||||
|
||||
my $ua = LWP::UserAgent->new();
|
||||
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 } );
|
||||
$ua->agent( "ownCloudTest_sharing");
|
||||
# http://localhost/ocm/ocs/v1.php/apps/files_sharing/api/v1/shares
|
||||
my $puturl = $ocs_url . "apps/files_sharing/api/v1/shares";
|
||||
my $puturl = $ocs_url . "ocs/v1.php/apps/files_sharing/api/v1/shares";
|
||||
|
||||
my $string = "path=$dir&shareType=0&shareWith=$user&publicUpload=false&permissions=$readWrite";
|
||||
print ">>>>>>>>>> $string\n";
|
||||
print ">>>>>>>>>> $puturl $string\n";
|
||||
|
||||
my $req = POST $puturl, Content => $string;
|
||||
$req->authorization_basic($share_user, $share_passwd);
|
||||
@@ -757,17 +760,16 @@ sub removeShare($$)
|
||||
-pass => $share_passwd );
|
||||
$dd->open( $owncloud);
|
||||
|
||||
my $ua = LWP::UserAgent->new();
|
||||
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
|
||||
$ua->agent( "ownCloudTest_sharing");
|
||||
# http://localhost/ocm/ocs/v1.php/apps/files_sharing/api/v1/shares
|
||||
my $url = $ocs_url . "apps/files_sharing/api/v1/shares/" . $shareId;
|
||||
|
||||
my $url = $ocs_url . "ocs/v1.php/apps/files_sharing/api/v1/shares/" . $shareId;
|
||||
|
||||
my $req = DELETE $url;
|
||||
$req->authorization_basic($share_user, $share_passwd);
|
||||
my $response = $ua->request($req);
|
||||
|
||||
if ($response->is_success()) {
|
||||
# print "OK: ", $response->content;
|
||||
print $response->decoded_content;
|
||||
if( $response->decoded_content =~ /<status_code>(\d+)<\/status_code>/m) {
|
||||
my $code = $1;
|
||||
@@ -783,4 +785,12 @@ sub removeShare($$)
|
||||
my $response = $ua->request($req);
|
||||
}
|
||||
|
||||
sub assert($;$)
|
||||
{
|
||||
unless( $_[0] ) {
|
||||
print Carp::confess(@_);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
user => "joe",
|
||||
passwd => "secret",
|
||||
url => "http://localhost/ocm/remote.php/webdav/",
|
||||
ld_libpath => "/home/joe/owncloud/csync/csync-build/modules",
|
||||
csync => "/home/joe/owncloud/csync/csync-build/client/csync",
|
||||
ld_libpath => "/home/joe/owncloud/mirall-install/lib",
|
||||
csync => "/home/joe/owncloud/mirall-install/bin/owncloudcmd",
|
||||
ocs_url => "http://localhost/owncloud/ocs/v1.php/",
|
||||
share_user => "jenny",
|
||||
share_passwd => "also_secret"
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
use lib ".";
|
||||
|
||||
use Carp::Assert;
|
||||
use File::Copy;
|
||||
use ownCloud::Test;
|
||||
|
||||
@@ -170,6 +169,19 @@ assertLocalAndRemoteDir( '', 0);
|
||||
assert( -e localDir().'remoteToLocal1/rtlX' );
|
||||
assert( -e localDir().'remoteToLocal1/rtlX/rtl11/file.txt' );
|
||||
|
||||
printInfo( "Remove a directory on the server with new files on the client");
|
||||
removeRemoteDir('remoteToLocal1/rtlX');
|
||||
system("echo hello > " . localDir(). "remoteToLocal1/rtlX/rtl11/hello.txt");
|
||||
csync();
|
||||
assertLocalAndRemoteDir( '', 0);
|
||||
# file.txt must be gone because the directory was removed on the server, but hello.txt must be there
|
||||
# as it is a new file
|
||||
assert( ! -e localDir().'remoteToLocal1/rtlX/rtl11/file.txt' );
|
||||
assert( -e localDir().'remoteToLocal1/rtlX/rtl11/hello.txt' );
|
||||
|
||||
|
||||
|
||||
|
||||
# ==================================================================
|
||||
|
||||
cleanup();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
use lib ".";
|
||||
|
||||
use Carp::Assert;
|
||||
|
||||
use File::Copy;
|
||||
use ownCloud::Test;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
use lib ".";
|
||||
|
||||
use Carp::Assert;
|
||||
|
||||
use File::Copy;
|
||||
use ownCloud::Test;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
use lib ".";
|
||||
|
||||
use Carp::Assert;
|
||||
|
||||
use File::Copy;
|
||||
use ownCloud::Test;
|
||||
|
||||
@@ -38,6 +38,10 @@ printInfo( "Copy some files to the remote location" );
|
||||
mkdir( localDir() . 'test_stat' );
|
||||
system( "echo foobar > " . localDir() . 'test_stat/file.txt' );
|
||||
|
||||
mkdir( localDir() . 'test_ignored' );
|
||||
mkdir( localDir() . 'test_ignored/sub' );
|
||||
system( "echo foobarfoo > " . localDir() . 'test_ignored/sub/file.txt' );
|
||||
|
||||
# call csync, sync local t1 to remote t1
|
||||
csync();
|
||||
|
||||
@@ -91,15 +95,25 @@ my $realMD5 = md5OfFile( '/tmp/kernelcrash.txt' );
|
||||
print "MD5 compare $localMD5 <-> $realMD5\n";
|
||||
assert( $localMD5 eq $realMD5 );
|
||||
|
||||
|
||||
printInfo("Added a file that is on the ignore list");
|
||||
# (*.directory is in the ignored list that needs cleanup)
|
||||
# (it is names with _conflict) because i want the conflicft detection of assertLocalAndRemoteDir to work
|
||||
system( "echo dir >> " . localDir() . 'test_stat/file_conflict.directory' );
|
||||
# this one should retain the directory
|
||||
system( "echo foobarfoo > " . localDir() . 'test_ignored/sub/ignored_conflict.part' );
|
||||
csync();
|
||||
# The file_conflict.directory is seen as a conflict
|
||||
assertLocalAndRemoteDir( '', 1 );
|
||||
# TODO: check that the file_conflict.directory is indeed NOT on the server
|
||||
# TODO: check that test_ignored/sub/ignored_conflict.part is NOT on the server
|
||||
assert(-e localDir() . 'test_ignored/sub/ignored_conflict.part');
|
||||
|
||||
printInfo("Remove a directory containing an ignored file that should not be removed\n");
|
||||
remoteCleanup('test_ignored');
|
||||
csync();
|
||||
assert(-e localDir() . 'test_ignored/sub/ignored_conflict.part');
|
||||
#remove the file so next sync allow the directory to be removed
|
||||
system( "rm " . localDir() . 'test_ignored/sub/ignored_conflict.part' );
|
||||
|
||||
printInfo("Remove a directory containing a local file\n");
|
||||
remoteCleanup('test_stat');
|
||||
@@ -150,6 +164,8 @@ printInfo("Now remove the symlink\n");
|
||||
system( "rm -f " . localDir() . 'anotherdir' );
|
||||
csync();
|
||||
assertLocalAndRemoteDir( '', 0 );
|
||||
assert(! -e localDir(). 'anotherdir' );
|
||||
|
||||
|
||||
cleanup();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
use lib ".";
|
||||
|
||||
use Carp::Assert;
|
||||
|
||||
use File::Copy;
|
||||
use ownCloud::Test;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
use lib ".";
|
||||
|
||||
use Carp::Assert;
|
||||
|
||||
use File::Copy;
|
||||
use ownCloud::Test;
|
||||
|
||||
@@ -33,11 +33,13 @@ print "Hello, this is t6, a tester for csync with ownCloud.\n";
|
||||
|
||||
initTesting();
|
||||
|
||||
sub createPostUpdateScript()
|
||||
sub createPostUpdateScript($)
|
||||
{
|
||||
my $srcFile = localDir()."BIG.file";
|
||||
my ($name) = @_;
|
||||
|
||||
my $srcFile = localDir().'BIG1.file';
|
||||
my $cred = configValue("user") . ":" . configValue("passwd");
|
||||
my $cmd = "curl -T $srcFile -u $cred " . testDirUrl();
|
||||
my $cmd = "curl -T $srcFile -u $cred " . testDirUrl().$name;
|
||||
my $script = "/tmp/post_update_script.sh";
|
||||
open SC, ">$script" || die("Can not create script file");
|
||||
print SC "#!/bin/bash\n";
|
||||
@@ -48,11 +50,11 @@ sub createPostUpdateScript()
|
||||
return $script;
|
||||
}
|
||||
|
||||
sub getETagFromJournal($)
|
||||
sub getETagFromJournal($$)
|
||||
{
|
||||
my ($num) = @_;
|
||||
|
||||
my $sql = "sqlite3 " . localDir() . ".csync_journal.db \"SELECT md5 FROM metadata WHERE path='BIG.file';\"";
|
||||
my ($name,$num) = @_;
|
||||
|
||||
my $sql = "sqlite3 " . localDir() . ".csync_journal.db \"SELECT md5 FROM metadata WHERE path='$name';\"";
|
||||
open(my $fh, '-|', $sql) or die $!;
|
||||
my $etag = <$fh>;
|
||||
close $fh;
|
||||
@@ -61,14 +63,14 @@ sub getETagFromJournal($)
|
||||
return $etag;
|
||||
}
|
||||
|
||||
sub chunkFileTest( $$ )
|
||||
sub chunkFileTest( $$ )
|
||||
{
|
||||
my ($name, $size) = @_;
|
||||
|
||||
# Big file chunking
|
||||
createLocalFile( localDir().$name, $size );
|
||||
assert( -e localDir().$name );
|
||||
|
||||
|
||||
my $bigMd5 = md5OfFile( localDir().$name );
|
||||
|
||||
csync();
|
||||
@@ -89,26 +91,39 @@ sub chunkFileTest( $$ )
|
||||
}
|
||||
|
||||
printInfo("Big file that needs chunking with default chunk size");
|
||||
chunkFileTest( "BIG.file", 23251233 );
|
||||
chunkFileTest( "BIG1.file", 23251233 );
|
||||
|
||||
printInfo("Update the existing file and trigger reupload");
|
||||
# change the existing file again -> update
|
||||
chunkFileTest( "BIG.file", 21762122 );
|
||||
chunkFileTest( "BIG2.file", 21762122 );
|
||||
|
||||
printInfo("Cause a precondition failed error");
|
||||
# Now overwrite the existing file to change it
|
||||
createLocalFile( localDir()."BIG.file", 21832199 );
|
||||
createLocalFile( localDir()."BIG3.file", 21832 );
|
||||
sleep(2);
|
||||
csync();
|
||||
createLocalFile( localDir().'BIG3.file', 34323 );
|
||||
sleep(2);
|
||||
# and create a post update script
|
||||
my $script = createPostUpdateScript();
|
||||
my $script = createPostUpdateScript('BIG3.file');
|
||||
$ENV{'OWNCLOUD_POST_UPDATE_SCRIPT'} = $script;
|
||||
|
||||
# Save the etag before the sync
|
||||
my $firstETag = getETagFromJournal('First');
|
||||
csync(); # Sync, which ends in a precondition failed error
|
||||
my $firstETag = getETagFromJournal('BIG3.file', 'First');
|
||||
sleep(2);
|
||||
csync(); # Sync, which ends in a precondition failed error
|
||||
# get the etag again. It has to be unchanged because of the error.
|
||||
my $secondETag = getETagFromJournal('Second');
|
||||
assert( $firstETag eq $secondETag, "Different ETags, no precondition error." );
|
||||
my $secondETag = getETagFromJournal('BIG3.file', 'Second');
|
||||
|
||||
# Now the result is that there is a conflict file because since 1.7
|
||||
# the sync is stopped on preconditoin failed and done again.
|
||||
my $seen = 0;
|
||||
opendir(my $dh, localDir() );
|
||||
while(readdir $dh) {
|
||||
$seen = 1 if ( /BIG3_conflict.*\.file/ );
|
||||
}
|
||||
closedir $dh;
|
||||
assert( $seen == 1, "No conflict file created on precondition failed!" );
|
||||
unlink($script);
|
||||
|
||||
# Set a custom chunk size in environment.
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
use lib ".";
|
||||
|
||||
use Carp::Assert;
|
||||
|
||||
use File::Copy;
|
||||
use ownCloud::Test;
|
||||
|
||||
@@ -176,8 +176,6 @@ system("sqlite3 " . localDir().'.csync_journal.db .dump');
|
||||
#new directory should be uploaded
|
||||
system("mv " . localDir().'readonlyDirectory_PERM_M_/subdir_PERM_CK_ ' . localDir().'normalDirectory_PERM_CKDNV_/subdir_PERM_CKDNV_' );
|
||||
|
||||
# two syncs may be necessary for now: https://github.com/owncloud/mirall/issues/2038
|
||||
csync();
|
||||
csync();
|
||||
system("sqlite3 " . localDir().'.csync_journal.db .dump');
|
||||
assertCsyncJournalOk(localDir());
|
||||
@@ -209,8 +207,6 @@ system("mv " . localDir().'readonlyDirectory_PERM_M_/subdir_PERM_CK_ ' . localDi
|
||||
#2. move a directory from read to read only (move the directory from previous step)
|
||||
system("mv " . localDir().'normalDirectory_PERM_CKDNV_/subdir_PERM_CKDNV_ ' . localDir().'readonlyDirectory_PERM_M_/moved_PERM_CK_' );
|
||||
|
||||
# two syncs may be necessary for now: https://github.com/owncloud/mirall/issues/2038
|
||||
csync();
|
||||
csync();
|
||||
assertCsyncJournalOk(localDir());
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
use lib ".";
|
||||
|
||||
use Carp::Assert;
|
||||
|
||||
use File::Copy;
|
||||
use ownCloud::Test;
|
||||
|
||||
@@ -48,6 +48,7 @@ mkdir($tmpdir);
|
||||
createLocalFile( $tmpdir . "HELLO.dat", 100 );
|
||||
createLocalFile( $tmpdir . "Hello.dat", 150 );
|
||||
createLocalFile( $tmpdir . "Normal.dat", 110 );
|
||||
createLocalFile( $tmpdir . "test.dat", 170 );
|
||||
|
||||
#put them in some directories
|
||||
createRemoteDir( "dir" );
|
||||
@@ -73,14 +74,20 @@ assertLocalAndRemoteDir( '', 0);
|
||||
|
||||
printInfo( "Renaming one file to the same name as another one with different casing" );
|
||||
moveRemoteFile( 'dir/Hello.dat', 'dir/NORMAL.dat');
|
||||
moveRemoteFile( 'dir/test.dat', 'dir/TEST.dat');
|
||||
|
||||
csync();
|
||||
|
||||
#It should not have do the move
|
||||
# Hello -> NORMAL should not have do the move since the case conflict
|
||||
assert( -e localDir() . 'dir/Hello.dat' );
|
||||
assert( !-e localDir() . 'dir/NORMAL.dat' );
|
||||
assert( -e localDir() . 'dir/Normal.dat' );
|
||||
|
||||
#test->TEST should have been worked.
|
||||
assert( -e localDir() . 'dir/TEST.dat' );
|
||||
assert( !-e localDir() . 'dir/test.dat' );
|
||||
|
||||
|
||||
printInfo( "Another directory with the same name but different casing is created" );
|
||||
|
||||
createRemoteDir( "DIR" );
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
The ownCloud Client reads a configuration file. You can locate this configuration files as follows:
|
||||
|
||||
- On Linux distributions:
|
||||
On Linux distributions:
|
||||
``$HOME/.local/share/data/ownCloud/owncloud.cfg``
|
||||
|
||||
- In Microsoft Windows systems:
|
||||
On Microsoft Windows systems:
|
||||
``%LOCALAPPDATA%\ownCloud\owncloud.cfg``
|
||||
|
||||
- In MAC OS X systems:
|
||||
On MAC OS X systems:
|
||||
``$HOME/Library/Application Support/ownCloud``
|
||||
|
||||
|
||||
|
||||
@@ -29,12 +29,24 @@ the server URL.
|
||||
|
||||
OPTIONS
|
||||
=======
|
||||
``--confdir`` `PATH`
|
||||
Specifies the configuration directory where `csync.conf` is located.
|
||||
``--user``, ``-u`` ``[user]``
|
||||
Use ``user`` as the login name.
|
||||
|
||||
``--silent``
|
||||
``--password``, ``-p`` ``[password]``
|
||||
Use ``password`` as the password.
|
||||
|
||||
``-n``
|
||||
Use ``netrc (5)`` for login.
|
||||
|
||||
``--non-interactive``
|
||||
Do not prompt for questions.
|
||||
|
||||
``--silent``, ``--s``
|
||||
Inhibits verbose log output.
|
||||
|
||||
``--trust``
|
||||
Trust any SSL certificate, including invalid ones.
|
||||
|
||||
``--httpproxy http://[user@pass:]<server>:<port>``
|
||||
Uses ``server`` as HTTP proxy.
|
||||
|
||||
@@ -48,6 +60,8 @@ the command line would be::
|
||||
$HOME/media/music \
|
||||
https://server/owncloud/remote.php/webdav/Music
|
||||
|
||||
``owncloudcmd`` will enquire user name and password, unless they have
|
||||
been specified on the command line or ``-n`` (see `netrc(5)`) has been passed.
|
||||
|
||||
Using the legacy scheme, it would be::
|
||||
|
||||
|
||||
@@ -22,13 +22,25 @@ the server URL.
|
||||
|
||||
Other comand line switches supported by owncloudcmd include the following:
|
||||
|
||||
- ``--silent``
|
||||
Supresses verbose log output.
|
||||
``--user``, ``-u`` ``[user]``
|
||||
Use ``user`` as the login name.
|
||||
|
||||
- ``--confdir`` `PATH`
|
||||
Fetches or stores configuration in the specified configuration directory.
|
||||
``--password``, ``-p`` ``[password]``
|
||||
Use ``password`` as the password.
|
||||
|
||||
- ``--httpproxy http://[user@pass:]<server>:<port>``
|
||||
``-n``
|
||||
Use ``netrc (5)`` for login.
|
||||
|
||||
``--non-interactive``
|
||||
Do not prompt for questions.
|
||||
|
||||
``--silent``, ``-s``
|
||||
Inhibits verbose log output.
|
||||
|
||||
``--trust``
|
||||
Trust any SSL certificate, including invalid ones.
|
||||
|
||||
``--httpproxy http://[user@pass:]<server>:<port>``
|
||||
Uses the specified ``server`` as the HTTP proxy.
|
||||
|
||||
Credential Handling
|
||||
@@ -41,18 +53,19 @@ setting with the usual URL pattern. For example::
|
||||
|
||||
https://user:secret@192.168.178.2/remote.php/webdav
|
||||
|
||||
|
||||
Example
|
||||
~~~~~~~
|
||||
|
||||
To synchronize the ownCloud directory ``Music`` to the local directory
|
||||
``media/music`, through a proxy listening on port ``8080``, and on a gateway
|
||||
``media/music``, through a proxy listening on port ``8080``, and on a gateway
|
||||
machine using IP address ``192.168.178.1``, the command line would be::
|
||||
|
||||
$ owncloudcmd --httpproxy http://192.168.178.1:8080 \
|
||||
$HOME/media/music \
|
||||
https://server/owncloud/remote.php/webdav/Music
|
||||
|
||||
``owncloudcmd`` will enquire user name and password, unless they have
|
||||
been specified on the command line or ``-n`` has been passed.
|
||||
|
||||
Using the legacy scheme, the command line would be::
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ Categories=Utility;X-SuSE-SyncUtility;
|
||||
Type=Application
|
||||
Exec=@APPLICATION_EXECUTABLE@
|
||||
Name=@APPLICATION_NAME@ desktop sync client
|
||||
Comment=@APPLICATION_NAME@ desktop synchronization client
|
||||
GenericName=Folder Sync
|
||||
Icon=@APPLICATION_EXECUTABLE@
|
||||
Keywords=@APPLICATION_NAME@;syncing;file;sharing;
|
||||
|
||||
@@ -3,7 +3,7 @@ if(APPLE)
|
||||
add_custom_target( mac_overlayplugin ALL
|
||||
xcodebuild -workspace ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/OwnCloud.xcworkspace
|
||||
-scheme OwnCloudFinder.osax SYMROOT=${CMAKE_CURRENT_BINARY_DIR} archive
|
||||
COMMENT building Mac Overlay iccons)
|
||||
COMMENT building Mac Overlay icons)
|
||||
|
||||
INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/OwnCloudFinder.osax/Contents
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/ScriptingAdditions/OwnCloudFinder.osax/ )
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
{
|
||||
NSMutableDictionary* _fileNamesCache;
|
||||
BOOL _fileIconsEnabled;
|
||||
BOOL _hasChangedContent;
|
||||
|
||||
NSNumber *_icnOk;
|
||||
NSNumber *_icnSync;
|
||||
@@ -38,6 +39,9 @@
|
||||
- (void)setIcons:(NSDictionary*)iconDictionary filterByFolder:(NSString*)filterFolder;
|
||||
- (void)setResultForPath:(NSString*)path result:(NSString*)result;
|
||||
- (void)clearFileNameCacheForPath:(NSString*)path;
|
||||
- (void)reFetchFileNameCacheForPath:(NSString*)path;
|
||||
- (void)repaintAllWindows;
|
||||
|
||||
- (void)loadIconResourcePath:(NSString*)path;
|
||||
|
||||
@end
|
||||
@@ -31,19 +31,7 @@ static ContentManager* sharedInstance = nil;
|
||||
{
|
||||
_fileNamesCache = [[NSMutableDictionary alloc] init];
|
||||
_fileIconsEnabled = TRUE;
|
||||
|
||||
NSString *base = @"/Applications/owncloud.app/Contents/Resources/icons/";
|
||||
|
||||
_icnOk = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"ok.icns"]];
|
||||
_icnSync = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"sync.icns"]];
|
||||
_icnWarn = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"warning.icns"]];
|
||||
_icnErr = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"error.icns"]];
|
||||
_icnOkSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"ok_swm.icns"]];
|
||||
_icnSyncSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"sync_swm.icns"]];
|
||||
_icnWarnSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"warning_swm.icns"]];
|
||||
_icnErrSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"error_swm.icns"]];
|
||||
|
||||
NSLog(@"Icon ok identifier: %d", [_icnOk intValue]);
|
||||
_hasChangedContent = TRUE;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -71,6 +59,22 @@ static ContentManager* sharedInstance = nil;
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (void)loadIconResourcePath:(NSString*)path
|
||||
{
|
||||
NSString *base = path;
|
||||
|
||||
_icnOk = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"ok.icns"]];
|
||||
_icnSync = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"sync.icns"]];
|
||||
_icnWarn = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"warning.icns"]];
|
||||
_icnErr = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"error.icns"]];
|
||||
_icnOkSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"ok_swm.icns"]];
|
||||
_icnSyncSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"sync_swm.icns"]];
|
||||
_icnWarnSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"warning_swm.icns"]];
|
||||
_icnErrSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"error_swm.icns"]];
|
||||
|
||||
NSLog(@"Icon ok identifier: %d from %@", [_icnOk intValue], [base stringByAppendingString:@"ok.icns"]);
|
||||
}
|
||||
|
||||
- (void)enableFileIcons:(BOOL)enable
|
||||
{
|
||||
_fileIconsEnabled = enable;
|
||||
@@ -80,6 +84,10 @@ static ContentManager* sharedInstance = nil;
|
||||
|
||||
- (void)setResultForPath:(NSString*)path result:(NSString*)result
|
||||
{
|
||||
if (_icnOk == nil) {
|
||||
// no icon resource path registered yet
|
||||
return;
|
||||
}
|
||||
|
||||
NSNumber *res;
|
||||
res = [NSNumber numberWithInt:0];
|
||||
@@ -107,14 +115,18 @@ static ContentManager* sharedInstance = nil;
|
||||
}
|
||||
|
||||
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
|
||||
[_fileNamesCache setObject:res forKey:normalizedPath];
|
||||
// NSLog(@"SET value %d", [res intValue]);
|
||||
|
||||
[self repaintAllWindows];
|
||||
|
||||
if (![_fileNamesCache objectForKey:normalizedPath] || ![[_fileNamesCache objectForKey:normalizedPath] isEqualTo:res]) {
|
||||
[_fileNamesCache setObject:res forKey:normalizedPath];
|
||||
//NSLog(@"SET value %d %@", [res intValue], normalizedPath);
|
||||
_hasChangedContent = YES;
|
||||
[self performSelector:@selector(repaintAllWindowsIfNeeded) withObject:0 afterDelay:1.0]; // 1 sec
|
||||
}
|
||||
}
|
||||
|
||||
- (NSNumber*)iconByPath:(NSString*)path isDirectory:(BOOL)isDir
|
||||
{
|
||||
//NSLog(@"%@ %@", NSStringFromSelector(_cmd), path);
|
||||
if (!_fileIconsEnabled)
|
||||
{
|
||||
NSLog(@"Icons are NOT ENABLED!");
|
||||
@@ -126,9 +138,13 @@ static ContentManager* sharedInstance = nil;
|
||||
return res;
|
||||
}
|
||||
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
|
||||
|
||||
if (![[RequestManager sharedInstance] isRegisteredPath:normalizedPath isDirectory:isDir]) {
|
||||
return [NSNumber numberWithInt:0];
|
||||
}
|
||||
|
||||
NSNumber* result = [_fileNamesCache objectForKey:normalizedPath];
|
||||
// NSLog(@"XXXXXXX Asking for icon for path %@ = %d",path, [result intValue]);
|
||||
// NSLog(@"XXXXXXX Asking for icon for path %@ = %d",normalizedPath, [result intValue]);
|
||||
|
||||
if( result == nil ) {
|
||||
// start the async call
|
||||
@@ -151,6 +167,7 @@ static ContentManager* sharedInstance = nil;
|
||||
// it clears the entries from the hash to make it call again home to mirall.
|
||||
- (void)clearFileNameCacheForPath:(NSString*)path
|
||||
{
|
||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||
NSMutableArray *keysToDelete = [NSMutableArray array];
|
||||
|
||||
if( path != nil ) {
|
||||
@@ -168,14 +185,32 @@ static ContentManager* sharedInstance = nil;
|
||||
}
|
||||
|
||||
if( [keysToDelete count] > 0 ) {
|
||||
NSLog( @"Entries to delete: %d", [keysToDelete count]);
|
||||
NSLog( @"Entries to delete: %lu", (unsigned long)[keysToDelete count]);
|
||||
[_fileNamesCache removeObjectsForKeys:keysToDelete];
|
||||
|
||||
[self repaintAllWindows];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reFetchFileNameCacheForPath:(NSString*)path
|
||||
{
|
||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||
|
||||
for (id p in [_fileNamesCache keyEnumerator]) {
|
||||
if ( path && [p hasPrefix:path] ) {
|
||||
[[RequestManager sharedInstance] askForIcon:p isDirectory:false]; // FIXME isDirectory parameter
|
||||
//[_fileNamesCache setObject:askState forKey:p]; We don't do this since we want to keep the old icon meanwhile
|
||||
//NSLog(@"%@ %@", NSStringFromSelector(_cmd), p);
|
||||
}
|
||||
}
|
||||
|
||||
// Ask for directory itself
|
||||
if ([path hasSuffix:@"/"]) {
|
||||
path = [path substringToIndex:path.length - 1];
|
||||
}
|
||||
[[RequestManager sharedInstance] askForIcon:path isDirectory:true];
|
||||
//NSLog(@"%@ %@", NSStringFromSelector(_cmd), path);
|
||||
}
|
||||
|
||||
|
||||
- (void)removeAllIcons
|
||||
{
|
||||
[_fileNamesCache removeAllObjects];
|
||||
@@ -195,8 +230,20 @@ static ContentManager* sharedInstance = nil;
|
||||
[self repaintAllWindows];
|
||||
}
|
||||
|
||||
- (void)repaintAllWindowsIfNeeded
|
||||
{
|
||||
if (!_hasChangedContent) {
|
||||
//NSLog(@"%@ Repaint scheduled but not needed", NSStringFromSelector(_cmd));
|
||||
return;
|
||||
}
|
||||
|
||||
_hasChangedContent = NO;
|
||||
[self repaintAllWindows];
|
||||
}
|
||||
|
||||
- (void)repaintAllWindows
|
||||
{
|
||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||
NSArray* windows = [[NSApplication sharedApplication] windows];
|
||||
|
||||
for (int i = 0; i < [windows count]; i++)
|
||||
@@ -286,7 +333,7 @@ static ContentManager* sharedInstance = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"LiferayNativityFinder: refreshing icon badges failed");
|
||||
NSLog(@"OwnCloudFinder: refreshing icon badges failed");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -297,6 +344,7 @@ static ContentManager* sharedInstance = nil;
|
||||
|
||||
- (void)setIcons:(NSDictionary*)iconDictionary filterByFolder:(NSString*)filterFolder
|
||||
{
|
||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||
for (NSString* path in iconDictionary)
|
||||
{
|
||||
if (filterFolder && ![path hasPrefix:filterFolder])
|
||||
|
||||
24
shell_integration/MacOSX/OwnCloudFinder/FinishedIconCache.h
Normal file
24
shell_integration/MacOSX/OwnCloudFinder/FinishedIconCache.h
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// FinishedIconCache.h
|
||||
// OwnCloudFinder
|
||||
//
|
||||
// Created by Markus Goetz on 01/10/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface FinishedIconCache : NSObject {
|
||||
NSCache *_cache;
|
||||
long long _hits;
|
||||
long long _misses;
|
||||
}
|
||||
|
||||
+ (FinishedIconCache*)sharedInstance;
|
||||
|
||||
- (NSImage*)getIcon:(NSString*)fileName overlayIconIndex:(int)idx width:(float)w height:(float)h;
|
||||
- (void)registerIcon:(NSImage*)icon withFileName:(NSString*)fileName overlayIconIndex:(int)idx width:(float)w height:(float)h;
|
||||
|
||||
|
||||
@end
|
||||
91
shell_integration/MacOSX/OwnCloudFinder/FinishedIconCache.m
Normal file
91
shell_integration/MacOSX/OwnCloudFinder/FinishedIconCache.m
Normal file
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// FinishedIconCache.m
|
||||
// OwnCloudFinder
|
||||
//
|
||||
// Created by Markus Goetz on 01/10/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "FinishedIconCache.h"
|
||||
|
||||
|
||||
@interface FinishedIconCacheItem : NSObject
|
||||
@property (nonatomic, strong) NSImage *icon;
|
||||
@property (nonatomic) NSTimeInterval maxAge;
|
||||
@end
|
||||
|
||||
@implementation FinishedIconCacheItem
|
||||
@synthesize icon;
|
||||
@synthesize maxAge;
|
||||
- (void)dealloc {
|
||||
//NSLog(@"RELEASE %@ %@", self, self.icon);
|
||||
if (self.icon) {
|
||||
[self->icon release];
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation FinishedIconCache
|
||||
|
||||
static FinishedIconCache* sharedInstance = nil;
|
||||
|
||||
- init
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_cache = [[NSCache alloc] init];
|
||||
_cache.totalCostLimit = (2880 * 1800); // mbp15 screen size
|
||||
_hits = 0;
|
||||
_misses = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_cache dealloc];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
+ (FinishedIconCache*)sharedInstance
|
||||
{
|
||||
@synchronized(self)
|
||||
{
|
||||
if (sharedInstance == nil)
|
||||
{
|
||||
sharedInstance = [[self alloc] init];
|
||||
}
|
||||
}
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
|
||||
- (NSImage*)getIcon:(NSString*)fileName overlayIconIndex:(int)idx width:(float)w height:(float)h
|
||||
{
|
||||
NSString *cacheKey = [NSString stringWithFormat:@"%@--%d--%f%f", fileName, idx, w,h];
|
||||
FinishedIconCacheItem *item = [_cache objectForKey:cacheKey];
|
||||
if (item) {
|
||||
if (item.maxAge > [[NSDate date] timeIntervalSinceReferenceDate]) {
|
||||
_hits++;
|
||||
return item.icon;
|
||||
}
|
||||
}
|
||||
_misses++;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- (void)registerIcon:(NSImage*)icon withFileName:(NSString*)fileName overlayIconIndex:(int)idx width:(float)w height:(float)h
|
||||
{
|
||||
NSString *cacheKey = [NSString stringWithFormat:@"%@--%d--%f%f", fileName, idx, w, h];
|
||||
FinishedIconCacheItem *item = [[FinishedIconCacheItem alloc] init];
|
||||
item.icon = icon;
|
||||
// max age between 1 sec and 5 sec
|
||||
item.maxAge = [[NSDate date] timeIntervalSinceReferenceDate] + 1.0 + 4.0*((double)arc4random() / 0x100000000);
|
||||
[_cache setObject:item forKey:cacheKey cost:w*h];
|
||||
[item release];
|
||||
//NSLog(@"CACHE hit/miss ratio: %f", (float)_hits/(float)_misses);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -3,25 +3,77 @@
|
||||
//
|
||||
// This class is in the public domain.
|
||||
// Originally created by Robbie Hanson in Q3 2010.
|
||||
// Updated and maintained by Deusty LLC and the Mac development community.
|
||||
// Updated and maintained by Deusty LLC and the Apple development community.
|
||||
//
|
||||
// http://code.google.com/p/cocoaasyncsocket/
|
||||
// https://github.com/robbiehanson/CocoaAsyncSocket
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Security/Security.h>
|
||||
#import <Security/SecureTransport.h>
|
||||
#import <dispatch/dispatch.h>
|
||||
|
||||
@class GCDAsyncReadPacket;
|
||||
@class GCDAsyncWritePacket;
|
||||
@class GCDAsyncSocketPreBuffer;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
// Compiling for iOS
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 // iOS 5.0 supported
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000 // iOS 5.0 supported and required
|
||||
|
||||
#define IS_SECURE_TRANSPORT_AVAILABLE YES
|
||||
#define SECURE_TRANSPORT_MAYBE_AVAILABLE 1
|
||||
#define SECURE_TRANSPORT_MAYBE_UNAVAILABLE 0
|
||||
|
||||
#else // iOS 5.0 supported but not required
|
||||
|
||||
#ifndef NSFoundationVersionNumber_iPhoneOS_5_0
|
||||
#define NSFoundationVersionNumber_iPhoneOS_5_0 881.00
|
||||
#endif
|
||||
|
||||
#define IS_SECURE_TRANSPORT_AVAILABLE (NSFoundationVersionNumber >= NSFoundationVersionNumber_iPhoneOS_5_0)
|
||||
#define SECURE_TRANSPORT_MAYBE_AVAILABLE 1
|
||||
#define SECURE_TRANSPORT_MAYBE_UNAVAILABLE 1
|
||||
|
||||
#endif
|
||||
|
||||
#else // iOS 5.0 not supported
|
||||
|
||||
#define IS_SECURE_TRANSPORT_AVAILABLE NO
|
||||
#define SECURE_TRANSPORT_MAYBE_AVAILABLE 0
|
||||
#define SECURE_TRANSPORT_MAYBE_UNAVAILABLE 1
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// Compiling for Mac OS X
|
||||
|
||||
#define IS_SECURE_TRANSPORT_AVAILABLE YES
|
||||
#define SECURE_TRANSPORT_MAYBE_AVAILABLE 1
|
||||
#define SECURE_TRANSPORT_MAYBE_UNAVAILABLE 0
|
||||
|
||||
#endif
|
||||
|
||||
extern NSString *const GCDAsyncSocketException;
|
||||
extern NSString *const GCDAsyncSocketErrorDomain;
|
||||
|
||||
#if !TARGET_OS_IPHONE
|
||||
extern NSString *const GCDAsyncSocketQueueName;
|
||||
extern NSString *const GCDAsyncSocketThreadName;
|
||||
|
||||
#if SECURE_TRANSPORT_MAYBE_AVAILABLE
|
||||
extern NSString *const GCDAsyncSocketSSLCipherSuites;
|
||||
#if TARGET_OS_IPHONE
|
||||
extern NSString *const GCDAsyncSocketSSLProtocolVersionMin;
|
||||
extern NSString *const GCDAsyncSocketSSLProtocolVersionMax;
|
||||
#else
|
||||
extern NSString *const GCDAsyncSocketSSLDiffieHellmanParameters;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum GCDAsyncSocketError
|
||||
{
|
||||
@@ -42,51 +94,6 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@interface GCDAsyncSocket : NSObject
|
||||
{
|
||||
uint32_t flags;
|
||||
uint16_t config;
|
||||
|
||||
id delegate;
|
||||
dispatch_queue_t delegateQueue;
|
||||
|
||||
int socket4FD;
|
||||
int socket6FD;
|
||||
int connectIndex;
|
||||
NSData * connectInterface4;
|
||||
NSData * connectInterface6;
|
||||
|
||||
dispatch_queue_t socketQueue;
|
||||
|
||||
dispatch_source_t accept4Source;
|
||||
dispatch_source_t accept6Source;
|
||||
dispatch_source_t connectTimer;
|
||||
dispatch_source_t readSource;
|
||||
dispatch_source_t writeSource;
|
||||
dispatch_source_t readTimer;
|
||||
dispatch_source_t writeTimer;
|
||||
|
||||
NSMutableArray *readQueue;
|
||||
NSMutableArray *writeQueue;
|
||||
|
||||
GCDAsyncReadPacket *currentRead;
|
||||
GCDAsyncWritePacket *currentWrite;
|
||||
|
||||
unsigned long socketFDBytesAvailable;
|
||||
|
||||
NSMutableData *partialReadBuffer;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
CFStreamClientContext streamContext;
|
||||
CFReadStreamRef readStream;
|
||||
CFWriteStreamRef writeStream;
|
||||
#else
|
||||
SSLContextRef sslContext;
|
||||
NSMutableData *sslReadBuffer;
|
||||
size_t sslWriteCachedLength;
|
||||
#endif
|
||||
|
||||
id userData;
|
||||
}
|
||||
|
||||
/**
|
||||
* GCDAsyncSocket uses the standard delegate paradigm,
|
||||
@@ -99,6 +106,8 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
* The socket queue is optional.
|
||||
* If you pass NULL, GCDAsyncSocket will automatically create it's own socket queue.
|
||||
* If you choose to provide a socket queue, the socket queue must not be a concurrent queue.
|
||||
* If you choose to provide a socket queue, and the socket queue has a configured target queue,
|
||||
* then please see the discussion for the method markSocketQueueTargetQueue.
|
||||
*
|
||||
* The delegate queue and socket queue can optionally be the same.
|
||||
**/
|
||||
@@ -121,39 +130,6 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
- (void)setDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
|
||||
- (void)synchronouslySetDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
|
||||
|
||||
/**
|
||||
* Traditionally sockets are not closed until the conversation is over.
|
||||
* However, it is technically possible for the remote enpoint to close its write stream.
|
||||
* Our socket would then be notified that there is no more data to be read,
|
||||
* but our socket would still be writeable and the remote endpoint could continue to receive our data.
|
||||
*
|
||||
* The argument for this confusing functionality stems from the idea that a client could shut down its
|
||||
* write stream after sending a request to the server, thus notifying the server there are to be no further requests.
|
||||
* In practice, however, this technique did little to help server developers.
|
||||
*
|
||||
* To make matters worse, from a TCP perspective there is no way to tell the difference from a read stream close
|
||||
* and a full socket close. They both result in the TCP stack receiving a FIN packet. The only way to tell
|
||||
* is by continuing to write to the socket. If it was only a read stream close, then writes will continue to work.
|
||||
* Otherwise an error will be occur shortly (when the remote end sends us a RST packet).
|
||||
*
|
||||
* In addition to the technical challenges and confusion, many high level socket/stream API's provide
|
||||
* no support for dealing with the problem. If the read stream is closed, the API immediately declares the
|
||||
* socket to be closed, and shuts down the write stream as well. In fact, this is what Apple's CFStream API does.
|
||||
* It might sound like poor design at first, but in fact it simplifies development.
|
||||
*
|
||||
* The vast majority of the time if the read stream is closed it's because the remote endpoint closed its socket.
|
||||
* Thus it actually makes sense to close the socket at this point.
|
||||
* And in fact this is what most networking developers want and expect to happen.
|
||||
* However, if you are writing a server that interacts with a plethora of clients,
|
||||
* you might encounter a client that uses the discouraged technique of shutting down its write stream.
|
||||
* If this is the case, you can set this property to NO,
|
||||
* and make use of the socketDidCloseReadStream delegate method.
|
||||
*
|
||||
* The default value is YES.
|
||||
**/
|
||||
- (BOOL)autoDisconnectOnClosedReadStream;
|
||||
- (void)setAutoDisconnectOnClosedReadStream:(BOOL)flag;
|
||||
|
||||
/**
|
||||
* By default, both IPv4 and IPv6 are enabled.
|
||||
*
|
||||
@@ -211,6 +187,15 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
**/
|
||||
- (BOOL)acceptOnInterface:(NSString *)interface port:(uint16_t)port error:(NSError **)errPtr;
|
||||
|
||||
/**
|
||||
* Tells the socket to begin listening and accepting connections on the unix domain at the given url.
|
||||
* When a connection is accepted, a new instance of GCDAsyncSocket will be spawned to handle it,
|
||||
* and the socket:didAcceptNewSocket: delegate method will be invoked.
|
||||
*
|
||||
* The socket will listen on all available interfaces (e.g. wifi, ethernet, etc)
|
||||
**/
|
||||
- (BOOL)acceptOnUrl:(NSURL *)url error:(NSError **)errPtr;
|
||||
|
||||
#pragma mark Connecting
|
||||
|
||||
/**
|
||||
@@ -326,6 +311,10 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
viaInterface:(NSString *)interface
|
||||
withTimeout:(NSTimeInterval)timeout
|
||||
error:(NSError **)errPtr;
|
||||
/**
|
||||
* Connects to the unix domain socket at the given url, using the specified timeout.
|
||||
*/
|
||||
- (BOOL)connectToUrl:(NSURL *)url withTimeout:(NSTimeInterval)timeout error:(NSError **)errPtr;
|
||||
|
||||
#pragma mark Disconnecting
|
||||
|
||||
@@ -389,6 +378,7 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
**/
|
||||
- (NSString *)connectedHost;
|
||||
- (uint16_t)connectedPort;
|
||||
- (NSURL *)connectedUrl;
|
||||
|
||||
- (NSString *)localHost;
|
||||
- (uint16_t)localPort;
|
||||
@@ -646,6 +636,12 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
maxLength:(NSUInteger)length
|
||||
tag:(long)tag;
|
||||
|
||||
/**
|
||||
* Returns progress of the current read, from 0.0 to 1.0, or NaN if no current read (use isnan() to check).
|
||||
* The parameters "tag", "done" and "total" will be filled in if they aren't NULL.
|
||||
**/
|
||||
- (float)progressOfReadReturningTag:(long *)tagPtr bytesDone:(NSUInteger *)donePtr total:(NSUInteger *)totalPtr;
|
||||
|
||||
#pragma mark Writing
|
||||
|
||||
/**
|
||||
@@ -667,6 +663,12 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
**/
|
||||
- (void)writeData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag;
|
||||
|
||||
/**
|
||||
* Returns progress of the current write, from 0.0 to 1.0, or NaN if no current write (use isnan() to check).
|
||||
* The parameters "tag", "done" and "total" will be filled in if they aren't NULL.
|
||||
**/
|
||||
- (float)progressOfWriteReturningTag:(long *)tagPtr bytesDone:(NSUInteger *)donePtr total:(NSUInteger *)totalPtr;
|
||||
|
||||
#pragma mark Security
|
||||
|
||||
/**
|
||||
@@ -678,7 +680,8 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
* Any reads or writes scheduled after this method is called will occur over the secured connection.
|
||||
*
|
||||
* The possible keys and values for the TLS settings are well documented.
|
||||
* Some possible keys are:
|
||||
* Standard keys are:
|
||||
*
|
||||
* - kCFStreamSSLLevel
|
||||
* - kCFStreamSSLAllowsExpiredCertificates
|
||||
* - kCFStreamSSLAllowsExpiredRoots
|
||||
@@ -688,6 +691,18 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
* - kCFStreamSSLCertificates
|
||||
* - kCFStreamSSLIsServer
|
||||
*
|
||||
* If SecureTransport is available on iOS:
|
||||
*
|
||||
* - GCDAsyncSocketSSLCipherSuites
|
||||
* - GCDAsyncSocketSSLProtocolVersionMin
|
||||
* - GCDAsyncSocketSSLProtocolVersionMax
|
||||
*
|
||||
* If SecureTransport is available on Mac OS X:
|
||||
*
|
||||
* - GCDAsyncSocketSSLCipherSuites
|
||||
* - GCDAsyncSocketSSLDiffieHellmanParameters;
|
||||
*
|
||||
*
|
||||
* Please refer to Apple's documentation for associated values, as well as other possible keys.
|
||||
*
|
||||
* If you pass in nil or an empty dictionary, the default settings will be used.
|
||||
@@ -712,6 +727,114 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
|
||||
#pragma mark Advanced
|
||||
|
||||
/**
|
||||
* Traditionally sockets are not closed until the conversation is over.
|
||||
* However, it is technically possible for the remote enpoint to close its write stream.
|
||||
* Our socket would then be notified that there is no more data to be read,
|
||||
* but our socket would still be writeable and the remote endpoint could continue to receive our data.
|
||||
*
|
||||
* The argument for this confusing functionality stems from the idea that a client could shut down its
|
||||
* write stream after sending a request to the server, thus notifying the server there are to be no further requests.
|
||||
* In practice, however, this technique did little to help server developers.
|
||||
*
|
||||
* To make matters worse, from a TCP perspective there is no way to tell the difference from a read stream close
|
||||
* and a full socket close. They both result in the TCP stack receiving a FIN packet. The only way to tell
|
||||
* is by continuing to write to the socket. If it was only a read stream close, then writes will continue to work.
|
||||
* Otherwise an error will be occur shortly (when the remote end sends us a RST packet).
|
||||
*
|
||||
* In addition to the technical challenges and confusion, many high level socket/stream API's provide
|
||||
* no support for dealing with the problem. If the read stream is closed, the API immediately declares the
|
||||
* socket to be closed, and shuts down the write stream as well. In fact, this is what Apple's CFStream API does.
|
||||
* It might sound like poor design at first, but in fact it simplifies development.
|
||||
*
|
||||
* The vast majority of the time if the read stream is closed it's because the remote endpoint closed its socket.
|
||||
* Thus it actually makes sense to close the socket at this point.
|
||||
* And in fact this is what most networking developers want and expect to happen.
|
||||
* However, if you are writing a server that interacts with a plethora of clients,
|
||||
* you might encounter a client that uses the discouraged technique of shutting down its write stream.
|
||||
* If this is the case, you can set this property to NO,
|
||||
* and make use of the socketDidCloseReadStream delegate method.
|
||||
*
|
||||
* The default value is YES.
|
||||
**/
|
||||
- (BOOL)autoDisconnectOnClosedReadStream;
|
||||
- (void)setAutoDisconnectOnClosedReadStream:(BOOL)flag;
|
||||
|
||||
/**
|
||||
* GCDAsyncSocket maintains thread safety by using an internal serial dispatch_queue.
|
||||
* In most cases, the instance creates this queue itself.
|
||||
* However, to allow for maximum flexibility, the internal queue may be passed in the init method.
|
||||
* This allows for some advanced options such as controlling socket priority via target queues.
|
||||
* However, when one begins to use target queues like this, they open the door to some specific deadlock issues.
|
||||
*
|
||||
* For example, imagine there are 2 queues:
|
||||
* dispatch_queue_t socketQueue;
|
||||
* dispatch_queue_t socketTargetQueue;
|
||||
*
|
||||
* If you do this (pseudo-code):
|
||||
* socketQueue.targetQueue = socketTargetQueue;
|
||||
*
|
||||
* Then all socketQueue operations will actually get run on the given socketTargetQueue.
|
||||
* This is fine and works great in most situations.
|
||||
* But if you run code directly from within the socketTargetQueue that accesses the socket,
|
||||
* you could potentially get deadlock. Imagine the following code:
|
||||
*
|
||||
* - (BOOL)socketHasSomething
|
||||
* {
|
||||
* __block BOOL result = NO;
|
||||
* dispatch_block_t block = ^{
|
||||
* result = [self someInternalMethodToBeRunOnlyOnSocketQueue];
|
||||
* }
|
||||
* if (is_executing_on_queue(socketQueue))
|
||||
* block();
|
||||
* else
|
||||
* dispatch_sync(socketQueue, block);
|
||||
*
|
||||
* return result;
|
||||
* }
|
||||
*
|
||||
* What happens if you call this method from the socketTargetQueue? The result is deadlock.
|
||||
* This is because the GCD API offers no mechanism to discover a queue's targetQueue.
|
||||
* Thus we have no idea if our socketQueue is configured with a targetQueue.
|
||||
* If we had this information, we could easily avoid deadlock.
|
||||
* But, since these API's are missing or unfeasible, you'll have to explicitly set it.
|
||||
*
|
||||
* IF you pass a socketQueue via the init method,
|
||||
* AND you've configured the passed socketQueue with a targetQueue,
|
||||
* THEN you should pass the end queue in the target hierarchy.
|
||||
*
|
||||
* For example, consider the following queue hierarchy:
|
||||
* socketQueue -> ipQueue -> moduleQueue
|
||||
*
|
||||
* This example demonstrates priority shaping within some server.
|
||||
* All incoming client connections from the same IP address are executed on the same target queue.
|
||||
* And all connections for a particular module are executed on the same target queue.
|
||||
* Thus, the priority of all networking for the entire module can be changed on the fly.
|
||||
* Additionally, networking traffic from a single IP cannot monopolize the module.
|
||||
*
|
||||
* Here's how you would accomplish something like that:
|
||||
* - (dispatch_queue_t)newSocketQueueForConnectionFromAddress:(NSData *)address onSocket:(GCDAsyncSocket *)sock
|
||||
* {
|
||||
* dispatch_queue_t socketQueue = dispatch_queue_create("", NULL);
|
||||
* dispatch_queue_t ipQueue = [self ipQueueForAddress:address];
|
||||
*
|
||||
* dispatch_set_target_queue(socketQueue, ipQueue);
|
||||
* dispatch_set_target_queue(iqQueue, moduleQueue);
|
||||
*
|
||||
* return socketQueue;
|
||||
* }
|
||||
* - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket
|
||||
* {
|
||||
* [clientConnections addObject:newSocket];
|
||||
* [newSocket markSocketQueueTargetQueue:moduleQueue];
|
||||
* }
|
||||
*
|
||||
* Note: This workaround is ONLY needed if you intend to execute code directly on the ipQueue or moduleQueue.
|
||||
* This is often NOT the case, as such queues are used solely for execution shaping.
|
||||
**/
|
||||
- (void)markSocketQueueTargetQueue:(dispatch_queue_t)socketQueuesPreConfiguredTargetQueue;
|
||||
- (void)unmarkSocketQueueTargetQueue:(dispatch_queue_t)socketQueuesPreviouslyConfiguredTargetQueue;
|
||||
|
||||
/**
|
||||
* It's not thread-safe to access certain variables from outside the socket's internal queue.
|
||||
*
|
||||
@@ -805,7 +928,9 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
**/
|
||||
- (BOOL)enableBackgroundingOnSocket;
|
||||
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if SECURE_TRANSPORT_MAYBE_AVAILABLE
|
||||
|
||||
/**
|
||||
* This method is only available from within the context of a performBlock: invocation.
|
||||
@@ -881,6 +1006,12 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
||||
**/
|
||||
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port;
|
||||
|
||||
/**
|
||||
* Called when a socket connects and is ready for reading and writing.
|
||||
* The host parameter will be an IP address, not a DNS name.
|
||||
**/
|
||||
- (void)socket:(GCDAsyncSocket *)sock didConnectToUrl:(NSURL *)url;
|
||||
|
||||
/**
|
||||
* Called when a socket has completed reading the requested data into memory.
|
||||
* Not called if there is an error.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -71,6 +71,7 @@ static IconCache* sharedInstance = nil;
|
||||
|
||||
if (image == nil)
|
||||
{
|
||||
NSLog(@"%@ Could not load %@", NSStringFromSelector(_cmd), path);
|
||||
return [NSNumber numberWithInt:-1];
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#import <objc/runtime.h>
|
||||
#import "ContentManager.h"
|
||||
#import "IconCache.h"
|
||||
#import "FinishedIconCache.h"
|
||||
#import "IconOverlayHandlers.h"
|
||||
#import "Finder/Finder.h"
|
||||
|
||||
@@ -34,7 +35,7 @@
|
||||
|
||||
NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path] isDirectory:isDir];
|
||||
|
||||
NSLog(@"1 The icon index is %d", [imageIndex intValue]);
|
||||
//NSLog(@"1 The icon index is %d", [imageIndex intValue]);
|
||||
if ([imageIndex intValue] > 0)
|
||||
{
|
||||
NSImage* image = [[IconCache sharedInstance] getIcon:imageIndex];
|
||||
@@ -69,7 +70,6 @@
|
||||
|
||||
NSURL* url = [node previewItemURL];
|
||||
|
||||
NSError *error;
|
||||
BOOL isDir;
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:[url path] isDirectory:&isDir] == NO) {
|
||||
NSLog(@"ERROR: Could not determine file type of %@", [url path]);
|
||||
@@ -77,21 +77,32 @@
|
||||
}
|
||||
|
||||
NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path] isDirectory:isDir];
|
||||
// NSLog(@"2 The icon index is %d", [imageIndex intValue]);
|
||||
//NSLog(@"2 The icon index is %d %@ %@", [imageIndex intValue], [url path], isDir ? @"isDir" : @"");
|
||||
|
||||
if ([imageIndex intValue] > 0)
|
||||
{
|
||||
NSImage* icon = [arg1 _nsImage];
|
||||
|
||||
[icon lockFocus];
|
||||
|
||||
CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
|
||||
// Use the short term icon cache that possibly has the finished icon
|
||||
FinishedIconCache *finishedIconCache = [FinishedIconCache sharedInstance];
|
||||
NSImage *finishedImage = [finishedIconCache getIcon:[url path] overlayIconIndex:imageIndex width:[icon size].width height:[icon size].height];
|
||||
if (finishedImage) {
|
||||
//NSLog(@"X Got finished image from cache %@ %@", finishedImage, [url path]);
|
||||
return [[[IKImageWrapper alloc] initWithNSImage:finishedImage] autorelease];;
|
||||
} else {
|
||||
//NSLog(@"X Need to redraw %@", [url path]);
|
||||
}
|
||||
|
||||
NSImage* iconimage = [[IconCache sharedInstance] getIcon:[NSNumber numberWithInt:[imageIndex intValue]]];
|
||||
|
||||
if (iconimage != nil)
|
||||
{
|
||||
[icon lockFocus];
|
||||
|
||||
CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
CGRect destRect = CGRectMake(0, 0, [icon size].width, [icon size].height);
|
||||
|
||||
CGImageRef cgImage = [iconimage CGImageForProposedRect:&destRect
|
||||
context:[NSGraphicsContext currentContext]
|
||||
hints:nil];
|
||||
@@ -103,9 +114,11 @@
|
||||
NSLog(@"No image given!!!!!11 %@", [url path]);
|
||||
}
|
||||
|
||||
[icon unlockFocus];
|
||||
}
|
||||
|
||||
[icon unlockFocus];
|
||||
// Insert into cache
|
||||
[finishedIconCache registerIcon:icon withFileName:[url path] overlayIconIndex:imageIndex width:[icon size].width height:[icon size].height];
|
||||
|
||||
return [[[IKImageWrapper alloc] initWithNSImage:icon] autorelease];
|
||||
}
|
||||
@@ -145,7 +158,7 @@
|
||||
}
|
||||
|
||||
NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path] isDirectory:isDir];
|
||||
NSLog(@"3 The icon index is %d", [imageIndex intValue]);
|
||||
//NSLog(@"3 The icon index is %d", [imageIndex intValue]);
|
||||
|
||||
if ([imageIndex intValue] > 0)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>NVTY</string>
|
||||
<string>OWNC</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>CFPlugInDynamicRegisterFunction</key>
|
||||
|
||||
@@ -1,251 +0,0 @@
|
||||
//
|
||||
// JSONKit.h
|
||||
// http://github.com/johnezang/JSONKit
|
||||
// Dual licensed under either the terms of the BSD License, or alternatively
|
||||
// under the terms of the Apache License, Version 2.0, as specified below.
|
||||
//
|
||||
|
||||
/*
|
||||
Copyright (c) 2011, John Engelhart
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the Zang Industries nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 John Engelhart
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <TargetConditionals.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSObjCRuntime.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#endif // __OBJC__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// For Mac OS X < 10.5.
|
||||
#ifndef NSINTEGER_DEFINED
|
||||
#define NSINTEGER_DEFINED
|
||||
#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
typedef long NSInteger;
|
||||
typedef unsigned long NSUInteger;
|
||||
#define NSIntegerMin LONG_MIN
|
||||
#define NSIntegerMax LONG_MAX
|
||||
#define NSUIntegerMax ULONG_MAX
|
||||
#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
typedef int NSInteger;
|
||||
typedef unsigned int NSUInteger;
|
||||
#define NSIntegerMin INT_MIN
|
||||
#define NSIntegerMax INT_MAX
|
||||
#define NSUIntegerMax UINT_MAX
|
||||
#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
#endif // NSINTEGER_DEFINED
|
||||
|
||||
|
||||
#ifndef _JSONKIT_H_
|
||||
#define _JSONKIT_H_
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
|
||||
#define JK_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
|
||||
#else
|
||||
#define JK_DEPRECATED_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
#define JSONKIT_VERSION_MAJOR 1
|
||||
#define JSONKIT_VERSION_MINOR 4
|
||||
|
||||
typedef NSUInteger JKFlags;
|
||||
|
||||
/*
|
||||
JKParseOptionComments : Allow C style // and /_* ... *_/ (without a _, obviously) comments in JSON.
|
||||
JKParseOptionUnicodeNewlines : Allow Unicode recommended (?:\r\n|[\n\v\f\r\x85\p{Zl}\p{Zp}]) newlines.
|
||||
JKParseOptionLooseUnicode : Normally the decoder will stop with an error at any malformed Unicode.
|
||||
This option allows JSON with malformed Unicode to be parsed without reporting an error.
|
||||
Any malformed Unicode is replaced with \uFFFD, or "REPLACEMENT CHARACTER".
|
||||
*/
|
||||
|
||||
enum {
|
||||
JKParseOptionNone = 0,
|
||||
JKParseOptionStrict = 0,
|
||||
JKParseOptionComments = (1 << 0),
|
||||
JKParseOptionUnicodeNewlines = (1 << 1),
|
||||
JKParseOptionLooseUnicode = (1 << 2),
|
||||
JKParseOptionPermitTextAfterValidJSON = (1 << 3),
|
||||
JKParseOptionValidFlags = (JKParseOptionComments | JKParseOptionUnicodeNewlines | JKParseOptionLooseUnicode | JKParseOptionPermitTextAfterValidJSON),
|
||||
};
|
||||
typedef JKFlags JKParseOptionFlags;
|
||||
|
||||
enum {
|
||||
JKSerializeOptionNone = 0,
|
||||
JKSerializeOptionPretty = (1 << 0),
|
||||
JKSerializeOptionEscapeUnicode = (1 << 1),
|
||||
JKSerializeOptionEscapeForwardSlashes = (1 << 4),
|
||||
JKSerializeOptionValidFlags = (JKSerializeOptionPretty | JKSerializeOptionEscapeUnicode | JKSerializeOptionEscapeForwardSlashes),
|
||||
};
|
||||
typedef JKFlags JKSerializeOptionFlags;
|
||||
|
||||
#ifdef __OBJC__
|
||||
|
||||
typedef struct JKParseState JKParseState; // Opaque internal, private type.
|
||||
|
||||
// As a general rule of thumb, if you use a method that doesn't accept a JKParseOptionFlags argument, it defaults to JKParseOptionStrict
|
||||
|
||||
@interface JSONDecoder : NSObject {
|
||||
JKParseState *parseState;
|
||||
}
|
||||
+ (id)decoder;
|
||||
+ (id)decoderWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)initWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (void)clearCache;
|
||||
|
||||
// The parse... methods were deprecated in v1.4 in favor of the v1.4 objectWith... methods.
|
||||
- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length: instead.
|
||||
- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length:error: instead.
|
||||
// The NSData MUST be UTF8 encoded JSON.
|
||||
- (id)parseJSONData:(NSData *)jsonData JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData: instead.
|
||||
- (id)parseJSONData:(NSData *)jsonData error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData:error: instead.
|
||||
|
||||
// Methods that return immutable collection objects.
|
||||
- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
|
||||
- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
|
||||
// The NSData MUST be UTF8 encoded JSON.
|
||||
- (id)objectWithData:(NSData *)jsonData;
|
||||
- (id)objectWithData:(NSData *)jsonData error:(NSError **)error;
|
||||
|
||||
// Methods that return mutable collection objects.
|
||||
- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
|
||||
- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
|
||||
// The NSData MUST be UTF8 encoded JSON.
|
||||
- (id)mutableObjectWithData:(NSData *)jsonData;
|
||||
- (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
////////////
|
||||
#pragma mark Deserializing methods
|
||||
////////////
|
||||
|
||||
@interface NSString (JSONKitDeserializing)
|
||||
- (id)objectFromJSONString;
|
||||
- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
|
||||
- (id)mutableObjectFromJSONString;
|
||||
- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
|
||||
@end
|
||||
|
||||
@interface NSData (JSONKitDeserializing)
|
||||
// The NSData MUST be UTF8 encoded JSON.
|
||||
- (id)objectFromJSONData;
|
||||
- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
|
||||
- (id)mutableObjectFromJSONData;
|
||||
- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
|
||||
@end
|
||||
|
||||
////////////
|
||||
#pragma mark Serializing methods
|
||||
////////////
|
||||
|
||||
@interface NSString (JSONKitSerializing)
|
||||
// Convenience methods for those that need to serialize the receiving NSString (i.e., instead of having to serialize a NSArray with a single NSString, you can "serialize to JSON" just the NSString).
|
||||
// Normally, a string that is serialized to JSON has quotation marks surrounding it, which you may or may not want when serializing a single string, and can be controlled with includeQuotes:
|
||||
// includeQuotes:YES `a "test"...` -> `"a \"test\"..."`
|
||||
// includeQuotes:NO `a "test"...` -> `a \"test\"...`
|
||||
- (NSData *)JSONData; // Invokes JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
|
||||
- (NSString *)JSONString; // Invokes JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
|
||||
@end
|
||||
|
||||
@interface NSArray (JSONKitSerializing)
|
||||
- (NSData *)JSONData;
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
|
||||
- (NSString *)JSONString;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
|
||||
@end
|
||||
|
||||
@interface NSDictionary (JSONKitSerializing)
|
||||
- (NSData *)JSONData;
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
|
||||
- (NSString *)JSONString;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
|
||||
@end
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
|
||||
@interface NSArray (JSONKitSerializingBlockAdditions)
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
|
||||
@end
|
||||
|
||||
@interface NSDictionary (JSONKitSerializingBlockAdditions)
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __OBJC__
|
||||
|
||||
#endif // _JSONKIT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,9 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0B13ECAE173C687400548DA1 /* GCDAsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B13ECAD173C686A00548DA1 /* GCDAsyncSocket.m */; };
|
||||
0B13ECAE173C687400548DA1 /* GCDAsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B13ECAD173C686A00548DA1 /* GCDAsyncSocket.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
|
||||
0B13ECAF173C687900548DA1 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0BFC9ACB173C57E400CDD329 /* Security.framework */; };
|
||||
0BFAF21C16F8E6C10017EA7E /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BFAF21B16F8E6C10017EA7E /* JSONKit.m */; };
|
||||
5BB74A8719DBF9BB001BAAAC /* FinishedIconCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 5BB74A8619DBF9BB001BAAAC /* FinishedIconCache.m */; };
|
||||
692C18A516660C4700BF6A53 /* ContextMenuHandlers.m in Sources */ = {isa = PBXBuildFile; fileRef = 692C18A416660C4600BF6A53 /* ContextMenuHandlers.m */; };
|
||||
692C18A9166617F500BF6A53 /* IconOverlayHandlers.m in Sources */ = {isa = PBXBuildFile; fileRef = 692C18A8166617F500BF6A53 /* IconOverlayHandlers.m */; };
|
||||
692C18AC1666392700BF6A53 /* MenuManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 692C18AB1666392700BF6A53 /* MenuManager.m */; };
|
||||
@@ -29,9 +29,9 @@
|
||||
0B13ECAC173C686900548DA1 /* GCDAsyncSocket.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GCDAsyncSocket.h; sourceTree = "<group>"; };
|
||||
0B13ECAD173C686A00548DA1 /* GCDAsyncSocket.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GCDAsyncSocket.m; sourceTree = "<group>"; };
|
||||
0B2BF60B176A43DB001246CD /* Finder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Finder.h; sourceTree = "<group>"; };
|
||||
0BFAF21A16F8E6C10017EA7E /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = "<group>"; };
|
||||
0BFAF21B16F8E6C10017EA7E /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = "<group>"; };
|
||||
0BFC9ACB173C57E400CDD329 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
||||
5BB74A8519DBF9BB001BAAAC /* FinishedIconCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FinishedIconCache.h; sourceTree = "<group>"; };
|
||||
5BB74A8619DBF9BB001BAAAC /* FinishedIconCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FinishedIconCache.m; sourceTree = "<group>"; };
|
||||
692C18A316660C4600BF6A53 /* ContextMenuHandlers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextMenuHandlers.h; sourceTree = "<group>"; };
|
||||
692C18A416660C4600BF6A53 /* ContextMenuHandlers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContextMenuHandlers.m; sourceTree = "<group>"; };
|
||||
692C18A7166617F500BF6A53 /* IconOverlayHandlers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconOverlayHandlers.h; sourceTree = "<group>"; };
|
||||
@@ -104,7 +104,6 @@
|
||||
children = (
|
||||
0B2BF60A176A43DB001246CD /* Finder */,
|
||||
0B08BAC21759627700C8351E /* GCDAsyncSocket */,
|
||||
0BFAF21916F8E6910017EA7E /* JSONKit */,
|
||||
8C37DD99161593BD00016A95 /* FinderHook.h */,
|
||||
8C37DD9A161593BD00016A95 /* FinderHook.m */,
|
||||
692C18A316660C4600BF6A53 /* ContextMenuHandlers.h */,
|
||||
@@ -117,6 +116,8 @@
|
||||
69948B351636D50E0093B6CE /* ContentManager.m */,
|
||||
8C99F6921622D145002D2135 /* IconCache.h */,
|
||||
8C99F6931622D145002D2135 /* IconCache.m */,
|
||||
5BB74A8519DBF9BB001BAAAC /* FinishedIconCache.h */,
|
||||
5BB74A8619DBF9BB001BAAAC /* FinishedIconCache.m */,
|
||||
692C18AA1666392700BF6A53 /* MenuManager.h */,
|
||||
692C18AB1666392700BF6A53 /* MenuManager.m */,
|
||||
);
|
||||
@@ -140,15 +141,6 @@
|
||||
path = Finder;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0BFAF21916F8E6910017EA7E /* JSONKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0BFAF21A16F8E6C10017EA7E /* JSONKit.h */,
|
||||
0BFAF21B16F8E6C10017EA7E /* JSONKit.m */,
|
||||
);
|
||||
name = JSONKit;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FB6FE9D52B211CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -226,10 +218,10 @@
|
||||
8C99F6941622D145002D2135 /* IconCache.m in Sources */,
|
||||
69948B361636D50E0093B6CE /* ContentManager.m in Sources */,
|
||||
6993878616494C000044E4DF /* RequestManager.m in Sources */,
|
||||
5BB74A8719DBF9BB001BAAAC /* FinishedIconCache.m in Sources */,
|
||||
692C18A516660C4700BF6A53 /* ContextMenuHandlers.m in Sources */,
|
||||
692C18A9166617F500BF6A53 /* IconOverlayHandlers.m in Sources */,
|
||||
692C18AC1666392700BF6A53 /* MenuManager.m in Sources */,
|
||||
0BFAF21C16F8E6C10017EA7E /* JSONKit.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -302,8 +294,9 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
+ (RequestManager*)sharedInstance;
|
||||
|
||||
- (BOOL)isRegisteredPath:(NSString*)path;
|
||||
- (BOOL)isRegisteredPath:(NSString*)path isDirectory:(BOOL)isDir;
|
||||
- (void)askOnSocket:(NSString*)path query:(NSString*)verb;
|
||||
- (NSNumber*)askForIcon:(NSString*)path isDirectory:(BOOL)isDir;
|
||||
- (void)menuItemClicked:(NSDictionary*)actionDictionary;
|
||||
|
||||
@@ -77,14 +77,20 @@ static RequestManager* sharedInstance = nil;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)isRegisteredPath:(NSString*)path
|
||||
- (BOOL)isRegisteredPath:(NSString*)path isDirectory:(BOOL)isDir
|
||||
{
|
||||
// check if the file in question is underneath a registered directory
|
||||
NSArray *regPathes = [_registeredPathes allKeys];
|
||||
BOOL registered = NO;
|
||||
|
||||
NSString* checkPath = [NSString stringWithString:path];
|
||||
if (isDir) {
|
||||
// append a slash
|
||||
checkPath = [path stringByAppendingString:@"/"];
|
||||
}
|
||||
|
||||
for( NSString *regPath in regPathes ) {
|
||||
if( [path hasPrefix:regPath]) {
|
||||
if( [checkPath hasPrefix:regPath]) {
|
||||
// the path was registered
|
||||
registered = YES;
|
||||
break;
|
||||
@@ -99,7 +105,7 @@ static RequestManager* sharedInstance = nil;
|
||||
NSString *verb = @"RETRIEVE_FILE_STATUS";
|
||||
NSNumber *res = [NSNumber numberWithInt:0];
|
||||
|
||||
if( [self isRegisteredPath:path] ) {
|
||||
if( [self isRegisteredPath:path isDirectory:isDir] ) {
|
||||
if( _isConnected ) {
|
||||
if(isDir) {
|
||||
verb = @"RETRIEVE_FOLDER_STATUS";
|
||||
@@ -121,41 +127,49 @@ static RequestManager* sharedInstance = nil;
|
||||
|
||||
- (void)socket:(GCDAsyncSocket*)socket didReadData:(NSData*)data withTag:(long)tag
|
||||
{
|
||||
NSArray *chunks;
|
||||
NSString *answer = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
NSArray *chunks = nil;
|
||||
if (answer != nil && [answer length] > 0) {
|
||||
// cut a trailing newline
|
||||
answer = [answer substringToIndex:[answer length] - 1];
|
||||
chunks = [answer componentsSeparatedByString: @":"];
|
||||
}
|
||||
NSLog(@"READ from socket (%ld): <%@>", tag, answer);
|
||||
ContentManager *contentman = [ContentManager sharedInstance];
|
||||
|
||||
if( [chunks count] > 0 && tag == READ_TAG ) {
|
||||
if( chunks && [chunks count] > 0 && tag == READ_TAG ) {
|
||||
NSLog(@"READ from socket (%ld): <%@>", tag, answer);
|
||||
if( [[chunks objectAtIndex:0] isEqualToString:@"STATUS"] ) {
|
||||
[contentman setResultForPath:[chunks objectAtIndex:2] result:[chunks objectAtIndex:1]];
|
||||
NSString *path = [chunks objectAtIndex:2];
|
||||
if( [chunks count] > 3 ) {
|
||||
for( int i = 2; i < [chunks count]-1; i++ ) {
|
||||
path = [NSString stringWithFormat:@"%@:%@",
|
||||
path, [chunks objectAtIndex:i+1] ];
|
||||
}
|
||||
}
|
||||
[contentman setResultForPath:path result:[chunks objectAtIndex:1]];
|
||||
} else if( [[chunks objectAtIndex:0] isEqualToString:@"UPDATE_VIEW"] ) {
|
||||
NSString *path = [chunks objectAtIndex:1];
|
||||
[contentman clearFileNameCacheForPath:path];
|
||||
|
||||
[contentman repaintAllWindows];
|
||||
[contentman reFetchFileNameCacheForPath:path];
|
||||
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"REGISTER_PATH"] ) {
|
||||
NSNumber *one = [NSNumber numberWithInt:1];
|
||||
NSString *path = [chunks objectAtIndex:1];
|
||||
NSLog(@"Registering path: %@", path);
|
||||
[_registeredPathes setObject:one forKey:path];
|
||||
|
||||
[contentman repaintAllWindows];
|
||||
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"UNREGISTER_PATH"] ) {
|
||||
NSNumber *one = [NSNumber numberWithInt:1];
|
||||
NSString *path = [chunks objectAtIndex:1];
|
||||
[_registeredPathes removeObjectForKey:path];
|
||||
|
||||
[contentman repaintAllWindows];
|
||||
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"ICON_PATH"] ) {
|
||||
NSString *path = [chunks objectAtIndex:1];
|
||||
[[ContentManager sharedInstance] loadIconResourcePath:path];
|
||||
} else {
|
||||
NSLog(@"Unknown command %@", [chunks objectAtIndex:0]);
|
||||
}
|
||||
} else {
|
||||
NSLog(@"Received unknown tag %ld", tag);
|
||||
} else if (tag != READ_TAG) {
|
||||
NSLog(@"Received unknown tag %ld <%@>", tag, answer);
|
||||
}
|
||||
// Read on and on
|
||||
NSData* stop = [@"\n" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
@@ -169,18 +183,32 @@ static RequestManager* sharedInstance = nil;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
-(void)socket:(GCDAsyncSocket*)socket didConnectToUrl:(NSURL *)url {
|
||||
NSLog(@"didConnectToUrl %@", url);
|
||||
[self socketDidConnect:socket];
|
||||
}
|
||||
|
||||
- (void)socket:(GCDAsyncSocket*)socket didConnectToHost:(NSString*)host port:(UInt16)port
|
||||
{
|
||||
NSLog( @"Connected to host successfully!");
|
||||
[self socketDidConnect:socket];
|
||||
}
|
||||
|
||||
// Our impl
|
||||
- (void)socketDidConnect:(GCDAsyncSocket*)socket {
|
||||
NSLog( @"Connected to sync client successfully!");
|
||||
_isConnected = YES;
|
||||
_isRunning = NO;
|
||||
|
||||
if( [_requestQueue count] > 0 ) {
|
||||
NSLog( @"We have to empty the queue");
|
||||
for( NSString *path in _requestQueue ) {
|
||||
[self askOnSocket:path];
|
||||
[self askOnSocket:path query:@"RETRIEVE_FILE_STATUS"];
|
||||
}
|
||||
}
|
||||
|
||||
ContentManager *contentman = [ContentManager sharedInstance];
|
||||
[contentman clearFileNameCacheForPath:nil];
|
||||
[contentman repaintAllWindows];
|
||||
|
||||
// Read for the UPDATE_VIEW requests
|
||||
NSData* stop = [@"\n" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
@@ -205,6 +233,7 @@ static RequestManager* sharedInstance = nil;
|
||||
// clear the caches in conent manager
|
||||
ContentManager *contentman = [ContentManager sharedInstance];
|
||||
[contentman clearFileNameCacheForPath:nil];
|
||||
[contentman repaintAllWindows];
|
||||
|
||||
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(start) userInfo:nil repeats:NO];
|
||||
|
||||
@@ -215,12 +244,27 @@ static RequestManager* sharedInstance = nil;
|
||||
{
|
||||
if (!_isRunning)
|
||||
{
|
||||
NSLog(@"Connect Socket!");
|
||||
NSError *err = nil;
|
||||
if (![_socket connectToHost:@"localhost" onPort:34001 withTimeout:5 error:&err]) // Asynchronous!
|
||||
{
|
||||
// If there was an error, it's likely something like "already connected" or "no delegate set"
|
||||
NSLog(@"I goofed: %@", err);
|
||||
BOOL useTcp = NO;
|
||||
if (useTcp) {
|
||||
NSLog(@"Connect Socket");
|
||||
if (![_socket connectToHost:@"localhost" onPort:34001 withTimeout:5 error:&err]) {
|
||||
// If there was an error, it's likely something like "already connected" or "no delegate set"
|
||||
NSLog(@"I goofed: %@", err);
|
||||
}
|
||||
} else if (!useTcp) {
|
||||
NSURL *url = nil;
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
if ([paths count])
|
||||
{
|
||||
// file:///Users/guruz/Library/Caches/SyncStateHelper/ownCloud.socket
|
||||
// FIXME Generify this and support all sockets there since multiple sync clients might be running
|
||||
url =[NSURL fileURLWithPath:[[[paths objectAtIndex:0] stringByAppendingPathComponent:@"SyncStateHelper"] stringByAppendingPathComponent:@"ownCloud.socket"]];
|
||||
}
|
||||
if (url) {
|
||||
NSLog(@"Connect Socket to %@", url);
|
||||
[_socket connectToUrl:url withTimeout:5 error:&err];
|
||||
}
|
||||
}
|
||||
|
||||
_isRunning = YES;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<dict>
|
||||
<key>Events</key>
|
||||
<dict>
|
||||
<key>NVTYlded</key>
|
||||
<key>OWNClded</key>
|
||||
<dict>
|
||||
<key>Context</key>
|
||||
<string>Process</string>
|
||||
@@ -35,7 +35,7 @@
|
||||
<key>ThreadSafe</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>NVTYload</key>
|
||||
<key>OWNCload</key>
|
||||
<dict>
|
||||
<key>Context</key>
|
||||
<string>Process</string>
|
||||
@@ -44,7 +44,7 @@
|
||||
<key>ThreadSafe</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>NVTYunld</key>
|
||||
<key>OWNCunld</key>
|
||||
<dict>
|
||||
<key>Context</key>
|
||||
<string>Process</string>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tell application "Finder"
|
||||
try
|
||||
«event NVTYlded»
|
||||
«event OWNClded»
|
||||
set the result to 0
|
||||
on error msg number code
|
||||
set the result to code
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tell application "Finder"
|
||||
try
|
||||
«event NVTYload»
|
||||
«event OWNCload»
|
||||
end try
|
||||
end tell
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
osascript -e 'tell application "Finder" \
|
||||
try \
|
||||
«event NVTYload» \
|
||||
«event OWNCload» \
|
||||
end try \
|
||||
end tell'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tell application "Finder"
|
||||
try
|
||||
«event NVTYunld»
|
||||
«event OWNCunld»
|
||||
end try
|
||||
end tell
|
||||
|
||||
|
||||
@@ -13,7 +13,12 @@ if( UNIX AND NOT APPLE )
|
||||
|
||||
FOREACH(size 128x128 16x16 256x256 32x32 48x48 64x64 72x72)
|
||||
file(GLOB files "${size}/*.png")
|
||||
install(FILES ${files} DESTINATION ${ICON_DIR}/${size}/apps)
|
||||
FOREACH( file ${files} )
|
||||
# the GLOB returns a absolute path. Make it relative by replacing the current src dir by nothing
|
||||
STRING(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/${size}/" "" shortFile ${file})
|
||||
STRING(REPLACE "oC" ${APPLICATION_NAME} brandedName ${shortFile})
|
||||
install(FILES ${file} DESTINATION ${ICON_DIR}/${size}/apps RENAME ${brandedName})
|
||||
ENDFOREACH(file)
|
||||
ENDFOREACH(size)
|
||||
|
||||
endif()
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
install(FILES ownCloud.py DESTINATION ${DATADIR}/nautilus-python/extensions)
|
||||
|
||||
install(FILES syncstate.py DESTINATION ${DATADIR}/nautilus-python/extensions)
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import urllib
|
||||
import socket
|
||||
|
||||
from gi.repository import GObject, Nautilus
|
||||
|
||||
class ownCloudExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.InfoProvider):
|
||||
|
||||
nautilusVFSFile_table = {}
|
||||
registered_paths = {}
|
||||
remainder = ''
|
||||
connected = False
|
||||
watch_id = 0
|
||||
|
||||
def __init__(self):
|
||||
self.connectToOwnCloud
|
||||
if not self.connected:
|
||||
# try again in 5 seconds - attention, logic inverted!
|
||||
GObject.timeout_add(5000, self.connectToOwnCloud)
|
||||
|
||||
def port(self):
|
||||
return 34001 # Fixme, read from config file.
|
||||
|
||||
def connectToOwnCloud(self):
|
||||
try:
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
self.sock.connect(("localhost", self.port()))
|
||||
self.sock.settimeout(5)
|
||||
self.connected = True
|
||||
self.watch_id = GObject.io_add_watch(self.sock, GObject.IO_IN, self.handle_notify)
|
||||
except:
|
||||
print "Connect could not be established, try again later!"
|
||||
self.sock.close()
|
||||
return not self.connected
|
||||
|
||||
def sendCommand(self, cmd):
|
||||
if self.connected:
|
||||
try:
|
||||
self.sock.send(cmd)
|
||||
except:
|
||||
print "Sending failed."
|
||||
GObject.source_remove( self.watch_id )
|
||||
self.connected = False
|
||||
GObject.timeout_add(5000, self.connectToOwnCloud)
|
||||
|
||||
def find_item_for_file( self, path ):
|
||||
if path in self.nautilusVFSFile_table:
|
||||
return self.nautilusVFSFile_table[path]
|
||||
else:
|
||||
return None
|
||||
|
||||
def askForOverlay(self, file):
|
||||
if os.path.isdir(file):
|
||||
folderStatus = self.sendCommand("RETRIEVE_FOLDER_STATUS:"+file+"\n");
|
||||
|
||||
if os.path.isfile(file):
|
||||
fileStatus = self.sendCommand("RETRIEVE_FILE_STATUS:"+file+"\n");
|
||||
|
||||
def invalidate_items_underneath( self, path ):
|
||||
update_items = []
|
||||
for p in self.nautilusVFSFile_table:
|
||||
if p == path or p.startswith( path ):
|
||||
item = self.nautilusVFSFile_table[p]
|
||||
update_items.append(item)
|
||||
|
||||
for item in update_items:
|
||||
item.invalidate_extension_info()
|
||||
# self.update_file_info(item)
|
||||
|
||||
# Handles a single line of server respoonse and sets the emblem
|
||||
def handle_server_response(self, l):
|
||||
Emblems = { 'OK' : 'oC_ok',
|
||||
'SYNC' : 'oC_sync',
|
||||
'NEW' : 'oC_sync',
|
||||
'IGNORE' : 'oC_warn',
|
||||
'ERROR' : 'oC_error',
|
||||
'OK+SWM' : 'oC_ok_shared',
|
||||
'SYNC+SWM' : 'oC_sync_shared',
|
||||
'NEW+SWM' : 'oC_sync_shared',
|
||||
'IGNORE+SWM': 'oC_warn_shared',
|
||||
'ERROR+SWM' : 'oC_error_shared',
|
||||
'NOP' : 'oC_error'
|
||||
}
|
||||
|
||||
print "Server response: "+l
|
||||
parts = l.split(':')
|
||||
if len(parts) > 0:
|
||||
action = parts[0]
|
||||
|
||||
# file = parts[1]
|
||||
# print "Action for " + file + ": "+parts[0]
|
||||
if action == 'STATUS':
|
||||
emblem = Emblems[parts[1]]
|
||||
if emblem:
|
||||
item = self.find_item_for_file(parts[2])
|
||||
if item:
|
||||
item.add_emblem(emblem)
|
||||
|
||||
elif action == 'UPDATE_VIEW':
|
||||
# Search all items underneath this path and invalidate them
|
||||
if parts[1] in self.registered_paths:
|
||||
self.invalidate_items_underneath( parts[1] )
|
||||
|
||||
elif action == 'REGISTER_PATH':
|
||||
self.registered_paths[parts[1]] = 1
|
||||
self.invalidate_items_underneath( parts[1] )
|
||||
elif action == 'UNREGISTER_PATH':
|
||||
del self.registered_paths[parts[1]]
|
||||
self.invalidate_items_underneath( parts[1] )
|
||||
|
||||
# check if there are non pathes any more, if so, its usual
|
||||
# that mirall went away. Try reconnect.
|
||||
if not self.registered_paths:
|
||||
self.sock.close()
|
||||
self.connected = False
|
||||
GObject.source_remove( self.watch_id )
|
||||
GObject.timeout_add(5000, self.connectToOwnCloud)
|
||||
|
||||
else:
|
||||
# print "We got unknown action " + action
|
||||
1
|
||||
|
||||
# notify is the raw answer from the socket
|
||||
def handle_notify(self, source, condition):
|
||||
|
||||
data = source.recv(1024)
|
||||
# prepend the remaining data from last call
|
||||
if len(self.remainder) > 0:
|
||||
data = self.remainder+data
|
||||
self.remainder = ''
|
||||
|
||||
if len(data) > 0:
|
||||
# remember the remainder for next round
|
||||
lastNL = data.rfind('\n');
|
||||
if lastNL > -1 and lastNL < len(data):
|
||||
self.remainder = data[lastNL+1:]
|
||||
data = data[:lastNL]
|
||||
|
||||
for l in data.split('\n'):
|
||||
self.handle_server_response( l )
|
||||
else:
|
||||
return False
|
||||
|
||||
return True # run again
|
||||
|
||||
def get_local_path(self, path):
|
||||
return path.replace("file://", "")
|
||||
|
||||
def update_file_info(self, item):
|
||||
if item.get_uri_scheme() != 'file':
|
||||
return
|
||||
|
||||
filename = urllib.unquote(item.get_uri()[7:])
|
||||
if item.is_directory():
|
||||
filename += '/'
|
||||
|
||||
for reg_path in self.registered_paths:
|
||||
if filename.startswith(reg_path):
|
||||
self.nautilusVFSFile_table[filename] = item
|
||||
|
||||
# item.add_string_attribute('share_state', "share state")
|
||||
self.askForOverlay(filename)
|
||||
break
|
||||
else:
|
||||
print "Not in scope:"+filename
|
||||
198
shell_integration/nautilus/syncstate.py
Executable file
198
shell_integration/nautilus/syncstate.py
Executable file
@@ -0,0 +1,198 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# 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; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import os
|
||||
import urllib
|
||||
import socket
|
||||
|
||||
from gi.repository import GObject, Nautilus
|
||||
|
||||
class syncStateExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.InfoProvider):
|
||||
|
||||
nautilusVFSFile_table = {}
|
||||
registered_paths = {}
|
||||
remainder = ''
|
||||
connected = False
|
||||
watch_id = 0
|
||||
appname = 'ownCloud'
|
||||
|
||||
def __init__(self):
|
||||
self.connectToSocketServer
|
||||
if not self.connected:
|
||||
# try again in 5 seconds - attention, logic inverted!
|
||||
GObject.timeout_add(5000, self.connectToSocketServer)
|
||||
|
||||
def connectToSocketServer(self):
|
||||
do_reconnect = True
|
||||
try:
|
||||
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
postfix = "/"+self.appname+"/socket"
|
||||
sock_file = os.environ["XDG_RUNTIME_DIR"]+postfix
|
||||
print ("XXXX " + sock_file + " <=> " + postfix)
|
||||
if sock_file != postfix:
|
||||
try:
|
||||
print("Socket File: "+sock_file)
|
||||
self.sock.connect(sock_file)
|
||||
self.connected = True
|
||||
print("Setting connected to %r" % self.connected )
|
||||
self.watch_id = GObject.io_add_watch(self.sock, GObject.IO_IN, self.handle_notify)
|
||||
do_reconnect = False
|
||||
except Exception, e:
|
||||
print("Could not connect to unix socket." + str(e))
|
||||
else:
|
||||
print("Sock-File not valid: "+sock_file)
|
||||
except Exception, e:
|
||||
print("Connect could not be established, try again later " + str(e))
|
||||
self.sock.close()
|
||||
# print("Returning %r" % do_reconnect)
|
||||
return do_reconnect
|
||||
|
||||
def sendCommand(self, cmd):
|
||||
if self.connected:
|
||||
try:
|
||||
self.sock.send(cmd)
|
||||
except:
|
||||
print("Sending failed.")
|
||||
GObject.source_remove(self.watch_id)
|
||||
self.connected = False
|
||||
GObject.timeout_add(5000, self.connectToSocketServer)
|
||||
|
||||
def find_item_for_file(self, path):
|
||||
if path in self.nautilusVFSFile_table:
|
||||
return self.nautilusVFSFile_table[path]
|
||||
else:
|
||||
return None
|
||||
|
||||
def askForOverlay(self, file):
|
||||
# print("Asking for overlay for "+file)
|
||||
if os.path.isdir(file):
|
||||
folderStatus = self.sendCommand("RETRIEVE_FOLDER_STATUS:"+file+"\n");
|
||||
|
||||
if os.path.isfile(file):
|
||||
fileStatus = self.sendCommand("RETRIEVE_FILE_STATUS:"+file+"\n");
|
||||
|
||||
def invalidate_items_underneath(self, path):
|
||||
update_items = []
|
||||
if not self.nautilusVFSFile_table:
|
||||
self.askForOverlay(path)
|
||||
else:
|
||||
for p in self.nautilusVFSFile_table:
|
||||
if p == path or p.startswith(path):
|
||||
item = self.nautilusVFSFile_table[p]['item']
|
||||
update_items.append(item)
|
||||
|
||||
for item in update_items:
|
||||
item.invalidate_extension_info()
|
||||
|
||||
# Handles a single line of server respoonse and sets the emblem
|
||||
def handle_server_response(self, l):
|
||||
Emblems = { 'OK' : self.appname +'_ok',
|
||||
'SYNC' : self.appname +'_sync',
|
||||
'NEW' : self.appname +'_sync',
|
||||
'IGNORE' : self.appname +'_warn',
|
||||
'ERROR' : self.appname +'_error',
|
||||
'OK+SWM' : self.appname +'_ok_shared',
|
||||
'SYNC+SWM' : self.appname +'_sync_shared',
|
||||
'NEW+SWM' : self.appname +'_sync_shared',
|
||||
'IGNORE+SWM': self.appname +'_warn_shared',
|
||||
'ERROR+SWM' : self.appname +'_error_shared',
|
||||
'NOP' : self.appname +'_error'
|
||||
}
|
||||
|
||||
print("Server response: "+l)
|
||||
parts = l.split(':')
|
||||
if len(parts) > 0:
|
||||
action = parts[0]
|
||||
|
||||
# file = parts[1]
|
||||
# print "Action for " + file + ": "+parts[0]
|
||||
if action == 'STATUS':
|
||||
newState = parts[1]
|
||||
emblem = Emblems[newState]
|
||||
if emblem:
|
||||
itemStore = self.find_item_for_file(parts[2])
|
||||
if itemStore:
|
||||
if( not itemStore['state'] or newState != itemStore['state'] ):
|
||||
item = itemStore['item']
|
||||
item.add_emblem(emblem)
|
||||
# print "Setting emblem on " + parts[2]+ "<>"+emblem+"<>"
|
||||
self.nautilusVFSFile_table[parts[2]] = {'item': item, 'state':newState}
|
||||
|
||||
elif action == 'UPDATE_VIEW':
|
||||
# Search all items underneath this path and invalidate them
|
||||
if parts[1] in self.registered_paths:
|
||||
self.invalidate_items_underneath(parts[1])
|
||||
|
||||
elif action == 'REGISTER_PATH':
|
||||
self.registered_paths[parts[1]] = 1
|
||||
self.invalidate_items_underneath(parts[1])
|
||||
elif action == 'UNREGISTER_PATH':
|
||||
del self.registered_paths[parts[1]]
|
||||
self.invalidate_items_underneath(parts[1])
|
||||
|
||||
# check if there are non pathes any more, if so, its usual
|
||||
# that mirall went away. Try reconnect.
|
||||
if not self.registered_paths:
|
||||
self.sock.close()
|
||||
self.connected = False
|
||||
GObject.source_remove(self.watch_id)
|
||||
GObject.timeout_add(5000, self.connectToSocketServer)
|
||||
|
||||
else:
|
||||
# print "We got unknown action " + action
|
||||
1
|
||||
|
||||
# notify is the raw answer from the socket
|
||||
def handle_notify(self, source, condition):
|
||||
|
||||
data = source.recv(1024)
|
||||
# prepend the remaining data from last call
|
||||
if len(self.remainder) > 0:
|
||||
data = self.remainder+data
|
||||
self.remainder = ''
|
||||
|
||||
if len(data) > 0:
|
||||
# remember the remainder for next round
|
||||
lastNL = data.rfind('\n');
|
||||
if lastNL > -1 and lastNL < len(data):
|
||||
self.remainder = data[lastNL+1:]
|
||||
data = data[:lastNL]
|
||||
|
||||
for l in data.split('\n'):
|
||||
self.handle_server_response(l)
|
||||
else:
|
||||
return False
|
||||
|
||||
return True # run again
|
||||
|
||||
def get_local_path(self, path):
|
||||
return path.replace("file://", "")
|
||||
|
||||
def update_file_info(self, item):
|
||||
if item.get_uri_scheme() != 'file':
|
||||
return
|
||||
|
||||
filename = urllib.unquote(item.get_uri()[7:])
|
||||
if item.is_directory():
|
||||
filename += '/'
|
||||
|
||||
for reg_path in self.registered_paths:
|
||||
if filename.startswith(reg_path):
|
||||
self.nautilusVFSFile_table[filename] = {'item': item, 'state':''}
|
||||
|
||||
# item.add_string_attribute('share_state', "share state")
|
||||
self.askForOverlay(filename)
|
||||
break
|
||||
else:
|
||||
print("Not in scope:"+filename)
|
||||
@@ -36,17 +36,13 @@ extern HINSTANCE instanceHandle;
|
||||
#define IDM_DISPLAY 0
|
||||
#define IDB_OK 101
|
||||
|
||||
namespace {
|
||||
static std::vector<std::wstring> s_watchedDirectories;
|
||||
}
|
||||
|
||||
OCOverlay::OCOverlay(int state)
|
||||
: _communicationSocket(0)
|
||||
, _referenceCount(1)
|
||||
, _checker(new RemotePathChecker(PORT))
|
||||
: _referenceCount(1)
|
||||
, _state(state)
|
||||
|
||||
{
|
||||
static RemotePathChecker s_remotePathChecker;
|
||||
_checker = &s_remotePathChecker;
|
||||
}
|
||||
|
||||
OCOverlay::~OCOverlay(void)
|
||||
@@ -121,23 +117,13 @@ IFACEMETHODIMP OCOverlay::GetPriority(int *pPriority)
|
||||
|
||||
IFACEMETHODIMP OCOverlay::IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib)
|
||||
{
|
||||
|
||||
//if(!_IsOverlaysEnabled())
|
||||
//{
|
||||
// return MAKE_HRESULT(S_FALSE, 0, 0);
|
||||
//}
|
||||
|
||||
// FIXME: Use Registry instead, this will only trigger once
|
||||
// and now follow any user changes in the client
|
||||
if (s_watchedDirectories.empty()) {
|
||||
s_watchedDirectories = _checker->WatchedDirectories();
|
||||
}
|
||||
auto watchedDirectories = _checker->WatchedDirectories();
|
||||
|
||||
wstring wpath(pwszPath);
|
||||
wpath.append(L"\\");
|
||||
//wpath.append(L"\\");
|
||||
vector<wstring>::iterator it;
|
||||
bool watched = false;
|
||||
for (it = s_watchedDirectories.begin(); it != s_watchedDirectories.end(); ++it) {
|
||||
for (it = watchedDirectories.begin(); it != watchedDirectories.end(); ++it) {
|
||||
if (StringUtil::begins_with(wpath, *it)) {
|
||||
watched = true;
|
||||
}
|
||||
|
||||
@@ -35,14 +35,13 @@ public:
|
||||
IFACEMETHODIMP_(ULONG) Release();
|
||||
|
||||
protected:
|
||||
~OCOverlay(void);
|
||||
~OCOverlay();
|
||||
|
||||
private:
|
||||
//bool _GenerateMessage(const wchar_t*, std::wstring*);
|
||||
|
||||
bool _IsOverlaysEnabled();
|
||||
long _referenceCount;
|
||||
CommunicationSocket* _communicationSocket;
|
||||
RemotePathChecker* _checker;
|
||||
int _state;
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@@ -30,8 +31,8 @@ using namespace std;
|
||||
|
||||
#define DEFAULT_BUFLEN 4096
|
||||
|
||||
CommunicationSocket::CommunicationSocket(int port)
|
||||
: _port(port), _clientSocket(INVALID_SOCKET)
|
||||
CommunicationSocket::CommunicationSocket()
|
||||
: _pipe(INVALID_HANDLE_VALUE)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,64 +44,39 @@ CommunicationSocket::~CommunicationSocket()
|
||||
bool CommunicationSocket::Close()
|
||||
{
|
||||
WSACleanup();
|
||||
bool closed = (closesocket(_clientSocket) == 0);
|
||||
shutdown(_clientSocket, SD_BOTH);
|
||||
_clientSocket = INVALID_SOCKET;
|
||||
return closed;
|
||||
if (_pipe == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
CloseHandle(_pipe);
|
||||
_pipe = INVALID_HANDLE_VALUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CommunicationSocket::Connect()
|
||||
bool CommunicationSocket::Connect(const std::wstring &pipename)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
_pipe = CreateFile(pipename.data(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
HRESULT iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
|
||||
if (iResult != NO_ERROR) {
|
||||
int error = WSAGetLastError();
|
||||
}
|
||||
|
||||
|
||||
_clientSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (_clientSocket == INVALID_SOCKET) {
|
||||
//int error = WSAGetLastError();
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
struct sockaddr_in clientService;
|
||||
|
||||
clientService.sin_family = AF_INET;
|
||||
clientService.sin_addr.s_addr = inet_addr(PLUG_IN_SOCKET_ADDRESS);
|
||||
clientService.sin_port = htons(_port);
|
||||
|
||||
iResult = connect(_clientSocket, (SOCKADDR*)&clientService, sizeof(clientService));
|
||||
DWORD timeout = 500; // ms
|
||||
setsockopt(_clientSocket, SOL_SOCKET, SO_RCVTIMEO, (const char*) &timeout, sizeof(DWORD));
|
||||
|
||||
if (iResult == SOCKET_ERROR) {
|
||||
//int error = WSAGetLastError();
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (_pipe == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommunicationSocket::SendMsg(const wchar_t* message)
|
||||
{
|
||||
const char* utf8_msg = StringUtil::toUtf8(message);
|
||||
size_t result = send(_clientSocket, utf8_msg, (int)strlen(utf8_msg), 0);
|
||||
delete[] utf8_msg;
|
||||
auto utf8_msg = StringUtil::toUtf8(message);
|
||||
|
||||
if (result == SOCKET_ERROR) {
|
||||
//int error = WSAGetLastError();
|
||||
closesocket(_clientSocket);
|
||||
return false;
|
||||
}
|
||||
DWORD numBytesWritten = 0;
|
||||
auto result = WriteFile( _pipe, utf8_msg.c_str(), DWORD(utf8_msg.size()), &numBytesWritten, NULL);
|
||||
|
||||
return true;
|
||||
if (result) {
|
||||
return true;
|
||||
} else {
|
||||
Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CommunicationSocket::ReadLine(wstring* response)
|
||||
@@ -109,21 +85,43 @@ bool CommunicationSocket::ReadLine(wstring* response)
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<char> resp_utf8;
|
||||
char buffer;
|
||||
response->clear();
|
||||
|
||||
if (_pipe == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
while (true) {
|
||||
int bytesRead = recv(_clientSocket, &buffer, 1, 0);
|
||||
if (bytesRead <= 0) {
|
||||
response = 0;
|
||||
int lbPos = 0;
|
||||
auto it = std::find(_buffer.begin() + lbPos, _buffer.end(), '\n');
|
||||
if (it != _buffer.end()) {
|
||||
*response = StringUtil::toUtf16(_buffer.data(), DWORD(it - _buffer.begin()));
|
||||
_buffer.erase(_buffer.begin(), it + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::array<char, 128> resp_utf8;
|
||||
DWORD numBytesRead = 0;
|
||||
DWORD totalBytesAvailable = 0;
|
||||
auto result = PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0);
|
||||
if (!result) {
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
if (totalBytesAvailable == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buffer == '\n') {
|
||||
resp_utf8.push_back(0);
|
||||
*response = StringUtil::toUtf16(&resp_utf8[0], resp_utf8.size());
|
||||
return true;
|
||||
} else {
|
||||
resp_utf8.push_back(buffer);
|
||||
}
|
||||
result = ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, NULL);
|
||||
if (!result) {
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
if (numBytesRead <= 0) {
|
||||
return false;
|
||||
}
|
||||
_buffer.insert(_buffer.end(), resp_utf8.begin(), resp_utf8.begin()+numBytesRead);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,23 +20,27 @@
|
||||
#pragma warning (disable : 4251)
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <WinSock2.h>
|
||||
|
||||
class __declspec(dllexport) CommunicationSocket
|
||||
{
|
||||
public:
|
||||
CommunicationSocket(int port);
|
||||
CommunicationSocket();
|
||||
~CommunicationSocket();
|
||||
|
||||
bool Connect();
|
||||
bool Connect(const std::wstring& pipename);
|
||||
bool Close();
|
||||
|
||||
bool SendMsg(const wchar_t*);
|
||||
bool ReadLine(std::wstring*);
|
||||
|
||||
HANDLE Event() { return _pipe; }
|
||||
|
||||
private:
|
||||
int _port;
|
||||
SOCKET _clientSocket;
|
||||
HANDLE _pipe;
|
||||
std::vector<char> _buffer;
|
||||
bool _connected;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -20,88 +20,168 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iterator>
|
||||
#include <unordered_set>
|
||||
#include <cassert>
|
||||
|
||||
#include <shlobj.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
RemotePathChecker::RemotePathChecker(int port)
|
||||
: _port(port)
|
||||
|
||||
// This code is run in a thread
|
||||
void RemotePathChecker::workerThreadLoop()
|
||||
{
|
||||
auto pipename = std::wstring(L"\\\\.\\pipe\\");
|
||||
pipename += L"ownCloud";
|
||||
|
||||
bool connected = false;
|
||||
CommunicationSocket socket;
|
||||
std::unordered_set<std::wstring> asked;
|
||||
|
||||
while(!_stop) {
|
||||
Sleep(50);
|
||||
|
||||
if (!connected) {
|
||||
asked.clear();
|
||||
if (!WaitNamedPipe(pipename.data(), 5 * 1000)) {
|
||||
continue;
|
||||
}
|
||||
if (!socket.Connect(pipename)) {
|
||||
continue;
|
||||
}
|
||||
connected = true;
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
_connected = true;
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
while (!_pending.empty() && !_stop) {
|
||||
auto filePath = _pending.front();
|
||||
_pending.pop();
|
||||
|
||||
lock.unlock();
|
||||
if (!asked.count(filePath)) {
|
||||
asked.insert(filePath);
|
||||
socket.SendMsg(wstring(L"RETRIEVE_FILE_STATUS:" + filePath + L'\n').data());
|
||||
}
|
||||
lock.lock();
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring response;
|
||||
while (!_stop && socket.ReadLine(&response)) {
|
||||
if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
|
||||
wstring responsePath = response.substr(14); // length of REGISTER_PATH:
|
||||
|
||||
{ std::unique_lock<std::mutex> lock(_mutex);
|
||||
_watchedDirectories.push_back(responsePath);
|
||||
}
|
||||
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH, responsePath.data(), NULL);
|
||||
} else if (StringUtil::begins_with(response, wstring(L"UNREGISTER_PATH:"))) {
|
||||
wstring responsePath = response.substr(16); // length of UNREGISTER_PATH:
|
||||
|
||||
{ std::unique_lock<std::mutex> lock(_mutex);
|
||||
_watchedDirectories.erase(
|
||||
std::remove(_watchedDirectories.begin(), _watchedDirectories.end(), responsePath),
|
||||
_watchedDirectories.end());
|
||||
|
||||
// Remove any item from the cache
|
||||
for (auto it = _cache.begin(); it != _cache.end() ; ) {
|
||||
if (StringUtil::begins_with(it->first, responsePath)) {
|
||||
it = _cache.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH, responsePath.data(), NULL);
|
||||
} else if (StringUtil::begins_with(response, wstring(L"STATUS:")) ||
|
||||
StringUtil::begins_with(response, wstring(L"BROADCAST:"))) {
|
||||
|
||||
auto statusBegin = response.find(L':', 0);
|
||||
assert(statusBegin != std::wstring::npos);
|
||||
|
||||
auto statusEnd = response.find(L':', statusBegin + 1);
|
||||
if (statusEnd == std::wstring::npos) {
|
||||
// the command do not contains two colon?
|
||||
continue;
|
||||
}
|
||||
|
||||
auto responseStatus = response.substr(statusBegin+1, statusEnd - statusBegin-1);
|
||||
auto responsePath = response.substr(statusEnd+1);
|
||||
auto state = _StrToFileState(responseStatus);
|
||||
auto erased = asked.erase(responsePath);
|
||||
|
||||
{ std::unique_lock<std::mutex> lock(_mutex);
|
||||
_cache[responsePath] = state;
|
||||
}
|
||||
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, responsePath.data(), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (socket.Event() == INVALID_HANDLE_VALUE) {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
_cache.clear();
|
||||
_watchedDirectories.clear();
|
||||
_connected = connected = false;
|
||||
}
|
||||
|
||||
if (_stop) return;
|
||||
|
||||
HANDLE handles[2] = { _newQueries, socket.Event() };
|
||||
WaitForMultipleObjects(2, handles, false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RemotePathChecker::RemotePathChecker()
|
||||
: _connected(false)
|
||||
, _newQueries(CreateEvent(NULL, true, true, NULL))
|
||||
, _thread([this]{ this->workerThreadLoop(); })
|
||||
{
|
||||
}
|
||||
|
||||
RemotePathChecker::~RemotePathChecker()
|
||||
{
|
||||
_stop = true;
|
||||
//_newQueries.notify_all();
|
||||
SetEvent(_newQueries);
|
||||
_thread.join();
|
||||
CloseHandle(_newQueries);
|
||||
}
|
||||
|
||||
vector<wstring> RemotePathChecker::WatchedDirectories()
|
||||
{
|
||||
vector<wstring> watchedDirectories;
|
||||
wstring response;
|
||||
bool needed = false;
|
||||
|
||||
CommunicationSocket socket(_port);
|
||||
socket.Connect();
|
||||
|
||||
while (socket.ReadLine(&response)) {
|
||||
if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
|
||||
size_t pathBegin = response.find(L':', 0);
|
||||
if (pathBegin == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// chop trailing '\n'
|
||||
wstring responsePath = response.substr(pathBegin + 1, response.length()-1);
|
||||
watchedDirectories.push_back(responsePath);
|
||||
}
|
||||
}
|
||||
|
||||
return watchedDirectories;
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
return _watchedDirectories;
|
||||
}
|
||||
|
||||
bool RemotePathChecker::IsMonitoredPath(const wchar_t* filePath, int* state)
|
||||
{
|
||||
wstring request;
|
||||
wstring response;
|
||||
bool needed = false;
|
||||
assert(state); assert(filePath);
|
||||
|
||||
CommunicationSocket socket(_port);
|
||||
socket.Connect();
|
||||
request = L"RETRIEVE_FILE_STATUS:";
|
||||
request += filePath;
|
||||
request += L'\n';
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
if (!_connected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!socket.SendMsg(request.c_str())) {
|
||||
return false;
|
||||
}
|
||||
auto path = std::wstring(filePath);
|
||||
|
||||
while (socket.ReadLine(&response)) {
|
||||
// discard broadcast messages
|
||||
if (StringUtil::begins_with(response, wstring(L"STATUS:"))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto it = _cache.find(path);
|
||||
if (it != _cache.end()) {
|
||||
*state = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t statusBegin = response.find(L':', 0);
|
||||
if (statusBegin == -1)
|
||||
return false;
|
||||
_pending.push(filePath);
|
||||
SetEvent(_newQueries);
|
||||
return false;
|
||||
|
||||
size_t statusEnd = response.find(L':', statusBegin + 1);
|
||||
if (statusEnd == -1)
|
||||
return false;
|
||||
|
||||
|
||||
wstring responseStatus = response.substr(statusBegin+1, statusEnd - statusBegin-1);
|
||||
wstring responsePath = response.substr(statusEnd+1);
|
||||
if (responsePath == filePath) {
|
||||
if (!state) {
|
||||
return false;
|
||||
}
|
||||
*state = _StrToFileState(responseStatus);
|
||||
if (*state == StateNone) {
|
||||
return false;
|
||||
}
|
||||
needed = true;
|
||||
}
|
||||
|
||||
return needed;
|
||||
}
|
||||
|
||||
int RemotePathChecker::_StrToFileState(const std::wstring &str)
|
||||
RemotePathChecker::FileState RemotePathChecker::_StrToFileState(const std::wstring &str)
|
||||
{
|
||||
if (str == L"NOP" || str == L"NONE") {
|
||||
return StateNone;
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <queue>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -29,14 +35,33 @@ public:
|
||||
StateWarning, StateWarningSWM,
|
||||
StateNone
|
||||
};
|
||||
RemotePathChecker(int port);
|
||||
RemotePathChecker();
|
||||
~RemotePathChecker();
|
||||
std::vector<std::wstring> WatchedDirectories();
|
||||
bool IsMonitoredPath(const wchar_t* filePath, int* state);
|
||||
|
||||
private:
|
||||
int _StrToFileState(const std::wstring &str);
|
||||
int _port;
|
||||
FileState _StrToFileState(const std::wstring &str);
|
||||
std::mutex _mutex;
|
||||
std::atomic<bool> _stop;
|
||||
|
||||
// Everything here is protected by the _mutex
|
||||
|
||||
/** The list of paths we need to query. The main thread fill this, and the worker thread
|
||||
* send that to the socket. */
|
||||
std::queue<std::wstring> _pending;
|
||||
|
||||
std::unordered_map<std::wstring, FileState> _cache;
|
||||
std::vector<std::wstring> _watchedDirectories;
|
||||
bool _connected;
|
||||
|
||||
|
||||
// The main thread notifies when there are new items in _pending
|
||||
//std::condition_variable _newQueries;
|
||||
HANDLE _newQueries;
|
||||
|
||||
std::thread _thread;
|
||||
void workerThreadLoop();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -11,22 +11,26 @@
|
||||
* details.
|
||||
*/
|
||||
|
||||
#include <Windows.h>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <codecvt>
|
||||
|
||||
#include "StringUtil.h"
|
||||
|
||||
char* StringUtil::toUtf8(const wchar_t *utf16, int len)
|
||||
std::string StringUtil::toUtf8(const wchar_t *utf16, int len)
|
||||
{
|
||||
int newlen = WideCharToMultiByte(CP_UTF8, 0, utf16, len, NULL, 0, NULL, NULL);
|
||||
char* str = new char[newlen];
|
||||
WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str, newlen, NULL, NULL);
|
||||
return str;
|
||||
if (len < 0) {
|
||||
len = wcslen(utf16);
|
||||
}
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
|
||||
return converter.to_bytes(utf16, utf16+len);
|
||||
}
|
||||
|
||||
wchar_t* StringUtil::toUtf16(const char *utf8, int len)
|
||||
std::wstring StringUtil::toUtf16(const char *utf8, int len)
|
||||
{
|
||||
int newlen = MultiByteToWideChar(CP_UTF8, 0, utf8, len, NULL, 0);
|
||||
wchar_t* wstr = new wchar_t[newlen];
|
||||
MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wstr, newlen);
|
||||
return wstr;
|
||||
if (len < 0) {
|
||||
len = strlen(utf8);
|
||||
}
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
|
||||
return converter.from_bytes(utf8, utf8+len);
|
||||
}
|
||||
|
||||
@@ -20,15 +20,14 @@
|
||||
|
||||
class __declspec(dllexport) StringUtil {
|
||||
public:
|
||||
static char* toUtf8(const wchar_t* utf16, int len = -1);
|
||||
static wchar_t* toUtf16(const char* utf8, int len = -1);
|
||||
|
||||
static std::string toUtf8(const wchar_t* utf16, int len = -1);
|
||||
static std::wstring toUtf16(const char* utf8, int len = -1);
|
||||
|
||||
template<class T>
|
||||
static bool begins_with(const T& input, const T& match)
|
||||
{
|
||||
return input.size() >= match.size()
|
||||
&& equal(match.begin(), match.end(), input.begin());
|
||||
&& std::equal(match.begin(), match.end(), input.begin());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
148882
src/3rdparty/sqlite3/sqlite3.c
vendored
Normal file
148882
src/3rdparty/sqlite3/sqlite3.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7494
src/3rdparty/sqlite3/sqlite3.h
vendored
Normal file
7494
src/3rdparty/sqlite3/sqlite3.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -75,6 +75,7 @@ set(libsync_SRCS
|
||||
mirall/propagator_legacy.cpp
|
||||
mirall/syncjournalfilerecord.cpp
|
||||
mirall/syncjournaldb.cpp
|
||||
mirall/ownsql.cpp
|
||||
mirall/theme.cpp
|
||||
mirall/owncloudtheme.cpp
|
||||
mirall/logger.cpp
|
||||
@@ -216,7 +217,7 @@ else()
|
||||
install(TARGETS ${synclib_NAME} DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/MacOS)
|
||||
if (SPARKLE_FOUND)
|
||||
install(DIRECTORY "${SPARKLE_LIBRARY}"
|
||||
DESTINATION "${OWNCLOUD_OSX_BUNDLE}/Contents/Frameworks")
|
||||
DESTINATION "${OWNCLOUD_OSX_BUNDLE}/Contents/Frameworks" USE_SOURCE_PERMISSIONS)
|
||||
endif (SPARKLE_FOUND)
|
||||
|
||||
endif()
|
||||
@@ -270,6 +271,7 @@ set(mirall_SRCS
|
||||
mirall/sslbutton.cpp
|
||||
mirall/syncrunfilelog.cpp
|
||||
mirall/selectivesyncdialog.cpp
|
||||
mirall/accountmigrator.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -336,7 +338,6 @@ set(ownCloud ${ownCloud_old})
|
||||
if (WITH_DBUS)
|
||||
set(ADDITIONAL_APP_MODULES DBus)
|
||||
endif(WITH_DBUS)
|
||||
|
||||
if(NOT BUILD_OWNCLOUD_OSX_BUNDLE AND NOT BUILD_LIBRARIES_ONLY)
|
||||
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
@@ -358,13 +359,7 @@ if(NOT BUILD_OWNCLOUD_OSX_BUNDLE AND NOT BUILD_LIBRARIES_ONLY)
|
||||
qt5_use_modules(${APPLICATION_EXECUTABLE} Widgets Network Xml WebKitWidgets Sql ${ADDITIONAL_APP_MODULES})
|
||||
elseif(NOT BUILD_LIBRARIES_ONLY)
|
||||
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
if (Qt5Core_FOUND)
|
||||
include(DeployQt5)
|
||||
else(Qt5Core_FOUND)
|
||||
include(DeployQt4)
|
||||
endif(Qt5Core_FOUND)
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX ".") # Examples use /Applications. hurmpf.
|
||||
# set(CMAKE_INSTALL_PREFIX ".") # Examples use /Applications. hurmpf.
|
||||
set(MACOSX_BUNDLE_ICON_FILE "ownCloud.icns")
|
||||
|
||||
# we must add MACOSX_BUNDLE only if building a bundle
|
||||
@@ -373,8 +368,15 @@ elseif(NOT BUILD_LIBRARIES_ONLY)
|
||||
|
||||
set (QM_DIR ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/Translations)
|
||||
install(FILES ${mirall_I18N} DESTINATION ${QM_DIR})
|
||||
get_target_property(_qmake Qt5::qmake LOCATION)
|
||||
execute_process(COMMAND ${_qmake} -query QT_INSTALL_TRANSLATIONS
|
||||
OUTPUT_VARIABLE QT_TRANSLATIONS_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
file(GLOB qt_I18N ${QT_TRANSLATIONS_DIR}/qt_??.qm ${QT_TRANSLATIONS_DIR}/qt_??_??.qm)
|
||||
install(FILES ${qt_I18N} DESTINATION ${QM_DIR})
|
||||
file(GLOB qtbase_I18N ${QT_TRANSLATIONS_DIR}/qtbase_??.qm ${QT_TRANSLATIONS_DIR}/qt_??_??.qm)
|
||||
install(FILES ${qtbase_I18N} DESTINATION ${QM_DIR})
|
||||
file(GLOB qtkeychain_I18N ${QT_TRANSLATIONS_DIR}/qtkeychain*.qm)
|
||||
install(FILES ${qtkeychain_I18N} DESTINATION ${QM_DIR})
|
||||
endif()
|
||||
@@ -388,7 +390,8 @@ if(NOT BUILD_LIBRARIES_ONLY)
|
||||
RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY}
|
||||
)
|
||||
set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE}" )
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/" )
|
||||
|
||||
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} ${QT_LIBRARIES} )
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
|
||||
@@ -403,18 +406,6 @@ if(NOT BUILD_LIBRARIES_ONLY)
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
#FIXME: find a nice solution to make the second if(BUILD_OWNCLOUD_OSX_BUNDLE) unnecessary
|
||||
# currently it needs to be done because the code right above needs to be executed no matter
|
||||
# if building a bundle or not and the install_qt4_executable needs to be called afterwards
|
||||
if(BUILD_OWNCLOUD_OSX_BUNDLE AND NOT BUILD_LIBRARIES_ONLY)
|
||||
if(Qt5Core_FOUND)
|
||||
install_qt5_executable(${OWNCLOUD_OSX_BUNDLE} "qtaccessiblewidgets;qsqlite;qcocoa")
|
||||
else(Qt5Core_FOUND)
|
||||
install_qt4_executable(${OWNCLOUD_OSX_BUNDLE} "qtaccessiblewidgets;qsqlite")
|
||||
endif(Qt5Core_FOUND)
|
||||
endif()
|
||||
|
||||
find_program(KRAZY2_EXECUTABLE krazy2)
|
||||
if(KRAZY2_EXECUTABLE)
|
||||
# s/y k/y ALL k/ for building this target always
|
||||
@@ -426,7 +417,7 @@ if(KRAZY2_EXECUTABLE)
|
||||
endif()
|
||||
|
||||
set(owncloudcmd_NAME ${APPLICATION_EXECUTABLE}cmd)
|
||||
set(OWNCLOUDCMD_SRC owncloudcmd/simplesslerrorhandler.cpp owncloudcmd/owncloudcmd.cpp)
|
||||
set(OWNCLOUDCMD_SRC owncloudcmd/simplesslerrorhandler.cpp owncloudcmd/owncloudcmd.cpp owncloudcmd/netrcparser.cpp)
|
||||
if(NOT BUILD_LIBRARIES_ONLY)
|
||||
|
||||
add_executable(${owncloudcmd_NAME} ${OWNCLOUDCMD_SRC})
|
||||
@@ -454,3 +445,14 @@ elseif(NOT BUILD_LIBRARIES_ONLY)
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
#FIXME: find a nice solution to make the second if(BUILD_OWNCLOUD_OSX_BUNDLE) unnecessary
|
||||
# currently it needs to be done because the code right above needs to be executed no matter
|
||||
# if building a bundle or not and the install_qt4_executable needs to be called afterwards
|
||||
if(BUILD_OWNCLOUD_OSX_BUNDLE AND NOT BUILD_LIBRARIES_ONLY)
|
||||
get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
|
||||
install(CODE "
|
||||
message(STATUS \"Deploying (Qt) dependencies and fixing library pathes...\")
|
||||
execute_process(COMMAND \"${CMAKE_SOURCE_DIR}/admin/osx/macdeployqt.py\" ${CMAKE_INSTALL_PREFIX}/${OWNCLOUD_OSX_BUNDLE} ${QT_QMAKE_EXECUTABLE})
|
||||
" COMPONENT RUNTIME)
|
||||
endif()
|
||||
|
||||
@@ -36,7 +36,7 @@ AbstractCredentials* create(const QString& type)
|
||||
|
||||
// empty string might happen for old version of configuration
|
||||
if (type == "http" || type == "") {
|
||||
return new HttpCredentials;
|
||||
return new HttpCredentialsGui;
|
||||
} else if (type == "dummy") {
|
||||
return new DummyCredentials;
|
||||
} else if (type == "shibboleth") {
|
||||
|
||||
@@ -37,9 +37,6 @@ using namespace QKeychain;
|
||||
namespace Mirall
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
int getauth(const char *prompt,
|
||||
char *buf,
|
||||
size_t len,
|
||||
@@ -69,15 +66,19 @@ int getauth(const char *prompt,
|
||||
// qDebug() << "OOO Password requested!";
|
||||
qstrncpy( buf, pwd.toUtf8().constData(), len );
|
||||
} else {
|
||||
re = handleNeonSSLProblems(prompt, buf, len, echo, verify, userdata);
|
||||
if( http_credentials->sslIsTrusted() ) {
|
||||
qstrcpy( buf, "yes" ); // Certificate is fine!
|
||||
} else {
|
||||
re = handleNeonSSLProblems(prompt, buf, len, echo, verify, userdata);
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
const char userC[] = "user";
|
||||
const char authenticationFailedC[] = "owncloud-authentication-failed";
|
||||
|
||||
|
||||
} // ns
|
||||
|
||||
class HttpCredentialsAccessManager : public MirallAccessManager {
|
||||
@@ -299,19 +300,6 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
|
||||
}
|
||||
}
|
||||
|
||||
QString HttpCredentials::queryPassword(bool *ok)
|
||||
{
|
||||
if (ok) {
|
||||
QString str = QInputDialog::getText(0, tr("Enter Password"),
|
||||
tr("Please enter %1 password for user '%2':")
|
||||
.arg(Theme::instance()->appNameGUI(), _user),
|
||||
QLineEdit::Password, QString(), ok);
|
||||
return str;
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
void HttpCredentials::invalidateToken(Account *account)
|
||||
{
|
||||
_password = QString();
|
||||
@@ -380,4 +368,17 @@ void HttpCredentials::slotAuthentication(QNetworkReply* reply, QAuthenticator* a
|
||||
reply->close();
|
||||
}
|
||||
|
||||
QString HttpCredentialsGui::queryPassword(bool *ok)
|
||||
{
|
||||
if (ok) {
|
||||
QString str = QInputDialog::getText(0, tr("Enter Password"),
|
||||
tr("Please enter %1 password for user '%2':")
|
||||
.arg(Theme::instance()->appNameGUI(), _user),
|
||||
QLineEdit::Password, QString(), ok);
|
||||
return str;
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
} // ns Mirall
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user