Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
hfedcba committed Jul 27, 2018
2 parents 9f62bfe + dc66cc5 commit 09db5fb
Show file tree
Hide file tree
Showing 28 changed files with 1,146 additions and 1,292 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ set(SOURCE_FILES
homegear-miscellaneous/src/Miscellaneous.h
homegear-miscellaneous/src/MiscPeer.cpp
homegear-miscellaneous/src/MiscPeer.h
src/CLI/CLIClient.cpp
src/CLI/CLIClient.h
src/CLI/CLIServer.cpp
src/CLI/CLIServer.h
src/CLI/CliClient.cpp
src/CLI/CliClient.h
src/CLI/CliServer.cpp
src/CLI/CliServer.h
src/Database/SQLite3.cpp
src/Database/SQLite3.h
src/Events/EventHandler.cpp
Expand Down
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Maintainer: Sathya Laufer <sathya@laufers.net>
Section: misc
Priority: optional
Standards-Version: 3.9.6
Build-Depends: debhelper (>= 8), libhomegear-base (= <BASELIBVER>), libhomegear-node, libsqlite3-dev (>= 3.7.13), libreadline6-dev | libreadline-dev, libgcrypt20-dev, libgpg-error-dev (>= 1.10), libgnutls28-dev, php7-homegear-dev, libxslt1-dev, libedit-dev, libenchant-dev, libqdbm-dev, libltdl-dev, zlib1g-dev, libtinfo-dev, libgmp-dev, libxml2-dev, libssl-dev, libcurl4-gnutls-dev
Build-Depends: debhelper (>= 8), libhomegear-base (= <BASELIBVER>), libhomegear-node, libhomegear-ipc, libsqlite3-dev (>= 3.7.13), libreadline6-dev | libreadline-dev, libgcrypt20-dev, libgpg-error-dev (>= 1.10), libgnutls28-dev, php7-homegear-dev, libxslt1-dev, libedit-dev, libenchant-dev, libqdbm-dev, libltdl-dev, zlib1g-dev, libtinfo-dev, libgmp-dev, libxml2-dev, libssl-dev, libcurl4-gnutls-dev
Homepage: https://homegear.eu

Package: homegear
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libhomegear-base (= <BASELIBVER>), libhomegear-node, wget, libsqlite3-0 (>= 3.7.13), libreadline7 | libreadline6, adduser (>= 3.113), libgcrypt20, libgnutlsxx28, libgpg-error0 (>= 1.10), unzip (>= 6.0), p7zip-full (>= 9.0), procps, libxslt1.1, libedit2, libenchant1c2a, libqdbm14, libltdl7, zlib1g, libtinfo5, libgmp10, libxml2, libssl1.1 | libssl1.0.0, openssl, libcurl3-gnutls, libmariadbclient20 | libmariadbclient18 | libmysqlclient20 | libmysqlclient18
Depends: ${shlibs:Depends}, ${misc:Depends}, libhomegear-base (= <BASELIBVER>), libhomegear-node, libhomegear-ipc, wget, libsqlite3-0 (>= 3.7.13), libreadline7 | libreadline6, adduser (>= 3.113), libgcrypt20, libgnutlsxx28, libgpg-error0 (>= 1.10), unzip (>= 6.0), p7zip-full (>= 9.0), procps, libxslt1.1, libedit2, libenchant1c2a, libqdbm14, libltdl7, zlib1g, libtinfo5, libgmp10, libxml2, libssl1.1 | libssl1.0.0, openssl, libcurl3-gnutls, libmariadbclient20 | libmariadbclient18 | libmysqlclient20 | libmysqlclient18
Replaces: homegear (<< 0.6)
Breaks: homegear (<< 0.6)
Description: Interface program to your smart home devices
Expand Down
81 changes: 18 additions & 63 deletions homegear-miscellaneous/src/MiscCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ void MiscCentral::deletePeer(uint64_t id)
int32_t i = 0;
while(peer.use_count() > 1 && i < 600)
{
if(_currentPeer && _currentPeer->getID() == id) _currentPeer.reset();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
i++;
}
Expand Down Expand Up @@ -274,15 +273,6 @@ std::string MiscCentral::handleCliCommand(std::string command)
std::ostringstream stringStream;
std::vector<std::string> arguments;
bool showHelp = false;
if(_currentPeer)
{
if(command == "unselect" || command == "u")
{
_currentPeer.reset();
return "Peer unselected.\n";
}
return _currentPeer->handleCliCommand(command);
}
if(command == "help" || command == "h")
{
stringStream << "List of commands:" << std::endl << std::endl;
Expand Down Expand Up @@ -394,7 +384,6 @@ std::string MiscCentral::handleCliCommand(std::string command)
if(!peerExists(peerId)) stringStream << "This peer is not paired to this central." << std::endl;
else
{
if(_currentPeer && _currentPeer->getID() == peerId) _currentPeer.reset();
stringStream << "Removing peer " << std::to_string(peerId) << std::endl;
deletePeer(peerId);
}
Expand Down Expand Up @@ -630,7 +619,6 @@ std::string MiscCentral::handleCliCommand(std::string command)
int32_t i = 0;
while(peer.use_count() > 1 && i < 600)
{
if(_currentPeer && _currentPeer->getID() == peerId) _currentPeer.reset();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
i++;
}
Expand All @@ -652,47 +640,6 @@ std::string MiscCentral::handleCliCommand(std::string command)
stringStream << "Peer restarted." << std::endl;
return stringStream.str();
}
else if(command.compare(0, 12, "peers select") == 0 || command.compare(0, 2, "ps") == 0)
{
uint64_t id = 0;

std::stringstream stream(command);
std::string element;
int32_t offset = (command.at(1) == 's') ? 0 : 1;
int32_t index = 0;
while(std::getline(stream, element, ' '))
{
if(index < 1 + offset)
{
index++;
continue;
}
else if(index == 1 + offset)
{
if(element == "help") break;
id = BaseLib::Math::getNumber(element, false);
if(id == 0) return "Invalid id.\n";
}
index++;
}
if(index == 1 + offset)
{
stringStream << "Description: This command selects a peer." << std::endl;
stringStream << "Usage: peers select PEERID" << std::endl << std::endl;
stringStream << "Parameters:" << std::endl;
stringStream << " PEERID:\tThe id of the peer to select. Example: 513" << std::endl;
return stringStream.str();
}

_currentPeer = getPeer(id);
if(!_currentPeer) stringStream << "This peer is not paired to this central." << std::endl;
else
{
stringStream << "Peer with id " << std::hex << std::to_string(id) << " and device type 0x" << _bl->hf.getHexString(_currentPeer->getDeviceType()) << " selected." << std::dec << std::endl;
stringStream << "For information about the peer's commands type: \"help\"" << std::endl;
}
return stringStream.str();
}
else return "Unknown command.\n";
}
catch(const std::exception& ex)
Expand Down Expand Up @@ -797,10 +744,16 @@ PVariable MiscCentral::deleteDevice(BaseLib::PRpcClientInfo clientInfo, std::str
try
{
if(serialNumber.empty()) return Variable::createError(-2, "Unknown device.");
std::shared_ptr<MiscPeer> peer = getPeer(serialNumber);
if(!peer) return PVariable(new Variable(VariableType::tVoid));

return deleteDevice(clientInfo, peer->getID(), flags);
uint64_t peerId = 0;

{
std::shared_ptr<MiscPeer> peer = getPeer(serialNumber);
if(!peer) return PVariable(new Variable(VariableType::tVoid));
peerId = peer->getID();
}

return deleteDevice(clientInfo, peerId, flags);
}
catch(const std::exception& ex)
{
Expand All @@ -817,18 +770,20 @@ PVariable MiscCentral::deleteDevice(BaseLib::PRpcClientInfo clientInfo, std::str
return Variable::createError(-32500, "Unknown application error.");
}

PVariable MiscCentral::deleteDevice(BaseLib::PRpcClientInfo clientInfo, uint64_t peerID, int32_t flags)
PVariable MiscCentral::deleteDevice(BaseLib::PRpcClientInfo clientInfo, uint64_t peerId, int32_t flags)
{
try
{
if(peerID == 0) return Variable::createError(-2, "Unknown device.");
std::shared_ptr<MiscPeer> peer = getPeer(peerID);
if(!peer) return PVariable(new Variable(VariableType::tVoid));
uint64_t id = peer->getID();
if(peerId == 0) return Variable::createError(-2, "Unknown device.");

{
std::shared_ptr<MiscPeer> peer = getPeer(peerId);
if(!peer) return PVariable(new Variable(VariableType::tVoid));
}

deletePeer(id);
deletePeer(peerId);

if(peerExists(id)) return Variable::createError(-1, "Error deleting peer. See log for more details.");
if(peerExists(peerId)) return Variable::createError(-1, "Error deleting peer. See log for more details.");

return PVariable(new Variable(VariableType::tVoid));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,18 @@ if [[ -n $2 ]]; then
sed -i '/if(sha256(baselibPath) == /d' homegear-licensing-${1}/src/Licensing.cpp
sed -i "/if(baselibPath.empty()) return false;/aif(sha256(baselibPath) == \"$sha256\") return true;" homegear-licensing-${1}/src/Licensing.cpp
sha256=`sha256sum /usr/lib/libhomegear-node.so.1 | awk '{print toupper($0)}' | cut -d ' ' -f 1`
sed -i '/if(sha256(nodelibPath) == /d' homegear-easy-licensing-${1}/src/EasyLicensing.cpp
sed -i "/if(nodelibPath.empty()) return false;/aif(sha256(nodelibPath) == \"$sha256\") return true;" homegear-easy-licensing-${1}/src/EasyLicensing.cpp
sed -i '/if(sha256(nodelibPath) == /d' homegear-licensing-${1}/src/Licensing.cpp
sed -i "/if(nodelibPath.empty()) return false;/aif(sha256(nodelibPath) == \"$sha256\") return true;" homegear-licensing-${1}/src/Licensing.cpp
sha256=`sha256sum /usr/lib/libhomegear-ipc.so.1 | awk '{print toupper($0)}' | cut -d ' ' -f 1`
sed -i '/if(sha256(ipclibPath) == /d' homegear-easy-licensing-${1}/src/EasyLicensing.cpp
sed -i "/if(ipclibPath.empty()) return false;/aif(sha256(ipclibPath) == \"$sha256\") return true;" homegear-easy-licensing-${1}/src/EasyLicensing.cpp
sed -i '/if(sha256(ipclibPath) == /d' homegear-licensing-${1}/src/Licensing.cpp
sed -i "/if(ipclibPath.empty()) return false;/aif(sha256(ipclibPath) == \"$sha256\") return true;" homegear-licensing-${1}/src/Licensing.cpp
createPackage homegear-easy-licensing $1 homegear-easy-licensing 1
createPackage homegear-licensing $1 homegear-licensing 1
Expand Down

0 comments on commit 09db5fb

Please sign in to comment.