fixed nextwork failed issue while login.
authorsandeepkpolu <polu.sandeep@samsung.com>
Tue, 15 Mar 2016 01:10:02 +0000 (10:10 +0900)
committercskim <charles0.kim@samsung.com>
Tue, 15 Mar 2016 02:38:36 +0000 (11:38 +0900)
Change-Id: Ia796368f0cc884fcd0434ba8f3238a7fc9b661ec

TelegramTizen/src/telegramtizen.c
TelegramTizen/src/tg_registration.c
TelegramTizen/tg_utils/tg_common.h
tg-engine-service/inc/server_response.h
tg-engine-service/src/server_response.c
tg-engine-service/tg_engine/tg_engine.c

index 785c68d..af2d2fe 100755 (executable)
@@ -2408,13 +2408,18 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg)
                return result;
        } else if (strcmp(rec_key_val, "server_restart_notification") == 0) {
                hide_loading_popup(app);
-               show_toast(app, i18n_get_text("IDS_NFC_POP_INITIALISING_PLEASE_WAIT_ING"));
+               if (!app->is_waiting_for_phone_num)
+                       show_toast(app, "Network error. Please try again");
+
                ecore_timer_add(1, on_start_server_requested, app);
        } 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);
-
+               if (app->login_timer)
+                       ecore_timer_del(app->login_timer);
+               app->login_timer = NULL;
+               
                if (strncmp("true", is_success_val, strlen("true")) == 0) {
                //show_toast(app, is_success_val);
                        // Launch login view
@@ -2439,6 +2444,8 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg)
        } else if (strcmp(rec_key_val, "request_phone_num_again") == 0) {
                show_toast(app, "Please enter a valid phone number.");
                hide_loading_popup(app);
+       } else if (strcmp(rec_key_val, "request_phone_new_num") == 0) {
+               app->is_waiting_for_phone_num = EINA_TRUE;
        } else if (strcmp(rec_key_val, "server_connection_failed") == 0) {
                show_toast(app, "Server connection failed. please check network connection");
                hide_loading_popup(app);
@@ -2464,6 +2471,8 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg)
                app->s_notififcation = NULL;
                app->panel = NULL;
                app->is_server_ready = EINA_FALSE;
+               app->is_waiting_for_phone_num = EINA_FALSE;
+               app->login_timer = NULL;
                app->contact_list = NULL;
 
                char *chat_bg = NULL;
@@ -3687,6 +3696,8 @@ static bool app_create(void *data)
        ad->s_notififcation = NULL;
        ad->panel = NULL;
        ad->is_server_ready = EINA_FALSE;
+       ad->is_waiting_for_phone_num = EINA_FALSE;
+       ad->login_timer = NULL;
        ad->contact_list = NULL;
        ad->main_item = NULL;
        ad->country_codes_list = NULL;
index 1ba732d..5b7b9d9 100644 (file)
@@ -52,6 +52,18 @@ static void on_text_change_enable_ok_button(void *data, Evas_Object *obj, void *
                elm_object_disabled_set(done_btn, EINA_TRUE);
 }
 
+Eina_Bool on_login_timer_expired(void *data)
+{
+       appdata_s *ad = data;
+       if (!ad)
+               return ECORE_CALLBACK_CANCEL;
+               
+       hide_loading_popup(ad);
+       send_request_for_restart_server(ad, ad->service_client);
+    return ECORE_CALLBACK_CANCEL;
+}
+
+
 static void on_naviframe_done_clicked(void *data, Evas_Object *obj, void *event_info)
 {
        appdata_s* ad = data;
@@ -74,8 +86,11 @@ static void on_naviframe_done_clicked(void *data, Evas_Object *obj, void *event_
                char phone_number[256];
                snprintf(phone_number, sizeof(phone_number), "%s%s", cunt_code, phone_num);
                ad->phone_number = strdup(phone_number);
-               show_loading_popup(ad);
                send_request_for_registration(ad, ad->service_client, ad->phone_number, EINA_TRUE);
+
+               if (!ad->is_waiting_for_phone_num)
+                       ad->login_timer = ecore_timer_add(60, on_login_timer_expired, ad);
+               show_loading_popup(ad);
        } else {
                launch_tg_server(ad);
                show_toast(ad, i18n_get_text("IDS_NFC_POP_INITIALISING_PLEASE_WAIT_ING"));
index 723c1a5..a4faf9a 100755 (executable)
@@ -573,6 +573,8 @@ typedef struct appdata {
        app_visible_state s_app_visible_state;
        notification_h s_notififcation;
        Eina_Bool is_server_ready;
+       Eina_Bool is_waiting_for_phone_num;
+       Ecore_Timer *login_timer;
        TelegramAppDirection target_direction;
        Evas_Object *floating_btn;
        Elm_Theme *theme;
index 1a0bc70..4f12ae6 100644 (file)
@@ -56,6 +56,7 @@ 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);
+extern void send_request_phone_new_num(tg_engine_data_s *tg_data);
 extern void send_name_registration_response(tg_engine_data_s *tg_data);
 extern void send_contacts_load_done_response(tg_engine_data_s *tg_data, Eina_Bool is_success);
 extern void send_self_profile_picture_updated_response(tg_engine_data_s *tg_data, char *file_path, Eina_Bool is_success);
index e22d61c..0f002d7 100644 (file)
@@ -462,6 +462,11 @@ void send_request_phone_num_again(tg_engine_data_s *tg_data)
        make_arg1_response(tg_data, "request_phone_num_again", "phone_number", tg_data->phone_number);
 }
 
+void send_request_phone_new_num(tg_engine_data_s *tg_data)
+{
+       make_base_response(tg_data, "request_phone_new_num");
+}
+
 void send_request_code_again(tg_engine_data_s *tg_data)
 {
        make_arg1_response(tg_data, "request_reg_code_again", "phone_number", tg_data->phone_number);
index 90e2c92..c8f567f 100644 (file)
@@ -529,19 +529,14 @@ void tg_get_string(struct tgl_state *TLS, const char *prompt, int flags, void(*c
                if (tg_data->tg_state == TG_ENGINE_STATE_REGISTRATION) {
                        send_request_phone_num_again(tg_data);
                } else {
-                       //tg_data->is_first_time_registration = EINA_TRUE;
                        tg_data->tg_state = TG_ENGINE_STATE_REGISTRATION;
-                       if (tg_data && tg_data->phone_number) {
+                       if (tg_data && tg_data->phone_number)
                                tg_data->get_string(TLS, tg_data->phone_number, tg_data->callback_arg);
-                               //tg_data->code_response_timer = ecore_timer_add(60, on_code_request_timer_expired, tg_data);
-                       }
+                       else
+                               send_request_phone_new_num(tg_data);
                }
-       } else if (strcmp(prompt, "code('call' for phone call):") == 0) {
 
-/*             if (tg_data->code_response_timer) {
-                       ecore_timer_del(tg_data->code_response_timer);
-                       tg_data->code_response_timer = NULL;
-               }*/
+       } else if (strcmp(prompt, "code('call' for phone call):") == 0) {
 
                void **T = arg;
                tg_data->mhash = strdup(T[1]);