• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OH_COMMON_EVENT_C_H
17 #define OH_COMMON_EVENT_C_H
18 
19 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 typedef enum CommonEvent_ErrCode {
26     /** @error Execution successful. */
27     COMMONEVENT_ERR_OK = 0,
28     /** @error Permission verification failed. */
29     COMMONEVENT_ERR_PERMISSION_ERROR = 201,
30     /** @error Invalid input parameter. */
31     COMMONEVENT_ERR_INVALID_PARAMETER = 401,
32     /** @error IPC request failed to send. */
33     COMMONEVENT_ERR_FAIL_SEND_REQUEST = 1500007,
34     /** @error Common event service not init. */
35     COMMONEVENT_ERR_INIT_UNDONE = 1500008,
36     /** @error the subscriber number exceed system specification */
37     COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED = 1500010,
38     /** @error A memory allocation error occurs. */
39     COMMONEVENT_ERR_ALLOC_MEMORY_FAILED = 1500011,
40 } CommonEvent_ErrCode;
41 
42 /**
43  * @brief the information of the subscriber
44  *
45  */
46 typedef struct CommonEvent_SubscribeInfo CommonEvent_SubscribeInfo;
47 
48 /**
49  * @brief the subscriber of common event
50  *
51  */
52 typedef void CommonEvent_Subscriber;
53 
54 /**
55  * @brief the common event publish information containing content and attributes of the common event
56  *
57  */
58 typedef struct CommonEvent_PublishInfo CommonEvent_PublishInfo;
59 
60 /**
61  * @brief the data of the commonEvent callback
62  *
63  */
64 typedef struct CommonEvent_RcvData CommonEvent_RcvData;
65 
66 /**
67  * @brief The description of the parameters in a common event callback data.
68  *
69  */
70 typedef void CommonEvent_Parameters;
71 
72 /**
73  * @brief Common event callback.
74  *
75  * @param data common event callback data.
76  */
77 typedef void (*CommonEvent_ReceiveCallback)(const CommonEvent_RcvData *data);
78 
79 /**
80  * @brief Create subscribe information.
81  *
82  * @param events Indicates the subscribed events.
83  * @param eventsNum Indicates the subscribed events of number.
84  * @return Returns the CommonEvent_SubscribeInfo, if create failed, returns null.
85  */
86 CommonEvent_SubscribeInfo* OH_CommonEvent_CreateSubscribeInfo(const char* events[], int32_t eventsNum);
87 
88 /**
89  * @brief Set the permission of the subscribe information.
90  *
91  * @param info Indicates the subscribe information.
92  * @param permission Indicates the permission.
93  * @return Returns the error code.
94  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
95  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
96  */
97 CommonEvent_ErrCode OH_CommonEvent_SetPublisherPermission(CommonEvent_SubscribeInfo* info, const char* permission);
98 
99 /**
100  * @brief Set the bundleName of the subscribe information.
101  *
102  * @param info Indicates the subscribed events.
103  * @param bundleName Indicates the bundleName.
104  * @return Returns the error code.
105  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
106  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
107  */
108 CommonEvent_ErrCode OH_CommonEvent_SetPublisherBundleName(CommonEvent_SubscribeInfo* info, const char* bundleName);
109 
110 /**
111  * @brief Destroy the subscribe information.
112  *
113  * @param info Indicates the subscribe info.
114  */
115 void OH_CommonEvent_DestroySubscribeInfo(CommonEvent_SubscribeInfo* info);
116 
117 /**
118  * @brief Create a subscriber.
119  *
120  * @param info Indicates the created subscribe Info.
121  * @param callback Indicates the received common event callback.
122  * @return Returns the CommonEvent_Subscriber, if create failed, returns null.
123  */
124 CommonEvent_Subscriber* OH_CommonEvent_CreateSubscriber(const CommonEvent_SubscribeInfo* info,
125     CommonEvent_ReceiveCallback callback);
126 
127 /**
128  * @brief Destory the subscriber.
129  *
130  * @param subscriber Indicates the created subscriber.
131  */
132 void OH_CommonEvent_DestroySubscriber(CommonEvent_Subscriber* subscriber);
133 
134 /**
135  * @brief Subscribe event by a subscriber.
136  *
137  * @param subscriber Indicates the subscriber.
138  * @return Returns the error code.
139  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
140  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER } if the input parameter is invalid.
141  *         Returns {@link COMMONEVENT_ERR_FAIL_SEND_REQUEST } if IPC request failed to send.
142  *         Returns {@link COMMONEVENT_ERR_INIT_UNDONE } if ces not init done.
143  *         Returns {@link COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED } if the subscriber number is exceeded.
144  *         Returns {@link COMMONEVENT_ERR_ALLOC_MEMORY_FAILED } if a memory allocation error occurs.
145  * @since 12
146  */
147 CommonEvent_ErrCode OH_CommonEvent_Subscribe(const CommonEvent_Subscriber* subscriber);
148 
149 /**
150  * @brief Unsubscribe event by a subscriber.
151  *
152  * @param subscriber Indicates the subscriber.
153  * @return Returns the error code.
154  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
155  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER } if the input parameter is invalid.
156  *         Returns {@link COMMONEVENT_ERR_FAIL_SEND_REQUEST } if IPC request failed to send.
157  *         Returns {@link COMMONEVENT_ERR_INIT_UNDONE } if ces not init done.
158  * @since 12
159  */
160 CommonEvent_ErrCode OH_CommonEvent_UnSubscribe(const CommonEvent_Subscriber* subscriber);
161 
162 /**
163  * @brief Get event name from callback data.
164  *
165  * @param rcvData Indicates the callback data.
166  * @return Returns the event name.
167  */
168 const char* OH_CommonEvent_GetEventFromRcvData(const CommonEvent_RcvData* rcvData);
169 
170 /**
171  * @brief Get event result code from callback data.
172  *
173  * @param rcvData Indicates the callback data.
174  * @return Returns the event of result code, default is 0.
175  */
176 int32_t OH_CommonEvent_GetCodeFromRcvData(const CommonEvent_RcvData* rcvData);
177 
178 /**
179  * @brief Get event result data from callback data.
180  *
181  * @param rcvData Indicates the callback data.
182  * @return Returns the event of result data, default is null.
183  */
184 const char* OH_CommonEvent_GetDataStrFromRcvData(const CommonEvent_RcvData* rcvData);
185 
186 /**
187  * @brief Get event bundlename from callback data.
188  *
189  * @param rcvData Indicates the  callback data.
190  * @return Returns the event of bundlename, default is null.
191  */
192 const char* OH_CommonEvent_GetBundleNameFromRcvData(const CommonEvent_RcvData* rcvData);
193 
194 /**
195  * @brief Get event parameters data from callback data.
196  *
197  * @param rcvData Indicates the callback data.
198  * @return Returns the event parameters data, default is null.
199  */
200 const CommonEvent_Parameters* OH_CommonEvent_GetParametersFromRcvData(const CommonEvent_RcvData* rcvData);
201 
202 /**
203  * @brief Create a common event publish information.
204  *
205  * @param ordered Indicates whether the common event is ordered.
206  * @return Returns the CommonEvent_PublishInfo, if create failed, returns null.
207  */
208 CommonEvent_PublishInfo* OH_CommonEvent_CreatePublishInfo(bool ordered);
209 
210 /**
211  * @brief Destroy the common event publish information.
212  *
213  * @param info Indicates the publish information.
214  */
215 void OH_CommonEvent_DestroyPublishInfo(CommonEvent_PublishInfo* info);
216 
217 /**
218  * @brief Set the bundleName of publish information.
219  *
220  * @param info Indicates the publish information.
221  * @param bundleName Indicates the bundleName.
222  * @return Returns the error code.
223  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
224  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
225  */
226 CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoBundleName(CommonEvent_PublishInfo* info, const char* bundleName);
227 
228 /**
229  * @brief Set the permissions of publish information.
230  *
231  * @param info Indicates the publish information.
232  * @param permissions Indicates the array of permissions.
233  * @param num Indicates the count of permissions.
234  * @return Returns the error code.
235  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
236  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
237  */
238 CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoPermissions(CommonEvent_PublishInfo* info,
239     const char* permissions[], int32_t num);
240 
241 /**
242  * @brief Set the code of publish information.
243  *
244  * @param info Indicates the publish information.
245  * @param code Indicates the code.
246  * @return Returns the error code.
247  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
248  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
249  */
250 CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoCode(CommonEvent_PublishInfo* info, int32_t code);
251 
252 /**
253  * @brief Set the data of publish information.
254  *
255  * @param info Indicates the publish information.
256  * @param data Indicates the data.
257  * @param length Indicates the length of data.
258  * @return Returns the error code.
259  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
260  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
261  */
262 CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoData(CommonEvent_PublishInfo* info,
263     const char* data, size_t length);
264 
265 /**
266  * @brief Set the parameters of publish information.
267  *
268  * @param info Indicates the publish information.
269  * @param param Indicates the parameters.
270  * @return Returns the error code.
271  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
272  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
273  */
274 CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoParameters(CommonEvent_PublishInfo* info,
275     CommonEvent_Parameters* param);
276 
277 /**
278  * @brief Create a common event publish information.
279  *
280  * @return Returns the CommonEvent_PublishInfo, if create failed, returns null.
281  */
282 CommonEvent_Parameters* OH_CommonEvent_CreateParameters();
283 
284 /**
285  * @brief Destroy the common event publish information.
286  *
287  * @param param Indicates the publish information.
288  */
289 void OH_CommonEvent_DestroyParameters(CommonEvent_Parameters* param);
290 
291 /**
292  * @brief Check whether the parameters data contains a key.
293  *
294  * @param para Indicates the parameters data.
295  * @param key Indicates the key.
296  * @return Returns the result of check, true means it contains.
297  */
298 bool OH_CommonEvent_HasKeyInParameters(const CommonEvent_Parameters* para, const char* key);
299 
300 /**
301  * @brief Get int data from parameters data by key.
302  *
303  * @param para Indicates the parameters data.
304  * @param key Indicates the key.
305  * @param defaultValue Indicates default return value.
306  * @return Returns the int data of the key in the parameters.
307  */
308 int OH_CommonEvent_GetIntFromParameters(const CommonEvent_Parameters* para, const char* key, const int defaultValue);
309 
310 /**
311  * @brief Set int data to parameters data by key.
312  *
313  * @param param Indicates the parameters data.
314  * @param key Indicates the key.
315  * @param value Indicates the int data.
316  * @return Returns the error code.
317  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
318  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
319  */
320 CommonEvent_ErrCode OH_CommonEvent_SetIntToParameters(CommonEvent_Parameters* param, const char* key, int value);
321 
322 /**
323  * @brief Get int array data from parameters data by key.
324  *
325  * @param para Indicates the parameters data.
326  * @param key Indicates the key.
327  * @param array Indicates the int array.
328  * @return Returns the length of the array.
329  */
330 int32_t OH_CommonEvent_GetIntArrayFromParameters(const CommonEvent_Parameters* para, const char* key, int** array);
331 
332 /**
333  * @brief Set int array data to parameters data by key.
334  *
335  * @param param Indicates the parameters data.
336  * @param key Indicates the key.
337  * @param value Indicates the int array data.
338  * @param num Indicates the length of the array.
339  * @return Returns the error code.
340  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
341  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
342  *         Returns {@link COMMONEVENT_ERR_ALLOC_MEMORY_FAILED} if a memory allocation error occurs.
343  */
344 CommonEvent_ErrCode OH_CommonEvent_SetIntArrayToParameters(CommonEvent_Parameters* param, const char* key,
345     const int* value, size_t num);
346 
347 /**
348  * @brief Get long data from parameters data by key.
349  *
350  * @param para Indicates the parameters data.
351  * @param key Indicates the key.
352  * @param defaultValue Indicates default return value.
353  * @return Returns the long data of the key in the parameters.
354  */
355 long OH_CommonEvent_GetLongFromParameters(const CommonEvent_Parameters* para, const char* key,
356     const long defaultValue);
357 
358 /**
359  * @brief Set long data to parameters data by key.
360  *
361  * @param param Indicates the parameters data.
362  * @param key Indicates the key.
363  * @param value Indicates the long data.
364  * @return Returns the error code.
365  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
366  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
367  */
368 CommonEvent_ErrCode OH_CommonEvent_SetLongToParameters(CommonEvent_Parameters* param, const char* key,
369     long value);
370 
371 /**
372  * @brief Get long array data from parameters data by key.
373  *
374  * @param para Indicates the parameters data.
375  * @param key Indicates the key.
376  * @param array Indicates the long array.
377  * @return Returns the length of the array.
378  */
379 int32_t OH_CommonEvent_GetLongArrayFromParameters(const CommonEvent_Parameters* para, const char* key, long** array);
380 
381 /**
382  * @brief Set long array data to parameters data by key.
383  *
384  * @param param Indicates the parameters data.
385  * @param key Indicates the key.
386  * @param value Indicates the long array data.
387  * @param num Indicates the length of the array.
388  * @return Returns the error code.
389  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
390  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
391  *         Returns {@link COMMONEVENT_ERR_ALLOC_MEMORY_FAILED} if a memory allocation error occurs.
392  */
393 CommonEvent_ErrCode OH_CommonEvent_SetLongArrayToParameters(CommonEvent_Parameters* param, const char* key,
394     const long* value, size_t num);
395 
396 /**
397  * @brief Get bool data from parameters data by key.
398  *
399  * @param para Indicates the parameters data.
400  * @param key Indicates the key.
401  * @param defaultValue Indicates default return value.
402  * @return Returns the bool data of the key in the parameters.
403  */
404 bool OH_CommonEvent_GetBoolFromParameters(const CommonEvent_Parameters* para, const char* key,
405     const bool defaultValue);
406 
407 /**
408  * @brief Set bool data to parameters data by key.
409  *
410  * @param param Indicates the parameters data.
411  * @param key Indicates the key.
412  * @param value Indicates the bool data.
413  * @return Returns the error code.
414  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
415  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
416  */
417 CommonEvent_ErrCode OH_CommonEvent_SetBoolToParameters(CommonEvent_Parameters* param, const char* key,
418     bool value);
419 
420 /**
421  * @brief Get bool array data from parameters data by key.
422  *
423  * @param para Indicates the parameters data.
424  * @param key Indicates the key.
425  * @param array Indicates the bool array.
426  * @return Returns the length of the array.
427  */
428 int32_t OH_CommonEvent_GetBoolArrayFromParameters(const CommonEvent_Parameters* para, const char* key, bool** array);
429 
430 /**
431  * @brief Set bool array data to parameters data by key.
432  *
433  * @param param Indicates the parameters data.
434  * @param key Indicates the key.
435  * @param value Indicates the bool array data.
436  * @param num Indicates the length of the array.
437  * @return Returns the error code.
438  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
439  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
440  *         Returns {@link COMMONEVENT_ERR_ALLOC_MEMORY_FAILED} if a memory allocation error occurs.
441  */
442 CommonEvent_ErrCode OH_CommonEvent_SetBoolArrayToParameters(CommonEvent_Parameters* param, const char* key,
443     const bool* value, size_t num);
444 
445 /**
446  * @brief Get char data from parameters data by key.
447  *
448  * @param para Indicates the parameters data.
449  * @param key Indicates the key.
450  * @param defaultValue Indicates default return value.
451  * @return Returns the char data of the key in the parameters.
452  */
453 char OH_CommonEvent_GetCharFromParameters(const CommonEvent_Parameters* para, const char* key,
454     const char defaultValue);
455 
456 /**
457  * @brief Set char data to parameters data by key.
458  *
459  * @param param Indicates the parameters data.
460  * @param key Indicates the key.
461  * @param value Indicates the char data.
462  * @return Returns the error code.
463  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
464  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
465  */
466 CommonEvent_ErrCode OH_CommonEvent_SetCharToParameters(CommonEvent_Parameters* param, const char* key,
467     char value);
468 
469 /**
470  * @brief Get char array data from parameters data by key.
471  *
472  * @param para Indicates the parameters data.
473  * @param key Indicates the key.
474  * @param array Indicates the char array.
475  * @return Returns the length of the array.
476  */
477 int32_t OH_CommonEvent_GetCharArrayFromParameters(const CommonEvent_Parameters* para, const char* key, char** array);
478 
479 /**
480  * @brief Set char array data to parameters data by key.
481  *
482  * @param param Indicates the parameters data.
483  * @param key Indicates the key.
484  * @param value Indicates the char array data.
485  * @param num Indicates the length of the array.
486  * @return Returns the error code.
487  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
488  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
489  */
490 CommonEvent_ErrCode OH_CommonEvent_SetCharArrayToParameters(CommonEvent_Parameters* param, const char* key,
491     const char* value, size_t num);
492 
493 /**
494  * @brief Get double data from parameters data by key.
495  *
496  * @param para Indicates the parameters data.
497  * @param key Indicates the key.
498  * @param defaultValue Indicates default return value.
499  * @return Returns the double data of the key in the parameters.
500  */
501 double OH_CommonEvent_GetDoubleFromParameters(const CommonEvent_Parameters* para, const char* key,
502     const double defaultValue);
503 
504 /**
505  * @brief Set double data to parameters data by key.
506  *
507  * @param param Indicates the parameters data.
508  * @param key Indicates the key.
509  * @param value Indicates the double data.
510  * @return Returns the error code.
511  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
512  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
513  */
514 CommonEvent_ErrCode OH_CommonEvent_SetDoubleToParameters(CommonEvent_Parameters* param, const char* key,
515     double value);
516 
517 /**
518  * @brief Get double array data from parameters data by key.
519  *
520  * @param para Indicates the parameters data.
521  * @param key Indicates the key.
522  * @param array Indicates the double array.
523  * @return Returns the length of the array, default is 0.
524  */
525 int32_t OH_CommonEvent_GetDoubleArrayFromParameters(const CommonEvent_Parameters* para, const char* key,
526     double** array);
527 
528 /**
529  * @brief Set double array data to parameters data by key.
530  *
531  * @param param Indicates the parameters data.
532  * @param key Indicates the key.
533  * @param value Indicates the double array data.
534  * @param num Indicates the length of the array.
535  * @return Returns the error code.
536  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
537  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
538  *         Returns {@link COMMONEVENT_ERR_ALLOC_MEMORY_FAILED} if a memory allocation error occurs.
539  */
540 CommonEvent_ErrCode OH_CommonEvent_SetDoubleArrayToParameters(CommonEvent_Parameters* param, const char* key,
541     const double* value, size_t num);
542 
543 /**
544  * @brief Publish a standard commen event.
545  *
546  * @param event Indicates the name of the common event.
547  * @return Returns the error code.
548  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
549  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
550  *         Returns {@link COMMONEVENT_ERR_FAIL_SEND_REQUEST } if IPC request failed to send.
551  *         Returns {@link COMMONEVENT_ERR_INIT_UNDONE } if ces not init done.
552  */
553 CommonEvent_ErrCode OH_CommonEvent_Publish(const char* event);
554 
555 /**
556  * @brief Publish a commen event with specified publish information.
557  *
558  * @param event Indicates the name of the common event.
559  * @param info Indicates the publish information.
560  * @return Returns the error code.
561  *         Returns {@link COMMONEVENT_ERR_OK} if the operation is successful.
562  *         Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs.
563  *         Returns {@link COMMONEVENT_ERR_FAIL_SEND_REQUEST } if IPC request failed to send.
564  *         Returns {@link COMMONEVENT_ERR_INIT_UNDONE } if ces not init done.
565  */
566 CommonEvent_ErrCode OH_CommonEvent_PublishWithInfo(const char* event, const CommonEvent_PublishInfo* info);
567 
568 /**
569  * @brief Check an event by a subscriber whether it is ordered.
570  *
571  * @param subscriber Indicates the subscriber.
572  * @return Returns the result of check, true means ordered.
573  */
574 bool OH_CommonEvent_IsOrderedCommonEvent(const CommonEvent_Subscriber* subscriber);
575 
576 /**
577  * @brief Finish an ordered event by a subscriber.
578  *
579  * @param subscriber Indicates the subscriber.
580  * @return Returns the result of operation, true means succeeded.
581  */
582 bool OH_CommonEvent_FinishCommonEvent(CommonEvent_Subscriber* subscriber);
583 
584 /**
585  * @brief Check an event by a subscriber whether it is aborted.
586  *
587  * @param subscriber Indicates the subscriber.
588  * @return Returns the result of check, true means aborted.
589  */
590 bool OH_CommonEvent_GetAbortCommonEvent(const CommonEvent_Subscriber* subscriber);
591 
592 /**
593  * @brief Abort an ordered event by a subscriber.
594  *
595  * @param subscriber Indicates the subscriber.
596  * @return Returns the result of operation, true means succeeded.
597  */
598 bool OH_CommonEvent_AbortCommonEvent(CommonEvent_Subscriber* subscriber);
599 
600 /**
601  * @brief Clear the aborted flag of an ordered event by a subscriber.
602  *
603  * @param subscriber Indicates the subscriber.
604  * @return Returns the result of operation, true means succeeded.
605  */
606 bool OH_CommonEvent_ClearAbortCommonEvent(CommonEvent_Subscriber* subscriber);
607 
608 /**
609  * @brief Get result code from an ordered event by a subscriber.
610  *
611  * @param subscriber Indicates the subscriber.
612  * @return Returns the result code, default is 0.
613  */
614 int32_t OH_CommonEvent_GetCodeFromSubscriber(const CommonEvent_Subscriber* subscriber);
615 
616 /**
617  * @brief Set result code to an ordered event by a subscriber.
618  *
619  * @param subscriber Indicates the subscriber.
620  * @param code Indicates the result code.
621  * @return Returns the result of operation, true means succeeded.
622  */
623 bool OH_CommonEvent_SetCodeToSubscriber(CommonEvent_Subscriber* subscriber, int32_t code);
624 
625 /**
626  * @brief Get result data from an ordered event by a subscriber.
627  *
628  * @param subscriber Indicates the subscriber.
629  * @return Returns the result data, default is null.
630  */
631 const char* OH_CommonEvent_GetDataFromSubscriber(const CommonEvent_Subscriber* subscriber);
632 
633 /**
634  * @brief Set result data to an ordered event by a subscriber.
635  *
636  * @param subscriber Indicates the subscriber.
637  * @param data Indicates the result data.
638  * @param length Indicates the length of result data.
639  * @return Returns the result of operation, true means succeeded.
640  */
641 bool OH_CommonEvent_SetDataToSubscriber(CommonEvent_Subscriber* subscriber, const char* data, size_t length);
642 
643 #ifdef __cplusplus
644 }
645 #endif
646 #endif // OH_COMMONEVENT_SUPPORT_CODE_H