upload tizen1.0 source
[pkgs/o/oma-ds-service.git] / include / ServiceAdapter / SA_Command.h
1 /*
2  * oma-ds-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JuHak Park <juhaki.park@samsung.com>,
7  *          JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8  *          SunBong Ha <sunbong.ha@samsung.com>
9  *
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
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
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.
21  *
22  */
23
24
25
26
27
28 /*
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.
33  *
34  * SeongWon Shim <seongwon.shim@samsung.com>
35  */
36
37 /**
38  *   @SA_Commandl.h
39  *   @version                                                                   0.1
40  *   @brief                                                                             This file is the header file of interface of Command structure
41  */
42
43 #ifndef SA_COMMAND_H_
44 #define SA_COMMAND_H_
45
46 #include "ServiceAdapter/SA_Define.h"
47 #include "Common/Common_Define.h"
48
49
50 /**
51  * @par Description: API to create alert command
52  *
53  *
54  * @par Purpose:
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
66  *
67  * @return                      ERROR_INTERNAL_OK on success
68  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
69  *
70  * @par Errors:
71  *
72  * @pre None.
73  * @post
74  * @see
75  * @remarks None.
76  *
77  * @par Sample Code:
78  * @code
79  * @endcode
80  */
81 SA_ErrorType create_alert_command(Session *session, AlertType  syncType, Location *source, Location *target,
82                 char *lastAnchor, char *nextAnchor, Cred *pCred, Command **pCommand);
83
84 /**
85  * @par Description: API to create get command
86  *
87  *
88  * @par Purpose:
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
96  *
97  * @return                      ERROR_INTERNAL_OK on success
98  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
99  *
100  * @par Errors:
101  *
102  * @pre None.
103  * @post
104  * @see
105  * @remarks None.
106  *
107  * @par Sample Code:
108  * @code
109  * @endcode
110  */
111 SA_ErrorType create_get_command(Session *session, Location* target, const char *contenttype, Command **pCommand);
112
113 /**
114  * @par Description: API to create put command
115  *
116  *
117  * @par Purpose:
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
126  *
127  * @return                      ERROR_INTERNAL_OK on success
128  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
129  *
130  * @par Errors:
131  *
132  * @pre None.
133  * @post
134  * @see
135  * @remarks None.
136  *
137  * @par Sample Code:
138  * @code
139  * @endcode
140  */
141 SA_ErrorType create_put_command(Session *session, Location *source,  const char *contenttype,  DevInf *devInf , Command **pCommand);
142
143 /**
144  * @par Description: API to create results command
145  *
146  *
147  * @par Purpose:
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
156  *
157  * @return                      ERROR_INTERNAL_OK on success
158  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
159  *
160  * @par Errors:
161  *
162  * @pre None.
163  * @post
164  * @see
165  * @remarks None.
166  *
167  * @par Sample Code:
168  * @code
169  * @endcode
170  */
171 SA_ErrorType create_results_command(Session *session, Location *source, const char *contenttype, DevInf *devInf, Command **pCommand);
172
173 /**
174  * @par Description: API to create sync start command
175  *
176  *
177  * @par Purpose:
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
185  *
186  * @return                      ERROR_INTERNAL_OK on success
187  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
188  *
189  * @par Errors:
190  *
191  * @pre None.
192  * @post
193  * @see
194  * @remarks None.
195  *
196  * @par Sample Code:
197  * @code
198  * @endcode
199  */
200 SA_ErrorType create_sync_start_command(Session *session, Location *source, Location *target, Command **pCommand);
201
202 /**
203  * @par Description: API to create sync end command
204  *
205  *
206  * @par Purpose:
207  * @par Typical use case:
208  * @par Method of function operation:
209  * @par Important notes:
210  * @param[in]
211  * @param[out]          Command structure
212  *
213  * @return                      ERROR_INTERNAL_OK on success
214  *                                              ERROR_INTERNAL_NO_MEMORY on error
215  *
216  * @par Errors:
217  *
218  * @pre None.
219  * @post
220  * @see
221  * @remarks None.
222  *
223  * @par Sample Code:
224  * @code
225  * @endcode
226  */
227 SA_ErrorType create_sync_end_command(Command **pCommand);
228
229 /**
230  * @par Description: API to create add command
231  *
232  *
233  * @par Purpose:
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
245  *
246  * @return                      ERROR_INTERNAL_OK on success
247  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
248  *
249  * @par Errors:
250  *
251  * @pre None.
252  * @post
253  * @see
254  * @remarks None.
255  *
256  * @par Sample Code:
257  * @code
258  * @endcode
259  */
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);
262
263 /**
264  * @par Description: API to create replace command
265  *
266  *
267  * @par Purpose:
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
279  *
280  * @return                      ERROR_INTERNAL_OK on success
281  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
282  *
283  * @par Errors:
284  *
285  * @pre None.
286  * @post
287  * @see
288  * @remarks None.
289  *
290  * @par Sample Code:
291  * @code
292  * @endcode
293  */
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);
296
297 /**
298  * @par Description: API to create delete command
299  *
300  *
301  * @par Purpose:
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
310  *
311  * @return                      ERROR_INTERNAL_OK on success
312  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
313  *
314  * @par Errors:
315  *
316  * @pre None.
317  * @post
318  * @see
319  * @remarks None.
320  *
321  * @par Sample Code:
322  * @code
323  * @endcode
324  */
325 SA_ErrorType create_delete_command(Session *session, ChangeType type, char *luid, const char *contenttype, Command **pCommand);
326
327 /**
328  * @par Description: API to create map command
329  *
330  *
331  * @par Purpose:
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
339  *
340  * @return                      ERROR_INTERNAL_OK on success
341  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
342  *
343  * @par Errors:
344  *
345  * @pre None.
346  * @post
347  * @see
348  * @remarks None.
349  *
350  * @par Sample Code:
351  * @code
352  * @endcode
353  */
354 SA_ErrorType create_map_command(Session *session, Location *source, Location *target, Command **pCommand);
355
356 /**
357  * @par Description: API to free list of command structure
358  *
359  *
360  * @par Purpose:
361  * @par Typical use case:
362  * @par Method of function operation:
363  * @par Important notes:
364  * @param[in]           list of command structure
365  * @param[out]
366  *
367  * @return
368  *
369  * @par Errors:
370  *
371  * @pre None.
372  * @post
373  * @see
374  * @remarks None.
375  *
376  * @par Sample Code:
377  * @code
378  * @endcode
379  */
380 void free_commands(GList *commands);
381
382 /**
383  * @par Description: API to free command structure
384  *
385  *
386  * @par Purpose:
387  * @par Typical use case:
388  * @par Method of function operation:
389  * @par Important notes:
390  * @param[in]           command structure
391  * @param[out]
392  *
393  * @return
394  *
395  * @par Errors:
396  *
397  * @pre None.
398  * @post
399  * @see
400  * @remarks None.
401  *
402  * @par Sample Code:
403  * @code
404  * @endcode
405  */
406 void free_command(Command *pCommand);
407
408 /**
409  * @par Description: API to increase reference count of command
410  *
411  *
412  * @par Purpose:
413  * @par Typical use case:
414  * @par Method of function operation:
415  * @par Important notes:
416  * @param[in]           Command structure
417  * @param[out]
418  *
419  * @return                              ERROR_INTERNAL_OK on success
420  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
421  *
422  * @par Errors:
423  *
424  * @pre None.
425  * @post
426  * @see
427  * @remarks None.
428  *
429  * @par Sample Code:
430  * @code
431  * @endcode
432  */
433 SA_ErrorType increase_command_refcount(Command *pCommand);
434
435 /**
436  * @par Description: API to decrease reference count of command
437  *
438  *
439  * @par Purpose:
440  * @par Typical use case:
441  * @par Method of function operation:
442  * @par Important notes:
443  * @param[in]           Command structure
444  * @param[out]
445  *
446  * @return                              ERROR_INTERNAL_OK on success
447  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
448  *
449  * @par Errors:
450  *
451  * @pre None.
452  * @post
453  * @see
454  * @remarks None.
455  *
456  * @par Sample Code:
457  * @code
458  * @endcode
459  */
460 SA_ErrorType decrease_command_refcount(Command *pCommand);
461
462 /**
463  * @par Description: API to set msgRef in results command
464  *
465  *
466  * @par Purpose:
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
472  * @param[out]
473  *
474  * @return                              ERROR_INTERNAL_OK on success
475  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
476  *
477  * @par Errors:
478  *
479  * @pre None.
480  * @post
481  * @see
482  * @remarks None.
483  *
484  * @par Sample Code:
485  * @code
486  * @endcode
487  */
488 SA_ErrorType set_results_command_msgref(Command *pCommand, unsigned int msgRef);
489
490 /**
491  * @par Description: API to set cmdRef in results command
492  *
493  *
494  * @par Purpose:
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
500  * @param[out]
501  *
502  * @return                              ERROR_INTERNAL_OK on success
503  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
504  *
505  * @par Errors:
506  *
507  * @pre None.
508  * @post
509  * @see
510  * @remarks None.
511  *
512  * @par Sample Code:
513  * @code
514  * @endcode
515  */
516 SA_ErrorType set_results_command_cmdref(Command *pCommand, unsigned int cmdRef);
517
518 /**
519  * @par Description: API to set targetRef in results command
520  *
521  *
522  * @par Purpose:
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)
528  * @param[out]
529  *
530  * @return                              ERROR_INTERNAL_OK on success
531  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
532  *
533  * @par Errors:
534  *
535  * @pre None.
536  * @post
537  * @see
538  * @remarks None.
539  *
540  * @par Sample Code:
541  * @code
542  * @endcode
543  */
544 SA_ErrorType set_results_command_targetref(Command *pCommand, Location *pLocation);
545
546 /**
547  * @par Description: API to set numberofchanges in sync start command
548  *
549  *
550  * @par Purpose:
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
556  * @param[out]
557  *
558  * @return                              ERROR_INTERNAL_OK on success
559  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
560  *
561  * @par Errors:
562  *
563  * @pre None.
564  * @post
565  * @see
566  * @remarks None.
567  *
568  * @par Sample Code:
569  * @code
570  * @endcode
571  */
572 SA_ErrorType set_sync_start_command_numberofchanges(Command *pCommand, unsigned int numberOfChanges);
573
574 /**
575  * @par Description: API to set item in map command
576  *
577  *
578  * @par Purpose:
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
584  * @param[out]
585  *
586  * @return                              ERROR_INTERNAL_OK on success
587  *                                                      ERROR_INTERNAL_NOT_DEFINED on error
588  *
589  * @par Errors:
590  *
591  * @pre None.
592  * @post
593  * @see
594  * @remarks None.
595  *
596  * @par Sample Code:
597  * @code
598  * @endcode
599  */
600 SA_ErrorType set_map_command_item(Command *mapCommand, Item *temp);
601
602 /**
603  * @par Description: API to create status command with locatiion structure
604  *
605  *
606  * @par Purpose:
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
617  *
618  * @return                              ERROR_INTERNAL_OK on success
619  *                                                      ERROR_INTERNAL_NO_MEMORY on error
620  *
621  * @par Errors:
622  *
623  * @pre None.
624  * @post
625  * @see
626  * @remarks None.
627  *
628  * @par Sample Code:
629  * @code
630  * @endcode
631  */
632 SA_ErrorType create_new_status_location(Session *session, OMA_StatusType data, Command *command,
633                 Location *sourceref, Location *targetref, CommandType type, Status **pStatus);
634
635 /**
636  * @par Description: API to create create status command
637  *
638  *
639  * @par Purpose:
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
648  *
649  * @return                              ERROR_INTERNAL_OK on success
650  *                                                      ERROR_INTERNAL_NO_MEMORY on error
651  *
652  * @par Errors:
653  *
654  * @pre None.
655  * @post
656  * @see
657  * @remarks None.
658  *
659  * @par Sample Code:
660  * @code
661  * @endcode
662  */
663 SA_ErrorType create_new_status(Session *session, OMA_StatusType data, Command *command, CommandType type, Status **pStatus);
664
665 /**
666  * @par Description: API to create status command
667  *
668  *
669  * @par Purpose:
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
681  *
682  * @return                              ERROR_INTERNAL_OK on success
683  *                                                      ERROR_INTERNAL_NO_MEMORY on error
684  *
685  * @par Errors:
686  *
687  * @pre None.
688  * @post
689  * @see
690  * @remarks None.
691  *
692  * @par Sample Code:
693  * @code
694  * @endcode
695  */
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);
698
699 /**
700  * @par Description: API to free list of Status structure
701  *
702  *
703  * @par Purpose:
704  * @par Typical use case:
705  * @par Method of function operation:
706  * @par Important notes:
707  * @param[in]           list of Status structure
708  * @param[out]
709  *
710  * @return
711  *
712  * @par Errors:
713  *
714  * @pre None.
715  * @post
716  * @see
717  * @remarks None.
718  *
719  * @par Sample Code:
720  * @code
721  * @endcode
722  */
723 void free_statuses(GList *status);
724
725 /**
726  * @par Description: API to free Status structure
727  *
728  *
729  * @par Purpose:
730  * @par Typical use case:
731  * @par Method of function operation:
732  * @par Important notes:
733  * @param[in]           Status structure
734  * @param[out]
735  *
736  * @return
737  *
738  * @par Errors:
739  *
740  * @pre None.
741  * @post
742  * @see
743  * @remarks None.
744  *
745  * @par Sample Code:
746  * @code
747  * @endcode
748  */
749 void    free_status(Status *status);
750
751 /**
752  * @par Description: API to get status code from Status structure
753  *
754  *
755  * @par Purpose:
756  * @par Typical use case:
757  * @par Method of function operation:
758  * @par Important notes:
759  * @param[in]           Status structure
760  * @param[out]
761  *
762  * @return                              OMA_StatusType type
763  *
764  * @par Errors:
765  *
766  * @pre None.
767  * @post
768  * @see
769  * @remarks None.
770  *
771  * @par Sample Code:
772  * @code
773  * @endcode
774  */
775 OMA_StatusType get_status_code(Status *status);
776
777 /**
778  * @par Description: API to convert to command type from char*
779  *
780  *
781  * @par Purpose:
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)
786  * @param[out]
787  *
788  * @return                              CommandType type
789  *
790  * @par Errors:
791  *
792  * @pre None.
793  * @post
794  * @see
795  * @remarks None.
796  *
797  * @par Sample Code:
798  * @code
799  * @endcode
800  */
801 CommandType convert_command_type(char *type);
802
803 /**
804  * @par Description: API to convert to change type from command type
805  *
806  *
807  * @par Purpose:
808  * @par Typical use case:
809  * @par Method of function operation:
810  * @par Important notes:
811  * @param[in]           enum type, CommandType
812  * @param[out]
813  *
814  * @return                              ChangeType type
815  *
816  * @par Errors:
817  *
818  * @pre None.
819  * @post
820  * @see
821  * @remarks None.
822  *
823  * @par Sample Code:
824  * @code
825  * @endcode
826  */
827 ChangeType convert_change_type_command_type(CommandType type);
828
829 /**
830  * @par Description: API to convert to command type from change type
831  *
832  *
833  * @par Purpose:
834  * @par Typical use case:
835  * @par Method of function operation:
836  * @par Important notes:
837  * @param[in]           enum type, ChangeType
838  * @param[out]
839  *
840  * @return                              CommandType type
841  *
842  * @par Errors:
843  *
844  * @pre None.
845  * @post
846  * @see
847  * @remarks None.
848  *
849  * @par Sample Code:
850  * @code
851  * @endcode
852  */
853 CommandType convert_command_type_change_type(ChangeType type);
854
855
856 /* unused function
857  * keep for  in case
858  */
859 /*
860 ChangeType convertToChangeType(unsigned int type);
861 char *convertFromCommandType(CommandType type);
862 */
863
864 #endif /* SA_COMMAND_H_ */