From: polu.sandeep Date: Mon, 26 Oct 2015 12:15:55 +0000 (+0900) Subject: Apply latest GUI X-Git-Tag: release/160311~131 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ab79e2e01eda2f7cc91d94f441d123dd3ecc4df;p=apps%2Fnative%2Ftelegram-tizen.git Apply latest GUI Change-Id: I84f5d1687f8b5c62f576af1988eba5d0350ee662 --- diff --git a/TelegramTizen/src/telegramtizen.c b/TelegramTizen/src/telegramtizen.c index df5eeb7..57cd17f 100644 --- a/TelegramTizen/src/telegramtizen.c +++ b/TelegramTizen/src/telegramtizen.c @@ -334,6 +334,10 @@ void load_main_list_data(appdata_s *ad) free(main_item->profile_pic_path); main_item->profile_pic_path = NULL; } + if (main_item->buddy_display_name) { + free(main_item->buddy_display_name); + main_item->buddy_display_name = NULL; + } main_item->date_lbl = NULL; main_item->msg_status_lbl = NULL; main_item->profile_pic = NULL; @@ -421,6 +425,34 @@ void load_main_list_data(appdata_s *ad) main_list_item->last_msg_status = msg->msg_state; main_list_item->last_msg_service = msg->service; main_list_item->number_of_unread_msgs = get_unread_message_count(tablename); + + + if (peer_info->peer_type == TGL_PEER_USER) { + char *user_name = NULL; + char *first_name = NULL; + char *last_name = NULL; + char *phone_num = NULL; + get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num); + + if (!first_name && !last_name && phone_num) { + first_name = phone_num; + } + + if (!last_name) { + last_name = ""; + } + user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1); + strcpy(user_name, first_name); + strcat(user_name, " "); + strcat(user_name, last_name); + main_list_item->buddy_display_name = user_name; + } else if (peer_info->peer_type == TGL_PEER_CHAT) { + main_list_item->buddy_display_name = replace(peer_info->print_name, '_', " "); + } else { + main_list_item->buddy_display_name = strdup(""); + } + + if (peer_info->photo_path) { main_list_item->profile_pic_path = strdup(peer_info->photo_path); } else { @@ -468,6 +500,31 @@ void load_main_list_data(appdata_s *ad) main_list_item->last_msg_id = -1; main_list_item->last_msg_status = -1; main_list_item->number_of_unread_msgs = 0; + if (peer_info->peer_type == TGL_PEER_USER) { + char *user_name = NULL; + char *first_name = NULL; + char *last_name = NULL; + char *phone_num = NULL; + get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num); + + if (!first_name && !last_name && phone_num) { + first_name = phone_num; + } + + if (!last_name) { + last_name = ""; + } + user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1); + strcpy(user_name, first_name); + strcat(user_name, " "); + strcat(user_name, last_name); + main_list_item->buddy_display_name = user_name; + } else if (peer_info->peer_type == TGL_PEER_CHAT) { + main_list_item->buddy_display_name = replace(peer_info->print_name, '_', " "); + } else { + main_list_item->buddy_display_name = strdup(""); + } + if (peer_info->photo_path) { main_list_item->profile_pic_path = strdup(peer_info->photo_path); } else { @@ -1500,11 +1557,19 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg) } else if(media_type == tgl_message_media_photo) { sel_item->last_message = strdup("Image"); } else if(media_type == tgl_message_media_document) { + +#if 0 if (msg->message && strlen(msg->message) > 0) { sel_item->last_message = strdup(msg->message); } else { sel_item->last_message = strdup("Document"); } +#else + tgl_media_s *media_msg = NULL; + media_msg = get_media_details_from_db(atoll(msg->media_id)); + sel_item->last_message = strdup(media_msg->doc_type); + free_media_details(media_msg); +#endif } else if(media_type == tgl_message_media_geo) { sel_item->last_message = strdup("Geo location"); } else if(media_type == tgl_message_media_contact) { @@ -1549,14 +1614,18 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg) if(len_org_str > 40) { strncpy(res, org_msg, 39); if(msg->service == 1 || msg->service == 2) { + sel_item->last_msg_service = 1; sprintf(status_buf,"%s", res); } else { + sel_item->last_msg_service = 0; sprintf(status_buf,"%s", res); } } else { if(msg->service == 1 || msg->service == 2) { + sel_item->last_msg_service = 1; sprintf(status_buf, "%s", org_msg); } else { + sel_item->last_msg_service = 0; sprintf(status_buf, "%s", org_msg); } } @@ -2238,9 +2307,9 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg) char status_buf[512] = {'\0'}; if(len_org_str > 25) { strncpy(res, org_msg, 25); - snprintf(status_buf, 512, "%s", res); + snprintf(status_buf, 512, "%s", res); } else { - snprintf(status_buf, 512, "%s", org_msg); + snprintf(status_buf, 512, "%s", org_msg); } elm_object_text_set(sel_item->status_lbl, status_buf); } @@ -2448,6 +2517,32 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad, peer_with_pic_s *item) } else { main_list_item->profile_pic_path = NULL; } + + if (peer_info->peer_type == TGL_PEER_USER) { + char *user_name = NULL; + char *first_name = NULL; + char *last_name = NULL; + char *phone_num = NULL; + get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num); + + if (!first_name && !last_name && phone_num) { + first_name = phone_num; + } + + if (!last_name) { + last_name = ""; + } + user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1); + strcpy(user_name, first_name); + strcat(user_name, " "); + strcat(user_name, last_name); + main_list_item->buddy_display_name = user_name; + } else if (peer_info->peer_type == TGL_PEER_CHAT) { + main_list_item->buddy_display_name = replace(peer_info->print_name, '_', " "); + } else { + main_list_item->buddy_display_name = strdup(""); + } + main_list_item->user_name_lbl = NULL; main_list_item->status_lbl = NULL; main_list_item->date_lbl = NULL; @@ -2494,6 +2589,32 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad, peer_with_pic_s *item) } else { main_list_item->profile_pic_path = NULL; } + + if (peer_info->peer_type == TGL_PEER_USER) { + char *user_name = NULL; + char *first_name = NULL; + char *last_name = NULL; + char *phone_num = NULL; + get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num); + + if (!first_name && !last_name && phone_num) { + first_name = phone_num; + } + + if (!last_name) { + last_name = ""; + } + user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1); + strcpy(user_name, first_name); + strcat(user_name, " "); + strcat(user_name, last_name); + main_list_item->buddy_display_name = user_name; + } else if (peer_info->peer_type == TGL_PEER_CHAT) { + main_list_item->buddy_display_name = replace(peer_info->print_name, '_', " "); + } else { + main_list_item->buddy_display_name = strdup(""); + } + main_list_item->user_name_lbl = NULL; main_list_item->status_lbl = NULL; main_list_item->date_lbl = NULL; @@ -2546,6 +2667,11 @@ void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info) free(old_item->profile_pic_path); old_item->profile_pic_path = NULL; } + if (old_item->buddy_display_name) { + free(old_item->buddy_display_name); + old_item->buddy_display_name = NULL; + } + old_item->date_lbl = NULL; old_item->msg_status_lbl = NULL; old_item->main_item_layout = NULL; @@ -2802,8 +2928,32 @@ static void create_base_gui(appdata_s *ad) //eina_list_free(user_info); } -static bool -app_create(void *data) +void on_tg_service_result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) +{ + appdata_s *ad = user_data; + if (result == APP_CONTROL_RESULT_SUCCEEDED) { + if (ad) { + show_toast(ad, "Server launched successfully."); + } else { + show_toast(ad, "Server not launched."); + } + } +} + +static void launch_tg_server(void *data) +{ + appdata_s *ad = data; + app_control_h app_control; + int ret = app_control_create(&app_control); +/* ret = app_control_set_operation(app_control, "http://tizen.org/appcontrol/operation/launch_on_event"); + ret = app_control_set_mime(app_control, "application/telegram"); + ret = app_control_set_uri(app_control, "http://tizen.org/appcontrol/operation/telegram_start");*/ + ret = app_control_set_app_id(app_control, "org.tizen.tg-engine-service"); + ret = app_control_send_launch_request(app_control, &on_tg_service_result_cb, ad); + ret = app_control_destroy(app_control); +} + +static bool app_create(void *data) { /* Hook to take necessary actions before main event loop starts @@ -2840,6 +2990,7 @@ app_create(void *data) } init_service(ad); + launch_tg_server(data); return true; } @@ -2954,6 +3105,10 @@ app_terminate(void *data) free(main_item->profile_pic_path); main_item->profile_pic_path = NULL; } + if (main_item->buddy_display_name) { + free(main_item->buddy_display_name); + main_item->buddy_display_name = NULL; + } main_item->date_lbl = NULL; main_item->msg_status_lbl = NULL; main_item->main_item_layout = NULL; diff --git a/TelegramTizen/src/tg_messaging_view.c b/TelegramTizen/src/tg_messaging_view.c index 1ad3b1b..5dcb587 100644 --- a/TelegramTizen/src/tg_messaging_view.c +++ b/TelegramTizen/src/tg_messaging_view.c @@ -563,6 +563,43 @@ void on_media_chat_item_clicked(void* data, Evas_Object *entry, void* event_info } } +static void on_video_play_pressed(void *data, Evas_Object *obj, void *event_info) +{ + if (!data) + return; + elm_image_file_set(data, ui_utils_get_resource(TG_PLAY_PRESS_ICON), NULL); +} + +static void on_video_play_unpressed(void *data, Evas_Object *obj, void *event_info) +{ + if (!data) + return; + elm_image_file_set(data, ui_utils_get_resource(TG_PLAY_NORMAL_ICON), NULL); +} + +static Evas_Object* get_video_paly_icon(Evas_Object *parent) +{ + Evas_Object* play_pause_btn = elm_button_add(parent); + elm_object_style_set(play_pause_btn, "transparent"); + evas_object_size_hint_align_set(play_pause_btn, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(play_pause_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + Evas_Object* play_pause_icon = elm_image_add(parent); + evas_object_size_hint_align_set(play_pause_icon, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(play_pause_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_image_file_set(play_pause_icon, ui_utils_get_resource(TG_PLAY_NORMAL_ICON), NULL); + + elm_image_resizable_set(play_pause_icon, EINA_TRUE, EINA_TRUE); + evas_object_show(play_pause_icon); + + elm_object_content_set(play_pause_btn, play_pause_icon); + + evas_object_smart_callback_add(play_pause_btn, "pressed", on_video_play_pressed, play_pause_icon); + evas_object_smart_callback_add(play_pause_btn, "unpressed", on_video_play_unpressed, play_pause_icon); + return play_pause_btn; +} + static Evas_Object *get_media_layout_with_play(char *img_path, Evas_Object *parent, Eina_Bool show_play_icon) { char edj_path[PATH_MAX] = {0, }; @@ -577,8 +614,11 @@ static Evas_Object *get_media_layout_with_play(char *img_path, Evas_Object *pare elm_object_part_content_set(rec_video_layout, "swallow.video_thumb_item", vid_thumb_icon); if (show_play_icon) { - Evas_Object* play_img = get_image_from_path(ui_utils_get_resource(MEDIA_PLAY_ICON), parent); - elm_object_part_content_set(rec_video_layout, "swallow.play_btn", play_img); +/* Evas_Object* play_img = get_image_from_path(ui_utils_get_resource(MEDIA_PLAY_ICON), parent); + elm_object_part_content_set(rec_video_layout, "swallow.play_btn", play_img);*/ + + Evas_Object* play_pause_btn = get_video_paly_icon(parent); + elm_object_part_content_set(rec_video_layout, "swallow.play_btn", play_pause_btn); } return rec_video_layout; @@ -1179,7 +1219,8 @@ void on_media_download_completed(appdata_s* ad, int buddy_id, long long media_id } if ((strstr(media_type_str, "video") != NULL) || (strstr(media_type_str, "audio") != NULL)) { - Evas_Object* play_img = get_image_from_path(ui_utils_get_resource(MEDIA_PLAY_ICON), img_item); + Evas_Object* play_img = get_video_paly_icon(img_item); + //Evas_Object* play_img = get_image_from_path(ui_utils_get_resource(MEDIA_PLAY_ICON), img_item); elm_object_part_content_set(img_item, "swallow.play_btn", play_img); } else if (strstr(media_type_str, "image") != NULL) { elm_image_file_set(img_item, file_path, NULL); diff --git a/TelegramTizen/src/tg_user_main_view.c b/TelegramTizen/src/tg_user_main_view.c index ba5ef4a..106453c 100644 --- a/TelegramTizen/src/tg_user_main_view.c +++ b/TelegramTizen/src/tg_user_main_view.c @@ -17,6 +17,7 @@ #include "tg_main_item_deletion_view.h" #include "tg_search_message_view.h" + static Evas_Object *create_image_object_from_file(const char *icon_name, Evas_Object *parent) { Evas_Object *icon = elm_image_add(parent); @@ -310,9 +311,9 @@ char* on_longpress_group_menu_text_get_cb(void *data, Evas_Object *obj, const ch { int id = (int) data; if (id == 0) { - return strdup("Clear history"); + return strdup(i18n_get_text("IDS_TGRAM_OPT_CLEAR_HISTORY_ABB3")); } else { - return strdup("Delete and exit"); + return strdup(i18n_get_text("IDS_TGRAM_OPT_LEAVE_CHAT")); } } @@ -320,9 +321,9 @@ char* on_longpress_single_menu_text_get_cb(void *data, Evas_Object *obj, const c { int id = (int) data; if (id == 0) { - return strdup("Clear history"); + return strdup(i18n_get_text("IDS_TGRAM_OPT_CLEAR_HISTORY_ABB3")); } else { - return strdup("Delete"); + return strdup(i18n_get_text("IDS_TGRAM_OPT_DELETE")); } } @@ -732,10 +733,12 @@ Evas_Object* on_chat_item_load_requested(void *data, Evas_Object *obj, const cha /*************************** user name ***************************************/ +#if 0 char* user_name = replace(item->peer_print_name, '_', ""); +#endif char buf[512] = {'\0'}; - snprintf(buf, 512, "%s", user_name); - free(user_name); + snprintf(buf, 512, "%s", item->buddy_display_name); + //free(user_name); Evas_Object* name_lbl = elm_label_add(ad->nf); elm_object_text_set(name_lbl, buf); diff --git a/TelegramTizen/tg_utils/tg_common.h b/TelegramTizen/tg_utils/tg_common.h index f40b5df..22ae37a 100644 --- a/TelegramTizen/tg_utils/tg_common.h +++ b/TelegramTizen/tg_utils/tg_common.h @@ -75,7 +75,7 @@ #define MEDIA_DOWNLOAD_ICON FM_ICON_PATH"/ic_attach_download.png" #define MEDIA_MANUAL_DOWNLOAD_ICON FM_ICON_PATH"/ic_attach_manual_download.png" -#define MEDIA_PLAY_ICON FM_ICON_PATH"/playvideo.png" +//#define MEDIA_PLAY_ICON FM_ICON_PATH"/playvideo.png" #define DEFAULT_TELEGRAM_ICON FM_ICON_PATH"/tg_icon.png" #define TELEGRAM_BUTTON_ADD_ICON FM_ICON_PATH"/telegram_button_add.png" @@ -510,6 +510,7 @@ typedef struct tg_main_list_item { Evas_Object* msg_status_lbl; Evas_Object* main_item_layout; Eina_Bool is_selected; + char *buddy_display_name; } tg_main_list_item_s; typedef struct appdata { diff --git a/tg-engine-service/mtprotocol/queries.c b/tg-engine-service/mtprotocol/queries.c index 98adabd..0bfe997 100644 --- a/tg-engine-service/mtprotocol/queries.c +++ b/tg-engine-service/mtprotocol/queries.c @@ -369,10 +369,15 @@ int tglq_query_result(struct tgl_state *TLS, long long id) vlogprintf(E_DEBUG, "in_ptr = %p, end_ptr = %p\n", in_ptr, in_end); if (skip_type_any(q->type) < 0) { vlogprintf(E_ERROR, "Skipped %ld int out of %ld(type %s)\n",(long)(in_ptr - save),(long)(in_end - save), q->type->type->id); - assert(0); + //sandeep + //assert(0); + return 0; + } + // sandeep + //assert(in_ptr == in_end); + if (in_ptr != in_end) { + return 0; } - - assert(in_ptr == in_end); in_ptr = save; } q->methods->on_answer(TLS, q);