4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JuHak Park <juhaki.park@samsung.com>,
7 * JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8 * SunBong Ha <sunbong.ha@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
29 * For any sort of issue you concern as to this software,
30 * you may use following point of contact.
31 * All resources contributed on this software
32 * are orinigally written by S-Core Inc., a member of Samsung Group.
34 * SeongWon Shim <seongwon.shim@samsung.com>
40 * @brief This file is the header file of interface of Command structure
46 #include "ServiceAdapter/SA_Define.h"
47 #include "Common/Common_Define.h"
51 * @par Description: API to create alert command
55 * @par Typical use case:
56 * @par Method of function operation:
57 * @par Important notes:
58 * @param[in] Session structure
59 * @param[in] enum type, sync type
60 * @param[in] Location structure(about source info)
61 * @param[in] Location structure(about target info)
62 * @param[in] string type, last anchor
63 * @param[in] string type, next anchor
64 * @param[in] Cred structure
65 * @param[out] Command structure
67 * @return ERROR_INTERNAL_OK on success
68 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
81 SA_ErrorType create_alert_command(Session *session, AlertType syncType, Location *source, Location *target,
82 char *lastAnchor, char *nextAnchor, Cred *pCred, Command **pCommand);
85 * @par Description: API to create get command
89 * @par Typical use case:
90 * @par Method of function operation:
91 * @par Important notes:
92 * @param[in] Session structure
93 * @param[in] Location structure(about target info)
94 * @param[in] string type, content type
95 * @param[out] Command structure
97 * @return ERROR_INTERNAL_OK on success
98 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
111 SA_ErrorType create_get_command(Session *session, Location* target, const char *contenttype, Command **pCommand);
114 * @par Description: API to create put command
118 * @par Typical use case:
119 * @par Method of function operation:
120 * @par Important notes:
121 * @param[in] Session structure
122 * @param[in] Location structure(about source info)
123 * @param[in] string type, content type
124 * @param[in] DevInf structure
125 * @param[out] Command structure
127 * @return ERROR_INTERNAL_OK on success
128 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
141 SA_ErrorType create_put_command(Session *session, Location *source, const char *contenttype, DevInf *devInf , Command **pCommand);
144 * @par Description: API to create results command
148 * @par Typical use case:
149 * @par Method of function operation:
150 * @par Important notes:
151 * @param[in] Session structure
152 * @param[in] Location structure(about source info)
153 * @param[in] string type, content type
154 * @param[in] DevInf structure
155 * @param[out] Command structure
157 * @return ERROR_INTERNAL_OK on success
158 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
171 SA_ErrorType create_results_command(Session *session, Location *source, const char *contenttype, DevInf *devInf, Command **pCommand);
174 * @par Description: API to create sync start command
178 * @par Typical use case:
179 * @par Method of function operation:
180 * @par Important notes:
181 * @param[in] Session structure
182 * @param[in] Location structure(about source info)
183 * @param[in] Location structure(about target info)
184 * @param[out] Command structure
186 * @return ERROR_INTERNAL_OK on success
187 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
200 SA_ErrorType create_sync_start_command(Session *session, Location *source, Location *target, Command **pCommand);
203 * @par Description: API to create sync end command
207 * @par Typical use case:
208 * @par Method of function operation:
209 * @par Important notes:
211 * @param[out] Command structure
213 * @return ERROR_INTERNAL_OK on success
214 * ERROR_INTERNAL_NO_MEMORY on error
227 SA_ErrorType create_sync_end_command(Command **pCommand);
230 * @par Description: API to create add command
234 * @par Typical use case:
235 * @par Method of function operation:
236 * @par Important notes:
237 * @param[in] Session structure
238 * @param[in] enum type, change type
239 * @param[in] string type, luid of item
240 * @param[in] string type, content type
241 * @param[in] string type, data(vobject)
242 * @param[in] unsigned int type, size of data
243 * @param[in] int type, moreData(LargeObj)
244 * @param[out] Command structure
246 * @return ERROR_INTERNAL_OK on success
247 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
260 SA_ErrorType create_add_command(Session *session, ChangeType type, char *luid, const char *contenttype,
261 char *data, unsigned int size, int moreData, Command **pCommand);
264 * @par Description: API to create replace command
268 * @par Typical use case:
269 * @par Method of function operation:
270 * @par Important notes:
271 * @param[in] Session structure
272 * @param[in] enum type, change type
273 * @param[in] string type, luid of item
274 * @param[in] string type, content type
275 * @param[in] string type, data(vobject)
276 * @param[in] unsigned int type, size of data
277 * @param[in] int type, moreData(LargeObj)
278 * @param[out] Command structure
280 * @return ERROR_INTERNAL_OK on success
281 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
294 SA_ErrorType create_replace_command(Session *session, ChangeType type, char *luid, const char *contenttype,
295 const char *data, unsigned int size, int moreData, Command **pCommand);
298 * @par Description: API to create delete command
302 * @par Typical use case:
303 * @par Method of function operation:
304 * @par Important notes:
305 * @param[in] Session structure
306 * @param[in] enum type, change type
307 * @param[in] string type, luid of item
308 * @param[in] string type, content type
309 * @param[out] Command structure
311 * @return ERROR_INTERNAL_OK on success
312 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
325 SA_ErrorType create_delete_command(Session *session, ChangeType type, char *luid, const char *contenttype, Command **pCommand);
328 * @par Description: API to create map command
332 * @par Typical use case:
333 * @par Method of function operation:
334 * @par Important notes:
335 * @param[in] Session structure
336 * @param[in] Location structure(about source info)
337 * @param[in] Location structure(about target info)
338 * @param[out] Command structure
340 * @return ERROR_INTERNAL_OK on success
341 * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
354 SA_ErrorType create_map_command(Session *session, Location *source, Location *target, Command **pCommand);
357 * @par Description: API to free list of command structure
361 * @par Typical use case:
362 * @par Method of function operation:
363 * @par Important notes:
364 * @param[in] list of command structure
380 void free_commands(GList *commands);
383 * @par Description: API to free command structure
387 * @par Typical use case:
388 * @par Method of function operation:
389 * @par Important notes:
390 * @param[in] command structure
406 void free_command(Command *pCommand);
409 * @par Description: API to increase reference count of command
413 * @par Typical use case:
414 * @par Method of function operation:
415 * @par Important notes:
416 * @param[in] Command structure
419 * @return ERROR_INTERNAL_OK on success
420 * ERROR_INTERNAL_NOT_DEFINED on error
433 SA_ErrorType increase_command_refcount(Command *pCommand);
436 * @par Description: API to decrease reference count of command
440 * @par Typical use case:
441 * @par Method of function operation:
442 * @par Important notes:
443 * @param[in] Command structure
446 * @return ERROR_INTERNAL_OK on success
447 * ERROR_INTERNAL_NOT_DEFINED on error
460 SA_ErrorType decrease_command_refcount(Command *pCommand);
463 * @par Description: API to set msgRef in results command
467 * @par Typical use case:
468 * @par Method of function operation:
469 * @par Important notes:
470 * @param[in] Commnad structure
471 * @param[in] unsigned int type, msg reference
474 * @return ERROR_INTERNAL_OK on success
475 * ERROR_INTERNAL_NOT_DEFINED on error
488 SA_ErrorType set_results_command_msgref(Command *pCommand, unsigned int msgRef);
491 * @par Description: API to set cmdRef in results command
495 * @par Typical use case:
496 * @par Method of function operation:
497 * @par Important notes:
498 * @param[in] Commnad structure
499 * @param[in] unsigned int, cmd reference
502 * @return ERROR_INTERNAL_OK on success
503 * ERROR_INTERNAL_NOT_DEFINED on error
516 SA_ErrorType set_results_command_cmdref(Command *pCommand, unsigned int cmdRef);
519 * @par Description: API to set targetRef in results command
523 * @par Typical use case:
524 * @par Method of function operation:
525 * @par Important notes:
526 * @param[in] Commnad structure
527 * @param[in] Location structure(target info)
530 * @return ERROR_INTERNAL_OK on success
531 * ERROR_INTERNAL_NOT_DEFINED on error
544 SA_ErrorType set_results_command_targetref(Command *pCommand, Location *pLocation);
547 * @par Description: API to set numberofchanges in sync start command
551 * @par Typical use case:
552 * @par Method of function operation:
553 * @par Important notes:
554 * @param[in] Commnad structure
555 * @param[in] unsigned int type, number of changes
558 * @return ERROR_INTERNAL_OK on success
559 * ERROR_INTERNAL_NOT_DEFINED on error
572 SA_ErrorType set_sync_start_command_numberofchanges(Command *pCommand, unsigned int numberOfChanges);
575 * @par Description: API to set item in map command
579 * @par Typical use case:
580 * @par Method of function operation:
581 * @par Important notes:
582 * @param[in] Commnad structure
583 * @param[in] item structure
586 * @return ERROR_INTERNAL_OK on success
587 * ERROR_INTERNAL_NOT_DEFINED on error
600 SA_ErrorType set_map_command_item(Command *mapCommand, Item *temp);
603 * @par Description: API to create status command with locatiion structure
607 * @par Typical use case:
608 * @par Method of function operation:
609 * @par Important notes:
610 * @param[in] Session structure
611 * @param[in] data (status code)
612 * @param[in] command structure
613 * @param[in] Location structure(about source info)
614 * @param[in] Location structure(about target info)
615 * @param[in] command type
616 * @param[out] Status structure
618 * @return ERROR_INTERNAL_OK on success
619 * ERROR_INTERNAL_NO_MEMORY on error
632 SA_ErrorType create_new_status_location(Session *session, OMA_StatusType data, Command *command,
633 Location *sourceref, Location *targetref, CommandType type, Status **pStatus);
636 * @par Description: API to create create status command
640 * @par Typical use case:
641 * @par Method of function operation:
642 * @par Important notes:
643 * @param[in] Session structure
644 * @param[in] enum type, data (status code)
645 * @param[in] command structure
646 * @param[in] enum type, command type
647 * @param[out] Status structure
649 * @return ERROR_INTERNAL_OK on success
650 * ERROR_INTERNAL_NO_MEMORY on error
663 SA_ErrorType create_new_status(Session *session, OMA_StatusType data, Command *command, CommandType type, Status **pStatus);
666 * @par Description: API to create status command
670 * @par Typical use case:
671 * @par Method of function operation:
672 * @par Important notes:
673 * @param[in] enum type, data (status code)
674 * @param[in] unsigned int type, cmd ID
675 * @param[in] unsigned int type, cmd reference
676 * @param[in] unsigned int type, msg reference
677 * @param[in] Location structure(about source info)
678 * @param[in] Location structure(about target info)
679 * @param[in] enum type, command type
680 * @param[out] Status structure
682 * @return ERROR_INTERNAL_OK on success
683 * ERROR_INTERNAL_NO_MEMORY on error
696 SA_ErrorType create_status(OMA_StatusType data, unsigned int cmdID, unsigned int cmdref, unsigned int msgref,
697 Location *sourceref, Location *targetref, CommandType type, Status **pStatus);
700 * @par Description: API to free list of Status structure
704 * @par Typical use case:
705 * @par Method of function operation:
706 * @par Important notes:
707 * @param[in] list of Status structure
723 void free_statuses(GList *status);
726 * @par Description: API to free Status structure
730 * @par Typical use case:
731 * @par Method of function operation:
732 * @par Important notes:
733 * @param[in] Status structure
749 void free_status(Status *status);
752 * @par Description: API to get status code from Status structure
756 * @par Typical use case:
757 * @par Method of function operation:
758 * @par Important notes:
759 * @param[in] Status structure
762 * @return OMA_StatusType type
775 OMA_StatusType get_status_code(Status *status);
778 * @par Description: API to convert to command type from char*
782 * @par Typical use case:
783 * @par Method of function operation:
784 * @par Important notes:
785 * @param[in] char* (Alert, Sync, Put, SyncHdr, Add, Replace, Map, Delete, Results, Get)
788 * @return CommandType type
801 CommandType convert_command_type(char *type);
804 * @par Description: API to convert to change type from command type
808 * @par Typical use case:
809 * @par Method of function operation:
810 * @par Important notes:
811 * @param[in] enum type, CommandType
814 * @return ChangeType type
827 ChangeType convert_change_type_command_type(CommandType type);
830 * @par Description: API to convert to command type from change type
834 * @par Typical use case:
835 * @par Method of function operation:
836 * @par Important notes:
837 * @param[in] enum type, ChangeType
840 * @return CommandType type
853 CommandType convert_command_type_change_type(ChangeType type);
860 ChangeType convertToChangeType(unsigned int type);
861 char *convertFromCommandType(CommandType type);
864 #endif /* SA_COMMAND_H_ */