/* wifi.c generated by valac 0.14.2, the Vala compiler * generated from wifi.vala, do not modify */ /* This file is part of iliwi. iliwi is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation. iliwi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with iliwi. If not, see . */ #include #include #include #include #include #include #include #include #include #include #define ILIWI_TYPE_WIFI (iliwi_wifi_get_type ()) #define ILIWI_WIFI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ILIWI_TYPE_WIFI, iliwiWifi)) #define ILIWI_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ILIWI_TYPE_WIFI, iliwiWifiClass)) #define ILIWI_IS_WIFI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ILIWI_TYPE_WIFI)) #define ILIWI_IS_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ILIWI_TYPE_WIFI)) #define ILIWI_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ILIWI_TYPE_WIFI, iliwiWifiClass)) typedef struct _iliwiWifi iliwiWifi; typedef struct _iliwiWifiClass iliwiWifiClass; typedef struct _iliwiWifiPrivate iliwiWifiPrivate; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) #define ILIWI_TYPE_NETWORK (iliwi_network_get_type ()) #define ILIWI_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ILIWI_TYPE_NETWORK, iliwiNetwork)) #define ILIWI_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ILIWI_TYPE_NETWORK, iliwiNetworkClass)) #define ILIWI_IS_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ILIWI_TYPE_NETWORK)) #define ILIWI_IS_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ILIWI_TYPE_NETWORK)) #define ILIWI_NETWORK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ILIWI_TYPE_NETWORK, iliwiNetworkClass)) typedef struct _iliwiNetwork iliwiNetwork; typedef struct _iliwiNetworkClass iliwiNetworkClass; typedef struct _iliwiNetworkPrivate iliwiNetworkPrivate; #define ILIWI_TYPE_NETWORK_STATUS (iliwi_network_status_get_type ()) #define ILIWI_TYPE_PREFERRED_NETWORK (iliwi_preferred_network_get_type ()) typedef struct _iliwiPreferredNetwork iliwiPreferredNetwork; typedef struct _iliwiParamSpecNetwork iliwiParamSpecNetwork; #define ILIWI_TYPE_WIFI_THREAD (iliwi_wifi_thread_get_type ()) #define ILIWI_WIFI_THREAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ILIWI_TYPE_WIFI_THREAD, iliwiWifiThread)) #define ILIWI_WIFI_THREAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ILIWI_TYPE_WIFI_THREAD, iliwiWifiThreadClass)) #define ILIWI_IS_WIFI_THREAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ILIWI_TYPE_WIFI_THREAD)) #define ILIWI_IS_WIFI_THREAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ILIWI_TYPE_WIFI_THREAD)) #define ILIWI_WIFI_THREAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ILIWI_TYPE_WIFI_THREAD, iliwiWifiThreadClass)) typedef struct _iliwiWifiThread iliwiWifiThread; typedef struct _iliwiWifiThreadClass iliwiWifiThreadClass; typedef struct _iliwiWifiThreadPrivate iliwiWifiThreadPrivate; #define TYPE_USAGE (usage_get_type ()) #define USAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_USAGE, Usage)) #define IS_USAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_USAGE)) #define USAGE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_USAGE, UsageIface)) typedef struct _Usage Usage; typedef struct _UsageIface UsageIface; #define TYPE_USAGE_PROXY (usage_proxy_get_type ()) #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) #define _g_source_unref0(var) ((var == NULL) ? NULL : (var = (g_source_unref (var), NULL))) #define _iliwi_network_unref0(var) ((var == NULL) ? NULL : (var = (iliwi_network_unref (var), NULL))) #define _fclose0(var) ((var == NULL) ? NULL : (var = (fclose (var), NULL))) #define _g_match_info_free0(var) ((var == NULL) ? NULL : (var = (g_match_info_free (var), NULL))) #define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL))) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL))) #define _iliwi_preferred_network_free0(var) ((var == NULL) ? NULL : (var = (iliwi_preferred_network_free (var), NULL))) struct _iliwiWifi { GObject parent_instance; iliwiWifiPrivate * priv; }; struct _iliwiWifiClass { GObjectClass parent_class; }; struct _iliwiWifiPrivate { gchar* _status; GThread* thread; }; struct _iliwiNetwork { GTypeInstance parent_instance; volatile int ref_count; iliwiNetworkPrivate * priv; gchar* address; gchar* essid; gboolean encryption; gboolean authentication; gboolean adhoc; gchar* password; gchar* username; gchar* cert; gchar* cert_dir; gboolean password_in_ascii; gint strength; gboolean unsaved; gboolean visible; gboolean preferred_network; Elm_Genlist_Item* listitem; }; struct _iliwiNetworkClass { GTypeClass parent_class; void (*finalize) (iliwiNetwork *self); }; typedef enum { ILIWI_NETWORK_STATUS_UNCONNECTED, ILIWI_NETWORK_STATUS_CONNECT, ILIWI_NETWORK_STATUS_CONNECTING, ILIWI_NETWORK_STATUS_CONNECTED } iliwiNetworkStatus; struct _iliwiPreferredNetwork { gchar* password; gboolean password_in_ascii; gchar* username; gchar* cert; gchar* cert_dir; }; struct _iliwiNetworkPrivate { gboolean _wpa_encryption; iliwiNetworkStatus _status; }; struct _iliwiParamSpecNetwork { GParamSpec parent_instance; }; struct _iliwiWifiThread { GObject parent_instance; iliwiWifiThreadPrivate * priv; }; struct _iliwiWifiThreadClass { GObjectClass parent_class; }; struct _UsageIface { GTypeInterface parent_iface; void (*RequestResource) (Usage* self, const gchar* resource, GError** error); void (*ReleaseResource) (Usage* self, const gchar* resource, GError** error); }; static gpointer iliwi_wifi_parent_class = NULL; static gpointer iliwi_network_parent_class = NULL; static gpointer iliwi_wifi_thread_parent_class = NULL; static GMainLoop* iliwi_wifi_thread_loop; static GMainLoop* iliwi_wifi_thread_loop = NULL; static Usage* iliwi_wifi_thread_fso_usage; static Usage* iliwi_wifi_thread_fso_usage = NULL; static GeeHashMap* iliwi_wifi_thread_preferred_networks; static GeeHashMap* iliwi_wifi_thread_preferred_networks = NULL; static GeeHashMap* iliwi_wifi_thread_networks; static GeeHashMap* iliwi_wifi_thread_networks = NULL; static GeeArrayList* iliwi_wifi_thread_visible_networks; static GStaticRecMutex __lock_iliwi_wifi_thread_visible_networks = {0}; static GeeArrayList* iliwi_wifi_thread_visible_networks = NULL; static iliwiNetworkStatus iliwi_wifi_thread_status; static iliwiNetworkStatus iliwi_wifi_thread_status = 0; static gchar* iliwi_wifi_thread_wireless_interface; static gchar* iliwi_wifi_thread_wireless_interface = NULL; static iliwiNetwork* iliwi_wifi_thread_connection_suggestion; static iliwiNetwork* iliwi_wifi_thread_connection_suggestion = NULL; static iliwiNetwork* iliwi_wifi_thread_connect_network; static iliwiNetwork* iliwi_wifi_thread_connect_network = NULL; static GRegex* iliwi_wifi_thread_line_regex_start_address; static GRegex* iliwi_wifi_thread_line_regex_start_address = NULL; static GRegex* iliwi_wifi_thread_line_regex_essid; static GRegex* iliwi_wifi_thread_line_regex_essid = NULL; static GRegex* iliwi_wifi_thread_line_regex_encryption; static GRegex* iliwi_wifi_thread_line_regex_encryption = NULL; static GRegex* iliwi_wifi_thread_line_regex_strength; static GRegex* iliwi_wifi_thread_line_regex_strength = NULL; static GRegex* iliwi_wifi_thread_line_regex_interface; static GRegex* iliwi_wifi_thread_line_regex_interface = NULL; static GRegex* iliwi_wifi_thread_line_regex_adhoc; static GRegex* iliwi_wifi_thread_line_regex_adhoc = NULL; static GRegex* iliwi_wifi_thread_line_regex_wpa_enc; static GRegex* iliwi_wifi_thread_line_regex_wpa_enc = NULL; static GRegex* iliwi_wifi_thread_line_regex_wpa_enc_auth; static GRegex* iliwi_wifi_thread_line_regex_wpa_enc_auth = NULL; static gint iliwi_wifi_thread_seconds_since_last_scan; static gint iliwi_wifi_thread_seconds_since_last_scan = 0; extern iliwiWifi* iliwi_wifi; GType iliwi_wifi_get_type (void) G_GNUC_CONST; #define ILIWI_WIFI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ILIWI_TYPE_WIFI, iliwiWifiPrivate)) enum { ILIWI_WIFI_DUMMY_PROPERTY, ILIWI_WIFI_STATUS }; void iliwi_wifi_thread_stop_thread (void); iliwiWifi* iliwi_wifi_new (void); iliwiWifi* iliwi_wifi_construct (GType object_type); void* iliwi_wifi_thread_run_thread (void); static gpointer _iliwi_wifi_thread_run_thread_gthread_func (gpointer self); gpointer iliwi_network_ref (gpointer instance); void iliwi_network_unref (gpointer instance); GParamSpec* iliwi_param_spec_network (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags); void iliwi_value_set_network (GValue* value, gpointer v_object); void iliwi_value_take_network (GValue* value, gpointer v_object); gpointer iliwi_value_get_network (const GValue* value); GType iliwi_network_get_type (void) G_GNUC_CONST; iliwiNetwork** iliwi_wifi_get_visible_networks (iliwiWifi* self, int* result_length1); iliwiNetwork** iliwi_wifi_thread_get_visible_networks (int* result_length1); void iliwi_wifi_connect_to (iliwiWifi* self, iliwiNetwork* network); void iliwi_wifi_thread_connect_to_network (iliwiNetwork* network); void iliwi_wifi_set_preferred_state (iliwiWifi* self, iliwiNetwork* network, gboolean new_state); void iliwi_wifi_thread_preferred_state_change (iliwiNetwork* network); void iliwi_wifi_set_ascii_state (iliwiWifi* self, iliwiNetwork* network, gboolean new_state); void iliwi_wifi_preferred_network_password_change (iliwiWifi* self, iliwiNetwork* network); void iliwi_wifi_preferred_network_username_change (iliwiWifi* self, iliwiNetwork* network); void iliwi_wifi_preferred_network_certificate_change (iliwiWifi* self, iliwiNetwork* network); void iliwi_wifi_set_new_status (iliwiWifi* self, const gchar* new_status); static void iliwi_wifi_set_status (iliwiWifi* self, const gchar* value); void iliwi_wifi_visible_network_change (iliwiWifi* self); const gchar* iliwi_wifi_get_status (iliwiWifi* self); static void iliwi_wifi_finalize (GObject* obj); static void _vala_iliwi_wifi_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); static void _vala_iliwi_wifi_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); GType iliwi_network_status_get_type (void) G_GNUC_CONST; GType iliwi_preferred_network_get_type (void) G_GNUC_CONST; iliwiPreferredNetwork* iliwi_preferred_network_dup (const iliwiPreferredNetwork* self); void iliwi_preferred_network_free (iliwiPreferredNetwork* self); void iliwi_preferred_network_copy (const iliwiPreferredNetwork* self, iliwiPreferredNetwork* dest); void iliwi_preferred_network_destroy (iliwiPreferredNetwork* self); #define ILIWI_NETWORK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ILIWI_TYPE_NETWORK, iliwiNetworkPrivate)) enum { ILIWI_NETWORK_DUMMY_PROPERTY }; gboolean iliwi_network_valid_network (iliwiNetwork* self); gchar* iliwi_network_pretty_string (iliwiNetwork* self); iliwiNetworkStatus iliwi_network_get_status (iliwiNetwork* self); gchar* iliwi_network_get_title (iliwiNetwork* self); void iliwi_network_set_new_status (iliwiNetwork* self, iliwiNetworkStatus _status); static void iliwi_network_set_status (iliwiNetwork* self, iliwiNetworkStatus value); static void iliwi_network_update_view (iliwiNetwork* self); void iliwi_network_set_strength (iliwiNetwork* self, gint i, gboolean update_list); void iliwi_network_set_encyption_to_wpa (iliwiNetwork* self); static void iliwi_network_set_wpa_encryption (iliwiNetwork* self, gboolean value); iliwiNetwork* iliwi_network_new (void); iliwiNetwork* iliwi_network_construct (GType object_type); gboolean iliwi_network_get_wpa_encryption (iliwiNetwork* self); static void iliwi_network_finalize (iliwiNetwork* obj); #define ILIWI_TIMEOUT_SECONDS 2 #define ILIWI_ZERO_NETWORKS_SCAN_SECONDS 4 #define ILIWI_NONZERO_NETWORKS_SCAN_SECONDS 20 #define ILIWI_CONNECTED_SCAN_SECONDS 300 GType iliwi_wifi_thread_get_type (void) G_GNUC_CONST; enum { ILIWI_WIFI_THREAD_DUMMY_PROPERTY }; GType usage_proxy_get_type (void) G_GNUC_CONST; guint usage_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); GType usage_get_type (void) G_GNUC_CONST; static void iliwi_wifi_thread_initialize (void); static gboolean __lambda0_ (void); static void iliwi_wifi_thread_scan (void); static iliwiNetwork* iliwi_wifi_thread_suggest_network (void); static void iliwi_wifi_thread_run_dhcp (void); static gboolean ___lambda0__gsource_func (gpointer self); void usage_ReleaseResource (Usage* self, const gchar* resource, GError** error); static void iliwi_wifi_thread_save_preferred_networks (void); static void iliwi_wifi_thread_disconnectt (void); void usage_RequestResource (Usage* self, const gchar* resource, GError** error); static void iliwi_wifi_thread_load_preferred_networks (void); static void iliwi_wifi_thread_parse_iwlist_networks (const gchar* iwlist_result); static void iliwi_wifi_thread_found_network (iliwiNetwork* network); static void iliwi_wifi_thread_connect_to_suggestion (iliwiNetwork* network); iliwiWifiThread* iliwi_wifi_thread_new (void); iliwiWifiThread* iliwi_wifi_thread_construct (GType object_type); static void iliwi_wifi_thread_finalize (GObject* obj); static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func); static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func); static gint _vala_array_length (gpointer array); static gpointer _iliwi_wifi_thread_run_thread_gthread_func (gpointer self) { gpointer result; result = iliwi_wifi_thread_run_thread (); return result; } iliwiWifi* iliwi_wifi_construct (GType object_type) { iliwiWifi * self = NULL; GError * _inner_error_ = NULL; self = (iliwiWifi*) g_object_new (object_type, NULL); { GThread* _tmp0_ = NULL; GThread* _tmp1_; _tmp0_ = g_thread_create (_iliwi_wifi_thread_run_thread_gthread_func, NULL, TRUE, &_inner_error_); _tmp1_ = _tmp0_; if (_inner_error_ != NULL) { goto __catch2_g_error; } self->priv->thread = _tmp1_; } goto __finally2; __catch2_g_error: { GError* e = NULL; e = _inner_error_; _inner_error_ = NULL; g_critical ("wifi.vala:34: Couldn't start wifi-thread!"); _g_error_free0 (e); } __finally2: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } return self; } iliwiWifi* iliwi_wifi_new (void) { return iliwi_wifi_construct (ILIWI_TYPE_WIFI); } iliwiNetwork** iliwi_wifi_get_visible_networks (iliwiWifi* self, int* result_length1) { iliwiNetwork** result = NULL; gint _tmp0_ = 0; iliwiNetwork** _tmp1_ = NULL; iliwiNetwork** _tmp2_; gint _tmp2__length1; g_return_val_if_fail (self != NULL, NULL); _tmp1_ = iliwi_wifi_thread_get_visible_networks (&_tmp0_); _tmp2_ = _tmp1_; _tmp2__length1 = _tmp0_; if (result_length1) { *result_length1 = _tmp2__length1; } result = _tmp2_; return result; } void iliwi_wifi_connect_to (iliwiWifi* self, iliwiNetwork* network) { iliwiNetwork* _tmp0_; g_return_if_fail (self != NULL); g_return_if_fail (network != NULL); _tmp0_ = network; iliwi_wifi_thread_connect_to_network (_tmp0_); } void iliwi_wifi_set_preferred_state (iliwiWifi* self, iliwiNetwork* network, gboolean new_state) { iliwiNetwork* _tmp0_; gboolean _tmp1_; iliwiNetwork* _tmp2_; g_return_if_fail (self != NULL); g_return_if_fail (network != NULL); _tmp0_ = network; _tmp1_ = new_state; _tmp0_->preferred_network = _tmp1_; _tmp2_ = network; iliwi_wifi_thread_preferred_state_change (_tmp2_); } void iliwi_wifi_set_ascii_state (iliwiWifi* self, iliwiNetwork* network, gboolean new_state) { iliwiNetwork* _tmp0_; gboolean _tmp1_; iliwiNetwork* _tmp2_; g_return_if_fail (self != NULL); g_return_if_fail (network != NULL); _tmp0_ = network; _tmp1_ = new_state; _tmp0_->password_in_ascii = _tmp1_; _tmp2_ = network; iliwi_wifi_thread_preferred_state_change (_tmp2_); } void iliwi_wifi_preferred_network_password_change (iliwiWifi* self, iliwiNetwork* network) { iliwiNetwork* _tmp0_; g_return_if_fail (self != NULL); g_return_if_fail (network != NULL); _tmp0_ = network; iliwi_wifi_thread_preferred_state_change (_tmp0_); } void iliwi_wifi_preferred_network_username_change (iliwiWifi* self, iliwiNetwork* network) { iliwiNetwork* _tmp0_; g_return_if_fail (self != NULL); g_return_if_fail (network != NULL); _tmp0_ = network; iliwi_wifi_thread_preferred_state_change (_tmp0_); } void iliwi_wifi_preferred_network_certificate_change (iliwiWifi* self, iliwiNetwork* network) { iliwiNetwork* _tmp0_; g_return_if_fail (self != NULL); g_return_if_fail (network != NULL); _tmp0_ = network; iliwi_wifi_thread_preferred_state_change (_tmp0_); } void iliwi_wifi_set_new_status (iliwiWifi* self, const gchar* new_status) { const gchar* _tmp0_; g_return_if_fail (self != NULL); g_return_if_fail (new_status != NULL); _tmp0_ = new_status; iliwi_wifi_set_status (self, _tmp0_); g_signal_emit_by_name (self, "status-change"); } void iliwi_wifi_visible_network_change (iliwiWifi* self) { g_return_if_fail (self != NULL); g_signal_emit_by_name (self, "network-list-change"); } const gchar* iliwi_wifi_get_status (iliwiWifi* self) { const gchar* result; const gchar* _tmp0_; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = self->priv->_status; result = _tmp0_; return result; } static void iliwi_wifi_set_status (iliwiWifi* self, const gchar* value) { const gchar* _tmp0_; gchar* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = value; _tmp1_ = g_strdup (_tmp0_); _g_free0 (self->priv->_status); self->priv->_status = _tmp1_; g_object_notify ((GObject *) self, "status"); } static void iliwi_wifi_class_init (iliwiWifiClass * klass) { iliwi_wifi_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (iliwiWifiPrivate)); G_OBJECT_CLASS (klass)->get_property = _vala_iliwi_wifi_get_property; G_OBJECT_CLASS (klass)->set_property = _vala_iliwi_wifi_set_property; G_OBJECT_CLASS (klass)->finalize = iliwi_wifi_finalize; g_object_class_install_property (G_OBJECT_CLASS (klass), ILIWI_WIFI_STATUS, g_param_spec_string ("status", "status", "status", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); g_signal_new ("status_change", ILIWI_TYPE_WIFI, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); g_signal_new ("network_list_change", ILIWI_TYPE_WIFI, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); } static void iliwi_wifi_instance_init (iliwiWifi * self) { gchar* _tmp0_; self->priv = ILIWI_WIFI_GET_PRIVATE (self); _tmp0_ = g_strdup ("initializing"); self->priv->_status = _tmp0_; } static void iliwi_wifi_finalize (GObject* obj) { iliwiWifi * self; GThread* _tmp0_; self = ILIWI_WIFI (obj); iliwi_wifi_thread_stop_thread (); _tmp0_ = self->priv->thread; g_thread_join (_tmp0_); _g_free0 (self->priv->_status); G_OBJECT_CLASS (iliwi_wifi_parent_class)->finalize (obj); } GType iliwi_wifi_get_type (void) { static volatile gsize iliwi_wifi_type_id__volatile = 0; if (g_once_init_enter (&iliwi_wifi_type_id__volatile)) { static const GTypeInfo g_define_type_info = { sizeof (iliwiWifiClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) iliwi_wifi_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (iliwiWifi), 0, (GInstanceInitFunc) iliwi_wifi_instance_init, NULL }; GType iliwi_wifi_type_id; iliwi_wifi_type_id = g_type_register_static (G_TYPE_OBJECT, "iliwiWifi", &g_define_type_info, 0); g_once_init_leave (&iliwi_wifi_type_id__volatile, iliwi_wifi_type_id); } return iliwi_wifi_type_id__volatile; } static void _vala_iliwi_wifi_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { iliwiWifi * self; self = ILIWI_WIFI (object); switch (property_id) { case ILIWI_WIFI_STATUS: g_value_set_string (value, iliwi_wifi_get_status (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void _vala_iliwi_wifi_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { iliwiWifi * self; self = ILIWI_WIFI (object); switch (property_id) { case ILIWI_WIFI_STATUS: iliwi_wifi_set_status (self, g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } GType iliwi_network_status_get_type (void) { static volatile gsize iliwi_network_status_type_id__volatile = 0; if (g_once_init_enter (&iliwi_network_status_type_id__volatile)) { static const GEnumValue values[] = {{ILIWI_NETWORK_STATUS_UNCONNECTED, "ILIWI_NETWORK_STATUS_UNCONNECTED", "unconnected"}, {ILIWI_NETWORK_STATUS_CONNECT, "ILIWI_NETWORK_STATUS_CONNECT", "connect"}, {ILIWI_NETWORK_STATUS_CONNECTING, "ILIWI_NETWORK_STATUS_CONNECTING", "connecting"}, {ILIWI_NETWORK_STATUS_CONNECTED, "ILIWI_NETWORK_STATUS_CONNECTED", "connected"}, {0, NULL, NULL}}; GType iliwi_network_status_type_id; iliwi_network_status_type_id = g_enum_register_static ("iliwiNetworkStatus", values); g_once_init_leave (&iliwi_network_status_type_id__volatile, iliwi_network_status_type_id); } return iliwi_network_status_type_id__volatile; } void iliwi_preferred_network_copy (const iliwiPreferredNetwork* self, iliwiPreferredNetwork* dest) { const gchar* _tmp0_; gchar* _tmp1_; gboolean _tmp2_; const gchar* _tmp3_; gchar* _tmp4_; const gchar* _tmp5_; gchar* _tmp6_; const gchar* _tmp7_; gchar* _tmp8_; _tmp0_ = (*self).password; _tmp1_ = g_strdup (_tmp0_); _g_free0 ((*dest).password); (*dest).password = _tmp1_; _tmp2_ = (*self).password_in_ascii; (*dest).password_in_ascii = _tmp2_; _tmp3_ = (*self).username; _tmp4_ = g_strdup (_tmp3_); _g_free0 ((*dest).username); (*dest).username = _tmp4_; _tmp5_ = (*self).cert; _tmp6_ = g_strdup (_tmp5_); _g_free0 ((*dest).cert); (*dest).cert = _tmp6_; _tmp7_ = (*self).cert_dir; _tmp8_ = g_strdup (_tmp7_); _g_free0 ((*dest).cert_dir); (*dest).cert_dir = _tmp8_; } void iliwi_preferred_network_destroy (iliwiPreferredNetwork* self) { _g_free0 ((*self).password); _g_free0 ((*self).username); _g_free0 ((*self).cert); _g_free0 ((*self).cert_dir); } iliwiPreferredNetwork* iliwi_preferred_network_dup (const iliwiPreferredNetwork* self) { iliwiPreferredNetwork* dup; dup = g_new0 (iliwiPreferredNetwork, 1); iliwi_preferred_network_copy (self, dup); return dup; } void iliwi_preferred_network_free (iliwiPreferredNetwork* self) { iliwi_preferred_network_destroy (self); g_free (self); } GType iliwi_preferred_network_get_type (void) { static volatile gsize iliwi_preferred_network_type_id__volatile = 0; if (g_once_init_enter (&iliwi_preferred_network_type_id__volatile)) { GType iliwi_preferred_network_type_id; iliwi_preferred_network_type_id = g_boxed_type_register_static ("iliwiPreferredNetwork", (GBoxedCopyFunc) iliwi_preferred_network_dup, (GBoxedFreeFunc) iliwi_preferred_network_free); g_once_init_leave (&iliwi_preferred_network_type_id__volatile, iliwi_preferred_network_type_id); } return iliwi_preferred_network_type_id__volatile; } gboolean iliwi_network_valid_network (iliwiNetwork* self) { gboolean result = FALSE; const gchar* _tmp0_; g_return_val_if_fail (self != NULL, FALSE); _tmp0_ = self->address; result = _tmp0_ != NULL; return result; } gchar* iliwi_network_pretty_string (iliwiNetwork* self) { gchar* result = NULL; gchar* _tmp0_; gchar* info_str; gboolean _tmp1_ = FALSE; gboolean _tmp2_; gboolean _tmp4_; gboolean _tmp11_; gchar* _tmp14_; gchar* status_str; iliwiNetworkStatus _tmp15_; const gchar* _tmp19_; gint _tmp20_; const gchar* _tmp21_; const gchar* _tmp22_; gchar* _tmp23_ = NULL; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = g_strdup (""); info_str = _tmp0_; _tmp2_ = self->encryption; if (_tmp2_) { gboolean _tmp3_; _tmp3_ = self->authentication; _tmp1_ = !_tmp3_; } else { _tmp1_ = FALSE; } _tmp4_ = _tmp1_; if (_tmp4_) { gchar* _tmp5_; _tmp5_ = g_strdup ("(enc)"); _g_free0 (info_str); info_str = _tmp5_; } else { gboolean _tmp6_ = FALSE; gboolean _tmp7_; gboolean _tmp9_; _tmp7_ = self->encryption; if (_tmp7_) { gboolean _tmp8_; _tmp8_ = self->authentication; _tmp6_ = _tmp8_; } else { _tmp6_ = FALSE; } _tmp9_ = _tmp6_; if (_tmp9_) { gchar* _tmp10_; _tmp10_ = g_strdup ("(enc+auth)"); _g_free0 (info_str); info_str = _tmp10_; } } _tmp11_ = self->adhoc; if (_tmp11_) { const gchar* _tmp12_; gchar* _tmp13_; _tmp12_ = info_str; _tmp13_ = g_strconcat (_tmp12_, "~", NULL); _g_free0 (info_str); info_str = _tmp13_; } _tmp14_ = g_strdup (""); status_str = _tmp14_; _tmp15_ = self->priv->_status; if (_tmp15_ == ILIWI_NETWORK_STATUS_CONNECTING) { gchar* _tmp16_; _tmp16_ = g_strdup ("CONNECTING "); _g_free0 (status_str); status_str = _tmp16_; } else { iliwiNetworkStatus _tmp17_; _tmp17_ = self->priv->_status; if (_tmp17_ == ILIWI_NETWORK_STATUS_CONNECTED) { gchar* _tmp18_; _tmp18_ = g_strdup ("CONNECTED "); _g_free0 (status_str); status_str = _tmp18_; } } _tmp19_ = status_str; _tmp20_ = self->strength; _tmp21_ = info_str; _tmp22_ = self->essid; _tmp23_ = g_strdup_printf ("%s%i%% %s %s", _tmp19_, _tmp20_, _tmp21_, _tmp22_); result = _tmp23_; _g_free0 (status_str); _g_free0 (info_str); return result; } gchar* iliwi_network_get_title (iliwiNetwork* self) { gchar* result = NULL; const gchar* _tmp0_; gchar* _tmp1_; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = self->essid; _tmp1_ = g_strdup (_tmp0_); result = _tmp1_; return result; } void iliwi_network_set_new_status (iliwiNetwork* self, iliwiNetworkStatus _status) { iliwiNetworkStatus _tmp0_; g_return_if_fail (self != NULL); _tmp0_ = _status; iliwi_network_set_status (self, _tmp0_); iliwi_network_update_view (self); } void iliwi_network_set_strength (iliwiNetwork* self, gint i, gboolean update_list) { gint _tmp0_; gboolean _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = i; self->strength = _tmp0_; _tmp1_ = update_list; if (_tmp1_) { iliwi_network_update_view (self); } } void iliwi_network_set_encyption_to_wpa (iliwiNetwork* self) { g_return_if_fail (self != NULL); iliwi_network_set_wpa_encryption (self, TRUE); } static void iliwi_network_update_view (iliwiNetwork* self) { Elm_Genlist_Item* _tmp0_; g_return_if_fail (self != NULL); _tmp0_ = self->listitem; if (_tmp0_ != NULL) { Elm_Genlist_Item* _tmp1_; _tmp1_ = self->listitem; elm_genlist_item_update (_tmp1_); } } iliwiNetwork* iliwi_network_construct (GType object_type) { iliwiNetwork* self = NULL; self = (iliwiNetwork*) g_type_create_instance (object_type); return self; } iliwiNetwork* iliwi_network_new (void) { return iliwi_network_construct (ILIWI_TYPE_NETWORK); } gboolean iliwi_network_get_wpa_encryption (iliwiNetwork* self) { gboolean result; gboolean _tmp0_; g_return_val_if_fail (self != NULL, FALSE); _tmp0_ = self->priv->_wpa_encryption; result = _tmp0_; return result; } static void iliwi_network_set_wpa_encryption (iliwiNetwork* self, gboolean value) { gboolean _tmp0_; g_return_if_fail (self != NULL); _tmp0_ = value; self->priv->_wpa_encryption = _tmp0_; } iliwiNetworkStatus iliwi_network_get_status (iliwiNetwork* self) { iliwiNetworkStatus result; iliwiNetworkStatus _tmp0_; g_return_val_if_fail (self != NULL, 0); _tmp0_ = self->priv->_status; result = _tmp0_; return result; } static void iliwi_network_set_status (iliwiNetwork* self, iliwiNetworkStatus value) { iliwiNetworkStatus _tmp0_; g_return_if_fail (self != NULL); _tmp0_ = value; self->priv->_status = _tmp0_; } static void iliwi_value_network_init (GValue* value) { value->data[0].v_pointer = NULL; } static void iliwi_value_network_free_value (GValue* value) { if (value->data[0].v_pointer) { iliwi_network_unref (value->data[0].v_pointer); } } static void iliwi_value_network_copy_value (const GValue* src_value, GValue* dest_value) { if (src_value->data[0].v_pointer) { dest_value->data[0].v_pointer = iliwi_network_ref (src_value->data[0].v_pointer); } else { dest_value->data[0].v_pointer = NULL; } } static gpointer iliwi_value_network_peek_pointer (const GValue* value) { return value->data[0].v_pointer; } static gchar* iliwi_value_network_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { if (collect_values[0].v_pointer) { iliwiNetwork* object; object = collect_values[0].v_pointer; if (object->parent_instance.g_class == NULL) { return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL); } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) { return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL); } value->data[0].v_pointer = iliwi_network_ref (object); } else { value->data[0].v_pointer = NULL; } return NULL; } static gchar* iliwi_value_network_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { iliwiNetwork** object_p; object_p = collect_values[0].v_pointer; if (!object_p) { return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value)); } if (!value->data[0].v_pointer) { *object_p = NULL; } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) { *object_p = value->data[0].v_pointer; } else { *object_p = iliwi_network_ref (value->data[0].v_pointer); } return NULL; } GParamSpec* iliwi_param_spec_network (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) { iliwiParamSpecNetwork* spec; g_return_val_if_fail (g_type_is_a (object_type, ILIWI_TYPE_NETWORK), NULL); spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags); G_PARAM_SPEC (spec)->value_type = object_type; return G_PARAM_SPEC (spec); } gpointer iliwi_value_get_network (const GValue* value) { g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, ILIWI_TYPE_NETWORK), NULL); return value->data[0].v_pointer; } void iliwi_value_set_network (GValue* value, gpointer v_object) { iliwiNetwork* old; g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, ILIWI_TYPE_NETWORK)); old = value->data[0].v_pointer; if (v_object) { g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, ILIWI_TYPE_NETWORK)); g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value))); value->data[0].v_pointer = v_object; iliwi_network_ref (value->data[0].v_pointer); } else { value->data[0].v_pointer = NULL; } if (old) { iliwi_network_unref (old); } } void iliwi_value_take_network (GValue* value, gpointer v_object) { iliwiNetwork* old; g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, ILIWI_TYPE_NETWORK)); old = value->data[0].v_pointer; if (v_object) { g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, ILIWI_TYPE_NETWORK)); g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value))); value->data[0].v_pointer = v_object; } else { value->data[0].v_pointer = NULL; } if (old) { iliwi_network_unref (old); } } static void iliwi_network_class_init (iliwiNetworkClass * klass) { iliwi_network_parent_class = g_type_class_peek_parent (klass); ILIWI_NETWORK_CLASS (klass)->finalize = iliwi_network_finalize; g_type_class_add_private (klass, sizeof (iliwiNetworkPrivate)); } static void iliwi_network_instance_init (iliwiNetwork * self) { gchar* _tmp0_; gchar* _tmp1_; gchar* _tmp2_; gchar* _tmp3_; gchar* _tmp4_; self->priv = ILIWI_NETWORK_GET_PRIVATE (self); _tmp0_ = g_strdup (""); self->essid = _tmp0_; self->encryption = FALSE; self->authentication = FALSE; self->priv->_wpa_encryption = FALSE; self->adhoc = FALSE; _tmp1_ = g_strdup (""); self->password = _tmp1_; _tmp2_ = g_strdup (""); self->username = _tmp2_; _tmp3_ = g_strdup (""); self->cert = _tmp3_; _tmp4_ = g_strdup (""); self->cert_dir = _tmp4_; self->password_in_ascii = TRUE; self->strength = 0; self->unsaved = TRUE; self->visible = FALSE; self->preferred_network = FALSE; self->listitem = NULL; self->priv->_status = ILIWI_NETWORK_STATUS_UNCONNECTED; self->ref_count = 1; } static void iliwi_network_finalize (iliwiNetwork* obj) { iliwiNetwork * self; self = ILIWI_NETWORK (obj); _g_free0 (self->address); _g_free0 (self->essid); _g_free0 (self->password); _g_free0 (self->username); _g_free0 (self->cert); _g_free0 (self->cert_dir); } GType iliwi_network_get_type (void) { static volatile gsize iliwi_network_type_id__volatile = 0; if (g_once_init_enter (&iliwi_network_type_id__volatile)) { static const GTypeValueTable g_define_type_value_table = { iliwi_value_network_init, iliwi_value_network_free_value, iliwi_value_network_copy_value, iliwi_value_network_peek_pointer, "p", iliwi_value_network_collect_value, "p", iliwi_value_network_lcopy_value }; static const GTypeInfo g_define_type_info = { sizeof (iliwiNetworkClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) iliwi_network_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (iliwiNetwork), 0, (GInstanceInitFunc) iliwi_network_instance_init, &g_define_type_value_table }; static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) }; GType iliwi_network_type_id; iliwi_network_type_id = g_type_register_fundamental (g_type_fundamental_next (), "iliwiNetwork", &g_define_type_info, &g_define_type_fundamental_info, 0); g_once_init_leave (&iliwi_network_type_id__volatile, iliwi_network_type_id); } return iliwi_network_type_id__volatile; } gpointer iliwi_network_ref (gpointer instance) { iliwiNetwork* self; self = instance; g_atomic_int_inc (&self->ref_count); return instance; } void iliwi_network_unref (gpointer instance) { iliwiNetwork* self; self = instance; if (g_atomic_int_dec_and_test (&self->ref_count)) { ILIWI_NETWORK_GET_CLASS (self)->finalize (self); g_type_free_instance ((GTypeInstance *) self); } } static gboolean __lambda0_ (void) { gboolean result = FALSE; iliwiNetworkStatus _tmp0_; iliwiNetworkStatus _tmp17_; gint _tmp18_; _tmp0_ = iliwi_wifi_thread_status; if (_tmp0_ == ILIWI_NETWORK_STATUS_UNCONNECTED) { gboolean _tmp1_ = FALSE; GeeHashMap* _tmp2_; gint _tmp3_; gint _tmp4_; gboolean _tmp6_; iliwiNetwork* _tmp13_ = NULL; iliwiNetwork* suggestion; iliwiNetwork* _tmp14_; _tmp2_ = iliwi_wifi_thread_networks; _tmp3_ = gee_abstract_map_get_size ((GeeMap*) _tmp2_); _tmp4_ = _tmp3_; if (_tmp4_ == 0) { gint _tmp5_; _tmp5_ = iliwi_wifi_thread_seconds_since_last_scan; _tmp1_ = _tmp5_ >= ILIWI_ZERO_NETWORKS_SCAN_SECONDS; } else { _tmp1_ = FALSE; } _tmp6_ = _tmp1_; if (_tmp6_) { iliwi_wifi_thread_scan (); } else { gboolean _tmp7_ = FALSE; GeeHashMap* _tmp8_; gint _tmp9_; gint _tmp10_; gboolean _tmp12_; _tmp8_ = iliwi_wifi_thread_networks; _tmp9_ = gee_abstract_map_get_size ((GeeMap*) _tmp8_); _tmp10_ = _tmp9_; if (_tmp10_ > 0) { gint _tmp11_; _tmp11_ = iliwi_wifi_thread_seconds_since_last_scan; _tmp7_ = _tmp11_ >= ILIWI_NONZERO_NETWORKS_SCAN_SECONDS; } else { _tmp7_ = FALSE; } _tmp12_ = _tmp7_; if (_tmp12_) { iliwi_wifi_thread_scan (); } } _tmp13_ = iliwi_wifi_thread_suggest_network (); suggestion = _tmp13_; _tmp14_ = suggestion; if (_tmp14_ != NULL) { iliwiNetwork* _tmp15_; _tmp15_ = suggestion; iliwi_wifi_thread_connect_to_network (_tmp15_); } } else { gint _tmp16_; _tmp16_ = iliwi_wifi_thread_seconds_since_last_scan; if (_tmp16_ >= ILIWI_CONNECTED_SCAN_SECONDS) { iliwi_wifi_thread_scan (); } } _tmp17_ = iliwi_wifi_thread_status; if (_tmp17_ == ILIWI_NETWORK_STATUS_CONNECT) { iliwi_wifi_thread_run_dhcp (); } _tmp18_ = iliwi_wifi_thread_seconds_since_last_scan; iliwi_wifi_thread_seconds_since_last_scan = _tmp18_ + ILIWI_TIMEOUT_SECONDS; result = TRUE; return result; } static gboolean ___lambda0__gsource_func (gpointer self) { gboolean result; result = __lambda0_ (); return result; } void* iliwi_wifi_thread_run_thread (void) { void* result = NULL; GMainLoop* _tmp0_; GSource* _tmp1_; GSource* time; GSource* _tmp2_; GSource* _tmp3_; GMainLoop* _tmp4_; GMainContext* _tmp5_ = NULL; GMainLoop* _tmp6_; GError * _inner_error_ = NULL; _tmp0_ = g_main_loop_new (NULL, FALSE); _g_main_loop_unref0 (iliwi_wifi_thread_loop); iliwi_wifi_thread_loop = _tmp0_; iliwi_wifi_thread_initialize (); _tmp1_ = g_timeout_source_new_seconds ((guint) ILIWI_TIMEOUT_SECONDS); time = _tmp1_; _tmp2_ = time; g_source_set_callback (_tmp2_, ___lambda0__gsource_func, NULL, NULL); _tmp3_ = time; _tmp4_ = iliwi_wifi_thread_loop; _tmp5_ = g_main_loop_get_context (_tmp4_); g_source_attach (_tmp3_, _tmp5_); _tmp6_ = iliwi_wifi_thread_loop; g_main_loop_run (_tmp6_); _g_source_unref0 (time); time = NULL; { Usage* _tmp7_; Usage* _tmp8_; _tmp7_ = iliwi_wifi_thread_fso_usage; usage_ReleaseResource (_tmp7_, "WiFi", &_inner_error_); if (_inner_error_ != NULL) { goto __catch3_g_error; } _tmp8_ = iliwi_wifi_thread_fso_usage; usage_ReleaseResource (_tmp8_, "CPU", &_inner_error_); if (_inner_error_ != NULL) { goto __catch3_g_error; } } goto __finally3; __catch3_g_error: { GError* e = NULL; e = _inner_error_; _inner_error_ = NULL; _g_error_free0 (e); } __finally3: if (_inner_error_ != NULL) { _g_source_unref0 (time); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } iliwi_wifi_thread_save_preferred_networks (); result = NULL; _g_source_unref0 (time); return result; } void iliwi_wifi_thread_stop_thread (void) { GMainLoop* _tmp0_; _tmp0_ = iliwi_wifi_thread_loop; g_main_loop_quit (_tmp0_); } iliwiNetwork** iliwi_wifi_thread_get_visible_networks (int* result_length1) { iliwiNetwork** result = NULL; gint a = 0; GeeArrayList* _tmp0_; gint _tmp1_; gint _tmp2_; iliwiNetwork** _tmp3_ = NULL; iliwiNetwork** n; gint n_length1; gint _n_size_; gint b = 0; GeeArrayList* _tmp4_; gint c = 0; iliwiNetwork** _tmp21_; gint _tmp21__length1; GError * _inner_error_ = NULL; _tmp0_ = iliwi_wifi_thread_visible_networks; _tmp1_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp0_); _tmp2_ = _tmp1_; _tmp3_ = g_new0 (iliwiNetwork*, _tmp2_ + 1); n = _tmp3_; n_length1 = _tmp2_; _n_size_ = n_length1; _tmp4_ = iliwi_wifi_thread_visible_networks; if (_tmp4_ == NULL) { FILE* _tmp5_; _tmp5_ = stderr; fprintf (_tmp5_, "null\n"); } { GeeArrayList* _tmp6_; _tmp6_ = iliwi_wifi_thread_visible_networks; g_static_rec_mutex_lock (&__lock_iliwi_wifi_thread_visible_networks); { { gint i; i = 0; { gboolean _tmp7_; _tmp7_ = TRUE; while (TRUE) { gboolean _tmp8_; gint _tmp10_; GeeArrayList* _tmp11_; gint _tmp12_; gint _tmp13_; iliwiNetwork** _tmp14_; gint _tmp14__length1; gint _tmp15_; GeeArrayList* _tmp16_; gint _tmp17_; gpointer _tmp18_ = NULL; iliwiNetwork* _tmp19_; _tmp8_ = _tmp7_; if (!_tmp8_) { gint _tmp9_; _tmp9_ = i; i = _tmp9_ + 1; } _tmp7_ = FALSE; _tmp10_ = i; _tmp11_ = iliwi_wifi_thread_visible_networks; _tmp12_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp11_); _tmp13_ = _tmp12_; if (!(_tmp10_ < _tmp13_)) { break; } _tmp14_ = n; _tmp14__length1 = n_length1; _tmp15_ = i; _tmp16_ = iliwi_wifi_thread_visible_networks; _tmp17_ = i; _tmp18_ = gee_abstract_list_get ((GeeAbstractList*) _tmp16_, _tmp17_); _iliwi_network_unref0 (_tmp14_[_tmp15_]); _tmp14_[_tmp15_] = (iliwiNetwork*) _tmp18_; _tmp19_ = _tmp14_[_tmp15_]; } } } } __finally4: { GeeArrayList* _tmp20_; _tmp20_ = iliwi_wifi_thread_visible_networks; g_static_rec_mutex_unlock (&__lock_iliwi_wifi_thread_visible_networks); } if (_inner_error_ != NULL) { n = (_vala_array_free (n, n_length1, (GDestroyNotify) iliwi_network_unref), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } _tmp21_ = n; _tmp21__length1 = n_length1; if (result_length1) { *result_length1 = _tmp21__length1; } result = _tmp21_; return result; } void iliwi_wifi_thread_preferred_state_change (iliwiNetwork* network) { iliwiNetwork* _tmp0_; gboolean _tmp1_; g_return_if_fail (network != NULL); _tmp0_ = network; _tmp1_ = _tmp0_->preferred_network; if (_tmp1_) { GeeHashMap* _tmp2_; iliwiNetwork* _tmp3_; const gchar* _tmp4_; iliwiNetwork* _tmp5_; const gchar* _tmp6_; gchar* _tmp7_; iliwiNetwork* _tmp8_; gboolean _tmp9_; iliwiNetwork* _tmp10_; const gchar* _tmp11_; gchar* _tmp12_; iliwiNetwork* _tmp13_; const gchar* _tmp14_; gchar* _tmp15_; iliwiNetwork* _tmp16_; const gchar* _tmp17_; gchar* _tmp18_; iliwiPreferredNetwork _tmp19_ = {0}; iliwiPreferredNetwork _tmp20_; iliwiPreferredNetwork _tmp21_; _tmp2_ = iliwi_wifi_thread_preferred_networks; _tmp3_ = network; _tmp4_ = _tmp3_->address; _tmp5_ = network; _tmp6_ = _tmp5_->password; _tmp7_ = g_strdup (_tmp6_); _tmp8_ = network; _tmp9_ = _tmp8_->password_in_ascii; _tmp10_ = network; _tmp11_ = _tmp10_->username; _tmp12_ = g_strdup (_tmp11_); _tmp13_ = network; _tmp14_ = _tmp13_->cert; _tmp15_ = g_strdup (_tmp14_); _tmp16_ = network; _tmp17_ = _tmp16_->cert_dir; _tmp18_ = g_strdup (_tmp17_); memset (&_tmp19_, 0, sizeof (iliwiPreferredNetwork)); _g_free0 (_tmp19_.password); _tmp19_.password = _tmp7_; _tmp19_.password_in_ascii = _tmp9_; _g_free0 (_tmp19_.username); _tmp19_.username = _tmp12_; _g_free0 (_tmp19_.cert); _tmp19_.cert = _tmp15_; _g_free0 (_tmp19_.cert_dir); _tmp19_.cert_dir = _tmp18_; _tmp20_ = _tmp19_; _tmp21_ = _tmp20_; gee_abstract_map_set ((GeeAbstractMap*) _tmp2_, _tmp4_, &_tmp21_); iliwi_preferred_network_destroy (&_tmp20_); } else { GeeHashMap* _tmp22_; iliwiNetwork* _tmp23_; const gchar* _tmp24_; gboolean _tmp25_ = FALSE; _tmp22_ = iliwi_wifi_thread_preferred_networks; _tmp23_ = network; _tmp24_ = _tmp23_->address; _tmp25_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp22_, _tmp24_); if (_tmp25_) { GeeHashMap* _tmp26_; iliwiNetwork* _tmp27_; const gchar* _tmp28_; _tmp26_ = iliwi_wifi_thread_preferred_networks; _tmp27_ = network; _tmp28_ = _tmp27_->address; gee_abstract_map_unset ((GeeAbstractMap*) _tmp26_, _tmp28_, NULL); } } } void iliwi_wifi_thread_connect_to_network (iliwiNetwork* network) { iliwiWifi* _tmp0_; iliwiNetwork* _tmp1_; iliwiNetwork* _tmp2_; const gchar* _tmp3_ = NULL; gchar* _tmp4_; gchar* _tmp5_; const gchar* _tmp6_ = NULL; gchar* _tmp7_; gchar* filename; iliwiNetwork* _tmp8_; const gchar* _tmp9_; gchar* _tmp10_; gchar* password; iliwiNetwork* _tmp11_; gboolean _tmp12_; const gchar* _tmp18_; FILE* _tmp19_ = NULL; FILE* stream; FILE* _tmp20_; iliwiNetwork* _tmp21_; gboolean _tmp22_; FILE* _tmp24_; FILE* _tmp25_; iliwiNetwork* _tmp26_; const gchar* _tmp27_; gchar* _tmp28_ = NULL; gchar* _tmp29_; iliwiNetwork* _tmp30_; gboolean _tmp31_; iliwiNetwork* _tmp87_; gboolean _tmp88_; FILE* _tmp90_; FILE* _tmp91_; GError * _inner_error_ = NULL; g_return_if_fail (network != NULL); iliwi_wifi_thread_disconnectt (); _tmp0_ = iliwi_wifi; iliwi_wifi_set_new_status (_tmp0_, "connecting.."); _tmp1_ = network; iliwi_wifi_thread_connect_network = _tmp1_; _tmp2_ = network; iliwi_network_set_new_status (_tmp2_, ILIWI_NETWORK_STATUS_CONNECTING); _tmp3_ = g_get_user_config_dir (); _tmp4_ = g_strconcat (_tmp3_, "/iliwi", NULL); _tmp5_ = _tmp4_; g_mkdir_with_parents (_tmp5_, 0755); _g_free0 (_tmp5_); _tmp6_ = g_get_user_config_dir (); _tmp7_ = g_strconcat (_tmp6_, "/iliwi/wpa_supplicant.conf", NULL); filename = _tmp7_; _tmp8_ = network; _tmp9_ = _tmp8_->password; _tmp10_ = g_strdup (_tmp9_); password = _tmp10_; _tmp11_ = network; _tmp12_ = _tmp11_->password_in_ascii; if (_tmp12_) { iliwiNetwork* _tmp13_; const gchar* _tmp14_; gchar* _tmp15_; gchar* _tmp16_; gchar* _tmp17_; _tmp13_ = network; _tmp14_ = _tmp13_->password; _tmp15_ = g_strconcat ("\"", _tmp14_, NULL); _tmp16_ = _tmp15_; _tmp17_ = g_strconcat (_tmp16_, "\"", NULL); _g_free0 (password); password = _tmp17_; _g_free0 (_tmp16_); } _tmp18_ = filename; _tmp19_ = fopen (_tmp18_, "w"); stream = _tmp19_; _tmp20_ = stream; fputs ("ctrl_interface=/var/run/wpa_supplicant\n", _tmp20_); _tmp21_ = network; _tmp22_ = _tmp21_->adhoc; if (_tmp22_) { FILE* _tmp23_; _tmp23_ = stream; fputs ("ap_scan=2\n", _tmp23_); } _tmp24_ = stream; fputs ("network={\n", _tmp24_); _tmp25_ = stream; _tmp26_ = network; _tmp27_ = _tmp26_->essid; _tmp28_ = g_strdup_printf (" ssid=\"%s\"\n", _tmp27_); _tmp29_ = _tmp28_; fputs (_tmp29_, _tmp25_); _g_free0 (_tmp29_); _tmp30_ = network; _tmp31_ = _tmp30_->encryption; if (_tmp31_) { gboolean _tmp32_ = FALSE; iliwiNetwork* _tmp33_; gboolean _tmp34_; gboolean _tmp35_; gboolean _tmp38_; _tmp33_ = network; _tmp34_ = iliwi_network_get_wpa_encryption (_tmp33_); _tmp35_ = _tmp34_; if (_tmp35_) { iliwiNetwork* _tmp36_; gboolean _tmp37_; _tmp36_ = network; _tmp37_ = _tmp36_->authentication; _tmp32_ = !_tmp37_; } else { _tmp32_ = FALSE; } _tmp38_ = _tmp32_; if (_tmp38_) { FILE* _tmp39_; const gchar* _tmp40_; gchar* _tmp41_ = NULL; gchar* _tmp42_; iliwiNetwork* _tmp43_; gboolean _tmp44_; _tmp39_ = stream; _tmp40_ = password; _tmp41_ = g_strdup_printf (" psk=%s\n", _tmp40_); _tmp42_ = _tmp41_; fputs (_tmp42_, _tmp39_); _g_free0 (_tmp42_); _tmp43_ = network; _tmp44_ = _tmp43_->adhoc; if (_tmp44_) { FILE* _tmp45_; FILE* _tmp46_; FILE* _tmp47_; FILE* _tmp48_; _tmp45_ = stream; fputs (" proto=WPA\n", _tmp45_); _tmp46_ = stream; fputs (" key_mgmt=WPA-NONE\n", _tmp46_); _tmp47_ = stream; fputs (" pairwise=NONE\n", _tmp47_); _tmp48_ = stream; fputs (" group=TKIP\n", _tmp48_); } } else { gboolean _tmp49_ = FALSE; iliwiNetwork* _tmp50_; gboolean _tmp51_; gboolean _tmp52_; gboolean _tmp55_; _tmp50_ = network; _tmp51_ = iliwi_network_get_wpa_encryption (_tmp50_); _tmp52_ = _tmp51_; if (_tmp52_) { iliwiNetwork* _tmp53_; gboolean _tmp54_; _tmp53_ = network; _tmp54_ = _tmp53_->authentication; _tmp49_ = _tmp54_; } else { _tmp49_ = FALSE; } _tmp55_ = _tmp49_; if (_tmp55_) { FILE* _tmp56_; iliwiNetwork* _tmp57_; const gchar* _tmp58_; gchar* _tmp59_ = NULL; gchar* _tmp60_; FILE* _tmp61_; FILE* _tmp62_; FILE* _tmp63_; FILE* _tmp64_; iliwiNetwork* _tmp65_; const gchar* _tmp66_; FILE* _tmp74_; iliwiNetwork* _tmp75_; const gchar* _tmp76_; gchar* _tmp77_ = NULL; gchar* _tmp78_; FILE* _tmp79_; FILE* _tmp80_; _tmp56_ = stream; _tmp57_ = network; _tmp58_ = _tmp57_->password; _tmp59_ = g_strdup_printf (" password=\"%s\"\n", _tmp58_); _tmp60_ = _tmp59_; fputs (_tmp60_, _tmp56_); _g_free0 (_tmp60_); _tmp61_ = stream; fputs (" key_mgmt=WPA-EAP\n", _tmp61_); _tmp62_ = stream; fputs (" pairwise=CCMP TKIP\n", _tmp62_); _tmp63_ = stream; fputs (" group=CCMP TKIP\n", _tmp63_); _tmp64_ = stream; fputs (" eap=PEAP\n", _tmp64_); _tmp65_ = network; _tmp66_ = _tmp65_->cert; if (g_strcmp0 (_tmp66_, "") != 0) { FILE* _tmp67_; iliwiNetwork* _tmp68_; const gchar* _tmp69_; iliwiNetwork* _tmp70_; const gchar* _tmp71_; gchar* _tmp72_ = NULL; gchar* _tmp73_; _tmp67_ = stream; _tmp68_ = network; _tmp69_ = _tmp68_->cert_dir; _tmp70_ = network; _tmp71_ = _tmp70_->cert; _tmp72_ = g_strdup_printf (" ca_cert=\"%s%s\"\n", _tmp69_, _tmp71_); _tmp73_ = _tmp72_; fputs (_tmp73_, _tmp67_); _g_free0 (_tmp73_); } _tmp74_ = stream; _tmp75_ = network; _tmp76_ = _tmp75_->username; _tmp77_ = g_strdup_printf (" identity=\"%s\"\n", _tmp76_); _tmp78_ = _tmp77_; fputs (_tmp78_, _tmp74_); _g_free0 (_tmp78_); _tmp79_ = stream; fputs (" phase1=\"peaplabel=0\"\n", _tmp79_); _tmp80_ = stream; fputs (" phase2=\"auth=MSCHAPV2\"\n", _tmp80_); } else { FILE* _tmp81_; FILE* _tmp82_; const gchar* _tmp83_; gchar* _tmp84_ = NULL; gchar* _tmp85_; _tmp81_ = stream; fputs (" key_mgmt=NONE\n", _tmp81_); _tmp82_ = stream; _tmp83_ = password; _tmp84_ = g_strdup_printf (" wep_key0=%s\n", _tmp83_); _tmp85_ = _tmp84_; fputs (_tmp85_, _tmp82_); _g_free0 (_tmp85_); } } } else { FILE* _tmp86_; _tmp86_ = stream; fputs (" key_mgmt=NONE\n", _tmp86_); } _tmp87_ = network; _tmp88_ = _tmp87_->adhoc; if (_tmp88_) { FILE* _tmp89_; _tmp89_ = stream; fputs (" mode=1\n", _tmp89_); } _tmp90_ = stream; fputs ("}\n", _tmp90_); _tmp91_ = stream; fflush (_tmp91_); _fclose0 (stream); stream = NULL; { gchar* _tmp92_ = NULL; gchar* _tmp93_; const gchar* _tmp94_; gchar* _tmp95_; gchar* _tmp96_; const gchar* _tmp97_; gchar* _tmp98_; gchar* _tmp99_; gchar** _tmp100_ = NULL; gchar** supplicant_args; gint supplicant_args_length1; gint _supplicant_args_size_; _tmp92_ = g_find_program_in_path ("wpa_supplicant"); _tmp93_ = g_strdup ("-i"); _tmp94_ = iliwi_wifi_thread_wireless_interface; _tmp95_ = g_strdup (_tmp94_); _tmp96_ = g_strdup ("-c"); _tmp97_ = filename; _tmp98_ = g_strdup (_tmp97_); _tmp99_ = g_strdup ("-B"); _tmp100_ = g_new0 (gchar*, 6 + 1); _tmp100_[0] = _tmp92_; _tmp100_[1] = _tmp93_; _tmp100_[2] = _tmp95_; _tmp100_[3] = _tmp96_; _tmp100_[4] = _tmp98_; _tmp100_[5] = _tmp99_; supplicant_args = _tmp100_; supplicant_args_length1 = 6; _supplicant_args_size_ = supplicant_args_length1; g_spawn_sync (NULL, supplicant_args, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, NULL, &_inner_error_); if (_inner_error_ != NULL) { supplicant_args = (_vala_array_free (supplicant_args, supplicant_args_length1, (GDestroyNotify) g_free), NULL); if (_inner_error_->domain == G_SPAWN_ERROR) { goto __catch5_g_spawn_error; } supplicant_args = (_vala_array_free (supplicant_args, supplicant_args_length1, (GDestroyNotify) g_free), NULL); _fclose0 (stream); _g_free0 (password); _g_free0 (filename); g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } supplicant_args = (_vala_array_free (supplicant_args, supplicant_args_length1, (GDestroyNotify) g_free), NULL); } goto __finally5; __catch5_g_spawn_error: { GError* e = NULL; e = _inner_error_; _inner_error_ = NULL; g_debug ("wifi.vala:330: Couldn't start spawn!"); _g_error_free0 (e); } __finally5: if (_inner_error_ != NULL) { _fclose0 (stream); _g_free0 (password); _g_free0 (filename); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } iliwi_wifi_thread_status = ILIWI_NETWORK_STATUS_CONNECT; _fclose0 (stream); _g_free0 (password); _g_free0 (filename); } static void iliwi_wifi_thread_disconnectt (void) { iliwiNetwork* _tmp4_; GError * _inner_error_ = NULL; iliwi_wifi_thread_status = ILIWI_NETWORK_STATUS_UNCONNECTED; { gchar* _tmp0_ = NULL; gchar* _tmp1_; gchar** _tmp2_ = NULL; gchar** _tmp3_; gint _tmp3__length1; _tmp0_ = g_find_program_in_path ("killall"); _tmp1_ = g_strdup ("wpa_supplicant"); _tmp2_ = g_new0 (gchar*, 2 + 1); _tmp2_[0] = _tmp0_; _tmp2_[1] = _tmp1_; _tmp3_ = _tmp2_; _tmp3__length1 = 2; g_spawn_sync (NULL, _tmp3_, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, NULL, &_inner_error_); _tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_SPAWN_ERROR) { goto __catch6_g_spawn_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } g_remove ("/var/run/wpa_supplicant/eth0"); } goto __finally6; __catch6_g_spawn_error: { GError* e = NULL; e = _inner_error_; _inner_error_ = NULL; _g_error_free0 (e); } __finally6: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _tmp4_ = iliwi_wifi_thread_connect_network; if (_tmp4_ != NULL) { iliwiNetwork* _tmp5_; _tmp5_ = iliwi_wifi_thread_connect_network; iliwi_network_set_new_status (_tmp5_, ILIWI_NETWORK_STATUS_UNCONNECTED); iliwi_wifi_thread_connect_network = NULL; } } static void iliwi_wifi_thread_run_dhcp (void) { GError * _inner_error_ = NULL; { gchar* _tmp0_; gchar* udhcpc_result; gchar* _tmp1_ = NULL; gchar* _tmp2_; const gchar* _tmp3_; gchar* _tmp4_; gchar* _tmp5_; gchar* _tmp6_; gchar** _tmp7_ = NULL; gchar** _tmp8_; gint _tmp8__length1; gchar* _tmp9_ = NULL; GRegex* _tmp10_; GRegex* regex_ip; GMatchInfo* _result_ = NULL; GRegex* _tmp11_; const gchar* _tmp12_; GMatchInfo* _tmp13_ = NULL; gboolean _tmp14_ = FALSE; _tmp0_ = g_strdup (""); udhcpc_result = _tmp0_; _tmp1_ = g_find_program_in_path ("udhcpc"); _tmp2_ = g_strdup ("-i"); _tmp3_ = iliwi_wifi_thread_wireless_interface; _tmp4_ = g_strdup (_tmp3_); _tmp5_ = g_strdup ("-n"); _tmp6_ = g_strdup ("-R"); _tmp7_ = g_new0 (gchar*, 5 + 1); _tmp7_[0] = _tmp1_; _tmp7_[1] = _tmp2_; _tmp7_[2] = _tmp4_; _tmp7_[3] = _tmp5_; _tmp7_[4] = _tmp6_; _tmp8_ = _tmp7_; _tmp8__length1 = 5; g_spawn_sync (NULL, _tmp8_, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &_tmp9_, NULL, NULL, &_inner_error_); _g_free0 (udhcpc_result); udhcpc_result = _tmp9_; _tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL); if (_inner_error_ != NULL) { _g_free0 (udhcpc_result); goto __catch7_g_error; } _tmp10_ = g_regex_new ("\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}", 0, 0, &_inner_error_); regex_ip = _tmp10_; if (_inner_error_ != NULL) { _g_free0 (udhcpc_result); goto __catch7_g_error; } _tmp11_ = regex_ip; _tmp12_ = udhcpc_result; _tmp14_ = g_regex_match (_tmp11_, _tmp12_, 0, &_tmp13_); _g_match_info_free0 (_result_); _result_ = _tmp13_; if (_tmp14_) { iliwiNetwork* _tmp15_; iliwiWifi* _tmp16_; _tmp15_ = iliwi_wifi_thread_connect_network; iliwi_network_set_new_status (_tmp15_, ILIWI_NETWORK_STATUS_CONNECTED); iliwi_wifi_thread_status = ILIWI_NETWORK_STATUS_CONNECTED; _tmp16_ = iliwi_wifi; iliwi_wifi_set_new_status (_tmp16_, "idle"); } _g_match_info_free0 (_result_); _g_regex_unref0 (regex_ip); _g_free0 (udhcpc_result); } goto __finally7; __catch7_g_error: { GError* e = NULL; e = _inner_error_; _inner_error_ = NULL; g_debug ("wifi.vala:359: Couldn't start spawn or regex failed!"); _g_error_free0 (e); } __finally7: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } static void iliwi_wifi_thread_initialize (void) { GHashFunc _tmp20_; GEqualFunc _tmp21_; GeeHashMap* _tmp22_; GeeArrayList* _tmp23_; GError * _inner_error_ = NULL; { Usage* _tmp0_ = NULL; Usage* _tmp1_; Usage* _tmp2_; Usage* _tmp3_; _tmp0_ = g_initable_new (TYPE_USAGE_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.freesmartphone.ousaged", "g-bus-type", G_BUS_TYPE_SYSTEM, "g-object-path", "/org/freesmartphone/Usage", "g-interface-name", "org.freesmartphone.Usage", NULL); _tmp1_ = (Usage*) _tmp0_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { goto __catch8_g_io_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _g_object_unref0 (iliwi_wifi_thread_fso_usage); iliwi_wifi_thread_fso_usage = _tmp1_; _tmp2_ = iliwi_wifi_thread_fso_usage; usage_RequestResource (_tmp2_, "WiFi", &_inner_error_); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { goto __catch8_g_io_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _tmp3_ = iliwi_wifi_thread_fso_usage; usage_RequestResource (_tmp3_, "CPU", &_inner_error_); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { goto __catch8_g_io_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } goto __finally8; __catch8_g_io_error: { GError* e = NULL; e = _inner_error_; _inner_error_ = NULL; g_debug ("wifi.vala:370: DBus error!"); _g_error_free0 (e); } __finally8: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } { GRegex* _tmp4_; GRegex* _tmp5_; GRegex* _tmp6_; GRegex* _tmp7_; GRegex* _tmp8_; GRegex* _tmp9_; GRegex* _tmp10_; GRegex* _tmp11_; GRegex* _tmp12_; GRegex* _tmp13_; GRegex* _tmp14_; GRegex* _tmp15_; GRegex* _tmp16_; GRegex* _tmp17_; GRegex* _tmp18_; GRegex* _tmp19_; _tmp4_ = g_regex_new (" Address: ([0-9A-Z:]{17})$", 0, 0, &_inner_error_); _tmp5_ = _tmp4_; if (_inner_error_ != NULL) { goto __catch9_g_error; } _g_regex_unref0 (iliwi_wifi_thread_line_regex_start_address); iliwi_wifi_thread_line_regex_start_address = _tmp5_; _tmp6_ = g_regex_new ("^\\s+ESSID:\\\"(.*)\\\"$", 0, 0, &_inner_error_); _tmp7_ = _tmp6_; if (_inner_error_ != NULL) { goto __catch9_g_error; } _g_regex_unref0 (iliwi_wifi_thread_line_regex_essid); iliwi_wifi_thread_line_regex_essid = _tmp7_; _tmp8_ = g_regex_new ("^\\s+Encryption key:on$", 0, 0, &_inner_error_); _tmp9_ = _tmp8_; if (_inner_error_ != NULL) { goto __catch9_g_error; } _g_regex_unref0 (iliwi_wifi_thread_line_regex_encryption); iliwi_wifi_thread_line_regex_encryption = _tmp9_; _tmp10_ = g_regex_new ("^\\s+Quality=(\\d+)/(\\d+) ", 0, 0, &_inner_error_); _tmp11_ = _tmp10_; if (_inner_error_ != NULL) { goto __catch9_g_error; } _g_regex_unref0 (iliwi_wifi_thread_line_regex_strength); iliwi_wifi_thread_line_regex_strength = _tmp11_; _tmp12_ = g_regex_new ("^(\\w+\\d+)\\s*Scan completed :$", 0, 0, &_inner_error_); _tmp13_ = _tmp12_; if (_inner_error_ != NULL) { goto __catch9_g_error; } _g_regex_unref0 (iliwi_wifi_thread_line_regex_interface); iliwi_wifi_thread_line_regex_interface = _tmp13_; _tmp14_ = g_regex_new ("^\\s+Mode:Ad-Hoc$", 0, 0, &_inner_error_); _tmp15_ = _tmp14_; if (_inner_error_ != NULL) { goto __catch9_g_error; } _g_regex_unref0 (iliwi_wifi_thread_line_regex_adhoc); iliwi_wifi_thread_line_regex_adhoc = _tmp15_; _tmp16_ = g_regex_new ("^\\s+IE: WPA", 0, 0, &_inner_error_); _tmp17_ = _tmp16_; if (_inner_error_ != NULL) { goto __catch9_g_error; } _g_regex_unref0 (iliwi_wifi_thread_line_regex_wpa_enc); iliwi_wifi_thread_line_regex_wpa_enc = _tmp17_; _tmp18_ = g_regex_new ("^\\s+Extra:wpa_ie=dd160050f20101000050f20201000050f20201000050f201$", 0, 0, &_inner_error_); _tmp19_ = _tmp18_; if (_inner_error_ != NULL) { goto __catch9_g_error; } _g_regex_unref0 (iliwi_wifi_thread_line_regex_wpa_enc_auth); iliwi_wifi_thread_line_regex_wpa_enc_auth = _tmp19_; } goto __finally9; __catch9_g_error: { GError* e = NULL; e = _inner_error_; _inner_error_ = NULL; g_debug ("wifi.vala:382: Regex error!"); _g_error_free0 (e); } __finally9: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _tmp20_ = g_str_hash; _tmp21_ = g_str_equal; _tmp22_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, ILIWI_TYPE_NETWORK, (GBoxedCopyFunc) iliwi_network_ref, iliwi_network_unref, _tmp20_, _tmp21_, NULL); _g_object_unref0 (iliwi_wifi_thread_networks); iliwi_wifi_thread_networks = _tmp22_; _tmp23_ = gee_array_list_new (ILIWI_TYPE_NETWORK, (GBoxedCopyFunc) iliwi_network_ref, iliwi_network_unref, NULL); _g_object_unref0 (iliwi_wifi_thread_visible_networks); iliwi_wifi_thread_visible_networks = _tmp23_; iliwi_wifi_thread_status = ILIWI_NETWORK_STATUS_UNCONNECTED; iliwi_wifi_thread_disconnectt (); iliwi_wifi_thread_load_preferred_networks (); iliwi_wifi_thread_scan (); } static gchar* g_file_stream_read_line (FILE* self) { gchar* result = NULL; gint c = 0; GString* ret; GString* _tmp7_; g_return_val_if_fail (self != NULL, NULL); ret = NULL; while (TRUE) { gint _tmp0_ = 0; gint _tmp1_; GString* _tmp2_; gint _tmp4_; GString* _tmp5_; gint _tmp6_; _tmp0_ = fgetc (self); c = _tmp0_; _tmp1_ = c; if (!(_tmp1_ != EOF)) { break; } _tmp2_ = ret; if (_tmp2_ == NULL) { GString* _tmp3_; _tmp3_ = g_string_new (""); _g_string_free0 (ret); ret = _tmp3_; } _tmp4_ = c; if (_tmp4_ == ((gint) '\n')) { break; } _tmp5_ = ret; _tmp6_ = c; g_string_append_c ((GString*) _tmp5_, (gchar) _tmp6_); } _tmp7_ = ret; if (_tmp7_ == NULL) { result = NULL; _g_string_free0 (ret); return result; } else { GString* _tmp8_; const gchar* _tmp9_; gchar* _tmp10_; _tmp8_ = ret; _tmp9_ = ((GString*) _tmp8_)->str; _tmp10_ = g_strdup (_tmp9_); result = _tmp10_; _g_string_free0 (ret); return result; } _g_string_free0 (ret); } static void iliwi_wifi_thread_load_preferred_networks (void) { const gchar* _tmp0_ = NULL; gchar* _tmp1_; gchar* filename; const gchar* _tmp2_; FILE* _tmp3_ = NULL; FILE* in_stream; gchar* line = NULL; GHashFunc _tmp4_; GEqualFunc _tmp5_; GeeHashMap* _tmp6_; GError * _inner_error_ = NULL; _tmp0_ = g_get_user_config_dir (); _tmp1_ = g_strconcat (_tmp0_, "/iliwi/preferred_networks", NULL); filename = _tmp1_; _tmp2_ = filename; _tmp3_ = fopen (_tmp2_, "r"); in_stream = _tmp3_; _tmp4_ = g_str_hash; _tmp5_ = g_str_equal; _tmp6_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, ILIWI_TYPE_PREFERRED_NETWORK, (GBoxedCopyFunc) iliwi_preferred_network_dup, iliwi_preferred_network_free, _tmp4_, _tmp5_, NULL); _g_object_unref0 (iliwi_wifi_thread_preferred_networks); iliwi_wifi_thread_preferred_networks = _tmp6_; { GRegex* _tmp7_; GRegex* regex_line; GMatchInfo* _result_ = NULL; _tmp7_ = g_regex_new ("^([0-9A-Z:]{17}) \\\"(.*)\\\"(h)? \\\"(.*)\\\" \\\"(.*)\\\" \\\"(.*)\\" \ "\"$", 0, 0, &_inner_error_); regex_line = _tmp7_; if (_inner_error_ != NULL) { goto __catch10_g_error; } while (TRUE) { FILE* _tmp8_; gchar* _tmp9_ = NULL; const gchar* _tmp10_; GRegex* _tmp11_; const gchar* _tmp12_; GMatchInfo* _tmp13_ = NULL; gboolean _tmp14_ = FALSE; _tmp8_ = in_stream; _tmp9_ = g_file_stream_read_line (_tmp8_); _g_free0 (line); line = _tmp9_; _tmp10_ = line; if (!(_tmp10_ != NULL)) { break; } _tmp11_ = regex_line; _tmp12_ = line; _tmp14_ = g_regex_match (_tmp11_, _tmp12_, 0, &_tmp13_); _g_match_info_free0 (_result_); _result_ = _tmp13_; if (_tmp14_) { GeeHashMap* _tmp15_; GMatchInfo* _tmp16_; gchar* _tmp17_ = NULL; gchar* _tmp18_; GMatchInfo* _tmp19_; gchar* _tmp20_ = NULL; GMatchInfo* _tmp21_; gchar* _tmp22_ = NULL; gchar* _tmp23_; GMatchInfo* _tmp24_; gchar* _tmp25_ = NULL; GMatchInfo* _tmp26_; gchar* _tmp27_ = NULL; GMatchInfo* _tmp28_; gchar* _tmp29_ = NULL; iliwiPreferredNetwork _tmp30_ = {0}; iliwiPreferredNetwork _tmp31_; iliwiPreferredNetwork _tmp32_; _tmp15_ = iliwi_wifi_thread_preferred_networks; _tmp16_ = _result_; _tmp17_ = g_match_info_fetch (_tmp16_, 1); _tmp18_ = _tmp17_; _tmp19_ = _result_; _tmp20_ = g_match_info_fetch (_tmp19_, 2); _tmp21_ = _result_; _tmp22_ = g_match_info_fetch (_tmp21_, 3); _tmp23_ = _tmp22_; _tmp24_ = _result_; _tmp25_ = g_match_info_fetch (_tmp24_, 4); _tmp26_ = _result_; _tmp27_ = g_match_info_fetch (_tmp26_, 5); _tmp28_ = _result_; _tmp29_ = g_match_info_fetch (_tmp28_, 6); memset (&_tmp30_, 0, sizeof (iliwiPreferredNetwork)); _g_free0 (_tmp30_.password); _tmp30_.password = _tmp20_; _tmp30_.password_in_ascii = g_strcmp0 (_tmp23_, "h") != 0; _g_free0 (_tmp30_.username); _tmp30_.username = _tmp25_; _g_free0 (_tmp30_.cert); _tmp30_.cert = _tmp27_; _g_free0 (_tmp30_.cert_dir); _tmp30_.cert_dir = _tmp29_; _tmp31_ = _tmp30_; _tmp32_ = _tmp31_; gee_abstract_map_set ((GeeAbstractMap*) _tmp15_, _tmp18_, &_tmp32_); iliwi_preferred_network_destroy (&_tmp31_); _g_free0 (_tmp23_); _g_free0 (_tmp18_); } } _g_match_info_free0 (_result_); _g_regex_unref0 (regex_line); } goto __finally10; __catch10_g_error: { GError* e = NULL; const gchar* _tmp33_; e = _inner_error_; _inner_error_ = NULL; _tmp33_ = filename; g_debug ("wifi.vala:417: Couldn't parse the file %s", _tmp33_); _g_error_free0 (e); } __finally10: if (_inner_error_ != NULL) { _g_free0 (line); _fclose0 (in_stream); _g_free0 (filename); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _g_free0 (line); _fclose0 (in_stream); _g_free0 (filename); } static void iliwi_wifi_thread_save_preferred_networks (void) { const gchar* _tmp0_ = NULL; gchar* _tmp1_; gchar* _tmp2_; const gchar* _tmp3_ = NULL; gchar* _tmp4_; gchar* filename; const gchar* _tmp5_; FILE* _tmp6_ = NULL; FILE* stream; _tmp0_ = g_get_user_config_dir (); _tmp1_ = g_strconcat (_tmp0_, "/iliwi", NULL); _tmp2_ = _tmp1_; g_mkdir_with_parents (_tmp2_, 0755); _g_free0 (_tmp2_); _tmp3_ = g_get_user_config_dir (); _tmp4_ = g_strconcat (_tmp3_, "/iliwi/preferred_networks", NULL); filename = _tmp4_; _tmp5_ = filename; _tmp6_ = fopen (_tmp5_, "w"); stream = _tmp6_; { GeeHashMap* _tmp7_; GeeSet* _tmp8_; GeeSet* _tmp9_; GeeSet* _tmp10_; GeeIterator* _tmp11_ = NULL; GeeIterator* _tmp12_; GeeIterator* _address_it; _tmp7_ = iliwi_wifi_thread_preferred_networks; _tmp8_ = gee_abstract_map_get_keys ((GeeMap*) _tmp7_); _tmp9_ = _tmp8_; _tmp10_ = _tmp9_; _tmp11_ = gee_iterable_iterator ((GeeIterable*) _tmp10_); _tmp12_ = _tmp11_; _g_object_unref0 (_tmp10_); _address_it = _tmp12_; while (TRUE) { GeeIterator* _tmp13_; gboolean _tmp14_ = FALSE; GeeIterator* _tmp15_; gpointer _tmp16_ = NULL; gchar* address; GeeHashMap* _tmp17_; const gchar* _tmp18_; gpointer _tmp19_ = NULL; iliwiPreferredNetwork* _tmp20_; iliwiPreferredNetwork _tmp21_ = {0}; iliwiPreferredNetwork _tmp22_; iliwiPreferredNetwork network; const gchar* _tmp23_ = NULL; iliwiPreferredNetwork _tmp24_; gboolean _tmp25_; const gchar* _tmp26_; gchar* _tmp27_; gchar* password_type; FILE* _tmp28_; const gchar* _tmp29_; iliwiPreferredNetwork _tmp30_; const gchar* _tmp31_; const gchar* _tmp32_; iliwiPreferredNetwork _tmp33_; const gchar* _tmp34_; iliwiPreferredNetwork _tmp35_; const gchar* _tmp36_; iliwiPreferredNetwork _tmp37_; const gchar* _tmp38_; gchar* _tmp39_ = NULL; gchar* _tmp40_; _tmp13_ = _address_it; _tmp14_ = gee_iterator_next (_tmp13_); if (!_tmp14_) { break; } _tmp15_ = _address_it; _tmp16_ = gee_iterator_get (_tmp15_); address = (gchar*) _tmp16_; _tmp17_ = iliwi_wifi_thread_preferred_networks; _tmp18_ = address; _tmp19_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp17_, _tmp18_); _tmp20_ = (iliwiPreferredNetwork*) _tmp19_; iliwi_preferred_network_copy (_tmp20_, &_tmp21_); _tmp22_ = _tmp21_; _iliwi_preferred_network_free0 (_tmp20_); network = _tmp22_; _tmp24_ = network; _tmp25_ = _tmp24_.password_in_ascii; if (_tmp25_) { _tmp23_ = ""; } else { _tmp23_ = "h"; } _tmp26_ = _tmp23_; _tmp27_ = g_strdup (_tmp26_); password_type = _tmp27_; _tmp28_ = stream; _tmp29_ = address; _tmp30_ = network; _tmp31_ = _tmp30_.password; _tmp32_ = password_type; _tmp33_ = network; _tmp34_ = _tmp33_.username; _tmp35_ = network; _tmp36_ = _tmp35_.cert; _tmp37_ = network; _tmp38_ = _tmp37_.cert_dir; _tmp39_ = g_strdup_printf ("%s \"%s\"%s \"%s\" \"%s\" \"%s\"\n", _tmp29_, _tmp31_, _tmp32_, _tmp34_, _tmp36_, _tmp38_); _tmp40_ = _tmp39_; fputs (_tmp40_, _tmp28_); _g_free0 (_tmp40_); _g_free0 (password_type); iliwi_preferred_network_destroy (&network); _g_free0 (address); } _g_object_unref0 (_address_it); } _fclose0 (stream); _g_free0 (filename); } static void iliwi_wifi_thread_scan (void) { iliwiWifi* _tmp0_; gchar* _tmp1_; gchar* _result_; iliwiWifi* _tmp8_; GError * _inner_error_ = NULL; _tmp0_ = iliwi_wifi; iliwi_wifi_set_new_status (_tmp0_, "scanning.."); iliwi_wifi_thread_seconds_since_last_scan = 0; _tmp1_ = g_strdup (""); _result_ = _tmp1_; { gchar* _tmp2_ = NULL; gchar* _tmp3_; gchar** _tmp4_ = NULL; gchar** _tmp5_; gint _tmp5__length1; gchar* _tmp6_ = NULL; const gchar* _tmp7_; _tmp2_ = g_find_program_in_path ("iwlist"); _tmp3_ = g_strdup ("scan"); _tmp4_ = g_new0 (gchar*, 2 + 1); _tmp4_[0] = _tmp2_; _tmp4_[1] = _tmp3_; _tmp5_ = _tmp4_; _tmp5__length1 = 2; g_spawn_sync (NULL, _tmp5_, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &_tmp6_, NULL, NULL, &_inner_error_); _g_free0 (_result_); _result_ = _tmp6_; _tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_SPAWN_ERROR) { goto __catch11_g_spawn_error; } _g_free0 (_result_); g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _tmp7_ = _result_; iliwi_wifi_thread_parse_iwlist_networks (_tmp7_); } goto __finally11; __catch11_g_spawn_error: { GError* e = NULL; e = _inner_error_; _inner_error_ = NULL; g_debug ("wifi.vala:439: Couldn't start spawn!"); _g_error_free0 (e); } __finally11: if (_inner_error_ != NULL) { _g_free0 (_result_); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } _tmp8_ = iliwi_wifi; iliwi_wifi_set_new_status (_tmp8_, "idle"); iliwi_wifi_thread_seconds_since_last_scan = 0; _g_free0 (_result_); } static gpointer _g_object_ref0 (gpointer self) { return self ? g_object_ref (self) : NULL; } static void iliwi_wifi_thread_parse_iwlist_networks (const gchar* iwlist_result) { const gchar* _tmp0_; gchar** _tmp1_; gchar** _tmp2_ = NULL; gchar** lines; gint lines_length1; gint _lines_size_; GMatchInfo* _result_ = NULL; iliwiNetwork* current_network; iliwiWifi* _tmp99_; GError * _inner_error_ = NULL; g_return_if_fail (iwlist_result != NULL); _tmp0_ = iwlist_result; _tmp2_ = _tmp1_ = g_strsplit (_tmp0_, "\n", 0); lines = _tmp2_; lines_length1 = _vala_array_length (_tmp1_); _lines_size_ = lines_length1; current_network = NULL; { GeeArrayList* _tmp3_; _tmp3_ = iliwi_wifi_thread_visible_networks; g_static_rec_mutex_lock (&__lock_iliwi_wifi_thread_visible_networks); { GeeArrayList* _tmp16_; gchar** _tmp17_; gint _tmp17__length1; gboolean _tmp92_ = FALSE; iliwiNetwork* _tmp93_; gboolean _tmp96_; { GeeArrayList* _tmp4_; GeeArrayList* _tmp5_; GeeArrayList* _n_list; GeeArrayList* _tmp6_; gint _tmp7_; gint _tmp8_; gint _n_size; gint _n_index; _tmp4_ = iliwi_wifi_thread_visible_networks; _tmp5_ = _g_object_ref0 (_tmp4_); _n_list = _tmp5_; _tmp6_ = _n_list; _tmp7_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp6_); _tmp8_ = _tmp7_; _n_size = _tmp8_; _n_index = -1; while (TRUE) { gint _tmp9_; gint _tmp10_; gint _tmp11_; GeeArrayList* _tmp12_; gint _tmp13_; gpointer _tmp14_ = NULL; iliwiNetwork* n; iliwiNetwork* _tmp15_; _tmp9_ = _n_index; _n_index = _tmp9_ + 1; _tmp10_ = _n_index; _tmp11_ = _n_size; if (!(_tmp10_ < _tmp11_)) { break; } _tmp12_ = _n_list; _tmp13_ = _n_index; _tmp14_ = gee_abstract_list_get ((GeeAbstractList*) _tmp12_, _tmp13_); n = (iliwiNetwork*) _tmp14_; _tmp15_ = n; iliwi_network_set_strength (_tmp15_, 0, FALSE); _iliwi_network_unref0 (n); } _g_object_unref0 (_n_list); } _tmp16_ = iliwi_wifi_thread_visible_networks; gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp16_); _tmp17_ = lines; _tmp17__length1 = lines_length1; { gchar** line_collection = NULL; gint line_collection_length1 = 0; gint _line_collection_size_ = 0; gint line_it = 0; line_collection = _tmp17_; line_collection_length1 = _tmp17__length1; for (line_it = 0; line_it < _tmp17__length1; line_it = line_it + 1) { gchar* _tmp18_; gchar* line = NULL; _tmp18_ = g_strdup (line_collection[line_it]); line = _tmp18_; { GRegex* _tmp19_; const gchar* _tmp20_; GMatchInfo* _tmp21_ = NULL; gboolean _tmp22_ = FALSE; _tmp19_ = iliwi_wifi_thread_line_regex_essid; _tmp20_ = line; _tmp22_ = g_regex_match (_tmp19_, _tmp20_, 0, &_tmp21_); _g_match_info_free0 (_result_); _result_ = _tmp21_; if (_tmp22_) { iliwiNetwork* _tmp23_; GMatchInfo* _tmp24_; gchar* _tmp25_ = NULL; _tmp23_ = current_network; _tmp24_ = _result_; _tmp25_ = g_match_info_fetch (_tmp24_, 1); _g_free0 (_tmp23_->essid); _tmp23_->essid = _tmp25_; } else { GRegex* _tmp26_; const gchar* _tmp27_; GMatchInfo* _tmp28_ = NULL; gboolean _tmp29_ = FALSE; _tmp26_ = iliwi_wifi_thread_line_regex_encryption; _tmp27_ = line; _tmp29_ = g_regex_match (_tmp26_, _tmp27_, 0, &_tmp28_); _g_match_info_free0 (_result_); _result_ = _tmp28_; if (_tmp29_) { iliwiNetwork* _tmp30_; _tmp30_ = current_network; _tmp30_->encryption = TRUE; } else { GRegex* _tmp31_; const gchar* _tmp32_; GMatchInfo* _tmp33_ = NULL; gboolean _tmp34_ = FALSE; _tmp31_ = iliwi_wifi_thread_line_regex_wpa_enc_auth; _tmp32_ = line; _tmp34_ = g_regex_match (_tmp31_, _tmp32_, 0, &_tmp33_); _g_match_info_free0 (_result_); _result_ = _tmp33_; if (_tmp34_) { iliwiNetwork* _tmp35_; iliwiNetwork* _tmp36_; _tmp35_ = current_network; _tmp35_->authentication = TRUE; _tmp36_ = current_network; iliwi_network_set_encyption_to_wpa (_tmp36_); } else { GRegex* _tmp37_; const gchar* _tmp38_; GMatchInfo* _tmp39_ = NULL; gboolean _tmp40_ = FALSE; _tmp37_ = iliwi_wifi_thread_line_regex_wpa_enc; _tmp38_ = line; _tmp40_ = g_regex_match (_tmp37_, _tmp38_, 0, &_tmp39_); _g_match_info_free0 (_result_); _result_ = _tmp39_; if (_tmp40_) { iliwiNetwork* _tmp41_; _tmp41_ = current_network; iliwi_network_set_encyption_to_wpa (_tmp41_); } else { GRegex* _tmp42_; const gchar* _tmp43_; GMatchInfo* _tmp44_ = NULL; gboolean _tmp45_ = FALSE; _tmp42_ = iliwi_wifi_thread_line_regex_adhoc; _tmp43_ = line; _tmp45_ = g_regex_match (_tmp42_, _tmp43_, 0, &_tmp44_); _g_match_info_free0 (_result_); _result_ = _tmp44_; if (_tmp45_) { iliwiNetwork* _tmp46_; _tmp46_ = current_network; _tmp46_->adhoc = TRUE; } else { GRegex* _tmp47_; const gchar* _tmp48_; GMatchInfo* _tmp49_ = NULL; gboolean _tmp50_ = FALSE; _tmp47_ = iliwi_wifi_thread_line_regex_strength; _tmp48_ = line; _tmp50_ = g_regex_match (_tmp47_, _tmp48_, 0, &_tmp49_); _g_match_info_free0 (_result_); _result_ = _tmp49_; if (_tmp50_) { iliwiNetwork* _tmp51_; GMatchInfo* _tmp52_; gchar* _tmp53_ = NULL; gchar* _tmp54_; gdouble _tmp55_ = 0.0; GMatchInfo* _tmp56_; gchar* _tmp57_ = NULL; gchar* _tmp58_; gdouble _tmp59_ = 0.0; _tmp51_ = current_network; _tmp52_ = _result_; _tmp53_ = g_match_info_fetch (_tmp52_, 1); _tmp54_ = _tmp53_; _tmp55_ = g_ascii_strtod (_tmp54_, NULL); _tmp56_ = _result_; _tmp57_ = g_match_info_fetch (_tmp56_, 2); _tmp58_ = _tmp57_; _tmp59_ = g_ascii_strtod (_tmp58_, NULL); iliwi_network_set_strength (_tmp51_, (gint) ((_tmp55_ / _tmp59_) * 100), TRUE); _g_free0 (_tmp58_); _g_free0 (_tmp54_); } else { GRegex* _tmp60_; const gchar* _tmp61_; GMatchInfo* _tmp62_ = NULL; gboolean _tmp63_ = FALSE; _tmp60_ = iliwi_wifi_thread_line_regex_start_address; _tmp61_ = line; _tmp63_ = g_regex_match (_tmp60_, _tmp61_, 0, &_tmp62_); _g_match_info_free0 (_result_); _result_ = _tmp62_; if (_tmp63_) { gboolean _tmp64_ = FALSE; iliwiNetwork* _tmp65_; gboolean _tmp68_; GeeHashMap* _tmp70_; GMatchInfo* _tmp71_; gchar* _tmp72_ = NULL; gchar* _tmp73_; gboolean _tmp74_ = FALSE; gboolean _tmp75_; iliwiNetwork* _tmp85_; _tmp65_ = current_network; if (_tmp65_ != NULL) { iliwiNetwork* _tmp66_; gboolean _tmp67_ = FALSE; _tmp66_ = current_network; _tmp67_ = iliwi_network_valid_network (_tmp66_); _tmp64_ = _tmp67_; } else { _tmp64_ = FALSE; } _tmp68_ = _tmp64_; if (_tmp68_) { iliwiNetwork* _tmp69_; _tmp69_ = current_network; iliwi_wifi_thread_found_network (_tmp69_); } _tmp70_ = iliwi_wifi_thread_networks; _tmp71_ = _result_; _tmp72_ = g_match_info_fetch (_tmp71_, 1); _tmp73_ = _tmp72_; _tmp74_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp70_, _tmp73_); _tmp75_ = _tmp74_; _g_free0 (_tmp73_); if (_tmp75_) { GeeHashMap* _tmp76_; GMatchInfo* _tmp77_; gchar* _tmp78_ = NULL; gchar* _tmp79_; gpointer _tmp80_ = NULL; _tmp76_ = iliwi_wifi_thread_networks; _tmp77_ = _result_; _tmp78_ = g_match_info_fetch (_tmp77_, 1); _tmp79_ = _tmp78_; _tmp80_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp76_, _tmp79_); _iliwi_network_unref0 (current_network); current_network = (iliwiNetwork*) _tmp80_; _g_free0 (_tmp79_); } else { iliwiNetwork* _tmp81_; iliwiNetwork* _tmp82_; GMatchInfo* _tmp83_; gchar* _tmp84_ = NULL; _tmp81_ = iliwi_network_new (); _iliwi_network_unref0 (current_network); current_network = _tmp81_; _tmp82_ = current_network; _tmp83_ = _result_; _tmp84_ = g_match_info_fetch (_tmp83_, 1); _g_free0 (_tmp82_->address); _tmp82_->address = _tmp84_; } _tmp85_ = current_network; _tmp85_->visible = TRUE; } else { GRegex* _tmp86_; const gchar* _tmp87_; GMatchInfo* _tmp88_ = NULL; gboolean _tmp89_ = FALSE; _tmp86_ = iliwi_wifi_thread_line_regex_interface; _tmp87_ = line; _tmp89_ = g_regex_match (_tmp86_, _tmp87_, 0, &_tmp88_); _g_match_info_free0 (_result_); _result_ = _tmp88_; if (_tmp89_) { GMatchInfo* _tmp90_; gchar* _tmp91_ = NULL; _tmp90_ = _result_; _tmp91_ = g_match_info_fetch (_tmp90_, 1); _g_free0 (iliwi_wifi_thread_wireless_interface); iliwi_wifi_thread_wireless_interface = _tmp91_; } } } } } } } } _g_free0 (line); } } } _tmp93_ = current_network; if (_tmp93_ != NULL) { iliwiNetwork* _tmp94_; gboolean _tmp95_ = FALSE; _tmp94_ = current_network; _tmp95_ = iliwi_network_valid_network (_tmp94_); _tmp92_ = _tmp95_; } else { _tmp92_ = FALSE; } _tmp96_ = _tmp92_; if (_tmp96_) { iliwiNetwork* _tmp97_; _tmp97_ = current_network; iliwi_wifi_thread_found_network (_tmp97_); } } __finally12: { GeeArrayList* _tmp98_; _tmp98_ = iliwi_wifi_thread_visible_networks; g_static_rec_mutex_unlock (&__lock_iliwi_wifi_thread_visible_networks); } if (_inner_error_ != NULL) { _iliwi_network_unref0 (current_network); _g_match_info_free0 (_result_); lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp99_ = iliwi_wifi; iliwi_wifi_visible_network_change (_tmp99_); _iliwi_network_unref0 (current_network); _g_match_info_free0 (_result_); lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL); } static void iliwi_wifi_thread_found_network (iliwiNetwork* network) { iliwiNetwork* _tmp0_; gboolean _tmp1_; GeeArrayList* _tmp13_; iliwiNetwork* _tmp14_; g_return_if_fail (network != NULL); _tmp0_ = network; _tmp1_ = _tmp0_->unsaved; if (_tmp1_) { iliwiNetwork* _tmp2_; GeeHashMap* _tmp3_; iliwiNetwork* _tmp4_; const gchar* _tmp5_; gboolean _tmp6_ = FALSE; GeeHashMap* _tmp9_; iliwiNetwork* _tmp10_; const gchar* _tmp11_; iliwiNetwork* _tmp12_; _tmp2_ = network; _tmp2_->unsaved = FALSE; _tmp3_ = iliwi_wifi_thread_preferred_networks; _tmp4_ = network; _tmp5_ = _tmp4_->address; _tmp6_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp3_, _tmp5_); if (_tmp6_) { iliwiNetwork* _tmp7_; iliwiNetwork* _tmp8_; _tmp7_ = network; _tmp7_->preferred_network = TRUE; _tmp8_ = network; iliwi_wifi_thread_connect_to_suggestion (_tmp8_); } _tmp9_ = iliwi_wifi_thread_networks; _tmp10_ = network; _tmp11_ = _tmp10_->address; _tmp12_ = network; gee_abstract_map_set ((GeeAbstractMap*) _tmp9_, _tmp11_, _tmp12_); } _tmp13_ = iliwi_wifi_thread_visible_networks; _tmp14_ = network; gee_abstract_collection_add ((GeeAbstractCollection*) _tmp13_, _tmp14_); } static void iliwi_wifi_thread_connect_to_suggestion (iliwiNetwork* network) { GeeHashMap* _tmp0_; iliwiNetwork* _tmp1_; const gchar* _tmp2_; gboolean _tmp3_ = FALSE; iliwiNetwork* _tmp43_; g_return_if_fail (network != NULL); _tmp0_ = iliwi_wifi_thread_preferred_networks; _tmp1_ = network; _tmp2_ = _tmp1_->address; _tmp3_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp2_); if (_tmp3_) { iliwiNetwork* _tmp4_; GeeHashMap* _tmp5_; iliwiNetwork* _tmp6_; const gchar* _tmp7_; gpointer _tmp8_ = NULL; iliwiPreferredNetwork* _tmp9_; const gchar* _tmp10_; gchar* _tmp11_; iliwiNetwork* _tmp12_; GeeHashMap* _tmp13_; iliwiNetwork* _tmp14_; const gchar* _tmp15_; gpointer _tmp16_ = NULL; iliwiPreferredNetwork* _tmp17_; gboolean _tmp18_; iliwiNetwork* _tmp19_; GeeHashMap* _tmp20_; iliwiNetwork* _tmp21_; const gchar* _tmp22_; gpointer _tmp23_ = NULL; iliwiPreferredNetwork* _tmp24_; const gchar* _tmp25_; gchar* _tmp26_; iliwiNetwork* _tmp27_; GeeHashMap* _tmp28_; iliwiNetwork* _tmp29_; const gchar* _tmp30_; gpointer _tmp31_ = NULL; iliwiPreferredNetwork* _tmp32_; const gchar* _tmp33_; gchar* _tmp34_; iliwiNetwork* _tmp35_; GeeHashMap* _tmp36_; iliwiNetwork* _tmp37_; const gchar* _tmp38_; gpointer _tmp39_ = NULL; iliwiPreferredNetwork* _tmp40_; const gchar* _tmp41_; gchar* _tmp42_; _tmp4_ = network; _tmp5_ = iliwi_wifi_thread_preferred_networks; _tmp6_ = network; _tmp7_ = _tmp6_->address; _tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp5_, _tmp7_); _tmp9_ = (iliwiPreferredNetwork*) _tmp8_; _tmp10_ = (*_tmp9_).password; _tmp11_ = g_strdup (_tmp10_); _g_free0 (_tmp4_->password); _tmp4_->password = _tmp11_; _iliwi_preferred_network_free0 (_tmp9_); _tmp12_ = network; _tmp13_ = iliwi_wifi_thread_preferred_networks; _tmp14_ = network; _tmp15_ = _tmp14_->address; _tmp16_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp13_, _tmp15_); _tmp17_ = (iliwiPreferredNetwork*) _tmp16_; _tmp18_ = (*_tmp17_).password_in_ascii; _tmp12_->password_in_ascii = _tmp18_; _iliwi_preferred_network_free0 (_tmp17_); _tmp19_ = network; _tmp20_ = iliwi_wifi_thread_preferred_networks; _tmp21_ = network; _tmp22_ = _tmp21_->address; _tmp23_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp20_, _tmp22_); _tmp24_ = (iliwiPreferredNetwork*) _tmp23_; _tmp25_ = (*_tmp24_).username; _tmp26_ = g_strdup (_tmp25_); _g_free0 (_tmp19_->username); _tmp19_->username = _tmp26_; _iliwi_preferred_network_free0 (_tmp24_); _tmp27_ = network; _tmp28_ = iliwi_wifi_thread_preferred_networks; _tmp29_ = network; _tmp30_ = _tmp29_->address; _tmp31_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp28_, _tmp30_); _tmp32_ = (iliwiPreferredNetwork*) _tmp31_; _tmp33_ = (*_tmp32_).cert; _tmp34_ = g_strdup (_tmp33_); _g_free0 (_tmp27_->cert); _tmp27_->cert = _tmp34_; _iliwi_preferred_network_free0 (_tmp32_); _tmp35_ = network; _tmp36_ = iliwi_wifi_thread_preferred_networks; _tmp37_ = network; _tmp38_ = _tmp37_->address; _tmp39_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp36_, _tmp38_); _tmp40_ = (iliwiPreferredNetwork*) _tmp39_; _tmp41_ = (*_tmp40_).cert_dir; _tmp42_ = g_strdup (_tmp41_); _g_free0 (_tmp35_->cert_dir); _tmp35_->cert_dir = _tmp42_; _iliwi_preferred_network_free0 (_tmp40_); } _tmp43_ = iliwi_wifi_thread_connection_suggestion; if (_tmp43_ == NULL) { iliwiNetwork* _tmp44_; _tmp44_ = network; iliwi_wifi_thread_connection_suggestion = _tmp44_; } else { iliwiNetwork* _tmp45_; gint _tmp46_; iliwiNetwork* _tmp47_; gint _tmp48_; _tmp45_ = iliwi_wifi_thread_connection_suggestion; _tmp46_ = _tmp45_->strength; _tmp47_ = network; _tmp48_ = _tmp47_->strength; if (_tmp46_ < _tmp48_) { iliwiNetwork* _tmp49_; _tmp49_ = network; iliwi_wifi_thread_connection_suggestion = _tmp49_; } } } static iliwiNetwork* iliwi_wifi_thread_suggest_network (void) { iliwiNetwork* result = NULL; iliwiNetwork* suggestion; iliwiNetwork* _tmp21_; suggestion = NULL; { GeeHashMap* _tmp0_; GeeCollection* _tmp1_; GeeCollection* _tmp2_; GeeCollection* _tmp3_; GeeIterator* _tmp4_ = NULL; GeeIterator* _tmp5_; GeeIterator* _network_it; _tmp0_ = iliwi_wifi_thread_networks; _tmp1_ = gee_abstract_map_get_values ((GeeMap*) _tmp0_); _tmp2_ = _tmp1_; _tmp3_ = _tmp2_; _tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_); _tmp5_ = _tmp4_; _g_object_unref0 (_tmp3_); _network_it = _tmp5_; while (TRUE) { GeeIterator* _tmp6_; gboolean _tmp7_ = FALSE; GeeIterator* _tmp8_; gpointer _tmp9_ = NULL; iliwiNetwork* network; GeeHashMap* _tmp10_; iliwiNetwork* _tmp11_; const gchar* _tmp12_; gboolean _tmp13_ = FALSE; _tmp6_ = _network_it; _tmp7_ = gee_iterator_next (_tmp6_); if (!_tmp7_) { break; } _tmp8_ = _network_it; _tmp9_ = gee_iterator_get (_tmp8_); network = (iliwiNetwork*) _tmp9_; _tmp10_ = iliwi_wifi_thread_preferred_networks; _tmp11_ = network; _tmp12_ = _tmp11_->address; _tmp13_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp10_, _tmp12_); if (_tmp13_) { iliwiNetwork* _tmp14_; _tmp14_ = suggestion; if (_tmp14_ == NULL) { iliwiNetwork* _tmp15_; _tmp15_ = network; suggestion = _tmp15_; } else { iliwiNetwork* _tmp16_; gint _tmp17_; iliwiNetwork* _tmp18_; gint _tmp19_; _tmp16_ = network; _tmp17_ = _tmp16_->strength; _tmp18_ = suggestion; _tmp19_ = _tmp18_->strength; if (_tmp17_ > _tmp19_) { iliwiNetwork* _tmp20_; _tmp20_ = network; suggestion = _tmp20_; } } } _iliwi_network_unref0 (network); } _g_object_unref0 (_network_it); } _tmp21_ = suggestion; result = _tmp21_; return result; } iliwiWifiThread* iliwi_wifi_thread_construct (GType object_type) { iliwiWifiThread * self = NULL; self = (iliwiWifiThread*) g_object_new (object_type, NULL); return self; } iliwiWifiThread* iliwi_wifi_thread_new (void) { return iliwi_wifi_thread_construct (ILIWI_TYPE_WIFI_THREAD); } static void iliwi_wifi_thread_class_init (iliwiWifiThreadClass * klass) { iliwi_wifi_thread_parent_class = g_type_class_peek_parent (klass); G_OBJECT_CLASS (klass)->finalize = iliwi_wifi_thread_finalize; g_static_rec_mutex_init (&__lock_iliwi_wifi_thread_visible_networks); } static void iliwi_wifi_thread_instance_init (iliwiWifiThread * self) { } static void iliwi_wifi_thread_finalize (GObject* obj) { iliwiWifiThread * self; self = ILIWI_WIFI_THREAD (obj); G_OBJECT_CLASS (iliwi_wifi_thread_parent_class)->finalize (obj); } GType iliwi_wifi_thread_get_type (void) { static volatile gsize iliwi_wifi_thread_type_id__volatile = 0; if (g_once_init_enter (&iliwi_wifi_thread_type_id__volatile)) { static const GTypeInfo g_define_type_info = { sizeof (iliwiWifiThreadClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) iliwi_wifi_thread_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (iliwiWifiThread), 0, (GInstanceInitFunc) iliwi_wifi_thread_instance_init, NULL }; GType iliwi_wifi_thread_type_id; iliwi_wifi_thread_type_id = g_type_register_static (G_TYPE_OBJECT, "iliwiWifiThread", &g_define_type_info, 0); g_once_init_leave (&iliwi_wifi_thread_type_id__volatile, iliwi_wifi_thread_type_id); } return iliwi_wifi_thread_type_id__volatile; } static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) { if ((array != NULL) && (destroy_func != NULL)) { int i; for (i = 0; i < array_length; i = i + 1) { if (((gpointer*) array)[i] != NULL) { destroy_func (((gpointer*) array)[i]); } } } } static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) { _vala_array_destroy (array, array_length, destroy_func); g_free (array); } static gint _vala_array_length (gpointer array) { int length; length = 0; if (array) { while (((gpointer*) array)[length]) { length++; } } return length; }