Merge pull request #1432 from RetroShare/v0.6.5

V0.6.5
This commit is contained in:
csoler 2018-12-16 14:35:30 +01:00 committed by GitHub
commit fd1e7074c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
465 changed files with 10220 additions and 8812 deletions

View File

@ -3,7 +3,7 @@
* * * *
* BitDHT: An Flexible DHT library. * * BitDHT: An Flexible DHT library. *
* * * *
* Copyright (C) 2010 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2010 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* BitDHT: An Flexible DHT library. * * BitDHT: An Flexible DHT library. *
* * * *
* Copyright (C) 2010 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2010 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* LibResAPI: API for local socket server * * LibResAPI: API for local socket server *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * * it under the terms of the GNU Affero General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2016 by Mr.Alice <retroshare.team@gmail.com> * * Copyright 2016 by Mr.Alice <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -1402,19 +1402,19 @@ bool ftController::FileClearCompleted()
std::cerr << "ftController::FileClearCompleted()" <<std::endl; std::cerr << "ftController::FileClearCompleted()" <<std::endl;
#endif #endif
{ {
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ RS_STACK_MUTEX(ctrlMutex);
for(std::map<RsFileHash, ftFileControl*>::iterator it(mCompleted.begin());it!=mCompleted.end();++it) for(auto it(mCompleted.begin()); it != mCompleted.end(); ++it)
delete it->second; delete it->second;
mCompleted.clear(); mCompleted.clear();
IndicateConfigChanged(); IndicateConfigChanged();
} /******* UNLOCKED ********/ }
RsServer::notify()->notifyDownloadCompleteCount(0); RsServer::notify()->notifyDownloadCompleteCount(0);
return false; return true;
} }
/* get Details of File Transfers */ /* get Details of File Transfers */

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2008 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2008 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -1827,7 +1827,7 @@ int ftServer::handleIncoming()
********************************** **********************************
*********************************/ *********************************/
void ftServer::receiveSearchResult(RsTurtleFTSearchResultItem *item) void ftServer::ftReceiveSearchResult(RsTurtleFTSearchResultItem *item)
{ {
bool hasCallback = false; bool hasCallback = false;

View File

@ -98,7 +98,7 @@ public:
uint16_t serviceId() const { return RS_SERVICE_TYPE_FILE_TRANSFER ; } uint16_t serviceId() const { return RS_SERVICE_TYPE_FILE_TRANSFER ; }
virtual bool handleTunnelRequest(const RsFileHash& hash,const RsPeerId& peer_id) ; virtual bool handleTunnelRequest(const RsFileHash& hash,const RsPeerId& peer_id) ;
virtual void receiveTurtleData(const RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ; virtual void receiveTurtleData(const RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
virtual void receiveSearchResult(RsTurtleFTSearchResultItem *item); virtual void ftReceiveSearchResult(RsTurtleFTSearchResultItem *item); // We dont use TurtleClientService::receiveSearchResult() because of backward compatibility.
virtual RsItem *create_item(uint16_t service,uint8_t item_type) const ; virtual RsItem *create_item(uint16_t service,uint8_t item_type) const ;
virtual RsServiceSerializer *serializer() { return this ; } virtual RsServiceSerializer *serializer() { return this ; }

View File

@ -36,20 +36,17 @@ bool GxsTokenQueue::queueRequest(uint32_t token, uint32_t req_type)
void GxsTokenQueue::checkRequests() void GxsTokenQueue::checkRequests()
{ {
{ {
RsStackMutex stack(mQueueMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mQueueMtx);
if (mQueue.empty()) if (mQueue.empty()) return;
{
return;
}
} }
// Must check all, and move to a different list - for reentrant / good mutex behaviour. // Must check all, and move to a different list - for reentrant / good mutex behaviour.
std::list<GxsTokenQueueItem> toload; std::list<GxsTokenQueueItem> toload;
std::list<GxsTokenQueueItem>::iterator it; std::list<GxsTokenQueueItem>::iterator it;
bool stuffToLoad = false; bool stuffToLoad = false;
{ {
RsStackMutex stack(mQueueMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mQueueMtx);
for(it = mQueue.begin(); it != mQueue.end();) for(it = mQueue.begin(); it != mQueue.end();)
{ {
uint32_t token = it->mToken; uint32_t token = it->mToken;
@ -62,29 +59,29 @@ void GxsTokenQueue::checkRequests()
stuffToLoad = true; stuffToLoad = true;
#ifdef GXS_DEBUG #ifdef GXS_DEBUG
std::cerr << "GxsTokenQueue::checkRequests() token: " << token << " Complete"; std::cerr << "GxsTokenQueue::checkRequests() token: " << token
std::cerr << std::endl; << " Complete" << std::endl;
#endif #endif
++it; ++it;
} }
else if (status == RsTokenService::FAILED) else if (status == RsTokenService::FAILED)
{ {
// maybe we should do alternative callback? // maybe we should do alternative callback?
std::cerr << "GxsTokenQueue::checkRequests() ERROR Request Failed: " << token; std::cerr << __PRETTY_FUNCTION__ << " ERROR Request Failed! "
std::cerr << std::endl; << " token: " << token << std::endl;
it = mQueue.erase(it); it = mQueue.erase(it);
} }
else else
{ {
#ifdef GXS_DEBUG #ifdef GXS_DEBUG
std::cerr << "GxsTokenQueue::checkRequests() token: " << token << " is unfinished, status: " << status; std::cerr << "GxsTokenQueue::checkRequests() token: " << token
std::cerr << std::endl; << " is unfinished, status: " << status << std::endl;
#endif #endif
++it; ++it;
} }
} }
} } // RS_STACK_MUTEX(mQueueMtx) END
if (stuffToLoad) if (stuffToLoad)
{ {
@ -95,11 +92,3 @@ void GxsTokenQueue::checkRequests()
} }
} }
// This must be overloaded to complete the functionality.
void GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type)
{
std::cerr << "GxsTokenQueue::handleResponse(" << token << "," << req_type << ") ERROR: NOT HANDLED";
std::cerr << std::endl;
}

View File

@ -54,7 +54,7 @@ public:
protected: protected:
/// This must be overloaded to complete the functionality. /// This must be overloaded to complete the functionality.
virtual void handleResponse(uint32_t token, uint32_t req_type); virtual void handleResponse(uint32_t token, uint32_t req_type) = 0;
private: private:
RsGenExchange *mGenExchange; RsGenExchange *mGenExchange;

View File

@ -1198,16 +1198,16 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
} }
} }
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool /* cache */, bool withMeta) int RsDataService::retrieveNxsMsgs(
const GxsMsgReq &reqIds, GxsMsgResult &msg, bool /* cache */,
bool withMeta )
{ {
#ifdef RS_DATA_SERVICE_DEBUG_TIME #ifdef RS_DATA_SERVICE_DEBUG_TIME
rstime::RsScopeTimer timer(""); rstime::RsScopeTimer timer("");
int resultCount = 0; int resultCount = 0;
#endif #endif
GxsMsgReq::const_iterator mit = reqIds.begin(); for(auto mit = reqIds.begin(); mit != reqIds.end(); ++mit)
for(; mit != reqIds.end(); ++mit)
{ {
const RsGxsGroupId& grpId = mit->first; const RsGxsGroupId& grpId = mit->first;
@ -1216,9 +1216,9 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
const std::set<RsGxsMessageId>& msgIdV = mit->second; const std::set<RsGxsMessageId>& msgIdV = mit->second;
std::vector<RsNxsMsg*> msgSet; std::vector<RsNxsMsg*> msgSet;
if(msgIdV.empty()){ if(msgIdV.empty())
{
RsStackMutex stack(mDbMutex); RS_STACK_MUTEX(mDbMutex);
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", ""); RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
@ -1228,16 +1228,17 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
} }
delete c; delete c;
}else{ }
else
{
RS_STACK_MUTEX(mDbMutex);
// request each grp // request each grp
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin(); for( std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
sit!=msgIdV.end();++sit )
for(; sit!=msgIdV.end();++sit){ {
const RsGxsMessageId& msgId = *sit; const RsGxsMessageId& msgId = *sit;
RsStackMutex stack(mDbMutex);
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString()
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", ""); + "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");

View File

@ -47,10 +47,14 @@ public:
* Retrieves all msgs * Retrieves all msgs
* @param reqIds requested msg ids (grpId,msgId), leave msg list empty to get all msgs for the grp * @param reqIds requested msg ids (grpId,msgId), leave msg list empty to get all msgs for the grp
* @param msg result of msg retrieval * @param msg result of msg retrieval
* @param cache whether to store results of this retrieval in memory for faster later retrieval * @param cache IGNORED whether to store results of this retrieval in memory
* for faster later retrieval
* @param strictFilter if true do not request any message if reqIds is empty
* @return error code * @return error code
*/ */
int retrieveNxsMsgs(const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache, bool withMeta = false); int retrieveNxsMsgs(
const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache,
bool withMeta = false );
/*! /*!
* Retrieves groups, if empty, retrieves all grps, if map is not empty * Retrieves groups, if empty, retrieves all grps, if map is not empty

View File

@ -137,16 +137,19 @@ public:
typedef std::map<RsNxsMsg*, RsGxsMsgMetaData*> MsgStoreMap; typedef std::map<RsNxsMsg*, RsGxsMsgMetaData*> MsgStoreMap;
RsGeneralDataService(){} RsGeneralDataService(){}
virtual ~RsGeneralDataService(){return;} virtual ~RsGeneralDataService(){}
/*! /*!
* Retrieves all msgs * Retrieves all msgs
* @param reqIds requested msg ids (grpId,msgId), leave msg list empty to get all msgs for the grp * @param reqIds requested msg ids (grpId,msgId), leave msg list empty to get all msgs for the grp
* @param msg result of msg retrieval * @param msg result of msg retrieval
* @param cache whether to store results of this retrieval in memory for faster later retrieval * @param cache whether to store results of this retrieval in memory for faster later retrieval
* @param strictFilter if true do not request any message if reqIds is empty
* @return error code * @return error code
*/ */
virtual int retrieveNxsMsgs(const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache, bool withMeta=false) = 0; virtual int retrieveNxsMsgs(
const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache,
bool withMeta = false ) = 0;
/*! /*!
* Retrieves all groups stored * Retrieves all groups stored

View File

@ -3429,3 +3429,9 @@ void RsGenExchange::turtleSearchRequest(const std::string& match_string)
{ {
mNetService->turtleSearchRequest(match_string) ; mNetService->turtleSearchRequest(match_string) ;
} }
bool RsGenExchange::localSearch( const std::string& matchString,
std::list<RsGxsGroupSummary>& results )
{
return mNetService->search(matchString, results);
}

View File

@ -313,6 +313,15 @@ public:
void turtleGroupRequest(const RsGxsGroupId& group_id); void turtleGroupRequest(const RsGxsGroupId& group_id);
void turtleSearchRequest(const std::string& match_string); void turtleSearchRequest(const std::string& match_string);
/**
* @brief Search local groups. Blocking API.
* @param matchString string to look for in the search
* @param results storage for results
* @return false on error, true otherwise
*/
bool localSearch( const std::string& matchString,
std::list<RsGxsGroupSummary>& results );
protected: protected:
bool messagePublicationTest(const RsGxsMsgMetaData&) ; bool messagePublicationTest(const RsGxsMsgMetaData&) ;

View File

@ -39,12 +39,14 @@ RsGxsDataAccess::~RsGxsDataAccess()
for(std::map<uint32_t, GxsRequest*>::const_iterator it(mRequests.begin());it!=mRequests.end();++it) for(std::map<uint32_t, GxsRequest*>::const_iterator it(mRequests.begin());it!=mRequests.end();++it)
delete it->second ; delete it->second ;
} }
bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, bool RsGxsDataAccess::requestGroupInfo(
uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts,
const std::list<RsGxsGroupId> &groupIds ) const std::list<RsGxsGroupId> &groupIds )
{ {
if(groupIds.empty()) if(groupIds.empty())
{ {
std::cerr << "(WW) Group Id list is empty" << std::endl; std::cerr << __PRETTY_FUNCTION__ << " (WW) Group Id list is empty!"
<< std::endl;
return false; return false;
} }
@ -76,19 +78,19 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
req = gir; req = gir;
} }
if(req == NULL) if(!req)
{ {
std::cerr << "RsGxsDataAccess::requestGroupInfo() request type not recognised, type " std::cerr << __PRETTY_FUNCTION__ << " request type not recognised, "
<< reqType << std::endl; << "reqType: " << reqType << std::endl;
return false; return false;
}else }
{
generateToken(token); generateToken(token);
#ifdef DATA_DEBUG #ifdef DATA_DEBUG
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl; std::cerr << "RsGxsDataAccess::requestGroupInfo() gets token: " << token
<< std::endl;
#endif #endif
}
setReq(req, token, ansType, opts); setReq(req, token, ansType, opts);
storeRequest(req); storeRequest(req);
@ -130,11 +132,8 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
void RsGxsDataAccess::generateToken(uint32_t &token) void RsGxsDataAccess::generateToken(uint32_t &token)
{ {
RsStackMutex stack(mDataMutex); /****** LOCKED *****/ RS_STACK_MUTEX(mDataMutex);
token = mNextToken++; token = mNextToken++;
return;
} }
@ -303,13 +302,10 @@ void RsGxsDataAccess::setReq(GxsRequest* req, uint32_t token, uint32_t ansType,
} }
void RsGxsDataAccess::storeRequest(GxsRequest* req) void RsGxsDataAccess::storeRequest(GxsRequest* req)
{ {
RsStackMutex stack(mDataMutex); /****** LOCKED *****/ RS_STACK_MUTEX(mDataMutex);
req->status = PENDING; req->status = PENDING;
req->reqTime = time(NULL); req->reqTime = time(NULL);
mRequests[req->token] = req; mRequests[req->token] = req;
return;
} }
RsTokenService::GxsRequestStatus RsGxsDataAccess::requestStatus(uint32_t token) RsTokenService::GxsRequestStatus RsGxsDataAccess::requestStatus(uint32_t token)
@ -1040,11 +1036,16 @@ bool RsGxsDataAccess::getMsgData(MsgDataReq* req)
{ {
GxsMsgReq msgIdOut; GxsMsgReq msgIdOut;
const RsTokReqOptions& opts(req->Options);
// filter based on options // filter based on options
getMsgList(req->mMsgIds, req->Options, msgIdOut); getMsgList(req->mMsgIds, opts, msgIdOut);
// If the list is empty because of filtering do not retrieve from DB
if((opts.mMsgFlagMask || opts.mStatusMask) && msgIdOut.empty())
return true;
mDataStore->retrieveNxsMsgs(msgIdOut, req->mMsgData, true, true); mDataStore->retrieveNxsMsgs(msgIdOut, req->mMsgData, true, true);
return true; return true;
} }
@ -1053,8 +1054,14 @@ bool RsGxsDataAccess::getMsgSummary(MsgMetaReq* req)
{ {
GxsMsgReq msgIdOut; GxsMsgReq msgIdOut;
const RsTokReqOptions& opts(req->Options);
// filter based on options // filter based on options
getMsgList(req->mMsgIds, req->Options, msgIdOut); getMsgList(req->mMsgIds, opts, msgIdOut);
// If the list is empty because of filtering do not retrieve from DB
if((opts.mMsgFlagMask || opts.mStatusMask) && msgIdOut.empty())
return true;
mDataStore->retrieveGxsMsgMetaData(msgIdOut, req->mMsgMetaData); mDataStore->retrieveGxsMsgMetaData(msgIdOut, req->mMsgMetaData);
@ -1062,7 +1069,9 @@ bool RsGxsDataAccess::getMsgSummary(MsgMetaReq* req)
} }
bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgReq& msgIdsOut) bool RsGxsDataAccess::getMsgList(
const GxsMsgReq& msgIds, const RsTokReqOptions& opts,
GxsMsgReq& msgIdsOut )
{ {
GxsMsgMetaResult result; GxsMsgMetaResult result;
@ -1693,41 +1702,48 @@ void RsGxsDataAccess::cleanseMsgMetaMap(GxsMsgMetaResult& result)
return; return;
} }
void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, void RsGxsDataAccess::filterMsgList(
GxsMsgIdResult& resultsMap, const RsTokReqOptions& opts,
const MsgMetaFilter& msgMetas ) const const MsgMetaFilter& msgMetas ) const
{ {
for( GxsMsgIdResult::iterator grpIt = resultsMap.begin();
GxsMsgIdResult::iterator mit = msgIds.begin(); grpIt != resultsMap.end(); ++grpIt )
for(;mit != msgIds.end(); ++mit)
{ {
const RsGxsGroupId& groupId(grpIt->first);
std::set<RsGxsMessageId>& msgsIdSet(grpIt->second);
MsgMetaFilter::const_iterator cit = msgMetas.find(mit->first); MsgMetaFilter::const_iterator cit = msgMetas.find(groupId);
if(cit == msgMetas.end()) continue;
#ifdef DATA_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " " << msgsIdSet.size()
<< " for group: " << groupId << " before filtering"
<< std::endl;
#endif
if(cit == msgMetas.end()) for( std::set<RsGxsMessageId>::iterator msgIdIt = msgsIdSet.begin();
continue; msgIdIt != msgsIdSet.end(); )
std::set<RsGxsMessageId>& msgs = mit->second;
std::set<RsGxsMessageId>::iterator vit = msgs.begin();
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>& meta = cit->second;
std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator cit2;
for(; vit != msgs.end();)
{ {
const RsGxsMessageId& msgId(*msgIdIt);
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>& msgsMetaMap =
cit->second;
bool keep = false; bool keep = false;
if( (cit2 = meta.find(*vit)) != meta.end() ) std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator msgsMetaMapIt;
if( (msgsMetaMapIt = msgsMetaMap.find(msgId)) != msgsMetaMap.end() )
{ {
keep = checkMsgFilter(opts, cit2->second); keep = checkMsgFilter(opts, msgsMetaMapIt->second);
} }
if(keep) if(keep) ++msgIdIt;
{ else msgIdIt = msgsIdSet.erase(msgIdIt);
++vit;
}else
{
vit = msgs.erase(vit);
}
} }
#ifdef DATA_DEBUG
std::cerr << __PRETTY_FUNCTION__ << " " << msgsIdSet.size()
<< " for group: " << groupId << " after filtering"
<< std::endl;
#endif
} }
} }
@ -1905,62 +1921,87 @@ bool RsGxsDataAccess::checkGrpFilter(const RsTokReqOptions &opts, const RsGxsGrp
return subscribeMatch; return subscribeMatch;
} }
bool RsGxsDataAccess::checkMsgFilter(const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta) const bool RsGxsDataAccess::checkMsgFilter(
const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta ) const
{ {
bool statusMatch = false;
if (opts.mStatusMask) if (opts.mStatusMask)
{ {
// Exact Flags match required. // Exact Flags match required.
if ((opts.mStatusMask & opts.mStatusFilter) == (opts.mStatusMask & meta->mMsgStatus)) if ( (opts.mStatusMask & opts.mStatusFilter) ==
(opts.mStatusMask & meta->mMsgStatus) )
{ {
std::cerr << "checkMsgFilter() Accepting Msg as StatusMatches: "; #ifdef DATA_DEBUG
std::cerr << " Mask: " << opts.mStatusMask << " StatusFilter: " << opts.mStatusFilter; std::cerr << __PRETTY_FUNCTION__
std::cerr << " MsgStatus: " << meta->mMsgStatus << " MsgId: " << meta->mMsgId; << " Continue checking Msg as StatusMatches: "
std::cerr << std::endl; << " Mask: " << opts.mStatusMask
<< " StatusFilter: " << opts.mStatusFilter
statusMatch = true; << " MsgStatus: " << meta->mMsgStatus
<< " MsgId: " << meta->mMsgId << std::endl;
#endif
} }
else else
{ {
std::cerr << "checkMsgFilter() Dropping Msg due to !StatusMatch "; #ifdef DATA_DEBUG
std::cerr << " Mask: " << opts.mStatusMask << " StatusFilter: " << opts.mStatusFilter; std::cerr << __PRETTY_FUNCTION__
std::cerr << " MsgStatus: " << meta->mMsgStatus << " MsgId: " << meta->mMsgId; << " Dropping Msg due to !StatusMatch "
std::cerr << std::endl; << " Mask: " << opts.mStatusMask
<< " StatusFilter: " << opts.mStatusFilter
<< " MsgStatus: " << meta->mMsgStatus
<< " MsgId: " << meta->mMsgId << std::endl;
#endif
return false;
} }
} }
else else
{ {
// no status comparision, #ifdef DATA_DEBUG
statusMatch = true; std::cerr << __PRETTY_FUNCTION__
<< " Status check not requested"
<< " mStatusMask: " << opts.mStatusMask
<< " MsgId: " << meta->mMsgId << std::endl;
#endif
} }
bool flagMatch = false;
if(opts.mMsgFlagMask) if(opts.mMsgFlagMask)
{ {
// Exact Flags match required. // Exact Flags match required.
if ((opts.mMsgFlagMask & opts.mMsgFlagFilter) == (opts.mMsgFlagMask & meta->mMsgFlags)) if ( (opts.mMsgFlagMask & opts.mMsgFlagFilter) ==
(opts.mMsgFlagMask & meta->mMsgFlags) )
{ {
std::cerr << "checkMsgFilter() Accepting Msg as FlagMatches: "; #ifdef DATA_DEBUG
std::cerr << " Mask: " << opts.mMsgFlagMask << " FlagFilter: " << opts.mMsgFlagFilter; std::cerr << __PRETTY_FUNCTION__
std::cerr << " MsgFlag: " << meta->mMsgFlags << " MsgId: " << meta->mMsgId; << " Accepting Msg as FlagMatches: "
std::cerr << std::endl; << " Mask: " << opts.mMsgFlagMask
<< " FlagFilter: " << opts.mMsgFlagFilter
flagMatch = true; << " MsgFlag: " << meta->mMsgFlags
<< " MsgId: " << meta->mMsgId << std::endl;
#endif
} }
else else
{ {
std::cerr << "checkMsgFilter() Dropping Msg due to !FlagMatch "; #ifdef DATA_DEBUG
std::cerr << " Mask: " << opts.mMsgFlagMask << " FlagFilter: " << opts.mMsgFlagFilter; std::cerr << __PRETTY_FUNCTION__
std::cerr << " MsgFlag: " << meta->mMsgFlags << " MsgId: " << meta->mMsgId; << " Dropping Msg due to !FlagMatch "
std::cerr << std::endl; << " Mask: " << opts.mMsgFlagMask
<< " FlagFilter: " << opts.mMsgFlagFilter
<< " MsgFlag: " << meta->mMsgFlags
<< " MsgId: " << meta->mMsgId << std::endl;
#endif
flagMatch = false; return false;
} }
}else{ }
flagMatch = true; else
{
#ifdef DATA_DEBUG
std::cerr << __PRETTY_FUNCTION__
<< " Flags check not requested"
<< " mMsgFlagMask: " << opts.mMsgFlagMask
<< " MsgId: " << meta->mMsgId << std::endl;
#endif
} }
return statusMatch && flagMatch; return true;
} }

View File

@ -5291,6 +5291,7 @@ void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req,const unsig
GXSNETDEBUG___ << " passing the grp data to observer." << std::endl; GXSNETDEBUG___ << " passing the grp data to observer." << std::endl;
#endif #endif
mObserver->receiveNewGroups(new_grps); mObserver->receiveNewGroups(new_grps);
mObserver->receiveDistantSearchResults(req, grpId);
} }
bool RsGxsNetService::search( const std::string& substring, bool RsGxsNetService::search( const std::string& substring,

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2018 by Cyril Soler <retroshare.team@gmail.com> * * Copyright 2018 by Cyril Soler <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2018 by Cyril Soler <retroshare.team@gmail.com> * * Copyright 2018 by Cyril Soler <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2011-2011 by Robert Fernie <retroshare.team@gmail.com> * * Copyright 2011-2011 by Robert Fernie <retroshare.project@gmail.com> *
* Copyright 2011-2011 by Christopher Evi-Parker * * Copyright 2011-2011 by Christopher Evi-Parker *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *

View File

@ -49,7 +49,7 @@ JsonApiServer::corsHeaders =
{ {
{ "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, OPTIONS"}, { "Access-Control-Allow-Methods", "GET, POST, OPTIONS"},
{ "Access-Control-Allow-Headers", "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" }, { "Access-Control-Allow-Headers", "Authorization,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" },
{ "Access-Control-Expose-Headers", "Content-Length,Content-Range" } { "Access-Control-Expose-Headers", "Content-Length,Content-Range" }
}; };
@ -58,7 +58,7 @@ JsonApiServer::corsOptionsHeaders =
{ {
{ "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, OPTIONS"}, { "Access-Control-Allow-Methods", "GET, POST, OPTIONS"},
{ "Access-Control-Allow-Headers", "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" }, { "Access-Control-Allow-Headers", "Authorization,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" },
{ "Access-Control-Max-Age", "1728000" }, // 20 days { "Access-Control-Max-Age", "1728000" }, // 20 days
{ "Content-Type", "text/plain; charset=utf-8" }, { "Content-Type", "text/plain; charset=utf-8" },
{ "Content-Length", "0" } { "Content-Length", "0" }
@ -322,6 +322,12 @@ void JsonApiServer::registerHandler(
const std::shared_ptr<rb::Session> session, const std::shared_ptr<rb::Session> session,
const std::function<void (const std::shared_ptr<rb::Session>)>& callback ) const std::function<void (const std::shared_ptr<rb::Session>)>& callback )
{ {
if(session->get_request()->get_method() == "OPTIONS")
{
callback(session);
return;
}
if(!rsLoginHelper->isLoggedIn()) if(!rsLoginHelper->isLoggedIn())
{ {
session->close(rb::CONFLICT); session->close(rb::CONFLICT);

View File

@ -769,7 +769,8 @@ HEADERS += serialiser/rsserializable.h \
serialiser/rstypeserializer.h \ serialiser/rstypeserializer.h \
util/rsjson.h util/rsjson.h
SOURCES += serialiser/rsserializer.cc \ SOURCES += serialiser/rsserializable.cc \
serialiser/rsserializer.cc \
serialiser/rstypeserializer.cc \ serialiser/rstypeserializer.cc \
util/rsjson.cc util/rsjson.cc

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2018 Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2018 Retroshare Team <retroshare.team@gmail.com> * * Copyright 2018 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -318,7 +318,7 @@ public:
/** /**
* @brief Get free disk space limit * @brief Get free disk space limit
* @jsonapi{development} * @jsonapi{development}
* @return current current minimum free space on disk in MB * @return current minimum free space on disk in MB
*/ */
virtual uint32_t freeDiskSpaceLimit() const = 0; virtual uint32_t freeDiskSpaceLimit() const = 0;
@ -330,7 +330,14 @@ public:
virtual void setFreeDiskSpaceLimit(uint32_t minimumFreeMB) = 0; virtual void setFreeDiskSpaceLimit(uint32_t minimumFreeMB) = 0;
virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0; virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0;
/**
* @brief Clear completed downloaded files list
* @jsonapi{development}
* @return false on error, true otherwise
*/
virtual bool FileClearCompleted() = 0; virtual bool FileClearCompleted() = 0;
virtual void setDefaultEncryptionPolicy(uint32_t policy)=0; // RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT/PERMISSIVE virtual void setDefaultEncryptionPolicy(uint32_t policy)=0; // RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT/PERMISSIVE
virtual uint32_t defaultEncryptionPolicy()=0; virtual uint32_t defaultEncryptionPolicy()=0;
virtual void setMaxUploadSlotsPerFriend(uint32_t n)=0; virtual void setMaxUploadSlotsPerFriend(uint32_t n)=0;

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2013 by Cyril Soler <retroshare.team@gmail.com> * * Copyright 2013 by Cyril Soler <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -1,4 +1,3 @@
#pragma once
/******************************************************************************* /*******************************************************************************
* libretroshare/src/retroshare: rsgxschannels.h * * libretroshare/src/retroshare: rsgxschannels.h *
* * * *
@ -21,8 +20,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#pragma once
#include <inttypes.h> #include <cstdint>
#include <string> #include <string>
#include <list> #include <list>
#include <functional> #include <functional>
@ -32,6 +32,7 @@
#include "retroshare/rsgxscommon.h" #include "retroshare/rsgxscommon.h"
#include "serialiser/rsserializable.h" #include "serialiser/rsserializable.h"
#include "retroshare/rsturtle.h" #include "retroshare/rsturtle.h"
#include "util/rsdeprecate.h"
class RsGxsChannels; class RsGxsChannels;
@ -61,9 +62,6 @@ struct RsGxsChannelGroup : RsSerializable
} }
}; };
std::ostream &operator<<(std::ostream& out, const RsGxsChannelGroup& group);
struct RsGxsChannelPost : RsSerializable struct RsGxsChannelPost : RsSerializable
{ {
RsGxsChannelPost() : mCount(0), mSize(0) {} RsGxsChannelPost() : mCount(0), mSize(0) {}
@ -94,16 +92,90 @@ struct RsGxsChannelPost : RsSerializable
} }
}; };
std::ostream &operator<<(std::ostream& out, const RsGxsChannelPost& post);
class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
{ {
public: public:
explicit RsGxsChannels(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} explicit RsGxsChannels(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {}
virtual ~RsGxsChannels() {} virtual ~RsGxsChannels() {}
/**
* @brief Create channel. Blocking API.
* @jsonapi{development}
* @param[inout] channel Channel data (name, description...)
* @return false on error, true otherwise
*/
virtual bool createChannel(RsGxsChannelGroup& channel) = 0;
/**
* @brief Add a comment on a post or on another comment
* @jsonapi{development}
* @param[inout] comment
* @return false on error, true otherwise
*/
virtual bool createComment(RsGxsComment& comment) = 0;
/**
* @brief Create channel post. Blocking API.
* @jsonapi{development}
* @param[inout] post
* @return false on error, true otherwise
*/
virtual bool createPost(RsGxsChannelPost& post) = 0;
/**
* @brief createVote
* @jsonapi{development}
* @param[inout] vote
* @return false on error, true otherwise
*/
virtual bool createVote(RsGxsVote& vote) = 0;
/**
* @brief Edit channel details.
* @jsonapi{development}
* @param[in] channel Channel data (name, description...) with modifications
* @return false on error, true otherwise
*/
virtual bool editChannel(RsGxsChannelGroup& channel) = 0;
/**
* @brief Share extra file
* Can be used to share extra file attached to a channel post
* @jsonapi{development}
* @param[in] path file path
* @return false on error, true otherwise
*/
virtual bool ExtraFileHash(const std::string& path) = 0;
/**
* @brief Remove extra file from shared files
* @jsonapi{development}
* @param[in] hash hash of the file to remove
* @return false on error, true otherwise
*/
virtual bool ExtraFileRemove(const RsFileHash& hash) = 0;
/**
* @brief Get auto-download option value for given channel
* @jsonapi{development}
* @param[in] channelId channel id
* @param[out] enabled storage for the auto-download option value
* @return false if something failed, true otherwhise
*/
virtual bool getChannelAutoDownload(
const RsGxsGroupId& channelId, bool& enabled ) = 0;
/**
* @brief Get download directory for the given channel
* @jsonapi{development}
* @param[in] channelId id of the channel
* @param[out] directory reference to string where to store the path
* @return false on error, true otherwise
*/
virtual bool getChannelDownloadDirectory( const RsGxsGroupId& channelId,
std::string& directory ) = 0;
/** /**
* @brief Get channels summaries list. Blocking API. * @brief Get channels summaries list. Blocking API.
* @jsonapi{development} * @jsonapi{development}
@ -125,76 +197,61 @@ public:
std::vector<RsGxsChannelGroup>& channelsInfo ) = 0; std::vector<RsGxsChannelGroup>& channelsInfo ) = 0;
/** /**
* @brief Get content of specified channels. Blocking API * @brief Get channel contents
* @jsonapi{development} * @jsonapi{development}
* @param[in] chanIds id of the channels of which the content is requested * @param[in] channelId id of the channel of which the content is requested
* @param[out] posts storage for the posts * @param[in] contentsIds ids of requested contents
* @param[out] posts storage for posts
* @param[out] comments storage for the comments * @param[out] comments storage for the comments
* @return false if something failed, true otherwhise * @return false if something failed, true otherwhise
*/ */
virtual bool getChannelsContent( virtual bool getChannelContent( const RsGxsGroupId& channelId,
const std::list<RsGxsGroupId>& chanIds, const std::set<RsGxsMessageId>& contentsIds,
std::vector<RsGxsChannelPost>& posts, std::vector<RsGxsChannelPost>& posts,
std::vector<RsGxsComment>& comments ) = 0; std::vector<RsGxsComment>& comments ) = 0;
/** /**
* @brief Create channel. Blocking API. * @brief Get channel content summaries
* @jsonapi{development} * @jsonapi{development}
* @param[inout] channel Channel data (name, description...) * @param[in] channelId id of the channel of which the content is requested
* @param[out] summaries storage for summaries
* @return false if something failed, true otherwhise
*/
virtual bool getContentSummaries( const RsGxsGroupId& channelId,
std::vector<RsMsgMetaData>& summaries ) = 0;
/**
* @brief Toggle post read status. Blocking API.
* @jsonapi{development}
* @param[in] postId post identifier
* @param[in] read true to mark as read, false to mark as unread
* @return false on error, true otherwise * @return false on error, true otherwise
*/ */
virtual bool createChannel(RsGxsChannelGroup& channel) = 0; virtual bool markRead(const RsGxsGrpMsgIdPair& postId, bool read) = 0;
/** /**
* @brief Create channel post. Blocking API. * @brief Enable or disable auto-download for given channel. Blocking API
* @jsonapi{development} * @jsonapi{development}
* @param[inout] post * @param[in] channelId channel id
* @return false on error, true otherwise
*/
virtual bool createPost(RsGxsChannelPost& post) = 0;
/* Specific Service Data
* TODO: change the orrible const uint32_t &token to uint32_t token
* TODO: create a new typedef for token so code is easier to read
*/
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
/**
* @brief toggle message read status
* @jsonapi{development}
* @param[out] token GXS token queue token
* @param[in] msgId
* @param[in] read
*/
virtual void setMessageReadStatus(
uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;
/**
* @brief Enable or disable auto-download for given channel
* @jsonapi{development}
* @param[in] groupId channel id
* @param[in] enable true to enable, false to disable * @param[in] enable true to enable, false to disable
* @return false if something failed, true otherwhise * @return false if something failed, true otherwhise
*/ */
virtual bool setChannelAutoDownload( virtual bool setChannelAutoDownload(
const RsGxsGroupId &groupId, bool enable) = 0; const RsGxsGroupId& channelId, bool enable ) = 0;
/** /**
* @brief Get auto-download option value for given channel * @brief Share channel publishing key
* This can be used to authorize other peers to post on the channel
* @jsonapi{development} * @jsonapi{development}
* @param[in] groupId channel id * @param[in] channelId id of the channel
* @param[in] enabled storage for the auto-download option value * @param[in] peers peers to share the key with
* @return false if something failed, true otherwhise * @return false on error, true otherwise
*/ */
virtual bool getChannelAutoDownload( virtual bool shareChannelKeys(
const RsGxsGroupId &groupId, bool& enabled) = 0; const RsGxsGroupId& channelId, const std::set<RsPeerId>& peers ) = 0;
/** /**
* @brief Set download directory for the given channel * @brief Set download directory for the given channel. Blocking API.
* @jsonapi{development} * @jsonapi{development}
* @param[in] channelId id of the channel * @param[in] channelId id of the channel
* @param[in] directory path * @param[in] directory path
@ -204,91 +261,15 @@ public:
const RsGxsGroupId& channelId, const std::string& directory) = 0; const RsGxsGroupId& channelId, const std::string& directory) = 0;
/** /**
* @brief Get download directory for the given channel * @brief Subscrbe to a channel. Blocking API
* @jsonapi{development} * @jsonapi{development}
* @param[in] channelId id of the channel * @param[in] channelId Channel id
* @param[out] directory reference to string where to store the path * @param[in] subscribe true to subscribe, false to unsubscribe
* @return false on error, true otherwise * @return false on error, true otherwise
*/ */
virtual bool getChannelDownloadDirectory( const RsGxsGroupId& channelId, virtual bool subscribeToChannel( const RsGxsGroupId& channelId,
std::string& directory ) = 0;
/**
* @brief Share channel publishing key
* This can be used to authorize other peers to post on the channel
* @jsonapi{development}
* @param[in] groupId Channel id
* @param[in] peers peers to which share the key
* @return false on error, true otherwise
*/
virtual bool groupShareKeys(
const RsGxsGroupId& groupId, const std::set<RsPeerId>& peers ) = 0;
/**
* @brief Request subscription to a group.
* The action is performed asyncronously, so it could fail in a subsequent
* phase even after returning true.
* @jsonapi{development}
* @param[out] token Storage for RsTokenService token to track request
* status.
* @param[in] groupId Channel id
* @param[in] subscribe
* @return false on error, true otherwise
*/
virtual bool subscribeToGroup( uint32_t& token, const RsGxsGroupId &groupId,
bool subscribe ) = 0; bool subscribe ) = 0;
/**
* @brief Request channel creation.
* The action is performed asyncronously, so it could fail in a subsequent
* phase even after returning true.
* @param[out] token Storage for RsTokenService token to track request
* status.
* @param[in] group Channel data (name, description...)
* @return false on error, true otherwise
*/
virtual bool createGroup(uint32_t& token, RsGxsChannelGroup& group) = 0;
/**
* @brief Request post creation.
* The action is performed asyncronously, so it could fail in a subsequent
* phase even after returning true.
* @param[out] token Storage for RsTokenService token to track request
* status.
* @param[in] post
* @return false on error, true otherwise
*/
virtual bool createPost(uint32_t& token, RsGxsChannelPost& post) = 0;
/**
* @brief Request channel change.
* The action is performed asyncronously, so it could fail in a subsequent
* phase even after returning true.
* @jsonapi{development}
* @param[out] token Storage for RsTokenService token to track request
* status.
* @param[in] group Channel data (name, description...) with modifications
* @return false on error, true otherwise
*/
virtual bool updateGroup(uint32_t& token, RsGxsChannelGroup& group) = 0;
/**
* @brief Share extra file
* Can be used to share extra file attached to a channel post
* @jsonapi{development}
* @param[in] path file path
* @return false on error, true otherwise
*/
virtual bool ExtraFileHash(const std::string& path) = 0;
/**
* @brief Remove extra file from shared files
* @jsonapi{development}
* @param[in] hash hash of the file to remove
* @return false on error, true otherwise
*/
virtual bool ExtraFileRemove(const RsFileHash& hash) = 0;
/** /**
* @brief Request remote channels search * @brief Request remote channels search
* @jsonapi{development} * @jsonapi{development}
@ -303,15 +284,136 @@ public:
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback, const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
rstime_t maxWait = 300 ) = 0; rstime_t maxWait = 300 ) = 0;
/**
* @brief Request remote channel
* @jsonapi{development}
* @param[in] channelId id of the channel to request to distants peers
* @param multiCallback function that will be called each time a result is
* received
* @param[in] maxWait maximum wait time in seconds for search results
* @return false on error, true otherwise
*/
virtual bool turtleChannelRequest(
const RsGxsGroupId& channelId,
const std::function<void (const RsGxsChannelGroup& result)>& multiCallback,
rstime_t maxWait = 300 ) = 0;
/**
* @brief Search local channels
* @jsonapi{development}
* @param[in] matchString string to look for in the search
* @param multiCallback function that will be called for each result
* @param[in] maxWait maximum wait time in seconds for search results
* @return false on error, true otherwise
*/
virtual bool localSearchRequest(
const std::string& matchString,
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
rstime_t maxWait = 30 ) = 0;
/* Following functions are deprecated as they expose internal functioning
* semantic, instead of a safe to use API */
RS_DEPRECATED_FOR(getChannelsInfo)
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups) = 0;
RS_DEPRECATED_FOR(getChannelsContent)
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
RS_DEPRECATED_FOR(getChannelsContent)
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
/**
* @brief toggle message read status
* @deprecated
* @param[out] token GXS token queue token
* @param[in] msgId
* @param[in] read
*/
RS_DEPRECATED_FOR(markRead)
virtual void setMessageReadStatus(
uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;
/**
* @brief Share channel publishing key
* This can be used to authorize other peers to post on the channel
* @deprecated
* @param[in] groupId Channel id
* @param[in] peers peers to which share the key
* @return false on error, true otherwise
*/
RS_DEPRECATED_FOR(shareChannelKeys)
virtual bool groupShareKeys(
const RsGxsGroupId& groupId, const std::set<RsPeerId>& peers ) = 0;
/**
* @brief Request subscription to a group.
* The action is performed asyncronously, so it could fail in a subsequent
* phase even after returning true.
* @deprecated
* @param[out] token Storage for RsTokenService token to track request
* status.
* @param[in] groupId Channel id
* @param[in] subscribe
* @return false on error, true otherwise
*/
RS_DEPRECATED_FOR(subscribeToChannel)
virtual bool subscribeToGroup( uint32_t& token, const RsGxsGroupId &groupId,
bool subscribe ) = 0;
/**
* @brief Request channel creation.
* The action is performed asyncronously, so it could fail in a subsequent
* phase even after returning true.
* @deprecated
* @param[out] token Storage for RsTokenService token to track request
* status.
* @param[in] group Channel data (name, description...)
* @return false on error, true otherwise
*/
RS_DEPRECATED_FOR(createChannel)
virtual bool createGroup(uint32_t& token, RsGxsChannelGroup& group) = 0;
/**
* @brief Request post creation.
* The action is performed asyncronously, so it could fail in a subsequent
* phase even after returning true.
* @deprecated
* @param[out] token Storage for RsTokenService token to track request
* status.
* @param[in] post
* @return false on error, true otherwise
*/
RS_DEPRECATED
virtual bool createPost(uint32_t& token, RsGxsChannelPost& post) = 0;
/**
* @brief Request channel change.
* The action is performed asyncronously, so it could fail in a subsequent
* phase even after returning true.
* @deprecated
* @param[out] token Storage for RsTokenService token to track request
* status.
* @param[in] group Channel data (name, description...) with modifications
* @return false on error, true otherwise
*/
RS_DEPRECATED_FOR(editChannel)
virtual bool updateGroup(uint32_t& token, RsGxsChannelGroup& group) = 0;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Distant synchronisation methods /// /// Distant synchronisation methods ///
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// ///
RS_DEPRECATED_FOR(turtleChannelRequest)
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0; virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0;
RS_DEPRECATED
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0; virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
RS_DEPRECATED_FOR(turtleSearchRequest)
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSummary> &results) =0; virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSummary> &results) =0;
RS_DEPRECATED
virtual bool clearDistantSearchResults(TurtleRequestId req)=0; virtual bool clearDistantSearchResults(TurtleRequestId req)=0;
RS_DEPRECATED_FOR(turtleChannelRequest)
virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0; virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
}; };

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2012-2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2012-2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,8 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2012-2012 by Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2012 by Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -19,88 +20,195 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef RETROSHARE_GXS_FORUM_GUI_INTERFACE_H #pragma once
#define RETROSHARE_GXS_FORUM_GUI_INTERFACE_H
#include <inttypes.h> #include <cstdint>
#include <string> #include <string>
#include <list> #include <list>
#include "retroshare/rstokenservice.h" #include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"
#include "serialiser/rstlvidset.h" #include "serialiser/rstlvidset.h"
#include "serialiser/rsserializable.h"
// Forum Service message flags, to be used in RsMsgMetaData::mMsgFlags
// Gxs imposes to use the first two bytes (lower bytes) of mMsgFlags for private forum flags, the upper bytes being used for internal GXS stuff.
/* The Main Interface Class - for information about your Peers */
class RsGxsForums;
/**
* Pointer to global instance of RsGxsChannels service implementation
* @jsonapi{development}
*/
extern RsGxsForums* rsGxsForums;
/** Forum Service message flags, to be used in RsMsgMetaData::mMsgFlags
* Gxs imposes to use the first two bytes (lower bytes) of mMsgFlags for
* private forum flags, the upper bytes being used for internal GXS stuff.
*/
static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MASK = 0x0000000f; static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MASK = 0x0000000f;
static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MODERATED = 0x00000001; static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MODERATED = 0x00000001;
#define IS_FORUM_MSG_MODERATION(flags) (flags & RS_GXS_FORUM_MSG_FLAGS_MODERATED) #define IS_FORUM_MSG_MODERATION(flags) (flags & RS_GXS_FORUM_MSG_FLAGS_MODERATED)
/* The Main Interface Class - for information about your Peers */
class RsGxsForums;
extern RsGxsForums *rsGxsForums;
class RsGxsForumGroup struct RsGxsForumGroup : RsSerializable
{ {
public: virtual ~RsGxsForumGroup() {}
RsGroupMetaData mMeta; RsGroupMetaData mMeta;
std::string mDescription; std::string mDescription;
// What's below is optional, and handled by the serialiser /* What's below is optional, and handled by the serialiser
* TODO: run away from TLV old serializables as those types are opaque to
* JSON API! */
RsTlvGxsIdSet mAdminList; RsTlvGxsIdSet mAdminList;
RsTlvGxsMsgIdSet mPinnedPosts; RsTlvGxsMsgIdSet mPinnedPosts;
/// @see RsSerializable
virtual void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_SERIAL_PROCESS(mMeta);
RS_SERIAL_PROCESS(mDescription);
RS_SERIAL_PROCESS(mAdminList);
RS_SERIAL_PROCESS(mPinnedPosts);
}
}; };
class RsGxsForumMsg struct RsGxsForumMsg : RsSerializable
{ {
public: virtual ~RsGxsForumMsg() {}
RsMsgMetaData mMeta; RsMsgMetaData mMeta;
std::string mMsg; std::string mMsg;
/// @see RsSerializable
virtual void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_SERIAL_PROCESS(mMeta);
RS_SERIAL_PROCESS(mMsg);
}
}; };
//typedef std::map<RsGxsGroupId, std::vector<RsGxsForumMsg> > GxsForumMsgResult;
std::ostream &operator<<(std::ostream &out, const RsGxsForumGroup &group);
std::ostream &operator<<(std::ostream &out, const RsGxsForumMsg &msg);
class RsGxsForums: public RsGxsIfaceHelper class RsGxsForums: public RsGxsIfaceHelper
{ {
public: public:
explicit RsGxsForums(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} explicit RsGxsForums(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {}
virtual ~RsGxsForums() {} virtual ~RsGxsForums() {}
/* Specific Service Data */ /**
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0; * @brief Create forum. Blocking API.
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0; * @jsonapi{development}
//Not currently used * @param[inout] forum Forum data (name, description...)
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0; * @return false on error, true otherwise
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;
//virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
//virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
//virtual bool groupRestoreKeys(const std::string &groupId);
//virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
/*!
* To update forum group with new information
* @param token the token used to check completion status of update
* @param group group to be updated, groupId element must be set or will be rejected
* @return false groupId not set, true if set and accepted (still check token for completion)
*/ */
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0; virtual bool createForum(RsGxsForumGroup& forum) = 0;
/**
* @brief Create forum message. Blocking API.
* @jsonapi{development}
* @param[inout] message
* @return false on error, true otherwise
*/
virtual bool createMessage(RsGxsForumMsg& message) = 0;
/**
* @brief Edit forum details.
* @jsonapi{development}
* @param[in] forum Forum data (name, description...) with modifications
* @return false on error, true otherwise
*/
virtual bool editForum(RsGxsForumGroup& forum) = 0;
/**
* @brief Get forums summaries list. Blocking API.
* @jsonapi{development}
* @param[out] forums list where to store the forums summaries
* @return false if something failed, true otherwhise
*/
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums) = 0;
/**
* @brief Get forums information (description, thumbnail...).
* Blocking API.
* @jsonapi{development}
* @param[in] forumIds ids of the forums of which to get the informations
* @param[out] forumsInfo storage for the forums informations
* @return false if something failed, true otherwhise
*/
virtual bool getForumsInfo(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo ) = 0;
/**
* @brief Get content of specified forums. Blocking API
* @jsonapi{development}
* @param[in] forumIds id of the forum of which the content is requested
* @param[out] messages storage for the forum messages
* @return false if something failed, true otherwhise
*/
virtual bool getForumsContent(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumMsg>& messages ) = 0;
/**
* @brief Get message metadatas for some messages of a specific forum. Blocking API
* @jsonapi{development}
* @param[in] forumIds id of the forum of which the content is requested
* @param[out] msg_metas storage for the forum messages meta data
* @return false if something failed, true otherwhise
*/
virtual bool getForumMsgMetaData( const RsGxsGroupId& forumId,
std::vector<RsMsgMetaData>& msg_metas) =0;
/**
* @brief Get specific list of messages from a single forums. Blocking API
* @jsonapi{development}
* @param[in] forumId id of the forum of which the content is requested
* @param[in] msgs_to_request list of message ids to request
* @param[out] msgs storage for the forum messages
* @return false if something failed, true otherwhise
*/
virtual bool getForumsContent(
const RsGxsGroupId& forumId,
std::set<RsGxsMessageId>& msgs_to_request,
std::vector<RsGxsForumMsg>& msgs) =0;
/**
* @brief Toggle message read status. Blocking API.
* @jsonapi{development}
* @param[in] messageId post identifier
* @param[in] read true to mark as read, false to mark as unread
* @return false on error, true otherwise
*/
virtual bool markRead(const RsGxsGrpMsgIdPair& messageId, bool read) = 0;
/**
* @brief Subscrbe to a forum. Blocking API
* @jsonapi{development}
* @param[in] forumId Forum id
* @param[in] subscribe true to subscribe, false to unsubscribe
* @return false on error, true otherwise
*/
virtual bool subscribeToForum( const RsGxsGroupId& forumId,
bool subscribe ) = 0;
/* Specific Service Data */
RS_DEPRECATED_FOR("getForumsSummaries, getForumsInfo")
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0;
RS_DEPRECATED_FOR(getForumsContent)
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
RS_DEPRECATED_FOR(markRead)
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;
RS_DEPRECATED_FOR(createForum)
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
RS_DEPRECATED_FOR(createMessage)
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
RS_DEPRECATED_FOR(editForum)
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
}; };
#endif

View File

@ -61,6 +61,8 @@ struct RsGroupMetaData : RsSerializable
mCircleType(0x0001), mAuthenFlags(0), mSubscribeFlags(0), mPop(0), mCircleType(0x0001), mAuthenFlags(0), mSubscribeFlags(0), mPop(0),
mVisibleMsgCount(0), mLastPost(0), mGroupStatus(0) {} mVisibleMsgCount(0), mLastPost(0), mGroupStatus(0) {}
virtual ~RsGroupMetaData() {}
void operator =(const RsGxsGrpMetaData& rGxsMeta); void operator =(const RsGxsGrpMetaData& rGxsMeta);
RsGxsGroupId mGroupId; RsGxsGroupId mGroupId;
@ -124,9 +126,9 @@ struct RsMsgMetaData : RsSerializable
{ {
RsMsgMetaData() : mPublishTs(0), mMsgFlags(0), mMsgStatus(0), mChildTs(0) {} RsMsgMetaData() : mPublishTs(0), mMsgFlags(0), mMsgStatus(0), mChildTs(0) {}
virtual ~RsMsgMetaData() {}
void operator =(const RsGxsMsgMetaData& rGxsMeta); void operator =(const RsGxsMsgMetaData& rGxsMeta);
RsGxsGroupId mGroupId; RsGxsGroupId mGroupId;
RsGxsMessageId mMsgId; RsGxsMessageId mMsgId;

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2015 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2015 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -288,6 +288,14 @@ struct RsLoginHelper
RsInit::LoadCertificateStatus attemptLogin( RsInit::LoadCertificateStatus attemptLogin(
const RsPeerId& account, const std::string& password ); const RsPeerId& account, const std::string& password );
/**
* @brief Feed extra entropy to the crypto libraries
* @jsonapi{development,unauthenticated}
* @param[in] bytes number to feed to the entropy pool
* @return false if error occurred, true otherwise
*/
static bool collectEntropy(uint32_t bytes);
struct Location : RsSerializable struct Location : RsSerializable
{ {
RsPeerId mLocationId; RsPeerId mLocationId;

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2012-2018 by Retroshare Team <retroshare.team@gmail.com> * * Copyright 2012-2018 by Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2015 by RetroShare Team <retroshare.team@gmail.com> * * Copyright 2015 by RetroShare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2015 by Robert Fernie <retroshare.team@gmail.com> * * Copyright 2015 by Robert Fernie <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -1934,6 +1934,9 @@ RsInit::LoadCertificateStatus RsLoginHelper::attemptLogin(
return RsInit::ERR_UNKOWN; return RsInit::ERR_UNKOWN;
} }
/*static*/ bool RsLoginHelper::collectEntropy(uint32_t bytes)
{ return RsInit::collectEntropy(bytes); }
void RsLoginHelper::getLocations(std::vector<RsLoginHelper::Location>& store) void RsLoginHelper::getLocations(std::vector<RsLoginHelper::Location>& store)
{ {
std::list<RsPeerId> locIds; std::list<RsPeerId> locIds;

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2018 retroshare team <retroshare.team@gmail.com> * * Copyright 2018 retroshare team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2004-2006 by Robert Fernie <retroshare.team@gmail.com> * * Copyright 2004-2006 by Robert Fernie <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -0,0 +1,31 @@
/*******************************************************************************
* libretroshare: retroshare core library *
* *
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#include "serialiser/rsserializable.h"
#include <iostream>
std::ostream& operator<<(std::ostream& out, const RsSerializable& serializable)
{
RsGenericSerializer::SerializeContext ctx;
const_cast<RsSerializable&>(serializable) // safe with TO_JSON
.serial_process(RsGenericSerializer::TO_JSON, ctx);
return out << ctx.mJson;
}

View File

@ -20,8 +20,11 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#pragma once #pragma once
#include "serialiser/rsserializer.h" #include "serialiser/rsserializer.h"
#include <iosfwd>
/** @brief Minimal ancestor for all serializable structs in RetroShare. /** @brief Minimal ancestor for all serializable structs in RetroShare.
* If you want your struct to be easly serializable you should inherit from this * If you want your struct to be easly serializable you should inherit from this
@ -49,3 +52,5 @@ struct RsSerializable
#define RS_SERIAL_PROCESS(I) do { \ #define RS_SERIAL_PROCESS(I) do { \
RsTypeSerializer::serial_process(j, ctx, I, #I ); \ RsTypeSerializer::serial_process(j, ctx, I, #I ); \
} while(0) } while(0)
std::ostream &operator<<(std::ostream& out, const RsSerializable& serializable);

View File

@ -28,13 +28,15 @@
#include "serialiser/rstlvbase.h" #include "serialiser/rstlvbase.h"
#include "serialiser/rstlvitem.h" #include "serialiser/rstlvitem.h"
#include "util/rsdeprecate.h"
#include <retroshare/rstypes.h> #include <retroshare/rstypes.h>
#include <retroshare/rsgxsifacetypes.h> #include <retroshare/rsgxsifacetypes.h>
#include <list> #include <list>
template<class ID_CLASS,uint32_t TLV_TYPE> class t_RsTlvIdSet: public RsTlvItem /// @deprecated use plain std::set<> instead
template<class ID_CLASS,uint32_t TLV_TYPE> class RS_DEPRECATED_FOR(std::set<>) t_RsTlvIdSet
: public RsTlvItem
{ {
public: public:
t_RsTlvIdSet() {} t_RsTlvIdSet() {}
@ -122,7 +124,7 @@ typedef t_RsTlvIdSet<RsGxsMessageId,TLV_TYPE_GXSMSGIDSET> RsTlvGxsMsgIdSet
typedef t_RsTlvIdSet<RsGxsCircleId, TLV_TYPE_GXSCIRCLEIDSET> RsTlvGxsCircleIdSet ; typedef t_RsTlvIdSet<RsGxsCircleId, TLV_TYPE_GXSCIRCLEIDSET> RsTlvGxsCircleIdSet ;
typedef t_RsTlvIdSet<RsNodeGroupId, TLV_TYPE_NODEGROUPIDSET> RsTlvNodeGroupIdSet ; typedef t_RsTlvIdSet<RsNodeGroupId, TLV_TYPE_NODEGROUPIDSET> RsTlvNodeGroupIdSet ;
class RsTlvServiceIdSet: public RsTlvItem class RS_DEPRECATED RsTlvServiceIdSet: public RsTlvItem
{ {
public: public:
RsTlvServiceIdSet() { return; } RsTlvServiceIdSet() { return; }

View File

@ -26,15 +26,18 @@
* *
******************************************************************/ ******************************************************************/
#include "util/rsdeprecate.h"
#include <iosfwd> #include <iosfwd>
#include <string> #include <string>
#include <inttypes.h> #include <inttypes.h>
//! A base class for all tlv items /*! A base class for all tlv items
/*! This class is provided to allow the serialisation and deserialization of compund * This class is provided to allow the serialisation and deserialization of
tlv items * compund tlv items
* @deprecated TLV serialization system is deprecated!
*/ */
class RsTlvItem class RS_DEPRECATED_FOR(RsSerializable) RsTlvItem
{ {
public: public:
RsTlvItem() { return; } RsTlvItem() { return; }
@ -51,8 +54,7 @@ std::ostream &printEnd(std::ostream &out, std::string clsName, uint16_t indent)
std::ostream &printIndent(std::ostream &out, uint16_t indent); std::ostream &printIndent(std::ostream &out, uint16_t indent);
class RS_DEPRECATED_FOR(RsSerializable) RsTlvUnit: public RsTlvItem
class RsTlvUnit: public RsTlvItem
{ {
public: public:
RsTlvUnit(uint16_t tlv_type); RsTlvUnit(uint16_t tlv_type);

View File

@ -36,6 +36,7 @@
#include "retroshare/rsnotify.h" #include "retroshare/rsnotify.h"
#include <cstdio> #include <cstdio>
#include <chrono>
// For Dummy Msgs. // For Dummy Msgs.
#include "util/rsrandom.h" #include "util/rsrandom.h"
@ -76,7 +77,10 @@ p3GxsChannels::p3GxsChannels(
RsGenExchange( gds, nes, new RsGxsChannelSerialiser(), RsGenExchange( gds, nes, new RsGxsChannelSerialiser(),
RS_SERVICE_GXS_TYPE_CHANNELS, gixs, channelsAuthenPolicy() ), RS_SERVICE_GXS_TYPE_CHANNELS, gixs, channelsAuthenPolicy() ),
RsGxsChannels(static_cast<RsGxsIface&>(*this)), GxsTokenQueue(this), RsGxsChannels(static_cast<RsGxsIface&>(*this)), GxsTokenQueue(this),
mSearchCallbacksMapMutex("GXS channels search") mSubscribedGroupsMutex("GXS channels subscribed groups cache"),
mKnownChannelsMutex("GXS channels known channels timestamp cache"),
mSearchCallbacksMapMutex("GXS channels search callbacks map"),
mDistantChannelsCallbacksMapMutex("GXS channels distant channels callbacks map")
{ {
// For Dummy Msgs. // For Dummy Msgs.
mGenActive = false; mGenActive = false;
@ -174,7 +178,10 @@ bool p3GxsChannels::saveList(bool &cleanup, std::list<RsItem *>&saveList)
RsGxsForumNotifyRecordsItem *item = new RsGxsForumNotifyRecordsItem ; RsGxsForumNotifyRecordsItem *item = new RsGxsForumNotifyRecordsItem ;
{
RS_STACK_MUTEX(mKnownChannelsMutex);
item->records = mKnownChannels; item->records = mKnownChannels;
}
saveList.push_back(item) ; saveList.push_back(item) ;
return true; return true;
@ -191,8 +198,9 @@ bool p3GxsChannels::loadList(std::list<RsItem *>& loadList)
RsGxsForumNotifyRecordsItem *fnr = dynamic_cast<RsGxsForumNotifyRecordsItem*>(item) ; RsGxsForumNotifyRecordsItem *fnr = dynamic_cast<RsGxsForumNotifyRecordsItem*>(item) ;
if(fnr != NULL) if(fnr)
{ {
RS_STACK_MUTEX(mKnownChannelsMutex);
mKnownChannels.clear(); mKnownChannels.clear();
for(auto it(fnr->records.begin());it!=fnr->records.end();++it) for(auto it(fnr->records.begin());it!=fnr->records.end();++it)
@ -228,7 +236,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl; std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
#endif #endif
p3Notify *notify = NULL; p3Notify* notify = nullptr;
if (!changes.empty()) if (!changes.empty())
{ {
notify = RsServer::notify(); notify = RsServer::notify();
@ -272,7 +280,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
bool enabled = false; bool enabled = false;
if (autoDownloadEnabled(mit->first, enabled) && enabled) if (autoDownloadEnabled(mit->first, enabled) && enabled)
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
@ -306,6 +313,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
/* group received */ /* group received */
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList; std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git; std::list<RsGxsGroupId>::iterator git;
RS_STACK_MUTEX(mKnownChannelsMutex);
for (git = grpList.begin(); git != grpList.end(); ++git) for (git = grpList.begin(); git != grpList.end(); ++git)
{ {
if(mKnownChannels.find(*git) == mKnownChannels.end()) if(mKnownChannels.find(*git) == mKnownChannels.end())
@ -338,6 +346,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
/* shouldn't need to worry about groups - as they need to be subscribed to */ /* shouldn't need to worry about groups - as they need to be subscribed to */
} }
if(!unprocessedGroups.empty())
request_SpecificSubscribedGroups(unprocessedGroups); request_SpecificSubscribedGroups(unprocessedGroups);
RsGxsIfaceHelper::receiveChanges(changes); RsGxsIfaceHelper::receiveChanges(changes);
@ -345,7 +354,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
void p3GxsChannels::service_tick() void p3GxsChannels::service_tick()
{ {
static rstime_t last_dummy_tick = 0; static rstime_t last_dummy_tick = 0;
if (time(NULL) > last_dummy_tick + 5) if (time(NULL) > last_dummy_tick + 5)
@ -414,18 +422,21 @@ bool p3GxsChannels::groupShareKeys(
* at the moment - fix it up later * at the moment - fix it up later
*/ */
bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs, std::vector<RsGxsComment> &cmts) bool p3GxsChannels::getPostData(
const uint32_t &token, std::vector<RsGxsChannelPost> &msgs,
std::vector<RsGxsComment> &cmts )
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::getPostData()"; std::cerr << __PRETTY_FUNCTION__ << std::cerr << std::endl;
std::cerr << std::endl;
#endif #endif
GxsMsgDataMap msgData; GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData); if(!RsGenExchange::getMsgData(token, msgData))
if(ok)
{ {
std::cerr << __PRETTY_FUNCTION__ <<" ERROR in request" << std::endl;
return false;
}
GxsMsgDataMap::iterator mit = msgData.begin(); GxsMsgDataMap::iterator mit = msgData.begin();
for(; mit != msgData.end(); ++mit) for(; mit != msgData.end(); ++mit)
@ -435,7 +446,8 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
for(; vit != msgItems.end(); ++vit) for(; vit != msgItems.end(); ++vit)
{ {
RsGxsChannelPostItem* postItem = dynamic_cast<RsGxsChannelPostItem*>(*vit); RsGxsChannelPostItem* postItem =
dynamic_cast<RsGxsChannelPostItem*>(*vit);
if(postItem) if(postItem)
{ {
@ -446,7 +458,8 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
} }
else else
{ {
RsGxsCommentItem* cmtItem = dynamic_cast<RsGxsCommentItem*>(*vit); RsGxsCommentItem* cmtItem =
dynamic_cast<RsGxsCommentItem*>(*vit);
if(cmtItem) if(cmtItem)
{ {
RsGxsComment cmt; RsGxsComment cmt;
@ -466,23 +479,27 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217; //const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
//const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03; //const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03;
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1; //const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1;
std::cerr << "Not a GxsChannelPostItem neither a RsGxsCommentItem" std::cerr << __PRETTY_FUNCTION__
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec << " Not a GxsChannelPostItem neither a "
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec << "RsGxsCommentItem PacketService=" << std::hex
<< (int)msg->PacketService() << std::dec
<< " PacketSubType=" << std::hex
<< (int)msg->PacketSubType() << std::dec
<< " , deleting!" << std::endl; << " , deleting!" << std::endl;
delete *vit; delete *vit;
} }
} }
} }
} }
}
else return true;
{
std::cerr << "p3GxsChannels::getPostData() ERROR in request";
std::cerr << std::endl;
} }
return ok; bool p3GxsChannels::getPostData(
const uint32_t& token, std::vector<RsGxsChannelPost>& posts )
{
std::vector<RsGxsComment> cmts;
return getPostData(token, posts, cmts);
} }
//Not currently used //Not currently used
@ -548,21 +565,6 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
/********************************************************************************************/ /********************************************************************************************/
/********************************************************************************************/ /********************************************************************************************/
#if 0
bool p3GxsChannels::setChannelAutoDownload(uint32_t &token, const RsGxsGroupId &groupId, bool autoDownload)
{
std::cerr << "p3GxsChannels::setChannelAutoDownload()";
std::cerr << std::endl;
// we don't actually use the token at this point....
//bool p3GxsChannels::setAutoDownload(const RsGxsGroupId &groupId, bool enabled)
return;
}
#endif
bool p3GxsChannels::setChannelAutoDownload(const RsGxsGroupId &groupId, bool enabled) bool p3GxsChannels::setChannelAutoDownload(const RsGxsGroupId &groupId, bool enabled)
{ {
return setAutoDownload(groupId, enabled); return setAutoDownload(groupId, enabled);
@ -574,20 +576,22 @@ bool p3GxsChannels::getChannelAutoDownload(const RsGxsGroupId &groupId, bool& en
return autoDownloadEnabled(groupId,enabled); return autoDownloadEnabled(groupId,enabled);
} }
bool p3GxsChannels::setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std::string& directory) bool p3GxsChannels::setChannelDownloadDirectory(
const RsGxsGroupId &groupId, const std::string& directory )
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::setDownloadDirectory() id: " << groupId << " to: " << directory << std::endl; std::cerr << __PRETTY_FUNCTION__ << " id: " << groupId << " to: "
<< directory << std::endl;
#endif #endif
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it; RS_STACK_MUTEX(mSubscribedGroupsMutex);
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
it = mSubscribedGroups.find(groupId); it = mSubscribedGroups.find(groupId);
if (it == mSubscribedGroups.end()) if (it == mSubscribedGroups.end())
{ {
#ifdef GXSCHANNELS_DEBUG std::cerr << __PRETTY_FUNCTION__ << " Error! Unknown groupId: "
std::cerr << "p3GxsChannels::setAutoDownload() Missing Group" << std::endl; << groupId.toStdString() << std::endl;
#endif
return false; return false;
} }
@ -597,13 +601,12 @@ bool p3GxsChannels::setChannelDownloadDirectory(const RsGxsGroupId &groupId, con
if (directory == ss.mDownloadDirectory) if (directory == ss.mDownloadDirectory)
{ {
#ifdef GXSCHANNELS_DEBUG std::cerr << __PRETTY_FUNCTION__ << " Warning! groupId: " << groupId
std::cerr << "p3GxsChannels::setDownloadDirectory() WARNING setting looks okay already" << std::endl; << " Was already configured to download into: " << directory
#endif << std::endl;
return false;
} }
/* we are just going to set it anyway. */
ss.mDownloadDirectory = directory; ss.mDownloadDirectory = directory;
std::string serviceString = ss.save(); std::string serviceString = ss.save();
uint32_t token; uint32_t token;
@ -611,6 +614,13 @@ bool p3GxsChannels::setChannelDownloadDirectory(const RsGxsGroupId &groupId, con
it->second.mServiceString = serviceString; // update Local Cache. it->second.mServiceString = serviceString; // update Local Cache.
RsGenExchange::setGroupServiceString(token, groupId, serviceString); // update dbase. RsGenExchange::setGroupServiceString(token, groupId, serviceString); // update dbase.
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Feiled setting group "
<< " service string" << std::endl;
return false;
}
/* now reload it */ /* now reload it */
std::list<RsGxsGroupId> groups; std::list<RsGxsGroupId> groups;
groups.push_back(groupId); groups.push_back(groupId);
@ -626,16 +636,15 @@ bool p3GxsChannels::getChannelDownloadDirectory(const RsGxsGroupId & groupId,std
std::cerr << "p3GxsChannels::getChannelDownloadDirectory(" << id << ")" << std::endl; std::cerr << "p3GxsChannels::getChannelDownloadDirectory(" << id << ")" << std::endl;
#endif #endif
RS_STACK_MUTEX(mSubscribedGroupsMutex);
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it; std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
it = mSubscribedGroups.find(groupId); it = mSubscribedGroups.find(groupId);
if (it == mSubscribedGroups.end()) if (it == mSubscribedGroups.end())
{ {
#ifdef GXSCHANNELS_DEBUG std::cerr << __PRETTY_FUNCTION__ << " Error! Unknown groupId: "
std::cerr << "p3GxsChannels::getChannelDownloadDirectory() No Entry" << std::endl; << groupId.toStdString() << std::endl;
#endif
return false; return false;
} }
@ -668,7 +677,8 @@ void p3GxsChannels::request_AllSubscribedGroups()
} }
void p3GxsChannels::request_SpecificSubscribedGroups(const std::list<RsGxsGroupId> &groups) void p3GxsChannels::request_SpecificSubscribedGroups(
const std::list<RsGxsGroupId> &groups )
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::request_SpecificSubscribedGroups()"; std::cerr << "p3GxsChannels::request_SpecificSubscribedGroups()";
@ -681,8 +691,19 @@ void p3GxsChannels::request_SpecificSubscribedGroups(const std::list<RsGxsGroupI
uint32_t token = 0; uint32_t token = 0;
RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts, groups); if(!RsGenExchange::getTokenService()->
GxsTokenQueue::queueRequest(token, GXSCHANNELS_SUBSCRIBED_META); requestGroupInfo(token, ansType, opts, groups))
{
std::cerr << __PRETTY_FUNCTION__ << " Failed requesting groups info!"
<< std::endl;
return;
}
if(!GxsTokenQueue::queueRequest(token, GXSCHANNELS_SUBSCRIBED_META))
{
std::cerr << __PRETTY_FUNCTION__ << " Failed queuing request!"
<< std::endl;
}
} }
@ -746,6 +767,7 @@ void p3GxsChannels::updateSubscribedGroup(const RsGroupMetaData &group)
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RS_STACK_MUTEX(mSubscribedGroupsMutex);
mSubscribedGroups[group.mGroupId] = group; mSubscribedGroups[group.mGroupId] = group;
} }
@ -757,9 +779,8 @@ void p3GxsChannels::clearUnsubscribedGroup(const RsGxsGroupId &id)
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
//std::map<RsGxsGroupId, RsGrpMetaData> mSubscribedGroups; RS_STACK_MUTEX(mSubscribedGroupsMutex);
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it; std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
it = mSubscribedGroups.find(id); it = mSubscribedGroups.find(id);
if (it != mSubscribedGroups.end()) if (it != mSubscribedGroups.end())
{ {
@ -838,24 +859,20 @@ void p3GxsChannels::request_GroupUnprocessedPosts(const std::list<RsGxsGroupId>
} }
void p3GxsChannels::load_SpecificUnprocessedPosts(const uint32_t &token) void p3GxsChannels::load_unprocessedPosts(uint32_t token)
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::load_SpecificUnprocessedPosts"; std::cerr << "p3GxsChannels::load_SpecificUnprocessedPosts" << std::endl;
std::cerr << std::endl;
#endif #endif
std::vector<RsGxsChannelPost> posts; std::vector<RsGxsChannelPost> posts;
if (!getPostData(token, posts)) if (!getPostData(token, posts))
{ {
#ifdef GXSCHANNELS_DEBUG std::cerr << __PRETTY_FUNCTION__ << " ERROR getting post data!"
std::cerr << "p3GxsChannels::load_SpecificUnprocessedPosts ERROR"; << std::endl;
std::cerr << std::endl;
#endif
return; return;
} }
std::vector<RsGxsChannelPost>::iterator it; std::vector<RsGxsChannelPost>::iterator it;
for(it = posts.begin(); it != posts.end(); ++it) for(it = posts.begin(); it != posts.end(); ++it)
{ {
@ -864,58 +881,27 @@ void p3GxsChannels::load_SpecificUnprocessedPosts(const uint32_t &token)
} }
} }
void p3GxsChannels::load_GroupUnprocessedPosts(const uint32_t &token)
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::load_GroupUnprocessedPosts";
std::cerr << std::endl;
#endif
std::vector<RsGxsChannelPost> posts;
if (!getPostData(token, posts))
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::load_GroupUnprocessedPosts ERROR";
std::cerr << std::endl;
#endif
return;
}
std::vector<RsGxsChannelPost>::iterator it;
for(it = posts.begin(); it != posts.end(); ++it)
{
handleUnprocessedPost(*it);
}
}
void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg) void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg)
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::handleUnprocessedPost() GroupId: " << msg.mMeta.mGroupId << " MsgId: " << msg.mMeta.mMsgId; std::cerr << __PRETTY_FUNCTION__ << " GroupId: " << msg.mMeta.mGroupId
std::cerr << std::endl; << " MsgId: " << msg.mMeta.mMsgId << std::endl;
#endif #endif
if (!IS_MSG_UNPROCESSED(msg.mMeta.mMsgStatus)) if (!IS_MSG_UNPROCESSED(msg.mMeta.mMsgStatus))
{ {
std::cerr << "p3GxsChannels::handleUnprocessedPost() Msg already Processed"; std::cerr << __PRETTY_FUNCTION__ << " ERROR Msg already Processed! "
std::cerr << std::endl; << "mMsgId: " << msg.mMeta.mMsgId << std::endl;
std::cerr << "p3GxsChannels::handleUnprocessedPost() ERROR - this should not happen";
std::cerr << std::endl;
return; return;
} }
bool enabled = false ;
/* check that autodownload is set */ /* check that autodownload is set */
bool enabled = false;
if (autoDownloadEnabled(msg.mMeta.mGroupId, enabled) && enabled) if (autoDownloadEnabled(msg.mMeta.mGroupId, enabled) && enabled)
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::handleUnprocessedPost() AutoDownload Enabled ... handling"; std::cerr << __PRETTY_FUNCTION__ << " AutoDownload Enabled... handling"
std::cerr << std::endl; << std::endl;
#endif #endif
/* check the date is not too old */ /* check the date is not too old */
@ -928,8 +914,7 @@ void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg)
// MORE THOUGHT HAS TO GO INTO THAT STUFF. // MORE THOUGHT HAS TO GO INTO THAT STUFF.
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::handleUnprocessedPost() START DOWNLOAD"; std::cerr << __PRETTY_FUNCTION__ << " START DOWNLOAD" << std::endl;
std::cerr << std::endl;
#endif #endif
std::list<RsGxsFile>::const_iterator fit; std::list<RsGxsFile>::const_iterator fit;
@ -952,7 +937,10 @@ void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg)
rsFiles->FileRequest(fname, hash, size, localpath, flags, srcIds); rsFiles->FileRequest(fname, hash, size, localpath, flags, srcIds);
} }
else else
std::cerr << "WARNING: Channel file is not auto-downloaded because its size exceeds the threshold of " << CHANNEL_MAX_AUTO_DL << " bytes." << std::endl; std::cerr << __PRETTY_FUNCTION__ << "Channel file is not auto-"
<< "downloaded because its size exceeds the threshold"
<< " of " << CHANNEL_MAX_AUTO_DL << " bytes."
<< std::endl;
} }
} }
@ -987,17 +975,16 @@ void p3GxsChannels::handleResponse(uint32_t token, uint32_t req_type)
break; break;
case GXSCHANNELS_UNPROCESSED_SPECIFIC: case GXSCHANNELS_UNPROCESSED_SPECIFIC:
load_SpecificUnprocessedPosts(token); load_unprocessedPosts(token);
break; break;
case GXSCHANNELS_UNPROCESSED_GENERIC: case GXSCHANNELS_UNPROCESSED_GENERIC:
load_SpecificUnprocessedPosts(token); load_unprocessedPosts(token);
break; break;
default: default:
/* error */ std::cerr << __PRETTY_FUNCTION__ << "ERROR Unknown Request Type: "
std::cerr << "p3GxsService::handleResponse() Unknown Request Type: " << req_type; << req_type << std::endl;
std::cerr << std::endl;
break; break;
} }
} }
@ -1029,28 +1016,69 @@ bool p3GxsChannels::getChannelsInfo(
return getGroupData(token, channelsInfo); return getGroupData(token, channelsInfo);
} }
bool p3GxsChannels::getChannelsContent( bool p3GxsChannels::getContentSummaries(
const std::list<RsGxsGroupId>& chanIds, const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
std::list<RsGxsGroupId> channelIds;
channelIds.push_back(channelId);
if( !requestMsgInfo(token, opts, channelIds) ||
waitToken(token, std::chrono::seconds(5)) != RsTokenService::COMPLETE )
return false;
GxsMsgMetaMap metaMap;
bool res = RsGenExchange::getMsgMeta(token, metaMap);
summaries = metaMap[channelId];
return res;
}
bool p3GxsChannels::getChannelContent( const RsGxsGroupId& channelId,
const std::set<RsGxsMessageId>& contentsIds,
std::vector<RsGxsChannelPost>& posts, std::vector<RsGxsChannelPost>& posts,
std::vector<RsGxsComment>& comments ) std::vector<RsGxsComment>& comments )
{ {
uint32_t token; uint32_t token;
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
if( !requestMsgInfo(token, opts, chanIds)
|| waitToken(token) != RsTokenService::COMPLETE ) return false; GxsMsgReq msgIds;
msgIds[channelId] = contentsIds;
if( !requestMsgInfo(token, opts, msgIds) ||
waitToken(token) != RsTokenService::COMPLETE ) return false;
return getPostData(token, posts, comments); return getPostData(token, posts, comments);
} }
bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel) bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel)
{ {
uint32_t token; uint32_t token;
if( !createGroup(token, channel) if(!createGroup(token, channel))
|| waitToken(token) != RsTokenService::COMPLETE )
return false;
if(RsGenExchange::getPublishedGroupMeta(token, channel.mMeta))
{ {
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating group."
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, channel.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated "
<< " group data." << std::endl;
return false;
}
#ifdef RS_DEEP_SEARCH #ifdef RS_DEEP_SEARCH
DeepSearch::indexChannelGroup(channel); DeepSearch::indexChannelGroup(channel);
#endif // RS_DEEP_SEARCH #endif // RS_DEEP_SEARCH
@ -1058,9 +1086,91 @@ bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel)
return true; return true;
} }
bool p3GxsChannels::createComment(RsGxsComment& comment)
{
uint32_t token;
if(!createComment(token, comment))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating comment."
<< std::endl;
return false; return false;
} }
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedMsgMeta(token, comment.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting generated "
<< " comment data." << std::endl;
return false;
}
return true;
}
bool p3GxsChannels::createVote(RsGxsVote& vote)
{
uint32_t token;
if(!createVote(token, vote))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating vote."
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedMsgMeta(token, vote.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting generated "
<< " vote data." << std::endl;
return false;
}
return true;
}
bool p3GxsChannels::editChannel(RsGxsChannelGroup& channel)
{
uint32_t token;
if(!updateGroup(token, channel))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed updating group."
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, channel.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated "
<< " group data." << std::endl;
return false;
}
#ifdef RS_DEEP_SEARCH
DeepSearch::indexChannelGroup(channel);
#endif // RS_DEEP_SEARCH
return true;
}
bool p3GxsChannels::createPost(RsGxsChannelPost& post) bool p3GxsChannels::createPost(RsGxsChannelPost& post)
{ {
uint32_t token; uint32_t token;
@ -1079,6 +1189,29 @@ bool p3GxsChannels::createPost(RsGxsChannelPost& post)
return false; return false;
} }
bool p3GxsChannels::subscribeToChannel(
const RsGxsGroupId& groupId, bool subscribe )
{
uint32_t token;
if( !subscribeToGroup(token, groupId, subscribe)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
return true;
}
bool p3GxsChannels::markRead(const RsGxsGrpMsgIdPair& msgId, bool read)
{
uint32_t token;
setMessageReadStatus(token, msgId, read);
if(waitToken(token) != RsTokenService::COMPLETE ) return false;
return true;
}
bool p3GxsChannels::shareChannelKeys(
const RsGxsGroupId& channelId, const std::set<RsPeerId>& peers)
{
return groupShareKeys(channelId, peers);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// Blocking API implementation end /// Blocking API implementation end
@ -1092,20 +1225,17 @@ bool p3GxsChannels::createPost(RsGxsChannelPost& post)
bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &groupId,bool& enabled) bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &groupId,bool& enabled)
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::autoDownloadEnabled(" << id << ")"; std::cerr << "p3GxsChannels::autoDownloadEnabled(" << groupId << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RS_STACK_MUTEX(mSubscribedGroupsMutex);
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it; std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
it = mSubscribedGroups.find(groupId); it = mSubscribedGroups.find(groupId);
if (it == mSubscribedGroups.end()) if (it == mSubscribedGroups.end())
{ {
#ifdef GXSCHANNELS_DEBUG std::cerr << __PRETTY_FUNCTION__ << " WARNING requested channel: "
std::cerr << "p3GxsChannels::autoDownloadEnabled() No Entry"; << groupId << " is not subscribed" << std::endl;
std::cerr << std::endl;
#endif
return false; return false;
} }
@ -1193,20 +1323,17 @@ std::string SSGxsChannelGroup::save() const
bool p3GxsChannels::setAutoDownload(const RsGxsGroupId& groupId, bool enabled) bool p3GxsChannels::setAutoDownload(const RsGxsGroupId& groupId, bool enabled)
{ {
#ifdef GXSCHANNELS_DEBUG #ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::setAutoDownload() id: " << groupId << " enabled: " << enabled; std::cerr << __PRETTY_FUNCTION__ << " id: " << groupId
std::cerr << std::endl; << " enabled: " << enabled << std::endl;
#endif #endif
RS_STACK_MUTEX(mSubscribedGroupsMutex);
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it; std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
it = mSubscribedGroups.find(groupId); it = mSubscribedGroups.find(groupId);
if (it == mSubscribedGroups.end()) if (it == mSubscribedGroups.end())
{ {
#ifdef GXSCHANNELS_DEBUG std::cerr << __PRETTY_FUNCTION__ << " ERROR requested channel: "
std::cerr << "p3GxsChannels::setAutoDownload() Missing Group"; << groupId.toStdString() << " is not subscribed!" << std::endl;
std::cerr << std::endl;
#endif
return false; return false;
} }
@ -1215,27 +1342,21 @@ bool p3GxsChannels::setAutoDownload(const RsGxsGroupId &groupId, bool enabled)
ss.load(it->second.mServiceString); ss.load(it->second.mServiceString);
if (enabled == ss.mAutoDownload) if (enabled == ss.mAutoDownload)
{ {
/* it should be okay! */ std::cerr << __PRETTY_FUNCTION__ << " WARNING mAutoDownload was already"
#ifdef GXSCHANNELS_DEBUG << " properly set to: " << enabled << " for channel:"
std::cerr << "p3GxsChannels::setAutoDownload() WARNING setting looks okay already"; << groupId.toStdString() << std::endl;
std::cerr << std::endl; return false;
#endif
} }
/* we are just going to set it anyway. */
ss.mAutoDownload = enabled; ss.mAutoDownload = enabled;
std::string serviceString = ss.save(); std::string serviceString = ss.save();
uint32_t token; uint32_t token;
RsGenExchange::setGroupServiceString(token, groupId, serviceString);
if(waitToken(token) != RsTokenService::COMPLETE) return false;
it->second.mServiceString = serviceString; // update Local Cache. it->second.mServiceString = serviceString; // update Local Cache.
RsGenExchange::setGroupServiceString(token, groupId, serviceString); // update dbase.
/* now reload it */
std::list<RsGxsGroupId> groups;
groups.push_back(groupId);
request_SpecificSubscribedGroups(groups);
return true; return true;
} }
@ -1604,7 +1725,7 @@ void p3GxsChannels::dummy_tick()
} }
cleanTimedOutSearches(); cleanTimedOutCallbacks();
} }
@ -1834,6 +1955,7 @@ bool p3GxsChannels::turtleSearchRequest(
TurtleRequestId sId = turtleSearchRequest(matchString); TurtleRequestId sId = turtleSearchRequest(matchString);
{
RS_STACK_MUTEX(mSearchCallbacksMapMutex); RS_STACK_MUTEX(mSearchCallbacksMapMutex);
mSearchCallbacksMap.emplace( mSearchCallbacksMap.emplace(
sId, sId,
@ -1841,6 +1963,60 @@ bool p3GxsChannels::turtleSearchRequest(
multiCallback, multiCallback,
std::chrono::system_clock::now() + std::chrono::system_clock::now() +
std::chrono::seconds(maxWait) ) ); std::chrono::seconds(maxWait) ) );
}
return true;
}
/// @see RsGxsChannels::turtleChannelRequest
bool p3GxsChannels::turtleChannelRequest(
const RsGxsGroupId& channelId,
const std::function<void (const RsGxsChannelGroup& result)>& multiCallback,
rstime_t maxWait)
{
if(channelId.isNull())
{
std::cerr << __PRETTY_FUNCTION__ << "Error! channelId can't be null!"
<< std::endl;
return false;
}
TurtleRequestId sId = turtleGroupRequest(channelId);
{
RS_STACK_MUTEX(mDistantChannelsCallbacksMapMutex);
mDistantChannelsCallbacksMap.emplace(
sId,
std::make_pair(
multiCallback,
std::chrono::system_clock::now() +
std::chrono::seconds(maxWait) ) );
}
return true;
}
/// @see RsGxsChannels::localSearchRequest
bool p3GxsChannels::localSearchRequest(
const std::string& matchString,
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
rstime_t maxWait )
{
if(matchString.empty())
{
std::cerr << __PRETTY_FUNCTION__ << " match string can't be empty!"
<< std::endl;
return false;
}
auto timeout = std::chrono::steady_clock::now() + std::chrono::seconds(maxWait);
RsThread::async([=]()
{
std::list<RsGxsGroupSummary> results;
RsGenExchange::localSearch(matchString, results);
if(std::chrono::steady_clock::now() < timeout)
for(const RsGxsGroupSummary& result : results) multiCallback(result);
});
return true; return true;
} }
@ -1851,6 +2027,7 @@ void p3GxsChannels::receiveDistantSearchResults(
std::cerr << __PRETTY_FUNCTION__ << "(" << id << ", " << grpId << ")" std::cerr << __PRETTY_FUNCTION__ << "(" << id << ", " << grpId << ")"
<< std::endl; << std::endl;
{
RsGenExchange::receiveDistantSearchResults(id, grpId); RsGenExchange::receiveDistantSearchResults(id, grpId);
RsGxsGroupSummary gs; RsGxsGroupSummary gs;
gs.mGroupId = grpId; gs.mGroupId = grpId;
@ -1860,14 +2037,48 @@ void p3GxsChannels::receiveDistantSearchResults(
RS_STACK_MUTEX(mSearchCallbacksMapMutex); RS_STACK_MUTEX(mSearchCallbacksMapMutex);
auto cbpt = mSearchCallbacksMap.find(id); auto cbpt = mSearchCallbacksMap.find(id);
if(cbpt != mSearchCallbacksMap.end()) if(cbpt != mSearchCallbacksMap.end())
{
cbpt->second.first(gs); cbpt->second.first(gs);
return;
}
} // end RS_STACK_MUTEX(mSearchCallbacksMapMutex); } // end RS_STACK_MUTEX(mSearchCallbacksMapMutex);
} }
void p3GxsChannels::cleanTimedOutSearches() {
RS_STACK_MUTEX(mDistantChannelsCallbacksMapMutex);
auto cbpt = mDistantChannelsCallbacksMap.find(id);
if(cbpt != mDistantChannelsCallbacksMap.end())
{
std::function<void (const RsGxsChannelGroup&)> callback =
cbpt->second.first;
RsThread::async([this, callback, grpId]()
{
std::list<RsGxsGroupId> chanIds({grpId});
std::vector<RsGxsChannelGroup> channelsInfo;
if(!getChannelsInfo(chanIds, channelsInfo))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Received "
<< "distant channel result grpId: " << grpId
<< " but failed getting channel info"
<< std::endl;
return;
}
for(const RsGxsChannelGroup& chan : channelsInfo)
callback(chan);
} );
return;
}
} // RS_STACK_MUTEX(mDistantChannelsCallbacksMapMutex);
}
void p3GxsChannels::cleanTimedOutCallbacks()
{
auto now = std::chrono::system_clock::now();
{ {
RS_STACK_MUTEX(mSearchCallbacksMapMutex); RS_STACK_MUTEX(mSearchCallbacksMapMutex);
auto now = std::chrono::system_clock::now();
for( auto cbpt = mSearchCallbacksMap.begin(); for( auto cbpt = mSearchCallbacksMap.begin();
cbpt != mSearchCallbacksMap.end(); ) cbpt != mSearchCallbacksMap.end(); )
if(cbpt->second.second <= now) if(cbpt->second.second <= now)
@ -1876,4 +2087,17 @@ void p3GxsChannels::cleanTimedOutSearches()
cbpt = mSearchCallbacksMap.erase(cbpt); cbpt = mSearchCallbacksMap.erase(cbpt);
} }
else ++cbpt; else ++cbpt;
} // RS_STACK_MUTEX(mSearchCallbacksMapMutex);
{
RS_STACK_MUTEX(mDistantChannelsCallbacksMapMutex);
for( auto cbpt = mDistantChannelsCallbacksMap.begin();
cbpt != mDistantChannelsCallbacksMap.end(); )
if(cbpt->second.second <= now)
{
clearDistantSearchResults(cbpt->first);
cbpt = mDistantChannelsCallbacksMap.erase(cbpt);
}
else ++cbpt;
} // RS_STACK_MUTEX(mDistantChannelsCallbacksMapMutex)
} }

View File

@ -83,7 +83,7 @@ public:
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups); virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups);
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts); virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts);
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) { std::vector<RsGxsComment> cmts; return getPostData( token, posts, cmts);} virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
//Not currently used //Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts); //virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
@ -112,6 +112,17 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
const std::function<void (const RsGxsGroupSummary&)>& multiCallback, const std::function<void (const RsGxsGroupSummary&)>& multiCallback,
rstime_t maxWait = 300 ); rstime_t maxWait = 300 );
/// @see RsGxsChannels::turtleChannelRequest
virtual bool turtleChannelRequest(
const RsGxsGroupId& channelId,
const std::function<void (const RsGxsChannelGroup& result)>& multiCallback,
rstime_t maxWait = 300 );
/// @see RsGxsChannels::localSearchRequest
virtual bool localSearchRequest(const std::string& matchString,
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
rstime_t maxWait = 30 ) override;
/** /**
* Receive results from turtle search @see RsGenExchange @see RsNxsObserver * Receive results from turtle search @see RsGenExchange @see RsNxsObserver
* @see RsGxsNetService::receiveTurtleSearchResults * @see RsGxsNetService::receiveTurtleSearchResults
@ -175,17 +186,40 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
std::vector<RsGxsChannelGroup>& channelsInfo ); std::vector<RsGxsChannelGroup>& channelsInfo );
/// Implementation of @see RsGxsChannels::getChannelContent /// Implementation of @see RsGxsChannels::getChannelContent
virtual bool getChannelsContent( virtual bool getChannelContent( const RsGxsGroupId& channelId,
const std::list<RsGxsGroupId>& chanIds, const std::set<RsGxsMessageId>& contentsIds,
std::vector<RsGxsChannelPost>& posts, std::vector<RsGxsChannelPost>& posts,
std::vector<RsGxsComment>& comments ); std::vector<RsGxsComment>& comments );
/// Implementation of @see RsGxsChannels::getContentSummaries
virtual bool getContentSummaries( const RsGxsGroupId& channelId,
std::vector<RsMsgMetaData>& summaries );
/// Implementation of @see RsGxsChannels::createChannel /// Implementation of @see RsGxsChannels::createChannel
virtual bool createChannel(RsGxsChannelGroup& channel); virtual bool createChannel(RsGxsChannelGroup& channel);
/// Implementation of @see RsGxsChannels::createComment
virtual bool createComment(RsGxsComment& comment);
/// Implementation of @see RsGxsChannels::editChannel
virtual bool editChannel(RsGxsChannelGroup& channel);
/// Implementation of @see RsGxsChannels::createPost /// Implementation of @see RsGxsChannels::createPost
virtual bool createPost(RsGxsChannelPost& post); virtual bool createPost(RsGxsChannelPost& post);
/// Implementation of @see RsGxsChannels::createVote
virtual bool createVote(RsGxsVote& vote);
/// Implementation of @see RsGxsChannels::subscribeToChannel
virtual bool subscribeToChannel( const RsGxsGroupId &groupId,
bool subscribe );
/// Implementation of @see RsGxsChannels::setPostRead
virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read);
virtual bool shareChannelKeys(
const RsGxsGroupId& channelId, const std::set<RsPeerId>& peers );
protected: protected:
// Overloaded from GxsTokenQueue for Request callbacks. // Overloaded from GxsTokenQueue for Request callbacks.
virtual void handleResponse(uint32_t token, uint32_t req_type); virtual void handleResponse(uint32_t token, uint32_t req_type);
@ -201,10 +235,8 @@ static uint32_t channelsAuthenPolicy();
void load_SubscribedGroups(const uint32_t &token); void load_SubscribedGroups(const uint32_t &token);
void request_SpecificUnprocessedPosts(std::list<std::pair<RsGxsGroupId, RsGxsMessageId> > &ids); void request_SpecificUnprocessedPosts(std::list<std::pair<RsGxsGroupId, RsGxsMessageId> > &ids);
void load_SpecificUnprocessedPosts(const uint32_t &token);
void request_GroupUnprocessedPosts(const std::list<RsGxsGroupId> &grouplist); void request_GroupUnprocessedPosts(const std::list<RsGxsGroupId> &grouplist);
void load_GroupUnprocessedPosts(const uint32_t &token); void load_unprocessedPosts(uint32_t token);
void handleUnprocessedPost(const RsGxsChannelPost &msg); void handleUnprocessedPost(const RsGxsChannelPost &msg);
@ -214,11 +246,6 @@ static uint32_t channelsAuthenPolicy();
bool setAutoDownload(const RsGxsGroupId &groupId, bool enabled); bool setAutoDownload(const RsGxsGroupId &groupId, bool enabled);
bool autoDownloadEnabled(const RsGxsGroupId &groupId, bool &enabled); bool autoDownloadEnabled(const RsGxsGroupId &groupId, bool &enabled);
std::map<RsGxsGroupId, RsGroupMetaData> mSubscribedGroups;
// DUMMY DATA, // DUMMY DATA,
virtual bool generateDummyData(); virtual bool generateDummyData();
@ -246,14 +273,21 @@ bool generateGroup(uint32_t &token, std::string groupName);
RsGxsMessageId mMsgId; RsGxsMessageId mMsgId;
}; };
std::map<RsGxsGroupId, RsGroupMetaData> mSubscribedGroups;
RsMutex mSubscribedGroupsMutex;
/** G10h4ck: Is this stuff really used? And for what? BEGIN */
uint32_t mGenToken; uint32_t mGenToken;
bool mGenActive; bool mGenActive;
int mGenCount; int mGenCount;
std::vector<ChannelDummyRef> mGenRefs; std::vector<ChannelDummyRef> mGenRefs;
RsGxsMessageId mGenThreadId; RsGxsMessageId mGenThreadId;
/** G10h4ck: Is this stuff really used? And for what? END */
p3GxsCommentService* mCommentService; p3GxsCommentService* mCommentService;
std::map<RsGxsGroupId,rstime_t> mKnownChannels; std::map<RsGxsGroupId,rstime_t> mKnownChannels;
RsMutex mKnownChannelsMutex;
/** Store search callbacks with timeout*/ /** Store search callbacks with timeout*/
std::map< std::map<
@ -264,8 +298,17 @@ bool generateGroup(uint32_t &token, std::string groupName);
> mSearchCallbacksMap; > mSearchCallbacksMap;
RsMutex mSearchCallbacksMapMutex; RsMutex mSearchCallbacksMapMutex;
/// Cleanup mSearchCallbacksMap /** Store distant channels requests callbacks with timeout*/
void cleanTimedOutSearches(); std::map<
TurtleRequestId,
std::pair<
std::function<void (const RsGxsChannelGroup&)>,
std::chrono::system_clock::time_point >
> mDistantChannelsCallbacksMap;
RsMutex mDistantChannelsCallbacksMapMutex;
/// Cleanup mSearchCallbacksMap and mDistantChannelsCallbacksMap
void cleanTimedOutCallbacks();
}; };
#endif #endif

View File

@ -297,6 +297,11 @@ bool p3GxsForums::getGroupData(const uint32_t &token, std::vector<RsGxsForumGrou
return ok; return ok;
} }
bool p3GxsForums::getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas)
{
return RsGenExchange::getMsgMeta(token, msg_metas);
}
/* Okay - chris is not going to be happy with this... /* Okay - chris is not going to be happy with this...
* but I can't be bothered with crazy data structures * but I can't be bothered with crazy data structures
* at the moment - fix it up later * at the moment - fix it up later
@ -379,6 +384,145 @@ bool p3GxsForums::getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &
/********************************************************************************************/ /********************************************************************************************/
bool p3GxsForums::createForum(RsGxsForumGroup& forum)
{
uint32_t token;
if(!createGroup(token, forum))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating group."
<< std::endl;
return false;
}
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, forum.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated "
<< " group data." << std::endl;
return false;
}
return true;
}
bool p3GxsForums::editForum(RsGxsForumGroup& forum)
{
uint32_t token;
if(!updateGroup(token, forum))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed updating group."
<< std::endl;
return false;
}
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, forum.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated "
<< " group data." << std::endl;
return false;
}
return true;
}
bool p3GxsForums::getForumsSummaries( std::list<RsGroupMetaData>& forums )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
if( !requestGroupInfo(token, opts)
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
return getGroupSummary(token, forums);
}
bool p3GxsForums::getForumsInfo(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
if( !requestGroupInfo(token, opts, forumIds)
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
return getGroupData(token, forumsInfo);
}
bool p3GxsForums::getForumsContent( const RsGxsGroupId& forumId, std::set<RsGxsMessageId>& msgs_to_request,std::vector<RsGxsForumMsg>& msgs)
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds;
msgIds[forumId] = msgs_to_request;
if( !requestMsgInfo(token, opts, msgIds) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
return getMsgData(token, msgs) ;
}
bool p3GxsForums::getForumsContent(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumMsg>& messages )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
if( !requestMsgInfo(token, opts, forumIds)
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
return getMsgData(token, messages);
}
bool p3GxsForums::getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas)
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
GxsMsgMetaMap meta_map;
std::list<RsGxsGroupId> forumIds;
forumIds.push_back(forumId);
if( !requestMsgInfo(token, opts, forumIds) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
bool res = getMsgMetaData(token, meta_map);
msg_metas = meta_map[forumId];
return res;
}
bool p3GxsForums::markRead(const RsGxsGrpMsgIdPair& msgId, bool read)
{
uint32_t token;
setMessageReadStatus(token, msgId, read);
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
return true;
}
bool p3GxsForums::subscribeToForum(
const RsGxsGroupId& groupId, bool subscribe )
{
uint32_t token;
if( !RsGenExchange::subscribeToGroup(token, groupId, subscribe)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
return true;
}
bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group) bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
{ {
std::cerr << "p3GxsForums::createGroup()" << std::endl; std::cerr << "p3GxsForums::createGroup()" << std::endl;
@ -407,6 +551,17 @@ bool p3GxsForums::updateGroup(uint32_t &token, RsGxsForumGroup &group)
return true; return true;
} }
bool p3GxsForums::createMessage(RsGxsForumMsg& message)
{
uint32_t token;
if( !createMsg(token, message)
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
if(RsGenExchange::getPublishedMsgMeta(token, message.mMeta)) return true;
return false;
}
bool p3GxsForums::createMsg(uint32_t &token, RsGxsForumMsg &msg) bool p3GxsForums::createMsg(uint32_t &token, RsGxsForumMsg &msg)
{ {
std::cerr << "p3GxsForums::createForumMsg() GroupId: " << msg.mMeta.mGroupId; std::cerr << "p3GxsForums::createForumMsg() GroupId: " << msg.mMeta.mGroupId;

View File

@ -39,19 +39,15 @@ class p3GxsForums: public RsGenExchange, public RsGxsForums, public p3Config,
public RsTickEvent /* only needed for testing - remove after */ public RsTickEvent /* only needed for testing - remove after */
{ {
public: public:
p3GxsForums(
p3GxsForums(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs); RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
virtual RsServiceInfo getServiceInfo(); virtual RsServiceInfo getServiceInfo();
virtual void service_tick(); virtual void service_tick();
protected: protected:
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes); virtual void notifyChanges(std::vector<RsGxsNotify*>& changes);
/// Overloaded from RsTickEvent.
// Overloaded from RsTickEvent.
virtual void handle_event(uint32_t event_type, const std::string &elabel); virtual void handle_event(uint32_t event_type, const std::string &elabel);
virtual RsSerialiser* setupSerialiser(); // @see p3Config::setupSerialiser() virtual RsSerialiser* setupSerialiser(); // @see p3Config::setupSerialiser()
@ -59,33 +55,49 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
virtual bool loadList(std::list<RsItem *>& loadList); // @see p3Config::loadList(std::list<RsItem *>&) virtual bool loadList(std::list<RsItem *>& loadList); // @see p3Config::loadList(std::list<RsItem *>&)
public: public:
/// @see RsGxsForums::createForum
virtual bool createForum(RsGxsForumGroup& forum);
/// @see RsGxsForums::createMessage
virtual bool createMessage(RsGxsForumMsg& message);
/// @see RsGxsForums::editForum
virtual bool editForum(RsGxsForumGroup& forum);
/// @see RsGxsForums::getForumsSummaries
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums);
/// @see RsGxsForums::getForumsInfo
virtual bool getForumsInfo(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo );
/// @see RsGxsForums::getForumsContent
virtual bool getForumsContent(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumMsg>& messages );
/// @see RsGxsForums::getForumMsgMetaData
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;
/// @see RsGxsForums::getForumsContent
virtual bool getForumsContent( const RsGxsGroupId& forumId, std::set<RsGxsMessageId>& msgs_to_request,std::vector<RsGxsForumMsg>& msgs) ;
/// @see RsGxsForums::markRead
virtual bool markRead(const RsGxsGrpMsgIdPair& messageId, bool read);
/// @see RsGxsForums::subscribeToForum
virtual bool subscribeToForum( const RsGxsGroupId& forumId,
bool subscribe );
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups); virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups);
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs); virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
//Not currently used virtual bool getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas);
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read); virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);
//virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
//virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
//virtual bool groupRestoreKeys(const std::string &groupId);
//virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group); virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg); virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
/*!
* To update forum group with new information
* @param token the token used to check completion status of update
* @param group group to be updated, groupId element must be set or will be rejected
* @return false groupId not set, true if set and accepted (still check token for completion)
*/
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group); virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group);
private: private:
static uint32_t forumsAuthenPolicy(); static uint32_t forumsAuthenPolicy();

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2012-2012 by Robert Fernie <retroshare.team@gmail.com> * * Copyright 2012-2012 by Robert Fernie <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -1220,7 +1220,7 @@ void p3turtle::handleSearchResult(RsTurtleSearchResultItem *item)
} }
//RsServer::notify()->notifyTurtleSearchResult(ftsr->request_id,ftsr->result) ; //RsServer::notify()->notifyTurtleSearchResult(ftsr->request_id,ftsr->result) ;
client->receiveSearchResult(ftsr); client->ftReceiveSearchResult(ftsr);
continue ; continue ;
} }

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2007-2018 Retroshare Team <retroshare.team@gmail.com> * * Copyright 2007-2018 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2007-2018 Retroshare Team <retroshare.team@gmail.com> * * Copyright 2007-2018 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2007-2018 Retroshare Team <retroshare.team@gmail.com> * * Copyright 2007-2018 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2007-2018 Retroshare Team <retroshare.team@gmail.com> * * Copyright 2007-2018 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2017 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2017 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2017 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2017 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2017 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2017 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2017 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2017 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2017 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2017 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

View File

@ -3,7 +3,7 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2017 Retroshare Team <retroshare.team@gmail.com> * * Copyright (C) 2017 Retroshare Team <retroshare.project@gmail.com> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *

Some files were not shown because too many files have changed in this diff Show More