Tizen 2.0 Release
[framework/system/oma-dm-agent.git] / include / serviceadapter / sa_command.h
1 /*
2  * oma-dm-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 #ifndef SA_COMMAND_H_
19 #define SA_COMMAND_H_
20
21 /*dm-agent*/
22 #include "common/dm_error.h"
23 #include "serviceadapter/sa_define.h"
24
25 /**
26  * @par Description: API to create add command
27  *
28  *
29  * @par Purpose:
30  * @par Typical use case:
31  * @par Method of function operation:
32  * @par Important notes:
33  * @param[in]           Session structure
34  * @param[in]           Location structure(about source info)
35  * @param[in]           string type, content type
36  * @param[in]           string type, data value
37  * @param[in]           int type, size
38  * @param[in]           int type, moreData
39  * @param[out]          Command structure
40  *
41  * @return                      ERROR_INTERNAL_OK on success
42  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
43  *
44  * @par Errors:
45  *
46  * @pre None.
47  * @post
48  * @see
49  * @remarks None.
50  *
51  * @par Sample Code:
52  * @code
53  * @endcode
54  */
55 DM_ERROR create_add_cmd(Session * session, char *luid, const char *contenttype, char *data, unsigned int size, int moreData, Command ** pCommand);
56
57 /**
58  * @par Description: API to create delete command
59  *
60  *
61  * @par Purpose:
62  * @par Typical use case:
63  * @par Method of function operation:
64  * @par Important notes:
65  * @param[in]           Session structure
66  * @param[in]           Location structure(about source info)
67  * @param[in]           string type, content type
68  * @param[out]          Command structure
69  *
70  * @return                      ERROR_INTERNAL_OK on success
71  *                                              ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
72  *
73  * @par Errors:
74  *
75  * @pre None.
76  * @post
77  * @see
78  * @remarks None.
79  *
80  * @par Sample Code:
81  * @code
82  * @endcode
83  */
84 DM_ERROR create_delete_cmd(Session * session, char *luid, const char *contenttype, Command ** pCommand);
85
86 /**
87  * @par Description: API to create alert command
88  *
89  *
90  * @par Purpose:
91  * @par Typical use case:
92  * @par Method of function operation:
93  * @par Important notes:
94  * @param[in]           Session structure
95  * @param[in]           enum type, alert type
96  * @param[out]          Command structure
97  *
98  * @return                      DM_OK on success
99  *                                              DM_ERROR on fail
100  *
101  * @par Errors:
102  *
103  * @pre None.
104  * @post
105  * @see
106  * @remarks None.
107  *
108  * @par Sample Code:
109  * @code
110  * @endcode
111  */
112 DM_ERROR create_alert_cmd(Session * session, AlertType syncType, Command ** pCommand);
113
114 /**
115  * @par Description: API to create replace command
116  *
117  *
118  * @par Purpose:
119  * @par Typical use case:
120  * @par Method of function operation:
121  * @par Important notes:
122  * @param[in]           Session structure
123  * @param[out]          Command structure
124  *
125  * @return                      DM_OK on success
126  *                                              DM_ERROR on fail
127  *
128  * @par Errors:
129  *
130  * @pre None.
131  * @post
132  * @see
133  * @remarks None.
134  *
135  * @par Sample Code:
136  * @code
137  * @endcode
138  */
139 DM_ERROR create_replace_cmd(Session * session, Command ** pCommand);
140
141 /**
142  * @par Description: API to create result command
143  *
144  *
145  * @par Purpose:
146  * @par Typical use case:
147  * @par Method of function operation:
148  * @par Important notes:
149  * @param[in]           Session structure
150  * @param[out]          Command structure
151  *
152  * @return                      DM_OK on success
153  *                                              DM_ERROR on fail
154  *
155  * @par Errors:
156  *
157  * @pre None.
158  * @post
159  * @see
160  * @remarks None.
161  *
162  * @par Sample Code:
163  * @code
164  * @endcode
165  */
166 DM_ERROR create_results_cmd(Session * session, Command ** pCommand);
167
168 /**
169  * @par Description: API to create duplicate command
170  *
171  *
172  * @par Purpose:
173  * @par Typical use case:
174  * @par Method of function operation:
175  * @par Important notes:
176  * @param[in]           source
177  * @param[out]  target
178  *
179  * @return                      DM_OK on success
180  *                                              DM_ERROR on fail
181  *
182  * @par Errors:
183  *
184  * @pre None.
185  * @post
186  * @see
187  * @remarks None.
188  *
189  * @par Sample Code:
190  * @code
191  * @endcode
192  */
193 DM_ERROR duplicate_command(Command * source, Command ** target);
194
195 /**
196  * @par Description: API to free commands
197  *
198  *
199  * @par Purpose:
200  * @par Typical use case:
201  * @par Method of function operation:
202  * @par Important notes:
203  * @param[in]           commnads
204  *
205  * @return
206  *
207  * @par Errors:
208  *
209  * @pre None.
210  * @post
211  * @see
212  * @remarks None.
213  *
214  * @par Sample Code:
215  * @code
216  * @endcode
217  */
218 void free_commands(GList * commands);
219
220 /**
221  * @par Description: API to free command
222  *
223  *
224  * @par Purpose:
225  * @par Typical use case:
226  * @par Method of function operation:
227  * @par Important notes:
228  * @param[in]           Command structure
229  *
230  * @return
231  *
232  * @par Errors:
233  *
234  * @pre None.
235  * @post
236  * @see
237  * @remarks None.
238  *
239  * @par Sample Code:
240  * @code
241  * @endcode
242  */
243 void free_command(Command * pCommand);
244
245 /**
246  * @par Description: API to free command
247  *
248  *
249  * @par Purpose:
250  * @par Typical use case:
251  * @par Method of function operation:
252  * @par Important notes:
253  * @param[in]           Command structure
254  * @param[in]           string type, correlator
255  *
256  * @return                              DM_OK on success
257  *                                                      DM_ERROR on fail
258  *
259  * @par Errors:
260  *
261  * @pre None.
262  * @post
263  * @see
264  * @remarks None.
265  *
266  * @par Sample Code:
267  * @code
268  * @endcode
269  */
270 DM_ERROR set_correlator(Command ** pAlertCommand, char *pCorrelator);
271
272 /**
273  * @par Description: API to set result command msg ref
274  *
275  *
276  * @par Purpose:
277  * @par Typical use case:
278  * @par Method of function operation:
279  * @par Important notes:
280  * @param[in]           Command structure
281  * @param[in]           msg ref
282  *
283  * @return                              DM_OK on success
284  *                                                      DM_ERROR on fail
285  *
286  * @par Errors:
287  *
288  * @pre None.
289  * @post
290  * @see
291  * @remarks None.
292  *
293  * @par Sample Code:
294  * @code
295  * @endcode
296  */
297 DM_ERROR set_resultscommand_msgref(Command * pCommand, unsigned int msgRef);
298
299 /**
300  * @par Description: API to set result command cmd ref
301  *
302  *
303  * @par Purpose:
304  * @par Typical use case:
305  * @par Method of function operation:
306  * @par Important notes:
307  * @param[in]           Command structure
308  * @param[in]           msg ref
309  *
310  * @return                              DM_OK on success
311  *                                                      DM_ERROR on fail
312  *
313  * @par Errors:
314  *
315  * @pre None.
316  * @post
317  * @see
318  * @remarks None.
319  *
320  * @par Sample Code:
321  * @code
322  * @endcode
323  */
324 DM_ERROR set_resultscommand_cmdref(Command * pCommand, unsigned int cmdRef);
325
326 /**
327  * @par Description: API to set result command cmd ref
328  *
329  *
330  * @par Purpose:
331  * @par Typical use case:
332  * @par Method of function operation:
333  * @par Important notes:
334  * @param[in]           Command structure
335  * @param[in]           location target uri
336  *
337  * @return                              DM_OK on success
338  *                                                      DM_ERROR on fail
339  *
340  * @par Errors:
341  *
342  * @pre None.
343  * @post
344  * @see
345  * @remarks None.
346  *
347  * @par Sample Code:
348  * @code
349  * @endcode
350  */
351 DM_ERROR set_resultscommand_targetref(Command * pCommand, Location * pLocation);
352
353 /**
354  * @par Description: API to create new status location
355  *
356  *
357  * @par Purpose:
358  * @par Typical use case:
359  * @par Method of function operation:
360  * @par Important notes:
361  * @param[in]           session structure
362  * @param[in]           enum type, dm error
363  * @param[in]           command structure
364  * @param[in]           string type, loaction source uri
365  * @param[in]           string type, location target uri
366  * @param[in]           enum type, command type
367  * @param[out]          status structure
368  *
369  * @return                              DM_OK on success
370  *                                                      DM_ERROR on fail
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 DM_ERROR create_newstatuslocation(Session * session, DM_ERROR data, Command * command, Location * sourceref, Location * targetref, CommandType type, Status ** pStatus);
384
385 /**
386  * @par Description: API to create new status
387  *
388  *
389  * @par Purpose:
390  * @par Typical use case:
391  * @par Method of function operation:
392  * @par Important notes:
393  * @param[in]           session structure
394  * @param[in]           enum type, dm error
395  * @param[in]           command structure
396  * @param[in]           string type, loaction source uri
397  * @param[in]           string type, location target uri
398  * @param[in]           enum type, command type
399  * @param[in]           status structure
400  *
401  * @return                              DM_OK on success
402  *                                                      DM_ERROR on fail
403  *
404  * @par Errors:
405  *
406  * @pre None.
407  * @post
408  * @see
409  * @remarks None.
410  *
411  * @par Sample Code:
412  * @code
413  * @endcode
414  */
415 DM_ERROR create_newstatus(Session * session, DM_ERROR data, Command * command, Location * sourceref, Location * targetref, CommandType type, Status ** pStatus);
416
417 /**
418  * @par Description: API to create new status location
419  *
420  *
421  * @par Purpose:
422  * @par Typical use case:
423  * @par Method of function operation:
424  * @par Important notes: *
425  * @param[in]           enum type, dm error
426  * @param[in]           int type, cmd id
427  * @param[in]           int type, msg ref
428  * @param[in]           int type, cmd ref
429  * @param[in]           string type, location source ref
430  * @param[in]           string type, location target ref
431  * @param[in]           chalenge structure
432  * @param[in]           enum type, commadn type
433  * @param[out]          status structure
434  *
435  * @return                              DM_OK on success
436  *                                                      DM_ERROR on fail
437  *
438  * @par Errors:
439  *
440  * @pre None.
441  * @post
442  * @see
443  * @remarks None.
444  *
445  * @par Sample Code:
446  * @code
447  * @endcode
448  */
449 DM_ERROR create_status(DM_ERROR data, unsigned int cmdID, unsigned int msgref, unsigned int cmdref, Location * sourceref, Location * targetref, Chal * pChal, CommandType type, Status ** pStatus);
450
451 /**
452  * @par Description: API to create new status location
453  *
454  *
455  * @par Purpose:
456  * @par Typical use case:
457  * @par Method of function operation:
458  * @par Important notes: *
459  * @param[in]           session structure
460  * @param[in]           command structure
461  * @param[in]           item structure
462  * @param[in]           enum type, dm error
463  *
464  * @return                              DM_OK on success
465  *                                                      DM_ERROR on fail
466  *
467  * @par Errors:
468  *
469  * @pre None.
470  * @post
471  * @see
472  * @remarks None.
473  *
474  * @par Sample Code:
475  * @code
476  * @endcode
477  */
478 DM_ERROR set_status_data(Session * session, Command * pCommand, Item * item, DM_ERROR data);
479
480 /**
481  * @par Description: API to free status list
482  *
483  *
484  * @par Purpose:
485  * @par Typical use case:
486  * @par Method of function operation:
487  * @par Important notes: *
488  * @param[in]           status list
489  *
490  * @return
491  *
492  * @par Errors:
493  *
494  * @pre None.
495  * @post
496  * @see
497  * @remarks None.
498  *
499  * @par Sample Code:
500  * @code
501  * @endcode
502  */
503 void free_statuses(GList * status);
504
505 /**
506  * @par Description: API to free status
507  *
508  *
509  * @par Purpose:
510  * @par Typical use case:
511  * @par Method of function operation:
512  * @par Important notes: *
513  * @param[in]           status
514  *
515  * @return
516  *
517  * @par Errors:
518  *
519  * @pre None.
520  * @post
521  * @see
522  * @remarks None.
523  *
524  * @par Sample Code:
525  * @code
526  * @endcode
527  */
528 void free_status(Status * status);
529
530 /**
531  * @par Description: API to get status code
532  *
533  *
534  * @par Purpose:
535  * @par Typical use case:
536  * @par Method of function operation:
537  * @par Important notes: *
538  * @param[out]          status
539  *
540  * @return                              DM_OK on success
541  *                                                      DM_ERROR on fail
542  * @par Errors:
543  *
544  * @pre None.
545  * @post
546  * @see
547  * @remarks None.
548  *
549  * @par Sample Code:
550  * @code
551  * @endcode
552  */
553 DM_ERROR get_statuscode(Status * status);
554
555 /**
556  * @par Description: API to convert int type to change type
557  *
558  *
559  * @par Purpose:
560  * @par Typical use case:
561  * @par Method of function operation:
562  * @par Important notes: *
563  * @param[in]           type
564  *
565  * @return                              enum type, ChangeType
566  *
567  *
568  * @par Errors:
569  *
570  * @pre None.
571  * @post
572  * @see
573  * @remarks None.
574  *
575  * @par Sample Code:
576  * @code
577  * @endcode
578  */
579 ChangeType converttochangetype(unsigned int type);
580
581 /**
582  * @par Description: API to convert change type to int type
583  *
584  *
585  * @par Purpose:
586  * @par Typical use case:
587  * @par Method of function operation:
588  * @par Important notes: *
589  * @param[in]           type
590  *
591  * @return                              int type, int
592  *
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 unsigned int convertfromchangetype(ChangeType changeType);
606
607 /**
608  * @par Description: API to convert string type to command type
609  *
610  *
611  * @par Purpose:
612  * @par Typical use case:
613  * @par Method of function operation:
614  * @par Important notes: *
615  * @param[in]           string type, type
616  *
617  * @return                              CommandType
618  *
619  *
620  * @par Errors:
621  *
622  * @pre None.
623  * @post
624  * @see
625  * @remarks None.
626  *
627  * @par Sample Code:
628  * @code
629  * @endcode
630  */
631 CommandType converttocommandtype(char *type);
632
633 /**
634  * @par Description: API to convert command type to string
635  *
636  *
637  * @par Purpose:
638  * @par Typical use case:
639  * @par Method of function operation:
640  * @par Important notes: *
641  * @param[in]           string type, type
642  *
643  * @return                              string type, string
644  *
645  *
646  * @par Errors:
647  *
648  * @pre None.
649  * @post
650  * @see
651  * @remarks None.
652  *
653  * @par Sample Code:
654  * @code
655  * @endcode
656  */
657 char *convertfromcommandtype(CommandType type);
658
659 #endif                          /* SA_COMMAND_H_ */