2 This file is part of Telegram application for tizen
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "tg_user_info_view.h"
20 #include "server_requests.h"
21 #include "tg_user_main_view.h"
22 #include "tg_add_contact.h"
23 #include "tg_db_wrapper.h"
24 #include "tg_search_peer_view.h"
26 static Evas_Object* get_image_from_path(const char* path, Evas_Object* parent)
31 Evas_Object *media_image = elm_image_add(parent);
32 elm_image_aspect_fixed_set(media_image, EINA_FALSE);
33 elm_image_file_set(media_image, path, NULL);
34 evas_object_size_hint_weight_set(media_image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
35 evas_object_size_hint_align_set(media_image, EVAS_HINT_FILL, EVAS_HINT_FILL);
36 evas_object_show(media_image);
40 void on_user_added_response_received(appdata_s *ad, int buddy_id, Eina_Bool is_success)
42 if (!is_success || !ad->buddy_in_cahtting_data || !ad->peer_in_cahtting_data || ad->peer_in_cahtting_data->use_data->peer_id != buddy_id) {
43 show_toast(ad, "Failed to add user.");
47 ad->buddy_in_cahtting_data->use_data->is_deleted = 0;
48 load_buddy_list_data(ad);
49 load_unknown_buddy_list_data(ad);
51 load_main_list_data(ad);
52 refresh_main_list_view(ad, EINA_FALSE);
55 user_data_with_pic_s *item = NULL;
56 EINA_LIST_FOREACH(ad->buddy_list, l, item) {
57 user_data_s* user_data = item->use_data;
58 if (user_data->user_id.id == buddy_id) {
59 ad->buddy_in_cahtting_data = item;
64 if (ad->buddy_in_cahtting_data == NULL) {
66 user_data_with_pic_s *item = NULL;
67 EINA_LIST_FOREACH(ad->unknown_buddy_list, l, item) {
68 user_data_s* user_data = item->use_data;
69 if (user_data->user_id.id == buddy_id) {
70 ad->buddy_in_cahtting_data = item;
76 peer_with_pic_s* pic_item = NULL;
78 EINA_LIST_FOREACH(ad->peer_list, l, pic_item) {
79 tg_peer_info_s* item = pic_item->use_data;
80 if (item->peer_id == buddy_id) {
81 ad->peer_in_cahtting_data = pic_item;
88 show_toast(ad, "User added successfully");
91 void on_user_deleted_response_received(appdata_s *ad, int buddy_id, Eina_Bool is_success)
93 if (!is_success || !ad->buddy_in_cahtting_data || !ad->peer_in_cahtting_data || ad->peer_in_cahtting_data->use_data->peer_id != buddy_id) {
94 show_toast(ad, "Failed to delete user.");
98 ad->buddy_in_cahtting_data->use_data->is_deleted = 1;
99 load_buddy_list_data(ad);
100 load_unknown_buddy_list_data(ad);
102 load_main_list_data(ad);
103 refresh_main_list_view(ad, EINA_FALSE);
106 user_data_with_pic_s *item = NULL;
107 EINA_LIST_FOREACH(ad->buddy_list, l, item) {
108 user_data_s* user_data = item->use_data;
109 if (user_data->user_id.id == buddy_id) {
110 ad->buddy_in_cahtting_data = item;
115 if (ad->buddy_in_cahtting_data == NULL) {
117 user_data_with_pic_s *item = NULL;
118 EINA_LIST_FOREACH(ad->unknown_buddy_list, l, item) {
119 user_data_s* user_data = item->use_data;
120 if (user_data->user_id.id == buddy_id) {
121 ad->buddy_in_cahtting_data = item;
128 peer_with_pic_s* pic_item = NULL;
130 EINA_LIST_FOREACH(ad->peer_list, l, pic_item) {
131 tg_peer_info_s* item = pic_item->use_data;
132 if (item->peer_id == buddy_id) {
133 ad->peer_in_cahtting_data = pic_item;
140 show_toast(ad, "User deleted successfully");
144 void on_user_block_response_received(appdata_s *ad, int buddy_id, Eina_Bool is_success)
146 if (!is_success || !ad->buddy_in_cahtting_data || !ad->peer_in_cahtting_data || ad->peer_in_cahtting_data->use_data->peer_id != buddy_id) {
147 show_toast(ad, "Failed to block user.");
149 ad->buddy_in_cahtting_data->use_data->is_blocked = 1;
150 show_toast(ad, "User blocked successfully");
153 void on_user_unblock_response_received(appdata_s *ad, int buddy_id, Eina_Bool is_success)
155 if (!is_success || !ad->buddy_in_cahtting_data || !ad->peer_in_cahtting_data || ad->peer_in_cahtting_data->use_data->peer_id != buddy_id) {
156 show_toast(ad, "Failed to unblock user.");
158 ad->buddy_in_cahtting_data->use_data->is_blocked = 0;
159 show_toast(ad, "User unblocked successfully");
163 static void on_userinfo_menu_canceled(void *data, Evas_Object *obj, void *event_info)
165 //appdata_s *ad = evas_object_data_get(obj, "app_data");
166 Evas_Object *popup = evas_object_data_get(obj, "popup");
167 evas_object_del(popup);
170 static void on_user_block_ok_selected(void *data, Evas_Object *obj, void *event_info)
172 appdata_s *ad = evas_object_data_get(obj, "app_data");
173 Evas_Object *popup = evas_object_data_get(obj, "popup");
175 if (ad->peer_in_cahtting_data && ad->peer_in_cahtting_data->use_data) {
176 show_loading_popup(ad);
177 peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
178 if (get_buddy_block_status(sel_item->use_data->peer_id) == 1) {
179 send_unblock_buddy_request(ad, ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
181 send_block_buddy_request(ad, ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
184 evas_object_del(popup);
187 static void on_block_selected_cb(appdata_s *ad)
189 Evas_Object *popup, *btn;
192 popup = elm_popup_add(ad->nf);
193 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
194 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
195 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
197 peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
198 if (get_buddy_block_status(sel_item->use_data->peer_id) == 1) {
199 elm_object_text_set(popup, "Are you sure want to unblock this contact?");
201 elm_object_text_set(popup, "Are you sure want to block this contact?");
205 btn = elm_button_add(popup);
206 elm_object_style_set(btn, "popup");
207 elm_object_text_set(btn, "OK");
208 elm_object_part_content_set(popup, "button1", btn);
209 evas_object_smart_callback_add(btn, "clicked", on_user_block_ok_selected, ad);
210 evas_object_data_set(btn, "app_data", ad);
211 evas_object_data_set(btn, "popup", popup);
214 btn = elm_button_add(popup);
215 elm_object_style_set(btn, "popup");
216 elm_object_text_set(btn, "Cancel");
217 elm_object_part_content_set(popup, "button2", btn);
218 evas_object_smart_callback_add(btn, "clicked", on_userinfo_menu_canceled, ad);
219 evas_object_data_set(btn, "app_data", ad);
220 evas_object_data_set(btn, "popup", popup);
222 evas_object_show(popup);
225 /************************ delete user *****************************/
227 static void on_user_delete_ok_selected(void *data, Evas_Object *obj, void *event_info)
229 appdata_s *ad = evas_object_data_get(obj, "app_data");
230 Evas_Object *popup = evas_object_data_get(obj, "popup");
232 if (ad->peer_in_cahtting_data && ad->peer_in_cahtting_data->use_data) {
233 peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
234 if (get_buddy_delete_status(sel_item->use_data->peer_id) == 1 || get_buddy_unknown_status(sel_item->use_data->peer_id) == 1) {
235 launch_add_contact_screen(ad);
236 //send_add_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
238 show_loading_popup(ad);
239 send_delete_buddy_request(ad, ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
243 evas_object_del(popup);
246 static void on_delete_selected_cb(appdata_s *ad)
248 Evas_Object *popup, *btn;
251 popup = elm_popup_add(ad->nf);
252 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
253 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
254 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
255 peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
256 if (get_buddy_delete_status(sel_item->use_data->peer_id) == 1 || get_buddy_unknown_status(sel_item->use_data->peer_id) == 1) {
257 elm_object_text_set(popup, "Are you sure want to add this contact?");
259 elm_object_text_set(popup, "Are you sure want to delete this contact?");
263 btn = elm_button_add(popup);
264 elm_object_style_set(btn, "popup");
265 elm_object_text_set(btn, "OK");
266 elm_object_part_content_set(popup, "button1", btn);
267 evas_object_smart_callback_add(btn, "clicked", on_user_delete_ok_selected, ad);
268 evas_object_data_set(btn, "app_data", ad);
269 evas_object_data_set(btn, "popup", popup);
272 btn = elm_button_add(popup);
273 elm_object_style_set(btn, "popup");
274 elm_object_text_set(btn, "Cancel");
275 elm_object_part_content_set(popup, "button2", btn);
276 evas_object_smart_callback_add(btn, "clicked", on_userinfo_menu_canceled, ad);
277 evas_object_data_set(btn, "app_data", ad);
278 evas_object_data_set(btn, "popup", popup);
280 evas_object_show(popup);
283 /************************ delete user *****************************/
285 /************************ Menu Handler ********************/
287 void on_user_info_menu_option_selected_cb(void *data, Evas_Object *obj, void *event_info)
289 appdata_s *ad = data;
290 Elm_Object_Item *it = event_info;
295 elm_genlist_item_selected_set(it, EINA_FALSE);
296 int id = (int)elm_object_item_data_get(it);
298 peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
299 tg_peer_info_s *user_data = sel_item->use_data;
301 if (!sel_item || !user_data)
307 if (user_data->peer_type == TGL_PEER_USER) {
308 if (get_buddy_delete_status(sel_item->use_data->peer_id) == 1 || get_buddy_unknown_status(sel_item->use_data->peer_id) == 1) {
311 on_delete_selected_cb(ad);
316 ad->is_loading_from_profile_view = EINA_TRUE;
317 on_create_new_contact(ad);
320 show_toast(ad, i18n_get_text("IDS_TGRAM_OPT_SHARE"));
323 if (user_data->peer_type == TGL_PEER_USER) {
324 on_block_selected_cb(ad);
329 evas_object_del(ad->msg_popup);
330 ad->msg_popup = NULL;
334 char* on_user_info_menu_text_get_cb(void *data, Evas_Object *obj, const char *part)
337 appdata_s *ad = evas_object_data_get(obj, "app_data");
338 peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
340 if (!ad || !sel_item)
345 if (get_buddy_delete_status(sel_item->use_data->peer_id) == 1 ||
346 get_buddy_unknown_status(sel_item->use_data->peer_id) == 1)
347 return strdup(i18n_get_text("IDS_TGRAM_OPT_ADD_TO_TELEGRAM"));
349 return strdup(i18n_get_text("IDS_TGRAM_OPT_DELETE"));
352 if(!is_telegram_account(sel_item->use_data->peer_id))
353 return strdup(i18n_get_text("IDS_TGRAM_OPT_EDIT"));
358 return strdup(i18n_get_text("IDS_TGRAM_OPT_SHARE"));
361 if (get_buddy_block_status(sel_item->use_data->peer_id) == 1)
362 return strdup(i18n_get_text("IDS_TGRAM_OPT_UNBLOCK"));
364 return strdup(i18n_get_text("IDS_TGRAM_OPT_BLOCK"));
369 void on_user_info_msg_popup_back_cb(void *data, Evas_Object *obj, void *event_info)
371 appdata_s *ad = data;
373 evas_object_del(ad->msg_popup);
374 ad->msg_popup = NULL;
378 void on_user_info_menu_button_clicked(void *data, Evas_Object *obj, void *event_info)
380 appdata_s *ad = data;
381 if (ad->msg_popup || ad->current_app_state != TG_SET_USER_INFO_STATE)
385 static Elm_Genlist_Item_Class itc;
386 Evas_Object *genlist;
387 Evas_Object *win = ad->win;
389 ad->msg_popup = elm_popup_add(win);
390 elm_popup_align_set(ad->msg_popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
391 eext_object_event_callback_add(ad->msg_popup, EEXT_CALLBACK_BACK, on_user_info_msg_popup_back_cb, ad);
392 evas_object_size_hint_weight_set(ad->msg_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
394 evas_object_data_set(ad->msg_popup, "app_data", ad);
396 genlist = elm_genlist_add(ad->msg_popup);
397 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
398 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
400 evas_object_data_set(genlist, "app_data", ad);
402 itc.item_style = "default";
403 itc.func.text_get = on_user_info_menu_text_get_cb;
404 itc.func.content_get = NULL;
405 itc.func.state_get = NULL;
408 int number_of_menus = 4;
409 Eina_Bool is_need_continue = EINA_FALSE;
410 peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
411 if(sel_item && is_telegram_account(sel_item->use_data->peer_id)) {
413 is_need_continue = EINA_TRUE;
416 for (int i = 0; i < number_of_menus; i++) {
417 if(is_need_continue && i == 1)
419 elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_user_info_menu_option_selected_cb, ad);
422 evas_object_show(genlist);
423 elm_object_content_set(ad->msg_popup, genlist);
424 evas_object_show(ad->msg_popup);
428 /************************ Menu Handler ********************/
430 Evas_Object* on_buddy_info_requested(void *data, Evas_Object *obj, const char *part)
432 Evas_Object *eo = NULL;
433 appdata_s* ad = evas_object_data_get(obj, "app_data");
434 if (!strcmp(part, "elm.swallow.icon")) {
435 Evas_Object *profile_pic = NULL;
436 if (ad->peer_in_cahtting_data->use_data->photo_path && strlen(ad->peer_in_cahtting_data->use_data->photo_path) > 0 && strstr(ad->peer_in_cahtting_data->use_data->photo_path, "_null_") == NULL) {
437 profile_pic = get_image_from_path(ad->peer_in_cahtting_data->use_data->photo_path, ad->nf);
439 profile_pic = get_image_from_path(ui_utils_get_resource(DEFAULT_PROFILE_PIC), ad->nf);
441 char edj_path[PATH_MAX] = {0, };
442 app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
443 Evas_Object* user_pic_layout = elm_layout_add(ad->nf);
444 elm_layout_file_set(user_pic_layout, edj_path, "circle_layout");
445 evas_object_size_hint_weight_set(user_pic_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
446 evas_object_size_hint_align_set(user_pic_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
447 evas_object_show(user_pic_layout);
448 elm_object_part_content_set(user_pic_layout, "content", profile_pic);
450 evas_object_data_set(ad->nf, "user_profile_pic", profile_pic);
452 eo = elm_layout_add(obj);
453 elm_layout_theme_set(eo, "layout", "list/C/type.1", "default");
454 elm_layout_content_set(eo, "elm.swallow.content", user_pic_layout);
455 } else if (!strcmp(part, "elm.swallow.icon.0")) {
456 char edj_path[PATH_MAX] = {0, };
457 app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
458 Evas_Object* user_status_layout = elm_layout_add(ad->nf);
459 elm_layout_file_set(user_status_layout, edj_path, "main_list_name_status_item");
460 evas_object_size_hint_weight_set(user_status_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
461 evas_object_size_hint_align_set(user_status_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
462 evas_object_show(user_status_layout);
464 char* user_name = replace(ad->peer_in_cahtting_data->use_data->print_name, '_', " ");
465 char buf[512] = {'\0'};
466 snprintf(buf, 512, "<font=Tizen:style=Bold color=#FFFFFF align=left><font_size=40>%s</font_size></font>", user_name);
469 Evas_Object* name_lbl = elm_label_add(ad->nf);
470 elm_object_text_set(name_lbl, buf);
471 evas_object_size_hint_weight_set(name_lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
472 evas_object_size_hint_align_set(name_lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
473 evas_object_show(name_lbl);
475 elm_object_part_content_set(user_status_layout, "swallow.name", name_lbl);
477 Evas_Object *profile_time = evas_object_data_get(ad->nf, "profile_time");
478 char *online_status = "";
480 online_status = elm_entry_markup_to_utf8(elm_object_text_get(profile_time));
482 char status_buf[126] = {'\0'};
483 sprintf(status_buf, "<font=Tizen:style=Normal color=#FFFFFF align=left><font_size=35>%s</font_size></font>", online_status);
485 Evas_Object* status_lbl = elm_label_add(ad->nf);
486 elm_object_text_set(status_lbl, status_buf);
487 evas_object_size_hint_weight_set(status_lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
488 evas_object_size_hint_align_set(status_lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
489 evas_object_show(status_lbl);
491 elm_object_part_content_set(user_status_layout, "swallow.status", status_lbl);
492 return user_status_layout;
499 Evas_Object* on_buddy_phone_info_requested(void *data, Evas_Object *obj, const char *part)
501 Evas_Object *eo = NULL;
502 if (strcmp(part, "elm.swallow.icon.0")) {
506 appdata_s* ad = evas_object_data_get(obj, "app_data");
508 char edj_path[PATH_MAX] = {0, };
509 app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
510 Evas_Object* user_status_layout = elm_layout_add(ad->nf);
511 elm_layout_file_set(user_status_layout, edj_path, "main_list_name_status_item");
512 evas_object_size_hint_weight_set(user_status_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
513 evas_object_size_hint_align_set(user_status_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
514 evas_object_show(user_status_layout);
516 char* first_text = NULL;
517 char buf[512] = {'\0'};
519 if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->phone) {
520 first_text = ad->buddy_in_cahtting_data->use_data->phone;
522 char *phone_no = get_buddy_phone_num_from_id(ad->peer_in_cahtting_data->use_data->peer_id);
524 first_text = phone_no;
530 if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->username && strlen(ad->buddy_in_cahtting_data->use_data->username) > 0 && strstr(ad->buddy_in_cahtting_data->use_data->username, "_null_") == NULL) {
531 first_text = ad->buddy_in_cahtting_data->use_data->username;
537 snprintf(buf, sizeof(buf) - 1, "<font=Tizen:style=Bold color=#000000 align=left><font_size=40>%s</font_size></font>", first_text);
539 Evas_Object* name_lbl = elm_label_add(ad->nf);
540 elm_object_text_set(name_lbl, buf);
541 evas_object_size_hint_weight_set(name_lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
542 evas_object_size_hint_align_set(name_lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
543 evas_object_show(name_lbl);
546 evas_object_data_set(ad->nf, "settings_user_name_label", name_lbl);
548 elm_object_part_content_set(user_status_layout, "swallow.name", name_lbl);
550 char* second_text = NULL;
552 second_text = "Phone";
554 second_text = "Username";
556 char status_buf[126] = {'\0'};
557 sprintf(status_buf, "<font=Tizen:style=Normal color=#808080 align=left><font_size=35>%s</font_size></font>", second_text);
559 Evas_Object* status_lbl = elm_label_add(ad->nf);
560 elm_object_text_set(status_lbl, status_buf);
561 evas_object_size_hint_weight_set(status_lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
562 evas_object_size_hint_align_set(status_lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
563 evas_object_show(status_lbl);
565 elm_object_part_content_set(user_status_layout, "swallow.status", status_lbl);
566 return user_status_layout;
570 void on_message_button_clicked(void *data, Evas_Object *obj, void *event_info)
572 appdata_s *ad = data;
576 elm_naviframe_item_pop(ad->nf);
577 ad->current_app_state = TG_CHAT_MESSAGING_VIEW_STATE;
580 void on_userinfo_back_button_clicked(void *data, Evas_Object *obj, void *event_info)
582 appdata_s *ad = data;
586 app_nf_back_cb(data, obj, event_info);
590 static void on_user_info_icon_pressed(void *data, Evas_Object *obj, void *event_info)
593 evas_object_color_set(data, 45, 165, 224, 178);
596 static void on_user_info_icon_unpressed(void *data, Evas_Object *obj, void *event_info)
599 evas_object_color_set(data, 45, 165, 224, 255);
602 static void on_user_info_msg_clicked(void *data, Evas_Object *obj, void *event_info)
604 appdata_s *ad = data;
607 elm_naviframe_item_pop(ad->nf);
608 ad->current_app_state = TG_CHAT_MESSAGING_VIEW_STATE;
611 static void on_user_info_call_clicked(void *data, Evas_Object *obj, void *event_info)
613 appdata_s *ad = data;
617 app_control_h app_control;
618 int ret = app_control_create(&app_control);
619 if (ret != APP_CONTROL_ERROR_NONE)
622 app_control_set_operation(app_control, APP_CONTROL_OPERATION_CALL);
623 char phone_num[512] = {0,};
624 strcpy(phone_num, "tel:");
625 strcat(phone_num, ad->buddy_in_cahtting_data->use_data->phone);
626 app_control_set_uri(app_control, phone_num);
627 if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE) {
630 app_control_destroy(app_control);
633 static void compare_with_current_date(int rtime, Elm_Object_Item *nf_it)
635 char time_str[256] = {0,};
636 time_t local_t = time(NULL);
642 diff_sec = local_t - rtime;
643 diff_min = diff_sec / 60;
644 diff_hour = diff_min / 60;
645 diff_day = diff_hour / 24;
646 LOGD("different : day : %d, hour = %d, min = %d, sec = %d", diff_day, diff_hour, diff_min, diff_sec);
650 snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_LONG_TIME_AGO_ABB"));
655 snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_WITHIN_A_MONTH_ABB"));
659 snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_WITHIN_A_WEEK_ABB"));
664 snprintf(time_str, sizeof(time_str) - 1, i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_PD_HOURS_AGO_ABB"), diff_hour);
668 if (diff_hour == 1) {
669 snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_1_HOUR_AGO_ABB"));
673 snprintf(time_str, sizeof(time_str) - 1, i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_PD_MINUTES_AGO_ABB"), diff_min);
677 snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_1_MINUTE_AGO_ABB"));
680 snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_RECENTLY_ABB"));
683 elm_object_item_part_text_set(nf_it, "subtitle", time_str);
686 void launch_user_info_screen(appdata_s* ad, int peer_id)
692 evas_object_del(ad->msg_popup);
693 ad->msg_popup = NULL;
695 ad->current_app_state = TG_SET_USER_INFO_STATE;
696 char edj_path[PATH_MAX] = {0, };
697 app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
699 Evas_Object* scroller = elm_scroller_add(ad->nf);
700 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
701 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
703 Evas_Object* layout = elm_layout_add(ad->nf);
704 elm_layout_file_set(layout, edj_path, "buddy_info_screen");
705 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
706 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
707 evas_object_show(layout);
708 elm_object_content_set(scroller, layout);
710 char temp_name[512] = {'\0'};
711 char* user_name = replace(ad->peer_in_cahtting_data->use_data->print_name, '_', " ");
712 snprintf(temp_name, 512, "%s", user_name);
715 Elm_Object_Item* navi_item = elm_naviframe_item_push(ad->nf, temp_name, NULL, NULL, scroller, NULL);
716 elm_object_item_part_text_set(navi_item, "subtitle", "Subtitle");
718 /*********************** set last seen ******************************/
720 Eina_List *buddy_details_array = get_buddy_info(ad->peer_in_cahtting_data->use_data->peer_id);
721 if (buddy_details_array && eina_list_count(buddy_details_array) > 0) {
722 Eina_List *buddy_details = eina_list_nth(buddy_details_array, 0);
723 if (buddy_details && eina_list_count(buddy_details) > 0) {
724 int* temp_online = (int *)eina_list_nth(buddy_details, 12);
725 int is_online = *temp_online;
726 int* temp_last_seen = (int *)eina_list_nth(buddy_details, 13);
727 int last_seen = *temp_last_seen;
730 elm_object_item_part_text_set(navi_item, "subtitle", i18n_get_text("IDS_TGRAM_SBODY_ONLINE"));
732 compare_with_current_date(last_seen, navi_item);
736 EINA_LIST_FREE(buddy_details,val) {
740 eina_list_free(buddy_details);
742 eina_list_free(buddy_details_array);
745 Evas_Object *profile_pic = NULL;
746 Evas_Object *image_layout = NULL;
748 if (ad->peer_in_cahtting_data->use_data->photo_path && strlen(ad->peer_in_cahtting_data->use_data->photo_path) > 0 && strstr(ad->peer_in_cahtting_data->use_data->photo_path, "_null_") == NULL) {
749 image_layout = elm_layout_add(ad->nf);
750 elm_layout_file_set(image_layout, edj_path, "contact_image_masking");
751 evas_object_size_hint_weight_set(image_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
752 evas_object_size_hint_align_set(image_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
753 evas_object_show(image_layout);
754 profile_pic = get_image_from_path(ad->peer_in_cahtting_data->use_data->photo_path, ad->nf);
755 elm_object_part_content_set(image_layout, "image", profile_pic);
757 image_layout = elm_layout_add(ad->nf);
758 elm_layout_file_set(image_layout, edj_path, "contact_image_masking");
759 evas_object_size_hint_weight_set(image_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
760 evas_object_size_hint_align_set(image_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
761 evas_object_show(image_layout);
762 profile_pic = get_image_from_path(ui_utils_get_resource(TG_CALLER_ID_IMAGE), ad->nf);
763 evas_object_color_set(profile_pic, 45, 165, 224, 225);
764 elm_object_part_content_set(image_layout, "image", profile_pic);
767 elm_object_part_content_set(layout, "swallow.profile_pic", image_layout);
769 Evas_Object *info_layout = elm_layout_add(ad->nf);
770 elm_layout_file_set(info_layout, edj_path, "buddy_num_layout");
771 evas_object_size_hint_weight_set(info_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
772 evas_object_size_hint_align_set(info_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
773 evas_object_show(info_layout);
774 elm_object_part_content_set(layout, "swallow.profile_info", info_layout);
776 Evas_Object *phone_type = elm_label_add(ad->nf);
777 elm_object_style_set(phone_type, "transparent");
778 char phone_type_str[256];
779 sprintf(phone_type_str, "<font=Tizen:style=Normal color=#A9A9A9 align=left><font_size=35> %s</font_size></font>", i18n_get_text("IDS_TGRAM_BODY_MOBILE_ABB"));
780 elm_object_text_set(phone_type, phone_type_str);
781 evas_object_size_hint_weight_set(phone_type, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
782 evas_object_size_hint_align_set(phone_type, EVAS_HINT_FILL, EVAS_HINT_FILL);
783 evas_object_show(phone_type);
785 elm_object_part_content_set(info_layout, "swallow.phone_type", phone_type);
787 if (ad->buddy_in_cahtting_data) {
788 Evas_Object* msg_btn = elm_button_add(ad->nf);
789 elm_object_style_set(msg_btn, "transparent");
790 evas_object_size_hint_align_set(msg_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
791 evas_object_size_hint_weight_set(msg_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
793 Evas_Object* msg_icon = elm_image_add(ad->nf);
794 evas_object_size_hint_align_set(msg_icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
795 evas_object_size_hint_weight_set(msg_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
796 elm_image_file_set(msg_icon, ui_utils_get_resource(TG_USER_INFO_MESSAGE), NULL);
797 evas_object_show(msg_icon);
798 evas_object_color_set(msg_icon, 45, 165, 224, 255);
799 elm_object_content_set(msg_btn, msg_icon);
801 evas_object_smart_callback_add(msg_btn, "clicked", on_user_info_msg_clicked, ad);
802 evas_object_smart_callback_add(msg_btn, "pressed", on_user_info_icon_pressed, msg_icon);
803 evas_object_smart_callback_add(msg_btn, "unpressed", on_user_info_icon_unpressed, msg_icon);
804 elm_object_part_content_set(info_layout, "swallow.phone_msg", msg_btn);
806 Evas_Object* call_btn = elm_button_add(ad->nf);
807 elm_object_style_set(call_btn, "transparent");
808 evas_object_size_hint_align_set(call_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
809 evas_object_size_hint_weight_set(call_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
811 Evas_Object* call_icon = elm_image_add(ad->nf);
812 evas_object_size_hint_align_set(call_icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
813 evas_object_size_hint_weight_set(call_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
814 elm_image_file_set(call_icon, ui_utils_get_resource(TG_USER_INFO_CALL), NULL);
815 evas_object_show(call_icon);
816 evas_object_color_set(call_icon, 45, 165, 224, 255);
817 elm_object_content_set(call_btn, call_icon);
819 evas_object_smart_callback_add(call_btn, "clicked", on_user_info_call_clicked, ad);
820 evas_object_smart_callback_add(call_btn, "pressed", on_user_info_icon_pressed, call_icon);
821 evas_object_smart_callback_add(call_btn, "unpressed", on_user_info_icon_unpressed, call_icon);
822 elm_object_part_content_set(info_layout, "swallow.phone_call", call_btn);
824 Evas_Object *phone_num = elm_label_add(ad->nf);
825 elm_object_style_set(phone_num, "transparent");
826 char phone_num_str[256];
827 sprintf(phone_num_str, "<font=Tizen:style=Bold color=#000000 align=left><font_size=40> %s</font_size></font>", ad->buddy_in_cahtting_data->use_data->phone);
828 elm_object_text_set(phone_num, phone_num_str);
829 evas_object_size_hint_weight_set(phone_num, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
830 evas_object_size_hint_align_set(phone_num, EVAS_HINT_FILL, EVAS_HINT_FILL);
831 evas_object_show(phone_num);
832 elm_object_part_content_set(info_layout, "swallow.phone_number", phone_num);
834 Evas_Object *back_btn = create_button(ad->nf, "naviframe/back_btn/default", NULL);
835 evas_object_smart_callback_add(back_btn, "clicked", on_userinfo_back_button_clicked, ad);
836 elm_object_item_part_content_set(navi_item, "elm.swallow.prev_btn", back_btn);
838 eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_MORE, on_user_info_menu_button_clicked, ad);