mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-03 11:00:14 -05:00
Merge branch 'master' into android
This commit is contained in:
commit
ea42d822c2
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,7 +5,8 @@
|
||||
moc_*.cpp
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
Makefile.*
|
||||
Makefile*
|
||||
*.sw?
|
||||
*~
|
||||
Thumbs.db
|
||||
*.pro.user
|
||||
|
71
MacOS_X_InstallGuide.md
Normal file
71
MacOS_X_InstallGuide.md
Normal file
@ -0,0 +1,71 @@
|
||||
##Compilation on MacOS
|
||||
|
||||
### Qt Installation
|
||||
|
||||
Install Qt via: [Qt Download](http://www.qt.io/download/)
|
||||
|
||||
Use default options.
|
||||
Add to the PATH environment variable with this temporary solution.
|
||||
|
||||
export PATH=/users/$USER/Qt/5.5/clang_64/bin:$PATH
|
||||
|
||||
Depends on wich version of Qt you use.
|
||||
|
||||
###MacPort Installation
|
||||
|
||||
Install MacPort and XCode following this guide: [MacPort and XCode](http://guide.macports.org/#installing.xcode)
|
||||
|
||||
Start XCode to get it updated and to able C compiler to create executables.
|
||||
|
||||
###Install libraries
|
||||
|
||||
$sudo port -v selfupdate
|
||||
$sudo port install openssl
|
||||
$sudo port install miniupnpc
|
||||
|
||||
For VOIP Plugin:
|
||||
|
||||
$sudo port install speex-devel
|
||||
$sudo port install opencv
|
||||
|
||||
Get Your OSX SDK if missing: [MacOSX-SDKs](https://github.com/phracker/MacOSX-SDKs)
|
||||
|
||||
###Last Settings
|
||||
|
||||
In QtCreator Option Git add its path:
|
||||
|
||||
C:\Program Files\Git\bin
|
||||
|
||||
and select "Pull" with "Rebase"
|
||||
|
||||
###Compil missing libraries
|
||||
####SQLCipher
|
||||
|
||||
cd <your development directory>
|
||||
git clone https://github.com/sqlcipher/sqlcipher.git
|
||||
cd sqlcipher
|
||||
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
|
||||
make
|
||||
sudo make install
|
||||
|
||||
NOTE, might be necessary to *chmod 000 /usr/local/ssl* temporarily during *./configure* if
|
||||
homebrew uses newer, non-stock ssl dependencies found there. configure might get confused.
|
||||
|
||||
####libMicroHTTPD
|
||||
The one with port don't have good support.
|
||||
|
||||
cd <your development directory>
|
||||
wget http://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-0.9.46.tar.gz
|
||||
tar zxvf libmicrohttpd-0.9.46.tar.gz
|
||||
cd libmicrohttpd-0.9.46
|
||||
bash ./configure
|
||||
sudo make install
|
||||
|
||||
You can now compile RS into Qt Creator or with terminal
|
||||
|
||||
cd <your development directory>
|
||||
git clone https://github.com/RetroShare/RetroShare.git retroshare
|
||||
cd retroshare
|
||||
qmake; make
|
||||
|
||||
You can find compiled application on *./retroshare/retroshare-gui/src/RetroShare06.app*
|
@ -1,66 +0,0 @@
|
||||
#############################
|
||||
###--- QT INSTALLATION ---###
|
||||
#############################
|
||||
|
||||
###Install Qt via:
|
||||
http://www.qt.io/download/
|
||||
|
||||
###Use default options.
|
||||
###Add to the PATH environment variable with this temporary solution.
|
||||
export PATH=/users/$USER/Qt/5.5/clang_64/bin:$PATH
|
||||
###Depends on wich version of Qt you use.
|
||||
|
||||
##################################
|
||||
###--- MACPORT INSTALLATION ---###
|
||||
##################################
|
||||
|
||||
###Install MacPort and XCode following this guide:
|
||||
http://guide.macports.org/#installing.xcode
|
||||
|
||||
###Start XCode to get it updated and to able C compiler to create executables.
|
||||
|
||||
###Install libraries
|
||||
$sudo port -v selfupdate
|
||||
$sudo port install openssl
|
||||
$sudo port install miniupnpc
|
||||
###For VOIP Plugin:
|
||||
$sudo port install speex-devel
|
||||
$sudo port install opencv
|
||||
|
||||
###Get Your OSX SDK if missing:
|
||||
https://github.com/phracker/MacOSX-SDKs
|
||||
|
||||
###########################
|
||||
###--- LAST SETTINGS ---###
|
||||
###########################
|
||||
|
||||
###In QtCreator Option Git add its path:
|
||||
C:\Program Files\Git\bin
|
||||
### and select "Pull" with "Rebase"
|
||||
|
||||
###Compil missing libraries
|
||||
###SQLCipher
|
||||
cd <your development directory>
|
||||
git clone https://github.com/sqlcipher/sqlcipher.git
|
||||
cd sqlcipher
|
||||
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
|
||||
make
|
||||
sudo make install
|
||||
#NOTE, might be necessary to chmod 000 /usr/local/ssl temporarily during ./configure if
|
||||
#homebrew uses newer, non-stock ssl dependencies found there. configure might get confused.
|
||||
|
||||
### libMicroHTTPD: The one with port don't have good support.
|
||||
cd <your development directory>
|
||||
wget http://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-0.9.46.tar.gz
|
||||
tar zxvf libmicrohttpd-0.9.46.tar.gz
|
||||
cd libmicrohttpd-0.9.46
|
||||
bash ./configure
|
||||
sudo make install
|
||||
|
||||
###You can now compile RS into Qt Creator or with terminal
|
||||
cd <your development directory>
|
||||
git clone https://github.com/RetroShare/RetroShare.git retroshare
|
||||
cd retroshare
|
||||
qmake;make
|
||||
|
||||
###You can find compiled application on ./retroshare/retroshare-gui/src/RetroShare06.app
|
@ -12,11 +12,11 @@ Build Status
|
||||
|
||||
Compilation on Windows
|
||||
----------------------------
|
||||
Follow this file : [WindowsMSys2_InstallGuide.txt](https://github.com/RetroShare/RetroShare/blob/master/WindowsMSys2_InstallGuide.txt)
|
||||
Follow this file : [WindowsMSys2_InstallGuide.md](https://github.com/RetroShare/RetroShare/blob/master/WindowsMSys2_InstallGuide.md)
|
||||
|
||||
Compilation on MacOSX
|
||||
----------------------------
|
||||
Follow this file : [MacOS_X_InstallGuide.txt](https://github.com/RetroShare/RetroShare/blob/master/MacOS_X_InstallGuide.txt)
|
||||
Follow this file : [MacOS_X_InstallGuide](https://github.com/RetroShare/RetroShare/blob/master/MacOS_X_InstallGuide.md)
|
||||
|
||||
Compilation on Linux
|
||||
----------------------------
|
||||
@ -67,6 +67,11 @@ Compilation on Linux
|
||||
/usr/bin/RetroShare06
|
||||
/usr/bin/RetroShare06-nogui
|
||||
|
||||
5. Uninstall:
|
||||
```bash
|
||||
sudo make uninstall
|
||||
```
|
||||
|
||||
Compile only retroshare-nogui
|
||||
-----------------------------
|
||||
If you want to run RetroShare on a server and don’t need the gui and plugins,
|
||||
|
87
WindowsMSys2_InstallGuide.md
Normal file
87
WindowsMSys2_InstallGuide.md
Normal file
@ -0,0 +1,87 @@
|
||||
##Compilation on Windows
|
||||
|
||||
###Qt Installation
|
||||
|
||||
Install Qt via: [Qt Download](http://www.qt.io/download/)
|
||||
|
||||
Use default options.
|
||||
Add to the PATH environment variable
|
||||
|
||||
;C:\Qt\5.5\mingw492_32\bin;C:\Qt\Tools\mingw492_32\bin;C:\Qt\Tools\mingw492_32\opt\bin
|
||||
|
||||
Depends on wich version of Qt you use.
|
||||
Change build-all-mingw32make.bat with these values too if you don't use MSys2.
|
||||
|
||||
###MSYS2 INSTALLATION
|
||||
|
||||
Choose your MSYS2 installer here: [MSYS2](http://msys2.github.io/)
|
||||
|
||||
Follow install procedure.
|
||||
Don't forget to sync & Update pacman.
|
||||
|
||||
pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
|
||||
|
||||
Restart console
|
||||
|
||||
pacman -Su
|
||||
|
||||
Install all default programms
|
||||
|
||||
pacman -S base-devel git mercurial cvs wget p7zip gcc perl ruby python2
|
||||
|
||||
Choose only w64-i686 if you want only compilation in 32b architecture.
|
||||
|
||||
pacman -S mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain
|
||||
|
||||
###Install other binutils:
|
||||
pacman -S mingw-w64-i686-miniupnpc mingw-w64-x86_64-miniupnpc
|
||||
pacman -S mingw-w64-i686-sqlite3 mingw-w64-x86_64-sqlite3
|
||||
pacman -S mingw-w64-i686-speex mingw-w64-x86_64-speex
|
||||
pacman -S mingw-w64-i686-opencv mingw-w64-x86_64-opencv
|
||||
pacman -S mingw-w64-i686-ffmpeg mingw-w64-x86_64-ffmpeg
|
||||
pacman -S mingw-w64-i686-libmicrohttpd mingw-w64-x86_64-libmicrohttpd
|
||||
pacman -S mingw-w64-i686-libxslt mingw-w64-x86_64-libxslt
|
||||
|
||||
Add MSYS2 to PATH environment variable depends your windows
|
||||
|
||||
;C:\msys64\mingw32\bin
|
||||
;C:\msys32\mingw32\bin
|
||||
|
||||
|
||||
###Git Installation
|
||||
|
||||
Install Git Gui or other client: [Git Scm](https://git-scm.com/download/win)
|
||||
|
||||
Create a new directory named:
|
||||
|
||||
C:\Development\GIT
|
||||
|
||||
Right-click on it and choose: *Git Bash Here*
|
||||
|
||||
Paste this text on git console:
|
||||
git clone https://github.com/RetroShare/RetroShare.git
|
||||
|
||||
|
||||
###Last Settings
|
||||
|
||||
|
||||
In QtCreator Option Git add its path: *C:\Program Files\Git\bin*
|
||||
and select "Pull" with "Rebase"
|
||||
|
||||
|
||||
Open an MSys2 32|64 shell
|
||||
Move to build_scripts:
|
||||
|
||||
cd /c/Development/GIT/RetroShare/msys2_build_libs/
|
||||
|
||||
###Compile missing library
|
||||
make
|
||||
|
||||
You can now compile RS into Qt Creator
|
||||
|
||||
For using, and debugging Plugins, you can use [Symlinker](http://amd989.github.io/Symlinker/) to link
|
||||
the files in
|
||||
|
||||
\build-RetroShare-Desktop_Qt_X_Y_Z_MinGW_32bit-Debug\plugins\PluginName\debug\*.dll
|
||||
to
|
||||
*%appdata%\RetroShare\extensions6*
|
@ -1,89 +0,0 @@
|
||||
#############################
|
||||
###--- QT INSTALLATION ---###
|
||||
#############################
|
||||
|
||||
###Install Qt via:
|
||||
http://www.qt.io/download/
|
||||
|
||||
###Use default options.
|
||||
###Add to the PATH environment variable.
|
||||
;C:\Qt\5.5\mingw492_32\bin;C:\Qt\Tools\mingw492_32\bin;C:\Qt\Tools\mingw492_32\opt\bin
|
||||
|
||||
###Depends on wich version of Qt you use.
|
||||
|
||||
###Change build-all-mingw32make.bat with these values too if you don't use MSys2.
|
||||
|
||||
|
||||
###############################
|
||||
###---MSYS2 INSTALLATION ---###
|
||||
###############################
|
||||
|
||||
###Choose your MSYS2 installer here:
|
||||
http://msys2.github.io/
|
||||
|
||||
###Follow install procedure.
|
||||
###Don't forget to sync & Update pacman.
|
||||
pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
|
||||
|
||||
###Restart console
|
||||
pacman -Su
|
||||
|
||||
###Install all default programms
|
||||
pacman -S base-devel git mercurial cvs wget p7zip gcc perl ruby python2
|
||||
|
||||
###Choose only w64-i686 if you want only compilation in 32b architecture.
|
||||
pacman -S mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain
|
||||
|
||||
###Install other binutils:
|
||||
pacman -S mingw-w64-i686-miniupnpc mingw-w64-x86_64-miniupnpc
|
||||
pacman -S mingw-w64-i686-sqlite3 mingw-w64-x86_64-sqlite3
|
||||
pacman -S mingw-w64-i686-speex mingw-w64-x86_64-speex
|
||||
pacman -S mingw-w64-i686-opencv mingw-w64-x86_64-opencv
|
||||
pacman -S mingw-w64-i686-ffmpeg mingw-w64-x86_64-ffmpeg
|
||||
pacman -S mingw-w64-i686-libmicrohttpd mingw-w64-x86_64-libmicrohttpd
|
||||
pacman -S mingw-w64-i686-libxslt mingw-w64-x86_64-libxslt
|
||||
|
||||
### Add MSYS2 to PATH environment variable depends your windows
|
||||
;C:\msys64\mingw32\bin
|
||||
;C:\msys32\mingw32\bin
|
||||
|
||||
|
||||
##############################
|
||||
###--- GIT INSTALLATION ---###
|
||||
##############################
|
||||
|
||||
###Install Git Gui or other client:
|
||||
https://git-scm.com/download/win
|
||||
|
||||
###Create a new directory named:
|
||||
C:\Development\GIT
|
||||
|
||||
###Right-click on it and choose:
|
||||
Git Bash Here
|
||||
|
||||
###Paste this text on git console:
|
||||
git clone https://github.com/RetroShare/RetroShare.git
|
||||
|
||||
|
||||
###########################
|
||||
###--- LAST SETTINGS ---###
|
||||
###########################
|
||||
|
||||
###In QtCreator Option Git add its path:
|
||||
C:\Program Files\Git\bin
|
||||
### and select "Pull" with "Rebase"
|
||||
|
||||
|
||||
###Open an MSys2 32|64 shell
|
||||
###Move to build_scripts:
|
||||
cd /c/Development/GIT/RetroShare/msys2_build_libs/
|
||||
|
||||
###Compil missing library
|
||||
make
|
||||
|
||||
###You can now compile RS into Qt Creator
|
||||
|
||||
###For using, and debugging Plugins, you can use SymLinker (http://amd989.github.io/Symlinker/) to link
|
||||
### the files in \build-RetroShare-Desktop_Qt_X_Y_Z_MinGW_32bit-Debug\plugins\PluginName\debug\*.dll
|
||||
### to %appdata%\RetroShare\extensions6
|
||||
|
@ -1,5 +1,144 @@
|
||||
retroshare06 (0.6.1-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
|
||||
|
||||
9a3eb1c csoler Sat, 8 Oct 2016 14:30:58 +0200 Merge pull request #528 from sehraf/pr-drop-ssh-protobuf
|
||||
c55fb0d csoler Sat, 8 Oct 2016 14:11:43 +0200 Merge pull request #524 from cavebeat/compile
|
||||
97f2589 csoler Sat, 8 Oct 2016 14:09:34 +0200 Merge pull request #513 from grennvyper/patch-1
|
||||
aa200bf csoler Sat, 8 Oct 2016 14:06:54 +0200 Merge pull request #526 from marcobarbosa16/master
|
||||
2591818 csoler Sat, 8 Oct 2016 14:04:31 +0200 Merge pull request #515 from PhenomRetroShare/Add_ContextMenuToShowImageInLobby
|
||||
9ed759d csoler Sat, 8 Oct 2016 13:38:18 +0200 Merge pull request #527 from PhenomRetroShare/Fix_DesktopFileName
|
||||
ada1cee sehraf Sat, 8 Oct 2016 12:59:27 +0200 remove deprecated ssh/protobuf code
|
||||
4b0f82a Phenom Sat, 8 Oct 2016 12:12:26 +0200 Fix Desktop Filename for option page message.
|
||||
69ecca4 MarcoBarbosa Fri, 7 Oct 2016 23:12:40 -0300 add uninstall section in README.md
|
||||
7cd31aa csoler Wed, 5 Oct 2016 14:15:12 +0200 fixed bug preventign update of subdirs after last commit
|
||||
fdfd2e9 Phenom Sat, 24 Sep 2016 16:12:44 +0200 Add context menu to show hidden image on lobby.
|
||||
854eebb csoler Wed, 5 Oct 2016 10:59:51 +0200 only update subfiles and subdirs list during dir watching sweep when the TS of the dir has changed. Greatly improve cost of regular directory watching process
|
||||
d020d8d thunder2 Wed, 5 Oct 2016 06:40:02 +0200 Windows build environment: - Added automatic mode for creating git-log - Fixed filename of installer
|
||||
891e61e cave beat Tue, 4 Oct 2016 23:27:40 +0200 MacOS to .md, + README update
|
||||
9177c82 cave beat Tue, 4 Oct 2016 23:14:50 +0200 updated MSys2 Install Guide to .md
|
||||
d367491 thunder2 Tue, 4 Oct 2016 21:45:59 +0200 Fixed env.bat for Windows build
|
||||
20cd123 csoler Tue, 4 Oct 2016 21:41:38 +0200 removed annoying ERROR output that is more a debug info than a real error, in p3filelists
|
||||
e42dae8 csoler Tue, 4 Oct 2016 21:34:23 +0200 continue sending packet slicing probes in case the peer has restarted
|
||||
b08a62a csoler Tue, 4 Oct 2016 21:25:48 +0200 restored delay between location cleaning to 5 mins
|
||||
133676f csoler Tue, 4 Oct 2016 21:24:53 +0200 simplified the code to remove old locations and fixed bug that in some situation would let a PGP key with no locations
|
||||
a35985e thunder2 Tue, 6 Sep 2016 21:31:41 +0200 Windows build environment: - Added build script - Added build-installer script - Added pack script - Added gitlog script - Use shadow build
|
||||
ebfc82c csoler Mon, 3 Oct 2016 21:44:34 +0200 save/restore selection in shared dir list tree view
|
||||
ed8d786 csoler Mon, 3 Oct 2016 20:49:49 +0200 added missing mChanged=false that caused remote directories to save far too often
|
||||
c968490 csoler Sat, 1 Oct 2016 22:14:50 +0200 switched to floating point time for bandwidth estimation in pqistreamer. Helps a lot RTTs since rounding to int prveviously caused packets to be delayed up to 1 sec (improvement by Jollavilette)
|
||||
20397c3 csoler Sat, 1 Oct 2016 18:09:39 +0200 Merge pull request #523 from bryongloden/patch-1
|
||||
9ae0511 Bryon Gloden Sat, 1 Oct 2016 12:01:09 -0400 uninitialized variable: size
|
||||
a751155 csoler Sat, 1 Oct 2016 15:46:32 +0200 do not send un-hashed files to friends, and allow to re-send the directory content when all files are hashed
|
||||
84341f2 csoler Thu, 29 Sep 2016 22:30:26 +0200 changed _outgoing_file_hashes into a new map that connects services to tunnel ID instead of file hash, hence avoiding to remove a hash on server side when a tunnel is closed (bug found by Jolavillette)
|
||||
b62b66a csoler Thu, 29 Sep 2016 20:55:16 +0200 replace std::vector for std::set to represent _hashes_to_remove, so as to avoid duplicates (suggested by Jo)
|
||||
1fd624c csoler Thu, 29 Sep 2016 12:47:14 +0200 Merge pull request #519 from PhenomRetroShare/Fix_WinCompil
|
||||
0ea909d Phenom Thu, 29 Sep 2016 12:45:01 +0200 Fix Windows Compilation after 6e4ba76b
|
||||
e185bcd csoler Wed, 28 Sep 2016 23:02:24 +0200 fixed removal of directory when removing a friend
|
||||
c276165 csoler Wed, 28 Sep 2016 22:28:43 +0200 updated clean.sh script to 0.6.1
|
||||
|
||||
-- Cyril Soler <csoler@users.sourceforge.net> Sat, 8 Oct 2016 15:00:00 +0100
|
||||
|
||||
retroshare06 (0.6.1-1.20160928.e185bcda~trusty) trusty; urgency=low
|
||||
|
||||
Warning: new file list sharing system.
|
||||
* Old list of shares is not preserved and should be re-defined.
|
||||
* The hash cache however is imported from the old format, meaning that Retroshare should not re-hash new files that were already shared before.
|
||||
* New system offers interactive browsing of shared dirs from online friends and background update of directory lists
|
||||
* The old cachestrapper system is removed since it is now obsolete.
|
||||
|
||||
6e4ba76 csoler Wed, 28 Sep 2016 21:55:03 +0200 improved display of shared directories for friends with no update info
|
||||
1d977dd csoler Wed, 28 Sep 2016 16:39:48 +0200 Merge pull request #518 from PhenomRetroShare/Fix_InternalFileHierarchyStorage__check
|
||||
9672fe3 Phenom Wed, 28 Sep 2016 11:35:44 +0200 Fix InternalFileHierarchyStorage::check, error_string will never be shown as always return true.
|
||||
bf0777f csoler Tue, 27 Sep 2016 23:13:59 +0200 fixed update of DirHash list and FileHash list when files and dirs are removed, while keeping the cost low
|
||||
5547d71 csoler Tue, 27 Sep 2016 21:09:13 +0200 fixed advanced search not closing
|
||||
c26970f csoler Tue, 27 Sep 2016 20:20:12 +0200 fixed open folder from File Sharing dialog
|
||||
37a4e77 csoler Tue, 27 Sep 2016 20:13:02 +0200 removed debug info in directory_storage.cc
|
||||
2916c8b csoler Tue, 27 Sep 2016 10:13:51 +0200 removed debug output in folderiterator
|
||||
0bcb6c3 csoler Tue, 27 Sep 2016 09:59:51 +0200 Merge pull request #517 from sehraf/pr-filelist-fixes
|
||||
9d72b06 sehraf Tue, 27 Sep 2016 09:50:59 +0200 add thread names & remove some warnings
|
||||
a2ff5d2 csoler Mon, 26 Sep 2016 22:06:30 +0200 simplified p3FileList code a little bit: removed mFriendIndexTab and made locked_getFriendIndex() create the remote directories on demand
|
||||
fc1a350 csoler Mon, 26 Sep 2016 21:12:13 +0200 added automated import of old hash cache in order to avoid re-hashing everything when switching to the new system
|
||||
15f69b2 csoler Mon, 26 Sep 2016 11:11:22 +0200 fixed crash in debug output in p3filelists
|
||||
b95fbe3 csoler Mon, 26 Sep 2016 10:49:59 +0200 added a few more missing checks for null entries in mRemoteDirectories
|
||||
3beaa97 csoler Mon, 26 Sep 2016 10:03:51 +0200 fixed potential crash when an entry in mRemoteDirectories is NULL
|
||||
1125dfe csoler Sun, 25 Sep 2016 23:42:20 +0200 fixed folder iterator to properly handle broken symbolic links
|
||||
be6370e csoler Sun, 25 Sep 2016 21:34:18 +0200 added missing code for searchTerms in new p3filelists service
|
||||
93e70ca csoler Sun, 25 Sep 2016 21:01:03 +0200 fixed search on remote files
|
||||
068955d csoler Sun, 25 Sep 2016 18:51:33 +0200 fixed up a few debug messages in p3filelists
|
||||
bb4b577 csoler Sun, 25 Sep 2016 18:44:28 +0200 prevent storage for hash of files that cannot be hashed
|
||||
ddc870c csoler Sun, 25 Sep 2016 11:05:01 +0200 added some more debug info in DirectoryStorage class
|
||||
19b1c4f csoler Sun, 25 Sep 2016 11:04:42 +0200 fixed potential crash due to not checking if mRemoteDirectory[i] is empty in p3FileLists
|
||||
cb4dc96 csoler Sat, 24 Sep 2016 17:12:38 +0200 removed debug info in p3filelists
|
||||
ee54c02 csoler Sat, 24 Sep 2016 14:47:45 +0200 merged branch v0.6-FileLists locally into master
|
||||
52ee76e csoler Sat, 24 Sep 2016 14:14:32 +0200 removed annoying debug message in ID system
|
||||
34f1ebb csoler Sat, 24 Sep 2016 14:13:38 +0200 Merge pull request #507 from mr-alice/v0.6-FileLists
|
||||
e03bd6c mr-alice Sat, 24 Sep 2016 13:56:02 +0200 fixed bug causing call to closedir on invalid handle
|
||||
96b333d Mr.Alice Sat, 24 Sep 2016 09:04:25 +0200 Merge pull request #1 from hunbernd/v0.6-FileLists
|
||||
8500b5e hunbernd Fri, 23 Sep 2016 21:56:41 +0200 Fixed inconsistency in integer sizes that caused segmentation fault while hashing files also broken message on the GUI
|
||||
71a5bff mr-alice Fri, 23 Sep 2016 20:07:57 +0200 added small hack against re-hashing due to stat64 depending on local time on windows
|
||||
70c8e14 hunbernd Fri, 23 Sep 2016 19:00:07 +0200 Fix folderiterator.cc:23: error: cannot convert '_stat64*' to '_stati64*' for argument '2' to 'int _wstati64(const wchar_t*, _stati64*)'
|
||||
529ab64 hunbernd Fri, 23 Sep 2016 18:43:48 +0200 Fixed missing time.h includes
|
||||
ca281e4 hunbernd Fri, 23 Sep 2016 18:32:36 +0200 Fixed error with 32 bit GCC Both uint32_t and size_t are resolved to unsigned int, it makes 2 lines conflicted. This happens in filelist_io.cc, lines: 31-32, 36-37, 41-42
|
||||
9ce4b13 mr-alice Fri, 23 Sep 2016 19:03:54 +0200 merged upstream/master
|
||||
9f76b76 mr-alice Fri, 23 Sep 2016 19:01:14 +0200 forced closedir in order to avoid leak of file descriptor in FolderIterator
|
||||
7bddd4b csoler Fri, 23 Sep 2016 13:18:55 +0200 removed call to exit causing the software to stop when local network interfaces are not ready
|
||||
0cc4ebd mr-alice Thu, 22 Sep 2016 21:47:58 +0200 added comments in the file lists code. Removed unused functions. Added a few missing mutexes.
|
||||
e6e9582 csoler Thu, 22 Sep 2016 13:44:53 +0200 fixed bug in estimation of next FT rate that caused downloads to stuck for a while
|
||||
7f99bc2 mr-alice Thu, 22 Sep 2016 10:26:05 +0200 fixed compilation after removal of dbase/
|
||||
1be5990 mr-alice Wed, 21 Sep 2016 22:31:39 +0200 disabled dbase from unittests.pro, which should be cnverted into proper tests for file_sharing.
|
||||
0f5cf56 mr-alice Wed, 21 Sep 2016 22:27:53 +0200 removed dbase directory
|
||||
0757fb3 mr-alice Tue, 20 Sep 2016 20:51:50 +0200 merged upstream/master
|
||||
7488ad4 mr-alice Sun, 18 Sep 2016 22:32:30 +0200 added display of files being hashed with green color and blue icon. This could be improved I suppose.
|
||||
0579fb0 mr-alice Sun, 18 Sep 2016 22:14:25 +0200 removed unused tickWatchers()
|
||||
9cf9504 mr-alice Sun, 18 Sep 2016 22:05:27 +0200 removed most of debug info in file list sharing code
|
||||
ff4c438 mr-alice Sun, 18 Sep 2016 21:41:18 +0200 fixed reloading of ShareManager due to postModDirectories and made it reload after addign new share
|
||||
e4568a8 mr-alice Sun, 18 Sep 2016 21:16:25 +0200 removed some unused code
|
||||
de104d3 mr-alice Sun, 18 Sep 2016 18:34:39 +0200 fixed up GUI parameters in Directories. Removed HashCache duration handles since this is now automatic
|
||||
04c908e MrAlice Fri, 16 Sep 2016 09:35:03 +0200 fixed two bugs in dirlist chunking system causing checksum errors
|
||||
3f9acb5 mr-alice Thu, 15 Sep 2016 23:51:46 +0200 added item splitting and checksum checking in p3filelists
|
||||
2343c91 mr-alice Thu, 15 Sep 2016 21:40:53 +0200 added display of hash progress
|
||||
d3b4622 mr-alice Thu, 15 Sep 2016 21:45:00 +0200 merged modifications from origin
|
||||
ca30b0d MrAlice Thu, 15 Sep 2016 10:41:40 +0200 fixed terrible cost of calling requestDirDetails before createIndex
|
||||
f58e9c1 mr-alice Wed, 14 Sep 2016 22:41:02 +0200 improved debug output of directory storage, and fixed bug causing loading error (previously crashing files should be removed)
|
||||
ddc89a6 mr-alice Wed, 14 Sep 2016 21:52:16 +0200 fixed core dump in printout of empty slots. Improved dir sync-ing strategy
|
||||
e985a2c mr-alice Wed, 14 Sep 2016 20:43:52 +0200 removed call to setDynamicSortFilter in SharedFilesDialog, as a workaround for the crash when sorting
|
||||
afbb641 mr-alice Wed, 14 Sep 2016 20:41:22 +0200 fixed forceDirectoryCheck and inDirectoryCheck methods
|
||||
93818f6 mr-alice Tue, 13 Sep 2016 21:23:27 +0200 simplified a bit the code in Flat_Model, and tried to fix the crash when sorting items
|
||||
53c65ff mr-alice Tue, 13 Sep 2016 18:54:00 +0200 removed cache transfers from the GUI
|
||||
02d2fb4 mr-alice Tue, 13 Sep 2016 13:53:51 +0200 fixed search and filter for regular expressions and terms
|
||||
6ac9b27 mr-alice Tue, 13 Sep 2016 12:14:16 +0200 moved rsexpr.cc into util/
|
||||
a2e34f9 mr-alice Tue, 13 Sep 2016 12:05:22 +0200 moved regular expression classes into a separate namespace
|
||||
e9418bb mr-alice Tue, 13 Sep 2016 00:01:26 +0200 added file headers with proper licence terms
|
||||
9f66c00 mr-alice Mon, 12 Sep 2016 23:37:19 +0200 moved rsexpr to file_sharing directory
|
||||
274f924 mr-alice Mon, 12 Sep 2016 20:55:20 +0200 fixed getFileInfo and transfer from new database
|
||||
af69790 csoler Mon, 12 Sep 2016 10:15:13 +0200 added control file for debian jessie
|
||||
c1e538f mr-alice Sun, 11 Sep 2016 17:52:12 +0200 added interactive update of dir entries when browsing files from an online friend
|
||||
3718e7e mr-alice Sat, 10 Sep 2016 20:47:51 +0200 fixed last bugs in hash-based dir list exchange. It works!
|
||||
88f8538 mr-alice Sat, 10 Sep 2016 17:25:29 +0200 fixed a few bugs in hash-based syncing
|
||||
384d001 mr-alice Sat, 10 Sep 2016 13:57:05 +0200 progress in hash-based sync. Not there yet.
|
||||
0ea695b mr-alice Thu, 8 Sep 2016 23:43:14 +0200 fixed a few bugs in hash-based sync. Not there yet.
|
||||
fafe684 mr-alice Thu, 8 Sep 2016 21:34:53 +0200 finished implementing hash-based transactions. To be tested.
|
||||
e3d12c4 csoler Thu, 8 Sep 2016 17:08:34 +0200 Merge pull request #491 from G10h4ck/warnings_cleanup
|
||||
eaa8ad8 MrAlice Wed, 7 Sep 2016 22:31:12 +0200 half implemented the hash-based communication for dirs between friends
|
||||
ea380b2 csoler Wed, 7 Sep 2016 21:29:48 +0200 Merge pull request #487 from AsamK/fix_wayland
|
||||
798ffd8 csoler Wed, 7 Sep 2016 21:28:28 +0200 Merge pull request #488 from sehraf/pr-stats-api
|
||||
ad1ba7a mr-alice Tue, 6 Sep 2016 23:05:46 +0200 fixed loading/saving of remote directories
|
||||
e9540d7 defnax Tue, 6 Sep 2016 17:45:42 +0200 Improved look and feel layout of Profile Generation Dialog
|
||||
679c53b mr-alice Mon, 5 Sep 2016 21:22:11 +0200 added load/save of directory hierarchies. Fixed bug in loading of hash cache (caused y non initialisation of dest string in GetRawString())
|
||||
5f5ce4a thunder2 Tue, 17 May 2016 19:02:14 +0200 Fixed version_detail_bash_script with shadow build
|
||||
ea6431e thunder2 Mon, 5 Sep 2016 14:03:39 +0200 Fixed Windows shadow build with Qt 5.6 or higher
|
||||
5b221c5 mr-alice Sat, 3 Sep 2016 18:46:03 +0200 moved encrypted data output/input to FileListIO
|
||||
371171f mr-alice Sat, 3 Sep 2016 13:29:23 +0200 moved InternalFileHierarchyStorage to separate file. Fixed loading/saving infrastructure (not working yet)
|
||||
153783a mr-alice Fri, 2 Sep 2016 22:08:27 +0200 fixed bug in saving hash cache
|
||||
7b566f2 mr-alice Fri, 2 Sep 2016 21:49:43 +0200 added load/save for hash cache in the proper place
|
||||
52ef7ad mr-alice Thu, 1 Sep 2016 21:41:12 +0200 fixed saving of config when diretory list is changed
|
||||
6fc02e0 mr-alice Thu, 1 Sep 2016 21:04:48 +0200 added load/save of configuration and shared dirs list
|
||||
f191fe6 mr-alice Thu, 1 Sep 2016 20:02:47 +0200 fixed compilation with new RsNodeGroupId
|
||||
ade6017 mr-alice Thu, 1 Sep 2016 19:52:31 +0200 merged with upstream/master
|
||||
1f3ea6f mr-alice Wed, 31 Aug 2016 22:47:05 +0200 added selection of subdirs to be seen for friends depending on permissions. Enabled dynamic update at friends
|
||||
|
||||
-- Cyril Soler <csoler@users.sourceforge.net> Wed, 28 Sep 2016 22:00:00 +0100
|
||||
|
||||
retroshare06 (0.6.1-1.20160831.53e26983~trusty) trusty; urgency=low
|
||||
|
||||
Release of version 0.6.1.
|
||||
* See detailed logs: https://github.com/RetroShare/RetroShare/blob/master/build_scripts/Debian%2BUbuntu/changelog
|
||||
* Release blog post: https://retroshareteam.wordpress.com
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -f ./libssh-0.5.4.tar.gz.*
|
||||
rm -f ./retroshare06_0.6.0-1.*_source.build
|
||||
rm -f ./retroshare06_0.6.0-1.*_source.changes
|
||||
rm -f ./retroshare06_0.6.0-1.*.tar.gz
|
||||
rm -f ./retroshare06_0.6.0-1.*.diff.gz
|
||||
rm -f ./retroshare06_0.6.0-1.*.dsc
|
||||
rm -f ./retroshare06_0.6.1-1.*_source.build
|
||||
rm -f ./retroshare06_0.6.1-1.*_source.changes
|
||||
rm -f ./retroshare06_0.6.1-1.*.tar.gz
|
||||
rm -f ./retroshare06_0.6.1-1.*.diff.gz
|
||||
rm -f ./retroshare06_0.6.1-1.*.dsc
|
||||
rm -f *.upload
|
||||
|
||||
rm -f *~
|
||||
|
44
build_scripts/Debian+Ubuntu/control.jessie
Normal file
44
build_scripts/Debian+Ubuntu/control.jessie
Normal file
@ -0,0 +1,44 @@
|
||||
Source: retroshare06
|
||||
Section: devel
|
||||
Priority: standard
|
||||
Maintainer: Cyril Soler <csoler@users.sourceforge.net>
|
||||
Build-Depends: debhelper (>= 7), libglib2.0-dev, libupnp-dev, libssl-dev, libxss-dev, libgnome-keyring-dev, libbz2-dev, libspeex-dev, libspeexdsp-dev, libxslt1-dev, cmake, libcurl4-openssl-dev, libopencv-dev, tcl8.6, libsqlcipher-dev, libmicrohttpd-dev, libavcodec-dev, qtmultimedia5-dev, qttools5-dev, libqt5x11extras5-dev, qt5-default
|
||||
Standards-Version: 3.9.6
|
||||
Homepage: http://retroshare.sourceforge.net
|
||||
|
||||
Package: retroshare06-voip-plugin
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare06, libspeex1, libspeexdsp1, libqt5multimedia5
|
||||
Description: RetroShare VOIP plugin
|
||||
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
|
||||
plateform. The plugin adds voice-over-IP functionality to the private chat window. Both
|
||||
friends chatting together need the plugin installed to be able to talk together.
|
||||
|
||||
Package: retroshare06-feedreader-plugin
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare06
|
||||
Description: RetroShare FeedReader plugin
|
||||
This package provides a plugin for RetroShare, a secured Friend-to-Friend communication
|
||||
plateform. The plugin adds a RSS feed reader tab to retroshare.
|
||||
|
||||
Package: retroshare06-nogui
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring
|
||||
Conflicts: retroshare06
|
||||
Description: Secure communication with friends
|
||||
This is the command-line client for RetroShare network. This client
|
||||
can be contacted and talked-to using SSL. Clients exist for portable
|
||||
devices running e.g. Android.
|
||||
|
||||
Package: retroshare06
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring
|
||||
Conflicts: retroshare06-nogui
|
||||
Description: Secure communication with friends
|
||||
RetroShare is a Open Source cross-platform, private and secure decentralised
|
||||
commmunication platform. It lets you to securely chat and share files with your
|
||||
friends and family, using a web-of-trust to authenticate peers and OpenSSL to
|
||||
encrypt all communication. RetroShare provides filesharing, chat, messages,
|
||||
forums and channels.
|
||||
|
||||
|
@ -20,6 +20,12 @@ dist=""
|
||||
# This is the key for "Cyril Soler <csoler@sourceforge.net>"
|
||||
gpgkey="0932399B"
|
||||
|
||||
date=`git log --pretty=format:"%ai" | head -1 | cut -d\ -f1 | sed -e s/-//g`
|
||||
time=`git log --pretty=format:"%aD" | head -1 | cut -d\ -f5 | sed -e s/://g`
|
||||
hhsh=`git log --pretty=format:"%H" | head -1 | cut -c1-8`
|
||||
|
||||
rev=${date}.${hhsh}
|
||||
|
||||
while [ ${#} -gt 0 ]; do
|
||||
case ${1} in
|
||||
"-rev") shift
|
||||
@ -54,12 +60,6 @@ echo Attempting to get revision number...
|
||||
ccount=`git rev-list --count --all`
|
||||
ccount=`expr $ccount + 8613 - 8267`
|
||||
|
||||
date=`git log --pretty=format:"%ai" | head -1 | cut -d\ -f1 | sed -e s/-//g`
|
||||
time=`git log --pretty=format:"%aD" | head -1 | cut -d\ -f5 | sed -e s/://g`
|
||||
hhsh=`git log --pretty=format:"%H" | head -1 | cut -c1-8`
|
||||
|
||||
rev=${date}.${hhsh}
|
||||
|
||||
echo " "Using PGP key id : ${gpgkey}
|
||||
echo " "Using distributions: ${dist}
|
||||
echo " "Commit count : ${ccount}
|
||||
@ -137,7 +137,8 @@ for i in ${dist}; do
|
||||
cp ../control.xenial debian/control
|
||||
elif test "${i}" = "stretch" ; then
|
||||
cp ../control.${i} debian/control
|
||||
cp ../rules.${i} debian/rules
|
||||
elif test "${i}" = "jessie" ; then
|
||||
cp ../control.${i} debian/control
|
||||
else
|
||||
cp ../debian/control debian/control
|
||||
fi
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
for i in `ls retroshare06_0.6.0-1.*.changes` ; do
|
||||
for i in `ls retroshare06_0.6.1-1.*.changes` ; do
|
||||
dput ppa:retroshare/unstable $i
|
||||
done
|
||||
|
1
build_scripts/Windows/.gitignore
vendored
Normal file
1
build_scripts/Windows/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build/env-mod.bat
|
56
build_scripts/Windows/build/build-installer.bat
Normal file
56
build_scripts/Windows/build/build-installer.bat
Normal file
@ -0,0 +1,56 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0..\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
call "%EnvPath%\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
:: Get gcc versions
|
||||
call "%ToolsPath%\get-gcc-version.bat" GCCVersion
|
||||
if "%GCCVersion%"=="" echo Cannot get gcc version.& exit /B 1
|
||||
|
||||
:: Check external libraries
|
||||
if not exist "%RootPath%\libs" echo Please build external libraries first.& exit /B 1
|
||||
|
||||
:: Check gcc version of external libraries
|
||||
if not exist "%RootPath%\libs\gcc-version" echo Cannot get gcc version of external libraries.& exit /B 1
|
||||
set /P LibsGCCVersion=<"%RootPath%\libs\gcc-version"
|
||||
if "%LibsGCCVersion%" NEQ "%GCCVersion%" echo Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%).& exit /B 1
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
:: Build defines for script
|
||||
set NSIS_PARAM=
|
||||
|
||||
set NSIS_PARAM=%NSIS_PARAM% /DRELEASEDIR="%RsBuildPath%"
|
||||
set NSIS_PARAM=%NSIS_PARAM% /DQTDIR="%QtPath%\.."
|
||||
set NSIS_PARAM=%NSIS_PARAM% /DMINGWDIR="%MinGWPath%\.."
|
||||
set NSIS_PARAM=%NSIS_PARAM% /DOUTDIR="%RsPackPath%"
|
||||
set NSIS_PARAM=%NSIS_PARAM% /DINSTALLERADD="%RsArchiveAdd%"
|
||||
|
||||
:: Scan version from source
|
||||
set RsRevision=
|
||||
set RsBuildAdd=
|
||||
call "%ToolsPath%\get-rs-version.bat" RS_REVISION_STRING RsRevision
|
||||
if "%RsRevision%"=="" echo Revision not found.& exit /B 1
|
||||
call "%ToolsPath%\get-rs-version.bat" RS_BUILD_NUMBER_ADD RsBuildAdd
|
||||
if errorlevel 1 exit /B 1
|
||||
|
||||
set NSIS_PARAM=%NSIS_PARAM% /DREVISION=%RsRevision% /DBUILDADD=%RsBuildAdd%
|
||||
|
||||
set QtMainVersion=%QtVersion:~0,1%
|
||||
|
||||
:: Create installer
|
||||
"%EnvMakeNSISExe%" %NSIS_PARAM% "%SourcePath%\build_scripts\Windows\installer\retroshare-Qt%QtMainVersion%.nsi"
|
||||
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:error_env
|
||||
echo Failed to initialize environment.
|
||||
endlocal
|
||||
exit /B 1
|
81
build_scripts/Windows/build/build.bat
Normal file
81
build_scripts/Windows/build/build.bat
Normal file
@ -0,0 +1,81 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0..\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
call "%EnvPath%\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
:: Get gcc versions
|
||||
call "%ToolsPath%\get-gcc-version.bat" GCCVersion
|
||||
if "%GCCVersion%"=="" echo Cannot get gcc version.& exit /B 1
|
||||
|
||||
:: Check external libraries
|
||||
if not exist "%RootPath%\libs" echo Please build external libraries first.& exit /B 1
|
||||
|
||||
:: Check gcc version of external libraries
|
||||
if not exist "%RootPath%\libs\gcc-version" echo Cannot get gcc version of external libraries.& exit /B 1
|
||||
set /P LibsGCCVersion=<"%RootPath%\libs\gcc-version"
|
||||
if "%LibsGCCVersion%" NEQ "%GCCVersion%" echo Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%).& exit /B 1
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
:: Check git executable
|
||||
set GitPath=
|
||||
call "%ToolsPath%\find-in-path.bat" GitPath git.exe
|
||||
if "%GitPath%" NEQ "" goto found_git
|
||||
choice /M "Git not found in PATH. Version information cannot be calculated. Do you want to proceed?"
|
||||
if %errorlevel%==2 exit /B 1
|
||||
:found_git
|
||||
|
||||
echo.
|
||||
echo === Version
|
||||
echo.
|
||||
|
||||
title Build - %SourceName%-%RsBuildConfig% [Version]
|
||||
|
||||
pushd "%SourcePath%\retroshare-gui\src\gui\images"
|
||||
:: Touch resource file
|
||||
copy /b retroshare_win.rc +,,
|
||||
popd
|
||||
|
||||
if not exist "%RsBuildPath%" mkdir "%RsBuildPath%"
|
||||
pushd "%RsBuildPath%"
|
||||
|
||||
echo.
|
||||
echo === qmake
|
||||
echo.
|
||||
|
||||
title Build - %SourceName%-%RsBuildConfig% [qmake]
|
||||
|
||||
qmake "%SourcePath%\RetroShare.pro" -r "CONFIG+=%RsBuildConfig% version_detail_bash_script"
|
||||
if errorlevel 1 goto error
|
||||
|
||||
echo.
|
||||
echo === make
|
||||
echo.
|
||||
|
||||
title Build - %SourceName%-%RsBuildConfig% [make]
|
||||
|
||||
if exist "%EnvJomExe%" (
|
||||
"%EnvJomExe%"
|
||||
) else (
|
||||
mingw32-make
|
||||
)
|
||||
|
||||
:error
|
||||
popd
|
||||
|
||||
title %COMSPEC%
|
||||
|
||||
if errorlevel 1 echo.& echo Build failed& echo.
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:error_env
|
||||
echo Failed to initialize environment.
|
||||
endlocal
|
||||
exit /B 1
|
21
build_scripts/Windows/build/clean.bat
Normal file
21
build_scripts/Windows/build/clean.bat
Normal file
@ -0,0 +1,21 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0..\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
call "%EnvPath%\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
call "%~dp0env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
if not exist "%RsBuildPath%" exit /B 0
|
||||
call "%ToolsPath%\remove-dir.bat" "%RsBuildPath%"
|
||||
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:error_env
|
||||
echo Failed to initialize environment.
|
||||
endlocal
|
||||
exit /B 1
|
33
build_scripts/Windows/build/env.bat
Normal file
33
build_scripts/Windows/build/env.bat
Normal file
@ -0,0 +1,33 @@
|
||||
set CurPath=%~dp0
|
||||
set BuildPath=%EnvRootPath%\builds
|
||||
set DeployPath=%EnvRootPath%\deploy
|
||||
|
||||
if not exist "%BuildPath%" mkdir "%BuildPath%"
|
||||
if not exist "%DeployPath%" mkdir "%DeployPath%"
|
||||
|
||||
:: Check Qt environment
|
||||
set QtPath=
|
||||
call "%ToolsPath%\find-in-path.bat" QtPath qmake.exe
|
||||
if "%QtPath%"=="" echo Please run command in the Qt Command Prompt.& exit /B 1
|
||||
|
||||
:: Check MinGW environment
|
||||
set MinGWPath=
|
||||
call "%ToolsPath%\find-in-path.bat" MinGWPath gcc.exe
|
||||
if "%MinGWPath%"=="" echo Please run command in the Qt Command Prompt.& exit /B 1
|
||||
|
||||
:: Get Qt version
|
||||
call "%ToolsPath%\get-qt-version.bat" QtVersion
|
||||
if "%QtVersion%"=="" echo Cannot get Qt version.& exit /B 1
|
||||
|
||||
set RsBuildConfig=release
|
||||
set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsBuildConfig%
|
||||
set RsDeployPath=%DeployPath%\Qt-%QtVersion%-%RsBuildConfig%
|
||||
set RsPackPath=%DeployPath%
|
||||
set RsArchiveAdd=
|
||||
|
||||
if not exist "%~dp0env-mod.bat" goto no_mod
|
||||
call "%~dp0env-mod.bat"
|
||||
if errorlevel 1 exit /B %ERRORLEVEL%
|
||||
:no_mod
|
||||
|
||||
exit /B 0
|
117
build_scripts/Windows/build/git-log.bat
Normal file
117
build_scripts/Windows/build/git-log.bat
Normal file
@ -0,0 +1,117 @@
|
||||
:: Usage:
|
||||
:: call git-log.bat [no-ask]
|
||||
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set NoAsk=
|
||||
if "%~1"=="no-ask" set NoAsk=1
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0..\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
call "%EnvPath%\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
call "%~dp0env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
:: Check git executable
|
||||
set GitPath=
|
||||
call "%ToolsPath%\find-in-path.bat" GitPath git.exe
|
||||
if "%GitPath%"=="" echo Git executable not found in PATH.& exit /B 1
|
||||
|
||||
:: Get compiled revision
|
||||
set GetRsVersion=%SourcePath%\build_scripts\Windows\tools\get-rs-version.bat
|
||||
if not exist "%GetRsVersion%" (
|
||||
echo File not found
|
||||
echo %GetRsVersion%
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
call "%GetRsVersion%" RS_REVISION_STRING RsRevision
|
||||
if "%RsRevision%"=="" echo Revision not found.& exit /B 1
|
||||
|
||||
:: Get compiled version
|
||||
call "%GetRsVersion%" RS_REVISION_STRING RsRevision
|
||||
if "%RsRevision%"=="" echo Revision not found.& exit /B 1
|
||||
|
||||
call "%GetRsVersion%" RS_MAJOR_VERSION RsMajorVersion
|
||||
if "%RsMajorVersion%"=="" echo Major version not found.& exit /B 1
|
||||
|
||||
call "%GetRsVersion%" RS_MINOR_VERSION RsMinorVersion
|
||||
if "%RsMinorVersion%"=="" echo Minor version not found.& exit /B 1
|
||||
|
||||
call "%GetRsVersion%" RS_BUILD_NUMBER RsBuildNumber
|
||||
if "%RsBuildNumber%"=="" echo Build number not found.& exit /B 1
|
||||
|
||||
call "%GetRsVersion%" RS_BUILD_NUMBER_ADD RsBuildNumberAdd
|
||||
|
||||
set RsVersion=%RsMajorVersion%.%RsMinorVersion%.%RsBuildNumber%%RsBuildNumberAdd%
|
||||
|
||||
:: Check WMIC is available
|
||||
wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& exit /B 1
|
||||
|
||||
:: Use WMIC to retrieve date in format YYYYMMDD
|
||||
set RsDate=
|
||||
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I
|
||||
set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2%
|
||||
|
||||
:: Get last revision
|
||||
set RsLastRefFile=%BuildPath%\Qt-%QtVersion%-%RsBuildConfig%-LastRef.txt
|
||||
set RsLastRef=
|
||||
if exist "%RsLastRefFile%" set /P RsLastRef=<"%RsLastRefFile%"
|
||||
|
||||
if "%NoAsk%"=="1" goto no_ask_for_last_revision
|
||||
if not "%RsLastRef%"=="" echo Last Revision was %RsLastRef%
|
||||
set /P RsLastRefInput=Last Revision:
|
||||
if "%RsLastRefInput%" NEQ "" set RsLastRef=%RsLastRefInput%
|
||||
:no_ask_for_last_revision
|
||||
|
||||
:: Get current revision
|
||||
pushd "%SourcePath%"
|
||||
call "%ToolsPath%\get-git-ref.bat" RsRef
|
||||
popd
|
||||
|
||||
if errorlevel 1 exit /B 1
|
||||
if "%RsRef%"=="" echo Cannot get git revision.& exit /B 1
|
||||
|
||||
echo.
|
||||
echo Creating log from %RsLastRef%
|
||||
echo to %RsRef%
|
||||
|
||||
if "%NoAsk%"=="1" goto no_confirm
|
||||
choice /M "Do you want to proceed?"
|
||||
if %errorlevel%==2 exit /B 1
|
||||
:no_confirm
|
||||
|
||||
if "%RsBuildConfig%" NEQ "release" (
|
||||
set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsArchiveAdd%-%RsBuildConfig%.txt
|
||||
) else (
|
||||
set RsGitLog=%DeployPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsArchiveAdd%.txt
|
||||
)
|
||||
|
||||
title %SourceName%-%RsBuildConfig% [git log]
|
||||
|
||||
pushd "%SourcePath%"
|
||||
if "%RsLastRef%"=="" (
|
||||
git log %RsRef% >"%RsGitLog%"
|
||||
) else (
|
||||
if "%RsLastRef%"=="%RsRef%" (
|
||||
git log %RsRef% --max-count=1 >"%RsGitLog%"
|
||||
) else (
|
||||
git log %RsLastRef%..%RsRef% >"%RsGitLog%"
|
||||
)
|
||||
)
|
||||
popd
|
||||
|
||||
title %COMSPEC%
|
||||
|
||||
echo %RsRef%>"%RsLastRefFile%"
|
||||
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:error_env
|
||||
echo Failed to initialize environment.
|
||||
endlocal
|
||||
exit /B 1
|
210
build_scripts/Windows/build/pack.bat
Normal file
210
build_scripts/Windows/build/pack.bat
Normal file
@ -0,0 +1,210 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set Quite=^>nul
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0..\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
call "%EnvPath%\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
:: Get gcc versions
|
||||
call "%ToolsPath%\get-gcc-version.bat" GCCVersion
|
||||
if "%GCCVersion%"=="" echo Cannot get gcc version.& exit /B 1
|
||||
|
||||
:: Check external libraries
|
||||
if not exist "%RootPath%\libs" echo Please build external libraries first.& exit /B 1
|
||||
|
||||
:: Check gcc version of external libraries
|
||||
if not exist "%RootPath%\libs\gcc-version" echo Cannot get gcc version of external libraries.& exit /B 1
|
||||
set /P LibsGCCVersion=<"%RootPath%\libs\gcc-version"
|
||||
if "%LibsGCCVersion%" NEQ "%GCCVersion%" echo Please use correct version of external libraries. (gcc %GCCVersion% ^<^> libs %LibsGCCVersion%).& exit /B 1
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
:: Remove deploy path
|
||||
if exist "%RsDeployPath%" rmdir /S /Q "%RsDeployPath%"
|
||||
|
||||
:: Check compilation
|
||||
if not exist "%RsBuildPath%\Makefile" echo Project is not compiled.& goto error
|
||||
|
||||
:: Get compiled revision
|
||||
set GetRsVersion=%SourcePath%\build_scripts\Windows\tools\get-rs-version.bat
|
||||
if not exist "%GetRsVersion%" (
|
||||
echo File not found
|
||||
echo %GetRsVersion%
|
||||
goto error
|
||||
)
|
||||
|
||||
call "%GetRsVersion%" RS_REVISION_STRING RsRevision
|
||||
if "%RsRevision%"=="" echo Revision not found.& goto error
|
||||
|
||||
:: Get compiled version
|
||||
call "%GetRsVersion%" RS_MAJOR_VERSION RsMajorVersion
|
||||
if "%RsMajorVersion%"=="" echo Major version not found.& goto error
|
||||
|
||||
call "%GetRsVersion%" RS_MINOR_VERSION RsMinorVersion
|
||||
if "%RsMinorVersion%"=="" echo Minor version not found.& goto error
|
||||
|
||||
call "%GetRsVersion%" RS_BUILD_NUMBER RsBuildNumber
|
||||
if "%RsBuildNumber%"=="" echo Build number not found.& goto error
|
||||
|
||||
call "%GetRsVersion%" RS_BUILD_NUMBER_ADD RsBuildNumberAdd
|
||||
|
||||
set RsVersion=%RsMajorVersion%.%RsMinorVersion%.%RsBuildNumber%%RsBuildNumberAdd%
|
||||
|
||||
:: Check WMIC is available
|
||||
wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& goto error
|
||||
|
||||
:: Use WMIC to retrieve date in format YYYYMMDD
|
||||
set RsDate=
|
||||
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I
|
||||
set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2%
|
||||
|
||||
set QtMainVersion=%QtVersion:~0,1%
|
||||
|
||||
rem Qt 4 = QtSvg4.dll
|
||||
rem Qt 5 = Qt5Svg.dll
|
||||
set QtMainVersion1=
|
||||
set QtMainVersion2=
|
||||
if "%QtMainVersion%"=="4" set QtMainVersion2=4
|
||||
if "%QtMainVersion%"=="5" set QtMainVersion1=5
|
||||
|
||||
if "%RsBuildConfig%" NEQ "release" (
|
||||
set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsArchiveAdd%-%RsBuildConfig%.7z
|
||||
) else (
|
||||
set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsRevision%-Qt-%QtVersion%%RsArchiveAdd%.7z
|
||||
)
|
||||
|
||||
if exist "%Archive%" del /Q "%Archive%"
|
||||
|
||||
:: Create deploy path
|
||||
mkdir "%RsDeployPath%"
|
||||
|
||||
title Pack - %SourceName%-%RsBuildConfig% [copy files]
|
||||
|
||||
set ExtensionsFile=%SourcePath%\libretroshare\src\rsserver\rsinit.cc
|
||||
set Extensions=
|
||||
for /f %%e in ('type "%ExtensionsFile%" ^| "%EnvSedExe%" -n "s/^.*\/\(extensions[^/]*\)\/.*$/\1/p" ^| "%EnvSedExe%" -n "1,1p"') do set Extensions=%%e
|
||||
if "%Extensions%"=="" echo Folder for extensions not found in %ExtensionsFile%& goto error
|
||||
|
||||
:: Copy files
|
||||
mkdir "%RsDeployPath%\Data\%Extensions%"
|
||||
mkdir "%RsDeployPath%\imageformats"
|
||||
mkdir "%RsDeployPath%\qss"
|
||||
mkdir "%RsDeployPath%\stylesheets"
|
||||
mkdir "%RsDeployPath%\sounds"
|
||||
mkdir "%RsDeployPath%\translations"
|
||||
|
||||
copy nul "%RsDeployPath%\portable" %Quite%
|
||||
|
||||
echo copy binaries
|
||||
copy "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\RetroShare*.exe" "%RsDeployPath%" %Quite%
|
||||
copy "%RsBuildPath%\retroshare-nogui\src\%RsBuildConfig%\retroshare*-nogui.exe" "%RsDeployPath%" %Quite%
|
||||
|
||||
echo copy extensions
|
||||
for /D %%D in ("%RsBuildPath%\plugins\*") do (
|
||||
call :copy_extension "%%D" "%RsDeployPath%\Data\%Extensions%"
|
||||
call :copy_dependencies "%RsDeployPath%\Data\%Extensions%\%%~nxD.dll" "%RsDeployPath%"
|
||||
)
|
||||
|
||||
echo copy external binaries
|
||||
copy "%RootPath%\libs\bin\*.dll" "%RsDeployPath%" %Quite%
|
||||
|
||||
echo copy dependencies
|
||||
call :copy_dependencies "%RsDeployPath%\RetroShare06.exe" "%RsDeployPath%"
|
||||
|
||||
echo copy Qt DLL's
|
||||
copy "%QtPath%\Qt%QtMainVersion1%Svg%QtMainVersion2%.dll" "%RsDeployPath%" %Quite%
|
||||
|
||||
if "%QtMainVersion%"=="5" (
|
||||
mkdir "%RsDeployPath%\platforms"
|
||||
copy "%QtPath%\..\plugins\platforms\qwindows.dll" "%RsDeployPath%\platforms" %Quite%
|
||||
mkdir "%RsDeployPath%\audio"
|
||||
copy "%QtPath%\..\plugins\audio\qtaudio_windows.dll" "%RsDeployPath%\audio" %Quite%
|
||||
)
|
||||
|
||||
copy "%QtPath%\..\plugins\imageformats\*.dll" "%RsDeployPath%\imageformats" %Quite%
|
||||
del /Q "%RsDeployPath%\imageformats\*d?.dll" %Quite%
|
||||
|
||||
echo copy qss
|
||||
xcopy /S "%SourcePath%\retroshare-gui\src\qss" "%RsDeployPath%\qss" %Quite%
|
||||
|
||||
echo copy stylesheets
|
||||
xcopy /S "%SourcePath%\retroshare-gui\src\gui\qss\chat" "%RsDeployPath%\stylesheets" %Quite%
|
||||
rmdir /S /Q "%RsDeployPath%\stylesheets\compact" %Quite%
|
||||
rmdir /S /Q "%RsDeployPath%\stylesheets\standard" %Quite%
|
||||
rmdir /S /Q "%RsDeployPath%\stylesheets\__MACOSX__Bubble" %Quite%
|
||||
|
||||
echo copy sounds
|
||||
xcopy /S "%SourcePath%\retroshare-gui\src\sounds" "%RsDeployPath%\sounds" %Quite%
|
||||
|
||||
echo copy translation
|
||||
copy "%SourcePath%\retroshare-gui\src\translations\qt_tr.qm" "%RsDeployPath%\translations" %Quite%
|
||||
copy "%QtPath%\..\translations\qt_*.qm" "%RsDeployPath%\translations" %Quite%
|
||||
if "%QtMainVersion%"=="5" (
|
||||
copy "%QtPath%\..\translations\qtbase_*.qm" "%RsDeployPath%\translations" %Quite%
|
||||
copy "%QtPath%\..\translations\qtscript_*.qm" "%RsDeployPath%\translations" %Quite%
|
||||
copy "%QtPath%\..\translations\qtquick1_*.qm" "%RsDeployPath%\translations" %Quite%
|
||||
copy "%QtPath%\..\translations\qtmultimedia_*.qm" "%RsDeployPath%\translations" %Quite%
|
||||
copy "%QtPath%\..\translations\qtxmlpatterns_*.qm" "%RsDeployPath%\translations" %Quite%
|
||||
)
|
||||
|
||||
echo copy bdboot.txt
|
||||
copy "%SourcePath%\libbitdht\src\bitdht\bdboot.txt" "%RsDeployPath%" %Quite%
|
||||
|
||||
echo copy changelog.txt
|
||||
copy "%SourcePath%\retroshare-gui\src\changelog.txt" "%RsDeployPath%" %Quite%
|
||||
|
||||
if exist "%SourcePath%\libresapi\src\webui" (
|
||||
echo copy webui
|
||||
mkdir "%RsDeployPath%\webui"
|
||||
xcopy /S "%SourcePath%\libresapi\src\webui" "%RsDeployPath%\webui" %Quite%
|
||||
)
|
||||
|
||||
rem pack files
|
||||
title Pack - %SourceName%-%RsBuildConfig% [pack files]
|
||||
|
||||
"%SevenZipExe%" a -mx=9 -t7z "%Archive%" "%RsDeployPath%\*"
|
||||
|
||||
title %COMSPEC%
|
||||
|
||||
call :cleanup
|
||||
|
||||
endlocal
|
||||
exit /B 0
|
||||
|
||||
:error
|
||||
call :Cleanup
|
||||
endlocal
|
||||
exit /B 1
|
||||
|
||||
:cleanup
|
||||
goto :EOF
|
||||
|
||||
:error_env
|
||||
echo Failed to initialize environment.
|
||||
endlocal
|
||||
exit /B 1
|
||||
|
||||
:copy_extension
|
||||
if exist "%~1\%RsBuildConfig%\%~n1.dll" (
|
||||
copy "%~1\%RsBuildConfig%\%~n1.dll" %2 %Quite%
|
||||
)
|
||||
goto :EOF
|
||||
|
||||
:copy_dependencies
|
||||
for /F "usebackq" %%A in (`%ToolsPath%\depends.bat list %1`) do (
|
||||
if exist "%QtPath%\%%A" (
|
||||
copy "%QtPath%\%%A" %2 %Quite%
|
||||
) else (
|
||||
if exist "%MinGWPath%\%%A" (
|
||||
copy "%MinGWPath%\%%A" %2 %Quite%
|
||||
)
|
||||
)
|
||||
)
|
||||
goto :EOF
|
6
build_scripts/Windows/build_libs/.gitignore
vendored
6
build_scripts/Windows/build_libs/.gitignore
vendored
@ -1,6 +0,0 @@
|
||||
/download
|
||||
/msys
|
||||
/libs
|
||||
/tools/7z.dll
|
||||
/tools/7z.exe
|
||||
/tools/curl.exe
|
@ -1,43 +0,0 @@
|
||||
@setlocal
|
||||
|
||||
@echo off
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0_env.bat"
|
||||
|
||||
set SevenZipUrl=http://7-zip.org/a/7z1602.msi
|
||||
set SevenZipInstall=7z1602.msi
|
||||
set CurlUrl=https://bintray.com/artifact/download/vszakats/generic/curl-7.50.1-win32-mingw.7z
|
||||
set CurlInstall=curl-7.50.1-win32-mingw.7z
|
||||
|
||||
if not exist "%DownloadPath%" mkdir "%DownloadPath%"
|
||||
|
||||
call :remove_dir "%TempPath%"
|
||||
|
||||
echo Download installation files
|
||||
if not exist "%DownloadPath%\%SevenZipInstall%" call "%ToolsPath%\winhttpjs.bat" %SevenZipUrl% -saveTo "%DownloadPath%\%SevenZipInstall%"
|
||||
if not exist "%DownloadPath%\%SevenZipInstall%" echo Cannot download 7z& goto :exit
|
||||
|
||||
if not exist "%DownloadPath%\%CurlInstall%" call "%ToolsPath%\winhttpjs.bat" %CurlUrl% -saveTo "%DownloadPath%\%CurlInstall%"
|
||||
if not exist "%DownloadPath%\%CurlInstall%" echo Cannot download Curl& goto :exit
|
||||
|
||||
echo Unpack 7z
|
||||
msiexec /a "%DownloadPath%\%SevenZipInstall%" /qb TARGETDIR="%TempPath%"
|
||||
copy "%TempPath%\Files\7-Zip\7z.dll" "%ToolsPath%"
|
||||
copy "%TempPath%\Files\7-Zip\7z.exe" "%ToolsPath%"
|
||||
call :remove_dir "%TempPath%"
|
||||
|
||||
echo Unpack Curl
|
||||
"%SevenZipExe%" x -o"%TempPath%" "%DownloadPath%\%CurlInstall%"
|
||||
copy "%TempPath%\curl-7.50.1-win32-mingw\bin\curl.exe" "%ToolsPath%"
|
||||
call :remove_dir "%TempPath%"
|
||||
|
||||
:exit
|
||||
endlocal
|
||||
exit /B 0
|
||||
|
||||
:remove_dir
|
||||
if not exist %1 goto :EOF
|
||||
del /s /f /q %1 >nul
|
||||
rmdir /s /q %1
|
||||
goto :EOF
|
@ -1,70 +0,0 @@
|
||||
@setlocal
|
||||
|
||||
@echo off
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0_env.bat"
|
||||
|
||||
set MSYSInstall=mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip
|
||||
set CMakeInstall=cmake-3.1.0-win32-x86.zip
|
||||
set CMakeUnpackPath=%MSYSPath%\msys\1.0
|
||||
|
||||
if not exist "%DownloadPath%" mkdir "%DownloadPath%"
|
||||
|
||||
echo Check existing installation
|
||||
if not exist "%MSYSPath%\bin\mingw-get.exe" goto proceed
|
||||
choice /M "Found existing MSYS version. Do you want to proceed?"
|
||||
if %ERRORLEVEL%==2 goto exit
|
||||
|
||||
:proceed
|
||||
echo Remove previous MSYS version
|
||||
call :remove_dir "%MSYSPath%"
|
||||
|
||||
echo Download installation files
|
||||
if not exist "%DownloadPath%\%MSYSInstall%" "%CurlExe%" -L -k http://sourceforge.net/projects/mingw/files/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/%MSYSInstall%/download -o "%DownloadPath%\%MSYSInstall%"
|
||||
if not exist "%DownloadPath%%\MSYSInstall%" echo Cannot download MSYS& goto :exit
|
||||
|
||||
if not exist "%DownloadPath%\%CMakeInstall%" "%CurlExe%" -L -k http://www.cmake.org/files/v3.1/cmake-3.1.0-win32-x86.zip -o "%DownloadPath%\%CMakeInstall%"
|
||||
if not exist "%DownloadPath%\%CMakeInstall%" echo Cannot download CMake& goto :exit
|
||||
|
||||
echo Unpack MSYS
|
||||
"%SevenZipExe%" x -o"%MSYSPath%" "%DownloadPath%\%MSYSInstall%"
|
||||
|
||||
echo Install MSYS
|
||||
if not exist "%MSYSPath%\var\lib\mingw-get\data\profile.xml" copy "%MSYSPath%\var\lib\mingw-get\data\defaults.xml" "%MSYSPath%\var\lib\mingw-get\data\profile.xml"
|
||||
pushd "%MSYSPath%\bin"
|
||||
mingw-get.exe install mingw32-mingw-get
|
||||
mingw-get.exe install msys-coreutils
|
||||
mingw-get.exe install msys-base
|
||||
mingw-get.exe install msys-autoconf
|
||||
mingw-get.exe install msys-automake
|
||||
mingw-get.exe install msys-autogen
|
||||
mingw-get.exe install msys-mktemp
|
||||
mingw-get.exe install msys-wget
|
||||
popd
|
||||
|
||||
echo Unpack CMake
|
||||
"%SevenZipExe%" x -o"%CMakeUnpackPath%" "%DownloadPath%\%CMakeInstall%"
|
||||
|
||||
echo Install CMake
|
||||
set CMakeVersion=
|
||||
for /D %%F in (%CMakeUnpackPath%\cmake*) do set CMakeVersion=%%~nxF
|
||||
if "%CMakeVersion%"=="" echo CMake version not found.& goto :exit
|
||||
echo Found CMake version %CMakeVersion%
|
||||
|
||||
set FoundProfile=
|
||||
for /f "tokens=3" %%F in ('find /c /i "%CMakeVersion%" "%MSYSPath%\msys\1.0\etc\profile"') do set FoundProfile=%%F
|
||||
|
||||
if "%FoundProfile%"=="0" (
|
||||
echo export PATH="${PATH}:/%CMakeVersion%/bin">>"%MSYSPath%\msys\1.0\etc\profile"
|
||||
)
|
||||
|
||||
:exit
|
||||
endlocal
|
||||
exit /B 0
|
||||
|
||||
:remove_dir
|
||||
if not exist %1 goto :EOF
|
||||
del /s /f /q %1 >nul
|
||||
rmdir /s /q %1
|
||||
goto :EOF
|
@ -1,29 +0,0 @@
|
||||
@setlocal
|
||||
|
||||
@echo off
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0_env.bat"
|
||||
|
||||
set MSYSSH=%MSYSPath%\msys\1.0\bin\sh.exe
|
||||
set MSYSCurPath=/%CurPath:~0,1%/%CurPath:~3%
|
||||
set MSYSCurPath=%MSYSCurPath:\=/%
|
||||
|
||||
if not exist "%MSYSSH%" echo Please install MSYS first.&& exit /B 1
|
||||
|
||||
set GCCPath=
|
||||
call :FIND_IN_PATH g++.exe GCCPath
|
||||
if "%GCCPath%"=="" echo Please run %~nx0 in the Qt Command Prompt or add the path to MinGW bin folder to PATH variable.&& exit /B 1
|
||||
|
||||
"%MSYSSH%" --login -i -c "cd "%MSYSCurPath%" && make -f makefile %*"
|
||||
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:FIND_IN_PATH
|
||||
SET PathTemp="%Path:;=";"%"
|
||||
FOR %%P IN (%PathTemp%) DO (
|
||||
IF EXIST "%%~P.\%~1" (
|
||||
set %2=%%~P
|
||||
goto :EOF
|
||||
)
|
||||
)
|
@ -13,214 +13,331 @@ SQLCIPHER_VERSION=2.2.1
|
||||
LIBMICROHTTPD_VERSION=0.9.46
|
||||
FFMPEG_VERSION=3.1.2
|
||||
|
||||
MAKEFILE_PATH=$(dir $(MAKEFILE_LIST))
|
||||
LIBS_PATH?=$(MAKEFILE_PATH)../../../../libs
|
||||
|
||||
DOWNLOAD_PATH?=download
|
||||
COPY_ANSWER?=
|
||||
|
||||
all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg copylibs
|
||||
|
||||
download: \
|
||||
download/zlib-$(ZLIB_VERSION).tar.gz \
|
||||
download/bzip2-$(BZIP2_VERSION).tar.gz \
|
||||
download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz \
|
||||
download/openssl-$(OPENSSL_VERSION).tar.gz \
|
||||
download/speex-$(SPEEX_VERSION).tar.gz \
|
||||
download/speexdsp-$(SPEEXDSP_VERSION).tar.gz \
|
||||
download/opencv-$(OPENCV_VERSION).tar.gz \
|
||||
download/libxml2-$(LIBXML2_VERSION).tar.gz \
|
||||
download/libxslt-$(LIBXSLT_VERSION).tar.gz \
|
||||
download/curl-$(CURL_VERSION).tar.gz \
|
||||
download/tcl$(TCL_VERSION)-src.tar.gz \
|
||||
download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz \
|
||||
download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz \
|
||||
download/ffmpeg-$(FFMPEG_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz \
|
||||
$(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz \
|
||||
$(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
|
||||
|
||||
clean:
|
||||
rm -r -f libs
|
||||
|
||||
dirs:
|
||||
mkdir -p download
|
||||
mkdir -p libs/include
|
||||
mkdir -p libs/lib
|
||||
mkdir -p libs/bin
|
||||
mkdir -p $(DOWNLOAD_PATH)
|
||||
mkdir -p libs
|
||||
gcc --version | head --lines 1 | tr ' ' '\n' | tail -1 >libs/gcc-version
|
||||
|
||||
download/zlib-$(ZLIB_VERSION).tar.gz:
|
||||
wget --no-check-certificate http://sourceforge.net/projects/libpng/files/zlib/$(ZLIB_VERSION)/zlib-$(ZLIB_VERSION).tar.gz/download -O download/zlib-$(ZLIB_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz:
|
||||
wget --no-check-certificate http://sourceforge.net/projects/libpng/files/zlib/$(ZLIB_VERSION)/zlib-$(ZLIB_VERSION).tar.gz/download -O $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz
|
||||
|
||||
zlib: download/zlib-$(ZLIB_VERSION).tar.gz
|
||||
tar xvf download/zlib-$(ZLIB_VERSION).tar.gz
|
||||
zlib: libs/zlib-$(ZLIB_VERSION)
|
||||
|
||||
libs/zlib-$(ZLIB_VERSION): $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/zlib-*
|
||||
tar xvf $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz
|
||||
# build
|
||||
cd zlib-$(ZLIB_VERSION) && ./configure
|
||||
#cd zlib-$(ZLIB_VERSION) && make install prefix="`pwd`/../libs"
|
||||
cd zlib-$(ZLIB_VERSION) && make
|
||||
cp zlib-$(ZLIB_VERSION)/zlib.h libs/include/
|
||||
cp zlib-$(ZLIB_VERSION)/zconf.h libs/include/
|
||||
cp zlib-$(ZLIB_VERSION)/libz.a libs/lib/
|
||||
# copy files
|
||||
mkdir -p libs/zlib-$(ZLIB_VERSION).tmp/include
|
||||
cp zlib-$(ZLIB_VERSION)/zlib.h libs/zlib-$(ZLIB_VERSION).tmp/include/
|
||||
cp zlib-$(ZLIB_VERSION)/zconf.h libs/zlib-$(ZLIB_VERSION).tmp/include/
|
||||
mkdir -p libs/zlib-$(ZLIB_VERSION).tmp/lib
|
||||
cp zlib-$(ZLIB_VERSION)/libz.a libs/zlib-$(ZLIB_VERSION).tmp/lib/
|
||||
rm -r -f zlib-$(ZLIB_VERSION)
|
||||
touch zlib
|
||||
mv libs/zlib-$(ZLIB_VERSION).tmp libs/zlib-$(ZLIB_VERSION)
|
||||
|
||||
download/bzip2-$(BZIP2_VERSION).tar.gz:
|
||||
wget http://bzip.org/$(BZIP2_VERSION)/bzip2-$(BZIP2_VERSION).tar.gz -O download/bzip2-$(BZIP2_VERSION).tar.gz
|
||||
bzip2: libs/bzip2-$(BZIP2_VERSION)
|
||||
|
||||
bzip2: download/bzip2-$(BZIP2_VERSION).tar.gz
|
||||
tar xvf download/bzip2-$(BZIP2_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz:
|
||||
wget http://bzip.org/$(BZIP2_VERSION)/bzip2-$(BZIP2_VERSION).tar.gz -O $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz
|
||||
|
||||
libs/bzip2-$(BZIP2_VERSION): $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/bzip2-*
|
||||
tar xvf $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz
|
||||
# build
|
||||
#cd bzip2-$(BZIP2_VERSION) && make install PREFIX="`pwd`/../libs"
|
||||
cd bzip2-$(BZIP2_VERSION) && make
|
||||
cp bzip2-$(BZIP2_VERSION)/bzlib.h libs/include/
|
||||
cp bzip2-$(BZIP2_VERSION)/libbz2.a libs/lib/
|
||||
# copy files
|
||||
mkdir -p libs/bzip2-$(BZIP2_VERSION).tmp/include
|
||||
cp bzip2-$(BZIP2_VERSION)/bzlib.h libs/bzip2-$(BZIP2_VERSION).tmp/include/
|
||||
mkdir -p libs/bzip2-$(BZIP2_VERSION).tmp/lib
|
||||
cp bzip2-$(BZIP2_VERSION)/libbz2.a libs/bzip2-$(BZIP2_VERSION).tmp/lib/
|
||||
rm -r -f bzip2-$(BZIP2_VERSION)
|
||||
touch bzip2
|
||||
mv libs/bzip2-$(BZIP2_VERSION).tmp libs/bzip2-$(BZIP2_VERSION)
|
||||
|
||||
download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz:
|
||||
wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-$(MINIUPNPC_VERSION).tar.gz -O download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
|
||||
miniupnpc: libs/miniupnpc-$(MINIUPNPC_VERSION)
|
||||
|
||||
miniupnpc: download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
|
||||
tar xvf download/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz:
|
||||
wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-$(MINIUPNPC_VERSION).tar.gz -O $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
|
||||
|
||||
libs/miniupnpc-$(MINIUPNPC_VERSION): $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/miniupnpc-*
|
||||
tar xvf $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz
|
||||
# build
|
||||
cd miniupnpc-$(MINIUPNPC_VERSION) && CC=gcc && export CC && make -f Makefile.mingw init libminiupnpc.a miniupnpc.dll
|
||||
mkdir -p libs/include/miniupnpc && cp miniupnpc-$(MINIUPNPC_VERSION)/*.h libs/include/miniupnpc/
|
||||
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.lib libs/lib/
|
||||
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.dll libs/bin/
|
||||
# copy files
|
||||
mkdir -p libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc
|
||||
cp miniupnpc-$(MINIUPNPC_VERSION)/*.h libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc/
|
||||
mkdir -p libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/lib
|
||||
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.lib libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/lib/
|
||||
mkdir -p libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/bin
|
||||
cp miniupnpc-$(MINIUPNPC_VERSION)/miniupnpc.dll libs/miniupnpc-$(MINIUPNPC_VERSION).tmp/bin/
|
||||
rm -r -f miniupnpc-$(MINIUPNPC_VERSION)
|
||||
touch miniupnpc
|
||||
mv libs/miniupnpc-$(MINIUPNPC_VERSION).tmp libs/miniupnpc-$(MINIUPNPC_VERSION)
|
||||
|
||||
download/openssl-$(OPENSSL_VERSION).tar.gz:
|
||||
wget --no-check-certificate https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz -O download/openssl-$(OPENSSL_VERSION).tar.gz
|
||||
openssl: libs/openssl-$(OPENSSL_VERSION)
|
||||
|
||||
openssl: download/openssl-$(OPENSSL_VERSION).tar.gz
|
||||
tar xvf download/openssl-$(OPENSSL_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz:
|
||||
wget --no-check-certificate https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz -O $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz
|
||||
|
||||
libs/openssl-$(OPENSSL_VERSION): $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/openssl-*
|
||||
tar xvf $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz
|
||||
# build
|
||||
#cd openssl-$(OPENSSL_VERSION) && ./config --prefix="`pwd`/../libs"
|
||||
#cd openssl-$(OPENSSL_VERSION) && make install
|
||||
cd openssl-$(OPENSSL_VERSION) && ./config shared
|
||||
cd openssl-$(OPENSSL_VERSION) && make
|
||||
mkdir -p libs/include/openssl && cp openssl-$(OPENSSL_VERSION)/include/openssl/*.h libs/include/openssl/
|
||||
cp openssl-$(OPENSSL_VERSION)/libeay32.dll libs/bin/
|
||||
cp openssl-$(OPENSSL_VERSION)/ssleay32.dll libs/bin/
|
||||
cp openssl-$(OPENSSL_VERSION)/libcrypto.dll.a libs/lib/
|
||||
cp openssl-$(OPENSSL_VERSION)/libssl.dll.a libs/lib/
|
||||
# copy files
|
||||
mkdir -p libs/openssl-$(OPENSSL_VERSION).tmp/include/openssl
|
||||
cp openssl-$(OPENSSL_VERSION)/include/openssl/*.h libs/openssl-$(OPENSSL_VERSION).tmp/include/openssl/
|
||||
mkdir -p libs/openssl-$(OPENSSL_VERSION).tmp/bin
|
||||
cp openssl-$(OPENSSL_VERSION)/libeay32.dll libs/openssl-$(OPENSSL_VERSION).tmp/bin/
|
||||
cp openssl-$(OPENSSL_VERSION)/ssleay32.dll libs/openssl-$(OPENSSL_VERSION).tmp/bin/
|
||||
mkdir -p libs/openssl-$(OPENSSL_VERSION).tmp/lib
|
||||
cp openssl-$(OPENSSL_VERSION)/libcrypto.dll.a libs/openssl-$(OPENSSL_VERSION).tmp/lib/
|
||||
cp openssl-$(OPENSSL_VERSION)/libssl.dll.a libs/openssl-$(OPENSSL_VERSION).tmp/lib/
|
||||
rm -r -f openssl-$(OPENSSL_VERSION)
|
||||
touch openssl
|
||||
mv libs/openssl-$(OPENSSL_VERSION).tmp libs/openssl-$(OPENSSL_VERSION)
|
||||
|
||||
download/speex-$(SPEEX_VERSION).tar.gz:
|
||||
wget http://downloads.xiph.org/releases/speex/speex-$(SPEEX_VERSION).tar.gz -O download/speex-$(SPEEX_VERSION).tar.gz
|
||||
speex: libs/speex-$(SPEEX_VERSION)
|
||||
|
||||
speex: download/speex-$(SPEEX_VERSION).tar.gz
|
||||
tar xvf download/speex-$(SPEEX_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz:
|
||||
wget http://downloads.xiph.org/releases/speex/speex-$(SPEEX_VERSION).tar.gz -O $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz
|
||||
|
||||
libs/speex-$(SPEEX_VERSION): $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/speex-*
|
||||
tar xvf $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz
|
||||
# build
|
||||
cd speex-$(SPEEX_VERSION) && ./configure
|
||||
#cd speex-$(SPEEX_VERSION) && make install exec_prefix="`pwd`/../libs"
|
||||
cd speex-$(SPEEX_VERSION) && make
|
||||
mkdir -p libs/include/speex && cp speex-$(SPEEX_VERSION)/include/speex/*.h libs/include/speex/
|
||||
cp speex-$(SPEEX_VERSION)/libspeex/.libs/libspeex.a libs/lib
|
||||
# copy files
|
||||
mkdir -p libs/speex-$(SPEEX_VERSION).tmp/include/speex
|
||||
cp speex-$(SPEEX_VERSION)/include/speex/*.h libs/speex-$(SPEEX_VERSION).tmp/include/speex/
|
||||
mkdir -p libs/speex-$(SPEEX_VERSION).tmp/lib
|
||||
cp speex-$(SPEEX_VERSION)/libspeex/.libs/libspeex.a libs/speex-$(SPEEX_VERSION).tmp/lib
|
||||
rm -r -f speex-$(SPEEX_VERSION)
|
||||
touch speex
|
||||
mv libs/speex-$(SPEEX_VERSION).tmp libs/speex-$(SPEEX_VERSION)
|
||||
|
||||
download/speexdsp-$(SPEEXDSP_VERSION).tar.gz:
|
||||
wget http://downloads.xiph.org/releases/speex/speexdsp-$(SPEEXDSP_VERSION).tar.gz -O download/speexdsp-$(SPEEXDSP_VERSION).tar.gz
|
||||
speexdsp: libs/speexdsp-$(SPEEXDSP_VERSION)
|
||||
|
||||
speexdsp: download/speexdsp-$(SPEEXDSP_VERSION).tar.gz
|
||||
tar xvf download/speexdsp-$(SPEEXDSP_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz:
|
||||
wget http://downloads.xiph.org/releases/speex/speexdsp-$(SPEEXDSP_VERSION).tar.gz -O $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz
|
||||
|
||||
libs/speexdsp-$(SPEEXDSP_VERSION): $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/speexdsp-*
|
||||
tar xvf $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz
|
||||
# build
|
||||
cd speexdsp-$(SPEEXDSP_VERSION) && ./configure
|
||||
cd speexdsp-$(SPEEXDSP_VERSION) && make
|
||||
mkdir -p libs/include/speex && cp speexdsp-$(SPEEXDSP_VERSION)/include/speex/*.h libs/include/speex/
|
||||
cp speexdsp-$(SPEEXDSP_VERSION)/libspeexdsp/.libs/libspeexdsp.a libs/lib
|
||||
# copy files
|
||||
mkdir -p libs/speexdsp-$(SPEEXDSP_VERSION).tmp/include/speex
|
||||
cp speexdsp-$(SPEEXDSP_VERSION)/include/speex/*.h libs/speexdsp-$(SPEEXDSP_VERSION).tmp/include/speex/
|
||||
mkdir -p libs/speexdsp-$(SPEEXDSP_VERSION).tmp/lib
|
||||
cp speexdsp-$(SPEEXDSP_VERSION)/libspeexdsp/.libs/libspeexdsp.a libs/speexdsp-$(SPEEXDSP_VERSION).tmp/lib
|
||||
rm -r -f speexdsp-$(SPEEXDSP_VERSION)
|
||||
touch speexdsp
|
||||
mv libs/speexdsp-$(SPEEXDSP_VERSION).tmp libs/speexdsp-$(SPEEXDSP_VERSION)
|
||||
|
||||
download/opencv-$(OPENCV_VERSION).tar.gz:
|
||||
wget --no-check-certificate https://github.com/Itseez/opencv/archive/$(OPENCV_VERSION).tar.gz -O download/opencv-$(OPENCV_VERSION).tar.gz
|
||||
opencv: libs/opencv-$(OPENCV_VERSION)
|
||||
|
||||
opencv: download/opencv-$(OPENCV_VERSION).tar.gz
|
||||
tar xvf download/opencv-$(OPENCV_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz:
|
||||
wget --no-check-certificate https://github.com/Itseez/opencv/archive/$(OPENCV_VERSION).tar.gz -O $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
|
||||
|
||||
libs/opencv-$(OPENCV_VERSION): $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/opencv-*
|
||||
tar xvf $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
|
||||
# build
|
||||
mkdir -p opencv-$(OPENCV_VERSION)/build
|
||||
#cd opencv-$(OPENCV_VERSION)/build && cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="`pwd`/../../libs"
|
||||
cd opencv-$(OPENCV_VERSION)/build && cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="`pwd`/install"
|
||||
cd opencv-$(OPENCV_VERSION)/build && make install
|
||||
cp -r opencv-$(OPENCV_VERSION)/build/install/include/* libs/include/
|
||||
mkdir -p libs/lib/opencv && cp -r opencv-$(OPENCV_VERSION)/build/install/x86/mingw/staticlib/* libs/lib/opencv/
|
||||
# copy files
|
||||
mkdir -p libs/opencv-$(OPENCV_VERSION).tmp/include
|
||||
cp -r opencv-$(OPENCV_VERSION)/build/install/include/* libs/opencv-$(OPENCV_VERSION).tmp/include/
|
||||
mkdir -p libs/opencv-$(OPENCV_VERSION).tmp/lib/opencv
|
||||
cp -r opencv-$(OPENCV_VERSION)/build/install/x86/mingw/staticlib/* libs/opencv-$(OPENCV_VERSION).tmp/lib/opencv/
|
||||
rm -r -f opencv-$(OPENCV_VERSION)
|
||||
touch opencv
|
||||
mv libs/opencv-$(OPENCV_VERSION).tmp libs/opencv-$(OPENCV_VERSION)
|
||||
|
||||
download/libxml2-$(LIBXML2_VERSION).tar.gz:
|
||||
wget ftp://xmlsoft.org/libxml2/libxml2-$(LIBXML2_VERSION).tar.gz -O download/libxml2-$(LIBXML2_VERSION).tar.gz
|
||||
libxml2: libs/libxml2-$(LIBXML2_VERSION)
|
||||
|
||||
libxml2: download/libxml2-$(LIBXML2_VERSION).tar.gz
|
||||
tar xvf download/libxml2-$(LIBXML2_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz:
|
||||
wget ftp://xmlsoft.org/libxml2/libxml2-$(LIBXML2_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
|
||||
|
||||
libs/libxml2-$(LIBXML2_VERSION): $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/libxml2-*
|
||||
tar xvf $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
|
||||
# build
|
||||
cd libxml2-$(LIBXML2_VERSION) && ./configure --without-iconv -enable-shared=no
|
||||
#cd libxml2-$(LIBXML2_VERSION) && make install exec_prefix="`pwd`/../libs"
|
||||
cd libxml2-$(LIBXML2_VERSION) && make
|
||||
mkdir -p libs/include/libxml && cp libxml2-$(LIBXML2_VERSION)/include/libxml/*.h libs/include/libxml/
|
||||
cp libxml2-$(LIBXML2_VERSION)/.libs/libxml2.a libs/lib/
|
||||
touch libxml2
|
||||
# copy files
|
||||
mkdir -p libs/libxml2-$(LIBXML2_VERSION).tmp/include/libxml
|
||||
cp libxml2-$(LIBXML2_VERSION)/include/libxml/*.h libs/libxml2-$(LIBXML2_VERSION).tmp/include/libxml/
|
||||
mkdir -p libs/libxml2-$(LIBXML2_VERSION).tmp/lib
|
||||
cp libxml2-$(LIBXML2_VERSION)/.libs/libxml2.a libs/libxml2-$(LIBXML2_VERSION).tmp/lib/
|
||||
#rm -r -f libxml2-$(LIBXML2_VERSION) # see libxslt
|
||||
mv libs/libxml2-$(LIBXML2_VERSION).tmp libs/libxml2-$(LIBXML2_VERSION)
|
||||
|
||||
download/libxslt-$(LIBXSLT_VERSION).tar.gz:
|
||||
wget ftp://xmlsoft.org/libxml2/libxslt-$(LIBXSLT_VERSION).tar.gz -O download/libxslt-$(LIBXSLT_VERSION).tar.gz
|
||||
libxslt: libs/libxslt-$(LIBXSLT_VERSION)
|
||||
|
||||
libxslt: download/libxml2-$(LIBXML2_VERSION).tar.gz download/libxslt-$(LIBXSLT_VERSION).tar.gz
|
||||
tar xvf download/libxml2-$(LIBXML2_VERSION).tar.gz
|
||||
tar xvf download/libxslt-$(LIBXSLT_VERSION).tar.gz
|
||||
tar xvf libxslt-$(LIBXSLT_VERSION)-fix.tar.gz
|
||||
$(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz:
|
||||
wget ftp://xmlsoft.org/libxml2/libxslt-$(LIBXSLT_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz
|
||||
|
||||
libs/libxslt-$(LIBXSLT_VERSION): $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/libxslt-*
|
||||
tar xvf $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz
|
||||
tar xvf $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz
|
||||
tar xvf $(MAKEFILE_PATH)libxslt-$(LIBXSLT_VERSION)-fix.tar.gz
|
||||
# build
|
||||
cd libxslt-$(LIBXSLT_VERSION) && ./configure --with-libxml-src=../libxml2-$(LIBXML2_VERSION) -enable-shared=no CFLAGS=-DLIBXML_STATIC
|
||||
cd libxslt-$(LIBXSLT_VERSION) && make
|
||||
mkdir -p libs/include/libxslt && cp libxslt-$(LIBXSLT_VERSION)/libxslt/*.h libs/include/libxslt/
|
||||
cp libxslt-$(LIBXSLT_VERSION)/libxslt/.libs/libxslt.a libs/lib/
|
||||
cp libxslt-$(LIBXSLT_VERSION)/libexslt/.libs/libexslt.a libs/lib/
|
||||
# copy files
|
||||
mkdir -p libs/libxslt-$(LIBXSLT_VERSION).tmp/include/libxslt
|
||||
cp libxslt-$(LIBXSLT_VERSION)/libxslt/*.h libs/libxslt-$(LIBXSLT_VERSION).tmp/include/libxslt/
|
||||
mkdir -p libs/libxslt-$(LIBXSLT_VERSION).tmp/lib
|
||||
cp libxslt-$(LIBXSLT_VERSION)/libxslt/.libs/libxslt.a libs/libxslt-$(LIBXSLT_VERSION).tmp/lib/
|
||||
cp libxslt-$(LIBXSLT_VERSION)/libexslt/.libs/libexslt.a libs/libxslt-$(LIBXSLT_VERSION).tmp/lib/
|
||||
rm -r -f libxml2-$(LIBXML2_VERSION)
|
||||
rm -r -f libxslt-$(LIBXSLT_VERSION)
|
||||
touch libxslt
|
||||
mv libs/libxslt-$(LIBXSLT_VERSION).tmp libs/libxslt-$(LIBXSLT_VERSION)
|
||||
|
||||
download/curl-$(CURL_VERSION).tar.gz:
|
||||
wget --no-check-certificate http://curl.haxx.se/download/curl-$(CURL_VERSION).tar.gz -O download/curl-$(CURL_VERSION).tar.gz
|
||||
curl: libs/curl-$(CURL_VERSION)
|
||||
|
||||
curl: download/curl-$(CURL_VERSION).tar.gz
|
||||
tar xvf download/curl-$(CURL_VERSION).tar.gz
|
||||
cd curl-$(CURL_VERSION) && ./configure --disable-shared --with-ssl="`pwd`/../libs"
|
||||
$(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz:
|
||||
wget --no-check-certificate http://curl.haxx.se/$(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz -O $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz
|
||||
|
||||
libs/curl-$(CURL_VERSION): $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/curl-*
|
||||
tar xvf $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz
|
||||
# build
|
||||
cd curl-$(CURL_VERSION) && ./configure --disable-shared --with-ssl="`pwd`/../libs/openssl-$(OPENSSL_VERSION)"
|
||||
#cd curl-$(CURL_VERSION) && make install exec_prefix="`pwd`/../libs"
|
||||
cd curl-$(CURL_VERSION) && make
|
||||
mkdir -p libs/include/curl && cp curl-$(CURL_VERSION)/include/curl/*.h libs/include/curl/
|
||||
cp curl-$(CURL_VERSION)/lib/.libs/libcurl.a libs/lib/
|
||||
# copy files
|
||||
mkdir -p libs/curl-$(CURL_VERSION).tmp/include/curl
|
||||
cp curl-$(CURL_VERSION)/include/curl/*.h libs/curl-$(CURL_VERSION).tmp/include/curl/
|
||||
mkdir -p libs/curl-$(CURL_VERSION).tmp/lib
|
||||
cp curl-$(CURL_VERSION)/lib/.libs/libcurl.a libs/curl-$(CURL_VERSION).tmp/lib/
|
||||
rm -r -f curl-$(CURL_VERSION)
|
||||
touch curl
|
||||
mv libs/curl-$(CURL_VERSION).tmp libs/curl-$(CURL_VERSION)
|
||||
|
||||
download/tcl$(TCL_VERSION)-src.tar.gz:
|
||||
wget http://prdownloads.sourceforge.net/tcl/tcl$(TCL_VERSION)-src.tar.gz -O download/tcl$(TCL_VERSION)-src.tar.gz
|
||||
sqlcipher: libs/sqlcipher-$(SQLCIPHER_VERSION)
|
||||
|
||||
download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz:
|
||||
wget --no-check-certificate https://github.com/sqlcipher/sqlcipher/archive/v$(SQLCIPHER_VERSION).tar.gz -O download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz:
|
||||
wget http://prdownloads.sourceforge.net/tcl/tcl$(TCL_VERSION)-src.tar.gz -O $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz
|
||||
|
||||
sqlcipher: download/tcl$(TCL_VERSION)-src.tar.gz download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
|
||||
$(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz:
|
||||
wget --no-check-certificate https://github.com/sqlcipher/sqlcipher/archive/v$(SQLCIPHER_VERSION).tar.gz -O $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
|
||||
|
||||
libs/sqlcipher-$(SQLCIPHER_VERSION): $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/sqlcipher-*
|
||||
# tcl
|
||||
tar xvf download/tcl$(TCL_VERSION)-src.tar.gz
|
||||
tar xvf $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz
|
||||
mkdir -p tcl$(TCL_VERSION)/build
|
||||
cd tcl$(TCL_VERSION)/build && ../win/configure
|
||||
cd tcl$(TCL_VERSION)/build && make
|
||||
#sqlcipher
|
||||
tar xvf download/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
|
||||
tar xvf $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz
|
||||
cd sqlcipher-$(SQLCIPHER_VERSION) && ln -s ../tcl$(TCL_VERSION)/build/tclsh86.exe tclsh
|
||||
mkdir -p tcl$(TCL_VERSION)/lib
|
||||
ln -s `pwd`/tcl$(TCL_VERSION)/library `pwd`/tcl$(TCL_VERSION)/lib/tcl8.6
|
||||
cd sqlcipher-$(SQLCIPHER_VERSION) && PATH=.:$$PATH:`pwd`/../tcl$(TCL_VERSION)/build && LIBS="-L`pwd`/../libs/lib -lgdi32 $$LIBS" && export LIBS && ./configure --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I`pwd`/../libs/include -I`pwd`/../tcl$(TCL_VERSION)/generic" LDFLAGS="-L`pwd`/../libs/lib -lcrypto -lgdi32" --with-tcl="`pwd`/../tcl$(TCL_VERSION)/build" && make install prefix="`pwd`/install"
|
||||
cp -r sqlcipher-$(SQLCIPHER_VERSION)/install/include/* libs/include/
|
||||
cp sqlcipher-$(SQLCIPHER_VERSION)/install/lib/libsqlcipher.a libs/lib/
|
||||
cp sqlcipher-$(SQLCIPHER_VERSION)/install/bin/sqlcipher.exe libs/bin/
|
||||
# build
|
||||
cd sqlcipher-$(SQLCIPHER_VERSION) && PATH=.:$$PATH:`pwd`/../tcl$(TCL_VERSION)/build && LIBS="-L`pwd`/../libs/openssl-$(OPENSSL_VERSION)/lib -lgdi32 $$LIBS" && export LIBS && ./configure --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I`pwd`/../libs/openssl-$(OPENSSL_VERSION)/include -I`pwd`/../tcl$(TCL_VERSION)/generic" LDFLAGS="-L`pwd`/../libs/openssl-$(OPENSSL_VERSION)/lib -lcrypto -lgdi32" --with-tcl="`pwd`/../tcl$(TCL_VERSION)/build" && make install prefix="`pwd`/install"
|
||||
# copy files
|
||||
mkdir -p libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/include
|
||||
cp -r sqlcipher-$(SQLCIPHER_VERSION)/install/include/* libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/include/
|
||||
mkdir -p libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/lib
|
||||
cp sqlcipher-$(SQLCIPHER_VERSION)/install/lib/libsqlcipher.a libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/lib/
|
||||
mkdir -p libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/bin
|
||||
cp sqlcipher-$(SQLCIPHER_VERSION)/install/bin/sqlcipher.exe libs/sqlcipher-$(SQLCIPHER_VERSION).tmp/bin/
|
||||
rm -r -f sqlcipher-$(SQLCIPHER_VERSION)
|
||||
rm -r -f tcl$(TCL_VERSION)
|
||||
touch sqlcipher
|
||||
mv libs/sqlcipher-$(SQLCIPHER_VERSION).tmp libs/sqlcipher-$(SQLCIPHER_VERSION)
|
||||
|
||||
download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz:
|
||||
wget --no-check-certificate http://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz -O download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
|
||||
libmicrohttpd: libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION)
|
||||
|
||||
libmicrohttpd: download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
|
||||
tar xvf download/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
|
||||
cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../libs"
|
||||
$(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz:
|
||||
wget --no-check-certificate http://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
|
||||
|
||||
libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION): $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/libmicrohttpd-*
|
||||
tar xvf $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz
|
||||
# build
|
||||
cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tmp"
|
||||
cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && make install
|
||||
# copy files
|
||||
rm -r -f libmicrohttpd-$(LIBMICROHTTPD_VERSION)
|
||||
touch libmicrohttpd
|
||||
mv libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tmp libs/libmicrohttpd-$(LIBMICROHTTPD_VERSION)
|
||||
|
||||
download/ffmpeg-$(FFMPEG_VERSION).tar.gz:
|
||||
wget --no-check-certificate https://ffmpeg.org/releases/ffmpeg-$(FFMPEG_VERSION).tar.gz -O download/ffmpeg-$(FFMPEG_VERSION).tar.gz
|
||||
ffmpeg: libs/ffmpeg-$(FFMPEG_VERSION)
|
||||
|
||||
ffmpeg: download/ffmpeg-$(FFMPEG_VERSION).tar.gz
|
||||
tar xvf download/ffmpeg-$(FFMPEG_VERSION).tar.gz
|
||||
cd ffmpeg-$(FFMPEG_VERSION) && ./configure --disable-shared --enable-static --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-yasm --disable-everything --enable-encoder=mpeg4 --enable-decoder=mpeg4 --prefix="`pwd`/../libs"
|
||||
$(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz:
|
||||
wget --no-check-certificate https://ffmpeg.org/releases/ffmpeg-$(FFMPEG_VERSION).tar.gz -O $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
|
||||
|
||||
libs/ffmpeg-$(FFMPEG_VERSION): $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
|
||||
# prepare
|
||||
rm -r -f libs/ffmpeg-*
|
||||
tar xvf $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz
|
||||
# build
|
||||
cd ffmpeg-$(FFMPEG_VERSION) && ./configure --disable-shared --enable-static --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-yasm --disable-everything --enable-encoder=mpeg4 --enable-decoder=mpeg4 --prefix="`pwd`/../libs/ffmpeg-$(FFMPEG_VERSION).tmp"
|
||||
cd ffmpeg-$(FFMPEG_VERSION) && make install
|
||||
# copy files
|
||||
rm -r -f ffmpeg-$(FFMPEG_VERSION)
|
||||
touch ffmpeg
|
||||
mv libs/ffmpeg-$(FFMPEG_VERSION).tmp libs/ffmpeg-$(FFMPEG_VERSION)
|
||||
|
||||
|
||||
copylibs:
|
||||
read -p "Do you want to copy libs to retroshare? (yes|no)" answer; \
|
||||
if [ "$$answer" = "yes" ] ; then \
|
||||
cp -r libs ../../../../ ; \
|
||||
copylibs:
|
||||
if [ "$(COPY_ANSWER)" = "" ] ; then \
|
||||
read -p "Do you want to copy libs to retroshare? (y|n)" answer; \
|
||||
else \
|
||||
answer=$(COPY_ANSWER) ; \
|
||||
fi ; \
|
||||
if [ "$$answer" = "y" ] ; then \
|
||||
rm -r -f $(LIBS_PATH) ; \
|
||||
mkdir -p $(LIBS_PATH) ; \
|
||||
cp ./libs/gcc-version $(LIBS_PATH) ; \
|
||||
find ./libs -mindepth 1 -maxdepth 1 -type d -not -name "*.tmp" -print -exec cp -r {}/. $(LIBS_PATH) \; ; \
|
||||
fi
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
set CurPath=%~dp0
|
||||
set DownloadPath=%CurPath%download
|
||||
set ToolsPath=%CurPath%tools
|
||||
set TempPath=%CurPath%tmp
|
||||
set MSYSPath=%CurPath%msys
|
||||
set LibsPath=%CurPath%libs
|
||||
|
||||
set CurlExe=%ToolsPath%\curl.exe
|
||||
set SevenZipExe=%ToolsPath%\7z.exe
|
46
build_scripts/Windows/build_libs/build-libs.bat
Normal file
46
build_scripts/Windows/build_libs/build-libs.bat
Normal file
@ -0,0 +1,46 @@
|
||||
:: Usage:
|
||||
:: call build-libs.bat [auto-copy] [make tasks]
|
||||
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
:: Parameter
|
||||
set MakeParam="DOWNLOAD_PATH=../download"
|
||||
if "%~1"=="auto-copy" set MakeParam=%MakeParam% "COPY_ANSWER=y"& shift /1
|
||||
|
||||
set MakeTask=
|
||||
:param_loop
|
||||
if "%~1" NEQ "" (
|
||||
set MakeTask=%MakeTask% %1
|
||||
shift /1
|
||||
goto param_loop
|
||||
)
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0..\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
call "%EnvPath%\env-msys.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
:: Check MSYS environment
|
||||
set MSYSSH=%EnvMSYSPath%\msys\1.0\bin\sh.exe
|
||||
if not exist "%MSYSSH%" echo Please install MSYS first.& exit /B 1
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
call "%ToolsPath%\msys-path.bat" "%CurPath%" MSYSCurPath
|
||||
call "%ToolsPath%\msys-path.bat" "%BuildLibsPath%" MSYSBuildLibsPath
|
||||
|
||||
if not exist "%BuildLibsPath%" mkdir "%BuildLibsPath%"
|
||||
|
||||
"%MSYSSH%" --login -i -c "cd "%MSYSBuildLibsPath%" && make -f %MSYSCurPath%/makefile %MakeParam% %MakeTask%"
|
||||
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:error_env
|
||||
echo Failed to initialize environment.
|
||||
endlocal
|
||||
exit /B 1
|
@ -1,30 +0,0 @@
|
||||
@setlocal
|
||||
|
||||
@echo off
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0_env.bat"
|
||||
|
||||
::call :remove_dir "%DownloadPath%"
|
||||
call :remove_dir "%MSYSPath%"
|
||||
call :remove_dir "%TempPath%"
|
||||
|
||||
call :remove_file "%ToolsPath%\7z.exe"
|
||||
call :remove_file "%ToolsPath%\7z.dll"
|
||||
call :remove_file "%ToolsPath%\curl.exe"
|
||||
|
||||
call "%~dp0clean.bat"
|
||||
|
||||
endlocal
|
||||
exit /B 0
|
||||
|
||||
:remove_dir
|
||||
if not exist %1 goto :EOF
|
||||
del /s /f /q %1 >nul
|
||||
rmdir /s /q %1
|
||||
goto :EOF
|
||||
|
||||
:remove_file
|
||||
if not exist %1 goto :EOF
|
||||
del /q %1 >nul
|
||||
goto :EOF
|
@ -1,36 +1,3 @@
|
||||
@setlocal
|
||||
|
||||
@echo off
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0_env.bat"
|
||||
|
||||
call :remove_dir "%LibsPath%"
|
||||
|
||||
call :remove_file "%CurPath%bzip2"
|
||||
call :remove_file "%CurPath%curl"
|
||||
call :remove_file "%CurPath%ffmpeg"
|
||||
call :remove_file "%CurPath%libmicrohttpd"
|
||||
call :remove_file "%CurPath%libxml2"
|
||||
call :remove_file "%CurPath%libxslt"
|
||||
call :remove_file "%CurPath%miniupnpc"
|
||||
call :remove_file "%CurPath%opencv"
|
||||
call :remove_file "%CurPath%openssl"
|
||||
call :remove_file "%CurPath%speex"
|
||||
call :remove_file "%CurPath%speexdsp"
|
||||
call :remove_file "%CurPath%sqlcipher"
|
||||
call :remove_file "%CurPath%zlib"
|
||||
|
||||
endlocal
|
||||
exit /B 0
|
||||
|
||||
:remove_dir
|
||||
if not exist %1 goto :EOF
|
||||
del /s /f /q %1 >nul
|
||||
rmdir /s /q %1
|
||||
goto :EOF
|
||||
|
||||
:remove_file
|
||||
if not exist %1 goto :EOF
|
||||
del /q %1 >nul
|
||||
goto :EOF
|
||||
call "%~dp0build-libs.bat" clean
|
||||
|
14
build_scripts/Windows/build_libs/env.bat
Normal file
14
build_scripts/Windows/build_libs/env.bat
Normal file
@ -0,0 +1,14 @@
|
||||
set CurPath=%~dp0
|
||||
|
||||
:: Check MinGW environment
|
||||
set MinGWPath=
|
||||
call "%ToolsPath%\find-in-path.bat" MinGWPath gcc.exe
|
||||
if "%MinGWPath%"=="" echo Please run command in the Qt Command Prompt or add the path to MinGW bin folder to PATH variable.& exit /B 1
|
||||
|
||||
:: Get gcc versions
|
||||
call "%ToolsPath%\get-gcc-version.bat" GCCVersion
|
||||
if "%GCCVersion%"=="" echo Cannot get gcc version.& exit /B 1
|
||||
|
||||
set BuildLibsPath=%EnvRootPath%\build-libs\gcc-%GCCVersion%
|
||||
|
||||
exit /B 0
|
@ -1,16 +0,0 @@
|
||||
@setlocal
|
||||
|
||||
@echo off
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0_env.bat"
|
||||
|
||||
if not exist "%MSYSPath%\bin\mingw-get.exe" exit /B 0
|
||||
|
||||
echo Update MSYS
|
||||
pushd "%MSYSPath%\bin"
|
||||
mingw-get.exe update
|
||||
mingw-get.exe upgrade
|
||||
popd
|
||||
|
||||
exit /B %ERRORLEVEL%
|
19
build_scripts/Windows/env.bat
Normal file
19
build_scripts/Windows/env.bat
Normal file
@ -0,0 +1,19 @@
|
||||
call :make_path SourcePath "%~dp0..\.."
|
||||
call :make_path RootPath "%SourcePath%\.."
|
||||
call :source_name SourceName "%SourcePath%"
|
||||
set ToolsPath=%~dp0tools
|
||||
set EnvPath=%~dp0env
|
||||
|
||||
exit /B 0
|
||||
|
||||
:make_path
|
||||
setlocal
|
||||
set Var=%~1
|
||||
pushd %2
|
||||
set CD=%cd%
|
||||
popd
|
||||
endlocal & set %Var%=%CD%
|
||||
goto :EOF
|
||||
|
||||
:source_name
|
||||
set %~1=%~nx2
|
16
build_scripts/Windows/env/env-msys.bat
vendored
Normal file
16
build_scripts/Windows/env/env-msys.bat
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
:: Usage:
|
||||
:: call find-in-path.bat [reinstall|clean]
|
||||
|
||||
:: Initialize environment
|
||||
call "%~dp0env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
set EnvMSYSPath=%EnvRootPath%\msys
|
||||
|
||||
call "%~dp0tools\prepare-msys.bat" %1
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:error_env
|
||||
echo Failed to initialize environment.
|
||||
endlocal
|
||||
exit /B 1
|
29
build_scripts/Windows/env/env.bat
vendored
Normal file
29
build_scripts/Windows/env/env.bat
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
:: Initialize environment
|
||||
call "%~dp0..\env.bat"
|
||||
if errorlevel 1 goto error_env
|
||||
|
||||
set EnvRootPath=%RootPath%\%SourceName%-env
|
||||
set EnvToolsPath=%EnvRootPath%\tools
|
||||
set EnvTempPath=%EnvRootPath%\tmp
|
||||
set EnvDownloadPath=%EnvRootPath%\download
|
||||
|
||||
set EnvCurlExe=%EnvToolsPath%\curl.exe
|
||||
set EnvSevenZipExe=%EnvToolsPath%\7z.exe
|
||||
set EnvJomExe=%EnvToolsPath%\jom.exe
|
||||
set EnvSedExe=%EnvToolsPath%\sed.exe
|
||||
set EnvCutExe=%EnvToolsPath%\cut.exe
|
||||
set EnvDependsExe=%EnvToolsPath%\depends.exe
|
||||
set EnvMakeNSISExe=%EnvToolsPath%\NSIS\makensis.exe
|
||||
|
||||
:: Create folders
|
||||
if not exist "%EnvRootPath%" mkdir "%EnvRootPath%"
|
||||
if not exist "%EnvToolsPath%" mkdir "%EnvToolsPath%"
|
||||
if not exist "%EnvDownloadPath%" mkdir "%EnvDownloadPath%"
|
||||
|
||||
call "%~dp0tools\prepare-tools.bat"
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:error_env
|
||||
echo Failed to initialize environment.
|
||||
endlocal
|
||||
exit /B 1
|
83
build_scripts/Windows/env/tools/prepare-msys.bat
vendored
Normal file
83
build_scripts/Windows/env/tools/prepare-msys.bat
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
:: Usage:
|
||||
:: call prepare-msys.bat [reinstall|clean]
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
if "%EnvMSYSPath%"=="" exit /B 1
|
||||
if not exist "%EnvRootPath%"=="" exit /B 1
|
||||
|
||||
copy "%~dp0root\update-msys.bat" "%EnvRootPath%" >nul
|
||||
|
||||
if "%~1"=="clean" (
|
||||
echo Clean MSYS
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvMSYSPath%"
|
||||
goto exit
|
||||
)
|
||||
|
||||
if exist "%EnvMSYSPath%\bin\mingw-get.exe" (
|
||||
if "%~1"=="reinstall" (
|
||||
choice /M "Found existing MSYS version. Do you want to proceed?"
|
||||
if !ERRORLEVEL!==2 goto exit
|
||||
) else (
|
||||
goto exit
|
||||
)
|
||||
)
|
||||
|
||||
set MSYSInstall=mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip
|
||||
set CMakeInstall=cmake-3.1.0-win32-x86.zip
|
||||
set CMakeUnpackPath=%EnvMSYSPath%\msys\1.0
|
||||
|
||||
echo Remove previous MSYS version
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvMSYSPath%"
|
||||
|
||||
echo Download installation files
|
||||
if not exist "%EnvDownloadPath%\%MSYSInstall%" "%EnvCurlExe%" -L -k http://sourceforge.net/projects/mingw/files/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/%MSYSInstall%/download -o "%EnvDownloadPath%\%MSYSInstall%"
|
||||
if not exist "%EnvDownloadPath%%\MSYSInstall%" echo Cannot download MSYS& goto error
|
||||
|
||||
if not exist "%EnvDownloadPath%\%CMakeInstall%" "%EnvCurlExe%" -L -k http://www.cmake.org/files/v3.1/cmake-3.1.0-win32-x86.zip -o "%EnvDownloadPath%\%CMakeInstall%"
|
||||
if not exist "%EnvDownloadPath%\%CMakeInstall%" echo Cannot download CMake& goto error
|
||||
|
||||
echo Unpack MSYS
|
||||
"%EnvSevenZipExe%" x -o"%EnvMSYSPath%" "%EnvDownloadPath%\%MSYSInstall%"
|
||||
|
||||
echo Install MSYS
|
||||
if not exist "%EnvMSYSPath%\var\lib\mingw-get\data\profile.xml" copy "%EnvMSYSPath%\var\lib\mingw-get\data\defaults.xml" "%EnvMSYSPath%\var\lib\mingw-get\data\profile.xml"
|
||||
pushd "%EnvMSYSPath%\bin"
|
||||
mingw-get.exe install mingw32-mingw-get
|
||||
mingw-get.exe install msys-coreutils
|
||||
mingw-get.exe install msys-base
|
||||
mingw-get.exe install msys-autoconf
|
||||
mingw-get.exe install msys-automake
|
||||
mingw-get.exe install msys-autogen
|
||||
mingw-get.exe install msys-mktemp
|
||||
mingw-get.exe install msys-wget
|
||||
popd
|
||||
|
||||
echo Unpack CMake
|
||||
"%EnvSevenZipExe%" x -o"%CMakeUnpackPath%" "%EnvDownloadPath%\%CMakeInstall%"
|
||||
|
||||
echo Install CMake
|
||||
set CMakeVersion=
|
||||
for /D %%F in (%CMakeUnpackPath%\cmake*) do set CMakeVersion=%%~nxF
|
||||
if "%CMakeVersion%"=="" echo CMake version not found.& goto :exit
|
||||
echo Found CMake version %CMakeVersion%
|
||||
|
||||
set FoundProfile=
|
||||
for /f "tokens=3" %%F in ('find /c /i "%CMakeVersion%" "%EnvMSYSPath%\msys\1.0\etc\profile"') do set FoundProfile=%%F
|
||||
|
||||
if "%FoundProfile%"=="0" (
|
||||
echo export PATH="${PATH}:/%CMakeVersion%/bin">>"%EnvMSYSPath%\msys\1.0\etc\profile"
|
||||
)
|
||||
|
||||
:exit
|
||||
endlocal
|
||||
exit /B 0
|
||||
|
||||
:error
|
||||
endlocal
|
||||
exit /B 1
|
||||
|
||||
:error_vars
|
||||
echo Failed to initialize variables.
|
||||
endlocal
|
||||
exit /B 1
|
139
build_scripts/Windows/env/tools/prepare-tools.bat
vendored
Normal file
139
build_scripts/Windows/env/tools/prepare-tools.bat
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
setlocal
|
||||
|
||||
if "%EnvRootPath%"=="" exit /B 1
|
||||
|
||||
set SevenZipUrl=http://7-zip.org/a/7z1602.msi
|
||||
set SevenZipInstall=7z1602.msi
|
||||
set CurlUrl=https://bintray.com/artifact/download/vszakats/generic/curl-7.50.1-win32-mingw.7z
|
||||
set CurlInstall=curl-7.50.1-win32-mingw.7z
|
||||
set JomUrl=http://download.qt.io/official_releases/jom/jom.zip
|
||||
set JomInstall=jom.zip
|
||||
set DependsUrl=http://www.dependencywalker.com/depends22_x86.zip
|
||||
set DependsInstall=depends22_x86.zip
|
||||
set UnixToolsUrl=http://unxutils.sourceforge.net/UnxUpdates.zip
|
||||
set UnixToolsInstall=UnxUpdates.zip
|
||||
set NSISUrl=http://prdownloads.sourceforge.net/nsis/nsis-3.0-setup.exe?download
|
||||
set NSISInstall=nsis-3.0-setup.exe
|
||||
set NSISInstallPath=%EnvToolsPath%\NSIS
|
||||
|
||||
if not exist "%EnvToolsPath%\7z.exe" (
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
mkdir "%EnvTempPath%"
|
||||
|
||||
echo Download 7z installation
|
||||
|
||||
if not exist "%EnvDownloadPath%\%SevenZipInstall%" call "%ToolsPath%\winhttpjs.bat" %SevenZipUrl% -saveTo "%EnvDownloadPath%\%SevenZipInstall%"
|
||||
if not exist "%EnvDownloadPath%\%SevenZipInstall%" echo Cannot download 7z installation& goto error
|
||||
|
||||
echo Unpack 7z
|
||||
msiexec /a "%EnvDownloadPath%\%SevenZipInstall%" /qb TARGETDIR="%EnvTempPath%"
|
||||
copy "%EnvTempPath%\Files\7-Zip\7z.dll" "%EnvToolsPath%"
|
||||
copy "%EnvTempPath%\Files\7-Zip\7z.exe" "%EnvToolsPath%"
|
||||
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
)
|
||||
|
||||
if not exist "%EnvToolsPath%\curl.exe" (
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
mkdir "%EnvTempPath%"
|
||||
|
||||
echo Download Curl installation
|
||||
|
||||
if not exist "%EnvDownloadPath%\%CurlInstall%" call "%ToolsPath%\winhttpjs.bat" %CurlUrl% -saveTo "%EnvDownloadPath%\%CurlInstall%"
|
||||
if not exist "%EnvDownloadPath%\%CurlInstall%" echo Cannot download Curl installation& goto error
|
||||
|
||||
echo Unpack Curl
|
||||
"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%CurlInstall%"
|
||||
copy "%EnvTempPath%\curl-7.50.1-win32-mingw\bin\curl.exe" "%EnvToolsPath%"
|
||||
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
)
|
||||
|
||||
if not exist "%EnvToolsPath%\jom.exe" (
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
mkdir "%EnvTempPath%"
|
||||
|
||||
echo Download jom installation
|
||||
|
||||
if not exist "%EnvDownloadPath%\%JomInstall%" call "%ToolsPath%\winhttpjs.bat" %JomUrl% -saveTo "%EnvDownloadPath%\%JomInstall%"
|
||||
if not exist "%EnvDownloadPath%\%JomInstall%" echo Cannot download jom installation& goto error
|
||||
|
||||
echo Unpack jom
|
||||
"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%JomInstall%"
|
||||
copy "%EnvTempPath%\jom.exe" "%EnvToolsPath%"
|
||||
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
)
|
||||
|
||||
if not exist "%EnvToolsPath%\depends.exe" (
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
mkdir "%EnvTempPath%"
|
||||
|
||||
echo Download Dependency Walker installation
|
||||
|
||||
if not exist "%EnvDownloadPath%\%DependsInstall%" call "%ToolsPath%\winhttpjs.bat" %DependsUrl% -saveTo "%EnvDownloadPath%\%DependsInstall%"
|
||||
if not exist "%EnvDownloadPath%\%DependsInstall%" echo Cannot download Dependendy Walker installation& goto error
|
||||
|
||||
echo Unpack Dependency Walker
|
||||
"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%DependsInstall%"
|
||||
copy "%EnvTempPath%\*" "%EnvToolsPath%"
|
||||
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
)
|
||||
|
||||
if not exist "%EnvToolsPath%\cut.exe" (
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
mkdir "%EnvTempPath%"
|
||||
|
||||
echo Download Unix Tools installation
|
||||
|
||||
if not exist "%EnvDownloadPath%\%UnixToolsInstall%" call "%ToolsPath%\winhttpjs.bat" %UnixToolsUrl% -saveTo "%EnvDownloadPath%\%UnixToolsInstall%"
|
||||
if not exist "%EnvDownloadPath%\%UnixToolsInstall%" echo Cannot download unix Tools installation& goto error
|
||||
|
||||
echo Unpack Unix Tools
|
||||
"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%UnixToolsInstall%"
|
||||
copy "%EnvTempPath%\cut.exe" "%EnvToolsPath%"
|
||||
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
)
|
||||
|
||||
if not exist "%EnvToolsPath%\sed.exe" (
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
mkdir "%EnvTempPath%"
|
||||
|
||||
echo Download Unix Tools installation
|
||||
|
||||
if not exist "%EnvDownloadPath%\%UnixToolsInstall%" call "%ToolsPath%\winhttpjs.bat" %UnixToolsUrl% -saveTo "%EnvDownloadPath%\%UnixToolsInstall%"
|
||||
if not exist "%EnvDownloadPath%\%UnixToolsInstall%" echo Cannot download Unix Tools installation& goto error
|
||||
|
||||
echo Unpack Unix Tools
|
||||
"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%UnixToolsInstall%"
|
||||
copy "%EnvTempPath%\sed.exe" "%EnvToolsPath%"
|
||||
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
)
|
||||
|
||||
if not exist "%EnvToolsPath%\NSIS\nsis.exe" (
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
mkdir "%EnvTempPath%"
|
||||
|
||||
echo Download NSIS installation
|
||||
|
||||
if not exist "%EnvDownloadPath%\%NSISInstall%" "%EnvCurlExe%" -L -k %NSISUrl% -o "%EnvDownloadPath%\%NSISInstall%"
|
||||
if not exist "%EnvDownloadPath%\%NSISInstall%" echo Cannot download NSIS installation& goto error
|
||||
|
||||
echo Unpack NSIS
|
||||
"%EnvSevenZipExe%" x -o"%EnvTempPath%" "%EnvDownloadPath%\%NSISInstall%"
|
||||
if not exist "%NSISInstallPath%" mkdir "%NSISInstallPath%"
|
||||
xcopy /s "%EnvTempPath%" "%NSISInstallPath%"
|
||||
|
||||
call "%ToolsPath%\remove-dir.bat" "%EnvTempPath%"
|
||||
)
|
||||
|
||||
:exit
|
||||
endlocal
|
||||
exit /B 0
|
||||
|
||||
:error
|
||||
endlocal
|
||||
exit /B 1
|
15
build_scripts/Windows/env/tools/root/update-msys.bat
vendored
Normal file
15
build_scripts/Windows/env/tools/root/update-msys.bat
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set MSYSPath=%~dp0msys
|
||||
|
||||
if not exist "%MSYSPath%\bin\mingw-get.exe" echo MSYS is not installed& exit /B 0
|
||||
|
||||
echo Update MSYS
|
||||
pushd "%MSYSPath%\bin"
|
||||
mingw-get.exe update
|
||||
mingw-get.exe upgrade
|
||||
popd
|
||||
|
||||
exit /B %ERRORLEVEL%
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@ -3,7 +3,6 @@
|
||||
|
||||
# Needed defines
|
||||
;!define BUILDADD ""
|
||||
;!define SOURCEDIR ""
|
||||
;!define RELEASEDIR ""
|
||||
;!define QTDIR ""
|
||||
;!define MINGWDIR ""
|
||||
@ -16,10 +15,6 @@
|
||||
!error "BUILDADD is not defined"
|
||||
!endif
|
||||
|
||||
!ifndef SOURCEDIR
|
||||
!error "SOURCEDIR is not defined"
|
||||
!endif
|
||||
|
||||
!ifndef RELEASEDIR
|
||||
!error "RELEASEDIR is not defined"
|
||||
!endif
|
||||
@ -38,12 +33,22 @@
|
||||
!define OUTDIR_ ""
|
||||
!endif
|
||||
|
||||
!ifndef INSTALLERADD
|
||||
!define INSTALLERADD ""
|
||||
!endif
|
||||
|
||||
# Source directory
|
||||
!define SOURCEDIR "..\..\.."
|
||||
|
||||
# Get version from executable
|
||||
!GetDllVersion "${RELEASEDIR}\retroshare-gui\src\release\RetroShare06.exe" VERSION_
|
||||
|
||||
!define VERSION ${VERSION_1}.${VERSION_2}.${VERSION_3}${BUILDADD}
|
||||
;!define REVISION ${VERSION_4}
|
||||
|
||||
# Get version of Qt
|
||||
!GetDllVersion "${QTDIR}\bin\QtCore4.dll" QTVERSION_
|
||||
!define QTVERSION ${QTVERSION_1}.${QTVERSION_2}.${QTVERSION_3}
|
||||
|
||||
# Check version
|
||||
!ifndef REVISION
|
||||
!error "REVISION is not defined"
|
||||
@ -71,7 +76,7 @@
|
||||
# Main Install settings
|
||||
Name "${APPNAMEANDVERSION}"
|
||||
InstallDirRegKey HKLM "Software\${APPNAME}" ""
|
||||
OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-setup.exe"
|
||||
OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-Qt-${QTVERSION}${INSTALLERADD}-setup.exe"
|
||||
BrandingText "${APPNAMEANDVERSION}"
|
||||
RequestExecutionlevel highest
|
||||
# Use compression
|
||||
@ -92,7 +97,7 @@ Var StyleSheetDir
|
||||
# Interface Settings
|
||||
!define MUI_ABORTWARNING
|
||||
!define MUI_HEADERIMAGE
|
||||
!define MUI_HEADERIMAGE_BITMAP "${SOURCEDIR}\build_scripts\Windows\HeaderImage.bmp"
|
||||
!define MUI_HEADERIMAGE_BITMAP "${SOURCEDIR}\build_scripts\Windows\installer\HeaderImage.bmp"
|
||||
;!define MUI_WELCOMEFINISHPAGE_BITMAP "...bmp"
|
||||
|
||||
# MUI defines
|
@ -3,7 +3,6 @@
|
||||
|
||||
# Needed defines
|
||||
;!define BUILDADD ""
|
||||
;!define SOURCEDIR ""
|
||||
;!define RELEASEDIR ""
|
||||
;!define QTDIR ""
|
||||
;!define MINGWDIR ""
|
||||
@ -16,10 +15,6 @@
|
||||
!error "BUILDADD is not defined"
|
||||
!endif
|
||||
|
||||
!ifndef SOURCEDIR
|
||||
!error "SOURCEDIR is not defined"
|
||||
!endif
|
||||
|
||||
!ifndef RELEASEDIR
|
||||
!error "RELEASEDIR is not defined"
|
||||
!endif
|
||||
@ -38,12 +33,22 @@
|
||||
!define OUTDIR_ ""
|
||||
!endif
|
||||
|
||||
!ifndef INSTALLERADD
|
||||
!define INSTALLERADD ""
|
||||
!endif
|
||||
|
||||
# Source directory
|
||||
!define SOURCEDIR "..\..\.."
|
||||
|
||||
# Get version from executable
|
||||
!GetDllVersion "${RELEASEDIR}\retroshare-gui\src\release\RetroShare06.exe" VERSION_
|
||||
|
||||
!define VERSION ${VERSION_1}.${VERSION_2}.${VERSION_3}${BUILDADD}
|
||||
;!define REVISION ${VERSION_4}
|
||||
|
||||
# Get version of Qt
|
||||
!GetDllVersion "${QTDIR}\bin\Qt5Core.dll" QTVERSION_
|
||||
!define QTVERSION ${QTVERSION_1}.${QTVERSION_2}.${QTVERSION_3}
|
||||
|
||||
# Check version
|
||||
!ifndef REVISION
|
||||
!error "REVISION is not defined"
|
||||
@ -71,7 +76,7 @@
|
||||
# Main Install settings
|
||||
Name "${APPNAMEANDVERSION}"
|
||||
InstallDirRegKey HKLM "Software\${APPNAME}" ""
|
||||
OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-setup.exe"
|
||||
OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-Qt-${QTVERSION}${INSTALLERADD}-setup.exe"
|
||||
BrandingText "${APPNAMEANDVERSION}"
|
||||
RequestExecutionlevel highest
|
||||
# Use compression
|
||||
@ -92,7 +97,7 @@ Var StyleSheetDir
|
||||
# Interface Settings
|
||||
!define MUI_ABORTWARNING
|
||||
!define MUI_HEADERIMAGE
|
||||
!define MUI_HEADERIMAGE_BITMAP "${SOURCEDIR}\build_scripts\Windows\HeaderImage.bmp"
|
||||
!define MUI_HEADERIMAGE_BITMAP "${SOURCEDIR}\build_scripts\Windows\installer\HeaderImage.bmp"
|
||||
;!define MUI_WELCOMEFINISHPAGE_BITMAP "...bmp"
|
||||
|
||||
# MUI defines
|
||||
@ -216,9 +221,7 @@ Section $(Section_Main) Section_Main
|
||||
File /r "${QTDIR}\plugins\imageformats\qgif.dll"
|
||||
File /r "${QTDIR}\plugins\imageformats\qicns.dll"
|
||||
File /r "${QTDIR}\plugins\imageformats\qico.dll"
|
||||
File /r "${QTDIR}\plugins\imageformats\qjp2.dll"
|
||||
File /r "${QTDIR}\plugins\imageformats\qjpeg.dll"
|
||||
File /r "${QTDIR}\plugins\imageformats\qmng.dll"
|
||||
File /r "${QTDIR}\plugins\imageformats\qsvg.dll"
|
||||
File /r "${QTDIR}\plugins\imageformats\qtga.dll"
|
||||
File /r "${QTDIR}\plugins\imageformats\qtiff.dll"
|
@ -1,46 +0,0 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
:: Modify variable when makensis.exe doesn't exist in PATH
|
||||
set NSIS_EXE=makensis.exe
|
||||
|
||||
:: Needed environment variables
|
||||
set SourceDir=%~dp0..\..
|
||||
::set ReleaseDir=
|
||||
::set QtDir=
|
||||
::set MinGWDir=
|
||||
|
||||
:: Optional environment variables
|
||||
::set OutDir=
|
||||
|
||||
:: Build defines for script
|
||||
set NSIS_PARAM=
|
||||
|
||||
if "%SourceDir%" NEQ "" set NSIS_PARAM=%NSIS_PARAM% /DSOURCEDIR="%SourceDir%"
|
||||
if "%ReleaseDir%" NEQ "" set NSIS_PARAM=%NSIS_PARAM% /DRELEASEDIR="%ReleaseDir%"
|
||||
if "%QtDir%" NEQ "" set NSIS_PARAM=%NSIS_PARAM% /DQTDIR="%QtDir%"
|
||||
if "%MinGWDir%" NEQ "" set NSIS_PARAM=%NSIS_PARAM% /DMINGWDIR="%MinGWDir%"
|
||||
if "%OutDir%" NEQ "" set NSIS_PARAM=%NSIS_PARAM% /DOUTDIR="%OutDir%"
|
||||
|
||||
:: Scan version from source
|
||||
set Revision=
|
||||
set BuildAdd=
|
||||
call "%~dp0GetRsVersion.bat" RS_REVISION_STRING Revision
|
||||
if errorlevel 1 goto exit
|
||||
call "%~dp0GetRsVersion.bat" RS_BUILD_NUMBER_ADD BuildAdd
|
||||
if errorlevel 1 goto exit
|
||||
|
||||
if "%Revision%"=="" (
|
||||
echo.
|
||||
echo Version not found
|
||||
goto exit
|
||||
)
|
||||
|
||||
set NSIS_PARAM=%NSIS_PARAM% /DREVISION=%Revision% /DBUILDADD=%BuildAdd%
|
||||
|
||||
:: Create installer
|
||||
"%NSIS_EXE%" %NSIS_PARAM% "%~dp0retroshare.nsi"
|
||||
|
||||
:exit
|
||||
endlocal
|
37
build_scripts/Windows/tools/depends.bat
Normal file
37
build_scripts/Windows/tools/depends.bat
Normal file
@ -0,0 +1,37 @@
|
||||
:: Usage:
|
||||
:: call depends.bat [list^|missing] file
|
||||
|
||||
setlocal
|
||||
|
||||
if "%2"=="" (
|
||||
echo Usage: %~nx0 [list^|missing] File
|
||||
goto :exit
|
||||
)
|
||||
|
||||
if not exist "%EnvDependsExe%" echo depends.exe not found in %EnvToolsPath%.& goto exit
|
||||
if not exist "%EnvCutExe%" echo cut.exe not found in %EnvToolsPath%.& goto exit
|
||||
|
||||
start /wait "" "%EnvDependsExe%" /c /oc:"%~dp0depends.tmp" %2
|
||||
if "%1"=="missing" (
|
||||
"%EnvCutExe%" --delimiter=, --fields=1,2 "%~dp0depends.tmp" >"%~dp0depends1.tmp"
|
||||
for /F "tokens=1,2 delims=," %%A in (%~sdp0depends1.tmp) do (
|
||||
if "%%A"=="?" (
|
||||
echo %%~B
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if "%1"=="list" (
|
||||
"%EnvCutExe%" --delimiter=, --fields=2 "%~dp0depends.tmp" >"%~dp0depends1.tmp"
|
||||
for /F "tokens=1 delims=," %%A in (%~sdp0depends1.tmp) do (
|
||||
if "%%A" NEQ "Module" (
|
||||
echo %%~A
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if exist "%~dp0depends.tmp" del /Q "%~dp0depends.tmp"
|
||||
if exist "%~dp0depends1.tmp" del /Q "%~dp0depends1.tmp"
|
||||
|
||||
:exit
|
||||
endlocal
|
26
build_scripts/Windows/tools/find-in-path.bat
Normal file
26
build_scripts/Windows/tools/find-in-path.bat
Normal file
@ -0,0 +1,26 @@
|
||||
:: Usage:
|
||||
:: call find-in-path.bat variable file
|
||||
|
||||
setlocal
|
||||
|
||||
set Var=%~1
|
||||
set File=%~2
|
||||
|
||||
if "%File%"=="" (
|
||||
echo.
|
||||
echo Parameter error.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
set FoundPath=
|
||||
|
||||
SET PathTemp="%Path:;=";"%"
|
||||
FOR %%P IN (%PathTemp%) DO (
|
||||
IF EXIST "%%~P.\%File%" (
|
||||
set FoundPath=%%~P
|
||||
goto :found
|
||||
)
|
||||
)
|
||||
|
||||
:found
|
||||
endlocal & set %Var%=%FoundPath%
|
42
build_scripts/Windows/tools/get-gcc-version.bat
Normal file
42
build_scripts/Windows/tools/get-gcc-version.bat
Normal file
@ -0,0 +1,42 @@
|
||||
:: Usage:
|
||||
:: call get-gcc-version.bat variable
|
||||
|
||||
setlocal
|
||||
|
||||
set Var=%~1
|
||||
if "%Var%"=="" (
|
||||
echo.
|
||||
echo Parameter error.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
set GCCVersion=
|
||||
|
||||
call "%~dp0find-in-path.bat" GCCPath gcc.exe
|
||||
if "%GCCPath%"=="" (
|
||||
echo.
|
||||
echo Cannot find gcc.exe in PATH.
|
||||
goto exit
|
||||
)
|
||||
|
||||
gcc --version >"%~dp0gccversion.tmp"
|
||||
for /F "tokens=1*" %%A in (%~sdp0gccversion.tmp) do (
|
||||
if "%%A"=="gcc" (
|
||||
call :find_version %%B
|
||||
goto exit
|
||||
)
|
||||
)
|
||||
|
||||
:exit
|
||||
if exist "%~dp0gccversion.tmp" del /Q "%~dp0gccversion.tmp"
|
||||
|
||||
endlocal & set %Var%=%GCCVersion%
|
||||
goto :EOF
|
||||
|
||||
:find_version
|
||||
:loop
|
||||
if "%2" NEQ "" (
|
||||
shift
|
||||
goto loop
|
||||
)
|
||||
set GCCVersion=%1
|
39
build_scripts/Windows/tools/get-git-ref.bat
Normal file
39
build_scripts/Windows/tools/get-git-ref.bat
Normal file
@ -0,0 +1,39 @@
|
||||
REM Usage:
|
||||
REM call get-git-ref.bat Variable [Branch]
|
||||
|
||||
setlocal
|
||||
|
||||
set Variable=%~1
|
||||
if "%Variable%"=="" (
|
||||
echo.
|
||||
echo Parameter error
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
set Ref=
|
||||
|
||||
:: Check git executable
|
||||
set GitPath=
|
||||
call "%~dp0find-in-path.bat" GitPath git.exe
|
||||
if "%GitPath%"=="" (
|
||||
echo.
|
||||
echo Git executable not found in PATH.
|
||||
goto exit
|
||||
)
|
||||
|
||||
set GitParameter=
|
||||
set Branch=%~2
|
||||
if "%Branch%"=="" (
|
||||
set Branch=HEAD
|
||||
set GitParameter=--head
|
||||
)
|
||||
|
||||
for /F "tokens=1*" %%A in ('git show-ref %GitParameter% %Branch%') do (
|
||||
if "%%B"=="%Branch%" (
|
||||
set Ref=%%A
|
||||
)
|
||||
)
|
||||
|
||||
:exit
|
||||
endlocal & set %Variable%=%Ref%
|
||||
exit /B 0
|
34
build_scripts/Windows/tools/get-qt-version.bat
Normal file
34
build_scripts/Windows/tools/get-qt-version.bat
Normal file
@ -0,0 +1,34 @@
|
||||
:: Usage:
|
||||
:: call get-qt-version.bat variable
|
||||
|
||||
setlocal
|
||||
|
||||
set Var=%~1
|
||||
if "%Var%"=="" (
|
||||
echo.
|
||||
echo Parameter error.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
set QtVersion=
|
||||
|
||||
call "%~dp0find-in-path.bat" QMakePath qmake.exe
|
||||
if "%QMakePath%"=="" (
|
||||
echo.
|
||||
echo Cannot find qmake.exe in PATH.
|
||||
goto exit
|
||||
)
|
||||
|
||||
qmake.exe -version >"%~dp0qtversion.tmp"
|
||||
for /F "tokens=1,2,3,4" %%A in (%~sdp0qtversion.tmp) do (
|
||||
if "%%A"=="Using" (
|
||||
set QtVersion=%%D
|
||||
goto exit
|
||||
)
|
||||
)
|
||||
|
||||
:exit
|
||||
if exist "%~dp0qtversion.tmp" del /Q "%~dp0qtversion.tmp"
|
||||
|
||||
endlocal & set %Var%=%QtVersion%
|
||||
exit /B 0
|
@ -1,33 +1,23 @@
|
||||
@:: Usage:
|
||||
@:: call GetRsVersion.bat Define Variable
|
||||
:: Usage:
|
||||
:: call get-rs-version.bat Define Variable
|
||||
|
||||
@setlocal
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set Define=%~1
|
||||
if "%Define%"=="" (
|
||||
echo.
|
||||
echo Parameter error
|
||||
endlocal
|
||||
exit /B1
|
||||
)
|
||||
|
||||
set Variable=%~2
|
||||
if "%Variable%"=="" (
|
||||
echo.
|
||||
echo Parameter error
|
||||
endlocal
|
||||
exit /B1
|
||||
echo Parameter error.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
set Result=
|
||||
set VersionFile="%~dp0..\..\libretroshare\src\retroshare\rsversion.h"
|
||||
set VersionFile="%~dp0..\..\..\libretroshare\src\retroshare\rsversion.h"
|
||||
|
||||
if not exist "%VersionFile%" (
|
||||
echo.
|
||||
echo Version file doesn't exist.
|
||||
echo %VersionFile%
|
||||
endlocal
|
||||
exit /B1
|
||||
)
|
||||
|
20
build_scripts/Windows/tools/msys-path.bat
Normal file
20
build_scripts/Windows/tools/msys-path.bat
Normal file
@ -0,0 +1,20 @@
|
||||
:: Usage:
|
||||
:: call msys-path.bat path variable
|
||||
|
||||
setlocal
|
||||
|
||||
set WinPath=%~1
|
||||
set MSYSVar=%~2
|
||||
|
||||
if "%MSYSVar%"=="" (
|
||||
echo.
|
||||
echo Parameter error.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
set MSYSPath=/%WinPath:~0,1%/%WinPath:~3%
|
||||
set MSYSPath=%MSYSPath:\=/%
|
||||
|
||||
endlocal & set %MSYSVar%=%MSYSPath%
|
||||
|
||||
exit /B 0
|
15
build_scripts/Windows/tools/remove-dir.bat
Normal file
15
build_scripts/Windows/tools/remove-dir.bat
Normal file
@ -0,0 +1,15 @@
|
||||
:: Usage:
|
||||
:: call remove-dir.bat path
|
||||
|
||||
if "%~1"=="" (
|
||||
echo.
|
||||
echo Parameter error.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
if exist %1 (
|
||||
del /s /f /q %1 >nul
|
||||
rmdir /s /q %1
|
||||
)
|
||||
|
||||
exit /B 0
|
@ -243,74 +243,66 @@ void UdpLayer::run()
|
||||
/* higher level interface */
|
||||
void UdpLayer::recv_loop()
|
||||
{
|
||||
int maxsize = 16000;
|
||||
size_t maxsize = 16000;
|
||||
void *inbuf = malloc(maxsize);
|
||||
|
||||
if(inbuf == NULL)
|
||||
{
|
||||
std::cerr << "(EE) Error in memory allocation of size " << maxsize << " in " << __PRETTY_FUNCTION__ << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
int status;
|
||||
struct timeval timeout;
|
||||
if(inbuf == NULL)
|
||||
{
|
||||
std::cerr << "(EE) Error in memory allocation of size " << maxsize
|
||||
<< " in " << __PRETTY_FUNCTION__ << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
int status;
|
||||
struct timeval timeout;
|
||||
|
||||
while(1)
|
||||
{
|
||||
fd_set rset;
|
||||
for(;;)
|
||||
for(;;)
|
||||
{
|
||||
/* check if we need to stop */
|
||||
bool toStop = false;
|
||||
{
|
||||
bdStackMutex stack(sockMtx); /********** LOCK MUTEX *********/
|
||||
bdStackMutex stack(sockMtx); (void) stack;
|
||||
toStop = stopThread;
|
||||
}
|
||||
|
||||
|
||||
if (toStop)
|
||||
{
|
||||
#ifdef DEBUG_UDP_LAYER
|
||||
std::cerr << "UdpLayer::recv_loop() stopping thread" << std::endl;
|
||||
#endif
|
||||
free(inbuf) ;
|
||||
free(inbuf);
|
||||
stop();
|
||||
return; // Avoid compiler warning about usage of inbuf after free
|
||||
}
|
||||
|
||||
FD_ZERO(&rset);
|
||||
FD_SET(sockfd, &rset);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 500000; /* 500 ms timeout */
|
||||
status = select(sockfd+1, &rset, NULL, NULL, &timeout);
|
||||
if (status > 0)
|
||||
{
|
||||
break; /* data available, go read it */
|
||||
}
|
||||
else if (status < 0)
|
||||
{
|
||||
fd_set rset;
|
||||
FD_ZERO(&rset);
|
||||
FD_SET(sockfd, &rset);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 500000; // 500 ms timeout
|
||||
status = select(sockfd+1, &rset, NULL, NULL, &timeout);
|
||||
if (status > 0) break; // data available, go read it
|
||||
#ifdef DEBUG_UDP_LAYER
|
||||
std::cerr << "UdpLayer::recv_loop() Error: " << bdnet_errno() << std::endl;
|
||||
else if (status < 0) std::cerr << "UdpLayer::recv_loop() Error: "
|
||||
<< bdnet_errno() << std::endl;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
int nsize = maxsize;
|
||||
int nsize = static_cast<int>(maxsize);
|
||||
struct sockaddr_in from;
|
||||
if (0 < receiveUdpPacket(inbuf, &nsize, from))
|
||||
{
|
||||
#ifdef DEBUG_UDP_LAYER
|
||||
std::cerr << "UdpLayer::readPkt() from : " << from << std::endl;
|
||||
std::cerr << printPkt(inbuf, nsize);
|
||||
std::cerr << "UdpLayer::readPkt() from : " << from << std::endl
|
||||
<< printPkt(inbuf, nsize);
|
||||
#endif
|
||||
// send to reciever.
|
||||
recv -> recvPkt(inbuf, nsize, from);
|
||||
recv->recvPkt(inbuf, nsize, from); // pass to reciever.
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_UDP_LAYER
|
||||
std::cerr << "UdpLayer::readPkt() not ready" << from;
|
||||
std::cerr << std::endl;
|
||||
else std::cerr << "UdpLayer::readPkt() not ready" << from << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "ApiPluginHandler.h"
|
||||
#include "ChannelsHandler.h"
|
||||
#include "StatsHandler.h"
|
||||
|
||||
/*
|
||||
data types in json http://json.org/
|
||||
@ -234,7 +235,8 @@ public:
|
||||
mTransfersHandler(sts, ifaces.mFiles),
|
||||
mChatHandler(sts, ifaces.mNotify, ifaces.mMsgs, ifaces.mPeers, ifaces.mIdentity, &mPeersHandler),
|
||||
mApiPluginHandler(sts, ifaces),
|
||||
mChannelsHandler(ifaces.mGxsChannels)
|
||||
mChannelsHandler(ifaces.mGxsChannels),
|
||||
mStatsHandler()
|
||||
{
|
||||
// the dynamic cast is to not confuse the addResourceHandler template like this:
|
||||
// addResourceHandler(derived class, parent class)
|
||||
@ -258,6 +260,8 @@ public:
|
||||
&ChatHandler::handleRequest);
|
||||
router.addResourceHandler("channels", dynamic_cast<ResourceRouter*>(&mChannelsHandler),
|
||||
&ChannelsHandler::handleRequest);
|
||||
router.addResourceHandler("stats", dynamic_cast<ResourceRouter*>(&mStatsHandler),
|
||||
&StatsHandler::handleRequest);
|
||||
}
|
||||
|
||||
PeersHandler mPeersHandler;
|
||||
@ -269,6 +273,7 @@ public:
|
||||
ChatHandler mChatHandler;
|
||||
ApiPluginHandler mApiPluginHandler;
|
||||
ChannelsHandler mChannelsHandler;
|
||||
StatsHandler mStatsHandler;
|
||||
};
|
||||
|
||||
ApiServer::ApiServer():
|
||||
|
@ -173,8 +173,8 @@ void FileSearchHandler::handleCreateSearch(Request &req, Response &resp)
|
||||
return;
|
||||
}
|
||||
|
||||
NameExpression exprs(ContainsAllStrings,words,true) ;
|
||||
LinearizedExpression lin_exp ;
|
||||
RsRegularExpression::NameExpression exprs(RsRegularExpression::ContainsAllStrings,words,true) ;
|
||||
RsRegularExpression::LinearizedExpression lin_exp ;
|
||||
exprs.linearize(lin_exp) ;
|
||||
|
||||
uint32_t search_id = RSRandom::random_u32();
|
||||
|
@ -29,7 +29,7 @@ private:
|
||||
std::vector<RsGxsId> mIds;
|
||||
StateToken mStateToken;
|
||||
protected:
|
||||
virtual void gxsDoWork(Request &req, Response &resp)
|
||||
virtual void gxsDoWork(Request& /*req*/, Response &resp)
|
||||
{
|
||||
resp.mDataStream.getStreamToMember();
|
||||
for(std::vector<RsGxsId>::iterator vit = mIds.begin(); vit != mIds.end(); ++vit)
|
||||
|
50
libresapi/src/api/StatsHandler.cpp
Normal file
50
libresapi/src/api/StatsHandler.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "StatsHandler.h"
|
||||
#include "Operators.h"
|
||||
|
||||
#include <retroshare/rsconfig.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <pqi/authssl.h>
|
||||
|
||||
namespace resource_api
|
||||
{
|
||||
|
||||
StatsHandler::StatsHandler()
|
||||
{
|
||||
addResourceHandler("*", this, &StatsHandler::handleStatsRequest);
|
||||
}
|
||||
|
||||
void StatsHandler::handleStatsRequest(Request &/*req*/, Response &resp)
|
||||
{
|
||||
StreamBase& itemStream = resp.mDataStream.getStreamToMember();
|
||||
|
||||
// location info
|
||||
itemStream << makeKeyValue("name", rsPeers->getGPGName(rsPeers->getGPGOwnId()));
|
||||
itemStream << makeKeyValue("location", AuthSSL::getAuthSSL()->getOwnLocation());
|
||||
|
||||
// peer info
|
||||
unsigned int all, online;
|
||||
rsPeers->getPeerCount(&all, &online, false);
|
||||
itemStream << makeKeyValue("peers_all", all);
|
||||
itemStream << makeKeyValue("peers_connected", online);
|
||||
|
||||
// bandwidth info
|
||||
float downKb, upKb;
|
||||
rsConfig->GetCurrentDataRates(downKb, upKb);
|
||||
itemStream << makeKeyValue("bandwidth_up_kb", (double)upKb);
|
||||
itemStream << makeKeyValue("bandwidth_down_kb", (double)downKb);
|
||||
|
||||
// DHT/NAT info
|
||||
RsConfigNetStatus config;
|
||||
rsConfig->getConfigNetStatus(config);
|
||||
itemStream << makeKeyValue("dht_active", config.DHTActive);
|
||||
itemStream << makeKeyValue("dht_ok", config.netDhtOk);
|
||||
itemStream << makeKeyValue("dht_size_all", config.netDhtNetSize);
|
||||
itemStream << makeKeyValue("dht_size_rs", config.netDhtRsNetSize);
|
||||
uint32_t netState = rsConfig -> getNetState();
|
||||
itemStream << makeKeyValue("nat_state", netState);
|
||||
|
||||
// ok
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
} // namespace resource_api
|
25
libresapi/src/api/StatsHandler.h
Normal file
25
libresapi/src/api/StatsHandler.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef STATSHANDLER_H
|
||||
#define STATSHANDLER_H
|
||||
|
||||
/*
|
||||
* simple class to output some basic stats about RS
|
||||
* like bandwidth, connected peers, ...
|
||||
*/
|
||||
|
||||
#include "ResourceRouter.h"
|
||||
|
||||
namespace resource_api
|
||||
{
|
||||
|
||||
class StatsHandler : public ResourceRouter
|
||||
{
|
||||
public:
|
||||
StatsHandler();
|
||||
|
||||
private:
|
||||
void handleStatsRequest(Request& req, Response& resp);
|
||||
};
|
||||
|
||||
} // namespace resource_api
|
||||
|
||||
#endif // STATSHANDLER_H
|
@ -824,7 +824,6 @@ static Value DeserializeValue(std::string& str, bool* had_error, std::stack<Stac
|
||||
std::string temp_val;
|
||||
size_t i = 0;
|
||||
bool found_digit = false;
|
||||
bool found_first_valid_char = false;
|
||||
|
||||
for (; i < str.length(); i++)
|
||||
{
|
||||
@ -894,7 +893,6 @@ static Value DeserializeValue(std::string& str, bool* had_error, std::stack<Stac
|
||||
if (std::isdigit(str[i]))
|
||||
found_digit = true;
|
||||
|
||||
found_first_valid_char = true;
|
||||
temp_val += str[i];
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,8 @@ SOURCES += \
|
||||
api/TmpBlobStore.cpp \
|
||||
util/ContentTypes.cpp \
|
||||
api/ApiPluginHandler.cpp \
|
||||
api/ChannelsHandler.cpp
|
||||
api/ChannelsHandler.cpp \
|
||||
api/StatsHandler.cpp
|
||||
|
||||
HEADERS += \
|
||||
api/ApiServer.h \
|
||||
@ -172,7 +173,8 @@ HEADERS += \
|
||||
api/TmpBlobStore.h \
|
||||
util/ContentTypes.h \
|
||||
api/ApiPluginHandler.h \
|
||||
api/ChannelsHandler.h
|
||||
api/ChannelsHandler.h \
|
||||
api/StatsHandler.h
|
||||
|
||||
libresapilocalserver {
|
||||
CONFIG *= qt
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,475 +0,0 @@
|
||||
/*
|
||||
* RetroShare FileCache Module: cachestrapper.h
|
||||
*
|
||||
* Copyright 2004-2007 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MRK_CACHE_STRAPPER_H
|
||||
#define MRK_CACHE_STRAPPER_H
|
||||
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
/******************* CacheStrapper and Related Classes *******************
|
||||
* A generic Cache Update system.
|
||||
*
|
||||
* CacheStrapper: maintains a set of CacheSources, and CacheStores,
|
||||
* queries and updates as new information arrives.
|
||||
*
|
||||
* CacheTransfer: Interface for FileTransfer Class to support.
|
||||
*
|
||||
* CacheSource: Base Class for cache data provider. eg. FileIndexMonitor.
|
||||
* CacheStore: Base Class for data cache. eg. FileCache/Store.
|
||||
*
|
||||
* Still TODO:
|
||||
* (1) Design and Implement the Upload side of CacheTransfer/CacheStrapper.
|
||||
* (2) CacheStrapper:: Save / Load Cache lists....
|
||||
* (3) Clean up lists, maps on shutdown etc.
|
||||
* (4) Consider Mutexes for multithreaded operations.
|
||||
* (5) Test the MultiSource/Store capabilities.
|
||||
*
|
||||
******************* CacheStrapper and Related Classes *******************/
|
||||
|
||||
|
||||
class CacheTransfer; /* Interface for File Transfer */
|
||||
class CacheSource; /* Interface for local File Index/Monitor */
|
||||
class CacheStore; /* Interface for the actual Cache */
|
||||
class CacheStrapper; /* Controlling Class */
|
||||
|
||||
/******************************** CacheId ********************************/
|
||||
|
||||
/*!
|
||||
* Use this to identify the type of cache source, strapper,
|
||||
*/
|
||||
class CacheId
|
||||
{
|
||||
public:
|
||||
CacheId() :type(0), subid(0) { return; }
|
||||
CacheId(uint16_t a, uint16_t b) :type(a), subid(b) { return; }
|
||||
uint16_t type; /// cache types, this should be set to services type
|
||||
uint16_t subid; /// should be initialised when using multicache feature of cachestrapper
|
||||
};
|
||||
|
||||
|
||||
bool operator<(const CacheId &a, const CacheId &b);
|
||||
|
||||
/*!
|
||||
* Use for identifying physical files that have been chosen as cache data
|
||||
* note: this does not actual store the data but serves to locate on network (via hash attribute,
|
||||
* and on file via path)
|
||||
*/
|
||||
class RsCacheData
|
||||
{
|
||||
public:
|
||||
|
||||
RsPeerId pid; /// peer id
|
||||
/// REMOVED as a WASTE to look it up everywhere! std::string pname; /// peer name (can be used by cachestore)
|
||||
CacheId cid; /// cache id
|
||||
std::string path; /// file system path where physical cache data is located
|
||||
std::string name;
|
||||
RsFileHash hash;
|
||||
uint64_t size;
|
||||
time_t recvd; /// received timestamp
|
||||
};
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsCacheData &d);
|
||||
|
||||
/***************************** CacheTransfer *****************************/
|
||||
|
||||
/**
|
||||
* Interface for FileTransfer Class to support cache
|
||||
*/
|
||||
class CacheTransfer
|
||||
{
|
||||
public:
|
||||
|
||||
CacheTransfer(CacheStrapper *cs) :strapper(cs) { return; }
|
||||
virtual ~CacheTransfer() {}
|
||||
|
||||
/*!
|
||||
* upload side of things .... searches through CacheStrapper.
|
||||
*/
|
||||
bool FindCacheFile(const RsFileHash& hash, std::string &path, uint64_t &size);
|
||||
|
||||
/*!
|
||||
* At the download side RequestCache() => overloaded RequestCacheFile()
|
||||
* the class should then call CompletedCache() or FailedCache()
|
||||
*/
|
||||
bool RequestCache(RsCacheData &data, CacheStore *cbStore); /* request from CacheStore */
|
||||
|
||||
protected:
|
||||
|
||||
/*!
|
||||
* to be overloaded
|
||||
*/
|
||||
virtual bool RequestCacheFile(const RsPeerId& id, std::string path, const RsFileHash& hash, uint64_t size);
|
||||
virtual bool CancelCacheFile(const RsPeerId& id, std::string path, const RsFileHash& hash, uint64_t size);
|
||||
|
||||
bool CompletedCache(const RsFileHash &hash); /* internal completion -> does cb */
|
||||
bool FailedCache(const RsFileHash &hash); /* internal completion -> does cb */
|
||||
|
||||
private:
|
||||
|
||||
CacheStrapper *strapper;
|
||||
|
||||
std::map<RsFileHash, RsCacheData> cbData;
|
||||
std::map<RsFileHash, CacheStore *> cbStores;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/************************ CacheSource/CacheStore *************************/
|
||||
|
||||
typedef std::map<uint16_t, RsCacheData> CacheSet;
|
||||
|
||||
/*!
|
||||
* Implements features needed for a service to act as a cachesource and allow pushing a of cache data from service to strapper
|
||||
* Service is able to use this class for refresh its cache (push cache data)
|
||||
* and interface to load and check cache availablility among peers (source of cache data)
|
||||
* Architecturally Cachestrapper maintains the cachesource (which is passed as a pointer handle) while the cachesource-inheriting
|
||||
* service can update cachesource as to new cache sources (cache data) created. Equivalently it enquiries through cache source for
|
||||
* new cache data from peers
|
||||
* @see p3Distrib
|
||||
*/
|
||||
class CacheSource
|
||||
{
|
||||
public:
|
||||
|
||||
CacheSource(uint16_t t, bool m, CacheStrapper *cs, std::string cachedir);
|
||||
virtual ~CacheSource() {}
|
||||
|
||||
/*!
|
||||
* called to determine available cache for peer -
|
||||
* default acceptable (returns all)
|
||||
*/
|
||||
virtual bool cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids)=0;
|
||||
|
||||
/*!
|
||||
* function called at startup to load from
|
||||
* configuration file....
|
||||
* to be overloaded by inherited class
|
||||
*/
|
||||
virtual bool loadLocalCache(const RsCacheData &data);
|
||||
|
||||
/* control Caches available */
|
||||
bool refreshCache(const RsCacheData &data,const std::set<RsPeerId>& destination_peers);
|
||||
bool refreshCache(const RsCacheData &data);
|
||||
bool clearCache(CacheId id);
|
||||
|
||||
/* controls if peer is an accepted receiver for cache items. Default is yes. To be overloaded. */
|
||||
virtual bool isPeerAcceptedAsCacheReceiver(const RsPeerId& /*peer_id*/) { return true ; }
|
||||
|
||||
/* get private data */
|
||||
std::string getCacheDir() { return cacheDir; }
|
||||
bool isMultiCache() { return multiCache; }
|
||||
uint16_t getCacheType() { return cacheType; }
|
||||
|
||||
/* display */
|
||||
void listCaches(std::ostream &out);
|
||||
|
||||
/* search */
|
||||
bool findCache(const RsFileHash& hash, RsCacheData &data) const;
|
||||
|
||||
protected:
|
||||
|
||||
uint16_t cacheType; /// for checking of cache type (usually of child class of source)
|
||||
bool multiCache; /// whether multisource is in use or not.
|
||||
CacheStrapper *mStrapper;
|
||||
|
||||
/*** MUTEX LOCKING */
|
||||
void lockData() const;
|
||||
void unlockData() const;
|
||||
|
||||
CacheSet caches; /// all local cache data stored here
|
||||
std::map<RsFileHash, RsCacheData> mOldCaches; /// replaced/cleared caches are pushed here (in case requested)
|
||||
|
||||
private:
|
||||
|
||||
std::string cacheDir;
|
||||
mutable RsMutex cMutex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* Base Class for data cache. eg. FileCache/Store.
|
||||
* This is best used to deal with external caches from other peers
|
||||
* @see p3Distrib. pqiMonitor
|
||||
*/
|
||||
class CacheStore
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param t set to particular rs_service id. see rsserviceids.h
|
||||
* @param m whether this is multicache service (true) or not(false)
|
||||
* @param cs cache strapper instance responsible for maintaining the cache service
|
||||
* @param cft cache transfer instance responsible for rquestiing and tranfering caches
|
||||
* @param cachedir directory used to store cache related info for cachestore client
|
||||
* @return
|
||||
*/
|
||||
CacheStore(uint16_t t, bool m, CacheStrapper *cs, CacheTransfer *cft, std::string cachedir);
|
||||
virtual ~CacheStore() {}
|
||||
|
||||
/* current stored data */
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param data returns cache data for pid/cid set in data itself
|
||||
* @return false is unsuccessful and vice versa
|
||||
*/
|
||||
bool getStoredCache(RsCacheData &data); /* use pid/cid in data */
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param data all cache store by cachestore is store here
|
||||
* @return false not returned, only true at the moment
|
||||
*/
|
||||
bool getAllStoredCaches(std::list<RsCacheData> &data); /* use pid/cid in data */
|
||||
|
||||
/*!
|
||||
* input from CacheStrapper -> store can then download new data
|
||||
*/
|
||||
void availableCache(const RsCacheData &data);
|
||||
|
||||
/*!
|
||||
* should be called when the download is completed ... cache data is loaded
|
||||
*/
|
||||
void downloadedCache(const RsCacheData &data);
|
||||
|
||||
/*!
|
||||
* called if the download fails, TODO: nothing done yet
|
||||
*/
|
||||
void failedCache(const RsCacheData &data);
|
||||
|
||||
/* virtual functions overloaded by cache implementor */
|
||||
|
||||
/* controls if peer is an accepted provider for cache items. Default is yes. To be overloaded. */
|
||||
virtual bool isPeerAcceptedAsCacheProvider(const RsPeerId& /*peer_id*/) { return true ; }
|
||||
|
||||
/*!
|
||||
* @param data cache data is stored here
|
||||
* @return false is failed (cache does not exist), otherwise true
|
||||
*/
|
||||
virtual bool fetchCache(const RsCacheData &data); /* a question? */
|
||||
virtual int nameCache(RsCacheData &data); /* fill in the name/path */
|
||||
virtual int loadCache(const RsCacheData &data); /* actual load, once data available */
|
||||
|
||||
/* get private data */
|
||||
|
||||
std::string getCacheDir() { return cacheDir; }
|
||||
bool isMultiCache() { return multiCache; }
|
||||
uint16_t getCacheType() { return cacheType; }
|
||||
|
||||
/*!
|
||||
* display, e.g. can pass std::out, cerr, ofstream, etc
|
||||
*/
|
||||
void listCaches(std::ostream &out);
|
||||
|
||||
protected:
|
||||
|
||||
/*!
|
||||
* ** MUTEX LOCKING
|
||||
*/
|
||||
void lockData() const;
|
||||
|
||||
/*!
|
||||
* ** MUTEX LOCKING
|
||||
*/
|
||||
void unlockData() const;
|
||||
|
||||
/*! This function is called to store Cache Entry in the CacheStore Table.
|
||||
* it must be called from within a Mutex Lock....
|
||||
*
|
||||
* It doesn't lock itself -> to avoid race conditions
|
||||
*/
|
||||
void locked_storeCacheEntry(const RsCacheData &data);
|
||||
|
||||
/*! This function is called to store Cache Entry in the CacheStore Table.
|
||||
* it must be called from within a Mutex Lock....
|
||||
*
|
||||
* It doesn't lock itself -> to avoid race conditions
|
||||
*/
|
||||
bool locked_getStoredCache(RsCacheData &data);
|
||||
|
||||
private:
|
||||
|
||||
uint16_t cacheType; /* for checking */
|
||||
bool multiCache; /* do we care about subid's */
|
||||
|
||||
CacheStrapper *mStrapper;
|
||||
CacheTransfer *cacheTransfer;
|
||||
|
||||
std::string cacheDir;
|
||||
|
||||
mutable RsMutex cMutex;
|
||||
std::map<RsPeerId, CacheSet> caches;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***************************** CacheStrapper *****************************/
|
||||
|
||||
|
||||
/*!
|
||||
* a convenient to pass cache handles to cachestrapper to maintain the cache service
|
||||
* Make Sure you get the Ids right! see rsservicesids.h.
|
||||
* When creating a cache service this data structure is
|
||||
* source, usually the child class of store and source also serves as both handles
|
||||
* @see CacheStrapper
|
||||
*/
|
||||
class CachePair
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* Default constructor, all variables set to NULL
|
||||
*/
|
||||
CachePair()
|
||||
:source(NULL), store(NULL), id(0, 0) { return; }
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param a cache source for service
|
||||
* @param b cache store for service
|
||||
* @param c the cache service id, c.type should be set to service id service-child class of store and source
|
||||
*/
|
||||
CachePair(CacheSource *a, CacheStore *b, CacheId c)
|
||||
:source(a), store(b), id(c) { return; }
|
||||
|
||||
CacheSource *source;
|
||||
CacheStore *store;
|
||||
CacheId id; /// should be set id type to service types of store and source service-child class, and subid for multicache use
|
||||
};
|
||||
|
||||
|
||||
bool operator<(const CachePair &a, const CachePair &b);
|
||||
|
||||
/*!
|
||||
* CacheStrapper: maintains a set of CacheSources, and CacheStores,
|
||||
* queries and updates as new information arrives.
|
||||
*/
|
||||
|
||||
class p3ServiceControl;
|
||||
|
||||
class CacheStrapper: public pqiServiceMonitor, public p3Config
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @param cm handle used by strapper for getting peer connection information (online peers, sslids...)
|
||||
* @return
|
||||
*/
|
||||
CacheStrapper(p3ServiceControl *sc, uint32_t ftServiceId);
|
||||
virtual ~CacheStrapper() { return; }
|
||||
|
||||
/************* from pqiMonitor *******************/
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
/************* from pqiMonitor *******************/
|
||||
|
||||
/* Feedback from CacheSources */
|
||||
|
||||
/*!
|
||||
* send data to peers online and self
|
||||
* @param data
|
||||
*
|
||||
*/
|
||||
void refreshCache(const RsCacheData &data);
|
||||
void refreshCache(const RsCacheData &data,const std::set<RsPeerId>& destination_peers); // specify a particular list of destination peers (self not added!)
|
||||
|
||||
/*!
|
||||
* forces config savelist
|
||||
* @param data
|
||||
* @see saveList()
|
||||
*/
|
||||
void refreshCacheStore(const RsCacheData &data);
|
||||
|
||||
/*!
|
||||
* list of Caches to send out
|
||||
*/
|
||||
bool getCacheUpdates(std::list<std::pair<RsPeerId, RsCacheData> > &updates);
|
||||
|
||||
/*!
|
||||
* add to strapper's cachepair set so a related service's store and source can be maintained
|
||||
* @param pair the source and store handle for a service
|
||||
*/
|
||||
void addCachePair(CachePair pair);
|
||||
|
||||
/*** I/O (2) ***/
|
||||
void recvCacheResponse(RsCacheData &data, time_t ts);
|
||||
void handleCacheQuery(const RsPeerId& id, std::map<CacheId, RsCacheData> &data);
|
||||
|
||||
|
||||
/*!
|
||||
* search through CacheSources.
|
||||
* @return false if cachedate mapping to hash not found
|
||||
*/
|
||||
bool findCache(const RsFileHash &hash, RsCacheData &data) const;
|
||||
|
||||
/* display */
|
||||
void listCaches(std::ostream &out);
|
||||
|
||||
/*!
|
||||
* does not do anything
|
||||
* @param out
|
||||
* @deprecated
|
||||
*/
|
||||
void listPeerStatus(std::ostream &out);
|
||||
|
||||
/**
|
||||
* Checks if the cache physically exist at path given
|
||||
* @param data
|
||||
* @return whether it exists or not
|
||||
*/
|
||||
bool CacheExist(RsCacheData& data);
|
||||
|
||||
/* Config */
|
||||
protected:
|
||||
|
||||
/* Key Functions to be overloaded for Full Configuration */
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
virtual bool loadList(std::list<RsItem *>& load);
|
||||
|
||||
private:
|
||||
|
||||
/* these are static - so shouldn't need mutex */
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
uint32_t mFtServiceId;
|
||||
|
||||
std::map<uint16_t, CachePair> caches;
|
||||
|
||||
RsMutex csMtx; /* protect below */
|
||||
|
||||
std::list<std::pair<RsPeerId, RsCacheData> > mCacheUpdates;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* RetroShare FileCache Module: cachetest.h
|
||||
*
|
||||
* Copyright 2004-2007 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MRK_TEST_CACHE_H
|
||||
#define MRK_TEST_CACHE_H
|
||||
|
||||
#include "cachestrapper.h"
|
||||
|
||||
#define TESTID 0xffff
|
||||
#define TESTID2 0xffee
|
||||
|
||||
class CacheTestSource: public CacheSource
|
||||
{
|
||||
public:
|
||||
CacheTestSource(CacheStrapper *cs, std::string dir)
|
||||
:CacheSource(cs, TESTID, false, dir) { return; }
|
||||
};
|
||||
|
||||
class CacheTestStore: public CacheStore
|
||||
{
|
||||
public:
|
||||
CacheTestStore(CacheTransfer *cft, std::string dir)
|
||||
:CacheStore(TESTID, false, cft, dir) { return; }
|
||||
};
|
||||
|
||||
|
||||
class CacheTestMultiSource: public CacheSource
|
||||
{
|
||||
public:
|
||||
CacheTestMultiSource(CacheStrapper *cs, std::string dir)
|
||||
:CacheSource(cs, TESTID2, true, dir) { return; }
|
||||
};
|
||||
|
||||
class CacheTestMultiStore: public CacheStore
|
||||
{
|
||||
public:
|
||||
CacheTestMultiStore(CacheTransfer *cft, std::string dir)
|
||||
:CacheStore(TESTID2, true, cft, dir) { return; }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,220 +0,0 @@
|
||||
/*
|
||||
* RetroShare FileCache Module: fimonitor.h
|
||||
*
|
||||
* Copyright 2004-2007 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILE_INDEX_MONITOR_H
|
||||
#define FILE_INDEX_MONITOR_H
|
||||
|
||||
#include "dbase/cachestrapper.h"
|
||||
#include "dbase/findex.h"
|
||||
#include "util/rsthreads.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
|
||||
/******************************************************************************************
|
||||
* The Local Monitoring Class: FileIndexMonitor.
|
||||
*
|
||||
* This periodically scans the directory tree, and updates any modified directories/files.
|
||||
*
|
||||
*****************************************************************************************/
|
||||
|
||||
/******************************************************************************************
|
||||
STILL TODO:
|
||||
|
||||
(1) Implement Hash function.
|
||||
|
||||
bool FileIndexMonitor::hashFile(std::string path, FileEntry &fi);
|
||||
|
||||
(2) Add Shared directory controls to Monitor.
|
||||
|
||||
int FileIndexMonitor::addSharedDirectory(std::path);
|
||||
int FileIndexMonitor::removeSharedDirectory(std::path);
|
||||
std::string FileIndexMonitor::findRealRoot(std::string base);
|
||||
|
||||
These must be split into <base>/<top> and the mapping saved.
|
||||
eg: addSharedDirectory("c:/home/stuff/dir1") --> "c:/home/stuff" <-> "dir1"
|
||||
This code has been written already, and can just be moved over.
|
||||
|
||||
FOR LATER:
|
||||
(2) Port File/Directory lookup code to windoze. (or compile dirent.c under windoze)
|
||||
(3) Add Load/Store interface to FileIndexMonitor. (later)
|
||||
(4) Integrate with real Thread/Mutex code (last thing to do)
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
|
||||
class DirContentToHash
|
||||
{
|
||||
public:
|
||||
std::vector<FileEntry> fentries ;
|
||||
|
||||
std::string realpath ;
|
||||
std::string dirpath ;
|
||||
};
|
||||
|
||||
class HashCache
|
||||
{
|
||||
public:
|
||||
HashCache(const std::string& save_file_name) ;
|
||||
|
||||
void save() ;
|
||||
void insert(const std::string& full_path,uint64_t size,time_t time_stamp,const RsFileHash& hash) ;
|
||||
bool find(const std::string& full_path,uint64_t size,time_t time_stamp,RsFileHash& hash) ;
|
||||
void clean() ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t size ;
|
||||
uint64_t time_stamp ;
|
||||
uint64_t modf_stamp ;
|
||||
RsFileHash hash ;
|
||||
} HashCacheInfo ;
|
||||
|
||||
void setRememberHashFilesDuration(uint32_t days) { _max_cache_duration_days = days ; }
|
||||
uint32_t rememberHashFilesDuration() const { return _max_cache_duration_days ; }
|
||||
void clear() { _files.clear(); }
|
||||
bool empty() const { return _files.empty() ; }
|
||||
private:
|
||||
uint32_t _max_cache_duration_days ; // maximum duration of un-requested cache entries
|
||||
std::map<std::string, HashCacheInfo> _files ;
|
||||
std::string _path ;
|
||||
bool _changed ;
|
||||
};
|
||||
|
||||
/******************************************************************************************
|
||||
* FileIndexMonitor
|
||||
*****************************************************************************************/
|
||||
|
||||
class FileIndexMonitor: public CacheSource, public RsTickingThread
|
||||
{
|
||||
public:
|
||||
FileIndexMonitor(CacheStrapper *cs, std::string cachedir, const RsPeerId& pid, const std::string& config_dir);
|
||||
virtual ~FileIndexMonitor();
|
||||
|
||||
/* external interface for filetransfer */
|
||||
bool findLocalFile(const RsFileHash& hash,FileSearchFlags flags,const RsPeerId& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<RsNodeGroupId>& parent_groups) const;
|
||||
|
||||
int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) ;
|
||||
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
|
||||
|
||||
int filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
|
||||
|
||||
|
||||
/* external interface for local access to files */
|
||||
bool convertSharedFilePath(std::string path, std::string &fullpath);
|
||||
|
||||
|
||||
/* Interacting with CacheSource */
|
||||
/* overloaded from CacheSource */
|
||||
virtual bool loadLocalCache(const RsCacheData &data); /* called with stored data */
|
||||
bool updateCache(const RsCacheData &data,const std::set<RsPeerId>& dest_peers); /* we call when we have a new cache for others */
|
||||
|
||||
|
||||
/* the FileIndexMonitor inner workings */
|
||||
//virtual void run(std::string& currentJob); /* overloaded from RsThread */
|
||||
//void updateCycle(std::string& currentJob);
|
||||
virtual void data_tick(); /* overloaded from RsThread */
|
||||
void updateCycle();
|
||||
|
||||
// Interface for browsing dir hirarchy
|
||||
int RequestDirDetails(void*, DirDetails&, FileSearchFlags) const ;
|
||||
uint32_t getType(void*) const ;
|
||||
int RequestDirDetails(const std::string& path, DirDetails &details) const ;
|
||||
|
||||
// set/update shared directories
|
||||
virtual void setSharedDirectories(const std::list<SharedDirInfo>& dirs);
|
||||
void getSharedDirectories(std::list<SharedDirInfo>& dirs);
|
||||
void updateShareFlags(const SharedDirInfo& info) ;
|
||||
|
||||
void forceDirectoryCheck(); // Force re-sweep the directories and see what's changed
|
||||
void forceDirListsRebuildAndSend() ; // Force re-build dir lists because groups have changed. Does not re-check files.
|
||||
bool inDirectoryCheck();
|
||||
|
||||
/* util fns */
|
||||
|
||||
// from CacheSource
|
||||
virtual bool cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids) ;
|
||||
|
||||
protected:
|
||||
// Sets/gets the duration period within which already hashed files are remembered.
|
||||
//
|
||||
void setRememberHashFilesDuration(uint32_t days) ;
|
||||
uint32_t rememberHashFilesDuration() const ;
|
||||
void setRememberHashFiles(bool) ;
|
||||
bool rememberHashFiles() ;
|
||||
// Remove any memory of formerly hashed files that are not shared anymore
|
||||
void clearHashFiles() ;
|
||||
void setPeriod(int insecs);
|
||||
int getPeriod() const;
|
||||
|
||||
bool autoCheckEnabled() const ;
|
||||
|
||||
private:
|
||||
/* the mutex should be locked before calling these 3. */
|
||||
|
||||
// Saves file indexs and update the cache. Returns the name of the main
|
||||
// file index, which becomes the new reference file for mod times.
|
||||
//
|
||||
time_t locked_saveFileIndexes(bool update_cache) ;
|
||||
|
||||
// Finds the share flags associated with this file entry.
|
||||
void locked_findShareFlagsAndParentGroups(FileEntry *fe, FileStorageFlags& shareflags, std::list<RsNodeGroupId> &parent_groups) const ;
|
||||
|
||||
std::string locked_findRealRoot(std::string base) const;
|
||||
|
||||
void hashFiles(const std::vector<DirContentToHash>& to_hash) ;
|
||||
bool hashFile(std::string path, FileEntry &fi); /* To Implement */
|
||||
|
||||
/* data */
|
||||
|
||||
mutable RsMutex fiMutex;
|
||||
|
||||
FileIndex fi;
|
||||
|
||||
int updatePeriod;
|
||||
std::map<std::string, SharedDirInfo> directoryMap; /* used by findRealRoot */
|
||||
|
||||
/* flags to kick - if we were busy or sleeping */
|
||||
bool pendingDirs;
|
||||
bool pendingForceCacheWrite;
|
||||
|
||||
/* flags to force Check, to tell if we're in check */
|
||||
bool mForceCheck;
|
||||
bool mInCheck;
|
||||
|
||||
std::list<SharedDirInfo> pendingDirList;
|
||||
bool internal_setSharedDirectories();
|
||||
|
||||
HashCache hashCache ;
|
||||
bool useHashCache ;
|
||||
|
||||
std::map<RsPeerId,RsCacheData> _cache_items_per_peer ; // stored the cache items to be sent to each peer.
|
||||
|
||||
// This file is the location of the current index file. When checking for new files, we compare the modification time
|
||||
// of this file to the mod time of the files on the disk. This allows to now account for time-shift in the computer.
|
||||
//
|
||||
time_t reference_time ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,278 +0,0 @@
|
||||
/*
|
||||
* RetroShare FileCache Module: findex.h
|
||||
*
|
||||
* Copyright 2004-2007 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILE_INDEX_H
|
||||
#define FILE_INDEX_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#if __MACH__
|
||||
#include <unordered_set>
|
||||
#else
|
||||
#include <tr1/unordered_set>
|
||||
#endif
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
/******************************************************************************************
|
||||
* The Key Data Types for the File Index:
|
||||
|
||||
FileEntry : Information about a single file.
|
||||
DirEntry : Information about a directory and its children
|
||||
PersonEntry : Information the root of a FileIndex.
|
||||
|
||||
FileIndex : A Collection of root directories, with a set of functions to manipulate them.
|
||||
In terms of retroshare, There will be a single 'Local' FileIndex used to store
|
||||
the shared files, and a set of 'Remote' FileIndices which are used to store
|
||||
the available files of all the peers.
|
||||
|
||||
******************************************************************************************/
|
||||
/******************************************************************************************
|
||||
STILL TODO:
|
||||
|
||||
(1) Load/Store a FileIndex to file...
|
||||
int FileIndex::loadIndex(FILE *input);
|
||||
int FileIndex::saveIndex(FILE *input);
|
||||
|
||||
This can be done in a recursive manner, or handled completely within FileIndex.
|
||||
|
||||
(2) Search Functions for Partial File Names and Hashes.
|
||||
|
||||
int FileIndex::searchHash(std::string hash, std::list<FileEntry> &results);
|
||||
int FileIndex::searchTerms(std::list<string> terms, std::list<FileEntry> &results);
|
||||
|
||||
This is probably best done in a recursive manner.
|
||||
|
||||
The search could also be extended to handle complex Boolean searches such as :
|
||||
match (size > 100K) && (name contains 'Blue') .... if anyone is interested.
|
||||
But this can get quite complicated, and can be left to a later date.
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************************
|
||||
* FileEntry
|
||||
*****************************************************************************************/
|
||||
|
||||
#include <util/smallobject.h>
|
||||
|
||||
class DirEntry;
|
||||
|
||||
class FileEntry: public RsMemoryManagement::SmallObject
|
||||
{
|
||||
public:
|
||||
FileEntry()
|
||||
: size(0), modtime(0), pop(0), updtime(0), parent(NULL), row(0)
|
||||
{ return; }
|
||||
|
||||
virtual ~FileEntry() { return; }
|
||||
virtual uint32_t type() const { return DIR_TYPE_FILE ; }
|
||||
|
||||
virtual int print(std::string &out);
|
||||
|
||||
/* Data */
|
||||
std::string name;
|
||||
RsFileHash hash;
|
||||
uint64_t size; /* file size */
|
||||
time_t modtime; /* modification time - most recent mod time for a sub entry for dirs */
|
||||
int pop; /* popularity rating */
|
||||
|
||||
time_t updtime; /* last updated */
|
||||
|
||||
/* References for easy manipulation */
|
||||
DirEntry *parent;
|
||||
int row;
|
||||
std::list<std::string> parent_groups ;
|
||||
};
|
||||
|
||||
/******************************************************************************************
|
||||
* DirEntry
|
||||
*****************************************************************************************/
|
||||
|
||||
class DirEntry: public FileEntry
|
||||
{
|
||||
public:
|
||||
|
||||
DirEntry() : most_recent_time(0) {}
|
||||
/* cleanup */
|
||||
virtual ~DirEntry();
|
||||
|
||||
/* update local entries */
|
||||
DirEntry * updateDir(const FileEntry& fe, time_t updtime);
|
||||
FileEntry * updateFile(const FileEntry& fe, time_t updtime);
|
||||
|
||||
|
||||
virtual uint32_t type() const { return DIR_TYPE_DIR ; }
|
||||
int checkParentPointers();
|
||||
int updateChildRows();
|
||||
|
||||
/* remove local entries */
|
||||
int removeFile(const std::string& name);
|
||||
int removeDir(const std::string& name);
|
||||
int removeOldDir(const std::string& name, time_t old); /* checks ts first */
|
||||
|
||||
/* recursive cleanup */
|
||||
int removeOldEntries(time_t old, bool recursive);
|
||||
|
||||
/* recursive searches */
|
||||
DirEntry * findOldDirectory(time_t old);
|
||||
DirEntry * findDirectory(const std::string& path);
|
||||
|
||||
/* recursive update directory mod/pop values */
|
||||
int updateDirectories(const std::string& path, int pop, int modtime);
|
||||
|
||||
/* output */
|
||||
int print(std::string &out);
|
||||
|
||||
int saveEntry(std::string &out);
|
||||
void writeDirInfo(std::string&);
|
||||
void writeFileInfo(std::string&);
|
||||
|
||||
/* Data */
|
||||
std::string path; /* full path (includes name) */
|
||||
std::map<std::string, DirEntry *> subdirs;
|
||||
std::map<std::string, FileEntry *> files;
|
||||
|
||||
time_t most_recent_time; /* last updated */
|
||||
|
||||
/* Inherited members from FileEntry:
|
||||
int size - count for dirs
|
||||
std::string name; - directory name
|
||||
std::string hash; - not used
|
||||
int size; - not used
|
||||
int modtime; - most recent modication time of any child file (recursive)
|
||||
int pop; - most popular child file (recursive)
|
||||
int updtime; - last updated
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
/******************************************************************************************
|
||||
* PersonEntry
|
||||
*****************************************************************************************/
|
||||
|
||||
class PersonEntry: public DirEntry
|
||||
{
|
||||
public:
|
||||
/* cleanup */
|
||||
PersonEntry(const RsPeerId& pid) : id(pid) { return; }
|
||||
virtual ~PersonEntry() { return; }
|
||||
|
||||
DirEntry &operator=(DirEntry &src)
|
||||
{
|
||||
DirEntry *pdest = this;
|
||||
(*pdest) = src;
|
||||
return *this;
|
||||
}
|
||||
virtual uint32_t type() const { return DIR_TYPE_PERSON ; }
|
||||
|
||||
/* Data */
|
||||
RsPeerId id;
|
||||
|
||||
/* Inherited members from FileEntry:
|
||||
int size - count for dirs
|
||||
std::string name; - directory name
|
||||
std::string hash; - not used
|
||||
int size; - not used
|
||||
int modtime; - most recent modication time of any child file (recursive)
|
||||
int pop; - most popular child file (recursive)
|
||||
int updtime; - last updated
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
/******************************************************************************************
|
||||
* FileIndex
|
||||
*****************************************************************************************/
|
||||
|
||||
class Expression;
|
||||
|
||||
class FileIndex
|
||||
{
|
||||
public:
|
||||
FileIndex(const RsPeerId& pid);
|
||||
~FileIndex();
|
||||
|
||||
/* control root entries */
|
||||
int setRootDirectories(const std::list<std::string> &inlist, time_t utime);
|
||||
int getRootDirectories(std::list<std::string> &outlist);
|
||||
|
||||
/* update (index building) */
|
||||
DirEntry * updateDirEntry(const std::string& path, const FileEntry& fe, time_t utime);
|
||||
FileEntry * updateFileEntry(const std::string& path, const FileEntry& fe, time_t utime);
|
||||
|
||||
DirEntry * findOldDirectory(time_t old); /* finds directories older than old */
|
||||
int removeOldDirectory(const std::string& fpath, const std::string& name, time_t old);
|
||||
|
||||
int cleanOldEntries(time_t old); /* removes entries older than old */
|
||||
|
||||
/* debug */
|
||||
int printFileIndex(std::string &out);
|
||||
int printFileIndex(std::ostream &out);
|
||||
|
||||
/* load/save to file */
|
||||
int loadIndex(const std::string& filename, const RsFileHash &expectedHash, uint64_t size);
|
||||
int saveIndex(const std::string& filename, RsFileHash &fileHash, uint64_t &size, const std::set<std::string>& forbidden_roots);
|
||||
|
||||
/* search through this index */
|
||||
int searchTerms(const std::list<std::string>& terms, std::list<FileEntry *> &results) const;
|
||||
int searchHash(const RsFileHash& hash, std::list<FileEntry *> &results) const;
|
||||
int searchBoolExp(Expression * exp, std::list<FileEntry *> &results) const;
|
||||
|
||||
/// Recursively compute the maximum modification time of children.
|
||||
/// Used to easily retrieve mose recent files.
|
||||
//
|
||||
void updateMaxModTime() ;
|
||||
void RecursUpdateMaxModTime(DirEntry *) ;
|
||||
|
||||
PersonEntry *root;
|
||||
|
||||
#ifdef __MACH__
|
||||
static std::unordered_set<void*> _pointers ;
|
||||
#else
|
||||
static std::tr1::unordered_set<void*> _pointers ;
|
||||
#endif
|
||||
static void registerEntry(void*p) ;
|
||||
static void unregisterEntry(void*p) ;
|
||||
static bool isValid(void*p) ;
|
||||
|
||||
/// Fills up details from the data contained in ref.
|
||||
//
|
||||
static bool extractData(void *ref,DirDetails& details) ;
|
||||
static uint32_t getType(void *ref) ;
|
||||
|
||||
void *findRef(const std::string& path) const ;
|
||||
bool extractData(const std::string& path,DirDetails& details) const ;
|
||||
|
||||
void updateHashIndex() ;
|
||||
void recursUpdateHashIndex(DirEntry *) ;
|
||||
|
||||
std::map<RsFileHash,FileEntry*> _file_hashes ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,459 +0,0 @@
|
||||
/*
|
||||
* RetroShare FileCache Module: fistore.cc
|
||||
*
|
||||
* Copyright 2004-2007 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "rsserver/p3face.h"
|
||||
#include "dbase/fistore.h"
|
||||
#include "retroshare/rsexpr.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "pqi/p3peermgr.h"
|
||||
#include "pqi/p3notify.h"
|
||||
|
||||
FileIndexStore::FileIndexStore(CacheStrapper *cs, CacheTransfer *cft,
|
||||
p3PeerMgr *cnmgr, RsPeerId ownid, std::string cachedir)
|
||||
:CacheStore(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cft, cachedir),
|
||||
localId(ownid), localindex(NULL), mPeerMgr(cnmgr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FileIndexStore::~FileIndexStore()
|
||||
{
|
||||
/* clean up the Index */
|
||||
return;
|
||||
}
|
||||
|
||||
/***
|
||||
* #define FIS_DEBUG2 1
|
||||
* #define FIS_DEBUG 1
|
||||
**/
|
||||
|
||||
/* actual load, once data available */
|
||||
int FileIndexStore::loadCache(const RsCacheData &data)
|
||||
{
|
||||
|
||||
#ifdef FIS_DEBUG2
|
||||
std::cerr << "FileIndexStore::loadCache() hash: " << data.hash << std::endl;
|
||||
std::cerr << "FileIndexStore::loadCache() path: " << data.path << std::endl;
|
||||
std::cerr << "FileIndexStore::loadCache() name: " << data.name << std::endl;
|
||||
std::cerr << "FileIndexStore::loadCache() size: " << data.size << std::endl;
|
||||
#endif
|
||||
|
||||
/* do Callback */
|
||||
AboutToModify();
|
||||
|
||||
/* lock it up */
|
||||
lockData();
|
||||
|
||||
FileIndex *fiold = NULL;
|
||||
bool local = (data.pid == localId);
|
||||
|
||||
std::map<RsPeerId, FileIndex *>::iterator it;
|
||||
/* remove old cache */
|
||||
if (local)
|
||||
{
|
||||
fiold = localindex;
|
||||
localindex = NULL;
|
||||
}
|
||||
else if (indices.end() != (it = indices.find(data.pid)))
|
||||
{
|
||||
fiold = it->second;
|
||||
indices.erase(it);
|
||||
//delete fi;
|
||||
}
|
||||
|
||||
if(mPeerMgr->isFriend(data.pid))
|
||||
{
|
||||
// We discard file lists from non friends. This is the place to remove file lists of deleted friends
|
||||
// from the cache. Doing this, the file list still shows in a session where we deleted a friend, but will be removed
|
||||
// at next restart.
|
||||
//
|
||||
|
||||
/* load Cache */
|
||||
FileIndex *finew = new FileIndex(data.pid);
|
||||
|
||||
if (finew->loadIndex(data.path + '/' + data.name, data.hash, data.size))
|
||||
{
|
||||
#ifdef FIS_DEBUG2
|
||||
std::cerr << "FileIndexStore::loadCache() Succeeded!" << std::endl;
|
||||
#endif
|
||||
/* This is not the place to set the peername.
|
||||
* It is a hack, which makes it programmatically impossible
|
||||
* to get the file data out....
|
||||
*
|
||||
* peername should not be used in dbase.
|
||||
*/
|
||||
finew->root->name = data.pid.toStdString();
|
||||
|
||||
if (local)
|
||||
{
|
||||
localindex = finew;
|
||||
}
|
||||
else
|
||||
{
|
||||
indices[data.pid] = finew;
|
||||
}
|
||||
delete fiold;
|
||||
|
||||
/* store in tale */
|
||||
locked_storeCacheEntry(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FIS_DEBUG2
|
||||
std::cerr << "FileIndexStore::loadCache() Failed!" << std::endl;
|
||||
#endif
|
||||
/* reinstall the old one! */
|
||||
delete finew;
|
||||
if (fiold)
|
||||
{
|
||||
if (local)
|
||||
{
|
||||
localindex = fiold;
|
||||
}
|
||||
else
|
||||
{
|
||||
indices[data.pid] = fiold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef FIS_DEBUG
|
||||
else
|
||||
std::cerr << "Discarding file list from deleted peer " << data.pid << std::endl ;
|
||||
#endif
|
||||
|
||||
/* need to correct indices(row) for the roots of the FileIndex */
|
||||
int i = 0;
|
||||
for(it = indices.begin(); it != indices.end(); ++it)
|
||||
{
|
||||
(it->second)->root->row = i++;
|
||||
it->second->FileIndex::updateMaxModTime() ;
|
||||
}
|
||||
if (localindex)
|
||||
{
|
||||
localindex->root->row = 0;
|
||||
localindex->updateMaxModTime() ;
|
||||
}
|
||||
|
||||
unlockData();
|
||||
|
||||
ModCompleted();
|
||||
bool ret = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Search Interface - For Directory Access */
|
||||
int FileIndexStore::RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails& details) const
|
||||
{
|
||||
lockData();
|
||||
|
||||
std::map<RsPeerId, FileIndex *>::const_iterator it = indices.find(uid);
|
||||
bool found = true;
|
||||
|
||||
if (it != indices.end())
|
||||
found = it->second->extractData(path,details) ;
|
||||
|
||||
unlockData();
|
||||
|
||||
return found ;
|
||||
|
||||
#ifdef OLD_STUFF_TO_REMOVE
|
||||
/* lock it up */
|
||||
lockData();
|
||||
|
||||
std::map<RsPeerId, FileIndex *>::const_iterator it;
|
||||
it = indices.find(uid);
|
||||
bool found = true;
|
||||
|
||||
if (it != indices.end())
|
||||
{
|
||||
//DirEntry *fdir = (it->second).lookupDirectory(path);
|
||||
/* translate it
|
||||
*/
|
||||
bool b = FileIndex::extractData((it->second)->root,details) ;
|
||||
|
||||
found = found && b ;
|
||||
}
|
||||
else
|
||||
found = false;
|
||||
|
||||
unlockData();
|
||||
return found;
|
||||
#endif
|
||||
}
|
||||
|
||||
int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) const
|
||||
{
|
||||
/* remove unused parameter warnings */
|
||||
(void) flags;
|
||||
|
||||
#ifdef FIS_DEBUG
|
||||
std::cerr << "FileIndexStore::RequestDirDetails() ref=" << ref << " flags: " << flags << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsPeerId, FileIndex *>::const_iterator pit;
|
||||
|
||||
lockData();
|
||||
|
||||
// checked by FileIndex::extractData
|
||||
// if(ref != NULL && !FileIndex::isValid(ref))
|
||||
// {
|
||||
// unlockData() ;
|
||||
// return false ;
|
||||
// }
|
||||
|
||||
/* so cast *ref to a DirEntry */
|
||||
/* root case */
|
||||
|
||||
#ifdef FIS_DEBUG
|
||||
std::cerr << "FileIndexStore::RequestDirDetails() CHKS" << std::endl;
|
||||
for(pit = indices.begin(); pit != indices.end(); ++pit)
|
||||
{
|
||||
(pit->second)->root->checkParentPointers();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ref == NULL)
|
||||
{
|
||||
#ifdef FIS_DEBUG
|
||||
std::cerr << "FileIndexStore::RequestDirDetails() ref=NULL (root)" << std::endl;
|
||||
#endif
|
||||
|
||||
/* get remote root entries */
|
||||
for(pit = indices.begin(); pit != indices.end(); ++pit)
|
||||
{
|
||||
/*
|
||||
*/
|
||||
FileIndex *fileIndex = pit->second;
|
||||
|
||||
DirStub stub;
|
||||
stub.type = DIR_TYPE_PERSON;
|
||||
stub.name = fileIndex->root->name;
|
||||
stub.ref = fileIndex->root;
|
||||
|
||||
details.children.push_back(stub);
|
||||
}
|
||||
details.parent = NULL;
|
||||
details.prow = -1;
|
||||
details.ref = NULL;
|
||||
details.type = DIR_TYPE_ROOT;
|
||||
details.name = "";
|
||||
details.hash.clear() ;
|
||||
details.path = "";
|
||||
details.count = indices.size();
|
||||
details.age = 0;
|
||||
details.flags.clear() ;
|
||||
details.min_age = 0;
|
||||
|
||||
unlockData();
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool b = FileIndex::extractData(ref,details) ;
|
||||
|
||||
unlockData();
|
||||
return b;
|
||||
}
|
||||
uint32_t FileIndexStore::getType(void *ref) const
|
||||
{
|
||||
lockData() ;
|
||||
uint32_t b = FileIndex::getType(ref) ;
|
||||
unlockData();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
int FileIndexStore::SearchHash(const RsFileHash& hash, std::list<FileDetail> &results) const
|
||||
{
|
||||
lockData();
|
||||
results.clear() ;
|
||||
std::map<RsPeerId, FileIndex *>::const_iterator pit;
|
||||
std::list<FileEntry *>::iterator rit;
|
||||
std::list<FileEntry *> firesults;
|
||||
|
||||
time_t now = time(NULL);
|
||||
|
||||
#ifdef FIS_DEBUG
|
||||
std::cerr << "FileIndexStore::SearchHash()" << std::endl;
|
||||
#endif
|
||||
for(pit = indices.begin(); pit != indices.end(); ++pit)
|
||||
{
|
||||
#ifdef FIS_DEBUG
|
||||
std::cerr << "FileIndexStore::SearchHash() Searching: Peer ";
|
||||
std::cerr << pit->first << std::endl;
|
||||
#endif
|
||||
firesults.clear();
|
||||
|
||||
(pit->second)->searchHash(hash, firesults);
|
||||
/* translate results */
|
||||
for(rit = firesults.begin(); rit != firesults.end(); ++rit)
|
||||
{
|
||||
FileDetail fd;
|
||||
fd.id = pit->first;
|
||||
fd.name = (*rit)->name;
|
||||
fd.hash = (*rit)->hash;
|
||||
fd.path = ""; /* TODO */
|
||||
fd.size = (*rit)->size;
|
||||
fd.age = now - (*rit)->modtime;
|
||||
fd.rank = (*rit)->pop;
|
||||
|
||||
results.push_back(fd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef FIS_DEBUG
|
||||
std::cerr << "FileIndexStore::SearchHash() Found " << results.size();
|
||||
std::cerr << " Results from " << indices.size() << " Peers" << std::endl;
|
||||
#endif
|
||||
|
||||
unlockData();
|
||||
return results.size();
|
||||
}
|
||||
|
||||
|
||||
int FileIndexStore::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags) const
|
||||
{
|
||||
lockData();
|
||||
std::map<RsPeerId, FileIndex *>::const_iterator pit;
|
||||
std::list<FileEntry *>::iterator rit;
|
||||
std::list<FileEntry *> firesults;
|
||||
|
||||
results.clear() ;
|
||||
|
||||
#ifdef FIS_DEBUG
|
||||
std::cerr << "FileIndexStore::SearchKeywords()" << std::endl;
|
||||
#endif
|
||||
if(flags & RS_FILE_HINTS_REMOTE)
|
||||
for(pit = indices.begin(); pit != indices.end(); ++pit)
|
||||
{
|
||||
firesults.clear();
|
||||
|
||||
(pit->second)->searchTerms(keywords, firesults);
|
||||
/* translate results */
|
||||
for(rit = firesults.begin(); rit != firesults.end(); ++rit)
|
||||
{
|
||||
DirDetails dd;
|
||||
|
||||
if(!FileIndex::extractData(*rit, dd))
|
||||
continue ;
|
||||
|
||||
results.push_back(dd);
|
||||
}
|
||||
}
|
||||
|
||||
if(flags & RS_FILE_HINTS_LOCAL)
|
||||
if (localindex)
|
||||
{
|
||||
firesults.clear();
|
||||
|
||||
localindex->searchTerms(keywords, firesults);
|
||||
/* translate results */
|
||||
for(rit = firesults.begin(); rit != firesults.end(); ++rit)
|
||||
{
|
||||
DirDetails dd;
|
||||
|
||||
if(!FileIndex::extractData(*rit, dd))
|
||||
continue ;
|
||||
|
||||
dd.id.clear() ;
|
||||
results.push_back(dd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unlockData();
|
||||
return results.size();
|
||||
}
|
||||
|
||||
|
||||
int FileIndexStore::searchBoolExp(Expression * exp, std::list<DirDetails> &results) const
|
||||
{
|
||||
lockData();
|
||||
std::map<RsPeerId, FileIndex *>::const_iterator pit;
|
||||
std::list<FileEntry *>::iterator rit;
|
||||
std::list<FileEntry *> firesults;
|
||||
|
||||
#ifdef FIS_DEBUG
|
||||
std::cerr << "FileIndexStore::searchBoolExp()" << std::endl;
|
||||
#endif
|
||||
for(pit = indices.begin(); pit != indices.end(); ++pit)
|
||||
{
|
||||
firesults.clear();
|
||||
|
||||
(pit->second)->searchBoolExp(exp, firesults);
|
||||
|
||||
/* translate results */
|
||||
for(rit = firesults.begin(); rit != firesults.end(); ++rit)
|
||||
{
|
||||
DirDetails dd;
|
||||
FileIndex::extractData(*rit, dd);
|
||||
results.push_back(dd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* finally search local files */
|
||||
if (localindex)
|
||||
{
|
||||
firesults.clear();
|
||||
|
||||
localindex->searchBoolExp(exp, firesults);
|
||||
|
||||
/* translate results */
|
||||
for(rit = firesults.begin(); rit != firesults.end(); ++rit)
|
||||
{
|
||||
DirDetails dd;
|
||||
FileIndex::extractData(*rit, dd);
|
||||
dd.id.clear() ;
|
||||
results.push_back(dd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
unlockData();
|
||||
return results.size();
|
||||
}
|
||||
|
||||
int FileIndexStore::AboutToModify()
|
||||
{
|
||||
RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_FRIENDS, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int FileIndexStore::ModCompleted()
|
||||
{
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_FRIENDS, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
* RetroShare FileCache Module: fistore.h
|
||||
*
|
||||
* Copyright 2004-2007 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MRK_FILE_INDEX_STORE_H
|
||||
#define MRK_FILE_INDEX_STORE_H
|
||||
|
||||
|
||||
/**********
|
||||
* Stores the FileCaches of the Peers
|
||||
* must implement 'loadCache' to
|
||||
*
|
||||
* This class is also accessed by the GUI....
|
||||
* and the FileTransfer class.
|
||||
*
|
||||
*/
|
||||
|
||||
class p3PeerMgr ;
|
||||
|
||||
#include "dbase/findex.h"
|
||||
#include "dbase/cachestrapper.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
|
||||
class FileStoreResult
|
||||
{
|
||||
public:
|
||||
std::string id;
|
||||
std::string path;
|
||||
std::string hash;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class NotifyCallback
|
||||
{
|
||||
public:
|
||||
NotifyCallback() { return; }
|
||||
virtual ~NotifyCallback() { return; }
|
||||
virtual void AboutToModify() { return; }
|
||||
virtual void ModCompleted() { return; }
|
||||
};
|
||||
|
||||
|
||||
class Expression;
|
||||
|
||||
class FileIndexStore: public CacheStore
|
||||
{
|
||||
public:
|
||||
|
||||
FileIndexStore(CacheStrapper *cs, CacheTransfer *cft, p3PeerMgr *pmgr, RsPeerId ownid, std::string cachedir);
|
||||
virtual ~FileIndexStore();
|
||||
|
||||
/* virtual functions overloaded by cache implementor */
|
||||
virtual int loadCache(const RsCacheData &data); /* actual load, once data available */
|
||||
|
||||
/* Search Interface - For FileTransfer Lookup */
|
||||
int SearchHash(const RsFileHash &hash, std::list<FileDetail> &results) const;
|
||||
|
||||
/* Search Interface - For Search Interface */
|
||||
int SearchKeywords(std::list<std::string> terms, std::list<DirDetails> &results,FileSearchFlags flags) const;
|
||||
|
||||
/* Search Interface - for Adv Search Interface */
|
||||
int searchBoolExp(Expression * exp, std::list<DirDetails> &results) const;
|
||||
|
||||
|
||||
/* Search Interface - For Directory Access */
|
||||
int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details) const;
|
||||
int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) const;
|
||||
uint32_t getType(void *ref) const ;
|
||||
|
||||
private:
|
||||
int AboutToModify();
|
||||
int ModCompleted();
|
||||
|
||||
std::map<RsPeerId, FileIndex *> indices;
|
||||
|
||||
RsPeerId localId;
|
||||
FileIndex *localindex;
|
||||
|
||||
p3PeerMgr *mPeerMgr ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -1,289 +0,0 @@
|
||||
/*
|
||||
* rs-core/src/dbase: rsexpr.cc
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2007-2008 by Kashif Kaleem.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "dbase/findex.h"
|
||||
#include "retroshare/rsexpr.h"
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
/******************************************************************************************
|
||||
eval functions of relational expressions.
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
template<>
|
||||
void RelExpression<int>::linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._ints.push_back(Op) ;
|
||||
e._ints.push_back(LowerValue) ;
|
||||
e._ints.push_back(HigherValue) ;
|
||||
}
|
||||
|
||||
|
||||
bool DateExpression::eval(FileEntry *file)
|
||||
{
|
||||
return evalRel(file->modtime);
|
||||
}
|
||||
|
||||
bool SizeExpressionMB::eval(FileEntry *file)
|
||||
{
|
||||
return evalRel((int)(file->size/(uint64_t)(1024*1024)));
|
||||
}
|
||||
|
||||
bool SizeExpression::eval(FileEntry *file)
|
||||
{
|
||||
return evalRel(file->size);
|
||||
}
|
||||
|
||||
bool PopExpression::eval(FileEntry *file)
|
||||
{
|
||||
return evalRel(file->pop);
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
Code for evaluating string expressions
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
bool NameExpression::eval(FileEntry *file)
|
||||
{
|
||||
return evalStr(file->name);
|
||||
}
|
||||
|
||||
bool PathExpression::eval(FileEntry *file){
|
||||
std::string path;
|
||||
/*Construct the path of this file*/
|
||||
DirEntry * curr = file->parent;
|
||||
while ( curr != NULL ){
|
||||
path = curr->name+"/"+ path;
|
||||
curr = curr->parent;
|
||||
}
|
||||
return evalStr(path);
|
||||
}
|
||||
|
||||
bool ExtExpression::eval(FileEntry *file){
|
||||
std::string ext;
|
||||
/*Get the part of the string after the last instance of . in the filename */
|
||||
size_t index = file->name.find_last_of('.');
|
||||
if (index != std::string::npos) {
|
||||
ext = file->name.substr(index+1);
|
||||
if (ext != "" ){
|
||||
return evalStr(ext);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HashExpression::eval(FileEntry *file){
|
||||
return evalStr(file->hash.toStdString());
|
||||
}
|
||||
|
||||
/*Check whether two strings are 'equal' to each other*/
|
||||
static bool StrEquals(const std::string & str1, const std::string & str2,
|
||||
bool IgnoreCase ){
|
||||
if ( str1.size() != str2.size() ){
|
||||
return false;
|
||||
} else if (IgnoreCase) {
|
||||
std::equal( str1.begin(), str1.end(),
|
||||
str2.begin(), CompareCharIC() );
|
||||
}
|
||||
return std::equal( str1.begin(), str1.end(),
|
||||
str2.begin());
|
||||
}
|
||||
|
||||
/*Check whether one string contains the other*/
|
||||
static bool StrContains( const std::string & str1, const std::string & str2,
|
||||
bool IgnoreCase){
|
||||
|
||||
std::string::const_iterator iter ;
|
||||
if (IgnoreCase) {
|
||||
iter = std::search( str1.begin(), str1.end(),
|
||||
str2.begin(), str2.end(), CompareCharIC() );
|
||||
} else {
|
||||
iter = std::search( str1.begin(), str1.end(),
|
||||
str2.begin(), str2.end());
|
||||
}
|
||||
|
||||
return ( iter != str1.end() );
|
||||
}
|
||||
|
||||
|
||||
bool StringExpression :: evalStr ( const std::string &str ){
|
||||
std::list<std::string>::iterator iter;
|
||||
switch (Op) {
|
||||
case ContainsAllStrings:
|
||||
for ( iter = terms.begin(); iter != terms.end(); ++iter ) {
|
||||
if ( StrContains (str, *iter, IgnoreCase) == false ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
case ContainsAnyStrings:
|
||||
for ( iter = terms.begin(); iter != terms.end(); ++iter ) {
|
||||
if ( StrContains (str,*iter, IgnoreCase) == true ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EqualsString:
|
||||
for ( iter = terms.begin(); iter != terms.end(); ++iter ) {
|
||||
if ( StrEquals (str,*iter, IgnoreCase) == true ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* linearization code
|
||||
*************************************************************************/
|
||||
|
||||
void CompoundExpression::linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_COMP) ;
|
||||
e._ints.push_back(Op) ;
|
||||
|
||||
Lexp->linearize(e) ;
|
||||
Rexp->linearize(e) ;
|
||||
}
|
||||
|
||||
void StringExpression::linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._ints.push_back(Op) ;
|
||||
e._ints.push_back(IgnoreCase) ;
|
||||
e._ints.push_back(terms.size()) ;
|
||||
|
||||
for(std::list<std::string>::const_iterator it(terms.begin());it!=terms.end();++it)
|
||||
e._strings.push_back(*it) ;
|
||||
}
|
||||
|
||||
Expression *LinearizedExpression::toExpr(const LinearizedExpression& e)
|
||||
{
|
||||
int i=0,j=0,k=0 ;
|
||||
return toExpr(e,i,j,k) ;
|
||||
}
|
||||
|
||||
void LinearizedExpression::readStringExpr(const LinearizedExpression& e,int& n_ints,int& n_strings,std::list<std::string>& strings,bool& b,StringOperator& op)
|
||||
{
|
||||
op = static_cast<StringOperator>(e._ints[n_ints++]) ;
|
||||
b = e._ints[n_ints++] ;
|
||||
int n = e._ints[n_ints++] ;
|
||||
|
||||
strings.clear() ;
|
||||
for(int i=0;i<n;++i)
|
||||
strings.push_back(e._strings[n_strings++]) ;
|
||||
}
|
||||
|
||||
Expression *LinearizedExpression::toExpr(const LinearizedExpression& e,int& n_tok,int& n_ints,int& n_strings)
|
||||
{
|
||||
LinearizedExpression::token tok = static_cast<LinearizedExpression::token>(e._tokens[n_tok++]) ;
|
||||
|
||||
switch(tok)
|
||||
{
|
||||
case EXPR_DATE: {
|
||||
RelOperator op = static_cast<RelOperator>(e._ints[n_ints++]) ;
|
||||
int lv = e._ints[n_ints++] ;
|
||||
int hv = e._ints[n_ints++] ;
|
||||
|
||||
return new DateExpression(op,lv,hv) ;
|
||||
}
|
||||
|
||||
case EXPR_POP: {
|
||||
RelOperator op = static_cast<RelOperator>(e._ints[n_ints++]) ;
|
||||
int lv = e._ints[n_ints++] ;
|
||||
int hv = e._ints[n_ints++] ;
|
||||
|
||||
return new PopExpression(op,lv,hv) ;
|
||||
}
|
||||
case EXPR_SIZE: {
|
||||
RelOperator op = static_cast<RelOperator>(e._ints[n_ints++]) ;
|
||||
int lv = e._ints[n_ints++] ;
|
||||
int hv = e._ints[n_ints++] ;
|
||||
|
||||
return new SizeExpression(op,lv,hv) ;
|
||||
}
|
||||
case EXPR_HASH: {
|
||||
std::list<std::string> strings ;
|
||||
StringOperator op ;
|
||||
bool b ;
|
||||
|
||||
readStringExpr(e,n_ints,n_strings,strings,b,op) ;
|
||||
return new HashExpression(op,strings) ;
|
||||
}
|
||||
case EXPR_NAME: {
|
||||
std::list<std::string> strings ;
|
||||
StringOperator op ;
|
||||
bool b ;
|
||||
|
||||
readStringExpr(e,n_ints,n_strings,strings,b,op) ;
|
||||
|
||||
return new NameExpression(op,strings,b) ;
|
||||
}
|
||||
case EXPR_PATH: {
|
||||
std::list<std::string> strings ;
|
||||
StringOperator op ;
|
||||
bool b ;
|
||||
|
||||
readStringExpr(e,n_ints,n_strings,strings,b,op) ;
|
||||
|
||||
return new ExtExpression(op,strings,b) ;
|
||||
}
|
||||
case EXPR_EXT: {
|
||||
std::list<std::string> strings ;
|
||||
StringOperator op ;
|
||||
bool b ;
|
||||
|
||||
readStringExpr(e,n_ints,n_strings,strings,b,op) ;
|
||||
|
||||
return new ExtExpression(op,strings,b) ;
|
||||
}
|
||||
case EXPR_COMP: {
|
||||
LogicalOperator op = static_cast<LogicalOperator>(e._ints[n_ints++]) ;
|
||||
|
||||
Expression *e1 = toExpr(e,n_tok,n_ints,n_strings) ;
|
||||
Expression *e2 = toExpr(e,n_tok,n_ints,n_strings) ;
|
||||
|
||||
return new CompoundExpression(op,e1,e2) ;
|
||||
}
|
||||
case EXPR_SIZE_MB: {
|
||||
RelOperator op = static_cast<RelOperator>(e._ints[n_ints++]) ;
|
||||
int lv = e._ints[n_ints++] ;
|
||||
int hv = e._ints[n_ints++] ;
|
||||
|
||||
return new SizeExpressionMB(op,lv,hv) ;
|
||||
}
|
||||
default:
|
||||
std::cerr << "No expression match the current value " << tok << std::endl ;
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,35 @@ Big picture
|
||||
- the same file should be able to be held by two different directories. Hash search will return a single hit.
|
||||
- the previously existing PersonEntry had no field and was overloading DirEntry, with overwritten file names, hashes etc. Super bad!
|
||||
|
||||
Directory storage file format
|
||||
-----------------------------
|
||||
* should be extensible (xml or binary format? Binary, because it's going to be encrypted anyway)
|
||||
=> works with binary fields
|
||||
=>
|
||||
|
||||
[= version =]
|
||||
[= peer id =]
|
||||
[= num entries =]
|
||||
[= some information =]
|
||||
|
||||
[entry tag] [entry size] [Field ID 01] [field size v 01] [Field data 01] [Field ID 02] [field size v 02] [Field data 02] ...
|
||||
[entry tag] [entry size] [Field ID 01] [field size v 01] [Field data 01] [Field ID 02] [field size v 02] [Field data 02] ...
|
||||
[entry tag] [entry size] [Field ID 01] [field size v 01] [Field data 01] [Field ID 02] [field size v 02] [Field data 02] ...
|
||||
...
|
||||
2 1-5 v 2 1-5 v
|
||||
* entry content
|
||||
Tag | Content | Size
|
||||
----------------+--------------------------------------+------
|
||||
01 | sha1 hash | 20
|
||||
01 | sha1^2 hash | 20
|
||||
02 | file name | < 512
|
||||
03 | file size | 8
|
||||
04 | dir name | < 512
|
||||
05 | last modif time local | 4
|
||||
06 | last modif time including sub-dirs | 4
|
||||
|
||||
Classes
|
||||
-------
|
||||
Rs
|
||||
|
||||
p3ShareManager
|
||||
- tick()
|
||||
@ -75,6 +101,29 @@ Classes
|
||||
- parent groups
|
||||
- group flags
|
||||
|
||||
Best data structure for file index
|
||||
----------------------------------
|
||||
|
||||
| Hash map map list
|
||||
----------------+-----------------+------------+--------------
|
||||
Adding | Constant | log(n) | O(n)
|
||||
Hash search | Constant | log(n) | O(n)
|
||||
Name/exp search | O(n) | O(n) | O(n)
|
||||
Recursive browse| Constant | log(n) | O(n)
|
||||
|
||||
Should we use the same struct for files and directories?
|
||||
|
||||
Sol 1:
|
||||
DirClass + PersonClass + FileEntry class
|
||||
- each has pointers to elements list of the same type
|
||||
- lists are handled for Files (all file entries),
|
||||
|
||||
Directories are represented by the hash of the full path
|
||||
|
||||
Sol 2:
|
||||
Same class for all elements, in a single hash map. Each element is
|
||||
defined by its type (Dir, Person, File) which all have a hash.
|
||||
|
||||
Syncing between peers
|
||||
---------------------
|
||||
|
||||
@ -83,19 +132,84 @@ Generating sync events
|
||||
- for each directory, in breadth first order
|
||||
- if directory has changed, or last update is old
|
||||
=> push a sync request
|
||||
- store the peer's last up time. Compare with peer uptimes recursively.
|
||||
|
||||
* Server side
|
||||
- after a change, broadcast a "directory changed" packet to all connected friends
|
||||
|
||||
|
||||
* directoy updater
|
||||
- crawl through directories
|
||||
- compare TS of files, missing files, new files
|
||||
- feed a queue of files to hash
|
||||
- directory whatcher gets notified when files are hashed
|
||||
|
||||
- a separate component hashes files (FileHashingProcess)
|
||||
|
||||
DirectoryWatcher (watches a hierarchy) File List (stores a directory hierarchy)
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
+-----------------------+------------------+
|
||||
| |
|
||||
Shared File Service |
|
||||
| |
|
||||
| |
|
||||
+----------- own file list -------+---------- Encrypted/compressed save to disk
|
||||
| | |
|
||||
+----------- friend file lists ---+
|
||||
Roadmap
|
||||
-------
|
||||
|
||||
- complete this file until a proper description of the whole thing is achieved.
|
||||
- create a new directory and implement the .h for the basic functionality
|
||||
- look into existing code in ftServer for the integration, but don't change anything yet
|
||||
- setup class hierarchy
|
||||
- merge hash cache into file lists.
|
||||
[X] complete this file until a proper description of the whole thing is achieved.
|
||||
[X] create a new directory and implement the .h for the basic functionality
|
||||
[ ] look into existing code in ftServer for the integration, but don't change anything yet
|
||||
[X] setup class hierarchy
|
||||
[ ] merge hash cache into file lists.
|
||||
[ ] new format for saving of FileIndex to make it locally encrypted, compact and extensible
|
||||
[ ] create basic directory functionality with own files: re-hash, and store
|
||||
[ ] display own files in GUI, with proper update and working sort
|
||||
|
||||
TODO
|
||||
====
|
||||
|
||||
[ ] directory handler
|
||||
[ ] abstract functions to keep a directory and get updates to it.
|
||||
[ ] hierarchical storage representation.
|
||||
[ ] allow add/delete entries
|
||||
[ ] auto-cleanup
|
||||
|
||||
[ ] directory updater
|
||||
[ ] abstract layer
|
||||
[ ] crawls the directory and ask updates
|
||||
|
||||
[ ] derive local directory updater
|
||||
[ ] crawl local files, and asks updates to storage class
|
||||
[ ] derive remote directory updater
|
||||
[ ] crawl stored files, and request updates to storage class
|
||||
|
||||
[ ] load/save of directory content. Should be extensible
|
||||
[ ] p3FileLists with minimal functonality: no exchange. Only storage of own file lists
|
||||
[ ] service (items) for p3FileLists
|
||||
[ ] connect RemoteDirModel to new system
|
||||
[ ] test GUI functions
|
||||
[ ] test update between peers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- optionally
|
||||
- change the saving system of FileIndex to make it locally encrypted and compact
|
||||
|
||||
|
1156
libretroshare/src/file_sharing/dir_hierarchy.cc
Normal file
1156
libretroshare/src/file_sharing/dir_hierarchy.cc
Normal file
File diff suppressed because it is too large
Load Diff
183
libretroshare/src/file_sharing/dir_hierarchy.h
Normal file
183
libretroshare/src/file_sharing/dir_hierarchy.h
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* RetroShare C++ Internal directory hierarchy class.
|
||||
*
|
||||
* file_sharing/dir_hierarchy.h
|
||||
*
|
||||
* Copyright 2016 by Mr.Alice
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "directory_storage.h"
|
||||
|
||||
class InternalFileHierarchyStorage
|
||||
{
|
||||
public:
|
||||
class FileStorageNode
|
||||
{
|
||||
public:
|
||||
static const uint32_t TYPE_UNKNOWN = 0x0000 ;
|
||||
static const uint32_t TYPE_FILE = 0x0001 ;
|
||||
static const uint32_t TYPE_DIR = 0x0002 ;
|
||||
|
||||
virtual ~FileStorageNode() {}
|
||||
virtual uint32_t type() const =0;
|
||||
|
||||
DirectoryStorage::EntryIndex parent_index;
|
||||
uint32_t row ;
|
||||
};
|
||||
class FileEntry: public FileStorageNode
|
||||
{
|
||||
public:
|
||||
FileEntry() : file_size(0), file_modtime(0) {}
|
||||
FileEntry(const std::string& name,uint64_t size,time_t modtime) : file_name(name),file_size(size),file_modtime(modtime) {}
|
||||
FileEntry(const std::string& name,uint64_t size,time_t modtime,const RsFileHash& hash) : file_name(name),file_size(size),file_modtime(modtime),file_hash(hash) {}
|
||||
|
||||
virtual uint32_t type() const { return FileStorageNode::TYPE_FILE ; }
|
||||
virtual ~FileEntry() {}
|
||||
|
||||
// local stuff
|
||||
std::string file_name ;
|
||||
uint64_t file_size ;
|
||||
time_t file_modtime;
|
||||
RsFileHash file_hash ;
|
||||
};
|
||||
|
||||
class DirEntry: public FileStorageNode
|
||||
{
|
||||
public:
|
||||
DirEntry(const std::string& name) : dir_name(name), dir_modtime(0),dir_most_recent_time(0),dir_update_time(0) {}
|
||||
virtual ~DirEntry() {}
|
||||
|
||||
virtual uint32_t type() const { return FileStorageNode::TYPE_DIR ; }
|
||||
|
||||
// local stuff
|
||||
std::string dir_name ;
|
||||
std::string dir_parent_path ;
|
||||
RsFileHash dir_hash ;
|
||||
|
||||
std::vector<DirectoryStorage::EntryIndex> subdirs ;
|
||||
std::vector<DirectoryStorage::EntryIndex> subfiles ;
|
||||
|
||||
time_t dir_modtime;
|
||||
time_t dir_most_recent_time; // recursive most recent modification time, including files and subdirs in the entire hierarchy below.
|
||||
time_t dir_update_time; // last time the information was updated for that directory. Includes subdirs indexes and subfile info.
|
||||
};
|
||||
|
||||
// class stuff
|
||||
InternalFileHierarchyStorage() ;
|
||||
|
||||
bool load(const std::string& fname) ;
|
||||
bool save(const std::string& fname) ;
|
||||
|
||||
int parentRow(DirectoryStorage::EntryIndex e);
|
||||
bool isIndexValid(DirectoryStorage::EntryIndex e) const;
|
||||
bool getChildIndex(DirectoryStorage::EntryIndex e,int row,DirectoryStorage::EntryIndex& c) const;
|
||||
bool updateSubDirectoryList(const DirectoryStorage::EntryIndex& indx, const std::map<std::string,time_t>& subdirs, const RsFileHash &random_hash_seed);
|
||||
bool removeDirectory(DirectoryStorage::EntryIndex indx) ;
|
||||
bool checkIndex(DirectoryStorage::EntryIndex indx,uint8_t type) const;
|
||||
bool updateSubFilesList(const DirectoryStorage::EntryIndex& indx,const std::map<std::string,DirectoryStorage::FileTS>& subfiles,std::map<std::string,DirectoryStorage::FileTS>& new_files);
|
||||
bool updateHash(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash);
|
||||
bool updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const time_t modf_time);
|
||||
bool updateDirEntry(const DirectoryStorage::EntryIndex& indx, const std::string& dir_name, time_t most_recent_time, time_t dir_modtime, const std::vector<RsFileHash> &subdirs_hash, const std::vector<FileEntry> &subfiles_array);
|
||||
|
||||
// TS get/set functions. Take one of the class members as argument.
|
||||
|
||||
bool getTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) const;
|
||||
bool setTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) ;
|
||||
|
||||
// Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method.
|
||||
|
||||
time_t recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index);
|
||||
|
||||
// hash stuff
|
||||
|
||||
bool getDirHashFromIndex(const DirectoryStorage::EntryIndex& index,RsFileHash& hash) const ;
|
||||
bool getIndexFromDirHash(const RsFileHash& hash,DirectoryStorage::EntryIndex& index) ;
|
||||
bool getIndexFromFileHash(const RsFileHash& hash,DirectoryStorage::EntryIndex& index) ;
|
||||
|
||||
// file/dir access and modification
|
||||
bool findSubDirectory(DirectoryStorage::EntryIndex e,const std::string& s) const ; // returns true when s is the name of a sub-directory in the given entry e
|
||||
|
||||
uint32_t mRoot ;
|
||||
std::vector<FileStorageNode*> mNodes;// uses pointers to keep information about valid/invalid objects.
|
||||
|
||||
void compress() ; // use empty space in the vector, mostly due to deleted entries. This is a complicated operation, mostly due to
|
||||
// all the indirections used. Nodes need to be moved, renamed, etc. The operation discards all file entries that
|
||||
// are not referenced.
|
||||
|
||||
friend class DirectoryStorage ; // only class that can use this.
|
||||
friend class LocalDirectoryStorage ; // only class that can use this.
|
||||
|
||||
// Low level stuff. Should normally not be used externally.
|
||||
|
||||
const FileStorageNode *getNode(DirectoryStorage::EntryIndex indx) const;
|
||||
const DirEntry *getDirEntry(DirectoryStorage::EntryIndex indx) const;
|
||||
const FileEntry *getFileEntry(DirectoryStorage::EntryIndex indx) const;
|
||||
uint32_t getType(DirectoryStorage::EntryIndex indx) const;
|
||||
DirectoryStorage::EntryIndex getSubFileIndex(DirectoryStorage::EntryIndex parent_index,uint32_t file_tab_index);
|
||||
DirectoryStorage::EntryIndex getSubDirIndex(DirectoryStorage::EntryIndex parent_index,uint32_t dir_tab_index);
|
||||
|
||||
// search. SearchHash is logarithmic. The other two are linear.
|
||||
|
||||
bool searchHash(const RsFileHash& hash,std::list<DirectoryStorage::EntryIndex>& results);
|
||||
int searchBoolExp(RsRegularExpression::Expression * exp, std::list<DirectoryStorage::EntryIndex> &results) const ;
|
||||
int searchTerms(const std::list<std::string>& terms, std::list<DirectoryStorage::EntryIndex> &results) const ; // does a logical OR between items of the list of terms
|
||||
|
||||
bool check(std::string& error_string) ;// checks consistency of storage.
|
||||
|
||||
void print() const;
|
||||
|
||||
private:
|
||||
void recursPrint(int depth,DirectoryStorage::EntryIndex node) const;
|
||||
static bool nodeAccessError(const std::string& s);
|
||||
static RsFileHash createDirHash(const std::string& dir_name, const RsFileHash &dir_parent_hash, const RsFileHash &random_hash_salt) ;
|
||||
|
||||
// Allocates a new entry in mNodes, possible re-using an empty slot and returns its index.
|
||||
|
||||
DirectoryStorage::EntryIndex allocateNewIndex();
|
||||
|
||||
// Removes the given subdirectory from the parent node and all its pendign subdirs. Files are kept, and will go during the cleaning
|
||||
// phase. That allows to keep file information when moving them around.
|
||||
|
||||
bool recursRemoveDirectory(DirectoryStorage::EntryIndex dir);
|
||||
|
||||
// Map of the hash of all files. The file hashes are the sha1sum of the file data.
|
||||
// is used for fast search access for FT.
|
||||
// Note: We should try something faster than std::map. hash_map??
|
||||
// Unlike directories, multiple files may have the same hash. So this cannot be used for anything else than FT.
|
||||
|
||||
std::map<RsFileHash,DirectoryStorage::EntryIndex> mFileHashes ;
|
||||
|
||||
// The directory hashes are the sha1sum of the
|
||||
// full public path to the directory.
|
||||
// The later is used by synchronisation items in order
|
||||
// to avoid sending explicit EntryIndex values.
|
||||
// This is kept separate from mFileHashes because the two are used
|
||||
// in very different ways.
|
||||
//
|
||||
std::map<RsFileHash,DirectoryStorage::EntryIndex> mDirHashes ;
|
||||
};
|
||||
|
13
libretroshare/src/file_sharing/directory_list.h
Normal file
13
libretroshare/src/file_sharing/directory_list.h
Normal file
@ -0,0 +1,13 @@
|
||||
// This class keeps a shared directory. It's quite the equivalent of the old "FileIndex" class
|
||||
// The main difference is that it is
|
||||
// - extensible
|
||||
// - fast to search (at least for hashes). Should provide possibly multiple search handles for
|
||||
// the same file, e.g. if connexion is encrypted.
|
||||
// - abstracts the browsing in a same manner.
|
||||
//
|
||||
class SharedDirectoryList
|
||||
{
|
||||
public:
|
||||
|
||||
DirEntry mRoot ;
|
||||
};
|
842
libretroshare/src/file_sharing/directory_storage.cc
Normal file
842
libretroshare/src/file_sharing/directory_storage.cc
Normal file
@ -0,0 +1,842 @@
|
||||
/*
|
||||
* RetroShare File list storage system.
|
||||
*
|
||||
* file_sharing/directory_storage.cc
|
||||
*
|
||||
* Copyright 2016 Mr.Alice
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
#include <set>
|
||||
#include <time.h>
|
||||
#include "serialiser/rstlvbinary.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "file_sharing_defaults.h"
|
||||
#include "directory_storage.h"
|
||||
#include "dir_hierarchy.h"
|
||||
#include "filelist_io.h"
|
||||
|
||||
//#define DEBUG_REMOTE_DIRECTORY_STORAGE 1
|
||||
|
||||
/******************************************************************************************************************/
|
||||
/* Iterators */
|
||||
/******************************************************************************************************************/
|
||||
|
||||
DirectoryStorage::DirIterator::DirIterator(DirectoryStorage *s,DirectoryStorage::EntryIndex i)
|
||||
{
|
||||
mStorage = s->mFileHierarchy ;
|
||||
mParentIndex = i;
|
||||
mDirTabIndex = 0;
|
||||
}
|
||||
|
||||
DirectoryStorage::FileIterator::FileIterator(DirectoryStorage *s,DirectoryStorage::EntryIndex i)
|
||||
{
|
||||
mStorage = s->mFileHierarchy ;
|
||||
mParentIndex = i;
|
||||
mFileTabIndex = 0;
|
||||
}
|
||||
|
||||
DirectoryStorage::DirIterator& DirectoryStorage::DirIterator::operator++()
|
||||
{
|
||||
++mDirTabIndex ;
|
||||
|
||||
return *this;
|
||||
}
|
||||
DirectoryStorage::FileIterator& DirectoryStorage::FileIterator::operator++()
|
||||
{
|
||||
++mFileTabIndex ;
|
||||
|
||||
return *this;
|
||||
}
|
||||
DirectoryStorage::EntryIndex DirectoryStorage::FileIterator::operator*() const { return mStorage->getSubFileIndex(mParentIndex,mFileTabIndex) ; }
|
||||
DirectoryStorage::EntryIndex DirectoryStorage::DirIterator ::operator*() const { return mStorage->getSubDirIndex(mParentIndex,mDirTabIndex) ; }
|
||||
|
||||
DirectoryStorage::FileIterator::operator bool() const { return **this != DirectoryStorage::NO_INDEX; }
|
||||
DirectoryStorage::DirIterator ::operator bool() const { return **this != DirectoryStorage::NO_INDEX; }
|
||||
|
||||
RsFileHash DirectoryStorage::FileIterator::hash() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_hash):RsFileHash(); }
|
||||
uint64_t DirectoryStorage::FileIterator::size() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_size):0; }
|
||||
std::string DirectoryStorage::FileIterator::name() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_name):std::string(); }
|
||||
time_t DirectoryStorage::FileIterator::modtime() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_modtime):0; }
|
||||
|
||||
std::string DirectoryStorage::DirIterator::name() const { const InternalFileHierarchyStorage::DirEntry *d = mStorage->getDirEntry(**this) ; return d?(d->dir_name):std::string(); }
|
||||
|
||||
/******************************************************************************************************************/
|
||||
/* Directory Storage */
|
||||
/******************************************************************************************************************/
|
||||
|
||||
DirectoryStorage::DirectoryStorage(const RsPeerId &pid)
|
||||
: mPeerId(pid), mDirStorageMtx("Directory storage "+pid.toStdString())
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
mFileHierarchy = new InternalFileHierarchyStorage();
|
||||
}
|
||||
|
||||
DirectoryStorage::EntryIndex DirectoryStorage::root() const
|
||||
{
|
||||
return EntryIndex(0) ;
|
||||
}
|
||||
int DirectoryStorage::parentRow(EntryIndex e) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
return mFileHierarchy->parentRow(e) ;
|
||||
}
|
||||
bool DirectoryStorage::getChildIndex(EntryIndex e,int row,EntryIndex& c) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
return mFileHierarchy->getChildIndex(e,row,c) ;
|
||||
}
|
||||
|
||||
uint32_t DirectoryStorage::getEntryType(const EntryIndex& indx)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
switch(mFileHierarchy->getType(indx))
|
||||
{
|
||||
case InternalFileHierarchyStorage::FileStorageNode::TYPE_DIR: return DIR_TYPE_DIR ;
|
||||
case InternalFileHierarchyStorage::FileStorageNode::TYPE_FILE: return DIR_TYPE_FILE ;
|
||||
default:
|
||||
return DIR_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
bool DirectoryStorage::getDirectoryUpdateTime (EntryIndex index,time_t& update_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); }
|
||||
bool DirectoryStorage::getDirectoryRecursModTime(EntryIndex index,time_t& rec_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); }
|
||||
bool DirectoryStorage::getDirectoryLocalModTime (EntryIndex index,time_t& loc_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); }
|
||||
|
||||
bool DirectoryStorage::setDirectoryUpdateTime (EntryIndex index,time_t update_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); }
|
||||
bool DirectoryStorage::setDirectoryRecursModTime(EntryIndex index,time_t rec_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); }
|
||||
bool DirectoryStorage::setDirectoryLocalModTime (EntryIndex index,time_t loc_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); }
|
||||
|
||||
bool DirectoryStorage::updateSubDirectoryList(const EntryIndex& indx,const std::map<std::string,time_t>& subdirs,const RsFileHash& hash_salt)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
bool res = mFileHierarchy->updateSubDirectoryList(indx,subdirs,hash_salt) ;
|
||||
locked_check() ;
|
||||
return res ;
|
||||
}
|
||||
bool DirectoryStorage::updateSubFilesList(const EntryIndex& indx,const std::map<std::string,FileTS>& subfiles,std::map<std::string,FileTS>& new_files)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
bool res = mFileHierarchy->updateSubFilesList(indx,subfiles,new_files) ;
|
||||
locked_check() ;
|
||||
return res ;
|
||||
}
|
||||
bool DirectoryStorage::removeDirectory(const EntryIndex& indx)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
bool res = mFileHierarchy->removeDirectory(indx);
|
||||
|
||||
locked_check();
|
||||
return res ;
|
||||
}
|
||||
|
||||
void DirectoryStorage::locked_check()
|
||||
{
|
||||
std::string error ;
|
||||
if(!mFileHierarchy->check(error))
|
||||
std::cerr << "Check error: " << error << std::endl;
|
||||
}
|
||||
|
||||
bool DirectoryStorage::updateFile(const EntryIndex& index,const RsFileHash& hash,const std::string& fname, uint64_t size,time_t modf_time)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->updateFile(index,hash,fname,size,modf_time);
|
||||
}
|
||||
bool DirectoryStorage::updateHash(const EntryIndex& index,const RsFileHash& hash)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->updateHash(index,hash);
|
||||
}
|
||||
|
||||
int DirectoryStorage::searchHash(const RsFileHash& hash, std::list<EntryIndex> &results) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->searchHash(hash,results);
|
||||
}
|
||||
|
||||
bool DirectoryStorage::load(const std::string& local_file_name)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->load(local_file_name);
|
||||
}
|
||||
void DirectoryStorage::save(const std::string& local_file_name)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
mFileHierarchy->save(local_file_name);
|
||||
}
|
||||
void DirectoryStorage::print()
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
mFileHierarchy->print();
|
||||
}
|
||||
|
||||
int DirectoryStorage::searchTerms(const std::list<std::string>& terms, std::list<EntryIndex> &results) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->searchTerms(terms,results);
|
||||
}
|
||||
int DirectoryStorage::searchBoolExp(RsRegularExpression::Expression * exp, std::list<EntryIndex> &results) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->searchBoolExp(exp,results);
|
||||
}
|
||||
|
||||
bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
d.children.clear() ;
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
uint32_t type = mFileHierarchy->getType(indx) ;
|
||||
|
||||
d.ref = (void*)(intptr_t)indx ;
|
||||
|
||||
if (type == InternalFileHierarchyStorage::FileStorageNode::TYPE_DIR) /* has children --- fill */
|
||||
{
|
||||
const InternalFileHierarchyStorage::DirEntry *dir_entry = mFileHierarchy->getDirEntry(indx) ;
|
||||
|
||||
/* extract all the entries */
|
||||
|
||||
for(DirectoryStorage::DirIterator it(this,indx);it;++it)
|
||||
{
|
||||
DirStub stub;
|
||||
stub.type = DIR_TYPE_DIR;
|
||||
stub.name = it.name();
|
||||
stub.ref = (void*)(intptr_t)*it; // this is updated by the caller, who knows which friend we're dealing with
|
||||
|
||||
d.children.push_back(stub);
|
||||
}
|
||||
|
||||
for(DirectoryStorage::FileIterator it(this,indx);it;++it)
|
||||
{
|
||||
DirStub stub;
|
||||
stub.type = DIR_TYPE_FILE;
|
||||
stub.name = it.name();
|
||||
stub.ref = (void*)(intptr_t)*it;
|
||||
|
||||
d.children.push_back(stub);
|
||||
}
|
||||
|
||||
d.type = DIR_TYPE_DIR;
|
||||
d.hash.clear() ;
|
||||
d.count = dir_entry->subdirs.size() + dir_entry->subfiles.size();
|
||||
d.min_age = now - dir_entry->dir_most_recent_time ;
|
||||
d.age = now - dir_entry->dir_modtime ;
|
||||
d.name = dir_entry->dir_name;
|
||||
d.path = RsDirUtil::makePath(dir_entry->dir_parent_path, dir_entry->dir_name) ;
|
||||
d.parent = (void*)(intptr_t)dir_entry->parent_index ;
|
||||
|
||||
if(indx == 0)
|
||||
{
|
||||
d.type = DIR_TYPE_PERSON ;
|
||||
d.name = mPeerId.toStdString();
|
||||
}
|
||||
}
|
||||
else if(type == InternalFileHierarchyStorage::FileStorageNode::TYPE_FILE)
|
||||
{
|
||||
const InternalFileHierarchyStorage::FileEntry *file_entry = mFileHierarchy->getFileEntry(indx) ;
|
||||
|
||||
d.type = DIR_TYPE_FILE;
|
||||
d.count = file_entry->file_size;
|
||||
d.min_age = now - file_entry->file_modtime ;
|
||||
d.name = file_entry->file_name;
|
||||
d.hash = file_entry->file_hash;
|
||||
d.age = now - file_entry->file_modtime;
|
||||
d.parent = (void*)(intptr_t)file_entry->parent_index ;
|
||||
|
||||
const InternalFileHierarchyStorage::DirEntry *parent_dir_entry = mFileHierarchy->getDirEntry(file_entry->parent_index);
|
||||
|
||||
if(parent_dir_entry != NULL)
|
||||
d.path = RsDirUtil::makePath(parent_dir_entry->dir_parent_path, parent_dir_entry->dir_name) ;
|
||||
else
|
||||
d.path = "" ;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
d.flags.clear() ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DirectoryStorage::getDirHashFromIndex(const EntryIndex& index,RsFileHash& hash) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->getDirHashFromIndex(index,hash) ;
|
||||
}
|
||||
bool DirectoryStorage::getIndexFromDirHash(const RsFileHash& hash,EntryIndex& index) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->getIndexFromDirHash(hash,index) ;
|
||||
}
|
||||
|
||||
/******************************************************************************************************************/
|
||||
/* Local Directory Storage */
|
||||
/******************************************************************************************************************/
|
||||
|
||||
void LocalDirectoryStorage::setSharedDirectoryList(const std::list<SharedDirInfo>& lst)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
// Chose virtual name if not supplied, and remove duplicates.
|
||||
|
||||
std::set<std::string> virtual_names ; // maps virtual to real name
|
||||
std::list<SharedDirInfo> processed_list ;
|
||||
|
||||
for(std::list<SharedDirInfo>::const_iterator it(lst.begin());it!= lst.end();++it)
|
||||
{
|
||||
int i=0;
|
||||
std::string candidate_virtual_name = it->virtualname ;
|
||||
|
||||
if(candidate_virtual_name.empty())
|
||||
candidate_virtual_name = RsDirUtil::getTopDir(it->filename);
|
||||
|
||||
while(virtual_names.find(candidate_virtual_name) != virtual_names.end())
|
||||
rs_sprintf_append(candidate_virtual_name, "-%d", ++i);
|
||||
|
||||
SharedDirInfo d(*it);
|
||||
d.virtualname = candidate_virtual_name ;
|
||||
processed_list.push_back(d) ;
|
||||
|
||||
virtual_names.insert(candidate_virtual_name) ;
|
||||
}
|
||||
|
||||
mLocalDirs.clear();
|
||||
|
||||
for(std::list<SharedDirInfo>::const_iterator it(processed_list.begin());it!=processed_list.end();++it)
|
||||
mLocalDirs[it->filename] = *it;
|
||||
|
||||
mTSChanged = true ;
|
||||
}
|
||||
void LocalDirectoryStorage::getSharedDirectoryList(std::list<SharedDirInfo>& lst)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
lst.clear();
|
||||
|
||||
for(std::map<std::string,SharedDirInfo>::iterator it(mLocalDirs.begin());it!=mLocalDirs.end();++it)
|
||||
lst.push_back(it->second) ;
|
||||
}
|
||||
|
||||
static bool sameLists(const std::list<RsNodeGroupId>& l1,const std::list<RsNodeGroupId>& l2)
|
||||
{
|
||||
std::list<RsNodeGroupId>::const_iterator it1(l1.begin()) ;
|
||||
std::list<RsNodeGroupId>::const_iterator it2(l2.begin()) ;
|
||||
|
||||
for(; (it1!=l1.end() && it2!=l2.end());++it1,++it2)
|
||||
if(*it1 != *it2)
|
||||
return false ;
|
||||
|
||||
return it1 == l1.end() && it2 == l2.end() ;
|
||||
}
|
||||
|
||||
void LocalDirectoryStorage::updateShareFlags(const SharedDirInfo& info)
|
||||
{
|
||||
bool changed = false ;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
std::map<std::string,SharedDirInfo>::iterator it = mLocalDirs.find(info.filename) ;
|
||||
|
||||
if(it == mLocalDirs.end())
|
||||
{
|
||||
std::cerr << "(EE) LocalDirectoryStorage::updateShareFlags: directory \"" << info.filename << "\" not found" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
// we compare the new info with the old one. If the two group lists have a different order, they will be seen as different. Not a big deal. We just
|
||||
// want to make sure that if they are different, flags get updated.
|
||||
|
||||
if(!sameLists(it->second.parent_groups,info.parent_groups) || it->second.filename != info.filename || it->second.shareflags != info.shareflags || it->second.virtualname != info.virtualname)
|
||||
{
|
||||
it->second = info;
|
||||
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
std::cerr << "Updating dir mod time because flags at level 0 have changed." << std::endl;
|
||||
#endif
|
||||
changed = true ;
|
||||
}
|
||||
}
|
||||
|
||||
if(changed)
|
||||
{
|
||||
setDirectoryLocalModTime(0,time(NULL)) ;
|
||||
mTSChanged = true ;
|
||||
}
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::convertSharedFilePath(const std::string& path, std::string& fullpath)
|
||||
{
|
||||
std::string shpath = RsDirUtil::removeRootDir(path);
|
||||
std::string basedir = RsDirUtil::getRootDir(path);
|
||||
std::string realroot ;
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
realroot = locked_findRealRootFromVirtualFilename(basedir);
|
||||
}
|
||||
|
||||
if (realroot.empty())
|
||||
return false;
|
||||
|
||||
/* construct full name */
|
||||
fullpath = realroot + "/";
|
||||
fullpath += shpath;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LocalDirectoryStorage::notifyTSChanged()
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
mTSChanged = true ;
|
||||
}
|
||||
void LocalDirectoryStorage::updateTimeStamps()
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
if(mTSChanged)
|
||||
{
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
std::cerr << "Updating recursive TS for local shared dirs..." << std::endl;
|
||||
#endif
|
||||
|
||||
time_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0)) ;
|
||||
mTSChanged = false ;
|
||||
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
std::cerr << "LocalDirectoryStorage: global last modf time is " << last_modf_time << " (which is " << time(NULL) - last_modf_time << " secs ago)" << std::endl;
|
||||
#else
|
||||
// remove unused variable warning
|
||||
// variable is only used for debugging
|
||||
(void)last_modf_time;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
std::string LocalDirectoryStorage::locked_findRealRootFromVirtualFilename(const std::string& virtual_rootdir) const
|
||||
{
|
||||
/**** MUST ALREADY BE LOCKED ****/
|
||||
|
||||
std::map<std::string, SharedDirInfo>::const_iterator cit = mLocalDirs.find(virtual_rootdir) ;
|
||||
|
||||
if (cit == mLocalDirs.end())
|
||||
{
|
||||
std::cerr << "(EE) locked_findRealRootFromVirtualFilename() Invalid RootDir: " << virtual_rootdir << std::endl;
|
||||
return std::string();
|
||||
}
|
||||
return cit->second.filename;
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
|
||||
{
|
||||
bool res = DirectoryStorage::extractData(indx,d) ;
|
||||
|
||||
if(!res)
|
||||
return false;
|
||||
|
||||
// here we should update the file sharing flags
|
||||
|
||||
return getFileSharingPermissions(indx,d.flags,d.parent_groups) ;
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::getFileInfo(DirectoryStorage::EntryIndex i,FileInfo& info)
|
||||
{
|
||||
DirDetails d;
|
||||
extractData(i,d) ;
|
||||
|
||||
if(d.type != DIR_TYPE_FILE)
|
||||
{
|
||||
std::cerr << "(EE) LocalDirectoryStorage: asked for file info for index " << i << " which is not a file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
info.storage_permission_flags = d.flags; // Combination of the four RS_DIR_FLAGS_*. Updated when the file is a local stored file.
|
||||
info.parent_groups = d.parent_groups;
|
||||
info.transfer_info_flags = TransferRequestFlags(); // various flags from RS_FILE_HINTS_*
|
||||
info.path = d.path + "/" + d.name;
|
||||
info.fname = d.name;
|
||||
info.hash = d.hash;
|
||||
info.size = d.count;
|
||||
|
||||
// all this stuff below is not useful in this case.
|
||||
|
||||
info.mId = 0; /* (GUI) Model Id -> unique number */
|
||||
info.ext.clear();
|
||||
info.avail = 0; /* how much we have */
|
||||
info.rank = 0;
|
||||
info.age = 0;
|
||||
info.queue_position =0;
|
||||
info.searchId = 0; /* 0 if none */
|
||||
|
||||
/* Transfer Stuff */
|
||||
info.transfered = 0;
|
||||
info.tfRate = 0; /* in kbytes */
|
||||
info.downloadStatus = FT_STATE_COMPLETE ;
|
||||
std::list<TransferInfo> peers;
|
||||
|
||||
info.priority = SPEED_NORMAL;
|
||||
info.lastTS = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::getFileSharingPermissions(const EntryIndex& indx,FileStorageFlags& flags,std::list<RsNodeGroupId>& parent_groups)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return locked_getFileSharingPermissions(indx,flags,parent_groups) ;
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::locked_getFileSharingPermissions(const EntryIndex& indx, FileStorageFlags& flags, std::list<RsNodeGroupId> &parent_groups)
|
||||
{
|
||||
flags.clear() ;
|
||||
parent_groups.clear();
|
||||
|
||||
std::string base_dir;
|
||||
|
||||
const InternalFileHierarchyStorage::FileStorageNode *n = mFileHierarchy->getNode(indx) ;
|
||||
|
||||
if(n == NULL)
|
||||
return false ;
|
||||
|
||||
for(DirectoryStorage::EntryIndex i=((n->type()==InternalFileHierarchyStorage::FileStorageNode::TYPE_FILE)?((intptr_t)n->parent_index):indx);;)
|
||||
{
|
||||
const InternalFileHierarchyStorage::DirEntry *e = mFileHierarchy->getDirEntry(i) ;
|
||||
|
||||
if(e == NULL)
|
||||
break ;
|
||||
|
||||
if(e->parent_index == 0)
|
||||
{
|
||||
base_dir = e->dir_name ;
|
||||
break ;
|
||||
}
|
||||
i = e->parent_index ;
|
||||
}
|
||||
|
||||
if(!base_dir.empty())
|
||||
{
|
||||
std::map<std::string,SharedDirInfo>::const_iterator it = mLocalDirs.find(base_dir) ;
|
||||
|
||||
if(it == mLocalDirs.end())
|
||||
{
|
||||
std::cerr << "(EE) very weird bug: base directory \"" << base_dir << "\" not found in shared dir list." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
flags = it->second.shareflags;
|
||||
parent_groups = it->second.parent_groups;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string LocalDirectoryStorage::locked_getVirtualDirName(EntryIndex indx) const
|
||||
{
|
||||
if(indx == 0)
|
||||
return std::string() ;
|
||||
|
||||
const InternalFileHierarchyStorage::DirEntry *dir = mFileHierarchy->getDirEntry(indx);
|
||||
|
||||
if(dir->parent_index != 0)
|
||||
return dir->dir_name ;
|
||||
|
||||
std::map<std::string,SharedDirInfo>::const_iterator it = mLocalDirs.find(dir->dir_name) ;
|
||||
|
||||
if(it == mLocalDirs.end())
|
||||
{
|
||||
std::cerr << "(EE) Cannot find real name " << dir->dir_name << " at level 1 among shared dirs. Bug?" << std::endl;
|
||||
return std::string() ;
|
||||
}
|
||||
|
||||
return it->second.virtualname ;
|
||||
}
|
||||
std::string LocalDirectoryStorage::locked_getVirtualPath(EntryIndex indx) const
|
||||
{
|
||||
if(indx == 0)
|
||||
return std::string() ;
|
||||
|
||||
std::string res ;
|
||||
const InternalFileHierarchyStorage::DirEntry *dir = mFileHierarchy->getDirEntry(indx);
|
||||
|
||||
while(dir->parent_index != 0)
|
||||
{
|
||||
dir = mFileHierarchy->getDirEntry(dir->parent_index) ;
|
||||
res += dir->dir_name + "/"+ res ;
|
||||
}
|
||||
|
||||
std::map<std::string,SharedDirInfo>::const_iterator it = mLocalDirs.find(dir->dir_name) ;
|
||||
|
||||
if(it == mLocalDirs.end())
|
||||
{
|
||||
std::cerr << "(EE) Cannot find real name " << dir->dir_name << " at level 1 among shared dirs. Bug?" << std::endl;
|
||||
return std::string() ;
|
||||
}
|
||||
return it->second.virtualname + "/" + res;
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::serialiseDirEntry(const EntryIndex& indx,RsTlvBinaryData& bindata,const RsPeerId& client_id)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
const InternalFileHierarchyStorage::DirEntry *dir = mFileHierarchy->getDirEntry(indx);
|
||||
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
std::cerr << "Serialising Dir entry " << std::hex << indx << " for client id " << client_id << std::endl;
|
||||
#endif
|
||||
if(dir == NULL)
|
||||
{
|
||||
std::cerr << "(EE) serialiseDirEntry: ERROR. Cannot find entry " << (void*)(intptr_t)indx << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// compute list of allowed subdirs
|
||||
std::vector<RsFileHash> allowed_subdirs ;
|
||||
FileStorageFlags node_flags ;
|
||||
std::list<RsNodeGroupId> node_groups ;
|
||||
|
||||
// for each subdir, compute the node flags and groups, then ask rsPeers to compute the mask that result from these flags for the particular peer supplied in parameter
|
||||
|
||||
for(uint32_t i=0;i<dir->subdirs.size();++i)
|
||||
if(indx != 0 || (locked_getFileSharingPermissions(dir->subdirs[i],node_flags,node_groups) && (rsPeers->computePeerPermissionFlags(client_id,node_flags,node_groups) & RS_FILE_HINTS_BROWSABLE)))
|
||||
{
|
||||
RsFileHash hash ;
|
||||
if(!mFileHierarchy->getDirHashFromIndex(dir->subdirs[i],hash))
|
||||
{
|
||||
std::cerr << "(EE) Cannot get hash from subdir index " << dir->subdirs[i] << ". Weird bug." << std::endl ;
|
||||
return false;
|
||||
}
|
||||
allowed_subdirs.push_back(hash) ;
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
std::cerr << " pushing subdir " << hash << ", array position=" << i << " indx=" << dir->subdirs[i] << std::endl;
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
else
|
||||
std::cerr << " not pushing subdir " << hash << ", array position=" << i << " indx=" << dir->subdirs[i] << ": permission denied for this peer." << std::endl;
|
||||
#endif
|
||||
|
||||
// now count the files that do not have a null hash (meaning the hash has indeed been computed)
|
||||
|
||||
uint32_t allowed_subfiles = 0 ;
|
||||
|
||||
for(uint32_t i=0;i<dir->subfiles.size();++i)
|
||||
{
|
||||
const InternalFileHierarchyStorage::FileEntry *file = mFileHierarchy->getFileEntry(dir->subfiles[i]) ;
|
||||
if(file != NULL && !file->file_hash.isNull())
|
||||
allowed_subfiles++ ;
|
||||
}
|
||||
|
||||
unsigned char *section_data = NULL;
|
||||
uint32_t section_size = 0;
|
||||
uint32_t section_offset = 0;
|
||||
|
||||
// we need to send:
|
||||
// - the name of the directory, its TS
|
||||
// - the index entry for each subdir (the updte TS are exchanged at a higher level)
|
||||
// - the file info for each subfile
|
||||
//
|
||||
std::string virtual_dir_name = locked_getVirtualDirName(indx) ;
|
||||
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_DIR_NAME ,virtual_dir_name )) return false ;
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RECURS_MODIF_TS,(uint32_t)dir->dir_most_recent_time)) return false ;
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_MODIF_TS ,(uint32_t)dir->dir_modtime )) return false ;
|
||||
|
||||
// serialise number of subdirs and number of subfiles
|
||||
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)allowed_subdirs.size() )) return false ;
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)allowed_subfiles )) return false ;
|
||||
|
||||
// serialise subdirs entry indexes
|
||||
|
||||
for(uint32_t i=0;i<allowed_subdirs.size();++i)
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_ENTRY_INDEX ,allowed_subdirs[i] )) return false ;
|
||||
|
||||
// serialise directory subfiles, with info for each of them
|
||||
|
||||
for(uint32_t i=0;i<dir->subfiles.size();++i)
|
||||
{
|
||||
unsigned char *file_section_data = NULL ;
|
||||
uint32_t file_section_offset = 0 ;
|
||||
uint32_t file_section_size = 0;
|
||||
|
||||
const InternalFileHierarchyStorage::FileEntry *file = mFileHierarchy->getFileEntry(dir->subfiles[i]) ;
|
||||
|
||||
if(file == NULL || file->file_hash.isNull())
|
||||
{
|
||||
std::cerr << "(II) skipping unhashed or Null file entry " << dir->subfiles[i] << " to get/send file info." << std::endl;
|
||||
continue ;
|
||||
}
|
||||
|
||||
if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_NAME ,file->file_name )) return false ;
|
||||
if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,file->file_size )) return false ;
|
||||
if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,file->file_hash )) return false ;
|
||||
if(!FileListIO::writeField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_MODIF_TS ,(uint32_t)file->file_modtime)) return false ;
|
||||
|
||||
// now write the whole string into a single section in the file
|
||||
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_REMOTE_FILE_ENTRY,file_section_data,file_section_offset)) return false ;
|
||||
|
||||
free(file_section_data) ;
|
||||
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
std::cerr << " pushing subfile " << file->hash << ", array position=" << i << " indx=" << dir->subfiles[i] << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
std::cerr << "Serialised dir entry to send for entry index " << (void*)(intptr_t)indx << ". Data size is " << section_size << " bytes" << std::endl;
|
||||
#endif
|
||||
|
||||
bindata.bin_data = section_data ;
|
||||
bindata.bin_len = section_offset ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
/******************************************************************************************************************/
|
||||
/* Remote Directory Storage */
|
||||
/******************************************************************************************************************/
|
||||
|
||||
RemoteDirectoryStorage::RemoteDirectoryStorage(const RsPeerId& pid,const std::string& fname)
|
||||
: DirectoryStorage(pid),mLastSavedTime(0),mChanged(false),mFileName(fname)
|
||||
{
|
||||
load(fname) ;
|
||||
|
||||
std::cerr << "Loaded remote directory for peer " << pid << std::endl;
|
||||
#ifdef DEBUG_REMOTE_DIRECTORY_STORAGE
|
||||
mFileHierarchy->print();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RemoteDirectoryStorage::checkSave()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
|
||||
if(mChanged && mLastSavedTime + MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE < now)
|
||||
{
|
||||
save(mFileName);
|
||||
mLastSavedTime = now ;
|
||||
mChanged = false ;
|
||||
}
|
||||
}
|
||||
|
||||
bool RemoteDirectoryStorage::deserialiseUpdateDirEntry(const EntryIndex& indx,const RsTlvBinaryData& bindata)
|
||||
{
|
||||
const unsigned char *section_data = (unsigned char*)bindata.bin_data ;
|
||||
uint32_t section_size = bindata.bin_len ;
|
||||
uint32_t section_offset=0 ;
|
||||
|
||||
#ifdef DEBUG_REMOTE_DIRECTORY_STORAGE
|
||||
std::cerr << "RemoteDirectoryStorage::deserialiseDirEntry(): deserialising directory content for friend " << peerId() << ", and directory " << indx << std::endl;
|
||||
#endif
|
||||
|
||||
std::string dir_name ;
|
||||
uint32_t most_recent_time ,dir_modtime ;
|
||||
|
||||
if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_DIR_NAME ,dir_name )) return false ;
|
||||
if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RECURS_MODIF_TS,most_recent_time)) return false ;
|
||||
if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_MODIF_TS ,dir_modtime )) return false ;
|
||||
|
||||
#ifdef DEBUG_REMOTE_DIRECTORY_STORAGE
|
||||
std::cerr << " dir name : \"" << dir_name << "\"" << std::endl;
|
||||
std::cerr << " most recent time : " << most_recent_time << std::endl;
|
||||
std::cerr << " modification time : " << dir_modtime << std::endl;
|
||||
#endif
|
||||
|
||||
// serialise number of subdirs and number of subfiles
|
||||
|
||||
uint32_t n_subdirs,n_subfiles ;
|
||||
|
||||
if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,n_subdirs )) return false ;
|
||||
if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,n_subfiles )) return false ;
|
||||
|
||||
#ifdef DEBUG_REMOTE_DIRECTORY_STORAGE
|
||||
std::cerr << " number of subdirs : " << n_subdirs << std::endl;
|
||||
std::cerr << " number of files : " << n_subfiles << std::endl;
|
||||
#endif
|
||||
|
||||
// serialise subdirs entry indexes
|
||||
|
||||
std::vector<RsFileHash> subdirs_hashes ;
|
||||
RsFileHash subdir_hash ;
|
||||
|
||||
for(uint32_t i=0;i<n_subdirs;++i)
|
||||
{
|
||||
if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_ENTRY_INDEX ,subdir_hash)) return false ;
|
||||
|
||||
subdirs_hashes.push_back(subdir_hash) ;
|
||||
}
|
||||
|
||||
// deserialise directory subfiles, with info for each of them
|
||||
|
||||
std::vector<InternalFileHierarchyStorage::FileEntry> subfiles_array ;
|
||||
|
||||
for(uint32_t i=0;i<n_subfiles;++i)
|
||||
{
|
||||
// Read the full data section for the file
|
||||
|
||||
unsigned char *file_section_data = NULL ;
|
||||
uint32_t file_section_size = 0;
|
||||
|
||||
if(!FileListIO::readField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_REMOTE_FILE_ENTRY,file_section_data,file_section_size)) return false ;
|
||||
|
||||
uint32_t file_section_offset = 0 ;
|
||||
|
||||
InternalFileHierarchyStorage::FileEntry f;
|
||||
uint32_t modtime =0;
|
||||
|
||||
if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_NAME ,f.file_name )) return false ;
|
||||
if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,f.file_size )) return false ;
|
||||
if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_FILE_SHA1_HASH,f.file_hash )) return false ;
|
||||
if(!FileListIO::readField(file_section_data,file_section_size,file_section_offset,FILE_LIST_IO_TAG_MODIF_TS ,modtime )) return false ;
|
||||
|
||||
f.file_modtime = modtime ;
|
||||
|
||||
free(file_section_data) ;
|
||||
|
||||
subfiles_array.push_back(f) ;
|
||||
}
|
||||
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
#ifdef DEBUG_REMOTE_DIRECTORY_STORAGE
|
||||
std::cerr << " updating dir entry..." << std::endl;
|
||||
#endif
|
||||
|
||||
// First create the entries for each subdir and each subfile, if needed.
|
||||
if(!mFileHierarchy->updateDirEntry(indx,dir_name,most_recent_time,dir_modtime,subdirs_hashes,subfiles_array))
|
||||
{
|
||||
std::cerr << "(EE) Cannot update dir entry with index " << indx << ": entry does not exist." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
mChanged = true ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
285
libretroshare/src/file_sharing/directory_storage.h
Normal file
285
libretroshare/src/file_sharing/directory_storage.h
Normal file
@ -0,0 +1,285 @@
|
||||
/*
|
||||
* RetroShare C++ Directory Storage system.
|
||||
*
|
||||
* file_sharing/directory_storage.h
|
||||
*
|
||||
* Copyright 2016 by Mr.Alice
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <list>
|
||||
|
||||
#include "retroshare/rsids.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
|
||||
#define NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; }
|
||||
|
||||
class RsTlvBinaryData ;
|
||||
class InternalFileHierarchyStorage ;
|
||||
class RsTlvBinaryData ;
|
||||
|
||||
class DirectoryStorage
|
||||
{
|
||||
public:
|
||||
DirectoryStorage(const RsPeerId& pid) ;
|
||||
virtual ~DirectoryStorage() {}
|
||||
|
||||
typedef uint32_t EntryIndex ;
|
||||
static const EntryIndex NO_INDEX = 0xffffffff;
|
||||
|
||||
void save() const ;
|
||||
|
||||
// These functions are to be used by file transfer and file search.
|
||||
|
||||
virtual int searchTerms(const std::list<std::string>& terms, std::list<EntryIndex> &results) const ;
|
||||
virtual int searchBoolExp(RsRegularExpression::Expression * exp, std::list<EntryIndex> &results) const ;
|
||||
virtual int searchHash(const RsFileHash& hash, std::list<EntryIndex> &results) const ;
|
||||
|
||||
// gets/sets the various time stamps:
|
||||
//
|
||||
bool getDirectoryRecursModTime(EntryIndex index,time_t& recurs_max_modf_TS) const ; // last modification time, computed recursively over all subfiles and directories
|
||||
bool getDirectoryLocalModTime (EntryIndex index,time_t& motime_TS) const ; // last modification time for that index only
|
||||
bool getDirectoryUpdateTime (EntryIndex index,time_t& update_TS) const ; // last time the entry was updated. This is only used on the RemoteDirectoryStorage side.
|
||||
|
||||
bool setDirectoryRecursModTime(EntryIndex index,time_t recurs_max_modf_TS) ;
|
||||
bool setDirectoryLocalModTime (EntryIndex index,time_t modtime_TS) ;
|
||||
bool setDirectoryUpdateTime (EntryIndex index,time_t update_TS) ;
|
||||
|
||||
uint32_t getEntryType(const EntryIndex& indx) ; // WARNING: returns DIR_TYPE_*, not the internal directory storage stuff.
|
||||
virtual bool extractData(const EntryIndex& indx,DirDetails& d);
|
||||
|
||||
// This class allows to abstractly browse the stored directory hierarchy in a depth-first manner.
|
||||
// It gives access to sub-files and sub-directories below. When using it, the client should make sure
|
||||
// that the DirectoryStorage is properly locked, since the iterator cannot lock it.
|
||||
//
|
||||
class DirIterator
|
||||
{
|
||||
public:
|
||||
DirIterator(const DirIterator& d) ;
|
||||
DirIterator(DirectoryStorage *d,EntryIndex i) ;
|
||||
|
||||
DirIterator& operator++() ;
|
||||
EntryIndex operator*() const ;
|
||||
|
||||
operator bool() const ; // used in for loops. Returns true when the iterator is valid.
|
||||
|
||||
// info about the directory that is pointed by the iterator
|
||||
|
||||
std::string name() const ;
|
||||
time_t last_modif_time() const ; // last time a file in this directory or in the directories below has been modified.
|
||||
time_t last_update_time() const ; // last time this directory was updated
|
||||
private:
|
||||
EntryIndex mParentIndex ; // index of the parent dir.
|
||||
uint32_t mDirTabIndex ; // index in the vector of subdirs.
|
||||
InternalFileHierarchyStorage *mStorage ;
|
||||
|
||||
friend class DirectoryStorage ;
|
||||
};
|
||||
class FileIterator
|
||||
{
|
||||
public:
|
||||
FileIterator(DirIterator& d); // crawls all files in specified directory
|
||||
FileIterator(DirectoryStorage *d,EntryIndex e); // crawls all files in specified directory
|
||||
|
||||
FileIterator& operator++() ;
|
||||
EntryIndex operator*() const ; // current file entry
|
||||
|
||||
operator bool() const ; // used in for loops. Returns true when the iterator is valid.
|
||||
|
||||
// info about the file that is pointed by the iterator
|
||||
|
||||
std::string name() const ;
|
||||
uint64_t size() const ;
|
||||
RsFileHash hash() const ;
|
||||
time_t modtime() const ;
|
||||
|
||||
private:
|
||||
EntryIndex mParentIndex ; // index of the parent dir.
|
||||
uint32_t mFileTabIndex ; // index in the vector of subdirs.
|
||||
InternalFileHierarchyStorage *mStorage ;
|
||||
};
|
||||
|
||||
struct FileTS
|
||||
{
|
||||
uint64_t size ;
|
||||
time_t modtime;
|
||||
};
|
||||
|
||||
EntryIndex root() const ; // returns the index of the root directory entry. This is generally 0.
|
||||
const RsPeerId& peerId() const { return mPeerId ; } // peer ID of who owns that file list.
|
||||
int parentRow(EntryIndex e) const ; // position of the current node, in the array of children at its parent node. Used by GUI for display.
|
||||
bool getChildIndex(EntryIndex e,int row,EntryIndex& c) const; // returns the index of the children node at position "row" in the children nodes. Used by GUI for display.
|
||||
|
||||
// Sets the subdirectory/subfiles list of entry indx the supplied one, possible adding and removing directories (resp.files). New directories are set empty with
|
||||
// just a name and need to be updated later on. New files are returned in a list so that they can be sent to hash cache.
|
||||
//
|
||||
bool updateSubDirectoryList(const EntryIndex& indx, const std::map<std::string, time_t> &subdirs, const RsFileHash &random_hash_salt) ;
|
||||
bool updateSubFilesList(const EntryIndex& indx, const std::map<std::string, FileTS> &subfiles, std::map<std::string, FileTS> &new_files) ;
|
||||
bool removeDirectory(const EntryIndex& indx) ;
|
||||
|
||||
// Updates relevant information for the file at the given index.
|
||||
|
||||
bool updateFile(const EntryIndex& index,const RsFileHash& hash, const std::string& fname, uint64_t size, time_t modf_time) ;
|
||||
bool updateHash(const EntryIndex& index,const RsFileHash& hash);
|
||||
|
||||
// Returns the hash of the directory at the given index and reverse. This hash is set as random the first time it is used (when updating directories). It will be
|
||||
// used by the sync system to designate the directory without referring to index (index could be used to figure out the existance of hidden directories)
|
||||
|
||||
bool getDirHashFromIndex(const EntryIndex& index,RsFileHash& hash) const ; // constant cost
|
||||
bool getIndexFromDirHash(const RsFileHash& hash,EntryIndex& index) const ; // log cost.
|
||||
|
||||
void print();
|
||||
void cleanup();
|
||||
|
||||
protected:
|
||||
bool load(const std::string& local_file_name) ;
|
||||
void save(const std::string& local_file_name) ;
|
||||
|
||||
private:
|
||||
|
||||
// debug
|
||||
void locked_check();
|
||||
|
||||
// storage of internal structure. Totally hidden from the outside. EntryIndex is simply the index of the entry in the vector.
|
||||
|
||||
RsPeerId mPeerId;
|
||||
|
||||
protected:
|
||||
mutable RsMutex mDirStorageMtx ;
|
||||
|
||||
InternalFileHierarchyStorage *mFileHierarchy ;
|
||||
};
|
||||
|
||||
class RemoteDirectoryStorage: public DirectoryStorage
|
||||
{
|
||||
public:
|
||||
RemoteDirectoryStorage(const RsPeerId& pid,const std::string& fname) ;
|
||||
virtual ~RemoteDirectoryStorage() {}
|
||||
|
||||
/*!
|
||||
* \brief deserialiseDirEntry
|
||||
* Loads a serialised directory content coming from a friend. The directory entry needs to exist already,
|
||||
* as it is created when updating the parent.
|
||||
*
|
||||
* \param indx index of the directory to update
|
||||
* \param bindata binary data to deserialise from
|
||||
* \return false when the directory cannot be found.
|
||||
*/
|
||||
bool deserialiseUpdateDirEntry(const EntryIndex& indx,const RsTlvBinaryData& data) ;
|
||||
|
||||
/*!
|
||||
* \brief checkSave
|
||||
* Checks the time of last saving, last modification time, and saves if needed.
|
||||
*/
|
||||
void checkSave() ;
|
||||
|
||||
private:
|
||||
time_t mLastSavedTime ;
|
||||
bool mChanged ;
|
||||
std::string mFileName;
|
||||
};
|
||||
|
||||
class LocalDirectoryStorage: public DirectoryStorage
|
||||
{
|
||||
public:
|
||||
LocalDirectoryStorage(const std::string& fname,const RsPeerId& own_id) : DirectoryStorage(own_id),mFileName(fname) {}
|
||||
virtual ~LocalDirectoryStorage() {}
|
||||
|
||||
/*!
|
||||
* \brief [gs]etSharedDirectoryList
|
||||
* Gets/sets the list of shared directories. Each directory is supplied with a virtual name (the name the friends will see), and sharing flags/groups.
|
||||
* \param lst
|
||||
*/
|
||||
void setSharedDirectoryList(const std::list<SharedDirInfo>& lst) ;
|
||||
void getSharedDirectoryList(std::list<SharedDirInfo>& lst) ;
|
||||
|
||||
void updateShareFlags(const SharedDirInfo& info) ;
|
||||
bool convertSharedFilePath(const std::string& path_with_virtual_name,std::string& fullpath) ;
|
||||
|
||||
/*!
|
||||
* \brief updateTimeStamps
|
||||
* Checks recursive TS and update the if needed.
|
||||
*/
|
||||
void updateTimeStamps();
|
||||
|
||||
/*!
|
||||
* \brief notifyTSChanged
|
||||
* Use this to force an update of the recursive TS, when calling updateTimeStamps();
|
||||
*/
|
||||
void notifyTSChanged();
|
||||
/*!
|
||||
* \brief getFileInfo Converts an index info a full file info structure.
|
||||
* \param i index in the directory structure
|
||||
* \param info structure to be filled in
|
||||
* \return false if the file does not exist, or is a directory,...
|
||||
*/
|
||||
bool getFileInfo(DirectoryStorage::EntryIndex i,FileInfo& info) ;
|
||||
|
||||
/*!
|
||||
* \brief getFileSharingPermissions
|
||||
* Computes the flags and parent groups for any index.
|
||||
* \param indx index of the entry to compute the flags for
|
||||
* \param flags computed flags
|
||||
* \param parent_groups computed parent groups
|
||||
* \return
|
||||
* false if the index is not valid
|
||||
* false otherwise
|
||||
*/
|
||||
bool getFileSharingPermissions(const EntryIndex& indx, FileStorageFlags &flags, std::list<RsNodeGroupId> &parent_groups);
|
||||
|
||||
virtual bool extractData(const EntryIndex& indx,DirDetails& d) ;
|
||||
|
||||
/*!
|
||||
* \brief serialiseDirEntry
|
||||
* Produced a serialised directory content listing suitable for export to friends.
|
||||
*
|
||||
* \param indx index of the directory to serialise
|
||||
* \param bindata binary data created by serialisation
|
||||
* \param client_id Peer id to be serialised to. Depending on permissions, some subdirs can be removed.
|
||||
* \return false when the directory cannot be found.
|
||||
*/
|
||||
bool serialiseDirEntry(const EntryIndex& indx, RsTlvBinaryData& bindata, const RsPeerId &client_id) ;
|
||||
|
||||
private:
|
||||
std::string locked_getVirtualPath(EntryIndex indx) const ;
|
||||
std::string locked_getVirtualDirName(EntryIndex indx) const ;
|
||||
|
||||
bool locked_getFileSharingPermissions(const EntryIndex& indx, FileStorageFlags &flags, std::list<RsNodeGroupId>& parent_groups);
|
||||
std::string locked_findRealRootFromVirtualFilename(const std::string& virtual_rootdir) const;
|
||||
|
||||
std::map<std::string,SharedDirInfo> mLocalDirs ; // map is better for search. it->first=it->second.filename
|
||||
std::string mFileName;
|
||||
|
||||
bool mTSChanged ;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
248
libretroshare/src/file_sharing/directory_updater.cc
Normal file
248
libretroshare/src/file_sharing/directory_updater.cc
Normal file
@ -0,0 +1,248 @@
|
||||
/*
|
||||
* RetroShare Directory watching system.
|
||||
*
|
||||
* file_sharing/directory_updater.cc
|
||||
*
|
||||
* Copyright 2016 Mr.Alice
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
#include "util/folderiterator.h"
|
||||
#include "rsserver/p3face.h"
|
||||
|
||||
#include "directory_storage.h"
|
||||
#include "directory_updater.h"
|
||||
#include "file_sharing_defaults.h"
|
||||
|
||||
//#define DEBUG_LOCAL_DIR_UPDATER 1
|
||||
|
||||
//=============================================================================================================//
|
||||
// Local Directory Updater //
|
||||
//=============================================================================================================//
|
||||
|
||||
LocalDirectoryUpdater::LocalDirectoryUpdater(HashStorage *hc,LocalDirectoryStorage *lds)
|
||||
: mHashCache(hc),mSharedDirectories(lds)
|
||||
{
|
||||
mLastSweepTime = 0;
|
||||
mLastTSUpdateTime = 0;
|
||||
|
||||
mDelayBetweenDirectoryUpdates = DELAY_BETWEEN_DIRECTORY_UPDATES;
|
||||
mIsEnabled = false ;
|
||||
}
|
||||
|
||||
bool LocalDirectoryUpdater::isEnabled() const
|
||||
{
|
||||
return mIsEnabled ;
|
||||
}
|
||||
void LocalDirectoryUpdater::setEnabled(bool b)
|
||||
{
|
||||
if(mIsEnabled == b)
|
||||
return ;
|
||||
|
||||
if(b)
|
||||
start("fs dir updater") ;
|
||||
else
|
||||
shutdown();
|
||||
|
||||
mIsEnabled = b ;
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::data_tick()
|
||||
{
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime)
|
||||
{
|
||||
sweepSharedDirectories() ;
|
||||
mLastSweepTime = now;
|
||||
mSharedDirectories->notifyTSChanged() ;
|
||||
}
|
||||
|
||||
if(now > DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE + mLastTSUpdateTime)
|
||||
{
|
||||
mSharedDirectories->updateTimeStamps() ;
|
||||
mLastTSUpdateTime = now ;
|
||||
}
|
||||
usleep(10*1000*1000);
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::forceUpdate()
|
||||
{
|
||||
mLastSweepTime = 0;
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::sweepSharedDirectories()
|
||||
{
|
||||
if(mHashSalt.isNull())
|
||||
{
|
||||
std::cerr << "(EE) no salt value in LocalDirectoryUpdater. Is that a bug?" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||
std::cerr << "[directory storage] LocalDirectoryUpdater::sweep()" << std::endl;
|
||||
#endif
|
||||
|
||||
// recursive update algorithm works that way:
|
||||
// - the external loop starts on the shared directory list and goes through sub-directories
|
||||
// - at the same time, it updates the local list of shared directories. A single sweep is performed over the whole directory structure.
|
||||
// - the information that is costly to compute (the hash) is store externally into a separate structure.
|
||||
// - doing so, changing directory names or moving files between directories does not cause a re-hash of the content.
|
||||
//
|
||||
std::list<SharedDirInfo> shared_directory_list ;
|
||||
mSharedDirectories->getSharedDirectoryList(shared_directory_list);
|
||||
|
||||
std::map<std::string,time_t> sub_dir_list ;
|
||||
|
||||
for(std::list<SharedDirInfo>::const_iterator real_dir_it(shared_directory_list.begin());real_dir_it!=shared_directory_list.end();++real_dir_it)
|
||||
sub_dir_list[(*real_dir_it).filename] = 0 ;
|
||||
|
||||
// make sure that entries in stored_dir_it are the same than paths in real_dir_it, and in the same order.
|
||||
|
||||
mSharedDirectories->updateSubDirectoryList(mSharedDirectories->root(),sub_dir_list,mHashSalt) ;
|
||||
|
||||
// now for each of them, go recursively and match both files and dirs
|
||||
|
||||
for(DirectoryStorage::DirIterator stored_dir_it(mSharedDirectories,mSharedDirectories->root()) ; stored_dir_it;++stored_dir_it)
|
||||
{
|
||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||
std::cerr << "[directory storage] recursing into " << stored_dir_it.name() << std::endl;
|
||||
#endif
|
||||
|
||||
recursUpdateSharedDir(stored_dir_it.name(), *stored_dir_it) ; // here we need to use the list that was stored, instead of the shared dir list, because the two
|
||||
// are not necessarily in the same order.
|
||||
}
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx)
|
||||
{
|
||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||
std::cerr << "[directory storage] parsing directory " << cumulated_path << ", index=" << indx << std::endl;
|
||||
#endif
|
||||
|
||||
// make sure list of subdirs is the same
|
||||
// make sure list of subfiles is the same
|
||||
// request all hashes to the hashcache
|
||||
|
||||
librs::util::FolderIterator dirIt(cumulated_path);
|
||||
|
||||
time_t dir_local_mod_time ;
|
||||
if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time))
|
||||
{
|
||||
std::cerr << "(EE) Cannot get local mod time for dir index " << indx << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(dirIt.dir_modtime() != dir_local_mod_time)
|
||||
{
|
||||
// collect subdirs and subfiles
|
||||
|
||||
std::map<std::string,DirectoryStorage::FileTS> subfiles ;
|
||||
std::map<std::string,time_t> subdirs ;
|
||||
|
||||
for(;dirIt.isValid();dirIt.next())
|
||||
{
|
||||
switch(dirIt.file_type())
|
||||
{
|
||||
case librs::util::FolderIterator::TYPE_FILE: subfiles[dirIt.file_name()].modtime = dirIt.file_modtime() ;
|
||||
subfiles[dirIt.file_name()].size = dirIt.file_size();
|
||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||
std::cerr << " adding sub-file \"" << dirIt.file_name() << "\"" << std::endl;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case librs::util::FolderIterator::TYPE_DIR: subdirs[dirIt.file_name()] = dirIt.file_modtime();
|
||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||
std::cerr << " adding sub-dir \"" << dirIt.file_name() << "\"" << std::endl;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
std::cerr << "(EE) Dir entry of unknown type with path \"" << cumulated_path << "/" << dirIt.file_name() << "\"" << std::endl;
|
||||
}
|
||||
}
|
||||
// update folder modificatoin time, which is the only way to detect e.g. removed or renamed files.
|
||||
|
||||
mSharedDirectories->setDirectoryLocalModTime(indx,dirIt.dir_modtime()) ;
|
||||
|
||||
// update file and dir lists for current directory.
|
||||
|
||||
mSharedDirectories->updateSubDirectoryList(indx,subdirs,mHashSalt) ;
|
||||
|
||||
std::map<std::string,DirectoryStorage::FileTS> new_files ;
|
||||
mSharedDirectories->updateSubFilesList(indx,subfiles,new_files) ;
|
||||
|
||||
// now go through list of subfiles and request the hash to hashcache
|
||||
|
||||
for(DirectoryStorage::FileIterator dit(mSharedDirectories,indx);dit;++dit)
|
||||
{
|
||||
// ask about the hash. If not present, ask HashCache. If not present, or different, the callback will update it.
|
||||
|
||||
RsFileHash hash ;
|
||||
|
||||
if(mHashCache->requestHash(cumulated_path + "/" + dit.name(),dit.size(),dit.modtime(),hash,this,*dit) && dit.hash() != hash)
|
||||
mSharedDirectories->updateHash(*dit,hash);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||
else
|
||||
std::cerr << " directory is unchanged. Keeping existing files and subdirs list." << std::endl;
|
||||
#endif
|
||||
|
||||
// go through the list of sub-dirs and recursively update
|
||||
|
||||
for(DirectoryStorage::DirIterator stored_dir_it(mSharedDirectories,indx) ; stored_dir_it; ++stored_dir_it)
|
||||
{
|
||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||
std::cerr << " recursing into " << stored_dir_it.name() << std::endl;
|
||||
#endif
|
||||
recursUpdateSharedDir(cumulated_path + "/" + stored_dir_it.name(), *stored_dir_it) ;
|
||||
}
|
||||
}
|
||||
|
||||
bool LocalDirectoryUpdater::inDirectoryCheck() const
|
||||
{
|
||||
return mHashCache->isRunning();
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::hash_callback(uint32_t client_param, const std::string &/*name*/, const RsFileHash &hash, uint64_t /*size*/)
|
||||
{
|
||||
if(!mSharedDirectories->updateHash(DirectoryStorage::EntryIndex(client_param),hash))
|
||||
std::cerr << "(EE) Cannot update file. Something's wrong." << std::endl;
|
||||
|
||||
mSharedDirectories->notifyTSChanged() ;
|
||||
}
|
||||
|
||||
bool LocalDirectoryUpdater::hash_confirm(uint32_t client_param)
|
||||
{
|
||||
return mSharedDirectories->getEntryType(DirectoryStorage::EntryIndex(client_param)) == DIR_TYPE_FILE ;
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::setFileWatchPeriod(int seconds)
|
||||
{
|
||||
mDelayBetweenDirectoryUpdates = seconds ;
|
||||
}
|
||||
uint32_t LocalDirectoryUpdater::fileWatchPeriod() const
|
||||
{
|
||||
return mDelayBetweenDirectoryUpdates ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
74
libretroshare/src/file_sharing/directory_updater.h
Normal file
74
libretroshare/src/file_sharing/directory_updater.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* RetroShare C++ Directory parsing code.
|
||||
*
|
||||
* file_sharing/directory_updater.h
|
||||
*
|
||||
* Copyright 2016 by Mr.Alice
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// This class crawls the given directry hierarchy and updates it. It does so by calling the
|
||||
// shared file list source. This source may be of two types:
|
||||
// - local: directories are crawled n disk and files are hashed / requested from a cache
|
||||
// - remote: directories are requested remotely to a providing client
|
||||
//
|
||||
#include "file_sharing/hash_cache.h"
|
||||
#include "file_sharing/directory_storage.h"
|
||||
|
||||
class LocalDirectoryUpdater: public HashStorageClient, public RsTickingThread
|
||||
{
|
||||
public:
|
||||
LocalDirectoryUpdater(HashStorage *hash_cache,LocalDirectoryStorage *lds) ;
|
||||
virtual ~LocalDirectoryUpdater() {}
|
||||
|
||||
void forceUpdate();
|
||||
bool inDirectoryCheck() const ;
|
||||
|
||||
void setHashSalt(const RsFileHash& hash) { mHashSalt = hash; }
|
||||
const RsFileHash& hashSalt() const { return mHashSalt; }
|
||||
|
||||
void setFileWatchPeriod(int seconds) ;
|
||||
uint32_t fileWatchPeriod() const ;
|
||||
|
||||
void setEnabled(bool b) ;
|
||||
bool isEnabled() const ;
|
||||
|
||||
protected:
|
||||
virtual void data_tick() ;
|
||||
|
||||
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
|
||||
virtual bool hash_confirm(uint32_t client_param) ;
|
||||
|
||||
void recursUpdateSharedDir(const std::string& cumulated_path,DirectoryStorage::EntryIndex indx);
|
||||
void sweepSharedDirectories();
|
||||
|
||||
private:
|
||||
HashStorage *mHashCache ;
|
||||
LocalDirectoryStorage *mSharedDirectories ;
|
||||
|
||||
RsFileHash mHashSalt ;
|
||||
|
||||
time_t mLastSweepTime;
|
||||
time_t mLastTSUpdateTime;
|
||||
|
||||
uint32_t mDelayBetweenDirectoryUpdates;
|
||||
bool mIsEnabled ;
|
||||
};
|
||||
|
45
libretroshare/src/file_sharing/file_sharing_defaults.h
Normal file
45
libretroshare/src/file_sharing/file_sharing_defaults.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* RetroShare C++ File sharing default variables
|
||||
*
|
||||
* file_sharing/file_sharing_defaults.h
|
||||
*
|
||||
* Copyright 2016 by Mr.Alice
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 600 ; // 10 minutes
|
||||
static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ = 120 ; // 2 minutes
|
||||
static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 20 ; // 20 sec. Buy we only update for real if something has changed.
|
||||
|
||||
static const std::string HASH_CACHE_DURATION_SS = "HASH_CACHE_DURATION" ; // key string to store hash remembering time
|
||||
static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files
|
||||
static const std::string WATCH_FILE_ENABLED_SS = "WATCH_FILES_ENABLED"; // key to store ON/OFF flags for file whatch
|
||||
static const std::string WATCH_HASH_SALT_SS = "WATCH_HASH_SALT"; // Salt that is used to hash directory names
|
||||
|
||||
static const std::string FILE_SHARING_DIR_NAME = "file_sharing" ; // hard-coded directory name to store friend file lists, hash cache, etc.
|
||||
static const std::string HASH_CACHE_FILE_NAME = "hash_cache.bin" ; // hard-coded directory name to store encrypted hash cache.
|
||||
|
||||
static const uint32_t MIN_INTERVAL_BETWEEN_HASH_CACHE_SAVE = 20 ; // never save hash cache more often than every 20 secs.
|
||||
static const uint32_t MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE = 23 ; // never save remote directories more often than this
|
||||
|
||||
static const uint32_t MAX_DIR_SYNC_RESPONSE_DATA_SIZE = 20000 ; // Maximum RsItem data size in bytes for serialised directory transmission
|
||||
static const uint32_t DEFAULT_HASH_STORAGE_DURATION_DAYS = 30 ; // remember deleted/inaccessible files for 30 days
|
234
libretroshare/src/file_sharing/filelist_io.cc
Normal file
234
libretroshare/src/file_sharing/filelist_io.cc
Normal file
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* RetroShare File lists IO methods.
|
||||
*
|
||||
* file_sharing/filelist_io.h
|
||||
*
|
||||
* Copyright 2016 Mr.Alice
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
#include "retroshare/rsids.h"
|
||||
#include "pqi/authssl.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "filelist_io.h"
|
||||
|
||||
template<> bool FileListIO::serialise(unsigned char *buff,uint32_t size,uint32_t& offset,const uint32_t & val) { return setRawUInt32(buff,size,&offset,val) ; }
|
||||
template<> bool FileListIO::serialise(unsigned char *buff,uint32_t size,uint32_t& offset,const uint64_t & val) { return setRawUInt64(buff,size,&offset,val) ; }
|
||||
template<> bool FileListIO::serialise(unsigned char *buff,uint32_t size,uint32_t& offset,const std::string & val) { return setRawString(buff,size,&offset,val) ; }
|
||||
template<> bool FileListIO::serialise(unsigned char *buff,uint32_t size,uint32_t& offset,const Sha1CheckSum & val) { return val.serialise(buff,size,offset) ; }
|
||||
|
||||
template<> bool FileListIO::deserialise(const unsigned char *buff,uint32_t size,uint32_t& offset,uint32_t & val) { return getRawUInt32(const_cast<uint8_t*>(buff),size,&offset,&val) ; }
|
||||
template<> bool FileListIO::deserialise(const unsigned char *buff,uint32_t size,uint32_t& offset,uint64_t & val) { return getRawUInt64(const_cast<uint8_t*>(buff),size,&offset,&val) ; }
|
||||
template<> bool FileListIO::deserialise(const unsigned char *buff,uint32_t size,uint32_t& offset,std::string & val) { return getRawString(const_cast<uint8_t*>(buff),size,&offset,val) ; }
|
||||
template<> bool FileListIO::deserialise(const unsigned char *buff,uint32_t size,uint32_t& offset,Sha1CheckSum & val) { return val.deserialise(const_cast<uint8_t*>(buff),size,offset) ; }
|
||||
|
||||
template<> uint32_t FileListIO::serial_size(const uint32_t & ) { return 4 ; }
|
||||
template<> uint32_t FileListIO::serial_size(const uint64_t & ) { return 8 ; }
|
||||
template<> uint32_t FileListIO::serial_size(const std::string & val) { return getRawStringSize(val) ; }
|
||||
template<> uint32_t FileListIO::serial_size(const Sha1CheckSum & ) { return Sha1CheckSum::serial_size(); }
|
||||
|
||||
bool FileListIO::writeField( unsigned char*&buff,uint32_t& buff_size,uint32_t& offset,uint8_t section_tag,const unsigned char * val,uint32_t size)
|
||||
{
|
||||
if(!checkSectionSize(buff,buff_size,offset,size))
|
||||
return false;
|
||||
|
||||
if(!writeSectionHeader(buff,buff_size,offset,section_tag,size))
|
||||
return false;
|
||||
|
||||
memcpy(&buff[offset],val,size) ;
|
||||
offset += size ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileListIO::readField (const unsigned char *buff,uint32_t buff_size,uint32_t& offset,uint8_t check_section_tag, unsigned char *& val,uint32_t& size)
|
||||
{
|
||||
if(!readSectionHeader(buff,buff_size,offset,check_section_tag,size))
|
||||
return false;
|
||||
|
||||
val = (unsigned char *)rs_malloc(size) ;
|
||||
|
||||
if(!val)
|
||||
return false;
|
||||
|
||||
memcpy(val,&buff[offset],size);
|
||||
offset += size ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool FileListIO::write125Size(unsigned char *data,uint32_t data_size,uint32_t& offset,uint32_t S)
|
||||
{
|
||||
if(S < 192)
|
||||
{
|
||||
if(offset+1 > data_size)
|
||||
return false;
|
||||
|
||||
data[offset++] = (uint8_t)S ;
|
||||
return true;
|
||||
}
|
||||
else if(S < 8384)
|
||||
{
|
||||
if(offset+2 > data_size)
|
||||
return false;
|
||||
|
||||
data[offset+1] = (S - 192) & 0xff ;
|
||||
data[offset ] = ((S - 192 - data[offset+1]) >> 8) + 192;
|
||||
|
||||
offset += 2 ;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(offset+5 > data_size)
|
||||
return false;
|
||||
|
||||
data[offset++] = 0xff ;
|
||||
data[offset++] = (uint8_t)((S >> 24) & 255) ;
|
||||
data[offset++] = (uint8_t)((S >> 16) & 255) ;
|
||||
data[offset++] = (uint8_t)((S >> 8) & 255) ;
|
||||
data[offset++] = (uint8_t)((S ) & 255) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
bool FileListIO::read125Size(const unsigned char *data,uint32_t data_size,uint32_t& offset,uint32_t& S)
|
||||
{
|
||||
if(offset + 1 >= data_size) return false;
|
||||
|
||||
uint8_t b1 = data[offset++] ;
|
||||
|
||||
if(b1 < 192)
|
||||
{
|
||||
S = b1;
|
||||
return true ;
|
||||
}
|
||||
if(offset + 1 >= data_size) return false;
|
||||
|
||||
uint8_t b2 = data[offset++] ;
|
||||
|
||||
if(b1 < 224)
|
||||
{
|
||||
S = ((b1-192) << 8) + b2 + 192 ;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(b1 != 0xff)
|
||||
return false;
|
||||
|
||||
if(offset + 3 >= data_size) return false;
|
||||
|
||||
uint8_t b3 = data[offset++];
|
||||
uint8_t b4 = data[offset++];
|
||||
uint8_t b5 = data[offset++];
|
||||
|
||||
S = (b2 << 24) | (b3 << 16) | (b4 << 8) | b5 ;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileListIO::saveEncryptedDataToFile(const std::string& fname,const unsigned char *data,uint32_t total_size)
|
||||
{
|
||||
void *encryptedData = NULL ;
|
||||
int encDataLen = 0 ;
|
||||
|
||||
if(!AuthSSL::getAuthSSL()->encrypt( encryptedData, encDataLen, data,total_size, AuthSSL::getAuthSSL()->OwnId()))
|
||||
{
|
||||
std::cerr << "Cannot encrypt encrypted file. Something's wrong." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
FILE *F = fopen( (fname+".tmp").c_str(),"wb" ) ;
|
||||
|
||||
if(!F)
|
||||
{
|
||||
std::cerr << "Cannot open encrypted file for writing: " << fname+".tmp" << std::endl;
|
||||
|
||||
free(encryptedData);
|
||||
return false;
|
||||
}
|
||||
if(fwrite(encryptedData,1,encDataLen,F) != (uint32_t)encDataLen)
|
||||
{
|
||||
std::cerr << "Could not write entire encrypted file. Out of disc space??" << std::endl;
|
||||
fclose(F) ;
|
||||
|
||||
free(encryptedData);
|
||||
return false;
|
||||
}
|
||||
|
||||
fclose(F) ;
|
||||
|
||||
RsDirUtil::renameFile(fname+".tmp",fname) ;
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "done." << std::endl ;
|
||||
#endif
|
||||
|
||||
free(encryptedData);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileListIO::loadEncryptedDataFromFile(const std::string& fname,unsigned char *& data,uint32_t& total_size)
|
||||
{
|
||||
uint64_t file_size ;
|
||||
|
||||
if(!RsDirUtil::checkFile( fname,file_size,false ) )
|
||||
{
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "Encrypted file " << fname << " not available." << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the binary stream into memory.
|
||||
//
|
||||
RsTemporaryMemory buffer(file_size) ;
|
||||
|
||||
if(buffer == NULL)
|
||||
return false;
|
||||
|
||||
FILE *F = fopen( fname.c_str(),"rb") ;
|
||||
if (!F)
|
||||
{
|
||||
std::cerr << "Cannot open encrypted file, filename " << fname << std::endl;
|
||||
return false;
|
||||
}
|
||||
if(fread(buffer,1,file_size,F) != file_size)
|
||||
{
|
||||
std::cerr << "Cannot read from file " + fname << ": something's wrong." << std::endl;
|
||||
fclose(F) ;
|
||||
return false;
|
||||
}
|
||||
fclose(F) ;
|
||||
|
||||
// now decrypt
|
||||
void *decrypted_data =NULL;
|
||||
int decrypted_data_size =0;
|
||||
|
||||
if(!AuthSSL::getAuthSSL()->decrypt(decrypted_data, decrypted_data_size, buffer, file_size))
|
||||
{
|
||||
std::cerr << "Cannot decrypt encrypted file. Something's wrong." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
data = (unsigned char*)decrypted_data ;
|
||||
total_size = decrypted_data_size ;
|
||||
|
||||
return true;
|
||||
}
|
145
libretroshare/src/file_sharing/filelist_io.h
Normal file
145
libretroshare/src/file_sharing/filelist_io.h
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* RetroShare C++ File lists IO methods.
|
||||
*
|
||||
* file_sharing/filelist_io.h
|
||||
*
|
||||
* Copyright 2016 by Mr.Alice
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util/rsmemory.h"
|
||||
|
||||
// This file implements load/save of various fields used for file lists and directory content.
|
||||
// WARNING: the encoding is system-dependent, so this should *not* be used to exchange data between computers.
|
||||
|
||||
static const uint32_t FILE_LIST_IO_LOCAL_DIRECTORY_STORAGE_VERSION_0001 = 0x00000001 ;
|
||||
|
||||
static const uint8_t FILE_LIST_IO_TAG_UNKNOWN = 0x00 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_LOCAL_DIRECTORY_VERSION = 0x01 ;
|
||||
|
||||
static const uint8_t FILE_LIST_IO_TAG_HASH_STORAGE_ENTRY = 0x10 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_LOCAL_FILE_ENTRY = 0x11 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_LOCAL_DIR_ENTRY = 0x12 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_REMOTE_FILE_ENTRY = 0x13 ;
|
||||
|
||||
static const uint8_t FILE_LIST_IO_TAG_FILE_SHA1_HASH = 0x20 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_FILE_NAME = 0x21 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_FILE_SIZE = 0x22 ;
|
||||
|
||||
static const uint8_t FILE_LIST_IO_TAG_MODIF_TS = 0x30 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_RECURS_MODIF_TS = 0x31 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_UPDATE_TS = 0x32 ;
|
||||
|
||||
static const uint8_t FILE_LIST_IO_TAG_ENTRY_INDEX = 0x40 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_PARENT_INDEX = 0x41 ;
|
||||
|
||||
static const uint8_t FILE_LIST_IO_TAG_DIR_HASH = 0x50 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_DIR_NAME = 0x51 ;
|
||||
|
||||
static const uint8_t FILE_LIST_IO_TAG_ROW = 0x60 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_BINARY_DATA = 0x61 ;
|
||||
static const uint8_t FILE_LIST_IO_TAG_RAW_NUMBER = 0x62 ;
|
||||
|
||||
static const uint32_t SECTION_HEADER_MAX_SIZE = 6 ; // section tag (1 byte) + size (max = 5 bytes)
|
||||
|
||||
class FileListIO
|
||||
{
|
||||
public:
|
||||
template<typename T>
|
||||
static bool writeField(unsigned char *& buff,uint32_t& buff_size,uint32_t& offset,uint8_t section_tag,const T& val)
|
||||
{
|
||||
uint32_t s = serial_size(val) ;
|
||||
|
||||
if(!checkSectionSize(buff,buff_size,offset,s))
|
||||
return false;
|
||||
|
||||
if(!writeSectionHeader(buff,buff_size,offset,section_tag,s))
|
||||
return false;
|
||||
|
||||
return serialise(buff,buff_size,offset,val) ;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static bool readField(const unsigned char *buff,uint32_t buff_size,uint32_t& offset,uint8_t check_section_tag,T& val)
|
||||
{
|
||||
uint32_t section_size ;
|
||||
|
||||
if(!readSectionHeader(buff,buff_size,offset,check_section_tag,section_size))
|
||||
return false;
|
||||
|
||||
return deserialise(buff,buff_size,offset,val);
|
||||
}
|
||||
|
||||
static bool writeField( unsigned char*&buff,uint32_t& buff_size,uint32_t& offset,uint8_t section_tag,const unsigned char * val,uint32_t size) ;
|
||||
static bool readField (const unsigned char *buff,uint32_t buff_size,uint32_t& offset,uint8_t check_section_tag, unsigned char *& val,uint32_t& size) ;
|
||||
|
||||
template<class T> static bool serialise(unsigned char *buff,uint32_t size,uint32_t& offset,const T& val) ;
|
||||
template<class T> static bool deserialise(const unsigned char *buff,uint32_t size,uint32_t& offset,T& val) ;
|
||||
template<class T> static uint32_t serial_size(const T& val) ;
|
||||
|
||||
static bool saveEncryptedDataToFile(const std::string& fname,const unsigned char *data,uint32_t total_size);
|
||||
static bool loadEncryptedDataFromFile(const std::string& fname,unsigned char *& data,uint32_t& total_size);
|
||||
|
||||
private:
|
||||
static bool write125Size(unsigned char *data,uint32_t total_size,uint32_t& offset,uint32_t size) ;
|
||||
static bool read125Size (const unsigned char *data,uint32_t total_size,uint32_t& offset,uint32_t& size) ;
|
||||
|
||||
static bool checkSectionSize(unsigned char *& buff,uint32_t& buff_size,uint32_t offset,uint32_t S)
|
||||
{
|
||||
if(offset + S + SECTION_HEADER_MAX_SIZE > buff_size)
|
||||
{
|
||||
buff = (unsigned char *)realloc(buff,offset + S + SECTION_HEADER_MAX_SIZE) ;
|
||||
buff_size = offset + S + SECTION_HEADER_MAX_SIZE;
|
||||
|
||||
if(!buff)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
static bool writeSectionHeader(unsigned char *& buff,uint32_t& buff_size,uint32_t& offset,uint8_t section_tag,uint32_t S)
|
||||
{
|
||||
buff[offset++] = section_tag ;
|
||||
if(!write125Size(buff,buff_size,offset,S)) return false ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool readSectionHeader(const unsigned char *& buff,uint32_t buff_size,uint32_t& offset,uint8_t check_section_tag,uint32_t& S)
|
||||
{
|
||||
if(offset + 1 > buff_size)
|
||||
return false ;
|
||||
|
||||
uint8_t section_tag = buff[offset] ; // we do the offset++ after, only if the header can be read. Doing so, we can make multiple read attempts.
|
||||
|
||||
if(section_tag != check_section_tag)
|
||||
return false;
|
||||
|
||||
offset++ ;
|
||||
|
||||
return read125Size(buff,buff_size,offset,S) ;
|
||||
}
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user