Make TIZEN 2.0
[apps/home/call.git] / ui / src / vcui-document.c
1 /*\r
2  * Copyright 2012  Samsung Electronics Co., Ltd\r
3  *\r
4  * Licensed under the Flora License, Version 1.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  * http://www.tizenopensource.org/license\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 \r
18 #include "vcui-application.h"\r
19 #include "vcui-document.h"\r
20 \r
21 struct _call_data_t {\r
22         unsigned char call_handle;\r
23         int contact_id;\r
24         int contact_phone_type;\r
25         int bday_remaining_days;\r
26         time_t start_time;\r
27 \r
28         char call_num[VC_PHONE_NUMBER_LENGTH_MAX];\r
29         char call_display[VC_DISPLAY_NAME_LENGTH_MAX];\r
30         char call_file_path[VC_IMAGE_PATH_LENGTH_MAX];\r
31         char call_full_file_path[VC_IMAGE_PATH_LENGTH_MAX];\r
32 \r
33         gboolean brejected;     /* auto reject */\r
34 \r
35         /* The below 2 fields are required on UI side as well, even though we can get these values from engine data structure\r
36          * When call is ended, engine will clear the call object info and hence we cannot get these status at this moment\r
37          * So we have to maintain a copy in UI side as well */\r
38         int call_type;                          /* whether MO or MT call*/\r
39         int caller_status;                      /* HOLD/UNHOLD */\r
40 };\r
41 \r
42 static call_data_t *recent_mo;\r
43 static call_data_t *recent_mt;\r
44 static call_data_t *recent_call;\r
45 static Eina_List *caller_list;\r
46 \r
47 /**\r
48  * This function initializes the data structure pointers maintained in the document file\r
49  *\r
50  * @return      nothing\r
51  * @param[in]   nothing\r
52 */\r
53 void _vcui_doc_data_init()\r
54 {\r
55         recent_mo = NULL;\r
56         recent_mt = NULL;\r
57         recent_call = NULL;\r
58         caller_list = NULL;\r
59 }\r
60 \r
61 /**\r
62  * This function allocates memory for the call data structure - call_data_t\r
63  *\r
64  * @return      pointer to the memory allocated for call-data structure, or NULL if memory allocation fails\r
65  * @param[in]   nothing\r
66 */\r
67 call_data_t *_vcui_doc_allocate_call_data_memory(void)\r
68 {\r
69         call_data_t *pcall_data = NULL;\r
70 \r
71         pcall_data = (call_data_t *)calloc(1, sizeof(call_data_t));\r
72         if (pcall_data == NULL) {\r
73                 CALL_UI_DEBUG("memory allocation failed...");\r
74         }\r
75         return pcall_data;\r
76 }\r
77 \r
78 /**\r
79  * This function retrieves the value of the call handle\r
80  *\r
81  * @return      value of the call handle\r
82  * @param[in]   pcall_data      pointer to the call-data structure\r
83 */\r
84 int _vcui_doc_get_call_handle(call_data_t *pcall_data)\r
85 {\r
86         VCUI_RETURN_INVALID_IF_FAIL(pcall_data);\r
87         return pcall_data->call_handle;\r
88 }\r
89 \r
90 /**\r
91  * This function assigns the value of call handle for a given pointer of the call-data structure\r
92  *\r
93  * @return      nothing\r
94  * @param[in]   pcall_data      pointer to the call-data structure\r
95  * @param[in]   call_handle     new value of the call handle\r
96 */\r
97 void _vcui_doc_set_call_handle(call_data_t *pcall_data, int call_handle)\r
98 {\r
99         VCUI_RETURN_IF_FAIL(pcall_data);\r
100         pcall_data->call_handle = call_handle;\r
101 }\r
102 \r
103 /**\r
104  * This function retrieves the value of the call number\r
105  *\r
106  * @return      pointer to the call number string\r
107  * @param[in]   pcall_data      pointer to the call-data structure\r
108 */\r
109 char *_vcui_doc_get_call_number(call_data_t *pcall_data)\r
110 {\r
111         VCUI_RETURN_NULL_IF_FAIL(pcall_data);\r
112         return (char *) pcall_data->call_num;\r
113 }\r
114 \r
115 /**\r
116  * This function assigns the value of call number for a given pointer of the call-data structure\r
117  *\r
118  * @return      nothing\r
119  * @param[in]   pcall_data      pointer to the call-data structure\r
120  * @param[in]   pnumber         pointer to the call number string\r
121 */\r
122 void _vcui_doc_set_call_number(call_data_t *pcall_data, char *pnumber)\r
123 {\r
124         VCUI_RETURN_IF_FAIL(pcall_data);\r
125         memset(pcall_data->call_num, 0, sizeof(pcall_data->call_num));\r
126         vcall_engine_util_strcpy(pcall_data->call_num, VC_PHONE_NUMBER_LENGTH_MAX, pnumber);\r
127 }\r
128 \r
129 /**\r
130  * This function retrieves the value of the call name (available from contact DB)\r
131  *\r
132  * @return      pointer to the call name string\r
133  * @param[in]   pcall_data      pointer to the call-data structure\r
134 */\r
135 char *_vcui_doc_get_call_display_name(call_data_t *pcall_data)\r
136 {\r
137         VCUI_RETURN_NULL_IF_FAIL(pcall_data);\r
138         return (char *) pcall_data->call_display;\r
139 }\r
140 \r
141 /**\r
142  * This function assigns the value of contact name for a given pointer of the call-data structure\r
143  *\r
144  * @return      nothing\r
145  * @param[in]   pcall_data      pointer to the call-data structure\r
146  * @param[in]   pname           pointer to the call number string\r
147 */\r
148 void _vcui_doc_set_call_display_name(call_data_t *pcall_data, char *pname)\r
149 {\r
150         VCUI_RETURN_IF_FAIL(pcall_data);\r
151         memset(pcall_data->call_display, 0, sizeof(pcall_data->call_display));\r
152         vcall_engine_util_strcpy(pcall_data->call_display, VC_DISPLAY_NAME_LENGTH_MAX, pname);\r
153 }\r
154 \r
155 /**\r
156  * This function retrieves the caller-ID file path (caller-ID for split screen)\r
157  *\r
158  * @return      pointer to the caller-ID file path string\r
159  * @param[in]   pcall_data      pointer to the call-data structure\r
160 */\r
161 char *_vcui_doc_get_caller_id_file_path(call_data_t *pcall_data)\r
162 {\r
163         VCUI_RETURN_NULL_IF_FAIL(pcall_data);\r
164         return (char *) pcall_data->call_file_path;\r
165 }\r
166 \r
167 /**\r
168  * This function assigns the value of caller-ID file-path for a given pointer of the call-data structure\r
169  *\r
170  * @return      nothing\r
171  * @param[in]   pcall_data      pointer to the call-data structure\r
172  * @param[in]   pfile_path      pointer to the caller-ID file-path string\r
173 */\r
174 void _vcui_doc_set_caller_id_file_path(call_data_t *pcall_data, char *pfile_path)\r
175 {\r
176         VCUI_RETURN_IF_FAIL(pcall_data);\r
177         memset(pcall_data->call_file_path, 0, sizeof(pcall_data->call_file_path));\r
178         vcall_engine_util_strcpy(pcall_data->call_file_path, VC_IMAGE_PATH_LENGTH_MAX, pfile_path);\r
179 }\r
180 \r
181 /**\r
182  * This function retrieves the caller-ID full file path (caller-ID for full screen)\r
183  *\r
184  * @return      pointer to the caller-ID full file path string\r
185  * @param[in]   pcall_data      pointer to the call-data structure\r
186 */\r
187 char *_vcui_doc_get_caller_id_full_file_path(call_data_t *pcall_data)\r
188 {\r
189         VCUI_RETURN_NULL_IF_FAIL(pcall_data);\r
190         return (char *) pcall_data->call_full_file_path;\r
191 }\r
192 \r
193 /**\r
194  * This function assigns the value of caller-ID full file-path for a given pointer of the call-data structure\r
195  *\r
196  * @return      nothing\r
197  * @param[in]   pcall_data              pointer to the call-data structure\r
198  * @param[in]   pfull_file_path pointer to the caller-ID full file-path string\r
199 */\r
200 void _vcui_doc_set_caller_id_full_file_path(call_data_t *pcall_data, char *pfull_file_path)\r
201 {\r
202         VCUI_RETURN_IF_FAIL(pcall_data);\r
203         memset(pcall_data->call_full_file_path, 0, sizeof(pcall_data->call_full_file_path));\r
204         vcall_engine_util_strcpy(pcall_data->call_full_file_path, VC_IMAGE_PATH_LENGTH_MAX, pfull_file_path);\r
205 }\r
206 \r
207 /**\r
208  * This function retrieves the value of the call start time\r
209  *\r
210  * @return      value of the call start time\r
211  * @param[in]   pcall_data      pointer to the call-data structure\r
212 */\r
213 int _vcui_doc_get_call_start_time(call_data_t *pcall_data)\r
214 {\r
215         VCUI_RETURN_INVALID_IF_FAIL(pcall_data);\r
216         return pcall_data->start_time;\r
217 }\r
218 \r
219 /**\r
220  * This function assigns the value of call start time for a given pointer of the call-data structure\r
221  *\r
222  * @return      nothing\r
223  * @param[in]   pcall_data      pointer to the call-data structure\r
224 */\r
225 void _vcui_doc_set_call_start_time(call_data_t *pcall_data)\r
226 {\r
227         VCUI_RETURN_IF_FAIL(pcall_data);\r
228         time(&(pcall_data->start_time));\r
229 }\r
230 \r
231 /**\r
232  * This function retrieves the value of the contact index\r
233  *\r
234  * @return      value of the contact index\r
235  * @param[in]   pcall_data      pointer to the call-data structure\r
236 */\r
237 int _vcui_doc_get_contact_index(call_data_t *pcall_data)\r
238 {\r
239         VCUI_RETURN_INVALID_IF_FAIL(pcall_data);\r
240         return pcall_data->contact_id;\r
241 }\r
242 \r
243 /**\r
244  * This function assigns the value of contact index for a given pointer of the call-data structure\r
245  *\r
246  * @return      nothing\r
247  * @param[in]   pcall_data              pointer to the call-data structure\r
248  * @param[in]   contact_index   value of the contact index\r
249 */\r
250 void _vcui_doc_set_contact_index(call_data_t *pcall_data, int contact_index)\r
251 {\r
252         VCUI_RETURN_IF_FAIL(pcall_data);\r
253         pcall_data->contact_id = contact_index;\r
254 }\r
255 \r
256 /**\r
257  * This function retrieves the value of the contact phone type\r
258  *\r
259  * @return      value of the contact phone type\r
260  * @param[in]   pcall_data      pointer to the call-data structure\r
261 */\r
262 int _vcui_doc_get_contact_phone_type(call_data_t *pcall_data)\r
263 {\r
264         VCUI_RETURN_INVALID_IF_FAIL(pcall_data);\r
265         return pcall_data->contact_phone_type;\r
266 }\r
267 \r
268 /**\r
269  * This function assigns the value of contact phone type for a given pointer of the call-data structure\r
270  *\r
271  * @return      nothing\r
272  * @param[in]   pcall_data      pointer to the call-data structure\r
273  * @param[in]   phone_type      value of the contact phone type\r
274 */\r
275 void _vcui_doc_set_contact_phone_type(call_data_t *pcall_data, int phone_type)\r
276 {\r
277         VCUI_RETURN_IF_FAIL(pcall_data);\r
278         pcall_data->contact_phone_type = phone_type;\r
279 }\r
280 \r
281 /**\r
282  * This function retrieves the value of the remaining days for the contact birthday\r
283  *\r
284  * @return      value of the contact remaining days in birthday\r
285  * @param[in]   pcall_data      pointer to the call-data structure\r
286 */\r
287 int _vcui_doc_get_birthday_remaining_days(call_data_t *pcall_data)\r
288 {\r
289         VCUI_RETURN_INVALID_IF_FAIL(pcall_data);\r
290         return pcall_data->bday_remaining_days;\r
291 }\r
292 \r
293 /**\r
294  * This function assigns the value of birthday remaining days for a given pointer of the call-data structure\r
295  *\r
296  * @return      nothing\r
297  * @param[in]   pcall_data              pointer to the call-data structure\r
298  * @param[in]   bday_rem_days   value of the birthday remaining days\r
299 */\r
300 void _vcui_doc_set_birthday_remaining_days(call_data_t *pcall_data, int bday_rem_days)\r
301 {\r
302         VCUI_RETURN_IF_FAIL(pcall_data);\r
303         pcall_data->bday_remaining_days = bday_rem_days;\r
304 }\r
305 \r
306 /**\r
307  * This function retrieves the value of the auto reject status\r
308  *\r
309  * @return      value of the auto reject status\r
310  * @param[in]   pcall_data      pointer to the call-data structure\r
311 */\r
312 int _vcui_doc_get_auto_reject_status(call_data_t *pcall_data)\r
313 {\r
314         VCUI_RETURN_INVALID_IF_FAIL(pcall_data);\r
315         return pcall_data->brejected;\r
316 }\r
317 \r
318 /**\r
319  * This function assigns the value of auto reject status for a given pointer of the call-data structure\r
320  *\r
321  * @return      nothing\r
322  * @param[in]   pcall_data              pointer to the call-data structure\r
323  * @param[in]   bauto_rejected  value of the auto reject status\r
324 */\r
325 void _vcui_doc_set_auto_reject_status(call_data_t *pcall_data, gboolean bauto_rejected)\r
326 {\r
327         VCUI_RETURN_IF_FAIL(pcall_data);\r
328         pcall_data->brejected = bauto_rejected;\r
329 }\r
330 \r
331 /**\r
332  * This function retrieves if a call is MO or MT type\r
333  *\r
334  * @return      value of the call type - MO or MT\r
335  * @param[in]   pcall_data      pointer to the call-data structure\r
336 */\r
337 int _vcui_doc_get_call_type(call_data_t *pcall_data)\r
338 {\r
339         VCUI_RETURN_INVALID_IF_FAIL(pcall_data);\r
340         return pcall_data->call_type;\r
341 }\r
342 \r
343 /**\r
344  * This function assigns the value of call type for a given pointer of the call-data structure\r
345  *\r
346  * @return      nothing\r
347  * @param[in]   pcall_data      pointer to the call-data structure\r
348  * @param[in]   call_type       type of call, MO or MT\r
349 */\r
350 void _vcui_doc_set_call_type(call_data_t *pcall_data, int call_type)\r
351 {\r
352         VCUI_RETURN_IF_FAIL(pcall_data);\r
353         pcall_data->call_type = call_type;\r
354 }\r
355 \r
356 /**\r
357  * This function retrieves the call status of a particular call data structure (HOLD/UNHOLD)\r
358  *\r
359  * @return      value of the call status, HOLD/UNHOLD\r
360  * @param[in]   pcall_data      pointer to the call-data structure\r
361 */\r
362 int _vcui_doc_get_call_status(call_data_t *pcall_data)\r
363 {\r
364         VCUI_RETURN_INVALID_IF_FAIL(pcall_data);\r
365         return pcall_data->caller_status;\r
366 }\r
367 \r
368 /**\r
369  * This function assigns the value of call status for a given pointer of the call-data structure\r
370  *\r
371  * @return      nothing\r
372  * @param[in]   pcall_data      pointer to the call-data structure\r
373  * @param[in]   call_status     status of call, active/held\r
374 */\r
375 void _vcui_doc_set_call_status(call_data_t *pcall_data, int call_status)\r
376 {\r
377         VCUI_RETURN_IF_FAIL(pcall_data);\r
378         pcall_data->caller_status = call_status;\r
379 }\r
380 \r
381 /**\r
382  * This function retrieves the pointer to the most recent MO(outgoing) call data\r
383  *\r
384  * @return      pointer to the call data structure\r
385  * @param[in]   nothing\r
386 */\r
387 call_data_t *_vcui_doc_get_recent_mo_call_data()\r
388 {\r
389         return recent_mo;\r
390 }\r
391 \r
392 /**\r
393  * This function assigns the pointer of the most recent MO(outgoing) call data\r
394  * to the pointer stored in the vcui-document file (recent_mo)\r
395  *\r
396  * @return      nothing\r
397  * @param[in]   in              pointer to the call-data structure to be copied/assigned\r
398 */\r
399 void _vcui_doc_set_recent_mo_call_data(call_data_t *in)\r
400 {\r
401         CALL_UI_DEBUG("..");\r
402         if (in == NULL) {\r
403                 CALL_UI_DEBUG("set recent_mo to null");\r
404         }\r
405         if (recent_mo != NULL && recent_mo->call_handle == NO_HANDLE) {\r
406                 CALL_UI_DEBUG("Set_recent 1");\r
407                 free(recent_mo);\r
408                 recent_mo = NULL;\r
409         }\r
410         _vcui_doc_set_all_recent(in);\r
411         recent_mo = in;\r
412 }\r
413 \r
414 /**\r
415  * This function retrieves the pointer to the most recent MT(incoming) call data\r
416  *\r
417  * @return      pointer to the call data structure\r
418  * @param[in]   nothing\r
419 */\r
420 call_data_t *_vcui_doc_get_recent_mt_call_data()\r
421 {\r
422         return recent_mt;\r
423 }\r
424 \r
425 /**\r
426  * This function assigns the pointer of the most recent MT(incoming) call data\r
427  * to the pointer stored in the vcui-document file (recent_mt)\r
428  *\r
429  * @return      nothing\r
430  * @param[in]   in              pointer to the call-data structure to be copied/assigned\r
431 */\r
432 void _vcui_doc_set_recent_mt_call_data(call_data_t *in)\r
433 {\r
434         CALL_UI_DEBUG("..");\r
435         if (in == NULL) {\r
436                 CALL_UI_DEBUG("set recent_mt to null");\r
437         }\r
438         _vcui_doc_set_all_recent(in);\r
439         recent_mt = in;\r
440 }\r
441 \r
442 /**\r
443  * This function retrieves the pointer to the most recent call data, either MT(incoming)/MO(outgoing)\r
444  *\r
445  * @return      pointer to the call data structure\r
446  * @param[in]   nothing\r
447 */\r
448 call_data_t *_vcui_doc_get_recent_call_data()\r
449 {\r
450         CALL_UI_DEBUG("..");\r
451         if (recent_call == NULL) {\r
452                 CALL_UI_DEBUG("recent is NULL");\r
453                 if (recent_mo != NULL) {\r
454                         recent_call = recent_mo;\r
455                         CALL_UI_DEBUG("recent is mo");\r
456                 } else if (recent_mt != NULL) {\r
457                         recent_call = recent_mt;\r
458                         CALL_UI_DEBUG("recent is mt");\r
459                 }\r
460         }\r
461         return recent_call;\r
462 }\r
463 \r
464 /**\r
465  * This function assigns the pointer of the most recent MT(incoming)/MO(outgoing) call data\r
466  * to the pointer stored in the vcui-document file (recent_call)\r
467  *\r
468  * @return      nothing\r
469  * @param[in]   in              pointer to the call-data structure to be copied/assigned\r
470 */\r
471 void _vcui_doc_set_all_recent(call_data_t *in)\r
472 {\r
473         CALL_UI_DEBUG("..");\r
474         if (in == NULL) {\r
475                 CALL_UI_DEBUG("set recent_call to null");\r
476         }\r
477         recent_call = in;\r
478 }\r
479 \r
480 /**\r
481  * This function adds the call data structure to the list of call data maintained in the\r
482  * vcui-document file (caller_list link list)\r
483  *\r
484  * @return      nothing\r
485  * @param[in]   in              pointer to the call-data structure to be copied/assigned\r
486 */\r
487 void _vcui_doc_add_call_data(call_data_t *in)\r
488 {\r
489         if (in == NULL)\r
490                 return;\r
491         Eina_List *l = NULL;\r
492         call_data_t *cd = NULL;\r
493         EINA_LIST_FOREACH(caller_list, l, cd) {\r
494                 if (cd == in) {\r
495                         return;\r
496                 }\r
497         }\r
498 \r
499         caller_list = eina_list_append(caller_list, (void *)in);\r
500 }\r
501 \r
502 /**\r
503  * This function updates the call data structure contained in the list of call data maintained in the\r
504  * vcui-document file (caller_list link list) with the new call-data structure\r
505  *\r
506  * @return      nothing\r
507  * @param[in]   in              pointer to the call-data structure to be updated\r
508 */\r
509 void _vcui_doc_update_call_data(call_data_t *in)\r
510 {\r
511         if (in == NULL)\r
512                 return;\r
513         Eina_List *l = NULL;\r
514         call_data_t *cd = NULL;\r
515         EINA_LIST_FOREACH(caller_list, l, cd) {\r
516                 if (cd == in) {\r
517                         *cd = *in;\r
518                         return;\r
519                 }\r
520         }\r
521 }\r
522 \r
523 /**\r
524  * This function checks if the call data pointer data is valid and present in the 'caller_list' list\r
525  *\r
526  * @return      TRUE if the call-data is present and FALSE if there is no such call-data in the list\r
527  * @param[in]   in              pointer to the call-data structure\r
528 */\r
529 Eina_Bool _vcui_doc_is_valid_call_data(call_data_t *in)\r
530 {\r
531         if (in == NULL)\r
532                 return EINA_FALSE;\r
533         Eina_List *l = NULL;\r
534         call_data_t *cd = NULL;\r
535         EINA_LIST_FOREACH(caller_list, l, cd) {\r
536                 if (cd == in) {\r
537                         return EINA_TRUE;\r
538                 }\r
539         }\r
540 \r
541         return EINA_FALSE;\r
542 }\r
543 \r
544 /**\r
545  * This function removes the call data structure from the list of call data maintained in the\r
546  * vcui-document file (caller_list link list) and frees the call data structure\r
547  *\r
548  * @return      nothing\r
549  * @param[in]   in              pointer to the call-data structure to be added\r
550 */\r
551 void _vcui_doc_remove_call_data(call_data_t *in)\r
552 {\r
553         if (in == NULL) {\r
554                 CALL_UI_DEBUG("Call data is Null");\r
555                 return;\r
556         }\r
557         Eina_List *l = NULL;\r
558         call_data_t *cd = NULL;\r
559         EINA_LIST_FOREACH(caller_list, l, cd) {\r
560                 if (cd == in) {\r
561                         if (in == _vcui_doc_get_recent_mo_call_data())\r
562                                 _vcui_doc_set_recent_mo_call_data(NULL);\r
563                         if (in == _vcui_doc_get_recent_mt_call_data())\r
564                                 _vcui_doc_set_recent_mt_call_data(NULL);\r
565 \r
566                         caller_list = eina_list_remove(caller_list, in);\r
567                         free(in);\r
568                         in = NULL;\r
569                         CALL_UI_DEBUG("Call data removed");\r
570                         break;\r
571                 }\r
572 \r
573         }\r
574 \r
575         if (_vcui_doc_get_all_call_data_count() == 0) {\r
576                 eina_list_free(caller_list);\r
577                 caller_list = NULL;\r
578         }\r
579 \r
580 }\r
581 \r
582 /**\r
583  * This function removes the call data structure from the list of call data maintained in the\r
584  * vcui-document file (caller_list link list)\r
585  *\r
586  * @return      a pointer to the call data structure which is passed\r
587  * @param[in]   in              pointer to the call-data structure to be added\r
588 */\r
589 call_data_t *_vcui_doc_remove_call_data_from_list(call_data_t *in)\r
590 {\r
591         if (in == NULL) {\r
592                 CALL_UI_DEBUG("Call data is Null");\r
593                 return NULL;\r
594         }\r
595         Eina_List *l = NULL;\r
596         call_data_t *cd = NULL;\r
597         EINA_LIST_FOREACH(caller_list, l, cd) {\r
598                 if (cd == in) {\r
599                         caller_list = eina_list_remove(caller_list, in);\r
600                         return in;\r
601                 }\r
602         }\r
603         return NULL;\r
604 }\r
605 \r
606 /**\r
607  * This function removes all the call data from list and frees the memory\r
608  *\r
609  * @return      nothing\r
610  * @param[in]   void\r
611 */\r
612 void _vcui_doc_remove_all_call_data()\r
613 {\r
614         Eina_List *l = NULL;\r
615         call_data_t *cd = NULL;\r
616         EINA_LIST_FOREACH(caller_list, l, cd) {\r
617                 if (cd != NULL) {\r
618                         free(cd);\r
619                         cd = NULL;\r
620                 }\r
621         }\r
622         eina_list_free(caller_list);\r
623         caller_list = NULL;\r
624 }\r
625 \r
626 /**\r
627  * This function retrieves the earliest call data based on the call status\r
628  *\r
629  * @return      pointer to the call data structure\r
630  * @param[in]   call_status             value of the call status (hold/unhold)\r
631 */\r
632 call_data_t *_vcui_doc_get_call_data_by_call_status(int call_status)\r
633 {\r
634 \r
635         Eina_List *l = NULL;\r
636         call_data_t *fast_cd = NULL;\r
637         call_data_t *cd = NULL;\r
638         int i = 0;\r
639         EINA_LIST_FOREACH(caller_list, l, cd) {\r
640                 if (cd != NULL) {\r
641                         if (cd->caller_status == call_status) {\r
642                                 if (i == 0) {\r
643                                         fast_cd = cd;\r
644                                         i++;\r
645                                         continue;\r
646                                 } else {\r
647                                         if (fast_cd->start_time > cd->start_time) {\r
648                                                 fast_cd = cd;\r
649                                         }\r
650                                 }\r
651                                 i++;\r
652                         }\r
653                 }\r
654         }\r
655         return fast_cd;\r
656 }\r
657 \r
658 /**\r
659  * This function retrieves the most recent MO call data\r
660  *\r
661  * @return      pointer to the call data structure\r
662  * @param[in]   nothing\r
663 */\r
664 call_data_t *_vcui_doc_get_call_data_mo_type()\r
665 {\r
666 \r
667         Eina_List *l = NULL;\r
668         call_data_t *last_cd = NULL;\r
669         call_data_t *cd = NULL;\r
670         int i = 0;\r
671         EINA_LIST_FOREACH(caller_list, l, cd) {\r
672                 if (cd != NULL) {\r
673                         if (cd->call_type == CALL_OUTGOING) {\r
674                                 if (i == 0) {\r
675                                         last_cd = cd;\r
676                                         i++;\r
677                                         continue;\r
678                                 } else {\r
679                                         if (last_cd->start_time < cd->start_time) {\r
680                                                 last_cd = cd;\r
681                                         }\r
682                                 }\r
683                                 i++;\r
684                         }\r
685                 }\r
686         }\r
687         return last_cd;\r
688 }\r
689 \r
690 /**\r
691  * This function retrieves the first call data in the list\r
692  *\r
693  * @return      pointer to the call data structure\r
694  * @param[in]   nothing\r
695 */\r
696 call_data_t *_vcui_doc_get_first_call_data_from_list()\r
697 {\r
698         Eina_List *l = NULL;\r
699         call_data_t *cd = NULL;\r
700         EINA_LIST_FOREACH(caller_list, l, cd) {\r
701                 if (cd != NULL) {\r
702                         return cd;\r
703                 }\r
704         }\r
705         return NULL;\r
706 }\r
707 \r
708 /**\r
709  * This function retrieves the first call data in the list which is of UNHOLD status\r
710  *\r
711  * @return      pointer to the call data structure\r
712  * @param[in]   nothing\r
713 */\r
714 call_data_t *_vcui_doc_get_first_call_data_by_unhold_status()\r
715 {\r
716         Eina_List *l = NULL;\r
717         call_data_t *cd = NULL;\r
718         EINA_LIST_FOREACH(caller_list, l, cd) {\r
719                 if (cd != NULL) {\r
720                         if (cd->caller_status == CALL_UNHOLD) {\r
721                                 return cd;\r
722                         }\r
723                 }\r
724         }\r
725         return NULL;\r
726 }\r
727 \r
728 /**\r
729  * This function retrieves the call data based on the given call handle\r
730  *\r
731  * @return      pointer to the call data structure\r
732  * @param[in]   handle  value of the call handle\r
733 */\r
734 call_data_t *_vcui_doc_get_call_data_by_handle(int handle)\r
735 {\r
736         Eina_List *l = NULL;\r
737         call_data_t *cd = NULL;\r
738         EINA_LIST_FOREACH(caller_list, l, cd) {\r
739                 if (cd != NULL) {\r
740                         if (cd->call_handle == handle) {\r
741                                 return cd;\r
742                         }\r
743                 }\r
744         }\r
745         return NULL;\r
746 }\r
747 \r
748 /**\r
749  * This function retrieves the count of call data which are in HOLD status\r
750  *\r
751  * @return      count of held call data\r
752  * @param[in]   nothing\r
753 */\r
754 int _vcui_doc_get_hold_call_data_count()\r
755 {\r
756         int i = 0;\r
757         Eina_List *l = NULL;\r
758         call_data_t *cd = NULL;\r
759         EINA_LIST_FOREACH(caller_list, l, cd) {\r
760                 if (cd != NULL) {\r
761                         if (cd->caller_status == CALL_HOLD) {\r
762                                 i++;\r
763                         }\r
764                 }\r
765         }\r
766         CALL_UI_DEBUG("(%d)", i);\r
767         return i;\r
768 }\r
769 \r
770 /**\r
771  * This function retrieves the count of call data which are in UNHOLD status\r
772  *\r
773  * @return      count of active call data\r
774  * @param[in]   nothing\r
775 */\r
776 int _vcui_doc_get_unhold_call_data_count()\r
777 {\r
778         int i = 0;\r
779         Eina_List *l = NULL;\r
780         call_data_t *cd = NULL;\r
781         EINA_LIST_FOREACH(caller_list, l, cd) {\r
782                 if (cd != NULL) {\r
783                         if (cd->caller_status == CALL_UNHOLD) {\r
784                                 i++;\r
785                         }\r
786                 }\r
787         }\r
788         CALL_UI_DEBUG("(%d)", i);\r
789         return i;\r
790 }\r
791 \r
792 /**\r
793  * This function retrieves the count of call data which are in NO status (neither hold/unhold)\r
794  *\r
795  * @return      count of 'no status' call data\r
796  * @param[in]   nothing\r
797 */\r
798 int _vcui_doc_get_no_status_call_data_count()\r
799 {\r
800         int i = 0;\r
801         Eina_List *l = NULL;\r
802         call_data_t *cd = NULL;\r
803         EINA_LIST_FOREACH(caller_list, l, cd) {\r
804                 if (cd != NULL) {\r
805                         if (cd->caller_status == NO_STATUS) {\r
806                                 i++;\r
807                         }\r
808                 }\r
809         }\r
810         return i;\r
811 }\r
812 \r
813 /**\r
814  * This function retrieves the count of all call data in the list\r
815  *\r
816  * @return      count of all call data\r
817  * @param[in]   nothing\r
818 */\r
819 int _vcui_doc_get_all_call_data_count()\r
820 {\r
821         int i = eina_list_count(caller_list);\r
822         return i;\r
823 }\r
824 \r
825 /**\r
826  * This function retrieves the call status of a group (greater than 1 member group)\r
827  *\r
828  * @return      value of the call status (HOLD/UNHOLD)\r
829  * @param[in]   nothing\r
830 */\r
831 int _vcui_doc_get_group_call_status()\r
832 {\r
833         if (_vcui_doc_get_all_call_data_count() > 1) {\r
834                 if (_vcui_doc_get_hold_call_data_count() > 1) {\r
835                         return CALL_HOLD;\r
836                 } else {\r
837                         return CALL_UNHOLD;\r
838                 }\r
839         } else {\r
840                 return CALL_UNHOLD;\r
841         }\r
842 }\r
843 \r
844 /**\r
845  * This function retrieves the pointer to the list containing the call data with HOLD status\r
846  *\r
847  * @return      pointer to the HOLD call data list\r
848  * @param[in]   nothing\r
849 */\r
850 Eina_List *_vcui_doc_get_caller_list_with_hold_status()\r
851 {\r
852         if (_vcui_doc_get_all_call_data_count() == 0)\r
853                 return NULL;\r
854         Eina_List *hold_list = NULL;\r
855         Eina_List *l = NULL;\r
856         call_data_t *cd = NULL;\r
857 \r
858         EINA_LIST_FOREACH(caller_list, l, cd) {\r
859                 if (cd != NULL) {\r
860                         if (cd->caller_status == CALL_HOLD) {\r
861                                 hold_list = eina_list_append(hold_list, cd);\r
862                         }\r
863                 }\r
864         }\r
865         return hold_list;\r
866 }\r
867 \r
868 /**\r
869  * This function retrieves the pointer to the list containing the call data with UNHOLD status\r
870  *\r
871  * @return      pointer to the UNHOLD call data list\r
872  * @param[in]   nothing\r
873 */\r
874 Eina_List *_vcui_doc_get_caller_list_with_unhold_status()\r
875 {\r
876         if (_vcui_doc_get_all_call_data_count() == 0)\r
877                 return NULL;\r
878         Eina_List *unhold_list = NULL;\r
879         Eina_List *l = NULL;\r
880         call_data_t *cd = NULL;\r
881 \r
882         EINA_LIST_FOREACH(caller_list, l, cd) {\r
883                 if (cd != NULL) {\r
884                         CALL_UI_DEBUG("_vcui_doc_get_caller_list_with_unhold_status");\r
885                         if (cd->caller_status == CALL_UNHOLD) {\r
886                                 CALL_UI_DEBUG("find it");\r
887                                 unhold_list = eina_list_append(unhold_list, cd);\r
888                         }\r
889                 }\r
890         }\r
891         return unhold_list;\r
892 }\r
893 \r
894 /**\r
895  * This function prints all the call data structure members\r
896  *\r
897  * @return      nothing\r
898  * @param[in]   msg_pos         type of message\r
899 */\r
900 void _vcui_doc_print_all_call_data(char *msg_pos)\r
901 {\r
902         CALL_UI_DEBUG(" --------%s------------", msg_pos);\r
903         Eina_List *l = NULL;\r
904         call_data_t *cd = NULL;\r
905         EINA_LIST_FOREACH(caller_list, l, cd) {\r
906                 if (cd != NULL) {\r
907                         CALL_UI_DEBUG(" call_handle %d", cd->call_handle);\r
908                         CALL_UI_DEBUG(" call_num %s", cd->call_num);\r
909                         CALL_UI_DEBUG(" call_display %s", cd->call_display);\r
910                         CALL_UI_DEBUG(" call_file_path %s", cd->call_file_path);\r
911                         CALL_UI_DEBUG(" call_full_file_path %s", cd->call_full_file_path);\r
912                         CALL_UI_DEBUG(" call_time %d", (int)(cd->start_time));\r
913                 }\r
914         }\r
915         CALL_UI_DEBUG(" --------------------------");\r
916 }\r
917 \r
918 /**\r
919  * This function assigns UNHOLD call status to all the call data in the list\r
920  *\r
921  * @return      nothing\r
922  * @param[in]   nothing\r
923 */\r
924 void _vcui_doc_set_all_call_data_to_unhold_status()\r
925 {\r
926         Eina_List *l = NULL;\r
927         call_data_t *cd = NULL;\r
928         EINA_LIST_FOREACH(caller_list, l, cd) {\r
929                 if (cd != NULL) {\r
930                         if (cd->caller_status == CALL_HOLD) {\r
931                                 cd->caller_status = CALL_UNHOLD;\r
932                         }\r
933                 }\r
934         }\r
935 }\r
936 \r
937 /**\r
938  * This function assigns HOLD call status to all the call data in the list\r
939  *\r
940  * @return      nothing\r
941  * @param[in]   nothing\r
942 */\r
943 void _vcui_doc_set_all_call_data_to_hold_status()\r
944 {\r
945         Eina_List *l = NULL;\r
946         call_data_t *cd = NULL;\r
947         EINA_LIST_FOREACH(caller_list, l, cd) {\r
948                 if (cd != NULL) {\r
949                         if (cd->caller_status == CALL_UNHOLD) {\r
950                                 cd->caller_status = CALL_HOLD;\r
951                         }\r
952                 }\r
953         }\r
954 }\r
955 \r
956 /**\r
957  * This function swaps the HOLD and UNHOLD calls in the call list\r
958  *\r
959  * @return      nothing\r
960  * @param[in]   nothing\r
961 */\r
962 void _vcui_doc_swap_all_call_data_status()\r
963 {\r
964         Eina_List *l = NULL;\r
965         call_data_t *cd = NULL;\r
966         EINA_LIST_FOREACH(caller_list, l, cd) {\r
967                 if (cd != NULL) {\r
968                         if (cd->caller_status == CALL_HOLD) {\r
969                                 cd->caller_status = CALL_UNHOLD;\r
970                         } else if (cd->caller_status == CALL_UNHOLD) {\r
971                                 cd->caller_status = CALL_HOLD;\r
972                         }\r
973                 }\r
974         }\r
975 }\r
976 \r