Skip to content

Commit

Permalink
sync upstream lib/noson
Browse files Browse the repository at this point in the history
janbar-noson-e0bd850
  • Loading branch information
janbar committed Jul 14, 2017
1 parent ca3069f commit f445834
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 41 deletions.
4 changes: 2 additions & 2 deletions backend/lib/noson/noson/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ endif ()

###############################################################################
# set lib version here
set (NOSON_LIB_VERSION "1.4.0")
set (NOSON_LIB_VERSION "1.4.1")
set (NOSON_LIB_SOVERSION "1")

###############################################################################
# add definitions
if (MSVC)
add_definitions ("/D_USE_32BIT_TIME_T /D_CRT_SECURE_NO_WARNINGS")
add_definitions ("/D_CRT_SECURE_NO_WARNINGS")
if (STATIC_CRT)
set (CMAKE_C_FLAGS_RELEASE "/MT")
set (CMAKE_C_FLAGS_DEBUG "/MTd")
Expand Down
3 changes: 3 additions & 0 deletions backend/lib/noson/noson/src/local_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
#undef LIBTAG
#define LIBTAG "SONOS"

#undef LIBVERSION
#define LIBVERSION "@NOSON_LIB_VERSION@"

#endif /* LOCAL_CONFIG_H */
2 changes: 1 addition & 1 deletion backend/lib/noson/noson/src/musicservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ SMService::SMService(const std::string& agent, const SMAccountPtr& account, cons
{
ServiceType(GetId(), m_type);
// make the sonos descriptor
m_desc.assign("SA_RINCON").append(m_type).append("_").append(account->GetUserName());
m_desc.assign("SA_RINCON").append(m_type).append("_").append(account->GetUsername());
}

const std::string& SMService::GetId() const
Expand Down
2 changes: 1 addition & 1 deletion backend/lib/noson/noson/src/musicservices.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace NSROOT
virtual ~SMAccount();
const std::string& GetType() const { return GetAttribut("Type"); }
const std::string& GetSerialNum() const { return GetAttribut("SerialNum"); }
const std::string& GetUserName() const { return GetAttribut("UN"); }
const std::string& GetUsername() const { return GetAttribut("UN"); }
const std::string& GetMetadata() const { return GetAttribut("MD"); }
const std::string& GetNickname() const { return GetAttribut("NN"); }

Expand Down
34 changes: 26 additions & 8 deletions backend/lib/noson/noson/src/private/eventbroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "xmldict.h"
#include "cppdef.h"
#include "debug.h"
#include "builtin.h"

#include <cstdio>

Expand Down Expand Up @@ -246,19 +247,36 @@ void EventBroker::Process()
case HRM_HEAD:
case HRM_GET:
{
EventMessage msg;
msg.event = EVENT_UNKNOWN;
msg.subject.push_back("GET");
msg.subject.push_back(rb.GetParsedURI());
m_handler->DispatchEvent(msg);
status.Set(HSC_OK);
if (rb.GetParsedURI().compare("/") == 0)
{
static const char* version_string = "<html><h1>Noson Event Broker</h1><p>Version <b>" LIBVERSION "</b>, compiled on " __DATE__ " at " __TIME__ "</html>";
char buf[8];
uint32_to_string(strlen(version_string), buf);
status.Set(HSC_OK);
resp.append(REQUEST_PROTOCOL " ").append(status.GetString()).append(" ").append(status.GetMessage()).append("\r\n");
resp.append("CONTENT-TYPE: text/html\r\n");
resp.append("CONTENT-LENGTH: ").append(buf).append("\r\n");
resp.append("\r\n");
resp.append(version_string);
}
else
{
EventMessage msg;
msg.event = EVENT_UNKNOWN;
msg.subject.push_back("GET");
msg.subject.push_back(rb.GetParsedURI());
m_handler->DispatchEvent(msg);
status.Set(HSC_OK);
resp.append(REQUEST_PROTOCOL " ").append(status.GetString()).append(" ").append(status.GetMessage());
resp.append("\r\n\r\n");
}
break;
}
default:
status.Set(HSC_Internal_Server_Error);
resp.append(REQUEST_PROTOCOL " ").append(status.GetString()).append(" ").append(status.GetMessage());
resp.append("\r\n\r\n");
}
resp.append(REQUEST_PROTOCOL " ").append(status.GetString()).append(" ").append(status.GetMessage());
resp.append("\r\n\r\n");
m_sockPtr->SendData(resp.c_str(), resp.size());
m_sockPtr->Disconnect();
}
2 changes: 1 addition & 1 deletion backend/lib/noson/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project (nosontest)
###############################################################################
# add definitions
if (MSVC)
add_definitions ("/D_USE_32BIT_TIME_T /D_CRT_SECURE_NO_WARNINGS")
add_definitions ("/D_CRT_SECURE_NO_WARNINGS")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /W3")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W3")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /Od /RTC1 /EHsc /nologo")
Expand Down
45 changes: 40 additions & 5 deletions backend/lib/noson/test/src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ void handleEventCB(void* handle)
fprintf(stderr, "#########################\n");
}

void usage(const char* cmd)
{
fprintf(stderr,
"Usage: %s [options]\n"
" --zone <zone name> Connect to zone\n"
" --search <media id> Testing search for id, default is 'Q:0'\n"
" --debug Enable debug output\n"
" --help print this help\n"
"\n", cmd
);
}

static int g_loglevel = 2;

int main(int argc, char** argv)
{
int ret = 0;
Expand All @@ -49,13 +63,34 @@ int main(int argc, char** argv)
#endif /* __WINDOWS__ */

std::string tryzone;
if (argc > 1)
tryzone.assign(argv[1]);
std::string search = "Q:0";
if (argc > 2)
search.assign(argv[2]);

SONOS::DBGLevel(3); // debug/proto
int i = 0;
while (++i < argc)
{
if (strcmp(argv[i], "--debug") == 0)
{
g_loglevel = 4;
fprintf(stderr, "debug=Yes, ");
}
else if (strcmp(argv[i], "--zone") == 0 && ++i < argc)
{
fprintf(stderr, "zone=%s, ", argv[i]);
tryzone.assign(argv[i]);
}
else if (strcmp(argv[i], "--search") == 0 && ++i < argc)
{
fprintf(stderr, "search=%s, ", argv[i]);
search.assign(argv[i]);
}
else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
{
usage(argv[0]);
return 0;
}
}
fprintf(stderr, "\n");
SONOS::DBGLevel(g_loglevel);

{

Expand Down
91 changes: 68 additions & 23 deletions backend/lib/noson/test/src/testms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ void handleEventCB(void* handle)
// fprintf(stderr, "#########################\n");
}


void usage(const char* cmd)
{
fprintf(stderr,
"Usage: %s [options]\n"
" --zone <zone name> Connect to zone\n"
" --service <service name> Testing for music service, default is 'TuneIn'\n"
" --search <media id> Testing search for id, default is 'root'\n"
" --username <user name> If policy auth is UserId: username\n"
" --password <password> If policy auth is UserId: password\n"
" --debug Enable debug output\n"
" --help print this help\n"
"\n", cmd
);
}

static int g_loglevel = 2;

int main(int argc, char** argv)
{
int ret = 0;
Expand All @@ -50,25 +68,52 @@ int main(int argc, char** argv)
#endif /* __WINDOWS__ */

std::string tryzone;
if (argc > 1)
tryzone.assign(argv[1]);
std::string tstServiceName;
std::string tstServiceMediaId;
if (argc > 2)
tstServiceName.assign(argv[2]);
if (argc > 3)
tstServiceMediaId.assign(argv[3]);
else
tstServiceMediaId.assign("root");
std::string username("");
std::string password("");
if (argc > 4)
username.assign(argv[4]);
if (argc > 5)
password.assign(argv[5]);


SONOS::DBGLevel(2); // debug/proto
std::string tstServiceName = "TuneIn";
std::string tstServiceMediaId = "root";
std::string username = "";
std::string password = "";

int i = 0;
while (++i < argc)
{
if (strcmp(argv[i], "--debug") == 0)
{
g_loglevel = 4;
fprintf(stderr, "debug=Yes, ");
}
else if (strcmp(argv[i], "--zone") == 0 && ++i < argc)
{
fprintf(stderr, "zone=%s, ", argv[i]);
tryzone.assign(argv[i]);
}
else if (strcmp(argv[i], "--service") == 0 && ++i < argc)
{
fprintf(stderr, "service=%s, ", argv[i]);
tstServiceName.assign(argv[i]);
}
else if (strcmp(argv[i], "--search") == 0 && ++i < argc)
{
fprintf(stderr, "search=%s, ", argv[i]);
tstServiceMediaId.assign(argv[i]);
}
else if (strcmp(argv[i], "--username") == 0 && ++i < argc)
{
fprintf(stderr, "username=%s, ", argv[i]);
username.assign(argv[i]);
}
else if (strcmp(argv[i], "--search") == 0 && ++i < argc)
{
fprintf(stderr, "password=%s, ", argv[i]);
password.assign(argv[i]);
}
else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
{
usage(argv[0]);
return 0;
}
}
fprintf(stderr, "\n");
SONOS::DBGLevel(g_loglevel);

{

Expand Down Expand Up @@ -108,7 +153,7 @@ int main(int argc, char** argv)

if (tstServiceName.empty() && item->GetName() == "TuneIn")
{
SONOS::DBGLevel(3);
SONOS::DBGLevel((g_loglevel < 3 ? 3 : g_loglevel));
PRINT1("Testing service %s ...\n", item->GetName().c_str());
SONOS::SMAPI sm(playerPtr);
sm.Init(item, "fr_FR");
Expand All @@ -123,11 +168,11 @@ int main(int argc, char** argv)
else
PRINT1("%s\n\n", data.item->DIDL().c_str());
}
SONOS::DBGLevel(2);
SONOS::DBGLevel(g_loglevel);
}
if (item->GetName() == tstServiceName)
{
SONOS::DBGLevel(3);
SONOS::DBGLevel((g_loglevel < 3 ? 3 : g_loglevel));
PRINT1("Testing service %s ...\n", item->GetName().c_str());
SONOS::SMAPI sm(playerPtr);
sm.Init(item, "fr_FR");
Expand Down Expand Up @@ -216,7 +261,7 @@ int main(int argc, char** argv)
else
PRINT1("%s\n\n", data.item->DIDL().c_str());
}
SONOS::DBGLevel(2);
SONOS::DBGLevel(g_loglevel);
}
}
}
Expand Down

0 comments on commit f445834

Please sign in to comment.