Modified:
trunk/imbus/src/im_event.c
trunk/imbus/src/im_event.h
Log:
Added Original Destination field.
Modified: trunk/imbus/src/im_event.c
==============================================================================
--- trunk/imbus/src/im_event.c (original)
+++ trunk/imbus/src/im_event.c Tue Nov 20 08:42:39 2007
@@ -29,6 +29,7 @@
IMUInt32 type;
IMUInt32 source;
IMUInt32 dest;
+ IMUInt32 orig_dest;
IMUInt32 icid;
IMUInt64 timestamp;
IMUInt32 serial;
@@ -54,6 +55,7 @@
((IMEvent*)event)->type = 0;
((IMEvent*)event)->source = 0;
((IMEvent*)event)->dest = IM_EVENT_DEST_DEFAULT;
+ ((IMEvent*)event)->orig_dest = IM_EVENT_DEST_DEFAULT;
((IMEvent*)event)->icid = IM_EVENT_INPUT_CONTEXT_NONE;
((IMEvent*)event)->timestamp =
im_get_current_time_in_milliseconds ();
((IMEvent*)event)->serial = 0;
@@ -84,6 +86,7 @@
dp->type = sp->type;
dp->source = sp->source;
dp->dest = sp->dest;
+ dp->orig_dest = sp->orig_dest;
dp->icid = sp->icid;
dp->timestamp = sp->timestamp;
dp->serial = sp->serial;
@@ -104,7 +107,7 @@
{
const IMEvent *ep = IM_CONST_EVENT (obj);
IMStream *sp = IM_STREAM (stream);
- IMUInt32 buf [8];
+ IMUInt32 buf [9];
_im_assert (ep && sp);
@@ -115,14 +118,15 @@
buf [0] = ep->type;
buf [1] = ep->source;
buf [2] = ep->dest;
- buf [3] = ep->icid;
- buf [4] = (ep->timestamp & 0xFFFFFFFF);
- buf [5] = (ep->timestamp >> 32);
- buf [6] = ep->serial;
- buf [7] = (ep->observable ? 1 : 0);
- buf [7] |= (ep->reply ? 2 : 0);
+ buf [3] = ep->orig_dest;
+ buf [4] = ep->icid;
+ buf [5] = (ep->timestamp & 0xFFFFFFFF);
+ buf [6] = (ep->timestamp >> 32);
+ buf [7] = ep->serial;
+ buf [8] = (ep->observable ? 1 : 0);
+ buf [8] |= (ep->reply ? 2 : 0);
- if (!im_stream_put_uint32_array (sp, buf, 8))
+ if (!im_stream_put_uint32_array (sp, buf, 9))
return FALSE;
if (ep->data)
@@ -136,7 +140,7 @@
{
IMEvent *ep = IM_EVENT (obj);
IMStream *sp = IM_STREAM (stream);
- IMUInt32 buf [8];
+ IMUInt32 buf [9];
IMType type;
_im_assert (ep && sp);
@@ -146,18 +150,19 @@
return FALSE;
if (im_stream_get_data_type (sp) != IM_TYPE_UINT32_ARRAY ||
- im_stream_get_data_size (sp) != 8 ||
- im_stream_get_uint32_array (sp, buf, 8) == FALSE)
+ im_stream_get_data_size (sp) != 9 ||
+ im_stream_get_uint32_array (sp, buf, 9) == FALSE)
return FALSE;
ep->type = buf [0];
ep->source = buf [1];
ep->dest = buf [2];
- ep->icid = buf [3];
- ep->timestamp = (((IMUInt64)buf [4]) | (((IMUInt64)buf [5]) << 32));
- ep->serial = buf [6];
- ep->observable = ((buf [7] & 1) != 0);
- ep->reply = ((buf [7] & 2) != 0);
+ ep->orig_dest = buf [3];
+ ep->icid = buf [4];
+ ep->timestamp = (((IMUInt64)buf [5]) | (((IMUInt64)buf [6]) << 32));
+ ep->serial = buf [7];
+ ep->observable = ((buf [8] & 1) != 0);
+ ep->reply = ((buf [8] & 2) != 0);
if (ep->data)
im_object_unref (ep->data);
@@ -292,6 +297,20 @@
{
_im_return_val_if_fail (IM_IS_EVENT(event), 0);
return event->dest;
+}
+
+void
+im_event_set_original_destination (IMEvent *event, IMUInt32 orig_dest_id)
+{
+ _im_return_if_fail (IM_IS_EVENT(event));
+ event->orig_dest = orig_dest_id;
+}
+
+IMUInt32
+im_event_get_original_destination (const IMEvent *event)
+{
+ _im_return_val_if_fail (IM_IS_EVENT(event), 0);
+ return event->orig_dest;
}
void
Modified: trunk/imbus/src/im_event.h
==============================================================================
--- trunk/imbus/src/im_event.h (original)
+++ trunk/imbus/src/im_event.h Tue Nov 20 08:42:39 2007
@@ -56,6 +56,18 @@
* components of the event will receive it no matter what
destination id is
* used, unless Observable is set to FALSE (see below).
*
+ * - Original Destination ID (IMUInt32)
+ * Unique ID of the original destination component for an observed event.
+ * This field is only valid when an event is sent to an observer. In this
+ * case, this field indicates the original destination of the event
+ * (event consumer).
+ * For the events that sent to event consumer directly, this field
shall be
+ * set to the same value as "Event destination ID", or IM_EVENT_DEST_DEFAULT.
+ * Actually, this field shall be ignored by the event consumer.
+ * For the events that sent to event observer, this field will be
set to the
+ * ID of original event consumer by IMBUS. The observer can
determine if it's
+ * an observed event by checking this field.
+ *
* - Input Context ID (ICID) (IMUInt32)
* Unique ID of the input context which the event is bound to. ICID
is allocated
* by IMBUS in sequence. There are two special ICID:
@@ -207,6 +219,16 @@
* @brief Get destination id of an event object.
*/
IMUInt32 im_event_get_destination (const IMEvent *event);
+
+/**
+ * @brief Set original destination id of an event object.
+ */
+void im_event_set_original_destination(IMEvent *event,
+ IMUInt32 orig_dest_id);
+/**
+ * @brief Get original destination id of an event object.
+ */
+IMUInt32 im_event_get_original_destination(const IMEvent *event);
/**
* @brief Set serial number of an event object.