Tizen 2.0 Release
[pkgs/o/oma-ds-service.git] / include / service-adapter / sa_command.h
1 /*
2  * oma-ds-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 /**
19  *   @SA_Commandl.h
20  *   @version                                                                   0.1
21  *   @brief                                                                             This file is the header file of interface of Command structure
22  */
23
24 #ifndef SA_COMMAND_H_
25 #define SA_COMMAND_H_
26
27 #include "service-adapter/sa_define.h"
28 #include "common/common_define.h"
29
30 /**
31  * @par Description: API to create alert command
32  *
33  *
34  * @par Purpose:
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
46  *
47  * @return                      ERROR_INTERNAL_OK on success
48  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
49  *
50  * @par Errors:
51  *
52  * @pre None.
53  * @post
54  * @see
55  * @remarks None.
56  *
57  * @par Sample Code:
58  * @code
59  * @endcode
60  */
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);
62
63 /**
64  * @par Description: API to create get command
65  *
66  *
67  * @par Purpose:
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
75  *
76  * @return                      ERROR_INTERNAL_OK on success
77  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
78  *
79  * @par Errors:
80  *
81  * @pre None.
82  * @post
83  * @see
84  * @remarks None.
85  *
86  * @par Sample Code:
87  * @code
88  * @endcode
89  */
90 sa_error_type_e create_get_command(session_s * session, location_s * target, const char *content_type, command_s ** command);
91
92 /**
93  * @par Description: API to create put command
94  *
95  *
96  * @par Purpose:
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
105  *
106  * @return                      ERROR_INTERNAL_OK on success
107  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
108  *
109  * @par Errors:
110  *
111  * @pre None.
112  * @post
113  * @see
114  * @remarks None.
115  *
116  * @par Sample Code:
117  * @code
118  * @endcode
119  */
120 sa_error_type_e create_put_command(session_s * session, location_s * source, const char *content_type, devinf_s * devinf, command_s ** command);
121
122 /**
123  * @par Description: API to create results command
124  *
125  *
126  * @par Purpose:
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
135  *
136  * @return                      ERROR_INTERNAL_OK on success
137  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
138  *
139  * @par Errors:
140  *
141  * @pre None.
142  * @post
143  * @see
144  * @remarks None.
145  *
146  * @par Sample Code:
147  * @code
148  * @endcode
149  */
150 sa_error_type_e create_results_command(session_s * session, location_s * source, const char *content_type, devinf_s * devinf, command_s ** command);
151
152 /**
153  * @par Description: API to create sync start command
154  *
155  *
156  * @par Purpose:
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
164  *
165  * @return                      ERROR_INTERNAL_OK on success
166  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
167  *
168  * @par Errors:
169  *
170  * @pre None.
171  * @post
172  * @see
173  * @remarks None.
174  *
175  * @par Sample Code:
176  * @code
177  * @endcode
178  */
179 sa_error_type_e create_sync_start_command(session_s * session, location_s * source, location_s * target, command_s ** command);
180
181 /**
182  * @par Description: API to create sync end command
183  *
184  *
185  * @par Purpose:
186  * @par Typical use case:
187  * @par Method of function operation:
188  * @par Important notes:
189  * @param[in]
190  * @param[out]          command_s structure
191  *
192  * @return                      ERROR_INTERNAL_OK on success
193  *                                              ERROR_INTERNAL_NO_MEMORY on error
194  *
195  * @par Errors:
196  *
197  * @pre None.
198  * @post
199  * @see
200  * @remarks None.
201  *
202  * @par Sample Code:
203  * @code
204  * @endcode
205  */
206 sa_error_type_e create_sync_end_command(command_s ** command);
207
208 /**
209  * @par Description: API to create add command
210  *
211  *
212  * @par Purpose:
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
224  *
225  * @return                      ERROR_INTERNAL_OK on success
226  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
227  *
228  * @par Errors:
229  *
230  * @pre None.
231  * @post
232  * @see
233  * @remarks None.
234  *
235  * @par Sample Code:
236  * @code
237  * @endcode
238  */
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);
240
241 /**
242  * @par Description: API to create replace command
243  *
244  *
245  * @par Purpose:
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
257  *
258  * @return                      ERROR_INTERNAL_OK on success
259  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
260  *
261  * @par Errors:
262  *
263  * @pre None.
264  * @post
265  * @see
266  * @remarks None.
267  *
268  * @par Sample Code:
269  * @code
270  * @endcode
271  */
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);
273
274 /**
275  * @par Description: API to create delete command
276  *
277  *
278  * @par Purpose:
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
287  *
288  * @return                      ERROR_INTERNAL_OK on success
289  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
290  *
291  * @par Errors:
292  *
293  * @pre None.
294  * @post
295  * @see
296  * @remarks None.
297  *
298  * @par Sample Code:
299  * @code
300  * @endcode
301  */
302 sa_error_type_e create_delete_command(session_s * session, change_type_e type, char *luid, const char *content_type, command_s ** command);
303
304 /**
305  * @par Description: API to create map command
306  *
307  *
308  * @par Purpose:
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
316  *
317  * @return                      ERROR_INTERNAL_OK on success
318  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
319  *
320  * @par Errors:
321  *
322  * @pre None.
323  * @post
324  * @see
325  * @remarks None.
326  *
327  * @par Sample Code:
328  * @code
329  * @endcode
330  */
331 sa_error_type_e create_map_command(session_s * session, location_s * source, location_s * target, command_s ** command);
332
333 /**
334  * @par Description: API to free list of command structure
335  *
336  *
337  * @par Purpose:
338  * @par Typical use case:
339  * @par Method of function operation:
340  * @par Important notes:
341  * @param[in]           list of command structure
342  * @param[out]
343  *
344  * @return
345  *
346  * @par Errors:
347  *
348  * @pre None.
349  * @post
350  * @see
351  * @remarks None.
352  *
353  * @par Sample Code:
354  * @code
355  * @endcode
356  */
357 void free_commands(GList * commands);
358
359 /**
360  * @par Description: API to free command structure
361  *
362  *
363  * @par Purpose:
364  * @par Typical use case:
365  * @par Method of function operation:
366  * @par Important notes:
367  * @param[in]           command structure
368  * @param[out]
369  *
370  * @return
371  *
372  * @par Errors:
373  *
374  * @pre None.
375  * @post
376  * @see
377  * @remarks None.
378  *
379  * @par Sample Code:
380  * @code
381  * @endcode
382  */
383 void free_command(command_s * command);
384
385 /**
386  * @par Description: API to increase reference count of command
387  *
388  *
389  * @par Purpose:
390  * @par Typical use case:
391  * @par Method of function operation:
392  * @par Important notes:
393  * @param[in]           command_s structure
394  * @param[out]
395  *
396  * @return                              ERROR_INTERNAL_OK on success
397  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
398  *
399  * @par Errors:
400  *
401  * @pre None.
402  * @post
403  * @see
404  * @remarks None.
405  *
406  * @par Sample Code:
407  * @code
408  * @endcode
409  */
410 sa_error_type_e increase_command_ref_count(command_s * command);
411
412 /**
413  * @par Description: API to decrease reference count of command
414  *
415  *
416  * @par Purpose:
417  * @par Typical use case:
418  * @par Method of function operation:
419  * @par Important notes:
420  * @param[in]           command_s structure
421  * @param[out]
422  *
423  * @return                              ERROR_INTERNAL_OK on success
424  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
425  *
426  * @par Errors:
427  *
428  * @pre None.
429  * @post
430  * @see
431  * @remarks None.
432  *
433  * @par Sample Code:
434  * @code
435  * @endcode
436  */
437 sa_error_type_e decrease_command_ref_count(command_s * command);
438
439 /**
440  * @par Description: API to set msgRef in results command
441  *
442  *
443  * @par Purpose:
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
449  * @param[out]
450  *
451  * @return                              ERROR_INTERNAL_OK on success
452  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
453  *
454  * @par Errors:
455  *
456  * @pre None.
457  * @post
458  * @see
459  * @remarks None.
460  *
461  * @par Sample Code:
462  * @code
463  * @endcode
464  */
465 sa_error_type_e set_results_command_msg_ref(command_s * command, unsigned int msg_ref);
466
467 /**
468  * @par Description: API to set cmdRef in results command
469  *
470  *
471  * @par Purpose:
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
477  * @param[out]
478  *
479  * @return                              ERROR_INTERNAL_OK on success
480  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
481  *
482  * @par Errors:
483  *
484  * @pre None.
485  * @post
486  * @see
487  * @remarks None.
488  *
489  * @par Sample Code:
490  * @code
491  * @endcode
492  */
493 sa_error_type_e set_results_command_cmd_ref(command_s * command, unsigned int cmd_ref);
494
495 /**
496  * @par Description: API to set targetRef in results command
497  *
498  *
499  * @par Purpose:
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)
505  * @param[out]
506  *
507  * @return                              ERROR_INTERNAL_OK on success
508  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
509  *
510  * @par Errors:
511  *
512  * @pre None.
513  * @post
514  * @see
515  * @remarks None.
516  *
517  * @par Sample Code:
518  * @code
519  * @endcode
520  */
521 sa_error_type_e set_results_command_target_ref(command_s * command, location_s * location);
522
523 /**
524  * @par Description: API to set number_of_changes in sync start command
525  *
526  *
527  * @par Purpose:
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
533  * @param[out]
534  *
535  * @return                              ERROR_INTERNAL_OK on success
536  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
537  *
538  * @par Errors:
539  *
540  * @pre None.
541  * @post
542  * @see
543  * @remarks None.
544  *
545  * @par Sample Code:
546  * @code
547  * @endcode
548  */
549 sa_error_type_e set_sync_start_command_number_of_changes(command_s * command, unsigned int number_of_changes);
550
551 /**
552  * @par Description: API to set Mem structure in sync start command
553  *
554  *
555  * @par Purpose:
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
561  * @param[out]
562  *
563  * @return                              ERROR_INTERNAL_OK on success
564  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
565  *
566  * @par Errors:
567  *
568  * @pre None.
569  * @post
570  * @see
571  * @remarks None.
572  *
573  * @par Sample Code:
574  * @code
575  * @endcode
576  */
577 sa_error_type_e set_sync_start_command_mem(command_s * command, mem_s * mem);
578
579 /**
580  * @par Description: API to set item in map command
581  *
582  *
583  * @par Purpose:
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
589  * @param[out]
590  *
591  * @return                              ERROR_INTERNAL_OK on success
592  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
593  *
594  * @par Errors:
595  *
596  * @pre None.
597  * @post
598  * @see
599  * @remarks None.
600  *
601  * @par Sample Code:
602  * @code
603  * @endcode
604  */
605 sa_error_type_e set_map_command_item(command_s * mapCommand, item_s * temp);
606
607 /**
608  * @par Description: API to create status command with locatiion structure
609  *
610  *
611  * @par Purpose:
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
622  *
623  * @return                              ERROR_INTERNAL_OK on success
624  *                                                      ERROR_INTERNAL_NO_MEMORY on error
625  *
626  * @par Errors:
627  *
628  * @pre None.
629  * @post
630  * @see
631  * @remarks None.
632  *
633  * @par Sample Code:
634  * @code
635  * @endcode
636  */
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);
638
639 /**
640  * @par Description: API to create create status command
641  *
642  *
643  * @par Purpose:
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
652  *
653  * @return                              ERROR_INTERNAL_OK on success
654  *                                                      ERROR_INTERNAL_NO_MEMORY on error
655  *
656  * @par Errors:
657  *
658  * @pre None.
659  * @post
660  * @see
661  * @remarks None.
662  *
663  * @par Sample Code:
664  * @code
665  * @endcode
666  */
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);
668
669 /**
670  * @par Description: API to create status command
671  *
672  *
673  * @par Purpose:
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
685  *
686  * @return                              ERROR_INTERNAL_OK on success
687  *                                                      ERROR_INTERNAL_NO_MEMORY on error
688  *
689  * @par Errors:
690  *
691  * @pre None.
692  * @post
693  * @see
694  * @remarks None.
695  *
696  * @par Sample Code:
697  * @code
698  * @endcode
699  */
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);
701
702 /**
703  * @par Description: API to free list of Status structure
704  *
705  *
706  * @par Purpose:
707  * @par Typical use case:
708  * @par Method of function operation:
709  * @par Important notes:
710  * @param[in]           list of Status structure
711  * @param[out]
712  *
713  * @return
714  *
715  * @par Errors:
716  *
717  * @pre None.
718  * @post
719  * @see
720  * @remarks None.
721  *
722  * @par Sample Code:
723  * @code
724  * @endcode
725  */
726 void free_statuses(GList * status);
727
728 /**
729  * @par Description: API to free Status structure
730  *
731  *
732  * @par Purpose:
733  * @par Typical use case:
734  * @par Method of function operation:
735  * @par Important notes:
736  * @param[in]           Status structure
737  * @param[out]
738  *
739  * @return
740  *
741  * @par Errors:
742  *
743  * @pre None.
744  * @post
745  * @see
746  * @remarks None.
747  *
748  * @par Sample Code:
749  * @code
750  * @endcode
751  */
752 void free_status(status_s * status);
753
754 /**
755  * @par Description: API to get status code from Status structure
756  *
757  *
758  * @par Purpose:
759  * @par Typical use case:
760  * @par Method of function operation:
761  * @par Important notes:
762  * @param[in]           Status structure
763  * @param[out]
764  *
765  * @return                              OMA_StatusType type
766  *
767  * @par Errors:
768  *
769  * @pre None.
770  * @post
771  * @see
772  * @remarks None.
773  *
774  * @par Sample Code:
775  * @code
776  * @endcode
777  */
778 oma_status_type_e get_status_code(status_s * status);
779
780 /**
781  * @par Description: API to convert to command type from char*
782  *
783  *
784  * @par Purpose:
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)
789  * @param[out]
790  *
791  * @return                              command_type_e type
792  *
793  * @par Errors:
794  *
795  * @pre None.
796  * @post
797  * @see
798  * @remarks None.
799  *
800  * @par Sample Code:
801  * @code
802  * @endcode
803  */
804 command_type_e convert_command_type(char *type);
805
806 /**
807  * @par Description: API to convert to change type from command type
808  *
809  *
810  * @par Purpose:
811  * @par Typical use case:
812  * @par Method of function operation:
813  * @par Important notes:
814  * @param[in]           enum type, command_type_e
815  * @param[out]
816  *
817  * @return                              change_type_e type
818  *
819  * @par Errors:
820  *
821  * @pre None.
822  * @post
823  * @see
824  * @remarks None.
825  *
826  * @par Sample Code:
827  * @code
828  * @endcode
829  */
830 change_type_e convert_change_type_command_type(command_type_e type);
831
832 /**
833  * @par Description: API to convert to command type from change type
834  *
835  *
836  * @par Purpose:
837  * @par Typical use case:
838  * @par Method of function operation:
839  * @par Important notes:
840  * @param[in]           enum type, change_type_e
841  * @param[out]
842  *
843  * @return                              command_type_e type
844  *
845  * @par Errors:
846  *
847  * @pre None.
848  * @post
849  * @see
850  * @remarks None.
851  *
852  * @par Sample Code:
853  * @code
854  * @endcode
855  */
856 command_type_e convert_command_type_change_type(change_type_e type);
857
858 /* unused function
859  * keep for  in case
860  */
861 /*
862 ChangeType convertToChangeType(unsigned int type);
863 char *convertFromCommandType(CommandType type);
864 */
865
866 #endif                          /* SA_COMMAND_H_ */