[LMSAPI] Renamed 'Remote' to 'LmsAPI'

This commit is contained in:
emeric
2015-07-29 13:23:14 +02:00
parent 407601f638
commit 1c62194935
28 changed files with 219 additions and 126 deletions
+1 -1
View File
@@ -61,7 +61,7 @@
- Make a dedicated audio layout in mobile environment (keep the same layout for videos?)
- Handle internal path
[Remote API]
[Lms API]
- Implement partial text search options in the GetXXX messages
[REST API]
+11 -11
View File
@@ -67,14 +67,14 @@ lms_SOURCES = \
if LMSAPI
lms_SOURCES += \
$(srcdir)/remote/server/Connection.cpp \
$(srcdir)/remote/server/ConnectionManager.cpp \
$(srcdir)/remote/server/AudioCollectionRequestHandler.cpp \
$(srcdir)/remote/server/AuthRequestHandler.cpp \
$(srcdir)/remote/server/MediaRequestHandler.cpp \
$(srcdir)/remote/server/RequestHandler.cpp \
$(srcdir)/remote/server/Server.cpp \
$(srcdir)/service/RemoteServerService.cpp
$(srcdir)/lms-api/server/Connection.cpp \
$(srcdir)/lms-api/server/ConnectionManager.cpp \
$(srcdir)/lms-api/server/AudioCollectionRequestHandler.cpp \
$(srcdir)/lms-api/server/AuthRequestHandler.cpp \
$(srcdir)/lms-api/server/MediaRequestHandler.cpp \
$(srcdir)/lms-api/server/RequestHandler.cpp \
$(srcdir)/lms-api/server/Server.cpp \
$(srcdir)/service/LmsAPIServerService.cpp
nodist_lms_SOURCES = \
$(builddir)/auth.pb.cc \
@@ -112,10 +112,10 @@ MOSTLYCLEANFILES = \
$(builddir)/messages.pb.cc \
$(builddir)/messages.pb.h
%.pb.cc %.pb.h: $(srcdir)/remote/proto/%.proto
$(PROTOC) --proto_path=$(srcdir)/remote/proto/ --cpp_out=$(builddir)/ $^
%.pb.cc %.pb.h: $(srcdir)/lms-api/proto/%.proto
$(PROTOC) --proto_path=$(srcdir)/lms-api/proto/ --cpp_out=$(builddir)/ $^
endif
lms_CXXFLAGS=-DBOOST_LOG_DYN_LINK -std=c++11 -Wall -I$(top_srcdir)/third-party -I$(srcdir)/ui -I$(srcdir)/remote
lms_CXXFLAGS=-DBOOST_LOG_DYN_LINK -std=c++11 -Wall -I$(top_srcdir)/third-party -I$(srcdir)/ui -I$(srcdir)/lms-api
+1 -1
View File
@@ -27,7 +27,7 @@
#include "logger/Logger.hpp"
#include "service/UserInterfaceService.hpp"
#include "service/RemoteServerService.hpp"
#include "service/LmsAPIServerService.hpp"
#include "service/DatabaseUpdateService.hpp"
class ConfigReader
@@ -24,7 +24,7 @@
#include <iomanip>
namespace Remote
namespace LmsAPI
{
@@ -104,7 +104,7 @@ class Header
} // namespace Remote
} // namespace LmsAPI
#endif
+67
View File
@@ -0,0 +1,67 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
import "common.proto";
package LmsAPI;
message AuthRequest
{
message Password
{
required string user_login = 1;
required string user_password = 2;
}
enum Type
{
TypePassword = 1;
}
required Type type = 1;
optional Password password = 2;
}
message AuthResponse
{
message PasswordResult
{
enum Type
{
TypePasswordInvalid = 1;
TypeLoginThrottling = 2; // The attempt was not processed because of throttling
TypePasswordValid = 3;
}
required Type type = 1;
optional uint32 delay = 2; // in seconds, in case of PasswordInvalid/LoginThrottling
}
enum Type
{
TypePasswordResult = 1;
}
required Type type = 1;
optional PasswordResult password_result = 2;
}
@@ -1,6 +1,25 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
import "common.proto";
package Remote;
package LmsAPI;
message AudioCollectionRequest
{
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
package LmsAPI;
message Error
{
required bool error = 1;
optional string message = 2;
}
@@ -1,8 +1,25 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
import "common.proto";
package Remote;
package LmsAPI;
message MediaRequest
{
@@ -1,9 +1,29 @@
/*
* Copyright (C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
import "common.proto";
import "auth.proto";
import "collection.proto";
import "media.proto";
package Remote;
package LmsAPI;
// Every request sent by the client must be a ClientMessage
// The server will answer using a ServerMessage
@@ -29,7 +29,7 @@
#include "database/Types.hpp"
#include "cover/CoverArtGrabber.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
using namespace Database;
@@ -387,7 +387,7 @@ AudioCollectionRequestHandler::processGetRevision(AudioCollectionResponse::Revis
} // namespace Remote
} // namespace LmsAPI
} // namespace Server
@@ -24,7 +24,7 @@
#include "messages.pb.h"
namespace Remote {
namespace LmsAPI {
namespace Server {
class AudioCollectionRequestHandler
@@ -54,7 +54,7 @@ class AudioCollectionRequestHandler
static const std::size_t _maxCoverArtSize = 512; // in pixels, square
};
} // namespace Remote
} // namespace LmsAPI
} // namespace Server
#endif
@@ -23,7 +23,7 @@
#include "AuthRequestHandler.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
AuthRequestHandler::AuthRequestHandler(Database::Handler& db)
@@ -100,6 +100,6 @@ AuthRequestHandler::processPassword(const AuthRequest::Password& request, AuthRe
return res;
}
} // namespace Remote
} // namespace Server
} // namespace LmsAPI
@@ -17,14 +17,14 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef REMOTE_AUTH_REQUEST_HANDLER
#define REMOTE_AUTH_REQUEST_HANDLER
#ifndef LMSAPI_AUTH_REQUEST_HANDLER
#define LMSAPI_AUTH_REQUEST_HANDLER
#include "database/DatabaseHandler.hpp"
#include "messages.pb.h"
namespace Remote {
namespace LmsAPI {
namespace Server {
class AuthRequestHandler
@@ -41,7 +41,7 @@ class AuthRequestHandler
Database::Handler& _db;
};
} // namespace Remote
} // namespace Server
} // namespace LmsAPI
#endif
@@ -33,7 +33,7 @@
#include "ConnectionManager.hpp"
#include "Connection.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
Connection::Connection(boost::asio::io_service& ioService,
@@ -79,11 +79,11 @@ void
Connection::readMsg()
{
// Read a header first
boost::asio::streambuf::mutable_buffers_type bufs = _inputStreamBuf.prepare(Remote::Header::size);
boost::asio::streambuf::mutable_buffers_type bufs = _inputStreamBuf.prepare(LmsAPI::Header::size);
boost::asio::async_read(_socket,
bufs,
boost::asio::transfer_exactly(Remote::Header::size),
boost::asio::transfer_exactly(LmsAPI::Header::size),
boost::bind(&Connection::handleReadHeader, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
@@ -114,9 +114,9 @@ Connection::handleReadHeader(const boost::system::error_code& error, std::size_t
{
if (!error)
{
if (bytes_transferred != Remote::Header::size)
if (bytes_transferred != LmsAPI::Header::size)
{
LMS_LOG(MOD_REMOTE, SEV_ERROR) << "bytes_transferred (" << bytes_transferred << ") != Remote::Header::size!";
LMS_LOG(MOD_REMOTE, SEV_ERROR) << "bytes_transferred (" << bytes_transferred << ") != LmsAPI::Header::size!";
_connectionManager.stop(shared_from_this());
return;
}
@@ -125,7 +125,7 @@ Connection::handleReadHeader(const boost::system::error_code& error, std::size_t
std::istream is(&_inputStreamBuf);
Remote::Header header;
LmsAPI::Header header;
if (!header.from_istream(is))
{
LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Cannot read header from buffer!";
@@ -161,8 +161,8 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by
std::istream is(&_inputStreamBuf);
std::ostream os(&_outputStreamBuf);
Remote::ServerMessage response;
Remote::ClientMessage request;
LmsAPI::ServerMessage response;
LmsAPI::ClientMessage request;
if (!request.ParseFromIstream(&is))
{
@@ -188,23 +188,23 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by
return;
}
if (_outputStreamBuf.size() >= Remote::Header::max_data_size)
if (_outputStreamBuf.size() >= LmsAPI::Header::max_data_size)
{
LMS_LOG(MOD_REMOTE, SEV_ERROR) << "output message is too big! " << _outputStreamBuf.size() << " > " << Remote::Header::max_data_size;
LMS_LOG(MOD_REMOTE, SEV_ERROR) << "output message is too big! " << _outputStreamBuf.size() << " > " << LmsAPI::Header::max_data_size;
_connectionManager.stop(shared_from_this());
return;
}
std::array<unsigned char, Remote::Header::size> headerBuffer;
std::array<unsigned char, LmsAPI::Header::size> headerBuffer;
{
Remote::Header header;
LmsAPI::Header header;
header.setDataSize(_outputStreamBuf.size());
header.to_buffer(headerBuffer);
}
std::size_t n = boost::asio::write(_socket,
boost::asio::buffer(headerBuffer),
boost::asio::transfer_exactly(Remote::Header::size),
boost::asio::transfer_exactly(LmsAPI::Header::size),
ec);
if (ec)
{
@@ -213,7 +213,7 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by
}
else
{
assert(n == Remote::Header::size);
assert(n == LmsAPI::Header::size);
}
// Now send serialized payload
@@ -247,4 +247,4 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by
} // namespace Server
} // namespace Remote
} // namespace LmsAPI
@@ -17,8 +17,8 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef REMOTE_CONNECTION_HPP
#define REMOTE_CONNECTION_HPP
#ifndef LMSAPI_CONNECTION_HPP
#define LMSAPI_CONNECTION_HPP
#include <array>
#include <memory>
@@ -30,7 +30,7 @@
#include "messages/Header.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
class ConnectionManager;
@@ -91,7 +91,7 @@ class Connection : public std::enable_shared_from_this<Connection>
} // namespace Server
} // namespace Remote
} // namespace LmsAPI
#endif
@@ -23,7 +23,7 @@
#include "ConnectionManager.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
ConnectionManager::ConnectionManager()
@@ -57,6 +57,6 @@ ConnectionManager::stopAll()
} // namespace Server
} // namespace Remote
} // namespace LmsAPI
@@ -24,7 +24,7 @@
#include "Connection.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
/// Manages open connections so that they may be cleanly stopped when the server
@@ -53,6 +53,6 @@ class ConnectionManager
};
} // namespace Server
} // namespace Remote
} // namespace LmsAPI
#endif
@@ -23,7 +23,7 @@
#include "database/Types.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
MediaRequestHandler::MediaRequestHandler(Database::Handler& db)
@@ -211,7 +211,7 @@ MediaRequestHandler::processTerminate(const MediaRequest::Terminate& request, Me
} // namespace Remote
} // namespace LmsAPI
} // namespace Server
@@ -28,7 +28,7 @@
#include "media.pb.h"
namespace Remote {
namespace LmsAPI {
namespace Server {
class MediaRequestHandler
@@ -58,8 +58,8 @@ class MediaRequestHandler
static const std::size_t _maxTranscoders = 1;
};
} // namespace Remote
} // namespace Server
} // namespace LmsAPI
#endif
@@ -21,7 +21,7 @@
#include "RequestHandler.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
RequestHandler::RequestHandler(boost::filesystem::path dbPath)
@@ -95,7 +95,7 @@ RequestHandler::process(const ClientMessage& request, ServerMessage& response)
} // namespace Server
} // namespace Remote
} // namespace LmsAPI
@@ -30,7 +30,7 @@
#include "AudioCollectionRequestHandler.hpp"
#include "MediaRequestHandler.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
class RequestHandler
@@ -52,7 +52,7 @@ class RequestHandler
};
} // namespace Server
} // namespace Remote
} // namespace LmsAPI
#endif
@@ -27,7 +27,7 @@
#include "Server.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
Server::Server(const endpoint_type& bindEndpoint,
@@ -109,4 +109,4 @@ Server::stop()
}
} // namespace Server
} // namespace Remote
} // namespace LmsAPI
@@ -32,7 +32,7 @@
#include "RequestHandler.hpp"
namespace Remote {
namespace LmsAPI {
namespace Server {
class Server
@@ -76,6 +76,6 @@ class Server
};
} // namespace Server
} // namespace Remote
} // namespace LmsAPI
#endif
+1 -1
View File
@@ -28,7 +28,7 @@
#include "service/ServiceManager.hpp"
#include "service/DatabaseUpdateService.hpp"
#include "service/UserInterfaceService.hpp"
#include "service/RemoteServerService.hpp"
#include "service/LmsAPIServerService.hpp"
int main(int argc, char* argv[])
{
-48
View File
@@ -1,48 +0,0 @@
import "common.proto";
package Remote;
message AuthRequest
{
message Password
{
required string user_login = 1;
required string user_password = 2;
}
enum Type
{
TypePassword = 1;
}
required Type type = 1;
optional Password password = 2;
}
message AuthResponse
{
message PasswordResult
{
enum Type
{
TypePasswordInvalid = 1;
TypeLoginThrottling = 2; // The attempt was not processed because of throttling
TypePasswordValid = 3;
}
required Type type = 1;
optional uint32 delay = 2; // in seconds, in case of PasswordInvalid/LoginThrottling
}
enum Type
{
TypePasswordResult = 1;
}
required Type type = 1;
optional PasswordResult password_result = 2;
}
-9
View File
@@ -1,9 +0,0 @@
package Remote;
message Error
{
required bool error = 1;
optional string message = 2;
}
@@ -19,7 +19,7 @@
#include "logger/Logger.hpp"
#include "RemoteServerService.hpp"
#include "LmsAPIServerService.hpp"
namespace Service {
@@ -25,7 +25,7 @@
#include "Service.hpp"
#include "remote/server/Server.hpp"
#include "lms-api/server/Server.hpp"
namespace Service {
@@ -51,7 +51,7 @@ class RemoteServerService : public Service
private:
Remote::Server::Server _server;
LmsAPI::Server::Server _server;
};
} // namespace Service