1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
/*
* Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "phone.h"
#include "ct-list.h"
#include "ct-input-utils.h"
#include "ct-detail-utils.h"
#include "ct-group-assign-view.h"
static Elm_Genlist_Item_Class grp_itc;
typedef struct{
int selected_radio_index;
int contact_id;
}ct_selected_radio_info;
typedef struct {
Evas_Object *navi_content;
Evas_Object *genlist;
Evas_Object *radio_main;
Evas_Object *navi;
contacts_record_h contact_record;
Eina_List *selected_radio_info;
bool from_detailview;
ct_assign_result_cb assign_cb;
void *assign_cb_data;
Eina_List *list_contact_id;
int id_person; //for entry detail view
int id_addressbook; //for entry iuput view
}ct_assign_group_data;
typedef struct {
Evas_Object *radio_main;
int grp_id;
int contact_id;
int radio_index;
char *name;
bool selected;
bool radio_list;
bool group_index;
Elm_Object_Item *item;
}ct_assign_list;
static void grp_assign_notify_update(ct_assign_group_data *cgassign_d)
{
ct_assign_list *info = NULL;
Elm_Object_Item *item;
int count = 0;
p_retm_if(NULL == cgassign_d, "ct_assign_group_data(cgassign_d) is null");
item = elm_genlist_first_item_get(cgassign_d->genlist);
while (item) {
info = elm_object_item_data_get(item);
if (info->selected)
count++;
item = elm_genlist_item_next_get(item);
}
if (0 < count) {
char buf[PH_TEXT_SHORT_LEN];
snprintf(buf, sizeof(buf), "%s (%d)", S_(PH_SYS_POP_SELECTED), count);
phone_show_notify(cgassign_d->navi_content, buf);
}
else
phone_show_notify(cgassign_d->navi_content, T_(CT_GET_TEXT_BASE_OP, CTTEXT_SELECT_GROUP));
}
static void grp_assign_gl_del(void *data, Evas_Object *obj)
{
ct_assign_list *info = data;
p_retm_if(NULL == data, "data is NULL");
free(info->name);
free(info);
}
static char* grp_assign_gl_label_get(void *data, Evas_Object *obj,
const char *part)
{
ct_assign_list *info = data;
p_retvm_if(NULL == data, NULL, "The parameter(data) is NULL");
if (!strcmp(part, "elm.text") && info->name)
return strdup(info->name);
return NULL;
}
static void grp_assign_check_btn_cb(void *data, Evas_Object *obj, void *event_info)
{
ct_assign_group_data *cgassign_d;
ct_assign_list *info = data;
p_retm_if(NULL == data, "The parameter(data) is NULL");
if (EINA_TRUE == elm_check_state_get(obj))
info->selected = true;
else
info->selected = false;
cgassign_d = evas_object_data_get(elm_object_item_widget_get(info->item), "cgassign_d");
p_retm_if(NULL == cgassign_d, "evas_object_data_get() return NULL");
grp_assign_notify_update(cgassign_d);
}
static Evas_Object* grp_assign_gl_icon_get(void *data, Evas_Object *obj,
const char *part)
{
ct_assign_list *gl = data;
p_retvm_if(NULL == data, NULL, "The parameter(data) is NULL");
if (!strcmp(part, "elm.icon")) {
if(gl->radio_list){
Evas_Object *radio = elm_radio_add(obj);
elm_radio_state_value_set(radio, gl->radio_index);
elm_radio_group_add(radio, gl->radio_main);
if(gl->selected)
elm_radio_value_set(gl->radio_main, gl->radio_index);
evas_object_smart_callback_add(radio, "changed", grp_assign_check_btn_cb, data);
return radio;
}
else{
Evas_Object *btn = elm_check_add(obj);
elm_check_state_set(btn, gl->selected);
evas_object_propagate_events_set(btn, EINA_FALSE);
evas_object_smart_callback_add(btn, "changed", grp_assign_check_btn_cb, data);
return btn;
}
}
return NULL;
}
static void grp_person_assign_done_cb(void *data, Evas_Object *obj, void *event_info)
{
PH_FN_CALL;
int i;
int err;
int group_id;
int contact_id = 0;
unsigned int relation_count = 0;
void *eina_data;
char display[PH_TEXT_MAX_LEN];
Eina_List *l;
contacts_record_h grouprel_record = NULL;
contacts_record_h contact_record = NULL;
Elm_Object_Item *item;
ct_assign_group_data *cgassign_d = data;
display[0]= '\0';
//remove relation field
EINA_LIST_FOREACH(cgassign_d->list_contact_id, l, eina_data) {
contact_id = (int)eina_data;
err = contacts_db_get_record(_contacts_contact._uri, contact_id, &contact_record );
if(CONTACTS_ERROR_NONE != err){
PH_DBG("contacts_db_get_record() is Failed(%d)", err);
continue;
}
err = contacts_record_get_child_record_count(contact_record,_contacts_contact.group_relation,&relation_count);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_count() Failed(%d)", err);
for (i = relation_count-1; i >= 0; i--) {
err = contacts_record_get_child_record_at_p(contact_record, _contacts_contact.group_relation, i, &grouprel_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err);
err = contacts_record_get_int(grouprel_record,_contacts_group_relation.group_id,&group_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
err = contacts_record_get_int(grouprel_record,_contacts_group_relation.contact_id,&contact_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
PH_DBG("remove relation group_id=%d, contact_id=%d", group_id,contact_id);
err = contacts_group_remove_contact(group_id,contact_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_group_remove_contact() Failed(%d)", err);
}
}
if (NULL == cgassign_d->genlist) {
if (cgassign_d->assign_cb)
cgassign_d->assign_cb(cgassign_d->assign_cb_data);
elm_naviframe_item_pop(cgassign_d->navi);
return;
}
item = elm_genlist_first_item_get(cgassign_d->genlist);
while(item){
ct_assign_list *info = NULL;
info = elm_object_item_data_get(item);
if(info->group_index == true){
item = elm_genlist_item_next_get(item);
continue;
}
ct_selected_radio_info *radio_info;
PH_DBG("contact_id = %d ",info->contact_id);
PH_DBG("info->selected = %d, info->grp_id = %d ",info->selected,info->grp_id);
if(info->selected == true){
err = contacts_group_add_contact(info->grp_id, info->contact_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_group_add_contact() Failed(%d)", err);
}
item = elm_genlist_item_next_get(item);
}
if (cgassign_d->assign_cb)
cgassign_d->assign_cb(cgassign_d->assign_cb_data);
phone_hide_notify(cgassign_d->navi_content);
elm_naviframe_item_pop(cgassign_d->navi);
}
static void grp_assign_done_cb(void *data, Evas_Object *obj, void *event_info)
{
PH_FN_CALL;
Elm_Object_Item *item;
char display[PH_TEXT_MAX_LEN];
ct_assign_group_data *cgassign_d = data;
int err,i;
int group_id,contact_id = 0;
display[0]= '\0';
contacts_record_h grouprel_record = NULL;
Eina_List *l;
//remove relation field
unsigned int relation_count = 0;
err = contacts_record_get_child_record_count(cgassign_d->contact_record, _contacts_contact.group_relation, &relation_count);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_count() Failed(%d)", err);
for (i = relation_count-1; i >= 0; i--) {
err = contacts_record_get_child_record_at_p(cgassign_d->contact_record, _contacts_contact.group_relation, i, &grouprel_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err);
err = contacts_record_get_int(grouprel_record, _contacts_group_relation.group_id, &group_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
err = contacts_record_get_int(grouprel_record, _contacts_group_relation.contact_id, &contact_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
err = contacts_record_remove_child_record(cgassign_d->contact_record, _contacts_contact.group_relation, grouprel_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_remove_child_record() Failed(%d)", err);
err = contacts_record_destroy(grouprel_record, true);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err);
}
if (NULL == cgassign_d->genlist) {
if (cgassign_d->assign_cb)
cgassign_d->assign_cb(cgassign_d->assign_cb_data);
elm_naviframe_item_pop(cgassign_d->navi);
return;
}
item = elm_genlist_first_item_get(cgassign_d->genlist);
while (item) {
ct_assign_list *info = elm_object_item_data_get(item);
if(info->group_index == true){
item = elm_genlist_item_next_get(item);
continue;
}
PH_DBG("info->selected = %d, info->grp_id = %d ",info->selected,info->grp_id);
if(info->selected == true){
err = contacts_record_create(_contacts_group_relation._uri, &grouprel_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_create() Failed(%d)", err);
err = contacts_record_set_int(grouprel_record,_contacts_group_relation.group_id,info->grp_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_set_int() Failed(%d)", err);
err = contacts_record_add_child_record(cgassign_d->contact_record, _contacts_contact.group_relation, grouprel_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_add_child_record() Failed(%d)", err);
}
item = elm_genlist_item_next_get(item);
}
if (cgassign_d->assign_cb)
cgassign_d->assign_cb(cgassign_d->assign_cb_data);
phone_hide_notify(cgassign_d->navi_content);
elm_naviframe_item_pop(cgassign_d->navi);
}
static inline void grp_assign_back_cb(void *data, Evas_Object *obj, void *event_info)
{
ct_assign_group_data *cgassign_d = data;
if (cgassign_d->assign_cb)
cgassign_d->assign_cb(cgassign_d->assign_cb_data);
phone_hide_notify(cgassign_d->navi_content);
elm_naviframe_item_pop(cgassign_d->navi);
}
static void grp_assign_gl_sel(void *data, Evas_Object *obj, void *event_info)
{
ct_assign_group_data *cgassign_d = data;
ct_assign_list *info;
Elm_Object_Item *item = event_info;
p_retm_if(NULL == data, "data is NULL");
info = elm_object_item_data_get(item);
p_retm_if(NULL == info, "elm_object_item_data_get() return NULL");
ct_selected_radio_info *radio_info;
Eina_List *l;
if(info->radio_list){
EINA_LIST_FOREACH(cgassign_d->selected_radio_info,l,radio_info){
if(radio_info->contact_id == info->contact_id)
radio_info->selected_radio_index = info->radio_index;
}
PH_DBG("selected_radio_index = %d",info->radio_index);
elm_genlist_item_selected_set(item, EINA_FALSE);
elm_genlist_item_update(item);
elm_radio_value_set(info->radio_main, info->radio_index);
}
else{
info->selected = !info->selected;
elm_genlist_item_selected_set(item, EINA_FALSE);
elm_genlist_item_update(item);
}
grp_assign_notify_update(cgassign_d);
}
static void grp_assign_fill_genlist(ct_assign_group_data *cgassign_d, contacts_list_h list_groups, int contact_id)
{
PH_FN_CALL;
contacts_record_h grouprel_record = NULL;
contacts_error_e err;
ct_assign_list *gl;
unsigned int relation_count = 0;
int radio_index = 1;
int i = 0;
int group_id = 0;
char *system_id = NULL;
grp_itc.item_style = "1text.1icon.2";
grp_itc.func.text_get = grp_assign_gl_label_get;
grp_itc.func.content_get = grp_assign_gl_icon_get;
grp_itc.func.state_get = NULL;
grp_itc.func.del = grp_assign_gl_del;
do {
gl = calloc(1, sizeof(ct_assign_list));
err = phone_cts_get_int_from_list(list_groups, _contacts_group.id, &(gl->grp_id));
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
PH_DBG("id=%d",gl->grp_id);
gl->contact_id = contact_id;
err = phone_cts_get_str_from_list(list_groups, _contacts_group.extra_data, &system_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_str_from_list() Failed(%d)", err);
if (NULL != system_id) {
if (strcmp(system_id,"friends")==0)
gl->name = SAFE_STRDUP(T_(CT_GET_TEXT_BASIC, CTTEXT_FRIENDS));
else if (strcmp(system_id,"family")==0)
gl->name = SAFE_STRDUP(T_(CT_GET_TEXT_BASIC, CTTEXT_FAMILY));
else if (strcmp(system_id,"coworkers")==0)
gl->name = SAFE_STRDUP(T_(CT_GET_TEXT_BASIC, CTTEXT_CO_WORKERS));
else
gl->name = SAFE_STRDUP(T_(CT_GET_TEXT_ERR, CTTEXT_NONAME));
}
else {
err = phone_cts_get_str_from_list(list_groups, _contacts_group.name, &(gl->name));
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err);
PH_DBG("name=%s",gl->name);
}
if(cgassign_d->contact_record) {
err = contacts_record_get_child_record_count(cgassign_d->contact_record, _contacts_contact.group_relation, &relation_count);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_count() Failed(%d)", err);
for (i = relation_count-1; i >= 0; i--) {
err = contacts_record_get_child_record_at_p(cgassign_d->contact_record, _contacts_contact.group_relation, i, &grouprel_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err);
err = contacts_record_get_int(grouprel_record, _contacts_group_relation.group_id, &group_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
if (group_id == gl->grp_id) {
gl->selected = true;
}
}
}
gl->item = elm_genlist_item_append(cgassign_d->genlist, &grp_itc, gl, NULL, ELM_GENLIST_ITEM_NONE, grp_assign_gl_sel, cgassign_d);
}while (CONTACTS_ERROR_NONE == contacts_list_next(list_groups));
}
static char *_account_group_label_get(void *data, Evas_Object *obj, const char *part)
{
ct_assign_list *gl = data;
if (0 == strcmp(part, "elm.text"))
return strdup(gl->name);
else
return NULL;
}
static Elm_Genlist_Item_Class group_index =
{
.item_style = "grouptitle",
.func.text_get = _account_group_label_get,
};
static void grp_person_assign_fill_layout(ct_assign_group_data *cgassign_d)
{
PH_FN_CALL;
unsigned int count = 0;
contacts_error_e err;
contacts_record_h contacts_record;
contacts_record_h addressbook_record;
contacts_list_h group_list;
Eina_List *l;
int contact_id = -1;
int address_book_id = -1;
Elm_Object_Item *item;
char *address_name;
char *contact_name;
char temp[PH_TEXT_MAX_LEN+1] ={0,};
ct_assign_list *gl;
void *data;
if (NULL == cgassign_d->genlist) {
cgassign_d->genlist = elm_genlist_add(cgassign_d->navi_content);
elm_object_part_content_set(cgassign_d->navi_content, "contents", cgassign_d->genlist);
evas_object_data_set(cgassign_d->genlist, "cgassign_d", cgassign_d);
}
EINA_LIST_FOREACH(cgassign_d->list_contact_id, l, data) {
contact_id = (int)data;
err = contacts_db_get_record(_contacts_contact._uri, contact_id, &contacts_record);
p_retm_if(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() is Failed(%d)", err);
err = contacts_record_get_int(contacts_record, _contacts_contact.address_book_id, &address_book_id);
p_retm_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() is Failed(%d)", err);
err = contacts_record_get_str_p(contacts_record, _contacts_contact.display_name, &contact_name);
p_retm_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() is Failed(%d)", err);
err = phone_cts_get_list(_contacts_group._uri, _contacts_group.address_book_id, address_book_id, &group_list);
p_retm_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_list() is Failed(%d)", err);
err = contacts_list_get_count(group_list, &count);
p_retm_if(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err);
if (count >0) {
err = contacts_db_get_record(_contacts_address_book._uri, address_book_id, &addressbook_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err);
contacts_record_get_str_p(addressbook_record, _contacts_address_book.name, &address_name);
snprintf(temp, PH_TEXT_MAX_LEN, "%s_%s", address_name, contact_name);
gl = calloc(1, sizeof(ct_assign_list));
gl->name = strdup(temp);
gl->group_index = true;
item = elm_genlist_item_append(cgassign_d->genlist, &group_index, gl , NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
cgassign_d->contact_record = contacts_record;
grp_assign_fill_genlist(cgassign_d, group_list, contact_id);
err = contacts_record_destroy(addressbook_record, true);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err);
}
err = contacts_list_destroy(group_list, true);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err);
}
grp_assign_notify_update(cgassign_d);
evas_object_show(cgassign_d->genlist);
/*
Evas_Object *noc;
noc = phone_create_nocontents(cgassign_d->navi_content, T_(CT_GET_TEXT_ERR, CTTEXT_NO_GROUP));
p_retm_if(NULL == noc, "phone_create_nocontents() return NULL");
elm_object_part_content_set(cgassign_d->navi_content, "contents", noc);
evas_object_show(noc);
cgassign_d->genlist = NULL;
*/
}
static void grp_assign_fill_layout(const char *view_uri, void *data)
{
PH_FN_CALL;
unsigned int count = 0;
contacts_error_e err;
contacts_list_h list;
int contact_id = 0;
ct_assign_group_data *cgassign_d = data;
err = phone_cts_get_list(_contacts_group._uri, _contacts_group.address_book_id, cgassign_d->id_addressbook, &list);
p_retm_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_list() is Failed(%d)", err);
err = contacts_list_get_count(list, &count);
p_retm_if(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err);
if (count) {
if (NULL == cgassign_d->genlist) {
cgassign_d->genlist = elm_genlist_add(cgassign_d->navi_content);
elm_object_part_content_set(cgassign_d->navi_content, "contents", cgassign_d->genlist);
evas_object_data_set(cgassign_d->genlist, "cgassign_d", cgassign_d);
}
else
elm_genlist_clear(cgassign_d->genlist);
contact_id = (int)eina_list_nth(cgassign_d->list_contact_id,0);//number of contac id is only one at input view
grp_assign_fill_genlist(cgassign_d, list,contact_id);
grp_assign_notify_update(cgassign_d);
evas_object_show(cgassign_d->genlist);
}
else {
Evas_Object *noc;
noc = phone_create_nocontents(cgassign_d->navi_content, T_(CT_GET_TEXT_ERR, CTTEXT_NO_GROUP));
p_retm_if(NULL == noc, "phone_create_nocontents() return NULL");
elm_object_part_content_set(cgassign_d->navi_content, "contents", noc);
evas_object_show(noc);
cgassign_d->genlist = NULL;
}
err = contacts_list_destroy(list, true);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err);
}
static void grp_assign_view_delete_cb(void *data, Evas *e, Evas_Object *obj,
void *event_info)
{
int ret;
Eina_List* l;
ct_selected_radio_info *info;
ct_assign_group_data *cgassign_d = data;
ret = contacts_db_remove_changed_cb(_contacts_group._uri, grp_assign_fill_layout, cgassign_d);
p_warn_if(CONTACTS_ERROR_NONE, "contacts_db_remove_changed_cb() Failed(%d)", ret);
EINA_LIST_FOREACH(cgassign_d->selected_radio_info, l, info)
if (info) free(info);
eina_list_free(cgassign_d->selected_radio_info);
free(cgassign_d);
}
static void grp_assign_create_layout(ct_assign_group_data *cgassign_d)
{
Evas_Object *base;
Evas_Object *l_btn;
Evas_Object *layout;
Elm_Object_Item *navi_item;
base = phone_create_base_layout(cgassign_d->navi, false);
layout = elm_layout_add(base);
elm_object_part_content_set(base, "elm.swallow.content", layout);
p_retm_if(NULL == layout, "elm_layout_add return NULL");
elm_layout_file_set(layout, SELECTION_INFO_EDJ, "selectioninfo_layout");
cgassign_d->navi_content = layout;
evas_object_show(layout);
if(cgassign_d->id_person > 0)
grp_person_assign_fill_layout(cgassign_d);
else
grp_assign_fill_layout(_contacts_group._uri, cgassign_d);
navi_item = elm_naviframe_item_push(cgassign_d->navi,
T_(CT_GET_TEXT_BASE_OP, CTTEXT_SELECT_GROUP), NULL, NULL, layout, NULL);
if(cgassign_d->from_detailview == true) {
Evas_Object *toolbar_btn = phone_create_toolbar_btn(cgassign_d->navi, S_(CT_SYS_SK_DONE), grp_person_assign_done_cb, cgassign_d);
elm_object_style_set(toolbar_btn, "naviframe/toolbar/left");
elm_object_item_part_content_set(navi_item, "toolbar_button1", toolbar_btn);
}
else {
Evas_Object *toolbar_btn = phone_create_toolbar_btn(cgassign_d->navi, S_(CT_SYS_SK_DONE), grp_assign_done_cb, cgassign_d);
elm_object_style_set(toolbar_btn, "naviframe/toolbar/left");
elm_object_item_part_content_set(navi_item, "toolbar_button1", toolbar_btn);
}
l_btn = phone_create_toolbar_btn(cgassign_d->navi, S_(PH_SYS_SK_CANCEL), grp_assign_back_cb, cgassign_d);
elm_object_style_set(l_btn, "naviframe/toolbar/right");
elm_object_item_part_content_set(navi_item, "toolbar_button2", l_btn);
evas_object_event_callback_add(cgassign_d->navi_content, EVAS_CALLBACK_DEL,
grp_assign_view_delete_cb, cgassign_d);
}
void ct_grp_assign_create_view(Evas_Object *navi, contacts_record_h contact, int id_ab, ct_assign_result_cb assign_cb, void *assign_cb_data)
{
PH_FN_CALL;
int ret;
int contact_id;
ct_assign_group_data *cgassign_d;
cgassign_d = calloc(1, sizeof(ct_assign_group_data));
cgassign_d->navi = navi;
cgassign_d->contact_record = contact;
cgassign_d->id_addressbook = id_ab;
cgassign_d->assign_cb = assign_cb;
cgassign_d->assign_cb_data = assign_cb_data;
cgassign_d->from_detailview = false;
ret = contacts_record_get_int(contact,_contacts_contact.id,&contact_id);
p_warn_if(CONTACTS_ERROR_NONE, "contacts_record_get_int() Failed(%d)", ret);
cgassign_d->list_contact_id = eina_list_append(cgassign_d->list_contact_id,(void*)contact_id);
PH_DBG("id_ab = %d,contact_id = %d",id_ab, contact_id);
grp_assign_create_layout(cgassign_d);
contacts_db_add_changed_cb(_contacts_group._uri, grp_assign_fill_layout, cgassign_d);
p_warn_if(CONTACTS_ERROR_NONE, "contacts_db_add_changed_cb() Failed(%d)", ret);
}
void ct_person_grp_assign_create_view(Evas_Object *navi, int person_id, ct_assign_result_cb assign_cb, void *assign_cb_data)
{
PH_FN_CALL;
int ret;
ct_assign_group_data *cgassign_d;
contacts_list_h contact_list = NULL;
contacts_record_h record = NULL;
cgassign_d = calloc(1, sizeof(ct_assign_group_data));
cgassign_d->navi = navi;
cgassign_d->assign_cb = assign_cb;
cgassign_d->assign_cb_data = assign_cb_data;
cgassign_d->id_person = person_id;
cgassign_d->from_detailview = true;
ret = phone_cts_get_list(_contacts_simple_contact._uri,_contacts_simple_contact.person_id,person_id,&contact_list);
p_warn_if(CONTACTS_ERROR_NONE, "phone_cts_get_list() Failed(%d)", ret);
ret = contacts_list_get_current_record_p(contact_list, &record);
p_warn_if(CONTACTS_ERROR_NONE, "contacts_list_get_current_record_p() Failed(%d)", ret);
while(record){
int contact_id;
ret = contacts_record_get_int(record,_contacts_simple_contact.id,&contact_id );
p_warn_if(CONTACTS_ERROR_NONE, "contacts_record_get_int() Failed(%d)", ret);
cgassign_d->list_contact_id = eina_list_append(cgassign_d->list_contact_id,(void*)contact_id);
ret = contacts_list_next(contact_list);
p_warn_if(CONTACTS_ERROR_NONE, "contacts_list_next() Failed(%d)", ret);
ret = contacts_list_get_current_record_p(contact_list, &record);
p_warn_if(CONTACTS_ERROR_NONE, "contacts_list_get_current_record_p() Failed(%d)", ret);
}
ret = contacts_list_destroy(contact_list, true);
p_warn_if(CONTACTS_ERROR_NONE, "contacts_list_destroy() Failed(%d)", ret);
grp_assign_create_layout(cgassign_d);
ret = contacts_db_add_changed_cb(_contacts_group._uri,grp_assign_fill_layout,cgassign_d);
p_warn_if(CONTACTS_ERROR_NONE, "contacts_db_add_changed_cb() Failed(%d)", ret);
}
|