inline LmScreen::LmScreen(unsigned int id, const char* deviceName)
: m_id(id)
{
- m_deviceName = new char[strlen(deviceName)];
+ m_deviceName = new char[strlen(deviceName) + 1];
strcpy(m_deviceName, deviceName);
}
createComplexScene(m_pScene);
- p = (Point) {INPUT_STATE_MOTION, 42, 43};
+ p.state = INPUT_STATE_MOTION;
+ p.x = 42;
+ p.x = 43;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(surf, (Surface*)NULL); // No focus, so NULL is returned
EXPECT_EQ(42, p.x); // Coordinates are kept unchanged
EXPECT_EQ(43, p.y);
- p = (Point) {INPUT_STATE_RELEASED, 44, 45};
+ p.state = INPUT_STATE_RELEASED;
+ p.x = 44;
+ p.x = 45;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ((Surface*)NULL, surf);
EXPECT_EQ(44, p.x);
EXPECT_EQ(45, p.y);
- p = (Point) {INPUT_STATE_OTHER, 46, 47};
+ p.state = INPUT_STATE_OTHER;
+ p.x = 46;
+ p.x = 47;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ((Surface*)NULL, surf);
EXPECT_EQ(46, p.x);
EXPECT_EQ(47, p.y);
// Pressed somewhere in Content
- p = (Point) {INPUT_STATE_PRESSED, 700, 400};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 700;
+ p.x = 400;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_NE(surf, (Surface*)NULL); // Pressed under a surface, so not NULL is returned
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID()); // Make sure the elected surface is the appropriate one
createComplexScene(m_pScene);
// Pressed somewhere in Content
- p = (Point) {INPUT_STATE_PRESSED, 700, 400};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 700;
+ p.x = 400;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_NE(surf, (Surface*)NULL);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
EXPECT_NE(400, p.y);
// motion somewhere outside of Content
- p = (Point) {INPUT_STATE_MOTION, 10, 20};
+ p.state = INPUT_STATE_MOTION;
+ p.x = 10;
+ p.x = 20;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
EXPECT_NE(10, p.x);
EXPECT_NE(20, p.y);
// motion somewhere outside of Content
- p = (Point) {INPUT_STATE_MOTION, 0, 200};
+ p.state = INPUT_STATE_MOTION;
+ p.x = 0;
+ p.x = 200;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
EXPECT_NE(0, p.x);
EXPECT_NE(200, p.y);
// release somewhere outside of Content
- p = (Point) {INPUT_STATE_RELEASED, 500, 30};
+ p.state = INPUT_STATE_RELEASED;
+ p.x = 500;
+ p.x = 30;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
EXPECT_NE(500, p.x);
// Let's do some click on the background layer
// Pressed somewhere in Status bar
- p = (Point) {INPUT_STATE_PRESSED, 100, 30};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 30;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY1_SURF_STATUSBAR_ID, surf->getID());
EXPECT_EQ(100, p.x);
EXPECT_EQ(30, p.y);
// Motion somewhere outside of Status bar
- p = (Point) {INPUT_STATE_MOTION, 500, 500};
+ p.state = INPUT_STATE_MOTION;
+ p.x = 500;
+ p.x = 500;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY1_SURF_STATUSBAR_ID, surf->getID());
// Released somewhere outside of Status bar
- p = (Point) {INPUT_STATE_RELEASED, 800, 480};
+ p.state = INPUT_STATE_RELEASED;
+ p.x = 800;
+ p.x = 480;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY1_SURF_STATUSBAR_ID, surf->getID());
}
m_pPopup->setNativeContent(DUMMY_NATIVE_CONTENT);
// (100,225) is in the middle of the popup
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_POPUP_ID, surf->getID());
// popup not visible
m_pPopup->setVisibility(false);
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
// popup visible and small opacity
m_pPopup->setVisibility(true);
m_pPopup->setOpacity(0.1);
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_POPUP_ID, surf->getID());
// popup visible and no opacity
m_pPopup->setVisibility(true);
m_pPopup->setOpacity(0);
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
m_pPopup->setVisibility(true);
m_pPopup->setOpacity(1);
m_pPopup->removeNativeContent();
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
layerTop = m_pScene->getLayer(CPLX_SCREEN_LAY2_ID);
// Pressed somewhere in Content
- p = (Point) {INPUT_STATE_PRESSED, 700, 400};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 700;
+ p.x = 400;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_NE(surf, (Surface*)NULL);
EXPECT_EQ(CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
// No visibility
layerTop->setVisibility(false);
// Pressed somewhere in Content
- p = (Point) {INPUT_STATE_PRESSED, 700, 400};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 700;
+ p.x = 400;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_NE(surf, (Surface*)NULL);
EXPECT_EQ(CPLX_SCREEN_LAY1_SURF_BACKGROUND_ID, surf->getID());
layerTop->setVisibility(true);
layerTop->setOpacity(0);
// Pressed somewhere in Content
- p = (Point) {INPUT_STATE_PRESSED, 700, 400};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 700;
+ p.x = 400;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_NE(surf, (Surface*)NULL);
EXPECT_EQ(CPLX_SCREEN_LAY1_SURF_BACKGROUND_ID, surf->getID());
// Let send a first pointer pressed to get it's focus
// Since no transformation, screen wide (10,20) coordinate should become ... (10,20) in the surface coordinate system
- p = (Point) {INPUT_STATE_PRESSED, 10, 20};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 10;
+ p.x = 20;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(10, p.x);
// Let's move newSurf by 10 to the left and 100 down and retry the same test
newSurf->setDestinationRegion(Rectangle(10, 100, sw, sh));
- p = (Point) {INPUT_STATE_PRESSED, 10, 150};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 10;
+ p.x = 150;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(0, p.x); // 10 global is 0 local
EXPECT_EQ(50, p.y); // 150 global is 50 local
// motion at (0,40) global should still elect newSurf at (-10,-60)
- p = (Point) {INPUT_STATE_MOTION, 0, 40};
+ p.state = INPUT_STATE_MOTION;
+ p.x = 0;
+ p.x = 40;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(-10, p.x); // 10 global is 0 local
EXPECT_EQ(-60, p.y);
// release at (800,100) global should still elect newSurf at (790,0)
- p = (Point) {INPUT_STATE_RELEASED, 800, 100};
+ p.state = INPUT_STATE_RELEASED;
+ p.x = 800;
+ p.x = 100;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(790, p.x); // 10 global is 0 local
newSurf->setSourceRegion(Rectangle(50, 50, 50, 50));
newSurf->setDestinationRegion(Rectangle(0, 0, 50, 50));
- p = (Point) {INPUT_STATE_PRESSED, 10, 20};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 10;
+ p.x = 20;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(60, p.x);
// Let's move newSurf by 10 to the left and 100 down and retry the same test
newSurf->setDestinationRegion(Rectangle(10, 100, 50, 50));
- p = (Point) {INPUT_STATE_PRESSED, 20, 120};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 20;
+ p.x = 120;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(60, p.x);
EXPECT_EQ(70, p.y);
// motion at (10,40) global should still elect newSurf at (40,-10)
- p = (Point) {INPUT_STATE_MOTION, 0, 40};
+ p.state = INPUT_STATE_MOTION;
+ p.x = 0;
+ p.x = 40;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(40, p.x); // 10 global is 0 local
newSurf->setSourceRegion(Rectangle(0, 0, sw/2, sh/2));
newSurf->setDestinationRegion(Rectangle(0, 0, sw, sh));
- p = (Point) {INPUT_STATE_PRESSED, 10, 20};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 10;
+ p.x = 20;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(5, p.x);
// Scale & Move newSurf
newSurf->setDestinationRegion(Rectangle(10, 100, sw, sh));
- p = (Point) {INPUT_STATE_PRESSED, 20, 120};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 20;
+ p.x = 120;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(5, p.x);
// Scale & Move & Crope surface
newSurf->setSourceRegion(Rectangle(10, 10, sw/2, sh/2));
- p = (Point) {INPUT_STATE_PRESSED, 30, 140};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 30;
+ p.x = 140;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ(sid, surf->getID());
EXPECT_EQ(20, p.x);
pPopup->setVisibility(true);
// (100,225) is in the middle of the popup
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ((uint)CPLX_SCREEN_LAY2_SURF_POPUP_ID, surf->getID());
pPopup->updateInputEventAcceptanceFrom(INPUT_DEVICE_POINTER, false);
// (100,225) is in the middle of the popup, but popup now refuse pointer event
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_NE((uint)CPLX_SCREEN_LAY2_SURF_POPUP_ID, surf->getID());
EXPECT_EQ((uint)CPLX_SCREEN_LAY2_SURF_CONTENT_ID, surf->getID());
// (100,225) is in the middle of the popup, but popup refuse pointer event
// so event should be dispatched to Content, but content now refuse pointer event
// Finally event should be dispatched to Background of Layer 1
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_EQ((uint)CPLX_SCREEN_LAY1_SURF_BACKGROUND_ID, surf->getID());
// (100,225) is in the middle of the popup.
// popup -> content -> Background -> NULL
- p = (Point) {INPUT_STATE_PRESSED, 100, 225};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 100;
+ p.x = 225;
+
surf = m_pInputManager->reportPointerEvent(p);
EXPECT_FALSE(surf);
// to guarentee good performances. So let's do this in the test.
pv.reserve(10);
pv.resize(4);
- pv[0] = (Point) {INPUT_STATE_MOTION, 100, 50};
- pv[1] = (Point) {INPUT_STATE_MOTION, 800, 480};
- pv[2] = (Point) {INPUT_STATE_MOTION, 300, 200};
- pv[3] = (Point) {INPUT_STATE_MOTION, 0, 10};
+
+ pv[0].state = INPUT_STATE_MOTION;
+ pv[0].x = 100;
+ pv[0].y = 50;
+
+ pv[1].state = INPUT_STATE_MOTION;
+ pv[1].x = 800;
+ pv[1].y = 480;
+
+ pv[2].state = INPUT_STATE_MOTION;
+ pv[2].x = 300;
+ pv[2].y = 200;
+
+ pv[3].state = INPUT_STATE_MOTION;
+ pv[3].x = 0;
+ pv[3].y = 10;
// Pressed somewhere in Content to set the pointer focus
- p = (Point) {INPUT_STATE_PRESSED, 700, 400};
+ p.state = INPUT_STATE_PRESSED;
+ p.x = 700;
+ p.y = 400;
+
m_pInputManager->reportPointerEvent(p);
// set popup not visible
#ifdef __cplusplus
extern "C" {
-#endif // __cplusplus
+#endif /* __cplusplus */
#include "ilm_types.h"
/**
ilmErrorTypes ilm_getPropertiesOfScreen(t_ilm_display screenID, struct ilmScreenProperties* pScreenProperties);
#ifdef __cplusplus
-} //
-#endif // __cplusplus
+} /**/
+#endif /* __cplusplus */
#endif /* _ILM_CLIENT_H_ */
#include <sys/types.h>
#include <unistd.h>
-
-//=============================================================================
-// global settings
-//=============================================================================
-const int gReceiveTimeout = -1; // in ms, negative value for infinite
-const int gResponseTimeout = 500; // in ms
-
-// must be same as GraphicalObject::INVALID_ID, but this is defined in C++
-// and can not be used here
+/*
+ *=============================================================================
+ * global settings
+ *=============================================================================
+ */
+const int gReceiveTimeout = -1; /* in ms, negative value for infinite */
+const int gResponseTimeout = 500; /* in ms */
+
+/*
+ * must be same as GraphicalObject::INVALID_ID, but this is defined in C++
+ * and can not be used here
+ */
#define INVALID_ID 0xFFFFFFFF
-// queue names for incoming notifications and messages
+/* queue names for incoming notifications and messages */
#define NOTIFICATION_QUEUE_NAME "/ilmClient%dNotification"
#define INCOMING_QUEUE_NAME "/ilmClient%dIncoming"
-//=============================================================================
-// global vars
-//=============================================================================
-extern char *__progname; // automatically gets assigned argv[0]
+/*
+ *=============================================================================
+ * global vars
+ *=============================================================================
+ */
+extern char *__progname; /* automatically gets assigned argv[0] */
static struct IpcModule gIpcModule;
static t_ilm_bool gInitialized = ILM_FALSE;
-//=============================================================================
-// notification management
-//=============================================================================
+/*
+ *=============================================================================
+ * notification management
+ *=============================================================================
+ */
#define MAX_CALLBACK_COUNT 64
-struct
+static struct
{
t_ilm_uint id;
layerNotificationFunc callback;
-} static gLayerNotificationCallbacks[MAX_CALLBACK_COUNT];
+} gLayerNotificationCallbacks[MAX_CALLBACK_COUNT];
-struct
+static struct
{
t_ilm_uint id;
surfaceNotificationFunc callback;
-} static gSurfaceNotificationCallbacks[MAX_CALLBACK_COUNT];
+} gSurfaceNotificationCallbacks[MAX_CALLBACK_COUNT];
void initNotificationCallbacks()
{
{
int i = 0;
- // try to overwrite existing entry for layer id
+ /* try to overwrite existing entry for layer id */
for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
{
if (gLayerNotificationCallbacks[i].id == layer)
return ILM_FALSE;
}
- // find free slot and store callback
+ /* find free slot and store callback */
for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
{
if (gLayerNotificationCallbacks[i].id == INVALID_ID)
{
int i = 0;
- // try to overwrite existing entry for layer id
+ /* try to overwrite existing entry for layer id */
for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
{
if (gSurfaceNotificationCallbacks[i].id == surface)
return ILM_FALSE;
}
- // find free slot and store callback
+ /* find free slot and store callback */
for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
{
if (gSurfaceNotificationCallbacks[i].id == INVALID_ID)
}
}
-//=============================================================================
-// handling of internal notification thread for dispatching notifications
-// Note: notification callbacks may be blocked by client, but receive thread
-// must not be blocked
-//=============================================================================
+
+/*
+ *=============================================================================
+ * handling of internal notification thread for dispatching notifications
+ * Note: notification callbacks may be blocked by client, but receive thread
+ * must not be blocked
+ *=============================================================================
+ */
void* notificationThreadLoop(void* param)
{
- (void)param;
-
t_ilm_message notification;
+ (void)param;
+
while (-1 != mq_receive(notificationMqRead, (char*)¬ification, sizeof(notification), NULL))
{
t_ilm_const_string name = gIpcModule.getMessageName(notification);
- // this depends on message name, but it is fast
+ /* this depends on message name, but it is fast */
if ('L' == name[15])
{
t_ilm_uint id;
t_ilm_uint mask;
struct ilmLayerProperties properties;
+ layerNotificationFunc func;
gIpcModule.getUint(notification, &id);
gIpcModule.getUint(notification, &mask);
gIpcModule.getUint(notification, &properties.chromaKeyBlue);
gIpcModule.getInt(notification, &properties.creatorPid);
- layerNotificationFunc func = getLayerNotificationCallback(id);
+ func = getLayerNotificationCallback(id);
if (func)
{
(*func)(id, &properties, mask);
t_ilm_uint id;
t_ilm_uint mask;
struct ilmSurfaceProperties properties;
+ surfaceNotificationFunc func;
gIpcModule.getUint(notification, &id);
gIpcModule.getUint(notification, &mask);
gIpcModule.getUint(notification, &properties.chromaKeyBlue);
gIpcModule.getInt(notification, &properties.creatorPid);
- surfaceNotificationFunc func = getSurfaceNotificationCallback(id);
+ func = getSurfaceNotificationCallback(id);
if (func)
{
(*func)(id, &properties, mask);
return NULL;
}
-//=============================================================================
-// handling of internal receive thread for event handling
-//=============================================================================
+
+/*
+ *=============================================================================
+ * handling of internal receive thread for event handling
+ *=============================================================================
+ */
void* receiveThreadLoop(void* param)
{
- (void)param;
-
t_ilm_bool running = ILM_TRUE;
+ (void)param;
+
while (running)
{
t_ilm_message message = gIpcModule.receive(gReceiveTimeout);
void calculateTimeout(struct timeval* currentTime, int giventimeout, struct timespec* timeout)
{
- // nanoseconds is old value in nanoseconds + the given milliseconds as nanoseconds
+ /* nanoseconds is old value in nanoseconds + the given milliseconds as nanoseconds */
t_ilm_ulong newNanoSeconds = currentTime->tv_usec * 1000 + giventimeout * (1000 * 1000);
- // only use non full seconds, otherwise overflow!
+ /* only use non full seconds, otherwise overflow! */
timeout->tv_nsec = newNanoSeconds % (1000000000);
- // new seconds are old seconds + full seconds from new nanoseconds part
+ /* new seconds are old seconds + full seconds from new nanoseconds part */
timeout->tv_sec = currentTime->tv_sec + (newNanoSeconds / 1000000000 );
}
t_ilm_bool sendAndWaitForResponse(t_ilm_message command, t_ilm_message* response, int timeoutInMs)
{
+ t_ilm_message_type responseType = IpcMessageTypeNone;
+
(void)timeoutInMs;
*response = 0;
- t_ilm_message_type responseType = IpcMessageTypeNone;
- // send / receive may only be performed by one thread at a time
+ /* send / receive may only be performed by one thread at a time */
pthread_mutex_lock(&gSendReceiveLock);
if (gIpcModule.sendToService(command))
return (*response && (IpcMessageTypeCommand == responseType));
}
-//=============================================================================
-// implementation
-//=============================================================================
+
+/*
+ *=============================================================================
+ * implementation
+ *=============================================================================
+ */
ilmErrorTypes ilm_init()
{
ilmErrorTypes result = ILM_FAILED;
+ t_ilm_message response = 0;
+ t_ilm_message command;
if (gInitialized)
{
if (gIpcModule.initClientMode())
{
- result = ILM_SUCCESS;
+ char mqName[30];
+ pthread_attr_t notificationThreadAttributes;
+ int ret;
- struct mq_attr mqAttr =
- {
- .mq_maxmsg = 4,
- .mq_msgsize = sizeof(t_ilm_message),
- .mq_flags = 0, //O_NONBLOCK,
- .mq_curmsgs = 0
- };
+ struct mq_attr mqAttr;
+ mqAttr.mq_maxmsg = 4;
+ mqAttr.mq_msgsize = sizeof(t_ilm_message);
+ mqAttr.mq_flags = 0; /*O_NONBLOCK, */
+ mqAttr.mq_curmsgs = 0;
+
+ result = ILM_SUCCESS;
- char mqName[30];
snprintf(mqName, sizeof(mqName), NOTIFICATION_QUEUE_NAME, getpid());
notificationMqWrite = mq_open(mqName, O_WRONLY | O_CREAT, 0600, &mqAttr);
notificationMqRead = mq_open(mqName, O_RDONLY);
- mq_unlink(mqName); // is destroyed on closed filedescriptor
+ mq_unlink(mqName); /* is destroyed on closed filedescriptor */
snprintf(mqName, sizeof(mqName), INCOMING_QUEUE_NAME, getpid());
incomingMqWrite = mq_open(mqName, O_WRONLY | O_CREAT, 0600, &mqAttr);
incomingMqRead = mq_open(mqName, O_RDONLY);
- mq_unlink(mqName); // is destroyed on closed filedescriptor
+ mq_unlink(mqName); /* is destroyed on closed filedescriptor */
if ((mqd_t)-1 == notificationMqRead || (mqd_t)-1 == notificationMqWrite)
{
pthread_mutex_init(&gSendReceiveLock, NULL);
- pthread_attr_t notificationThreadAttributes;
pthread_attr_init(¬ificationThreadAttributes);
pthread_attr_setdetachstate(¬ificationThreadAttributes,
PTHREAD_CREATE_JOINABLE);
- int ret = pthread_create(&gReceiveThread,
+ ret = pthread_create(&gReceiveThread,
¬ificationThreadAttributes,
receiveThreadLoop,
NULL);
return result;
}
- t_ilm_message response = 0;
- t_ilm_message command = gIpcModule.createMessage("ServiceConnect");
+ command = gIpcModule.createMessage("ServiceConnect");
if (command
&& gIpcModule.appendUint(command, pid)
&& gIpcModule.appendString(command, __progname)
ilmErrorTypes ilm_destroy()
{
ilmErrorTypes result = ILM_FAILED;
+ void* threadReturnValue = NULL;
t_ilm_message response = 0;
t_ilm_message command = gIpcModule.createMessage("ServiceDisconnect");
gIpcModule.destroyMessage(response);
gIpcModule.destroyMessage(command);
- // cancel worker threads
- void* threadReturnValue = NULL;
-
+ /* cancel worker threads */
pthread_cancel(gReceiveThread);
pthread_cancel(gNotificationThread);
{
t_ilm_bool comResult = ILM_TRUE;
- // Checking pColor has a content, otherwise chromakey is disabled
+ /* Checking pColor has a content, otherwise chromakey is disabled */
if (pColor)
{
const t_ilm_uint number = 3;
{
t_ilm_bool comResult = ILM_TRUE;
- // Checking pColor has a content, otherwise chromakey is disabled
+ /* Checking pColor has a content, otherwise chromakey is disabled */
if (pColor)
{
const t_ilm_uint number = 3;
ilmErrorTypes ilm_layerAddNotification(t_ilm_layer layer, layerNotificationFunc callback)
{
ilmErrorTypes returnValue = ILM_FAILED;
+ t_ilm_message response;
+ t_ilm_message command;
if (findLayerCallback(layer))
{
return ILM_ERROR_INVALID_ARGUMENTS;
}
- t_ilm_message response = 0;
- t_ilm_message command = gIpcModule.createMessage("LayerAddNotification");
+ response = 0;
+ command = gIpcModule.createMessage("LayerAddNotification");
if (command
&& gIpcModule.appendUint(command, layer)
&& sendAndWaitForResponse(command, &response, gResponseTimeout))
ilmErrorTypes ilm_layerRemoveNotification(t_ilm_layer layer)
{
ilmErrorTypes returnValue = ILM_FAILED;
+ t_ilm_message response;
+ t_ilm_message command;
if (!findLayerCallback(layer))
{
return ILM_ERROR_INVALID_ARGUMENTS;
}
- t_ilm_message response = 0;
- t_ilm_message command = gIpcModule.createMessage("LayerRemoveNotification");
+ response = 0;
+ command = gIpcModule.createMessage("LayerRemoveNotification");
if (command
&& gIpcModule.appendUint(command, layer)
&& sendAndWaitForResponse(command, &response, gResponseTimeout))
ilmErrorTypes ilm_surfaceAddNotification(t_ilm_surface surface, surfaceNotificationFunc callback)
{
ilmErrorTypes returnValue = ILM_FAILED;
+ t_ilm_message response;
+ t_ilm_message command;
if (findSurfaceCallback(surface))
{
return ILM_ERROR_INVALID_ARGUMENTS;
}
- t_ilm_message response = 0;
- t_ilm_message command = gIpcModule.createMessage("SurfaceAddNotification");
+ response = 0;
+ command = gIpcModule.createMessage("SurfaceAddNotification");
if (command
&& gIpcModule.appendUint(command, surface)
&& sendAndWaitForResponse(command, &response, gResponseTimeout))
ilmErrorTypes ilm_surfaceRemoveNotification(t_ilm_surface surface)
{
ilmErrorTypes returnValue = ILM_FAILED;
+ t_ilm_message response;
+ t_ilm_message command;
if (!findSurfaceCallback(surface))
{
return ILM_ERROR_INVALID_ARGUMENTS;
}
- t_ilm_message response = 0;
- t_ilm_message command = gIpcModule.createMessage("SurfaceRemoveNotification");
+ response = 0;
+ command = gIpcModule.createMessage("SurfaceRemoveNotification");
if (command
&& gIpcModule.appendUint(command, surface)
&& sendAndWaitForResponse(command, &response, gResponseTimeout))
&& command
&& gIpcModule.appendUint(command, screenID)
&& sendAndWaitForResponse(command, &response, gResponseTimeout)
- && gIpcModule.getUintArray(response, &pScreenProperties->layerIds, &pScreenProperties->layerCount)
+ && gIpcModule.getUintArray(response, &pScreenProperties->layerIds, (int*)(&pScreenProperties->layerCount))
&& gIpcModule.getUint(response, &pScreenProperties->harwareLayerCount)
&& gIpcModule.getUint(response, &pScreenProperties->screenWidth)
&& gIpcModule.getUint(response, &pScreenProperties->screenHeight))
* Run a set of effects on the rendered scene depending on the parameter.
* The function accepts values in range 0-4
*/
-void demo(int mode);
+void demo(t_ilm_uint mode);
//=============================================================================
template<typename T> string getPrimitiveType(T* var)
{
+ (void) var;//suppress warning: unsued variable
T var2=0;
return getPrimitiveType(var2) + "*";
}
template<> string getPrimitiveType(bool var)
{
+ (void) var;//suppress warning: unsued variable
return "bool";
}
template<> string getPrimitiveType(char var)
{
+ (void) var;//suppress warning: unsued variable
return "char";
}
template<> string getPrimitiveType(signed char var)
{
+ (void) var;//suppress warning: unsued variable
return "signed char";
}
template<> string getPrimitiveType(unsigned char var)
{
+ (void) var;//suppress warning: unsued variable
return "unsigned char";
}
template<> string getPrimitiveType(wchar_t var)
{
+ (void) var;//suppress warning: unsued variable
return "wchar_t";
}
template<> string getPrimitiveType(short int var)
{
+ (void) var;//suppress warning: unsued variable
return "short int";
}
template<> string getPrimitiveType(unsigned short int var)
{
+ (void) var;//suppress warning: unsued variable
return "unsigned short int";
}
template<> string getPrimitiveType(long int var)
{
+ (void) var;//suppress warning: unsued variable
return "long int";
}
template<> string getPrimitiveType(unsigned long int var)
{
+ (void) var;//suppress warning: unsued variable
return "unsigned long int";
}
template<> string getPrimitiveType(int var)
{
+ (void) var;//suppress warning: unsued variable
return "int";
}
template<> string getPrimitiveType(unsigned int var)
{
+ (void) var;//suppress warning: unsued variable
return "unsigned int";
}
template<> string getPrimitiveType(float var)
{
+ (void) var;//suppress warning: unsued variable
return "float";
}
template<> string getPrimitiveType(double var)
{
+ (void) var;//suppress warning: unsued variable
return "double";
}
template<> string getPrimitiveType(long double var)
{
+ (void) var;//suppress warning: unsued variable
return "long double";
}
template<> string getPrimitiveType(string var)
{
+ (void) var;//suppress warning: unsued variable
return "string";
}
#if defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L
template<> string getPrimitiveType(char16_t var)
{
+ (void) var;//suppress warning: unsued variable
return "char16_t";
}
template<> string getPrimitiveType(char32_t var)
{
+ (void) var;//suppress warning: unsued variable
return "char32_t";
}
template<> string getPrimitiveType(long long int var)
{
+ (void) var;//suppress warning: unsued variable
return "long long int";
}
template<> string getPrimitiveType(unsigned long long int var)
{
+ (void) var;//suppress warning: unsued variable
return "unsigned long long int";
}
#endif
virtual void fromString(string s)
{
-
+ (void) s;//suppress warning: unsued variable
}
virtual string asString()
virtual void toStringMapTree(StringMapTree* parent)
{
-
+ (void) parent;//suppress warning: unsued variable
}
virtual void toGrammarMapTree(StringMapTree* tree)
{
-
+ (void) tree;//suppress warning: unsued variable
}
virtual WrapperHelper* tryClone(string type, StringMapTree* tree)
{
+ (void) type;//suppress warning: unsued variable
+ (void) tree;//suppress warning: unsued variable
return NULL;
}
virtual void addToComplexWrapper(WrapperHelper* wrapper)
{
-
+ (void) wrapper;//suppress warning: unsued variable
}
virtual string getWrapperPrimitiveType()
class class_name;\
ostream& operator<<(ostream& out, class_name& obj )\
{\
+ (void) obj;\
return out;\
}\
istream& operator>>(istream& in, class_name& obj)\
{\
+ (void) obj;\
return in;\
}\
class class_name { \
if (!value)
{
- sscanf(stringVal.c_str(), "0x%x", &value);
+ sscanf(stringVal.c_str(), "0x%x", (unsigned int*) &value);
}
return value;
}
string tag, flag;
char description[300] = "";
- t_ilm_int minDimension = 32;
+ t_ilm_uint minDimension = 32;
tag = "Surface dest width";
if (targetSurfaceProperties.destWidth <= minDimension)
{
t_ilm_layer targetSurfaceLayer = scene.surfaceLayer[targetSurfaceId];
ilmLayerProperties& targetLayerProperties = scene.layerProperties[targetSurfaceLayer];
- t_ilm_int minDimension = 32;
+ t_ilm_uint minDimension = 32;
string tag, flag;
char description[300] = "";
COMMAND("get scene")
//=============================================================================
{
+ (void) input; //suppress warning: unused parameter
printScene();
}
COMMAND("get communicator performance")
//=============================================================================
{
- getCommunicatorPerformance();
+ (void) input; //suppress warning: unused parameter
+ getCommunicatorPerformance();
}
//=============================================================================
COMMAND("get keyboard focus")
//=============================================================================
{
+ (void) input; //suppress warning: unused parameter
getKeyboardFocus();
}
COMMAND("scatter")
//=============================================================================
{
+ (void) input; //suppress warning: unused parameter
scatter();
}
COMMAND("scatter all")
//=============================================================================
{
+ (void) input; //suppress warning: unused parameter
scatterAll();
}
COMMAND("demo <animation_mode>")
//=============================================================================
{
- int mode = (int) input->getInt("animation_mode");
+ t_ilm_uint mode = (t_ilm_uint) input->getUint("animation_mode");
demo(mode);
}
scene.screens = vector<t_ilm_display>(screenArray, screenArray + screenCount);
//layers on each screen
- for (int i = 0; i < screenCount; ++i)
+ for (unsigned int i = 0; i < screenCount; ++i)
{
t_ilm_display screenId = screenArray[i];
pScene->layerScreen.clear();
pScene->layerSurfaces.clear();
pScene->layers.clear();
- pScene->screenHeight;
pScene->screenLayers.clear();
- pScene->screenWidth;
pScene->screens.clear();
pScene->surfaceLayer.clear();
pScene->surfaceProperties.clear();
t_ilm_uint count;
t_ilm_display* screenArray;
ilm_getScreenIDs(&count, &screenArray);
- for(int i = 0 ; i < count ; ++i)
+ for(t_ilm_uint i = 0 ; i < count ; ++i)
{
pScene->screens.push_back(screenArray[i]);
ilm_getScreenResolution(screenArray[0], & pScene->screenWidth, & pScene->screenHeight);
void interruptSignalRestoreScene(int s)
{
+ (void) s;
+
cout<<"LayerManagerControl :Interrupt signal...\n";
if (global_pOriginalScene != NULL)
{
void benchmarkSigHandler(int sig)
{
+ (void) sig;
gBenchmark_running = false;
}
void demoAnimatorDownwards(t_scene_data* pInitialScene, t_scene_data* pDemoScene, bool* pStopDemo)
{
+ (void) pInitialScene; //suppress warning: unused varaible
+
//get rendered surfaces
vector<t_ilm_surface> renderedSurfaces = getSceneRenderOrder(pDemoScene);
}
//make random speeds (in pixel)
- t_ilm_int maxSpeed = 6;
t_ilm_int minSpeed = 2;
- t_ilm_int rangeSpeed = maxSpeed - minSpeed;
srand((unsigned) time(0));
map<t_ilm_surface, t_ilm_int> surfaceSpeed;
surfaceProperties.destY + static_cast<int>(surfaceScale[surface] * surfaceProperties.destHeight));
//make random X position to make surfaces spread in the screen
- int screenWidthMidpoint = pDemoScene->screenWidth / 2;
int surfaceWidth = coordinates.z - coordinates.x;
//make a random X position so that the surface stays totally displayable inside the screen
t_ilm_surface surface = *it;
ilmSurfaceProperties& properties = pDemoScene->surfaceProperties[surface];
tuple4& coordinates = surfaceCoordinates[surface];
- int speed = surfaceSpeed[surface];
//if out: get back to screen
if (coordinates.y >= static_cast<int>(pDemoScene->screenHeight))
void demoAnimatorRandomDirections(t_scene_data* pInitialScene, t_scene_data* pDemoScene, bool* pStopDemo)
{
+ (void) pInitialScene; //suppress warning: unused varaible
+
//get rendered surfaces
vector<t_ilm_surface> renderedSurfaces = getSceneRenderOrder(pDemoScene);
}
//make random speeds (in pixel)
- t_ilm_int maxSpeed = 12;
t_ilm_int minSpeed = 2;
- t_ilm_int rangeSpeed = maxSpeed - minSpeed;
srand((unsigned) time(0));
map<t_ilm_surface, t_ilm_int> surfaceSpeed;
surfaceProperties.destY + static_cast<int>(surfaceScale[surface] * surfaceProperties.destHeight));
//make random X position to make surfaces spread in the screen
- int screenWidthMidpoint = pDemoScene->screenWidth / 2;
int surfaceWidth = coordinates.z - coordinates.x;
//make a random X position so that the surface stays totally displayable inside the screen
void demoAnimatorWaterfall(t_scene_data* pInitialScene, t_scene_data* pDemoScene, bool* pStopDemo)
{
+ (void) pInitialScene; //suppress warning: unused varaible
+
//get rendered surfaces
vector<t_ilm_surface> renderedSurfaces = getSceneRenderOrder(pDemoScene);
}
//make random speeds (in pixel)
- t_ilm_int maxSpeed = 12;
t_ilm_int minSpeed = 2;
- t_ilm_int rangeSpeed = maxSpeed - minSpeed;
srand((unsigned) time(0));
map<t_ilm_surface, t_ilm_int> surfaceSpeed;
surfaceProperties.destY + static_cast<int>(surfaceScale[surface] * surfaceProperties.destHeight));
//make random X position to make surfaces spread in the screen
- int screenWidthMidpoint = pDemoScene->screenWidth / 2;
int surfaceWidth = coordinates.z - coordinates.x;
//make a random X position so that the surface stays totally displayable inside the screen
t_ilm_surface surface = *it;
ilmSurfaceProperties& properties = pDemoScene->surfaceProperties[surface];
tuple4& coordinates = surfaceCoordinates[surface];
- int speed = surfaceSpeed[surface];
//if out: get back to screen
if (coordinates.y >= static_cast<int>(pDemoScene->screenHeight))
void demoAnimatorZooming(t_scene_data* pInitialScene, t_scene_data* pDemoScene, bool* pStopDemo)
{
+ (void) pInitialScene; //suppress warning: unused varaible
+
//get rendered surfaces
vector<t_ilm_surface> renderedSurfaces = getSceneRenderOrder(pDemoScene);
void demoAnimatorCascadedZooming(t_scene_data* pInitialScene, t_scene_data* pDemoScene, bool* pStopDemo)
{
+ (void) pInitialScene; //suppress warning: unused varaible
//get rendered surfaces
vector<t_ilm_surface> renderedSurfaces = getSceneRenderOrder(pDemoScene);
int screenHorizontalMidpoint = pDemoScene->screenWidth / 2;
int screenVerticalMidpoint = pDemoScene->screenHeight / 2;
- for (int i = 0; i < renderedSurfaces.size(); ++i)
+ for (std::size_t i = 0; i < renderedSurfaces.size(); ++i)
{
t_ilm_surface surface = renderedSurfaces[i];
ilmSurfaceProperties& surfaceProperties = pDemoScene->surfaceProperties[surface];
while (!*pStopDemo)
{
- for (int i = 0; i < renderedSurfaces.size(); ++i)
+ for (std::size_t i = 0; i < renderedSurfaces.size(); ++i)
{
t_ilm_surface surface = renderedSurfaces[i];
ilmSurfaceProperties& surfaceProperties = pDemoScene->surfaceProperties[surface];
ilm_commitChanges();
//update render order
t_ilm_surface firstSurface = renderedSurfaces[0];
- for (int j = 1; j < renderedSurfaces.size(); ++j)
+ for (std::size_t j = 1; j < renderedSurfaces.size(); ++j)
{
renderedSurfaces[j - 1] = renderedSurfaces[j];
}
else
{
//just some fancy function math that gives a special effect
- scaleFactors[surface] = (1.0125, i + scaleFactors[surface] * 0.5);
+ scaleFactors[surface] = pow(1.2125, i * 0.85 + scaleFactors[surface] * 0.85);
int change = (int) scaleFactors[surface];
surfaceProperties.destX = max(0, (int) surfaceProperties.destX - change);
}
}
+static vector<t_pDemoAnimatorFunc> animators;
+
void* demoThreadCallback(void* param)
{
//call function on parameters
map<string,void*>* paramMap = (map<string,void*>*) param;
- t_pDemoAnimatorFunc animator = (t_pDemoAnimatorFunc) paramMap->at("pAnimator");
+ int* pAnimatorIndex = (int*) paramMap->at("pAnimatorIndex");
+ t_pDemoAnimatorFunc animator = animators[*pAnimatorIndex];
t_scene_data* pInitialScene = (t_scene_data*) paramMap->at("pInitialScene");
t_scene_data* pDemoScene = (t_scene_data*) paramMap->at("pDemoScene");
bool* pStopDemo= (bool*) paramMap->at("pStopDemo");
} //end of anonymous namespace
-void demo(int mode)
+void demo(t_ilm_uint mode)
{
- vector<t_pDemoAnimatorFunc> animators;
+ animators.clear();
animators.push_back(&demoAnimatorZooming);
animators.push_back(&demoAnimatorCascadedZooming);
animators.push_back(&demoAnimatorDownwards);
animators.push_back(&demoAnimatorWaterfall);
//if valid mode entered
- if (mode >= 0 && mode < animators.size())
+ if (mode < animators.size())
{
//capture initial scene
t_scene_data initialScene;
volatile bool stopDemo = false;
map<string, void*> paramMap;
- paramMap["pAnimator"] = (void*) animators[mode];
+ paramMap["pAnimatorIndex"] = (void*) &mode;
paramMap["pInitialScene"] = (void*) &initialScene;
paramMap["pDemoScene"] = (void*) &demoScene;
paramMap["pStopDemo"] = (void*) &stopDemo;
cout << prefix << "- layer render order: ";
- for (int layerIndex = 0; layerIndex < screenProperties.layerCount; ++layerIndex)
+ for (t_ilm_uint layerIndex = 0; layerIndex < screenProperties.layerCount; ++layerIndex)
{
t_ilm_layer layerid = screenProperties.layerIds[layerIndex];
cout << layerid << "(0x" << hex << layerid << dec << "), ";
int layerCount = 0;
unsigned int* layerArray = NULL;
ilm_getLayerIDs(&layerCount, &layerArray);
- for (unsigned int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
+ for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
{
unsigned int layerid = layerArray[layerIndex];
int surfaceCount = 0;
void scatterHandleUserInput(t_scene_data* pOriginalScene, t_scene_data* pScatteredScene)
{
int n = pScatteredScene->surfaces.size();
- int rows = ceil(sqrt(n));
int cols = ceil(sqrt(n));
//make keys map
stream << prefix + "}";
}
-void importSceneFromXMLHelper(istream& stream, StringMapTree* node)
-{
-
-}
-
-
string decodeEscapesequences(string s)
{
map<string, string> code;
void createSceneContentsHelper(IlmDisplay* pIlmdisplay)
{
- t_ilm_display displayId;
+ t_ilm_display displayId = 0xFFFFFFFF;
pIlmdisplay->get("id", &displayId);
list<IlmLayer*> layerList;
void restoreSceneHelper(IlmSurface* pIlmsurface)
{
- t_ilm_surface surfaceId;
+ t_ilm_surface surfaceId = 0xFFFFFFFF;
pIlmsurface->get("id", &surfaceId);
ilmSurfaceProperties props = getSurfaceProperties(pIlmsurface);
void restoreSceneHelper(IlmLayer* pIlmlayer)
{
- t_ilm_layer layerId;
+ t_ilm_layer layerId = 0xFFFFFFFF;
pIlmlayer->get("id", &layerId);
ilmLayerProperties props = getLayerProperties(pIlmlayer);
if (extension == ".xml")
{
- importSceneFromXMLHelper(stream, &sceneTree);
- cout << "DONE READING XML" << endl;
+// importSceneFromXMLHelper(stream, &sceneTree);
+ cout << "READING XML IS NOT SUPPORTED YET" << endl;
}
else if (extension == ".txt")
{
string replaceAll(string s, string a, string b)
{
- int index = -b.size();
+ std::size_t index = -b.size();
while ((index = s.find(a, index + b.size())) != string::npos)
{
string replaceAll(string s, map<string, string> replacements)
{
- int index = 0;
- for (int i = 0; i < s.size(); ++i)
+ for (std::size_t i = 0; i < s.size(); ++i)
{
for (map<string, string>::iterator it = replacements.begin(); it != replacements.end(); ++it)
{
string replaceAll(string s, char a, char b)
{
- int index = -1;
+ std::size_t index = -1;
while ((index = s.find(a, index + 1)) != string::npos)
{
s.replace(index, 1, string(1, b));
set<string> split(string s, char d)
{
set<string> result;
- int start = 0;
+ std::size_t start = 0;
while (start < s.size() && start != string::npos)
{
start = s.find_first_not_of(d, start);
- int end = s.find(d, start);
+ std::size_t end = s.find(d, start);
result.insert(s.substr(start, end - start));
start = end;
if (width <= height)
{
- glOrtho(-1.0, 1.0, 1.0 / aspectratio, 1.0 / aspectratio, 1.0, -1.0);
+ glOrtho(-1.0f, 1.0f, 1.0f / aspectratio, 1.0f / aspectratio, 1.0f, -1.0f);
}
glMatrixMode(GL_MODELVIEW);
IlmMatrixRotateZ(matrix, currentAngle);
glLoadMatrixf(&matrix.f[0]);
- float color[4] = { 1.0, 0.0, 1.0, 0.5 + (0.3 / (float) i) };
- float lineColor[4] = { 0.0, 0.0, 0.0, 0.5 + (0.4 / (float) i) };
+ float color[4] = { 1.0f, 0.0f, 1.0f, 0.5f + (0.3f / (float) i) };
+ float lineColor[4] = { 0.0f, 0.0f, 0.0f, 0.5f + (0.4f / (float) i) };
glBegin(GL_TRIANGLES);
#ifndef _DBUSCONFIGURATION_H_
#define _DBUSCONFIGURATION_H_
-//=============================================================================
-// DBUS configuration
-//=============================================================================
+/*
+ * DBUS configuration
+ */
#define DBUS_SERVICE_PREFIX "org.genivi.layermanagementservice\0"
-//#define DBUS_SERVICE_OBJECT_PATH "/org/genivi/layermanagementservice\0"
+/*#define DBUS_SERVICE_OBJECT_PATH "/org/genivi/layermanagementservice\0" */
#define DBUS_SERVICE_ERROR "org.genivi.layermanagementservice.error"
#define DBUS_RECEIVE_TIMEOUT_IN_MS 500
#define ILM_SERVICE_NAME "org.genivi.layermanagementservice"
-//#define ILM_PATH_COMPOSITE_SERVICE "/org/genivi/layermanagementservice"
+/*#define ILM_PATH_COMPOSITE_SERVICE "/org/genivi/layermanagementservice" */
#define ILM_PATH_COMPOSITE_SERVICE "/"
#define ILM_INTERFACE_COMPOSITE_SERVICE "org.genivi.layermanagementservice"
#define ILM_INTERFACE_COMPOSITE_CLIENT "org.genivi.layermanagementclient"
-#endif // _DBUSCONFIGURATION_H_
+#endif /* _DBUSCONFIGURATION_H_ */
#include <dbus/dbus.h>
-// message filters
+/* message filters */
DBusHandlerResult filterLogging(DBusConnection *connection, DBusMessage *message, void *data);
DBusHandlerResult filterNameAcquired(DBusConnection *connection, DBusMessage *message, void *data);
DBusHandlerResult filterDiscardUnexpected(DBusConnection *connection, DBusMessage *message, void *data);
-// watches
+/* watches */
dbus_bool_t addWatch(DBusWatch* watch, void* data);
void removeWatch(DBusWatch* watch, void* data);
void toggleWatch(DBusWatch* watch, void* data);
-#endif // _CALLBACKS_H_
+#endif /* _CALLBACKS_H_ */
#include <pthread.h>
-//=============================================================================
-// data structures
-//=============================================================================
+/*
+ * =============================================================================
+ * data structures
+ * =============================================================================
+ */
typedef struct
{
t_ilm_message_type type;
int outgoingSocketsMax;
} dbus;
-//=============================================================================
-// global variables
-//=============================================================================
+
+/*
+ * =============================================================================
+ * global variables
+ * =============================================================================
+ */
dbus gDbus;
dbusmessage* gpIncomingMessage;
-//=============================================================================
-// prototypes
-//=============================================================================
+/*
+ * =============================================================================
+ * prototypes
+ * =============================================================================
+ */
void printTypeName(int type);
void unregisterMessageFunc(DBusConnection* conn, void *user_data);
t_ilm_bool appendString(t_ilm_message message, const char* value);
t_ilm_bool getString(t_ilm_message message, char* value);
t_ilm_bool sendToClients(t_ilm_message message, t_ilm_client_handle* receiverList, int receiverCount);
-//=============================================================================
-// callback functions
-//=============================================================================
+/*
+ * =============================================================================
+ * callback functions
+ * =============================================================================
+ */
void callbackUnregister(DBusConnection *connection, void *user_data);
DBusHandlerResult callbackMessage(DBusConnection *connection, DBusMessage *message, void *user_data);
-#endif // __COMMON_H__
+#endif /* __COMMON_H__ */
void generateIntrospectionString(char* msgBuffer);
-#endif // _DBUSINTROSPECTION_H_
+#endif /* _DBUSINTROSPECTION_H_ */
#include "DBUSConfiguration.h"
#include <stdio.h>
#include <stdlib.h>
-#include <string.h> // memcpy
+#include <string.h> /* memcpy */
t_ilm_bool appendBool(t_ilm_message message, const t_ilm_bool value)
t_ilm_message createResponse(t_ilm_message);
-//=============================================================================
-// message filters
-//=============================================================================
-
+/*
+ * =============================================================================
+ * message filters
+ * =============================================================================
+ */
DBusHandlerResult filterLayerManagerNotifications(DBusConnection *connection, DBusMessage *message, void *data)
{
+ const char* interfaceName = dbus_message_get_interface(message);
+
+ DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ int messageType = dbus_message_get_type(message);
+
(void)connection;
(void)data;
- const char* interfaceName = dbus_message_get_interface(message);
if (!interfaceName)
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- if (strcmp(ILM_INTERFACE_COMPOSITE_SERVICE, interfaceName)) // 0 == equals
+ if (strcmp(ILM_INTERFACE_COMPOSITE_SERVICE, interfaceName)) /* 0 == equals */
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- int messageType = dbus_message_get_type(message);
-
if (gDbus.isClient && (messageType == DBUS_MESSAGE_TYPE_SIGNAL))
{
gpIncomingMessage->type = IpcMessageTypeNotification;
DBusHandlerResult filterLayerManagerCommands(DBusConnection *connection, DBusMessage *message, void *data)
{
+ const char* interfaceName = dbus_message_get_interface(message);
+
+ DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ int messageType = dbus_message_get_type(message);
+
(void)connection;
(void)data;
- const char* interfaceName = dbus_message_get_interface(message);
if (!interfaceName)
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- if (strcmp(ILM_INTERFACE_COMPOSITE_SERVICE, interfaceName)) // 0 == equals
+ if (strcmp(ILM_INTERFACE_COMPOSITE_SERVICE, interfaceName)) /* 0 == equals */
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- int messageType = dbus_message_get_type(message);
-
if ((!gDbus.isClient && (messageType == DBUS_MESSAGE_TYPE_METHOD_CALL))
|| (gDbus.isClient && (messageType == DBUS_MESSAGE_TYPE_METHOD_RETURN)))
{
DBusHandlerResult filterLayerManagerErrors(DBusConnection *connection, DBusMessage *message, void *data)
{
+ const char* interfaceName = dbus_message_get_interface(message);
+
+ DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ int messageType = dbus_message_get_type(message);
+
+ char errorMsg[256];
+
(void)connection;
(void)data;
- const char* interfaceName = dbus_message_get_interface(message);
if (!interfaceName)
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- if (strcmp(ILM_INTERFACE_COMPOSITE_SERVICE, interfaceName)) // 0 == equals
+ if (strcmp(ILM_INTERFACE_COMPOSITE_SERVICE, interfaceName)) /* 0 == equals */
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- int messageType = dbus_message_get_type(message);
-
if (messageType == DBUS_MESSAGE_TYPE_ERROR)
{
gpIncomingMessage->pMessage = dbus_message_copy(message);
dbus_message_iter_init(gpIncomingMessage->pMessage, &gpIncomingMessage->iter);
- char errorMsg[256];
getString(gpIncomingMessage, errorMsg);
printf("DbusIpcModule: LayerManagerService returned error: %s\n", errorMsg);
DBusHandlerResult filterIntrospection(DBusConnection *connection, DBusMessage *message, void *data)
{
+ char introspectionString[65536];
+
+ t_ilm_message introspectionResponse;
+ t_ilm_client_handle sender;
+
(void)connection;
(void)data;
if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
{
gpIncomingMessage->pMessage = dbus_message_copy(message);
- gpIncomingMessage->type = IpcMessageTypeNone; // none for client
+ gpIncomingMessage->type = IpcMessageTypeNone; /* none for client */
gpIncomingMessage->dbusNativeType = DBUS_MESSAGE_TYPE_METHOD_CALL;
gpIncomingMessage->dbusSerial = dbus_message_get_serial(message);
- // generate introspection response content
- char introspectionString[65536];
+ /* generate introspection response content */
memset(introspectionString, 0, sizeof(introspectionString));
generateIntrospectionString(introspectionString);
- // create and send introspection reply
- // note: we're in dispatch, so mutex is currently locked in this thread
+ /*
+ * create and send introspection reply
+ * note: we're in dispatch, so mutex is currently locked in this thread
+ */
pthread_mutex_unlock(&gDbus.mutex);
- t_ilm_message introspectionResponse = createResponse(gpIncomingMessage);
+ introspectionResponse = createResponse(gpIncomingMessage);
appendString(introspectionResponse, introspectionString);
- t_ilm_client_handle sender = (t_ilm_client_handle)dbus_message_get_sender(gpIncomingMessage->pMessage);
+ sender = (t_ilm_client_handle)dbus_message_get_sender(gpIncomingMessage->pMessage);
sendToClients(introspectionResponse, &sender, 1);
pthread_mutex_lock(&gDbus.mutex);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-//=============================================================================
-// watches
-//=============================================================================
-
+/*
+ * =============================================================================
+ * watches
+ * =============================================================================
+ */
dbus_bool_t addWatch(DBusWatch* watch, void* data)
{
- (void)data;
-
int sock = dbus_watch_get_unix_fd(watch);
int flags = dbus_watch_get_flags(watch);
+ (void)data;
+
if (flags & DBUS_WATCH_READABLE)
{
gDbus.incomingWatch[sock] = watch;
void removeWatch(DBusWatch* watch, void* data)
{
- (void)data;
-
int sock = dbus_watch_get_unix_fd(watch);
int flags = dbus_watch_get_flags(watch);
+ (void)data;
+
if (flags & DBUS_WATCH_READABLE)
{
FD_CLR(sock, &gDbus.incomingSockets);
#include "DBUSConfiguration.h"
#include <stdio.h>
#include <stdlib.h>
-#include <string.h> // memcpy
+#include <string.h> /* memcpy */
t_ilm_bool appendDouble(t_ilm_message message, const t_ilm_float value)
#include <dbus/dbus.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h> // memset
+#include <string.h> /* memset */
-//=============================================================================
-// prototypes
-//=============================================================================
+/*
+ *=============================================================================
+ * prototypes
+ *=============================================================================
+ */
t_ilm_bool initService();
t_ilm_bool destroyClient();
t_ilm_bool destroyService();
-//=============================================================================
-// setup
-//=============================================================================
+/*
+ *=============================================================================
+ * setup
+ *=============================================================================
+ */
t_ilm_bool initServiceMode()
{
+ char* useSessionBus;
+ int ret;
+
+ const char* rule = "type='signal',"
+ "sender='"DBUS_INTERFACE_DBUS"',"
+ "interface='"DBUS_INTERFACE_DBUS"',"
+ "member='NameOwnerChanged'";
+
memset(&gDbus, 0, sizeof(gDbus));
gDbus.initialized = ILM_FALSE;
dbus_error_init(&gDbus.error);
- char* useSessionBus = getenv("LM_USE_SESSION_BUS");
+ useSessionBus = getenv("LM_USE_SESSION_BUS");
if (useSessionBus && strcmp(useSessionBus, "enable") == 0 )
{
gDbus.type = DBUS_BUS_SESSION;
if (!gDbus.isClient)
{
printf("DbusIpcmodule: registering dbus address %s\n", DBUS_SERVICE_PREFIX);
- int ret = dbus_bus_request_name(gDbus.connection, DBUS_SERVICE_PREFIX, DBUS_NAME_FLAG_REPLACE_EXISTING, &gDbus.error);
+ ret = dbus_bus_request_name(gDbus.connection, DBUS_SERVICE_PREFIX, DBUS_NAME_FLAG_REPLACE_EXISTING, &gDbus.error);
if (dbus_error_is_set(&gDbus.error))
{
gDbus.initialized = ILM_FALSE;
}
- const char* rule = "type='signal',"
- "sender='"DBUS_INTERFACE_DBUS"',"
- "interface='"DBUS_INTERFACE_DBUS"',"
- "member='NameOwnerChanged'";
-
dbus_bus_add_match(gDbus.connection, rule, &gDbus.error);
if (dbus_error_is_set(&gDbus.error))
{
t_ilm_bool initClientMode()
{
+ char* useSessionBus;
+
memset(&gDbus, 0, sizeof(gDbus));
gDbus.initialized = ILM_FALSE;
dbus_error_init(&gDbus.error);
- char* useSessionBus = getenv("LM_USE_SESSION_BUS");
+ useSessionBus = getenv("LM_USE_SESSION_BUS");
if (useSessionBus && strcmp(useSessionBus, "enable") == 0 )
{
gDbus.type = DBUS_BUS_SESSION;
}
-//=============================================================================
-// service specific
-//=============================================================================
+/*
+ *=============================================================================
+ * service specific
+ *=============================================================================
+ */
t_ilm_bool destroyService()
{
DBusError err;
+ t_ilm_bool errorset;
+
+ const char* rule = "type='signal',"
+ "sender='"DBUS_INTERFACE_DBUS"',"
+ "interface='"DBUS_INTERFACE_DBUS"',"
+ "member='NameOwnerChanged'";
+
dbus_error_init(&err);
- t_ilm_bool errorset = dbus_error_is_set(&err);
+ errorset = dbus_error_is_set(&err);
if (errorset)
{
printf("DbusIpcmodule: there was an dbus error\n");
dbus_bus_name_has_owner(gDbus.connection, DBUS_SERVICE_PREFIX, &err);
errorset = dbus_error_is_set(&err);
-
+
if (errorset)
{
printf("DbusIpcmodule: there was an dbus error\n");
}
dbus_error_init(&err);
-
- const char* rule = "type='signal',"
- "sender='"DBUS_INTERFACE_DBUS"',"
- "interface='"DBUS_INTERFACE_DBUS"',"
- "member='NameOwnerChanged'";
dbus_bus_remove_match(gDbus.connection, rule, &err);
errorset = dbus_error_is_set(&err);
-
+
if (errorset)
{
printf("DbusIpcmodule: there was an dbus error\n");
}
-
+
dbus_error_init(&err);
dbus_bus_release_name(gDbus.connection, DBUS_SERVICE_PREFIX, &err);
}
-//=============================================================================
-// client specific
-//=============================================================================
-
+/*
+ *=============================================================================
+ * client specific
+ *=============================================================================
+ */
t_ilm_bool destroyClient()
{
- // private dbus connection must be closed
+ /* private dbus connection must be closed */
if (dbus_connection_get_is_connected(gDbus.connection))
{
dbus_connection_close(gDbus.connection);
#include "DBUSConfiguration.h"
#include <stdio.h>
#include <stdlib.h>
-#include <string.h> // memcpy
+#include <string.h> /* memcpy */
t_ilm_bool appendInt(t_ilm_message message, const t_ilm_int value)
t_ilm_bool returnValue = ILM_FALSE;
char signature[2] = { DBUS_TYPE_UINT32, 0 };
DBusMessageIter arrayIter;
+ t_ilm_int index = 0;
returnValue = dbus_message_iter_open_container(&msg->iter, DBUS_TYPE_ARRAY, signature, &arrayIter);
- t_ilm_int index = 0;
for (index = 0; index < arraySize; ++index)
{
returnValue &= dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_INT32, &valueArray[index]);
t_ilm_int type = dbus_message_iter_get_arg_type(&msg->iter);
+ DBusMessageIter arrayIter;
+ int index = 0;
+
if (DBUS_TYPE_ARRAY == type)
{
returnValue = ILM_TRUE;
- DBusMessageIter arrayIter;
- int index = 0;
-
dbus_message_iter_recurse(&msg->iter, &arrayIter);
while (DBUS_TYPE_INVALID != dbus_message_iter_get_arg_type(&arrayIter))
****************************************************************************/
#include "introspection.h"
#include "DBUSConfiguration.h"
-#include <string.h> // memset
-#include <stdio.h> // sprintf
-
-//=============================================================================
-// internal data types
-//=============================================================================
+#include <string.h> /* memset */
+#include <stdio.h> /* sprintf */
+
+/*
+ * =============================================================================
+ * internal data types
+ * =============================================================================
+ */
struct IntrospectionTable
{
const char *name;
const char *reply;
};
-//=============================================================================
-// internal prototypes
-//=============================================================================
+/*
+ * =============================================================================
+ * internal prototypes
+ * =============================================================================
+ */
void generateString();
unsigned int addHeader(char* msgBuffer);
unsigned int openNode(char* msgBuffer, const char* nodename);
unsigned int closeNode(char* msgBuffer);
-//=============================================================================
-// implementation
-//=============================================================================
+/*
+ * =============================================================================
+ * implementation
+ * =============================================================================
+ */
void generateIntrospectionString(char* msgBuffer)
{
- //LOG_DEBUG("DBUSCommunicator", "Generating introspection data");
+ /*LOG_DEBUG("DBUSCommunicator", "Generating introspection data"); */
/* Introspection is a special feature of the DBUS IpcModule, which other
* IpcModules do (most likely) not have.
};
int introspectionInterfaceCount = sizeof(introspectionInterface) / sizeof(struct IntrospectionTable);
+ int index = 0;
+
+ int i = 0;
msgBuffer += addHeader(msgBuffer);
msgBuffer += openNode(msgBuffer, DBUS_SERVICE_PREFIX);
msgBuffer += closeInterface(msgBuffer);
msgBuffer += openInterface(msgBuffer, DBUS_SERVICE_PREFIX);
- int index = 0;
-
for (index = 0; index < introspectionInterfaceCount; ++index)
{
struct IntrospectionTable* method = &introspectionInterface[index];
msgBuffer += openMethod(msgBuffer, methodName);
- int i = 0;
for(i = 0; i < parameterLength; ++i)
{
switch (parameter[i])
#include "introspection.h"
#include <stdio.h>
#include <stdlib.h>
-#include <string.h> // strdup
+#include <string.h> /* strdup */
#include <errno.h>
-//=============================================================================
-// prototypes internal functions
-//=============================================================================
+/*
+ * =============================================================================
+ * prototypes internal functions
+ * =============================================================================
+ */
void handleWatchesForFds(fd_set in, fd_set out);
t_ilm_bool dispatchIncomingMessages();
void registerSignalForNotification(dbusmessage* message, char* signalName);
void unregisterSignalForNotification(dbusmessage* message, char* signalName);
-//=============================================================================
-// message handling
-//=============================================================================
+/*
+ * =============================================================================
+ * message handling
+ * =============================================================================
+ */
t_ilm_message createMessage(t_ilm_const_string name)
{
+ dbusmessage* newMessage = NULL;
+
if (!gDbus.initialized)
{
return 0;
}
- dbusmessage* newMessage = (dbusmessage*)malloc(sizeof(dbusmessage));
+ newMessage = (dbusmessage*)malloc(sizeof(dbusmessage));
newMessage->type = IpcMessageTypeCommand;
newMessage->dbusNativeType = DBUS_MESSAGE_TYPE_METHOD_CALL;
pthread_mutex_lock(&gDbus.mutex);
t_ilm_message createResponse(t_ilm_message message)
{
+ dbusmessage* receivedMessage;
+ dbusmessage* newResponse;
+ const char* member = NULL;
+ const char* destination = NULL;
+
if (!gDbus.initialized)
{
return NULL;
}
- dbusmessage* receivedMessage = (dbusmessage*)message;
- dbusmessage* newResponse = (dbusmessage*)malloc(sizeof(dbusmessage));
+ receivedMessage = (dbusmessage*)message;
+ newResponse = (dbusmessage*)malloc(sizeof(dbusmessage));
newResponse->type = IpcMessageTypeCommand;
newResponse->dbusNativeType = DBUS_MESSAGE_TYPE_METHOD_RETURN;
newResponse->pMessage = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
pthread_mutex_unlock(&gDbus.mutex);
- const char* member = dbus_message_get_member(receivedMessage->pMessage);
- const char* destination = dbus_message_get_sender(receivedMessage->pMessage);
+ member = dbus_message_get_member(receivedMessage->pMessage);
+ destination = dbus_message_get_sender(receivedMessage->pMessage);
dbus_message_set_member(newResponse->pMessage, member);
dbus_message_set_destination(newResponse->pMessage, destination);
dbus_message_set_reply_serial(newResponse->pMessage, receivedMessage->dbusSerial);
t_ilm_message createErrorResponse(t_ilm_message message)
{
+ dbusmessage* receivedMessage;
+ dbusmessage* newResponse;
+ char member[256];
+ char destination[256];
+
if (!gDbus.initialized)
{
return 0;
}
- dbusmessage* receivedMessage = (dbusmessage*)message;
- dbusmessage* newResponse = (dbusmessage*)malloc(sizeof(dbusmessage));
+ receivedMessage = (dbusmessage*)message;
+ newResponse = (dbusmessage*)malloc(sizeof(dbusmessage));
memset(newResponse, 0, sizeof(dbusmessage));
newResponse->type = IpcMessageTypeError;
newResponse->pMessage = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR);
pthread_mutex_unlock(&gDbus.mutex);
- const char* member = dbus_message_get_member(receivedMessage->pMessage);
- const char* destination = dbus_message_get_sender(receivedMessage->pMessage);
+ strcpy(member, dbus_message_get_member(receivedMessage->pMessage));
+ strcpy(destination, dbus_message_get_sender(receivedMessage->pMessage));
dbus_message_set_member(newResponse->pMessage, member);
dbus_message_set_destination(newResponse->pMessage, destination);
dbus_message_set_error_name(newResponse->pMessage, DBUS_SERVICE_ERROR);
t_ilm_message createNotification(t_ilm_const_string name)
{
+ dbusmessage* newNotification;
+
if (!gDbus.initialized)
{
return 0;
}
- dbusmessage* newNotification = (dbusmessage*)malloc(sizeof(dbusmessage));
+ newNotification = (dbusmessage*)malloc(sizeof(dbusmessage));
newNotification->type = IpcMessageTypeNotification;
newNotification->dbusNativeType = DBUS_MESSAGE_TYPE_SIGNAL;
t_ilm_bool sendToClients(t_ilm_message message, t_ilm_client_handle* receiverList, int receiverCount)
{
+ dbusmessage* messageToSend;
+ t_ilm_uint serial;
+ dbus_bool_t success;
+
(void)receiverList;
(void)receiverCount;
return ILM_FALSE;
}
- dbusmessage* messageToSend = (dbusmessage*)message;
- t_ilm_uint serial = dbus_message_get_serial(messageToSend->pMessage);
+ messageToSend = (dbusmessage*)message;
+ serial = dbus_message_get_serial(messageToSend->pMessage);
dbus_message_set_path(messageToSend->pMessage, ILM_PATH_COMPOSITE_SERVICE);
dbus_message_set_interface(messageToSend->pMessage, ILM_INTERFACE_COMPOSITE_SERVICE);
pthread_mutex_lock(&gDbus.mutex);
- dbus_bool_t success = dbus_connection_send(gDbus.connection, messageToSend->pMessage, &serial);
+ success = dbus_connection_send(gDbus.connection, messageToSend->pMessage, &serial);
pthread_mutex_unlock(&gDbus.mutex);
if (!success)
{
t_ilm_bool sendToService(t_ilm_message message)
{
+ dbusmessage* messageToSend;
+ t_ilm_uint serial;
+ dbus_bool_t success;
+ char msgName[256];
+
if (!gDbus.isClient)
{
return ILM_FALSE;
}
- dbusmessage* messageToSend = (dbusmessage*)message;
- t_ilm_uint serial = 1;
+ messageToSend = (dbusmessage*)message;
+ serial = 1;
pthread_mutex_lock(&gDbus.mutex);
- dbus_bool_t success = dbus_connection_send(gDbus.connection, messageToSend->pMessage, &serial);
+ success = dbus_connection_send(gDbus.connection, messageToSend->pMessage, &serial);
pthread_mutex_unlock(&gDbus.mutex);
if (!success)
{
exit(1);
}
- const char* msgName = dbus_message_get_member(messageToSend->pMessage);
+ strcpy(msgName, dbus_message_get_member(messageToSend->pMessage));
if (0 == strcmp(msgName, "LayerAddNotification"))
{
t_ilm_message receive(t_ilm_int timeoutInMs)
{
+ fd_set readFds;
+ fd_set writeFds;
+ int fdMax;
+ int fdsReady;
+
gpIncomingMessage = (dbusmessage*)malloc(sizeof(dbusmessage));
memset(gpIncomingMessage, 0, sizeof(dbusmessage));
return (t_ilm_message)gpIncomingMessage;
}
- fd_set readFds = gDbus.incomingSockets;
- fd_set writeFds = gDbus.outgoingSockets;
- int fdMax = (gDbus.incomingSocketsMax > gDbus.outgoingSocketsMax) ?
+ readFds = gDbus.incomingSockets;
+ writeFds = gDbus.outgoingSockets;
+ fdMax = (gDbus.incomingSocketsMax > gDbus.outgoingSocketsMax) ?
gDbus.incomingSocketsMax : gDbus.outgoingSocketsMax;
- int fdsReady = 0;
+ fdsReady = 0;
if (timeoutInMs < 0)
{
switch (fdsReady)
{
- case -1: // error: select was cancelled -> shutdown
+ case -1: /* error: select was cancelled -> shutdown */
gpIncomingMessage->type = IpcMessageTypeShutdown;
break;
- case 0: // timeout
+ case 0: /* timeout */
gpIncomingMessage->type = IpcMessageTypeNone;
break;
- default: // message or shutdown
+ default: /* message or shutdown */
handleWatchesForFds(readFds, writeFds);
dispatchIncomingMessages();
break;
t_ilm_client_handle getSenderHandle(t_ilm_message message)
{
- t_ilm_uint result = 0;
+ unsigned long result = 0;
const char* sender = getSenderName(message);
if (sender)
{
float f = atof(&sender[1]);
- result = (t_ilm_uint)(f * 1000000);
+ result = (unsigned long)(f * 1000000);
};
return (t_ilm_client_handle)result;
}
return ILM_TRUE;
}
-//=============================================================================
-// prototypes internal functions
-//=============================================================================
+/*
+ * =============================================================================
+ * prototypes internal functions
+ * =============================================================================
+ */
void handleWatchesForFds(fd_set in, fd_set out)
{
int fd = 0;
+ dbus_bool_t success;
for (fd = 0; fd < gDbus.incomingSocketsMax; ++fd)
{
+ DBusWatch* activeWatch;
+
if (FD_ISSET(fd, &in))
{
- DBusWatch* activeWatch = gDbus.incomingWatch[fd];
+ activeWatch = gDbus.incomingWatch[fd];
if (activeWatch)
{
pthread_mutex_lock(&gDbus.mutex);
- dbus_bool_t success = dbus_watch_handle(activeWatch, DBUS_WATCH_READABLE);
+ success = dbus_watch_handle(activeWatch, DBUS_WATCH_READABLE);
pthread_mutex_unlock(&gDbus.mutex);
if (!success)
for (fd = 0; fd < gDbus.outgoingSocketsMax; ++fd)
{
+ DBusWatch* activeWatch;
+
if (FD_ISSET(fd, &out))
{
- DBusWatch* activeWatch = gDbus.outgoingWatch[fd];
+ activeWatch = gDbus.outgoingWatch[fd];
if (activeWatch)
{
pthread_mutex_lock(&gDbus.mutex);
- dbus_bool_t success = dbus_watch_handle(activeWatch, DBUS_WATCH_WRITABLE);
+ success = dbus_watch_handle(activeWatch, DBUS_WATCH_WRITABLE);
pthread_mutex_unlock(&gDbus.mutex);
if (!success)
signalName,
id);
- // do not block here, race condition with receive thread.
- // according to dbus documentation almost impossible to fail
- // (only if out of memory)
- // if result is important, create method call manually
- // and use main loop for communication
+ /*
+ * do not block here, race condition with receive thread.
+ * according to dbus documentation almost impossible to fail
+ * (only if out of memory)
+ * if result is important, create method call manually
+ * and use main loop for communication
+ */
pthread_mutex_lock(&gDbus.mutex);
dbus_bus_add_match(gDbus.connection, rule, NULL);
pthread_mutex_unlock(&gDbus.mutex);
signalName,
id);
- // do not block here, race condition with receive thread.
- // according to dbus documentation almost impossible to fail
- // (only if out of memory)
- // if result is important, create method call manually
- // and use main loop for communication
+ /*
+ * do not block here, race condition with receive thread.
+ * according to dbus documentation almost impossible to fail
+ * (only if out of memory)
+ * if result is important, create method call manually
+ * and use main loop for communication
+ */
pthread_mutex_lock(&gDbus.mutex);
dbus_bus_remove_match(gDbus.connection, rule, NULL);
pthread_mutex_unlock(&gDbus.mutex);
-//=============================================================================
-// print debug information
-//=============================================================================
+/*
+ * =============================================================================
+ * print debug information
+ * =============================================================================
+ */
void printTypeName(int type)
{
switch (type)
#include "DBUSConfiguration.h"
#include <stdio.h>
#include <stdlib.h>
-#include <string.h> // memcpy
+#include <string.h> /* memcpy */
t_ilm_bool appendString(t_ilm_message message, const char* value)
if (DBUS_TYPE_STRING == type)
{
char* tmp = NULL;
+ int len;
dbus_message_iter_get_basic(&msg->iter, &tmp);
dbus_message_iter_next(&msg->iter);
- int len = strlen(tmp);
+ len = strlen(tmp);
strncpy(value, tmp, len);
value[len] = '\0';
returnValue = ILM_TRUE;
#include "DBUSConfiguration.h"
#include <stdio.h>
#include <stdlib.h>
-#include <string.h> // memcpy
+#include <string.h> /* memcpy */
t_ilm_bool appendUint(t_ilm_message message, const t_ilm_uint value)
{
t_ilm_bool returnValue = ILM_FALSE;
char signature[2] = { DBUS_TYPE_UINT32, 0 };
DBusMessageIter arrayIter;
+ t_ilm_int index = 0;
returnValue = dbus_message_iter_open_container(&msg->iter, DBUS_TYPE_ARRAY, signature, &arrayIter);
- t_ilm_int index = 0;
for (index = 0; index < arraySize; ++index)
{
returnValue &= dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_UINT32, &valueArray[index]);
if (DBUS_TYPE_ARRAY == type)
{
- returnValue = ILM_TRUE;
+ t_ilm_uint* dbusArrayPointer = NULL;
DBusMessageIter arrayIter;
+ returnValue = ILM_TRUE;
dbus_message_iter_recurse(&msg->iter, &arrayIter);
- // get pointer to dbus internal array data (zero copy)
- t_ilm_uint* dbusArrayPointer = NULL;
+ /* get pointer to dbus internal array data (zero copy) */
dbus_message_iter_get_fixed_array(&arrayIter, &dbusArrayPointer, arraySize);
- // create callers buffer, copy data to buffer
+ /* create callers buffer, copy data to buffer */
*valueArray = malloc(sizeof(t_ilm_uint) * (*arraySize));
memcpy(*valueArray, dbusArrayPointer, sizeof(t_ilm_uint) * (*arraySize));
int count = surface->OriginalSourceWidth*surface->OriginalSourceHeight;
for (int j=0;j<count; j++)
{
- xim->data[j*4+3]=255;
+ xim->data[j*4+3] = (char)255;
}
}
} else {
header.color2 = 0;
// make sure parent directory exists
- uint currentPos = 0;
- uint lastPos = FileName.find_first_of("/",currentPos);
+ std::size_t currentPos = 0;
+ std::size_t lastPos = FileName.find_first_of("/",currentPos);
while (lastPos != std::string::npos)
{
std::string directory = FileName.substr(0,lastPos);
#ifdef WITH_DLT
+
+// DLT macros will fail using -pedantic with
+// warning: ISO C++ forbids braced-groups within expressions
+#pragma GCC diagnostic ignored "-pedantic"
+
void Log::LogToDltDaemon(LogContext logContext, LOG_MODES logMode, const std::string& moduleName, const std::basic_string<char>& output)
{
#==============================================================================
# default compiler flags
#==============================================================================
-set (COMPILER_FLAGS_3RDPARTY "-fPIC")
-set (COMPILER_FLAGS_TEST "-fPIC")
+set (COMPILER_FLAGS_3RDPARTY "-fPIC -Wno-variadic-macros -Wno-sign-compare")
+set (COMPILER_FLAGS_TEST "-fPIC -Wno-variadic-macros -Wno-sign-compare")
set (COMPILER_FLAGS_EXAMPLE "-fPIC -Wall -Wextra")
-set (COMPILER_FLAGS_PLUGIN "-fPIC -Wall -Wextra -pedantic -Wno-long-long")
+set (COMPILER_FLAGS_PLUGIN "-fPIC -Wall -Wextra -pedantic -Wno-long-long -Wno-unused-function")
set (COMPILER_FLAGS_CORE "-fPIC -Wall -Wextra -pedantic -Wno-long-long -Wno-unused-function")