Don't free dbus method invocation twice
[platform/core/connectivity/net-config.git] / src / wifi-agent.c
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <stdio.h>
21 #include <vconf.h>
22 #include <stdlib.h>
23 #include <unistd.h>
24 #include <vconf-keys.h>
25
26 #include "log.h"
27 #include "util.h"
28 #include "wifi.h"
29 #include "netdbus.h"
30 #include "wifi-agent.h"
31 #include "wifi-state.h"
32 #include "wifi-eap-config.h"
33 #include "network-state.h"
34 #include "network-accessibility.h"
35 #include "wifi-key-encryption.h"
36
37 #define NETCONFIG_AGENT_FIELD_NAME                              "Name"
38 #define NETCONFIG_AGENT_FIELD_SSID                              "SSID"
39 #define NETCONFIG_AGENT_FIELD_IDENTITY                  "Identity"
40 #define NETCONFIG_AGENT_FIELD_PASSPHRASE                "Passphrase"
41 #define NETCONFIG_AGENT_FIELD_WPS                               "WPS"
42 #define NETCONFIG_AGENT_FIELD_WPS_PBC                   "WPS_PBC"
43 #define NETCONFIG_AGENT_FIELD_WPS_PIN                   "WPS_PIN"
44 #if defined TIZEN_CAPTIVE_PORTAL
45 #define NETCONFIG_AGENT_FIELD_USERNAME                  "Username"
46 #define NETCONFIG_AGENT_FIELD_PASSWORD                  "Password"
47 #endif
48
49 #define NETCONFIG_AGENT_ERR_CONNECT_FAILED              "connect-failed"
50
51 struct netconfig_wifi_agent {
52         GByteArray *ssid;
53         char *name;
54         char *identity;
55         char *passphrase;
56         char *wps_pin;
57 #if defined TIZEN_CAPTIVE_PORTAL
58         char *username;
59         char *password;
60 #endif
61         gboolean wps_pbc;
62 };
63
64 static struct netconfig_wifi_agent agent;
65
66 static void __netconfig_agent_clear_fields(void)
67 {
68         if (agent.ssid)
69                 g_byte_array_free(agent.ssid, TRUE);
70         g_free(agent.name);
71         g_free(agent.identity);
72         g_free(agent.passphrase);
73         g_free(agent.wps_pin);
74 #if defined TIZEN_CAPTIVE_PORTAL
75         g_free(agent.username);
76         g_free(agent.password);
77 #endif
78
79         agent.ssid = NULL;
80         agent.name = NULL;
81         agent.identity = NULL;
82         agent.passphrase = NULL;
83         agent.wps_pin = NULL;
84 #if defined TIZEN_CAPTIVE_PORTAL
85         agent.username = NULL;
86         agent.password = NULL;
87 #endif
88         agent.wps_pbc = FALSE;
89 }
90
91 int connman_register_agent(void)
92 {
93         GVariant *reply = NULL;
94         GVariant *params = NULL;
95
96         params = g_variant_new("(o)", NETCONFIG_WIFI_PATH);
97         reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
98                         CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
99                         "RegisterAgent", params);
100
101         if (reply == NULL) {
102                         ERR("Fail to register agent");
103                         return FALSE;
104         } else
105                 g_variant_unref(reply);
106
107         INFO("Registered to connman agent successfully");
108
109         return TRUE;
110 }
111
112 int connman_unregister_agent(void)
113 {
114         gboolean reply = FALSE;
115         GVariant *param = NULL;
116         const char *path = NETCONFIG_WIFI_PATH;
117
118         param = g_variant_new("(o)", path);
119
120         DBG("ConnMan agent unregister");
121
122         reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
123                         CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
124                         "UnregisterAgent", param, NULL);
125
126         if (reply != TRUE)
127                 ERR("Fail to unregister agent");
128
129         /* Clearing the agent fields */
130         __netconfig_agent_clear_fields();
131
132         return reply;
133 }
134
135 gboolean netconfig_wifi_set_agent_field_for_eap_network(
136                 const char *name, const char *identity, const char *passphrase)
137 {
138         int name_len;
139
140         if (name == NULL)
141                 return FALSE;
142
143         __netconfig_agent_clear_fields();
144
145         name_len = strlen(name);
146         agent.ssid = g_byte_array_sized_new(name_len);
147         agent.ssid->len = name_len;
148         memcpy(agent.ssid->data, name, name_len + 1);
149
150         if (identity)
151                 agent.identity = g_strdup(identity);
152
153         if (passphrase)
154                 agent.passphrase = g_strdup(passphrase);
155
156         gchar *enc_data = NULL;
157         enc_data = _netconfig_encrypt_passphrase(agent.passphrase);
158
159         if (!enc_data) {
160                 ERR("Failed to encrypt the passphrase");
161         } else {
162                 g_free(agent.passphrase);
163                 agent.passphrase = enc_data;
164         }
165
166         DBG("Successfully configured for EAP network");
167
168         return TRUE;
169 }
170
171 gboolean handle_set_field(NetConnmanAgent *connman_agent,
172                 GDBusMethodInvocation *context, const gchar *service, GVariant *fields)
173 {
174         GError *error = NULL;
175         GVariantIter *iter;
176         gpointer field;
177         GVariant *value;
178         gboolean updated = FALSE;
179         gboolean reply = FALSE;
180
181         g_return_val_if_fail(connman_agent != NULL, TRUE);
182
183         DBG("Set agent fields for %s", service);
184
185         if (netconfig_is_wifi_profile(service) != TRUE) {
186                 error = g_error_new(G_DBUS_ERROR,
187                                 G_DBUS_ERROR_AUTH_FAILED,
188                                 CONNMAN_ERROR_INTERFACE ".InvalidService");
189
190                 g_dbus_method_invocation_return_gerror(context, error);
191                 g_clear_error(&error);
192
193                 return TRUE;
194         }
195
196         __netconfig_agent_clear_fields();
197         g_variant_get(fields, "a{sv}", &iter);
198         while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
199                 if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0) {
200                         if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
201                                 agent.passphrase = g_strdup(g_variant_get_string(value, NULL));
202                                 updated = TRUE;
203
204                                 DBG("Field [%s] - []", field);
205
206                                 if (agent.passphrase == NULL)
207                                         continue;
208
209                                 if (netconfig_check_passphrase(service, agent.passphrase) == FALSE) {
210                                         ERR("Invalid passphrase");
211
212                                         g_free(agent.passphrase);
213                                         agent.passphrase = NULL;
214
215                                         updated = FALSE;
216                                         continue;
217                                 }
218
219                                 gchar *enc_data = NULL;
220                                 enc_data = _netconfig_encrypt_passphrase(agent.passphrase);
221
222                                 if (!enc_data) {
223                                         ERR("Failed to encrypt the passphrase");
224                                         continue;
225                                 }
226
227                                 g_free(agent.passphrase);
228                                 agent.passphrase = enc_data;
229                         }
230                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS_PBC) == 0) {
231                         if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING) &&
232                                         g_strcmp0(g_variant_get_string(value, NULL), "enable") == 0) {
233                                 agent.wps_pbc = TRUE;
234                                 updated = TRUE;
235
236                                 DBG("Field [%s] - [%d]", field, agent.wps_pbc);
237                         }
238                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS_PIN) == 0) {
239                         if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
240                                 agent.wps_pin = g_strdup(g_variant_get_string(value, NULL));
241                                 updated = TRUE;
242
243                                 DBG("Field [%s] - [%s]", field, agent.wps_pin);
244                         }
245                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_NAME) == 0) {
246                         if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
247                                 agent.name = g_strdup(g_variant_get_string(value, NULL));
248                                 updated = TRUE;
249
250                                 DBG("Field [%s] - [%s]", field, agent.name);
251                         }
252                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_SSID) == 0) {
253                         if (agent.ssid != NULL) {
254                                 g_byte_array_free(agent.ssid, TRUE);
255                                 agent.ssid = NULL;
256                         }
257
258                         if (g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) {
259                                 guint8 char_value;
260                                 GVariantIter *iter1;
261                                 GByteArray *array = g_byte_array_new();
262
263                                 g_variant_get(value, "ay", &iter1);
264                                 while (g_variant_iter_loop(iter1, "y", &char_value))
265                                         g_byte_array_append(array, &char_value, 1);
266                                 g_variant_iter_free(iter1);
267                                 if (array != NULL && (array->len > 0)) {
268                                         agent.ssid = g_byte_array_sized_new(array->len);
269                                         agent.ssid->len = array->len;
270                                         memcpy(agent.ssid->data, array->data, array->len);
271                                         updated = TRUE;
272
273                                         DBG("Field [%s] - []", field);
274                                 }
275                         }
276                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_IDENTITY) == 0) {
277                         if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
278                                 agent.identity = g_strdup(g_variant_get_string(value, NULL));
279                                 updated = TRUE;
280
281                                 DBG("Field [%s] - [%s]", field, agent.identity);
282                         }
283 #if defined TIZEN_CAPTIVE_PORTAL
284                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_USERNAME) == 0) {
285                         if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
286                                 agent.username = g_strdup(g_variant_get_string(value, NULL));
287                                 updated = TRUE;
288
289                                 DBG("Field [%s] - [%s]", field, agent.username);
290                         }
291                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSWORD) == 0) {
292                         if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
293                                 agent.password = g_strdup(g_variant_get_string(value, NULL));
294                                 updated = TRUE;
295
296                                 DBG("Field [%s] - [%s]", field, agent.password);
297                         }
298 #endif
299                 }
300         }
301
302         g_variant_iter_free(iter);
303
304         if (updated == TRUE) {
305                 reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
306                                 service, CONNMAN_SERVICE_INTERFACE, "Connect",
307                                 NULL, __netconfig_wifi_connect_reply);
308                 if (reply != TRUE) {
309                         ERR("Fail to connect Wi-Fi");
310                         __netconfig_agent_clear_fields();
311                         error = g_error_new(G_DBUS_ERROR,
312                                         G_DBUS_ERROR_AUTH_FAILED,
313                                         CONNMAN_ERROR_INTERFACE ".InvalidArguments");
314
315                         g_dbus_method_invocation_return_gerror(context, error);
316                         g_clear_error(&error);
317                         return TRUE;
318                 }
319         } else {
320                 ERR("Fail to connect Wi-Fi");
321                 __netconfig_agent_clear_fields();
322
323                 error = g_error_new(G_DBUS_ERROR,
324                                 G_DBUS_ERROR_AUTH_FAILED,
325                                 CONNMAN_ERROR_INTERFACE ".InvalidArguments");
326
327                 g_dbus_method_invocation_return_gerror(context, error);
328                 g_clear_error(&error);
329                 return TRUE;
330         }
331
332         net_connman_agent_complete_set_field(connman_agent, context);
333         return TRUE;
334 }
335
336 gboolean handle_request_input(NetConnmanAgent *connman_agent,
337                 GDBusMethodInvocation *context, const gchar *service, GVariant *fields)
338 {
339         GVariantIter *iter;
340         gchar *field = NULL;
341         GVariant *r_value = NULL;
342         GVariant *out_table = NULL;
343         gboolean updated = FALSE;
344         GVariantBuilder *builder = NULL;
345
346         g_return_val_if_fail(connman_agent != NULL, TRUE);
347
348         if (NULL == service)
349                 return TRUE;
350
351         DBG("Agent fields requested for service: %s", service);
352
353         builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
354
355         g_variant_get(fields, "a{sv}", &iter);
356         while (g_variant_iter_loop(iter, "{sv}", &field, &r_value)) {
357
358                 if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSPHRASE) == 0 &&
359                                 agent.passphrase != NULL) {
360                         g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_PASSPHRASE,
361                                                         g_variant_new_string(agent.passphrase));
362
363                         updated = TRUE;
364                         DBG("Setting [%s] - [%s]", field, agent.passphrase);
365                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_WPS) == 0 &&
366                                 (agent.wps_pbc == TRUE || agent.wps_pin != NULL)) {
367                         if (agent.wps_pbc == TRUE) {
368                                 /* Sending empty string for WPS push button method */
369                                 g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS, g_variant_new_string(""));
370
371                                 updated = TRUE;
372                                 DBG("Setting empty string for [%s]", field);
373                         } else if (agent.wps_pin != NULL) {
374                                 g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_WPS, g_variant_new_string(agent.wps_pin));
375
376                                 updated = TRUE;
377                                 DBG("Setting string [%s] - [%s]", field, agent.wps_pin);
378                         }
379                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_NAME) == 0 &&
380                                 agent.name != NULL) {
381                         g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_NAME, g_variant_new_string(agent.name));
382
383                         updated = TRUE;
384                         DBG("Settings [%s] - [%s]", field, agent.name);
385                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_SSID) == 0 &&
386                                 agent.ssid != NULL) {
387                         int i = 0;
388                         GVariantBuilder *builder1 = NULL;
389                         builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
390
391                         for (i = 0; i < (agent.ssid->len); i++)
392                                 g_variant_builder_add(builder1, "y", agent.ssid->data[i]);
393
394                         g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_SSID, g_variant_builder_end(builder1));
395                         if (builder1 != NULL)
396                                 g_variant_builder_unref(builder1);
397
398                         updated = TRUE;
399                         DBG("Settings [%s] - []", field);
400                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_IDENTITY) == 0 &&
401                                 agent.identity != NULL) {
402                         g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_IDENTITY, g_variant_new_string(agent.identity));
403
404                         updated = TRUE;
405                         DBG("Settings [%s] - [%s]", field, agent.identity);
406 #if defined TIZEN_CAPTIVE_PORTAL
407                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_USERNAME) == 0 &&
408                                 agent.username != NULL) {
409                         g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_USERNAME, g_variant_new_string(agent.username));
410
411                         updated = TRUE;
412                         DBG("Settings [%s] - [%s]", field, agent.username);
413                 } else if (g_strcmp0(field, NETCONFIG_AGENT_FIELD_PASSWORD) == 0 &&
414                                 agent.password != NULL) {
415                         g_variant_builder_add(builder, "{sv}", NETCONFIG_AGENT_FIELD_PASSWORD, g_variant_new_string(agent.password));
416
417                         updated = TRUE;
418                         DBG("Settings [%s] - [%s]", field, agent.password);
419 #endif
420                 }
421         }
422
423         out_table = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
424
425         if (builder)
426                 g_variant_builder_unref(builder);
427
428         g_variant_iter_free(iter);
429
430
431         if (NULL == out_table) {
432                 net_connman_agent_complete_request_input(connman_agent, context, out_table);
433
434                 return TRUE;
435         }
436
437         if (updated == TRUE)
438                 g_dbus_method_invocation_return_value(context, out_table);
439         else {
440                 GError *error = NULL;
441                 error = g_error_new(G_DBUS_ERROR,
442                                 G_DBUS_ERROR_AUTH_FAILED,
443                                 "net.connman.Agent.Error.Canceled");
444
445                 g_dbus_method_invocation_return_gerror(context, error);
446                 g_clear_error(&error);
447         }
448
449         __netconfig_agent_clear_fields();
450
451         return TRUE;
452 }
453
454
455 gboolean handle_report_error(NetConnmanAgent *connman_agent,
456                 GDBusMethodInvocation *context, const gchar *service, const gchar *error)
457 {
458         g_return_val_if_fail(connman_agent != NULL, TRUE);
459
460         net_connman_agent_complete_report_error(connman_agent, context);
461         DBG("Agent error for service[%s] - [%s]", service, error);
462
463         /* Do something when it failed to make a connection */
464
465         return TRUE;
466 }
467
468 #if defined TIZEN_CAPTIVE_PORTAL
469 #if defined TIZEN_WEARABLE
470 #define QUERY_FOR_INTERNET_INTERVAL                     2
471 #define TIMER_THRESHOLD                                         4
472 #else
473 #define QUERY_FOR_INTERNET_INTERVAL                     20
474 #define TIMER_THRESHOLD                                         120
475 #endif
476
477 static gboolean is_monitor_notifier_registered = FALSE;
478
479 #if defined TIZEN_WEARABLE
480 static gboolean is_portal_msg_shown = FALSE;
481 #endif
482
483 struct poll_timer_data {
484         guint time_elapsed;
485         guint timer_id;
486         void* data;
487 };
488
489 static struct poll_timer_data timer_data = {
490                 QUERY_FOR_INTERNET_INTERVAL, 0, NULL};
491
492 static gboolean __check_ignore_portal_list(const char * ssid)
493 {
494         char def_str[1024];
495         int i = 0;
496         int ignore_ap_count = 0;
497
498         if (ssid == NULL)
499                 return FALSE;
500
501         DBG("checking ssid [%s]", ssid);
502
503         DBG("csc string [%s]", def_str);
504         gchar ** ignore_ap_list = g_strsplit(def_str, ",", 0);
505         ignore_ap_count = g_strv_length(ignore_ap_list);
506         for (i = 0; i < ignore_ap_count; i++) {
507                 DBG("[%d] - [%s]", i, ignore_ap_list[i]);
508                 if (strncmp(ignore_ap_list[i], ssid, strlen(ssid)) == 0) {
509                         g_strfreev(ignore_ap_list);
510                         return TRUE;
511                 }
512         }
513
514         g_strfreev(ignore_ap_list);
515         return FALSE;
516 }
517
518 static void __wifi_state_monitor(wifi_service_state_e state,
519                 void *user_data);
520
521 static wifi_state_notifier wifi_state_monitor_notifier = {
522                 .wifi_state_changed = __wifi_state_monitor,
523                 .user_data = NULL,
524 };
525
526 static void __wifi_state_monitor(wifi_service_state_e state,
527                 void *user_data)
528 {
529         DBG("Wi-Fi state: %x", state);
530
531         if (state == NETCONFIG_WIFI_CONNECTED)
532                 return;
533
534         if (is_monitor_notifier_registered == TRUE) {
535                 wifi_state_notifier_unregister(&wifi_state_monitor_notifier);
536                 is_monitor_notifier_registered = FALSE;
537         }
538
539 #if defined TIZEN_WEARABLE
540         is_portal_msg_shown = FALSE;
541 #endif
542
543         /* suspend if Internet check activity in progress */
544         if (timer_data.timer_id == 0)
545                 return;
546
547         netconfig_stop_timer(&timer_data.timer_id);
548         netconfig_stop_internet_check();
549
550         DBG("Stopped Internet accessibility check");
551 }
552
553 static gboolean __netconfig_wifi_portal_login_timeout(gpointer data)
554 {
555         char *service_profile = NULL;
556         GVariant *reply = NULL;
557
558         DBG("");
559
560         struct poll_timer_data *timer = (struct poll_timer_data *)data;
561         if (timer == NULL)
562                 return FALSE;
563
564         if (TRUE == netconfig_get_internet_status()) {
565                 if (is_monitor_notifier_registered == TRUE) {
566                         wifi_state_notifier_unregister(&wifi_state_monitor_notifier);
567                         is_monitor_notifier_registered = FALSE;
568                 }
569
570                 DBG("Portal logged in successfully and update ConnMan state");
571                 return FALSE; /* to stop the timer */
572         } else {
573                 if (timer->time_elapsed >= TIMER_THRESHOLD) {
574                         DBG("Login failed, update ConnMan");
575
576                         if (is_monitor_notifier_registered == TRUE) {
577                                 wifi_state_notifier_unregister(&wifi_state_monitor_notifier);
578                                 is_monitor_notifier_registered = FALSE;
579                         }
580
581                         /* Disconnect and forget the AP */
582                         service_profile = (char*) netconfig_get_default_profile();
583                         if (service_profile && netconfig_is_wifi_profile(service_profile)) {
584                                 /* Now forget the AP*/
585                                 reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
586                                                 service_profile, CONNMAN_SERVICE_INTERFACE, "Remove",
587                                                 NULL);
588
589                                 if (reply != NULL)
590                                         g_variant_unref(reply);
591                                 else
592                                         ERR("Failed to forget the AP ");
593                         }
594                 } else {
595                         if (NETCONFIG_WIFI_CONNECTED ==
596                                         wifi_state_get_service_state()) {
597                                 /* check Internet availability by sending and receiving data*/
598                                 netconfig_check_internet_accessibility();
599                                 /* Returning TRUE itself is enough to restart the timer */
600                                 timer->time_elapsed = timer->time_elapsed +
601                                                                         QUERY_FOR_INTERNET_INTERVAL;
602                                 return TRUE;
603                         }
604                 }
605         }
606
607         return FALSE;
608 }
609
610 static void __netconfig_wifi_portal_login_timer_start(struct poll_timer_data
611                 *data)
612 {
613         DBG("__netconfig_wifi_browser_start_timer...starting timer");
614
615         if (data == NULL)
616                 return;
617
618         netconfig_stop_timer(&(data->timer_id));
619
620         /* Timer logic: After successful launch of browser, we would check for
621          * Internet status for every 20s until a threshold of 120s
622          */
623
624         data->time_elapsed = QUERY_FOR_INTERNET_INTERVAL;
625         netconfig_start_timer_seconds(QUERY_FOR_INTERNET_INTERVAL,
626                 __netconfig_wifi_portal_login_timeout, data, &(data->timer_id));
627 }
628 #endif
629
630 gboolean handle_request_browser(NetConnmanAgent *connman_agent,
631                 GDBusMethodInvocation *context, const gchar *service, const gchar *url)
632 {
633 #if defined TIZEN_CAPTIVE_PORTAL
634         gboolean ignore_portal = FALSE;
635         const char * ssid = NULL;
636
637         g_return_val_if_fail(connman_agent != NULL, TRUE);
638
639         DBG("service[%s] - url[%s]", service, url);
640
641         ssid = netconfig_wifi_get_connected_essid(netconfig_get_default_profile());
642         if (ssid == NULL) {
643                 ERR("Connected AP name is NULL!!");
644                 net_connman_agent_complete_request_browser(connman_agent, context);
645                 return TRUE;
646         }
647
648         ignore_portal = __check_ignore_portal_list(ssid);
649
650         if (ignore_portal == TRUE) {
651                 net_connman_agent_complete_request_browser(connman_agent, context);
652                 return TRUE;
653         }
654         /* Register for Wifi state change notifier*/
655         if (is_monitor_notifier_registered == FALSE) {
656                 wifi_state_notifier_register(&wifi_state_monitor_notifier);
657                 is_monitor_notifier_registered = TRUE;
658         }
659
660         netconfig_send_notification_to_net_popup(NETCONFIG_ADD_PORTAL_NOTI, ssid);
661
662         timer_data.time_elapsed = 0;
663         __netconfig_wifi_portal_login_timer_start(&timer_data);
664
665         net_connman_agent_complete_request_browser(connman_agent, context);
666         return TRUE;
667 #else
668         GError *error = NULL;
669         error = g_error_new(G_DBUS_ERROR,
670                         G_DBUS_ERROR_AUTH_FAILED,
671                         CONNMAN_ERROR_INTERFACE ".NotSupported");
672
673         g_dbus_method_invocation_return_gerror(context, error);
674         g_clear_error(&error);
675
676         return TRUE;
677 #endif
678 }