00001
00020 #include <glib.h>
00021 #include <glib-object.h>
00022 #include <gmodule.h>
00023 #include <string.h>
00024
00025 #include "rtcom-eventlogger/eventlogger-plugin.h"
00026
00027 #define PLUGIN_NAME "TEST"
00028 #define PLUGIN_DESC "Test plugin"
00029 #define SERVICE_NAME "RTCOM_EL_SERVICE_TEST"
00030 #define SERVICE_DESC "Service for testing framework's functionalities."
00031
00032 const gchar * g_module_check_init(
00033 GModule * module)
00034 {
00035 g_message("Plugin registered: %s.", PLUGIN_NAME);
00036 return NULL;
00037 }
00038
00039 const gchar * rtcom_el_plugin_name(void)
00040 {
00041 return PLUGIN_NAME;
00042 }
00043
00044 void rtcom_el_plugin_init(void)
00045 {
00046 }
00047
00048 const gchar * rtcom_el_plugin_desc(void)
00049 {
00050 return PLUGIN_DESC;
00051 }
00052
00053 RTComElService * rtcom_el_plugin_service(void)
00054 {
00055 RTComElService * service = rtcom_el_service_new(
00056 SERVICE_NAME,
00057 SERVICE_DESC);
00058 return service;
00059 }
00060
00061 GList * rtcom_el_plugin_eventtypes(void)
00062 {
00063 GList * event_types = NULL;
00064
00065 event_types = g_list_append(
00066 event_types,
00067 rtcom_el_eventtype_new(
00068 "RTCOM_EL_EVENTTYPE_TEST_ET1",
00069 "Some event type."));
00070 event_types = g_list_append(
00071 event_types,
00072 rtcom_el_eventtype_new(
00073 "RTCOM_EL_EVENTTYPE_TEST_ET2",
00074 "Some other event type."));
00075
00076 event_types = g_list_first(event_types);
00077
00078 return event_types;
00079 }
00080
00081 GList * rtcom_el_plugin_flags(void)
00082 {
00083 GList * flags = NULL;
00084
00085 flags = g_list_append(
00086 flags,
00087 rtcom_el_flag_new(
00088 "RTCOM_EL_FLAG_TEST_FLAG1",
00089 2,
00090 "Some flag"));
00091 flags = g_list_append(
00092 flags,
00093 rtcom_el_flag_new(
00094 "RTCOM_EL_FLAG_TEST_FLAG2",
00095 4,
00096 "Some other flag"));
00097 flags = g_list_append(
00098 flags,
00099 rtcom_el_flag_new(
00100 "RTCOM_EL_FLAG_TEST_FLAG3",
00101 8,
00102 "Even some another flag"));
00103
00104 flags = g_list_first(flags);
00105
00106 return flags;
00107 }
00108
00109 gboolean rtcom_el_plugin_get_value(
00110 RTComElIter * it,
00111 const gchar * item,
00112 GValue * value)
00113 {
00114 gchar * header_value = NULL;
00115
00116 g_return_val_if_fail(it, FALSE);
00117 g_return_val_if_fail(item, FALSE);
00118 g_return_val_if_fail(value, FALSE);
00119
00120 GString * add = NULL;
00121
00122 GString * markup = NULL;
00123 GValue id = {0};
00124 GValue local_name = {0};
00125 GValue local_uid = {0};
00126
00127 if(!strcmp(item, "Foo"))
00128 {
00129 header_value = rtcom_el_iter_get_header_raw(
00130 it,
00131 item);
00132
00133 g_value_init(value, G_TYPE_STRING);
00134
00135 if(header_value)
00136 {
00137 g_value_set_string(value, header_value);
00138 g_free(header_value);
00139 return TRUE;
00140 }
00141 else
00142 {
00143 g_debug("Plugin %s couldn't find item %s", PLUGIN_NAME, item);
00144 g_value_set_static_string(value, NULL);
00145 return TRUE;
00146 }
00147 }
00148 else if(!strcmp(item, "additional-text"))
00149 {
00150 add = g_string_new("");
00151 rtcom_el_iter_get_raw(it, "id", &id);
00152 g_string_append_printf(add, "%d", g_value_get_int(&id));
00153 g_value_unset(&id);
00154 g_string_append(add, ": Hello from the Test plugin!");
00155
00156 g_value_init(value, G_TYPE_STRING);
00157 g_value_set_string(value, add->str);
00158
00159 g_string_free(add, TRUE);
00160 return TRUE;
00161 }
00162 else if(!strcmp(item, "pango-markup"))
00163 {
00164 markup = g_string_new("");
00165 rtcom_el_iter_get_raw(it, "id", &id);
00166 rtcom_el_iter_get_raw(it, "local-name", &local_name);
00167 rtcom_el_iter_get_raw(it, "local-uid", &local_uid);
00168 g_string_append_printf(
00169 markup,
00170 "%d: <b>%s</b>\n<small>Hello from the Test plugin! UID: %s</small>",
00171 g_value_get_int(&id),
00172 g_value_get_string(&local_name),
00173 g_value_get_string(&local_uid));
00174
00175 g_value_unset(&local_name);
00176 g_value_unset(&local_uid);
00177
00178 g_value_init(value, G_TYPE_STRING);
00179 g_value_set_string(value, markup->str);
00180
00181 g_string_free(markup, TRUE);
00182 return TRUE;
00183 }
00184 else if(!strcmp(item, "icon-path"))
00185 {
00186 g_value_init(value, G_TYPE_STRING);
00187 g_value_set_string(value, "");
00188 return TRUE;
00189 }
00190
00191 return FALSE;
00192 }
00193
00194
00195