plugin_event.h

Go to the documentation of this file.
00001 /*
00002  * File Name: plugin_event.h
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-common.
00007  *
00008  * uds-plugin-common is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-common is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 #ifndef PLUGIN_EVENT_H_
00028 #define PLUGIN_EVENT_H_
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #include "config.h"
00035 #include "plugin_type.h"
00036 #include "plugin_unknown.h"
00037 
00038 /**
00039  * @brief Type definition of plugin events.
00040  */
00041 typedef enum
00042 {
00043     EVENT_PAGINATE_START,             /**< Pagination starting Event */
00044     EVENT_PAGINATE_END,               /**< Pagination ending Event */
00045     EVENT_RENDERING_END,              /**< Rendering ending Event */
00046     EVENT_MARKER_READY,               /**< Marker(tree) ready Event */
00047     EVENT_MARKER_OUT_OF_DATE,         /**< Marker(tree) Out-Of-Date Event */
00048     EVENT_SEARCH_END,                 /**< Search ending Event */
00049     EVENT_SEARCH_ABORTED,             /**< Search aborted Event */
00050     EVENT_PRERENDERING_START,         /**< Pre rendering started Event */
00051     EVENT_PRERENDERING_END            /**< Pre rendering ended Event */
00052 } PluginEvent;
00053 
00054 /**
00055  * @brief Define render status here.
00056  */
00057 typedef enum
00058 {
00059     RENDER_PENDING = -1,                /**< Job pending      */
00060     RENDER_DONE,                        /**< Render finished. */
00061     RENDER_OUT_OF_MEMORY,               /**< Out of memory.   */
00062     RENDER_INVALID_PAGE,                /**< Invalid page.    */
00063     RENDER_FAIL,                        /**< Render fails.    */
00064     RENDER_BEYOND_LAST_PAGE,            /**< Requested page is after the document's end */
00065     RENDER_BEYOND_FIRST_PAGE            /**< Requested page is before the document's start */
00066 } PluginRenderStatus;
00067 
00068 /**
00069  * @brief Pagination event, could be triggered when start and finished.
00070  */
00071 typedef struct
00072 {
00073     int current;    /**< The number of the latest paginated page */
00074     int total;      /**< The number of total pages that should be paginated */
00075 } EventParmsPaginate_t;
00076 
00077 /**
00078  * @brief Render event.
00079  */
00080 typedef struct 
00081 {
00082     unsigned long       rid;        /**< The reference ID of the rendered result */
00083     PluginRenderStatus  status;     /**< The status of render result. */
00084     IPluginUnknown*     result;     /**< The IPluginUnknown pointer of render result object */
00085                                     /**< depending on the render status:                    */
00086                                     /**<   RENDER_DONE              rendered page           */
00087                                     /**<   RENDER_BEYOND_LAST_PAGE  last page in document   */
00088                                     /**<   RENDER_BEYOND_FIRST_PAGE first page in document  */
00089                                     /**<   other                    NULL pointer            */
00090 } EventRenderEnd_t;
00091 
00092 /**
00093  * @brief Marker(tree) generation done event.
00094  */
00095 typedef struct 
00096 {
00097     IPluginUnknown* result; /**< The IPluginUnknown pointer of the collection 
00098                                  which contains the requested marker(tree) */
00099 } EventMarkerReady_t;
00100 
00101 /**
00102  * @brief Search finishing event.
00103  */
00104 typedef struct 
00105 {
00106     unsigned long   search_id;  /**< ID of the search request*/
00107     IPluginUnknown* result;     /**< The IPluginUnknown pointer of the collection 
00108                                      which contains the requested search results. */
00109 } EventSearchEnd_t;
00110 
00111 
00112 /**
00113  * @brief Put all above events into together.
00114  */
00115 typedef union 
00116 {
00117     EventParmsPaginate_t    paginate;       /**< Parameter of pagination  */
00118     EventRenderEnd_t        render_end;     /**< Parameter of rendering done */
00119     EventMarkerReady_t      marker_ready;   /**< Parameter of marker ready */
00120     EventSearchEnd_t        search_end;     /**< Parameter of search done */
00121 } PluginEventAttrs;
00122 
00123 /** 
00124  * @brief Define the callback function prototype.
00125  * @param thiz_sender The IPluginUnknown pointer of the object which sends 
00126  * the event.
00127  * @param handler_id Because UDS can register same event with same function 
00128     pointer twice, we use handler_id to distinguish them.
00129  * @param plugin_event The event which is sent by thiz_sender.
00130  * @param user_data User specified data.
00131  * @param plugin_data The data coming from plugin library. It would be used 
00132  * as parameters when broadcasting the event.
00133  */
00134 typedef void (* EventFunc)( IPluginUnknown          *thiz_sender,
00135                             unsigned long           handler_id,
00136                             const PluginEvent       plugin_event,
00137                             void                    *user_data,
00138                             const PluginEventAttrs  *plugin_data );
00139 
00140 /**
00141  * @brief Universal Document Shell Plugin Document Event Broadcaster interface.
00142  * Through IPluginEventBroadcaster, listeners can receive notification from 
00143  * plugin.
00144  */
00145 typedef struct 
00146 {
00147     /**
00148      * @brief Register call back function for specified event.
00149      * @param thiz The object identifier which implements the 
00150      * IPluginEventBroadcaster interface.
00151      * @param event The event on which the listener needs to register.
00152      * @param callback Callback function defined by caller.
00153      * @param user_data User specified data, plugin puts this variable 
00154      * to callback function as a parameter.
00155      * @param handler_id The identifier ID of this registration.
00156      * @return TODO. Add return code here.
00157      */
00158     PluginStatus (* add_event_receiver)( IPluginUnknown     *thiz,
00159                                          const PluginEvent  plugin_event,
00160                                          EventFunc          callback,
00161                                          void               *user_data,
00162                                          unsigned long      *handler_id);
00163 
00164     /**
00165      * @brief Remove a listener by specified ID.
00166      * @param thiz The object identifier which implements the 
00167      * IPluginEventBroadcaster interface.
00168      * @param handler_id The unique identifier of the registration, it is 
00169      * always generated by plugin while caller registers a callback 
00170      * function for specified event.
00171      * @return TODO. Add return code here.
00172      */
00173     PluginStatus (* remove_event_receiver)( IPluginUnknown  *thiz,
00174                                             unsigned long   handler_id );
00175 
00176 } IPluginEventBroadcaster;
00177 
00178 #ifdef __cplusplus
00179 }
00180 #endif 
00181 
00182 #endif
00183 
Generated by  doxygen 1.6.2-20100208