3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 * @brief This file is the header file of interface of Command structure
27 #include "service-adapter/sa_define.h"
28 #include "common/common_define.h"
31 * @par Description: API to create alert command
35 * @par Typical use case:
36 * @par Method of function operation:
37 * @par Important notes:
38 * @param[in] session_s structure
39 * @param[in] enum type, sync type
40 * @param[in] location_s structure(about source info)
41 * @param[in] location_s structure(about target info)
42 * @param[in] string type, last anchor
43 * @param[in] string type, next anchor
44 * @param[in] Cred structure
45 * @param[out] command_s structure
47 * @return ERROR_INTERNAL_OK on success
48 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
61 sa_error_type_e create_alert_command(session_s * session, alert_type_e sync_type, location_s * source, location_s * target, char *last_anchor, char *next_anchor, cred_s * cred, command_s ** command);
64 * @par Description: API to create get command
68 * @par Typical use case:
69 * @par Method of function operation:
70 * @par Important notes:
71 * @param[in] session_s structure
72 * @param[in] location_s structure(about target info)
73 * @param[in] string type, content type
74 * @param[out] command_s structure
76 * @return ERROR_INTERNAL_OK on success
77 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
90 sa_error_type_e create_get_command(session_s * session, location_s * target, const char *content_type, command_s ** command);
93 * @par Description: API to create put command
97 * @par Typical use case:
98 * @par Method of function operation:
99 * @par Important notes:
100 * @param[in] session_s structure
101 * @param[in] location_s structure(about source info)
102 * @param[in] string type, content type
103 * @param[in] DevInf structure
104 * @param[out] command_s structure
106 * @return ERROR_INTERNAL_OK on success
107 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
120 sa_error_type_e create_put_command(session_s * session, location_s * source, const char *content_type, devinf_s * devinf, command_s ** command);
123 * @par Description: API to create results command
127 * @par Typical use case:
128 * @par Method of function operation:
129 * @par Important notes:
130 * @param[in] session_s structure
131 * @param[in] location_s structure(about source info)
132 * @param[in] string type, content type
133 * @param[in] DevInf structure
134 * @param[out] command_s structure
136 * @return ERROR_INTERNAL_OK on success
137 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
150 sa_error_type_e create_results_command(session_s * session, location_s * source, const char *content_type, devinf_s * devinf, command_s ** command);
153 * @par Description: API to create sync start command
157 * @par Typical use case:
158 * @par Method of function operation:
159 * @par Important notes:
160 * @param[in] session_s structure
161 * @param[in] location_s structure(about source info)
162 * @param[in] location_s structure(about target info)
163 * @param[out] command_s structure
165 * @return ERROR_INTERNAL_OK on success
166 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
179 sa_error_type_e create_sync_start_command(session_s * session, location_s * source, location_s * target, command_s ** command);
182 * @par Description: API to create sync end command
186 * @par Typical use case:
187 * @par Method of function operation:
188 * @par Important notes:
190 * @param[out] command_s structure
192 * @return ERROR_INTERNAL_OK on success
193 * ERROR_INTERNAL_NO_MEMORY on error
206 sa_error_type_e create_sync_end_command(command_s ** command);
209 * @par Description: API to create add command
213 * @par Typical use case:
214 * @par Method of function operation:
215 * @par Important notes:
216 * @param[in] session_s structure
217 * @param[in] enum type, change type
218 * @param[in] string type, luid of item
219 * @param[in] string type, content type
220 * @param[in] string type, data(vobject)
221 * @param[in] unsigned int type, size of data
222 * @param[in] int type, moreData(LargeObj)
223 * @param[out] command_s structure
225 * @return ERROR_INTERNAL_OK on success
226 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
239 sa_error_type_e create_add_command(session_s * session, change_type_e type, char *luid, const char *content_type, char *data, unsigned int size, int more_data, command_s ** command);
242 * @par Description: API to create replace command
246 * @par Typical use case:
247 * @par Method of function operation:
248 * @par Important notes:
249 * @param[in] session_s structure
250 * @param[in] enum type, change type
251 * @param[in] string type, luid of item
252 * @param[in] string type, content type
253 * @param[in] string type, data(vobject)
254 * @param[in] unsigned int type, size of data
255 * @param[in] int type, more_data(LargeObj)
256 * @param[out] command_s structure
258 * @return ERROR_INTERNAL_OK on success
259 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
272 sa_error_type_e create_replace_command(session_s * session, change_type_e type, char *luid, const char *content_type, const char *data, unsigned int size, int more_data, command_s ** command);
275 * @par Description: API to create delete command
279 * @par Typical use case:
280 * @par Method of function operation:
281 * @par Important notes:
282 * @param[in] session_s structure
283 * @param[in] enum type, change type
284 * @param[in] string type, luid of item
285 * @param[in] string type, content type
286 * @param[out] command_s structure
288 * @return ERROR_INTERNAL_OK on success
289 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
302 sa_error_type_e create_delete_command(session_s * session, change_type_e type, char *luid, const char *content_type, command_s ** command);
305 * @par Description: API to create map command
309 * @par Typical use case:
310 * @par Method of function operation:
311 * @par Important notes:
312 * @param[in] session_s structure
313 * @param[in] location_s structure(about source info)
314 * @param[in] location_s structure(about target info)
315 * @param[out] command_s structure
317 * @return ERROR_INTERNAL_OK on success
318 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
331 sa_error_type_e create_map_command(session_s * session, location_s * source, location_s * target, command_s ** command);
334 * @par Description: API to free list of command structure
338 * @par Typical use case:
339 * @par Method of function operation:
340 * @par Important notes:
341 * @param[in] list of command structure
357 void free_commands(GList * commands);
360 * @par Description: API to free command structure
364 * @par Typical use case:
365 * @par Method of function operation:
366 * @par Important notes:
367 * @param[in] command structure
383 void free_command(command_s * command);
386 * @par Description: API to increase reference count of command
390 * @par Typical use case:
391 * @par Method of function operation:
392 * @par Important notes:
393 * @param[in] command_s structure
396 * @return ERROR_INTERNAL_OK on success
397 * ERROR_INTERNAL_NOT_DEFINED on error
410 sa_error_type_e increase_command_ref_count(command_s * command);
413 * @par Description: API to decrease reference count of command
417 * @par Typical use case:
418 * @par Method of function operation:
419 * @par Important notes:
420 * @param[in] command_s structure
423 * @return ERROR_INTERNAL_OK on success
424 * ERROR_INTERNAL_NOT_DEFINED on error
437 sa_error_type_e decrease_command_ref_count(command_s * command);
440 * @par Description: API to set msgRef in results command
444 * @par Typical use case:
445 * @par Method of function operation:
446 * @par Important notes:
447 * @param[in] Commnad structure
448 * @param[in] unsigned int type, msg reference
451 * @return ERROR_INTERNAL_OK on success
452 * ERROR_INTERNAL_NOT_DEFINED on error
465 sa_error_type_e set_results_command_msg_ref(command_s * command, unsigned int msg_ref);
468 * @par Description: API to set cmdRef in results command
472 * @par Typical use case:
473 * @par Method of function operation:
474 * @par Important notes:
475 * @param[in] Commnad structure
476 * @param[in] unsigned int, cmd reference
479 * @return ERROR_INTERNAL_OK on success
480 * ERROR_INTERNAL_NOT_DEFINED on error
493 sa_error_type_e set_results_command_cmd_ref(command_s * command, unsigned int cmd_ref);
496 * @par Description: API to set targetRef in results command
500 * @par Typical use case:
501 * @par Method of function operation:
502 * @par Important notes:
503 * @param[in] command_s structure
504 * @param[in] location_s structure(target info)
507 * @return ERROR_INTERNAL_OK on success
508 * ERROR_INTERNAL_NOT_DEFINED on error
521 sa_error_type_e set_results_command_target_ref(command_s * command, location_s * location);
524 * @par Description: API to set number_of_changes in sync start command
528 * @par Typical use case:
529 * @par Method of function operation:
530 * @par Important notes:
531 * @param[in] command_s structure
532 * @param[in] unsigned int type, number of changes
535 * @return ERROR_INTERNAL_OK on success
536 * ERROR_INTERNAL_NOT_DEFINED on error
549 sa_error_type_e set_sync_start_command_number_of_changes(command_s * command, unsigned int number_of_changes);
552 * @par Description: API to set Mem structure in sync start command
556 * @par Typical use case:
557 * @par Method of function operation:
558 * @par Important notes:
559 * @param[in] command_s structure
560 * @param[in] mem_s structure
563 * @return ERROR_INTERNAL_OK on success
564 * ERROR_INTERNAL_NOT_DEFINED on error
577 sa_error_type_e set_sync_start_command_mem(command_s * command, mem_s * mem);
580 * @par Description: API to set item in map command
584 * @par Typical use case:
585 * @par Method of function operation:
586 * @par Important notes:
587 * @param[in] command_s structure
588 * @param[in] item_s structure
591 * @return ERROR_INTERNAL_OK on success
592 * ERROR_INTERNAL_NOT_DEFINED on error
605 sa_error_type_e set_map_command_item(command_s * mapCommand, item_s * temp);
608 * @par Description: API to create status command with locatiion structure
612 * @par Typical use case:
613 * @par Method of function operation:
614 * @par Important notes:
615 * @param[in] session_s structure
616 * @param[in] data (status code)
617 * @param[in] command_s structure
618 * @param[in] location_s structure(about source info)
619 * @param[in] location_s structure(about target info)
620 * @param[in] command type
621 * @param[out] status_s structure
623 * @return ERROR_INTERNAL_OK on success
624 * ERROR_INTERNAL_NO_MEMORY on error
637 sa_error_type_e create_new_status_location(session_s * session, oma_status_type_e data, command_s * command, location_s * source_ref, location_s * target_ref, command_type_e type, status_s ** status);
640 * @par Description: API to create create status command
644 * @par Typical use case:
645 * @par Method of function operation:
646 * @par Important notes:
647 * @param[in] session_s structure
648 * @param[in] enum type, data (status code)
649 * @param[in] command_s structure
650 * @param[in] enum type, command type
651 * @param[out] status_s structure
653 * @return ERROR_INTERNAL_OK on success
654 * ERROR_INTERNAL_NO_MEMORY on error
667 sa_error_type_e create_new_status(session_s * session, oma_status_type_e data, command_s * command, command_type_e type, status_s ** status);
670 * @par Description: API to create status command
674 * @par Typical use case:
675 * @par Method of function operation:
676 * @par Important notes:
677 * @param[in] enum type, data (status code)
678 * @param[in] unsigned int type, cmd ID
679 * @param[in] unsigned int type, cmd reference
680 * @param[in] unsigned int type, msg reference
681 * @param[in] location_s structure(about source info)
682 * @param[in] location_s structure(about target info)
683 * @param[in] enum type, command type
684 * @param[out] status_s structure
686 * @return ERROR_INTERNAL_OK on success
687 * ERROR_INTERNAL_NO_MEMORY on error
700 sa_error_type_e create_status(oma_status_type_e data, unsigned int cmd_id, unsigned int cmd_ref, unsigned int msg_ref, location_s * source_ref, location_s * target_ref, command_type_e type, status_s ** status);
703 * @par Description: API to free list of Status structure
707 * @par Typical use case:
708 * @par Method of function operation:
709 * @par Important notes:
710 * @param[in] list of Status structure
726 void free_statuses(GList * status);
729 * @par Description: API to free Status structure
733 * @par Typical use case:
734 * @par Method of function operation:
735 * @par Important notes:
736 * @param[in] Status structure
752 void free_status(status_s * status);
755 * @par Description: API to get status code from Status structure
759 * @par Typical use case:
760 * @par Method of function operation:
761 * @par Important notes:
762 * @param[in] Status structure
765 * @return OMA_StatusType type
778 oma_status_type_e get_status_code(status_s * status);
781 * @par Description: API to convert to command type from char*
785 * @par Typical use case:
786 * @par Method of function operation:
787 * @par Important notes:
788 * @param[in] char* (Alert, Sync, Put, SyncHdr, Add, Replace, Map, Delete, Results, Get)
791 * @return command_type_e type
804 command_type_e convert_command_type(char *type);
807 * @par Description: API to convert to change type from command type
811 * @par Typical use case:
812 * @par Method of function operation:
813 * @par Important notes:
814 * @param[in] enum type, command_type_e
817 * @return change_type_e type
830 change_type_e convert_change_type_command_type(command_type_e type);
833 * @par Description: API to convert to command type from change type
837 * @par Typical use case:
838 * @par Method of function operation:
839 * @par Important notes:
840 * @param[in] enum type, change_type_e
843 * @return command_type_e type
856 command_type_e convert_command_type_change_type(change_type_e type);
862 ChangeType convertToChangeType(unsigned int type);
863 char *convertFromCommandType(CommandType type);
866 #endif /* SA_COMMAND_H_ */