#include "tg_common.h"
-void send_request_for_restart_server(service_client* service_client);
-void send_request_for_logout(service_client* service_client);
-void send_request_for_registration(service_client* service_client, const char* phone_number, Eina_Bool through_sms);
-void send_request_for_profile_registration(service_client* service_client, const char* first_name, const char* last_name);
-void send_request_for_validation(service_client* service_client, const char* sms_code);
+void send_request_for_restart_server(appdata_s *ad, service_client* service_client);
+void send_request_for_logout(appdata_s *ad, service_client* service_client);
+void send_request_for_registration(appdata_s *ad, service_client* service_client, const char* phone_number, Eina_Bool through_sms);
+void send_request_for_profile_registration(appdata_s *ad, service_client* service_client, const char* first_name, const char* last_name);
+void send_request_for_validation(appdata_s *ad, service_client* service_client, const char* sms_code);
// type_of_chat 0-buddy, 1-group_chat 2-encrpted_chat
void send_request_for_message_transport(appdata_s *ad, service_client* service_client, const int buddy_id, const int message_id, const int msg_type, const char* data, const int type_of_chat);
-void send_request_for_marked_as_read(service_client* service_client, const int buddy_id, const int type_of_chat);
-void send_delete_selected_group_chats_request(service_client* service_client, Eina_List *sel_grp_chats);
-void send_delete_group_chat_request(service_client* service_client, const int chat_id);
-void send_add_buddy_request(service_client* service_client, const int buddy_id, const char *first_name, const char *last_name, const char *phone_number);
-void send_delete_buddy_request(service_client* service_client, const int buddy_id);
-void send_block_buddy_request(service_client* service_client, const int buddy_id);
-void send_unblock_buddy_request(service_client* service_client, const int buddy_id);
-Eina_Bool send_request_for_media_downloading(service_client* service_client, const int buddy_id, const long long media_id);
+void send_request_for_marked_as_read(appdata_s *ad, service_client* service_client, const int buddy_id, const int type_of_chat);
+void send_delete_selected_group_chats_request(appdata_s *ad, service_client* service_client, Eina_List *sel_grp_chats);
+void send_delete_group_chat_request(appdata_s *ad, service_client* service_client, const int chat_id);
+void send_add_buddy_request(appdata_s *ad, service_client* service_client, const int buddy_id, const char *first_name, const char *last_name, const char *phone_number);
+void send_start_secret_chat_request(appdata_s *ad, service_client* service_client, const int buddy_id);
+void send_delete_buddy_request(appdata_s *ad, service_client* service_client, const int buddy_id);
+void send_block_buddy_request(appdata_s *ad, service_client* service_client, const int buddy_id);
+void send_unblock_buddy_request(appdata_s *ad, service_client* service_client, const int buddy_id);
+Eina_Bool send_request_for_media_downloading(appdata_s *ad, service_client* service_client, const int buddy_id, const long long media_id);
void send_request_for_media_transport(appdata_s *ad, service_client* service_client, const int buddy_id, const int message_id, const int media_id, const int msg_type, const char* file_path, const int type_of_chat);
-void send_group_creation_request_to_server(service_client* service_client, Eina_List* buddy_list, const char* group_name, const char* group_image);
+void send_group_creation_request_to_server(appdata_s *ad, service_client* service_client, Eina_List* buddy_list, const char* group_name, const char* group_image);
-void send_add_buddy_to_group_chat_request(service_client* service_client, int user_id, int chat_id);
-void send_set_group_chat_new_title_request(service_client* service_client, int user_id, const char* new_title);
-void send_set_group_chat_profile_pic_request(service_client* service_client, int user_id, const char* file_path);
-void send_set_profile_pic_request(service_client* service_client, int user_id, const char* file_path);
-void send_set_username_request(service_client* service_client, int user_id, const char* username);
-void send_remove_buddy_from_group_chat_request(service_client* service_client, int user_id, int chat_id);
-void send_request_for_delete_notifications(service_client* service_client);
-void send_request_for_server_connection_status(service_client* service_client);
-void send_update_chat_request(service_client* service_client, const int chat_id);
-void send_update_display_name_request(service_client* service_client, int user_id, const char* first_name, const char* last_name);
+void send_add_buddy_to_group_chat_request(appdata_s *ad, service_client* service_client, int user_id, int chat_id);
+void send_set_group_chat_new_title_request(appdata_s *ad, service_client* service_client, int user_id, const char* new_title);
+void send_set_group_chat_profile_pic_request(appdata_s *ad, service_client* service_client, int user_id, const char* file_path);
+void send_set_profile_pic_request(appdata_s *ad, service_client* service_client, int user_id, const char* file_path);
+void send_set_username_request(appdata_s *ad, service_client* service_client, int user_id, const char* username);
+void send_remove_buddy_from_group_chat_request(appdata_s *ad, service_client* service_client, int user_id, int chat_id);
+void send_request_for_delete_notifications(appdata_s *ad, service_client* service_client);
+void send_request_for_server_connection_status(appdata_s *ad, service_client* service_client);
+void send_update_chat_request(appdata_s *ad, service_client* service_client, const int chat_id);
+void send_update_display_name_request(appdata_s *ad, service_client* service_client, int user_id, const char* first_name, const char* last_name);
#endif /* SERVER_REQUESTS_H_ */
}
}
+ group {
+ name: "add_contact_custom_item";
+ parts {
+ part {
+ name: "swallow.item";
+ type: SWALLOW;
+ description {
+ state: default 0.0;
+ min: 720 440;
+ rel1.relative: 0.0 0.0;
+ rel2.relative: 1.0 1.0;
+ color: 0 0 0 0;
+ }
+ }
+ }
+ }
+
group {
name: "main_list_custom_sent_item";
parts {
{
name: "group_chat_entry";
parts{
- part{
- name: "group_chat_entry_box,bg";
- type:RECT;
- description{
- state: "default" 0.0;
- rel1 { relative: 0.0 0.0; }
- rel2 { relative: 1.0 0.2; }
- color: 255 255 255 255;
- }
- }
+ part {
+ name: "view_bg";
+ type: RECT;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 0.2; }
+ color: 255 255 255 255;
+ }
+ }
part{
name: "swallow.group_chat_entry_box";
type:SWALLOW;
{
name: "group_chat_photo_name_entry";
parts{
+ part{
+ name: "swallow.cam_box, bg";
+ type: RECT;
+ description{
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 0.9; }
+ color: 255 255 255 255;
+ }
+ }
+
part{
name: "swallow.cam_box";
- type:SWALLOW;
+ type: SWALLOW;
description{
state: "default" 0.0;
- rel1 { relative: 0.1 0.2; }
- rel2 { relative: 0.25 0.8; }
- }
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 0.9; }
+ color: 0 0 0 0;
+ }
}
-
- part {
- name: "entry_box,bg";
- type: RECT;
- description {
- state: "default" 0.0;
- rel1 { relative: 0.3 0.3; }
- rel2 { relative: 0.95 0.65; }
- color: 222 222 222 222;
- }
- }
+
+ part{
+ name: "swallow.entry_box,bg";
+ type: IMAGE;
+ description{
+ state: "default" 0.0;
+ rel1 { relative: 0.28 0.65; }
+ rel2 { relative: 0.9 0.68; }
+ max: 800 2;
+ image {
+ normal: "telegram_date_divider.#.png";
+ }
+ color: 0 0 0 51;
+ }
+ }
part{
name: "swallow.entry_box";
description{
state: "default" 0.0;
rel1 { relative: 0.3 0.3;}
- rel2 { relative: 0.95 0.65;}
+ rel2 { relative: 0.87 0.65;}
color: 50 100 255 255;
}
}
}
}
+
+
+
+ group {
+ name: "group_circle_layout";
+ parts {
+ part {
+ name: masking_bg;
+ type: RECT;
+ precise_is_inside: 1;
+ description {
+ state: default 0.0;
+ rel1.relative: 0.0 0.0;
+ rel2.relative: 1.0 1.0;
+ color: 250 250 250 0;
+ }
+ }
+ part {
+ name: masking;
+ type: IMAGE;
+ precise_is_inside: 1;
+ description {
+ state: default 0.0;
+ rel1.relative: 0.0 0.0;
+ rel2.relative: 1.0 1.0;
+ image.normal: camera_btn_gallery_mask.png;
+ }
+ }
+ part {
+ name: content_bg;
+ type: RECT;
+ clip_to: masking;
+ description {
+ state: default 0.0;
+ rel1.relative: 0.0 -0.4;
+ rel2.relative: 1.0 1.4;
+ color: 250 250 250 255;
+ }
+ }
+ part {
+ name: content;
+ type: SWALLOW;
+ clip_to: masking;
+ description {
+ state: default 0.0;
+ rel1.relative: 0.0 -0.4;
+ rel2.relative: 1.0 1.4;
+ }
+ }
+ }
+ }
+
+
images {
image: "telegram_attach_image_round_bg.#.png" COMP;
image: "telegram_attach_image_round_line.#.png" COMP;
user_data_with_pic_s* item = eina_list_nth(list, id - 1);
user_data_s* user = item->use_data;
- char* user_name = replace(user->print_name, '_', " ");
- char buf[512] = {'\0'};
- snprintf(buf, 512, "<align=left><font_size=35><color=#000000>%s</color></font_size></align>", user_name);
- free(user_name);
- return strdup(buf);
-
+ if (user && user->print_name) {
+ char* user_name = replace(user->print_name, '_', " ");
+ char buf[512] = {'\0'};
+ snprintf(buf, 512, "<align=left><font_size=35><color=#000000>%s</color></font_size></align>", user_name);
+ free(user_name);
+ return strdup(buf);
+ }
}
}
if (selected_item_count > 1) {
appdata_s* ad = data;
- elm_naviframe_item_pop(ad->nf);
+ // elm_naviframe_item_pop(ad->nf);
// Load chat name entry view
launch_group_chat_name_entry_view(ad);
} else {
{
int id = (int) data;
if (id == 0) {
- return strdup("Camera");
+ return strdup(_("IDS_TGRAM_OPT_FROM_GALLERY_ABB2"));
} else {
- return strdup("Gallery");
+ return strdup(_("IDS_TGRAM_OPT_TAKE_PICTURE_ABB"));
}
}
file_path = strdup(path_arryay[i]);
evas_object_data_set(user_data, "image_path", (void*)file_path);
elm_image_file_set(user_data, file_path, NULL);
+ evas_object_color_set(user_data, 255, 255, 255, 255);
break;
}
}
return;
}
- if (id == 0) {
+ if (id == 1) {
app_control_set_operation(app_control, APP_CONTROL_OPERATION_CREATE_CONTENT);
app_control_set_mime(app_control, "image/jpg");
app_control_send_launch_request(app_control, &on_camera_result_cb, cam_icon);
popup = elm_popup_add(win);
elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
- elm_object_part_text_set(popup, "title,text", "Load image from");
+ elm_object_part_text_set(popup, "title,text", i18n_get_text("IDS_TGRAM_HEADER_SELECT_IMAGE_ABB2"));
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_data_set(popup, "cam_icon", cam_icon);
void on_group_buddy_selected(void *data, Evas_Object *obj, void *event_info)
{
- // nothing to do
+ Elm_Object_Item *it = event_info;
+ elm_genlist_item_selected_set(it, EINA_FALSE);
}
char* on_group_buddy_name_get_cb(void *data, Evas_Object *obj, const char *part)
char edj_path[PATH_MAX] = {0, };
app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
Evas_Object* user_pic_layout = elm_layout_add(obj);
- elm_layout_file_set(user_pic_layout, edj_path, "circle_layout");
+ elm_layout_file_set(user_pic_layout, edj_path, "search_circle_layout");
evas_object_size_hint_weight_set(user_pic_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(user_pic_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(user_pic_layout);
elm_object_part_content_set(user_pic_layout, "content", profile_pic);
eo = elm_layout_add(obj);
- elm_layout_theme_set(eo, "layout", "list/C/type.3", "default");
+ elm_layout_theme_set(eo, "layout", "list/B/type.2", "default");
elm_layout_content_set(eo, "elm.swallow.content", user_pic_layout);
}
return eo;
}
Eina_List* selected_buddies = evas_object_data_get(name_entry, "selected_buddies");
- Evas_Object* cam_icon = evas_object_data_get(name_entry, "cam_icon");
+ //Evas_Object* cam_icon = evas_object_data_get(name_entry, "cam_icon");
+ Evas_Object* cam_icon = evas_object_data_get(ad->nf, "group_chat_profile_pic");
char* img_file_path = evas_object_data_get(cam_icon, "image_path");
- send_group_creation_request_to_server(ad->service_client, selected_buddies, group_name, img_file_path);
+ show_loading_popup(ad);
+
+ send_group_creation_request_to_server(ad, ad->service_client, selected_buddies, group_name, img_file_path);
eina_list_free(selected_buddies);
}
elm_panel_hidden_set(ad->panel, EINA_FALSE);
}
+char* group_chat_entry_requested_cb(void *data, Evas_Object *obj, const char *part)
+{
+ //int id = (int) data;
+ return NULL;
+}
+
+Evas_Object* group_chat_pic_requested_cb(void *data, Evas_Object *obj, const char *part)
+{
+ Evas_Object *eo = NULL;
+ if (!strcmp(part, "elm.icon.left") || !strcmp(part, "elm.icon.1") || !strcmp(part, "elm.swallow.icon") ) {
+ appdata_s* ad = evas_object_data_get(obj, "app_data");
+ int id = (int) data;
+ if (id == 0) {
+ Evas_Object *profile_pic = NULL;
+ profile_pic = create_image_object_from_file(ui_utils_get_resource(DEFAULT_LIST_THUMB_MULTI_PIC), ad->nf);
+ evas_object_color_set(profile_pic, 45, 165, 224, 255);
+ evas_object_data_set(profile_pic, "app_data", ad);
+ evas_object_smart_callback_add(profile_pic, "clicked", on_image_load_options_cb, (void*)profile_pic);
+ char edj_path[PATH_MAX] = {0, };
+ app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
+ Evas_Object* user_pic_layout = elm_layout_add(ad->nf);
+ elm_layout_file_set(user_pic_layout, edj_path, "group_circle_layout");
+ evas_object_size_hint_weight_set(user_pic_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(user_pic_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(user_pic_layout);
+ elm_object_part_content_set(user_pic_layout, "content", profile_pic);
+ evas_object_data_set(ad->nf, "group_chat_profile_pic", profile_pic);
+
+ eo = elm_layout_add(obj);
+ elm_layout_theme_set(eo, "layout", "list/B/type.1", "default");
+ elm_layout_content_set(eo, "elm.swallow.content", user_pic_layout);
+ }
+ }
+ return eo;
+}
+
void launch_group_chat_name_entry_view(void *data)
{
appdata_s* ad = data;
evas_object_show(entry_layout);
elm_object_part_content_set(main_layout, "swallow.group_chat_entry_box", entry_layout);
+#if 0
Evas_Object* cam_icon = elm_image_add(main_layout);
elm_image_file_set(cam_icon, ui_utils_get_resource(CAMERA_ICON), NULL);
evas_object_show(cam_icon);
+#endif
+#if 0
+
+ Evas_Object *cam_icon = create_image_object_from_file(ui_utils_get_resource(DEFAULT_LIST_THUMB_MULTI_PIC), main_layout);
+ evas_object_color_set(cam_icon, 45, 165, 224, 255);
+
+
+ Evas_Object *user_pic_layout = elm_layout_add(ad->nf);
+ elm_layout_file_set(user_pic_layout, edj_path, "search_circle_layout");
+ evas_object_size_hint_weight_set(user_pic_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(user_pic_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(user_pic_layout);
+ elm_object_part_content_set(user_pic_layout, "content", cam_icon);
Evas_Object* eo = elm_layout_add(main_layout);
- elm_layout_theme_set(eo, "layout", "list/C/type.3", "default");
- elm_layout_content_set(eo, "elm.swallow.content", cam_icon);
+ elm_layout_theme_set(eo, "layout", "list/B/type.1", "default");
+ elm_layout_content_set(eo, "elm.swallow.content", user_pic_layout);
evas_object_smart_callback_add(cam_icon, "clicked", on_image_load_options_cb, (void*)cam_icon);
elm_object_part_content_set(entry_layout, "swallow.cam_box", eo);
+#endif
+
+ /********************* list *************************/
+
+
+ Evas_Object *list = elm_genlist_add(ad->nf);
+ elm_list_mode_set(list, ELM_LIST_COMPRESS);
+ elm_genlist_mode_set(list, ELM_LIST_COMPRESS);
+ evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(list);
+
+ elm_object_part_content_set(entry_layout, "swallow.cam_box", list);
+
+ evas_object_data_set(ad->nf, "group_chat_entry_list", list);
+ evas_object_data_set(list, "app_data", ad);
+ static Elm_Genlist_Item_Class itc1;
+ itc1.item_style = "type1";
+ itc1.func.text_get = group_chat_entry_requested_cb;
+ itc1.func.content_get = group_chat_pic_requested_cb;
+ itc1.func.state_get = NULL;
+ itc1.func.del = NULL;
+
+ elm_genlist_item_append(list, &itc1, (void*) 0, NULL, ELM_GENLIST_ITEM_NONE, on_group_buddy_selected, (void*)ad);
+
+
+ /******************** list *************************/
+
Evas_Object* name_entry = elm_entry_add(main_layout);
elm_entry_single_line_set(name_entry, EINA_TRUE);
+ limit_filter_data.max_char_count = 20;
+ elm_entry_markup_filter_append(name_entry, elm_entry_filter_limit_size, &limit_filter_data);
evas_object_show(name_entry);
elm_object_part_content_set(entry_layout, "swallow.entry_box", name_entry);
-
-
Eina_List* selected_buddies = NULL;
for (int i = 0 ; i < eina_list_count(ad->buddy_list) ; i++) {
evas_object_size_hint_weight_set(contact_lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(contact_lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ char res_str[256] = {'\0'};
+ sprintf(res_str, i18n_get_text("IDS_TGRAM_BODY_PD_PARTICIPANTS"), eina_list_count(selected_buddies));
+
char count_str[256] = {'\0'};
- sprintf(count_str, "<font=Tizen:style=Bold color=#ffffff align=left><font_size=45> %d contacts selected</font_size></font>", eina_list_count(selected_buddies));
+ sprintf(count_str, "<font=Tizen:style=Bold color=#ffffff align=left><font_size=45> %s</font_size></font>", res_str);
elm_object_text_set(contact_lbl, count_str);
elm_object_part_content_set(main_layout, "swallow.contacts_header", contact_lbl);
evas_object_data_set(buddy_gen_list, "app_data", ad);
evas_object_data_set(buddy_gen_list, "selected_buddies", (void*)selected_buddies);
- evas_object_data_set(cam_icon, "app_data", ad);
- evas_object_data_set(cam_icon, "selected_buddies", (void*)selected_buddies);
+ //evas_object_data_set(cam_icon, "app_data", ad);
+ //evas_object_data_set(cam_icon, "selected_buddies", (void*)selected_buddies);
evas_object_data_set(name_entry, "app_data", ad);
evas_object_data_set(name_entry, "selected_buddies", (void*)selected_buddies);
- evas_object_data_set(name_entry, "cam_icon", cam_icon);
+ //evas_object_data_set(name_entry, "cam_icon", cam_icon);
itc.item_style = "default_style";
itc.func.text_get = on_group_buddy_name_get_cb;
Elm_Object_Item* chat_nav_item = elm_naviframe_item_push(ad->nf, "New Group", NULL, NULL, scroller, NULL);
- Evas_Object* done_btn = elm_button_add(ad->layout);
- elm_object_style_set(done_btn, "naviframe/title_icon");
+ Evas_Object *done_btn = elm_button_add(ad->nf);
+ elm_object_style_set(done_btn, "naviframe/title_right");
+ elm_object_text_set(done_btn, i18n_get_text("IDS_TGRAM_ACBUTTON_DONE_ABB"));
evas_object_smart_callback_add(done_btn, "clicked", on_group_chat_done_buton_clicked, name_entry);
- elm_object_text_set(done_btn, "Done");
evas_object_show(done_btn);
- Evas_Object* cancel_btn = elm_button_add(ad->layout);
- elm_object_style_set(cancel_btn, "naviframe/title_icon");
+ Evas_Object *cancel_btn = elm_button_add(ad->nf);
+ elm_object_style_set(cancel_btn, "naviframe/title_left");
+ elm_object_text_set(cancel_btn, i18n_get_text("IDS_TGRAM_ACBUTTON_CANCEL_ABB"));
evas_object_smart_callback_add(cancel_btn, "clicked", on_group_chat_cancel_buton_clicked, ad);
- elm_object_text_set(cancel_btn, "Cancel");
evas_object_show(cancel_btn);
elm_object_item_part_content_set(chat_nav_item, "title_right_btn", done_btn);
#include "server_requests.h"
#include "tg_db_wrapper.h"
+static void failed_to_communicate_server(appdata_s *ad)
+{
+ if (!ad)
+ return;
+ hide_loading_popup(ad);
+ show_toast(ad, "Check your network settings.");
+}
-void send_request_for_restart_server(service_client* service_client)
+void send_request_for_restart_server(appdata_s *ad, service_client* service_client)
{
bundle *msg;
int result;
if (!service_client) {
// error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
LOGE("Failed to create a bundle");
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "restart_server") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if(result != SVC_RES_OK) {
// error
LOGE("Failed to send a service message");
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_request_for_logout(service_client* service_client)
+void send_request_for_logout(appdata_s *ad, service_client* service_client)
{
bundle *msg;
int result;
if (!service_client) {
// error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
LOGE("Failed to create a bundle");
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "logout_telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if(result != SVC_RES_OK) {
// error
LOGE("Failed to send a service message");
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_request_for_registration(service_client* service_client, const char* phone_number, Eina_Bool through_sms)
+void send_request_for_registration(appdata_s *ad, service_client* service_client, const char* phone_number, Eina_Bool through_sms)
{
bundle *msg;
int result;
if (!service_client || !phone_number) {
// error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
LOGE("Failed to create a bundle");
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "registration") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "phone_number", phone_number) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "through_sms", (through_sms) ? "true" : "false") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if(result != SVC_RES_OK) {
// error
LOGE("Failed to send a service message");
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_request_for_profile_registration(service_client* service_client, const char* first_name, const char* last_name)
+void send_request_for_profile_registration(appdata_s *ad, service_client* service_client, const char* first_name, const char* last_name)
{
bundle *msg;
int result;
if (!service_client || !first_name || !last_name) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "profile_registration") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "first_name", first_name) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "last_name", last_name) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
- if(result != SVC_RES_OK) {
- // error
+ if (result != SVC_RES_OK) {
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_request_for_validation(service_client* service_client, const char* sms_code)
+void send_request_for_validation(appdata_s *ad, service_client* service_client, const char* sms_code)
{
bundle *msg;
int result;
if (!service_client || !sms_code) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "code_validation") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "sms_code", sms_code) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if (result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_add_buddy_request(service_client* service_client, const int buddy_id, const char *first_name, const char *last_name, const char *phone_number)
+void send_add_buddy_request(appdata_s *ad, service_client* service_client, const int buddy_id, const char *first_name, const char *last_name, const char *phone_number)
{
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
bundle *msg;
int result;
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "add_buddy") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
snprintf(tmp, sizeof(tmp) - 1, "%d", buddy_id);
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "first_name", first_name) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "last_name", last_name) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "phone_number", phone_number) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_update_chat_request(service_client* service_client, const int chat_id)
+void send_update_chat_request(appdata_s *ad, service_client* service_client, const int chat_id)
{
if (!service_client) {
// error
int result;
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "update_chat_info") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
snprintf(tmp, sizeof(tmp) - 1, "%d", chat_id);
if (bundle_add_str(msg, "chat_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_delete_buddy_request(service_client* service_client, const int buddy_id)
+void send_start_secret_chat_request(appdata_s *ad, service_client* service_client, const int buddy_id)
{
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
bundle *msg;
int result;
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
+ return;
+ }
+
+ if (bundle_add_str(msg, "command", "start_secret_chat") != 0) {
+ ERR("Failed to add data by key to bundle");
+ bundle_free(msg);
+ failed_to_communicate_server(ad);
+ return;
+ }
+ snprintf(tmp, sizeof(tmp) - 1, "%d", buddy_id);
+
+ if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
+ ERR("Failed to add data by key to bundle");
+ bundle_free(msg);
+ failed_to_communicate_server(ad);
+ return;
+ }
+
+ result = service_client_send_message(service_client, msg);
+ if(result != SVC_RES_OK) {
+ failed_to_communicate_server(ad);
+ }
+ bundle_free(msg);
+}
+
+
+void send_delete_buddy_request(appdata_s *ad, service_client* service_client, const int buddy_id)
+{
+ if (!service_client) {
+ failed_to_communicate_server(ad);
+ return;
+ }
+ bundle *msg;
+ char tmp[50];
+ int result;
+ msg = bundle_create();
+ if (!msg) {
+ failed_to_communicate_server(ad);
+ return;
+ }
+
+ if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
+ ERR("Failed to add data by key to bundle");
+ bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "delete_buddy") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
snprintf(tmp, sizeof(tmp) - 1, "%d", buddy_id);
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_block_buddy_request(service_client* service_client, const int buddy_id)
+void send_block_buddy_request(appdata_s *ad, service_client* service_client, const int buddy_id)
{
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
bundle *msg;
int result;
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "block_buddy") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
snprintf(tmp, sizeof(tmp) - 1, "%d", buddy_id);
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_unblock_buddy_request(service_client* service_client, const int buddy_id)
+void send_unblock_buddy_request(appdata_s *ad, service_client* service_client, const int buddy_id)
{
if (!service_client) {
// error
int result;
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "unblock_buddy") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
snprintf(tmp, sizeof(tmp) - 1, "%d", buddy_id);
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_delete_selected_group_chats_request(service_client* service_client, Eina_List *sel_grp_chats)
+void send_delete_selected_group_chats_request(appdata_s *ad, service_client* service_client, Eina_List *sel_grp_chats)
{
if (!service_client || !sel_grp_chats) {
- // error
+ failed_to_communicate_server(ad);
return;
}
bundle *msg;
int result;
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "delete_selected_group_chats_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "list_size", cnt_str) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, chat_id_key, tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-
-void send_delete_group_chat_request(service_client* service_client, const int chat_id)
+void send_delete_group_chat_request(appdata_s *ad, service_client* service_client, const int chat_id)
{
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
bundle *msg;
int result;
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "delete_group_chat_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
snprintf(tmp, sizeof(tmp) - 1, "%d", chat_id);
if (bundle_add_str(msg, "chat_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_request_for_marked_as_read(service_client* service_client, const int buddy_id, const int type_of_chat)
+void send_request_for_marked_as_read(appdata_s *ad, service_client* service_client, const int buddy_id, const int type_of_chat)
{
bundle *msg;
char tmp[50];
int result;
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "marked_as_read") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "type_of_chat", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
char *msg_type_str = NULL;
char *type_of_chat_str = NULL;
if (!service_client || !data) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "message_transport") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "message_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "message_type", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "message_data", data) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "type_of_chat", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (result != SVC_RES_OK || !ad->is_server_ready) {
// error
insert_unsent_message_to_db("Tizen Telegram", "message_transport", buddy_id_str, msg_id_str, msg_type_str, data, type_of_chat_str);
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
char *msg_type_str = NULL;
char *type_of_chat_str = NULL;
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "media_transport") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "message_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "media_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "message_type", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "file_path", file_path) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
} else {
if (bundle_add_str(msg, "file_path", "") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
}
if (bundle_add_str(msg, "type_of_chat", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
result = service_client_send_message(service_client, msg);
if (result != SVC_RES_OK || !ad->is_server_ready) {
insert_unsent_media_message_to_db("Tizen Telegram", "message_transport", buddy_id_str, msg_id_str, media_id_str, msg_type_str, file_path, type_of_chat_str);
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-Eina_Bool send_request_for_media_downloading(service_client* service_client, const int buddy_id, const long long media_id)
+Eina_Bool send_request_for_media_downloading(appdata_s *ad, service_client* service_client, const int buddy_id, const long long media_id)
{
bundle *msg;
char tmp[50];
if (!service_client) {
// error
+ failed_to_communicate_server(ad);
return EINA_FALSE;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return EINA_FALSE;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return EINA_FALSE;
}
if (bundle_add_str(msg, "command", "media_download_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return EINA_FALSE;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
+ failed_to_communicate_server(ad);
bundle_free(msg);
}
-
snprintf(tmp, sizeof(tmp) - 1, "%lld", media_id);
if (bundle_add_str(msg, "media_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
+ failed_to_communicate_server(ad);
return EINA_FALSE;
}
bundle_free(msg);
return EINA_TRUE;
}
-void send_group_creation_request_to_server(service_client* service_client, Eina_List* buddy_list, const char* group_name, const char* group_image)
+void send_group_creation_request_to_server(appdata_s *ad, service_client* service_client, Eina_List* buddy_list, const char* group_name, const char* group_image)
{
bundle *msg;
int count;
int result;
if (!service_client || !buddy_list || !group_name) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "group_creation_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "count", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, buddy_id_key, tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "group_name", group_name) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "group_image", group_image) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
} else {
if (bundle_add_str(msg, "group_image", "") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
-
}
-void send_set_group_chat_new_title_request(service_client* service_client, int user_id, const char* new_title)
+void send_set_group_chat_new_title_request(appdata_s *ad, service_client* service_client, int user_id, const char* new_title)
{
bundle *msg;
char tmp[50];
int result;
if (!service_client || !new_title) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "set_group_chat_new_title_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
if (bundle_add_str(msg, "new_title", new_title) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_remove_buddy_from_group_chat_request(service_client* service_client, int user_id, int chat_id)
+void send_remove_buddy_from_group_chat_request(appdata_s *ad, service_client* service_client, int user_id, int chat_id)
{
bundle *msg;
char tmp[50];
int result;
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "remove_buddy_from_chat_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
snprintf(ctmp, sizeof(ctmp) - 1, "%d", chat_id);
if (bundle_add_str(msg, "chat_id", ctmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
-
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_add_buddy_to_group_chat_request(service_client* service_client, int user_id, int chat_id)
+void send_add_buddy_to_group_chat_request(appdata_s *ad, service_client* service_client, int user_id, int chat_id)
{
bundle *msg;
char tmp[50];
int result;
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "add_new_buddy_to_chat_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
snprintf(ctmp, sizeof(ctmp) - 1, "%d", chat_id);
if (bundle_add_str(msg, "chat_id", ctmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
-
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_set_group_chat_profile_pic_request(service_client* service_client, int user_id, const char* file_path)
+void send_set_group_chat_profile_pic_request(appdata_s *ad, service_client* service_client, int user_id, const char* file_path)
{
bundle *msg;
char tmp[50];
int result;
if (!service_client || !file_path) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "set_group_chat_profile_pic_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
if (bundle_add_str(msg, "file_path", file_path) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_set_profile_pic_request(service_client* service_client, int user_id, const char* file_path)
+void send_set_profile_pic_request(appdata_s *ad, service_client* service_client, int user_id, const char* file_path)
{
bundle *msg;
char tmp[50];
int result;
if (!service_client || !file_path) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "set_profile_pic_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
if (bundle_add_str(msg, "file_path", file_path) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_update_display_name_request(service_client* service_client, int user_id, const char* first_name, const char* last_name)
+void send_update_display_name_request(appdata_s *ad, service_client* service_client, int user_id, const char* first_name, const char* last_name)
{
bundle *msg;
char tmp[50];
int result;
if (!service_client || !first_name || !last_name) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "update_display_name_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
if (bundle_add_str(msg, "first_name", first_name) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
if (bundle_add_str(msg, "last_name", last_name) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_set_username_request(service_client* service_client, int user_id, const char* username)
+void send_set_username_request(appdata_s *ad, service_client* service_client, int user_id, const char* username)
{
bundle *msg;
char tmp[50];
int result;
if (!service_client || !username) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "set_username_request") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "buddy_id", tmp) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
if (bundle_add_str(msg, "username", username) != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
}
result = service_client_send_message(service_client, msg);
if(result != SVC_RES_OK) {
- // error
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_request_for_delete_notifications(service_client* service_client)
+void send_request_for_delete_notifications(appdata_s *ad, service_client* service_client)
{
bundle *msg;
int result;
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
LOGE("Failed to create a bundle");
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "delete_all_notifications") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if(result != SVC_RES_OK) {
// error
LOGE("Failed to send a service message");
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
}
-void send_request_for_server_connection_status(service_client* service_client)
+void send_request_for_server_connection_status(appdata_s *ad, service_client* service_client)
{
bundle *msg;
int result;
if (!service_client) {
- // error
+ failed_to_communicate_server(ad);
return;
}
msg = bundle_create();
if (!msg) {
LOGE("Failed to create a bundle");
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if (bundle_add_str(msg, "command", "server_connection_status") != 0) {
ERR("Failed to add data by key to bundle");
bundle_free(msg);
+ failed_to_communicate_server(ad);
return;
}
if(result != SVC_RES_OK) {
// error
LOGE("Failed to send a service message");
+ failed_to_communicate_server(ad);
}
bundle_free(msg);
#include "tg_settings_view.h"
#include "device_contacts_manager.h"
+static Eina_Bool on_load_main_view_requested(void *data);
static void free_app_data(appdata_s *app_data, Eina_Bool destroy_server);
static int init_service(appdata_s *app);
static void popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
int result = SVC_RES_FAIL;
+
+#if 0
char* chat_id_str = NULL;
result = bundle_get_str(rec_msg, "chat_id", &chat_id_str);
tg_main_list_item_s* latest_item = get_latest_item(app, peer_item);
if (latest_item) {
app->main_list = eina_list_prepend(app->main_list, latest_item);
- refresh_main_list_view(app, EINA_TRUE);
+ hide_loading_popup(app);
+ refresh_main_list_view(app, EINA_FALSE);
}
} else {
+
+ hide_loading_popup(app);
+ if (app->main_item) {
+ elm_naviframe_item_pop_to(app->main_item);
+ app->current_app_state = TG_USER_MAIN_VIEW_STATE;
+ }
+
tg_main_list_item_s* latest_item = get_latest_item(app, peer_item);
if (latest_item) {
app->main_list = eina_list_prepend(app->main_list, latest_item);
- refresh_main_list_view(app, EINA_TRUE);
+ refresh_main_list_view(app, EINA_FALSE);
}
- elm_naviframe_item_pop(app->nf);
- app->current_app_state = TG_USER_MAIN_VIEW_STATE;
- evas_object_show(app->panel);
- //elm_panel_hidden_set(app->panel, EINA_FALSE);
+
}
app->peer_list = eina_list_prepend(app->peer_list, peer_item);
- hide_loading_popup(app);
+#else
+ load_registered_user_data(app);
+ load_buddy_list_data(app);
+ load_unknown_buddy_list_data(app);
+ load_peer_data(app);
+ load_main_list_data(app);
+
+ if (app->main_item) {
+ elm_naviframe_item_pop_to(app->main_item);
+ }
+ ecore_timer_add(1, on_load_main_view_requested, app);
+#endif
return result;
}
result = bundle_get_str(rec_msg, "command", &rec_key_val);
- if (strcmp(rec_key_val, "registration_done") == 0) {
+ if (strcmp(rec_key_val, "server_not_initialized") == 0) {
+ hide_loading_popup(app);
+ show_toast(app, "Please check your network connection.");
+ return result;
+ } else if (strcmp(rec_key_val, "registration_done") == 0) {
char* is_success_val = NULL;
result = bundle_get_str(rec_msg, "is_success", &is_success_val);
void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info)
{
appdata_s *ad = data;
+ if (ad->loading_popup) {
+ show_toast(ad, "Please wait. request in progress");
+ return;
+ }
+
switch(ad->current_app_state) {
case TG_INIT_SCREEN_STATE:
elm_win_lower(ad->win);
elm_naviframe_item_pop(ad->nf);
ad->current_app_state = TG_SETTINGS_SCREEN_STATE;
break;
+#if 0
case TG_ADD_CONTACT_STATE:
elm_naviframe_item_pop(ad->nf);
ad->current_app_state = TG_SET_USER_INFO_STATE;
break;
+#endif
case TG_SET_CHAT_INFO_STATE:
case TG_SET_USER_INFO_STATE:
elm_naviframe_item_pop(ad->nf);
elm_exit();
break;
case TG_LOGIN_STATE:
- send_request_for_restart_server(ad->service_client);
+ send_request_for_restart_server(ad, ad->service_client);
if (ad->timer_value > 0) {
Ecore_Timer* timer = evas_object_data_get(ad->nf, "code_timer");
if (timer)
//evas_object_show(ad->panel);
//refresh_buddy_list(ad);
break;
+ case TG_ADD_CONTACT_STATE:
+ elm_naviframe_item_pop(ad->nf);
+ ad->current_app_state = TG_PEER_SEARCH_VIEW_STATE;
+ show_floating_button(ad);
+ break;
case TG_BUDDY_LIST_SELECTION_STATE:
if (ad->buddy_list) {
for (int i = 0 ; i < eina_list_count(ad->buddy_list) ; i++) {
}
}
elm_naviframe_item_pop(ad->nf);
- ad->current_app_state = TG_BUDDY_LIST_STATE;
+ ad->current_app_state = TG_BUDDY_LIST_SELECTION_STATE;
//evas_object_show(ad->panel);
//elm_panel_hidden_set(ad->panel, EINA_FALSE);
//refresh_buddy_list(ad);
bundle_free(msg);
}
-static Eina_Bool on_load_main_view_requested(void *data)
+Eina_Bool on_load_main_view_requested(void *data)
{
appdata_s *ad = data;
if (ad) {
elm_naviframe_item_pop(ad->nf);
+ hide_loading_popup(ad);
launch_user_main_view_cb(ad);
int unread_msg_cnt = get_number_of_unread_messages();
int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
ad->panel = NULL;
ad->is_server_ready = EINA_FALSE;
ad->contact_list = NULL;
+ ad->main_item = NULL;
//ad->msg_count = 0;
create_base_gui(ad);
int err = badge_new(TELEGRAM_APP_ID);
char* phone_num = get_buddy_phone_num_from_id(ad->peer_in_cahtting_data->use_data->peer_id);
- send_add_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id, first_name, last_name, phone_num);
+ send_add_buddy_request(ad, ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id, first_name, last_name, phone_num);
free(first_name);
Evas_Object *profile_pic = evas_object_data_get(ad->nf, "user_chat_profile_pic");
if (profile_pic) {
elm_image_file_set(profile_pic, file_path, NULL);
- send_set_group_chat_profile_pic_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id, file_path);
+ send_set_group_chat_profile_pic_request(ad, ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id, file_path);
}
}
break;
if (new_title) {
//send request to server.
int chat_id = ad->peer_in_cahtting_data->use_data->peer_id;
- send_set_group_chat_new_title_request(ad->service_client, chat_id, new_title);
+ send_set_group_chat_new_title_request(ad, ad->service_client, chat_id, new_title);
}
}
evas_object_del(popup);
if (ad->selected_buddy_item) {
user_data_s *sel_user = ad->selected_buddy_item;
show_loading_popup(ad);
- send_remove_buddy_from_group_chat_request(ad->service_client, ad->selected_buddy_item->user_id.id, ad->peer_in_cahtting_data->use_data->peer_id);
+ send_remove_buddy_from_group_chat_request(ad, ad->service_client, ad->selected_buddy_item->user_id.id, ad->peer_in_cahtting_data->use_data->peer_id);
}
}
}
peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
tg_peer_info_s *user_data = sel_item->use_data;
show_loading_popup(ad);
- send_delete_group_chat_request(ad->service_client, user_data->peer_id);
+ send_delete_group_chat_request(ad, ad->service_client, user_data->peer_id);
} else {
}
/* FIXME : Write the request for edit name */
- send_update_display_name_request(ad->service_client, ad->current_user_data->user_id.id, first_name, last_name);
+ send_update_display_name_request(ad, ad->service_client, ad->current_user_data->user_id.id, first_name, last_name);
free(first_name);
free(last_name);
}
char* first_name = trim((char*)tfirst_name);
char* last_name = trim((char*)tlast_name);
- send_request_for_profile_registration(ad->service_client, first_name, last_name);
+ send_request_for_profile_registration(ad, ad->service_client, first_name, last_name);
show_loading_popup(ad);
free(first_name);
free(last_name);
if (!ad)
return;
- send_request_for_restart_server(ad->service_client);
+ send_request_for_restart_server(ad, ad->service_client);
Ecore_Timer* timer = evas_object_data_get(ad->nf, "code_timer");
if (timer)
ecore_timer_del(timer);
}
- send_request_for_validation(ad->service_client, val);
+ send_request_for_validation(ad, ad->service_client, val);
show_loading_popup(ad);
}
#else
snprintf(temp_txt, sizeof(temp_txt), i18n_get_text("IDS_TGRAM_BODY_TELEGRAM_WILL_CALL_IN_P1SD_CP2SD"), 0, 0);
// send request to get phone call
- send_request_for_registration(ad->service_client, ad->phone_number, EINA_FALSE);
+ send_request_for_registration(ad, ad->service_client, ad->phone_number, EINA_FALSE);
return ECORE_CALLBACK_CANCEL;
}
}
if (sel_grp_chat && eina_list_count(sel_grp_chat) > 0) {
- send_delete_selected_group_chats_request(ad->service_client, sel_grp_chat);
+ send_delete_selected_group_chats_request(ad, ad->service_client, sel_grp_chat);
} else {
refresh_main_list_view(ad, EINA_FALSE);
elm_naviframe_item_pop(ad->nf);
strcpy(phone_number, cunt_code);
strcat(phone_number, phone_num);
ad->phone_number = strdup(phone_number);
- send_request_for_registration(ad->service_client, ad->phone_number, EINA_TRUE);
+ send_request_for_registration(ad, ad->service_client, ad->phone_number, EINA_TRUE);
show_loading_popup(ad);
} else {
// request chat info
//show_toast(ad, "Loading chat info. Please wait.");
show_loading_popup(ad);
- send_update_chat_request(ad->service_client, sel_item->peer_id);
+ send_update_chat_request(ad, ad->service_client, sel_item->peer_id);
return;
}
}
static Evas_Object *_get_picture_cb(void *data, Evas_Object *obj, const char *part)
{
- if (0 == strcmp(part, "contents")) {
+ //if (0 == strcmp(part, "contents")) {
+ if (!strcmp(part, "elm.swallow.content")) {
+#if 0
Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(obj));
evas_object_color_set(rect, 0, 0, 255, 255);
evas_object_resize(rect, 720, 440);
evas_object_show(rect);
return rect;
+#else
+ char edj_path[PATH_MAX] = {0, };
+ app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
+ Evas_Object* layout = elm_layout_add(obj);
+ elm_layout_file_set(layout, edj_path, "add_contact_custom_item");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(layout);
+ Evas_Object *profile_pic = create_image_object_from_file(ui_utils_get_resource(TG_CALLER_ID_IMAGE), obj);
+ elm_image_fill_outside_set(profile_pic, EINA_TRUE);
+ elm_image_aspect_fixed_set(profile_pic, EINA_FALSE);
+ evas_object_color_set(profile_pic, 45, 165, 224, 255);
+ elm_object_part_content_set(layout, "swallow.item", profile_pic);
+ return layout;
+#endif
}
return NULL;
}
Elm_Object_Item *item = NULL;
itc = elm_genlist_item_class_new();
- itc->item_style = "input.1image";
+ itc->item_style = "full";
itc->func.text_get = NULL;
itc->func.content_get = _get_picture_cb;
itc->func.state_get = NULL;
return list;
}
+static void on_new_contact_done_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ appdata_s* ad = data;
+}
+
+static void on_new_contact_cancel_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ appdata_s* ad = data;
+ elm_naviframe_item_pop(ad->nf);
+ ad->current_app_state = TG_PEER_SEARCH_VIEW_STATE;
+ show_floating_button(ad);
+}
+
int on_create_new_contact(appdata_s* ad)
{
if (!ad)
return 0;
+ delete_floating_button(ad);
ad->current_app_state = TG_ADD_CONTACT_STATE;
char edj_path[PATH_MAX] = {0, };
Evas_Object *done_btn = elm_button_add(ad->nf);
elm_object_style_set(done_btn, "naviframe/title_right");
elm_object_text_set(done_btn, i18n_get_text("IDS_TGRAM_ACBUTTON_DONE_ABB"));
- //evas_object_smart_callback_add(done_btn, "clicked", on_name_entry_done_clicked, ad);
+ evas_object_smart_callback_add(done_btn, "clicked", on_new_contact_done_clicked, ad);
Evas_Object *cancel_btn = elm_button_add(ad->nf);
elm_object_style_set(cancel_btn, "naviframe/title_left");
elm_object_text_set(cancel_btn, i18n_get_text("IDS_TGRAM_ACBUTTON_CANCEL_ABB"));
- //evas_object_smart_callback_add(cancel_btn, "clicked", on_naviframe_cancel_clicked, ad);
+ evas_object_smart_callback_add(cancel_btn, "clicked", on_new_contact_cancel_clicked, ad);
elm_object_item_part_content_set(navi_item, "title_right_btn", done_btn);
elm_object_item_part_content_set(navi_item, "title_left_btn", cancel_btn);
char edj_path[PATH_MAX] = {0, };
app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
Evas_Object* user_pic_layout = elm_layout_add(ad->nf);
- elm_layout_file_set(user_pic_layout, edj_path, "circle_layout");
+ elm_layout_file_set(user_pic_layout, edj_path, "search_circle_layout");
evas_object_size_hint_weight_set(user_pic_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(user_pic_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(user_pic_layout);
elm_object_part_content_set(user_pic_layout, "content", profile_pic);
eo = elm_layout_add(obj);
- elm_layout_theme_set(eo, "layout", "list/C/type.3", "default");
+ elm_layout_theme_set(eo, "layout", "list/B/type.2", "default");
elm_layout_content_set(eo, "elm.swallow.content", user_pic_layout);
}
return eo;
if (ad->peer_in_cahtting_data && ad->peer_in_cahtting_data->use_data) {
show_loading_popup(ad);
- send_add_buddy_to_group_chat_request(ad->service_client, ad->selected_buddy_item->user_id.id, ad->peer_in_cahtting_data->use_data->peer_id);
+ send_add_buddy_to_group_chat_request(ad, ad->service_client, ad->selected_buddy_item->user_id.id, ad->peer_in_cahtting_data->use_data->peer_id);
elm_naviframe_item_pop(ad->nf);
ad->current_app_state = TG_SET_CHAT_INFO_STATE;
}
if (strlen(user_name) < MIN_USERNAME_LENGTH) {
show_toast(ad, "Username should not be less than 5 characters");
} else {
- send_set_username_request(ad->service_client, ad->current_user_data->user_id.id, user_name);
+ send_set_username_request(ad, ad->service_client, ad->current_user_data->user_id.id, user_name);
show_loading_popup(ad);
}
free(user_name);
appdata_s *ad = (appdata_s*)user_data;
if (ad) {
show_loading_popup(ad);
- send_set_profile_pic_request(ad->service_client, ad->current_user_data->user_id.id, file_path);
+ send_set_profile_pic_request(ad, ad->service_client, ad->current_user_data->user_id.id, file_path);
}
break;
}
return;
}
- if (id == 1) {
+ if (id == 1) {
app_control_set_operation(app_control, APP_CONTROL_OPERATION_CREATE_CONTENT);
app_control_set_mime(app_control, "image/jpg");
app_control_send_launch_request(app_control, &on_image_select_result_cb, ad);
appdata_s* ad = evas_object_data_get(obj, "app_data");
char *user_name = NULL;
+ char *first_name = NULL;
+ char *last_name = NULL;
if (!strcmp(part,"elm.text.main.left.top") || !strcmp(part,"elm.text")){
switch(id) {
case 0:
//return replace(ad->current_user_data->print_name, '_', " ");
-
+#if 0
user_name = (char*)malloc(strlen(ad->current_user_data->first_name) + strlen(" ") + strlen(ad->current_user_data->last_name) + 1);
strcpy(user_name, ad->current_user_data->first_name);
strcat(user_name, " ");
strcat(user_name, ad->current_user_data->last_name);
return user_name;
+#else
+ first_name = ad->current_user_data->first_name;
+ last_name = ad->current_user_data->last_name;
+
+
+ if (!first_name || strstr(first_name ,"null") != 0) {
+ first_name = NULL;
+ }
+ if (!first_name && !last_name) {
+ first_name = "";
+ }
+
+ if (!last_name || strstr(last_name ,"null") != 0) {
+ 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);
+ return user_name;
+#endif
case 1:
return strdup(i18n_get_text("IDS_TGRAM_OPT_SET_BACKGROUND_IMAGE_ABB"));
default:
if (popup) {
evas_object_del(popup);
}
- send_request_for_logout(ad->service_client);
+ send_request_for_logout(ad, ad->service_client);
show_loading_popup(ad);
}
show_loading_popup(ad);
peer_with_pic_s *sel_item = ad->peer_in_cahtting_data;
if (get_buddy_block_status(sel_item->use_data->peer_id) == 1) {
- send_unblock_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
+ send_unblock_buddy_request(ad, ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
} else {
- send_block_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
+ send_block_buddy_request(ad, ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
}
}
//send_add_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
} else {
show_loading_popup(ad);
- send_delete_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
+ send_delete_buddy_request(ad, ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
}
}
//send group chat delete request
show_loading_popup(ad);
- send_delete_group_chat_request(ad->service_client, sel_item->peer_id);
+ send_delete_group_chat_request(ad, ad->service_client, sel_item->peer_id);
} else {
// request chat info
//show_toast(ad, "Loading chat info. Please wait.");
show_loading_popup(ad);
- send_update_chat_request(ad->service_client, sel_item->peer_id);
+ send_update_chat_request(ad, ad->service_client, sel_item->peer_id);
return;
}
}
ad->is_tg_initilized = EINA_TRUE;
char edj_path[PATH_MAX] = {0, };
app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
- send_request_for_server_connection_status(ad->service_client);
- send_request_for_delete_notifications(ad->service_client);
+ send_request_for_server_connection_status(ad, ad->service_client);
+ send_request_for_delete_notifications(ad, ad->service_client);
Evas_Object* scroller = elm_scroller_add(ad->nf);
elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
evas_object_smart_callback_add(search_btn, "unpressed", on_search_icon_unpressed, search_icon);
#endif
- elm_naviframe_item_push(ad->nf, i18n_get_text("IDS_TGRAM_HEADER_TELEGRAM"), NULL, NULL, scroller, NULL);
+ ad->main_item = elm_naviframe_item_push(ad->nf, i18n_get_text("IDS_TGRAM_HEADER_TELEGRAM"), NULL, NULL, scroller, NULL);
#if 0
Elm_Object_Item* navi_item = elm_naviframe_item_push(ad->nf, "<font=Tizen:style=Bold color=#ffffff align=center><font_size=48>Telegram</font_size></font>", NULL, NULL, scroller, NULL);
Evas_Object *menu_popup;
//int msg_count;
Eina_List *contact_list;
+ Elm_Naviframe_Item *main_item;
} appdata_s;
extern void show_toast(appdata_s* ad, char* value);
extern void process_add_user_request(tg_engine_data_s* tg_data, int buddy_id, char *first_name, char *last_name, char *phone_num);
extern void process_update_chat_request(tg_engine_data_s* tg_data, int chat_id);
extern void process_delete_user_request(tg_engine_data_s* tg_data, int buddy_id);
+extern void process_send_secret_chat_request(tg_engine_data_s* tg_data, int buddy_id);
extern void process_block_user_request(tg_engine_data_s* tg_data, int buddy_id);
extern void process_unblock_user_request(tg_engine_data_s* tg_data, int buddy_id);
extern void process_send_media_command(int buddy_id, int message_id, int media_id, int msg_type, char* file_path, int type_of_chat);
extern void process_update_display_name_command(tg_engine_data_s *tg_data, int buddy_id, const char *first_name, const char *last_name);
extern void send_add_contacts_request(tg_engine_data_s *tg_data);
+extern void send_server_not_initialized_response(tg_engine_data_s *tg_data);
extern void send_registration_response(tg_engine_data_s *tg_data, Eina_Bool is_success);
extern void send_request_code_again(tg_engine_data_s *tg_data);
extern void send_request_phone_num_again(tg_engine_data_s *tg_data);
do_update_chat_info(chat_id);
}
+void process_send_secret_chat_request(tg_engine_data_s* tg_data, int buddy_id)
+{
+ if (!tgl_engine_get_TLS()) {
+ return;
+ }
+ request_for_secret_chat(buddy_id);
+}
void process_delete_user_request(tg_engine_data_s* tg_data, int buddy_id)
{
bundle_free(msg);
}
+void send_server_not_initialized_response(tg_engine_data_s *tg_data)
+{
+ bundle *msg = bundle_create();
+ if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0) {
+ ERR("Failed to add data by key to bundle");
+ bundle_free(msg);
+ }
+
+ if (bundle_add_str(msg, "command", "server_not_initialized") != 0) {
+ ERR("Failed to add data by key to bundle");
+ bundle_free(msg);
+ }
+ int result = SVC_RES_FAIL;
+ result = tg_server_send_message(tg_data->tg_server, msg);
+
+ if(result != SVC_RES_OK) {
+ // error: cient not ready
+ }
+ bundle_free(msg);
+}
+
void send_contacts_and_chats_load_done_response(tg_engine_data_s *tg_data, Eina_Bool is_success)
{
bundle *msg = bundle_create();
}
process_registration_command(tg_data, ph_no_key_val, th_sms);
+ return result;
- } else if (strcmp(cmd_key_val, "logout_telegram") == 0) {
+ }
+
+ if (strcmp(cmd_key_val, "code_validation") == 0) {
+
+ char* sms_code_val = NULL;
+ res = bundle_get_str(rec_msg, "sms_code", &sms_code_val);
+ process_validation_command(tg_data, sms_code_val);
+ return result;
+ }
+
+ if (strcmp(cmd_key_val, "profile_registration") == 0) {
+
+ char* first_name = NULL;
+ char* last_name = NULL;
+
+ res = bundle_get_str(rec_msg, "first_name", &first_name);
+ if (res == BUNDLE_ERROR_NONE && first_name) {
+ tg_data->first_name = strdup(first_name);
+ }
+
+ res = bundle_get_str(rec_msg, "last_name", &last_name);
+ if (res == BUNDLE_ERROR_NONE && last_name) {
+ tg_data->last_name = strdup(last_name);
+ }
+
+ if (tg_data->tg_state == TG_ENGINE_STATE_PROFILE_FIRST_NAME_REGISTRATION && tg_data->get_string) {
+ tg_data->get_string(tgl_engine_get_TLS(), tg_data->first_name, tg_data->callback_arg);
+ }
+ return result;
+ }
+
+ if (!tg_data->is_login_activated) {
+ send_server_not_initialized_response(tg_data);
+ return result;
+ }
+
+ if (strcmp(cmd_key_val, "logout_telegram") == 0) {
//process_logout_command(tg_data);
} else if (strcmp(cmd_key_val, "restart_server") == 0) {
on_restart_service_requested(tg_data);
- } else if (strcmp(cmd_key_val, "code_validation") == 0) {
-
- char* sms_code_val = NULL;
- res = bundle_get_str(rec_msg, "sms_code", &sms_code_val);
- process_validation_command(tg_data, sms_code_val);
-
} else if (strcmp(cmd_key_val, "message_transport") == 0) {
char* buddy_id_str = NULL;
process_update_chat_request(tg_data, chat_id);
+ } else if (strcmp(cmd_key_val, "start_secret_chat") == 0) {
+
+ char* buddy_id_str = NULL;
+ res = bundle_get_str(rec_msg, "buddy_id", &buddy_id_str);
+ int buddy_id = atoi(buddy_id_str);
+
+ process_send_secret_chat_request(tg_data, buddy_id);
+
+
} else if (strcmp(cmd_key_val, "delete_buddy") == 0) {
char* buddy_id_str = NULL;
process_send_media_command(buddy_id, message_id, media_id, msg_type, file_path_str, type_of_chat);
- } else if (strcmp(cmd_key_val, "profile_registration") == 0) {
-
- char* first_name = NULL;
- char* last_name = NULL;
-
- res = bundle_get_str(rec_msg, "first_name", &first_name);
- if (res == BUNDLE_ERROR_NONE && first_name) {
- tg_data->first_name = strdup(first_name);
- }
-
- res = bundle_get_str(rec_msg, "last_name", &last_name);
- if (res == BUNDLE_ERROR_NONE && last_name) {
- tg_data->last_name = strdup(last_name);
- }
-
- if (tg_data->tg_state == TG_ENGINE_STATE_PROFILE_FIRST_NAME_REGISTRATION && tg_data->get_string) {
- tg_data->get_string(tgl_engine_get_TLS(), tg_data->first_name, tg_data->callback_arg);
- }
} else if (strcmp(cmd_key_val, "device_contact_list") == 0) {
char* count_str = NULL;
char *msg_table;
msg_table = get_table_name_from_number(chat_info->id.id);
create_buddy_msg_table(msg_table);
- free(msg_table);
+
if (!chat_info) {
return;
}
+
+ if (chat_info->flags == 144) {
+ return;
+ }
+ int msg_count = get_number_of_messages(msg_table);
+ if (msg_count <= 0) {
+ if (chat_info->admin_id > 0) {
+ set_date_item_to_table(msg_table, chat_info->date);
+ tgl_peer_id_t admin_id;
+ admin_id.id = chat_info->admin_id;
+ admin_id.type = TGL_PEER_USER;
+
+ tgl_peer_t* UC = tgl_peer_get(TLS, admin_id);
+ int msg_len = strlen(UC->user.first_name) + strlen(" created the group") + 1;
+ char* creator_name = (char*)malloc(msg_len);
+ strcpy(creator_name, UC->user.first_name);
+ strcat(creator_name, " created the group");
+ struct tgl_message msg;
+ int cur_time = chat_info->date;
+ msg.to_id = chat_info->id;
+ msg.from_id = admin_id;
+ msg.id = cur_time;
+ msg.message = creator_name;
+ msg.message_len = msg_len;
+ msg.unread = 0;
+ msg.date = cur_time;
+ msg.media.type = tgl_message_media_none;
+ msg.service = 1;
+ msg.out = 0;
+
+ insert_buddy_msg_to_db(&msg);
+ free(creator_name);
+ //send_message_received_response(TLS->callback_data, msg.from_id.id, msg.to_id.id, msg.id, tgl_get_peer_type(msg.to_id));
+ }
+
+ }
+
+ free(msg_table);
+
if (!chat_info->user_list) {
tgl_do_get_chat_info(TLS, chat_info->id, 0, &on_chat_info_received, NULL);
return;
return ECORE_CALLBACK_CANCEL;
}
+static Eina_Bool send_login_activated_response(void *data)
+{
+ struct tgl_state *TLS = data;
+ if (TLS) {
+ tg_engine_data_s *tg_data = TLS->callback_data;
+ send_response_for_server_connection_status(tg_data, tg_data->is_login_activated);
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static Eina_Bool send_chat_loading_is_done_response(void *data)
+{
+ struct tgl_state *TLS = data;
+ if (TLS) {
+ send_contacts_and_chats_load_done_response(TLS->callback_data, EINA_TRUE);
+ ecore_timer_add(3, send_login_activated_response, TLS);
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
void on_contacts_received(struct tgl_state *TLS, void *callback_extra, int success, int size, struct tgl_user *contacts[])
{
tg_engine_data_s *tg_data = TLS->callback_data;
// inform client that contact loading is done.
//send_contacts_load_done_response(EINA_TRUE);
- send_contacts_and_chats_load_done_response(TLS->callback_data, EINA_TRUE);
for (int i = size - 1; i >= 0; i--) {
struct tgl_user *buddy = contacts[i];
tgl_do_get_user_info(TLS, buddy->id, 0, on_buddy_info_loaded, NULL);
}
- send_response_for_server_connection_status(tg_data, tg_data->is_login_activated);
+
ecore_timer_add(3, on_send_unsent_messages_requested, TLS);
ecore_timer_add(6, on_load_buddy_history_requested, TLS);
+ ecore_timer_add(12, send_chat_loading_is_done_response, TLS);
}
}
}
-
void create_new_group(tg_engine_data_s *tg_data, Eina_List* buddy_ids, const char *group_name, const char *group_icon)
{
if (!buddy_ids || ! group_name) {
}
+void on_secret_chat_request_sent(struct tgl_state *TLS, void *callback_extra, int success, struct tgl_secret_chat *E)
+{
+ int buddy_id = (int)callback_extra;
+ tg_engine_data_s *tg_data = TLS->callback_data;
+ if (success) {
+
+ } else {
+
+ }
+}
+
+void request_for_secret_chat(int buddy_id)
+{
+ tgl_peer_id_t peer_id;
+ peer_id.id = buddy_id;
+ peer_id.type = TGL_PEER_USER;
+ tgl_do_create_secret_chat(s_info.TLS, peer_id, on_secret_chat_request_sent, (void*)(buddy_id));
+}
+
void do_delete_buddy(int buddy_id)
{
tgl_peer_id_t peer_id;
extern void leave_group_chat(tg_engine_data_s *tg_data, int group_chat_id);
extern void delete_selected_group_chat(tg_engine_data_s *tg_data, Eina_List *sel_grp_chats);
extern void do_delete_buddy(int buddy_id);
+extern void request_for_secret_chat(int buddy_id);
extern void do_add_buddy(int buddy_id, char *first_name, char *last_name, char *phone_num);
extern void do_update_chat_info(int chat_id);
extern void do_unblock_buddy(int buddy_id);