Changing namespace CentralKeyManager to shorter version.
Change-Id: If0ce82ee574a0bb77c4c3e014cec60a2a37240ad
//#include <key-manager.h>
#include <ckm/errors.h>
-IMPLEMENT_SAFE_SINGLETON(CentralKeyManager::Log::LogSystem);
+IMPLEMENT_SAFE_SINGLETON(CKM::Log::LogSystem);
namespace {
const int POLL_TIMEOUT = 2000;
void centKeyClientEnableLogSystem(void) {
- CentralKeyManager::Singleton<CentralKeyManager::Log::LogSystem>::Instance().SetTag("CENT_KEY_CLIENT");
+ CKM::Singleton<CKM::Log::LogSystem>::Instance().SetTag("CENT_KEY_CLIENT");
}
int waitForSocket(int sock, int event, int timeout) {
} // namespace anonymous
-namespace CentralKeyManager {
+namespace CKM {
int sendToServer(char const * const interface, const RawBuffer &send, MessageBuffer &recv) {
try {
return func();
} catch (MessageBuffer::Exception::Base &e) {
- LogError("CentralKeyManager::MessageBuffer::Exception " << e.DumpToString());
+ LogError("CKM::MessageBuffer::Exception " << e.DumpToString());
} catch (std::exception &e) {
LogError("STD exception " << e.what());
} catch (...) {
return KEY_MANAGER_API_ERROR_UNKNOWN;
}
-} // namespace CentralKeyManager
+} // namespace CKM
static void init_lib(void) __attribute__ ((constructor));
static void init_lib(void)
struct msghdr;
}
-namespace CentralKeyManager {
+namespace CKM {
typedef std::vector<unsigned char> RawBuffer;
*/
int try_catch(const std::function<int()>& func);
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _KEY_MANAGER_CLIENT_
KEY_MANAGER_API
int key_manager_echo(const char *echo, char** oche) {
- using namespace CentralKeyManager;
+ using namespace CKM;
if(echo == NULL){
LogDebug("Echo message is null");
#include <generic-socket-manager.h>
#include <message-buffer.h>
-namespace CentralKeyManager
+namespace CKM
{
struct ConnectionInfo {
InterfaceID interfaceID;
};
typedef std::map<int, ConnectionInfo> ConnectionInfoMap;
-} //namespace CentralKeyManager
+} //namespace CKM
#endif //_CONNECTION_INFO_H_
#include <dpl/log/log.h>
-namespace CentralKeyManager {
+namespace CKM {
void MessageBuffer::Push(const RawBuffer &data) {
m_buffer.AppendCopy(&data[0], data.size());
m_buffer.AppendCopy(bytes, num);
}
-} // namespace CentralKeyManager
+} // namespace CKM
#include <dpl/exception.h>
#include <dpl/serialization.h>
-namespace CentralKeyManager {
+namespace CKM {
typedef std::vector<unsigned char> RawBuffer;
-class MessageBuffer : public CentralKeyManager::IStream {
+class MessageBuffer : public CKM::IStream {
public:
class Exception
{
public:
- DECLARE_EXCEPTION_TYPE(CentralKeyManager::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(CKM::Exception, Base)
DECLARE_EXCEPTION_TYPE(Base, OutOfData)
};
}
size_t m_bytesLeft;
- CentralKeyManager::BinaryQueue m_buffer;
+ CKM::BinaryQueue m_buffer;
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _CENT_KEY_MNG_SOCKET_BUFFER_
#include <protocols.h>
-namespace CentralKeyManager {
+namespace CKM {
char const * const SERVICE_SOCKET_ECHO =
"/tmp/.key-manager-api-echo.sock";
-} // namespace CentralKeyManager
+} // namespace CKM
#ifndef _CENT_KEY_MNG_PROTOCOLS_
#define _CENT_KEY_MNG_PROTOCOLS_
-namespace CentralKeyManager {
+namespace CKM {
extern char const * const SERVICE_SOCKET_ECHO;
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _CENT_KEY_MNG_PROTOCOLS_
#include <dpl/log/log.h>
-namespace CentralKeyManager {
+namespace CKM {
int smack_runtime_check(void)
{
#endif
}
-} // namespace CentralKeyManager
+} // namespace CKM
#ifndef _SMACK_CHECK_H_
#define _SMACK_CHECK_H_
-namespace CentralKeyManager {
+namespace CKM {
/*
* A very simple runtime check for SMACK on the platform
*/
int smack_check(void);
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _SMACK_CHECK_H_
#include <dpl/noreturn.h>
-namespace CentralKeyManager {
+namespace CKM {
// Assertion handler procedure
// Do not call directly
// Always use Assert macro
const char *file,
int line,
const char *function);
-} // namespace CentralKeyManager
+} // namespace CKM
-#define Assert(Condition) do { if (!(Condition)) { CentralKeyManager::AssertProc(#Condition, \
+#define Assert(Condition) do { if (!(Condition)) { CKM::AssertProc(#Condition, \
__FILE__, \
__LINE__, \
__FUNCTION__); \
#include <memory>
#include <list>
-namespace CentralKeyManager {
+namespace CKM {
/**
* Binary queue auto pointer
*/
class Exception
{
public:
- DECLARE_EXCEPTION_TYPE(CentralKeyManager::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(CKM::Exception, Base)
DECLARE_EXCEPTION_TYPE(Base, OutOfData)
};
virtual size_t Write(const BinaryQueue &buffer, size_t bufferSize);
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // CENT_KEY_BINARY_QUEUE_H
#ifndef CENT_KEY_COLORS_H
#define CENT_KEY_COLORS_H
-namespace CentralKeyManager {
+namespace CKM {
namespace Colors {
namespace Text {
extern const char* BOLD_GREEN_BEGIN;
extern const char* BOLD_WHITE_END;
} //namespace Html
} //namespace Colors
-} //namespace CentralKeyManager
+} //namespace CKM
#endif /* CENT_KEY_COLORS_H */
#include <cstdlib>
#include <sstream>
-namespace CentralKeyManager {
+namespace CKM {
void LogUnhandledException(const std::string &str);
void LogUnhandledException(const std::string &str,
const char *filename,
const char *function);
}
-namespace CentralKeyManager {
+namespace CKM {
class Exception
{
private:
{
std::ostringstream message;
message <<
- "\033[1;5;31m\n=== Unhandled CentralKeyManager exception occurred ===\033[m\n\n";
+ "\033[1;5;31m\n=== Unhandled CKM exception occurred ===\033[m\n\n";
message << "\033[1;33mException trace:\033[m\n\n";
message << e.DumpToString();
message << "\033[1;31m\n=== Will now abort ===\033[m\n";
{
std::ostringstream message;
message <<
- "\033[1;5;31m\n=== Unhandled non-CentralKeyManager exception occurred ===\033[m\n\n";
+ "\033[1;5;31m\n=== Unhandled non-CKM exception occurred ===\033[m\n\n";
message << "\033[1;31m\n=== Will now abort ===\033[m\n";
return message.str();
return m_className;
}
};
-} // namespace CentralKeyManager
+} // namespace CKM
#define Try try
Class(const char *path, \
const char *function, \
int line, \
- const CentralKeyManager::Exception & reason, \
+ const CKM::Exception & reason, \
const std::string & message = std::string()) : \
BaseClass(path, function, line, reason, message) \
{ \
#define UNHANDLED_EXCEPTION_HANDLER_BEGIN try
#define UNHANDLED_EXCEPTION_HANDLER_END \
- catch (const CentralKeyManager::Exception &exception) \
+ catch (const CKM::Exception &exception) \
{ \
std::ostringstream msg; \
- msg << CentralKeyManager::Exception::KnownExceptionToString(exception); \
- CentralKeyManager::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
+ msg << CKM::Exception::KnownExceptionToString(exception); \
+ CKM::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
abort(); \
} \
catch (std::exception& e) \
std::ostringstream msg; \
msg << e.what(); \
msg << "\n"; \
- msg << CentralKeyManager::Exception::UnknownExceptionToString(); \
- CentralKeyManager::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
+ msg << CKM::Exception::UnknownExceptionToString(); \
+ CKM::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
abort(); \
} \
catch (...) \
{ \
std::ostringstream msg; \
- msg << CentralKeyManager::Exception::UnknownExceptionToString(); \
- CentralKeyManager::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
+ msg << CKM::Exception::UnknownExceptionToString(); \
+ CKM::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
abort(); \
}
-namespace CentralKeyManager {
+namespace CKM {
namespace CommonException {
/**
* Internal exception definitions
#ifndef CENT_KEY_NONCOPYABLE_H
#define CENT_KEY_NONCOPYABLE_H
-namespace CentralKeyManager {
+namespace CKM {
class Noncopyable
{
private:
Noncopyable();
virtual ~Noncopyable();
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // CENT_KEY_NONCOPYABLE_H
#include <map>
#include <memory>
-namespace CentralKeyManager {
+namespace CKM {
// Abstract data stream buffer
class IStream
{
Deserialize(stream, *map);
}
}; // struct Deserialization
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // CENT_KEY_SERIALIZATION_H
#ifndef CENT_KEY_SINGLETON_H
#define CENT_KEY_SINGLETON_H
-namespace CentralKeyManager {
+namespace CKM {
template<typename Class>
class Singleton :
private Class
static Class &Instance();
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // CENT_KEY_SINGLETON_H
* singleton_safe_impl.h if possible.
*/
-namespace CentralKeyManager {
+namespace CKM {
template<typename Class>
Singleton<Class>& Singleton<Class>::InternalInstance()
{
Singleton<Class>& instance = Singleton<Class>::InternalInstance();
return instance;
}
-} // namespace CentralKeyManager
+} // namespace CKM
#define IMPLEMENT_SINGLETON(Type) \
- template CentralKeyManager::Singleton<Type>&CentralKeyManager::Singleton<Type>::InternalInstance(); \
- template Type & CentralKeyManager::Singleton<Type>::Instance(); \
+ template CKM::Singleton<Type>&CKM::Singleton<Type>::InternalInstance(); \
+ template Type & CKM::Singleton<Type>::Instance(); \
#endif // CENT_KEY_SINGLETON_IMPL_H
#define CENT_KEY_SINGLETON_SAFE_IMPL_H
#define IMPLEMENT_SAFE_SINGLETON(Class) \
- namespace CentralKeyManager { \
+ namespace CKM { \
template<> \
Singleton<Class>&Singleton<Class>::InternalInstance() \
{ \
\
template Singleton<Class>&Singleton<Class>::InternalInstance(); \
template Class & Singleton<Class>::Instance(); \
- } // namespace CentralKeyManager
+ } // namespace CKM
#endif // CENT_KEY_SINGLETON_SAFE_IMPL_H
#include <dpl/exception.h>
#include <cstdlib>
-namespace CentralKeyManager {
+namespace CKM {
void AssertProc(const char *condition,
const char *file,
int line,
{ \
std::ostringstream platformLog; \
platformLog << message; \
- CentralKeyManager::Log::LogSystemSingleton::Instance().Pedantic( \
+ CKM::Log::LogSystemSingleton::Instance().Pedantic( \
platformLog.str().c_str(), \
__FILE__, __LINE__, __FUNCTION__); \
} \
INTERNAL_LOG(
"################################################################################");
INTERNAL_LOG(
- "### CentralKeyManager assertion failed! ###");
+ "### CKM assertion failed! ###");
INTERNAL_LOG(
"################################################################################");
INTERNAL_LOG("### Condition: " << condition);
// Fail with c-library abort
abort();
}
-} // namespace CentralKeyManager
+} // namespace CKM
#include <cstring>
#include <new>
-namespace CentralKeyManager {
+namespace CKM {
BinaryQueue::BinaryQueue() :
m_size(0)
{}
AppendCopyFrom(buffer);
return bufferSize;
}
-} // namespace CentralKeyManager
+} // namespace CKM
#include <stddef.h>
#include <dpl/colors.h>
-namespace CentralKeyManager {
+namespace CKM {
namespace Colors {
namespace Text {
const char* BOLD_GREEN_BEGIN = "\033[1;32m";
const char* BOLD_WHITE_END = "</b></font>";
} //namespace Html
} //namespace Colors
-} //namespace CentralKeyManager
+} //namespace CKM
#include <dpl/log/log.h>
#include <cstdio>
-namespace CentralKeyManager {
+namespace CKM {
Exception* Exception::m_lastException = NULL;
unsigned int Exception::m_exceptionCount = 0;
void (*Exception::m_terminateHandler)() = NULL;
printf("%s\n", msg.str().c_str());
// Logging to dlog
- CentralKeyManager::Log::LogSystemSingleton::Instance().Error(
+ CKM::Log::LogSystemSingleton::Instance().Error(
str.c_str(), filename, line, function);
}
-} // namespace CentralKeyManager
+} // namespace CKM
#include <stddef.h>
#include <dpl/noncopyable.h>
-namespace CentralKeyManager {
+namespace CKM {
Noncopyable::Noncopyable()
{}
Noncopyable::~Noncopyable()
{}
-} // namespace CentralKeyManager
+} // namespace CKM
#ifndef CENT_KEY_ABSTRACT_LOG_PROVIDER_H
#define CENT_KEY_ABSTRACT_LOG_PROVIDER_H
-namespace CentralKeyManager {
+namespace CKM {
namespace Log {
class AbstractLogProvider
{
static const char *LocateSourceFileName(const char *filename);
};
}
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // CENT_KEY_ABSTRACT_LOG_PROVIDER_H
#include <memory>
#include <string>
-namespace CentralKeyManager {
+namespace CKM {
namespace Log {
class DLOGLogProvider :
public AbstractLogProvider
};
} // namespace Log
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // CENT_KEY_DLOG_LOG_PROVIDER_H
#include <sstream>
#include <list>
-namespace CentralKeyManager {
+namespace CKM {
namespace Log {
/**
- * CentralKeyManager log system
+ * CKM log system
*
* To switch logs into old style, export
* DPL_USE_OLD_STYLE_LOGS before application start
*/
typedef Singleton<LogSystem> LogSystemSingleton;
}
-} // namespace CentralKeyManager
+} // namespace CKM
//
// Log support
/* avoid warnings about unused variables */
#define DPL_MACRO_DUMMY_LOGGING(message, function) \
do { \
- CentralKeyManager::Log::NullStream ns; \
+ CKM::Log::NullStream ns; \
ns << message; \
} while (0)
#define DPL_MACRO_FOR_LOGGING(message, function) \
do \
{ \
- if (CentralKeyManager::Log::LogSystemSingleton::Instance().IsLoggingEnabled()) \
+ if (CKM::Log::LogSystemSingleton::Instance().IsLoggingEnabled()) \
{ \
std::ostringstream platformLog; \
platformLog << message; \
- CentralKeyManager::Log::LogSystemSingleton::Instance().function( \
+ CKM::Log::LogSystemSingleton::Instance().function( \
platformLog.str().c_str(), \
__FILE__, __LINE__, __FUNCTION__); \
} \
#include <dpl/log/abstract_log_provider.h>
#include <string>
-namespace CentralKeyManager {
+namespace CKM {
namespace Log {
class OldStyleLogProvider :
public AbstractLogProvider
const char *function);
};
}
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // CENT_KEY_OLD_STYLE_LOG_PROVIDER_H
#define UNUSED __attribute__((unused))
-namespace CentralKeyManager {
+namespace CKM {
namespace Log {
void AbstractLogProvider::SetTag(const char *tag UNUSED) {}
#define UNUSED __attribute__((unused))
-namespace CentralKeyManager {
+namespace CKM {
namespace Log {
std::string DLOGLogProvider::FormatMessage(const char *message,
const char *filename,
int line,
const char *function)
{
- SLOG(LOG_DEBUG, "CentralKeyManager", "%s", FormatMessage(message,
+ SLOG(LOG_DEBUG, "CKM", "%s", FormatMessage(message,
filename,
line,
function).c_str());
}
} // nemespace Log
-} // namespace CentralKeyManager
+} // namespace CKM
#include <dpl/log/dlog_log_provider.h>
#include <dpl/log/old_style_log_provider.h>
-IMPLEMENT_SINGLETON(CentralKeyManager::Log::LogSystem)
+IMPLEMENT_SINGLETON(CKM::Log::LogSystem)
-namespace CentralKeyManager {
+namespace CKM {
namespace Log {
namespace // anonymous
{
}
}
-} // namespace CentralKeyManager
+} // namespace CKM
#include <unistd.h>
#include <dlog.h>
-namespace CentralKeyManager {
+namespace CKM {
namespace Log {
namespace // anonymous
{
-using namespace CentralKeyManager::Colors::Text;
+using namespace CKM::Colors::Text;
const char *DEBUG_BEGIN = GREEN_BEGIN;
const char *DEBUG_END = GREEN_END;
const char *INFO_BEGIN = CYAN_BEGIN;
}
}
-} // namespace CentralKeyManager
+} // namespace CKM
#ifndef _CENT_KEY_MNG_GENERIC_EVENT_
#define _CENT_KEY_MNG_GENERIC_EVENT_
-namespace CentralKeyManager {
+namespace CKM {
struct GenericEvent {
virtual ~GenericEvent(){}
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _CENT_KEY_MNG_GENERIC_EVENT_
#include <generic-socket-manager.h>
-namespace CentralKeyManager {
+namespace CKM {
-} // namespace CentralKeyManager
+} // namespace CKM
struct msghdr;
} // extern "C"
-namespace CentralKeyManager {
+namespace CKM {
typedef int InterfaceID;
virtual ~GenericSocketManager(){}
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _CENT_KEY_MNG_GENERIC_SERVICE_MANAGER_
#include <echo.h>
-IMPLEMENT_SAFE_SINGLETON(CentralKeyManager::Log::LogSystem);
+IMPLEMENT_SAFE_SINGLETON(CKM::Log::LogSystem);
#define REGISTER_SOCKET_SERVICE(manager, service) \
registerSocketService<service>(manager, #service)
template<typename T>
-void registerSocketService(CentralKeyManager::SocketManager &manager, const std::string& serviceName)
+void registerSocketService(CKM::SocketManager &manager, const std::string& serviceName)
{
T *service = NULL;
try {
service->Create();
manager.RegisterSocketService(service);
service = NULL;
- } catch (const CentralKeyManager::Exception &exception) {
+ } catch (const CKM::Exception &exception) {
LogError("Error in creating service " << serviceName <<
", details:\n" << exception.DumpToString());
} catch (const std::exception& e) {
UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
- CentralKeyManager::Singleton<CentralKeyManager::Log::LogSystem>::Instance().SetTag("CENT_KEY_MNG");
+ CKM::Singleton<CKM::Log::LogSystem>::Instance().SetTag("CENT_KEY_MNG");
sigset_t mask;
sigemptyset(&mask);
}
LogInfo("Start!");
- CentralKeyManager::SocketManager manager;
+ CKM::SocketManager manager;
- auto echoService = new CentralKeyManager::EchoService;
+ auto echoService = new CKM::EchoService;
echoService->Create();
manager.RegisterSocketService(echoService);
const size_t SIZE_T_MAX = std::numeric_limits<size_t>::max();
} // namespace anonymous
-namespace CentralKeyManager {
+namespace CKM {
int util_smack_label_is_valid(const char *smack_label)
{
return exe;
}
-} // namespace CentralKeyManager
+} // namespace CKM
#include <sys/types.h>
-namespace CentralKeyManager {
+namespace CKM {
int util_smack_label_is_valid(const char *smack_label);
char *read_exe_path_from_proc(pid_t pid);
-} // namespace CentralKeyManager
+} // namespace CKM
#endif /*CENT_KEY_MNG_UTIL_H*/
#define DEFINE_THREAD_EVENT(eventType) \
void Event(const eventType &event) { \
- CentralKeyManager::ServiceThread<ParentClassName>:: \
+ CKM::ServiceThread<ParentClassName>:: \
Event(event, \
this, \
&ParentClassName::EventInternal##eventType); \
#define DECLARE_THREAD_EVENT(eventType, methodName) \
void Event(const eventType &event) { \
- CentralKeyManager::ServiceThread<ParentClassName>:: \
+ CKM::ServiceThread<ParentClassName>:: \
Event(event, \
this, \
&ParentClassName::methodName); \
}
-namespace CentralKeyManager {
+namespace CKM {
template <class Service>
class ServiceThread {
bool m_quit;
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _CENT_KEY_SERVICE_THREAD_
} // namespace anonymous
-namespace CentralKeyManager {
+namespace CKM {
struct DummyService : public GenericSocketService {
ServiceDescriptionVector GetServiceDescription() {
FD_CLR(sock, &m_writeSet);
}
-} // namespace CentralKeyManager
+} // namespace CKM
#include <generic-socket-manager.h>
-namespace CentralKeyManager {
+namespace CKM {
class SocketManager : public GenericSocketManager {
public:
class Exception {
public:
- DECLARE_EXCEPTION_TYPE(CentralKeyManager::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(CKM::Exception, Base)
DECLARE_EXCEPTION_TYPE(Base, InitFailed)
};
SocketManager();
std::priority_queue<Timeout> m_timeoutQueue;
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _CENT_KEY_MNG_SOCKET_MANAGER_
#include <protocols.h>
#include <echo.h>
-namespace CentralKeyManager {
+namespace CKM {
GenericSocketService::ServiceDescriptionVector EchoService::GetServiceDescription() {
return ServiceDescriptionVector {{SERVICE_SOCKET_ECHO, "*"}};
LogDebug("CloseEvent. ConnectionID: " << event.connectionID.sock);
}
-} // namespace CentralKeyManager
+} // namespace CKM
#include <message-buffer.h>
-namespace CentralKeyManager {
+namespace CKM {
class EchoService
- : public CentralKeyManager::GenericSocketService
- , public CentralKeyManager::ServiceThread<EchoService>
+ : public CKM::GenericSocketService
+ , public CKM::ServiceThread<EchoService>
{
public:
ServiceDescriptionVector GetServiceDescription();
void close(const CloseEvent &event);
};
-} // namespace CentralKeyManager
+} // namespace CKM
#endif // _SECURITY_SERVER_ECHO_