/* AbstractModemInterface.c generated by valac 0.56.19, the Vala compiler
 * generated from AbstractModemInterface.vala, do not modify */

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright 2017-2020 elementary, Inc. (https://elementary.io)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program 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 Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: David Hewitt <davidmhewitt@gmail.com>
 */

#include "networkapplet.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <NetworkManager.h>
#include <glib/gi18n-lib.h>
#include <glib-object.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	NETWORK_ABSTRACT_MODEM_INTERFACE_0_PROPERTY,
	NETWORK_ABSTRACT_MODEM_INTERFACE_NUM_PROPERTIES
};
static GParamSpec* network_abstract_modem_interface_properties[NETWORK_ABSTRACT_MODEM_INTERFACE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer network_abstract_modem_interface_parent_class = NULL;
static GType network_abstract_modem_interface_type_id = 0;

static void network_abstract_modem_interface_real_update_name (NetworkWidgetNMInterface* base,
                                                        gint count);

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
network_abstract_modem_interface_real_update_name (NetworkWidgetNMInterface* base,
                                                   gint count)
{
	NetworkAbstractModemInterface * self;
	gchar* name = NULL;
	NMDevice* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	NMDevice* _tmp6_;
	self = (NetworkAbstractModemInterface*) base;
	_tmp0_ = ((NetworkWidgetNMInterface*) self)->device;
	_tmp1_ = nm_device_get_description (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	name = _tmp2_;
	if (count > 1) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = name;
		_tmp4_ = g_strdup_printf (_ ("Mobile Broadband: %s"), _tmp3_);
		_tmp5_ = _tmp4_;
		network_widget_nm_interface_set_display_title ((NetworkWidgetNMInterface*) self, _tmp5_);
		_g_free0 (_tmp5_);
	} else {
		network_widget_nm_interface_set_display_title ((NetworkWidgetNMInterface*) self, _ ("Mobile Broadband"));
	}
	_tmp6_ = ((NetworkWidgetNMInterface*) self)->device;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp6_, nm_device_modem_get_type ())) {
		NMDeviceModem* device = NULL;
		NMDevice* _tmp7_;
		NMDeviceModem* _tmp8_;
		NMDeviceModem* _tmp9_;
		_tmp7_ = ((NetworkWidgetNMInterface*) self)->device;
		_tmp8_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, nm_device_modem_get_type ()) ? ((NMDeviceModem*) _tmp7_) : NULL);
		device = _tmp8_;
		_tmp9_ = device;
		if (_tmp9_ != NULL) {
			NMDeviceModemCapabilities capabilities = 0U;
			NMDeviceModem* _tmp10_;
			_tmp10_ = device;
			capabilities = nm_device_modem_get_current_capabilities (_tmp10_);
			if ((capabilities & NM_DEVICE_MODEM_CAPABILITY_POTS) == NM_DEVICE_MODEM_CAPABILITY_POTS) {
				network_widget_nm_interface_set_display_title ((NetworkWidgetNMInterface*) self, _ ("Modem"));
			}
		}
		_g_object_unref0 (device);
	}
	_g_free0 (name);
}

NetworkAbstractModemInterface*
network_abstract_modem_interface_construct (GType object_type)
{
	NetworkAbstractModemInterface * self = NULL;
	self = (NetworkAbstractModemInterface*) network_widget_nm_interface_construct (object_type);
	return self;
}

static void
network_abstract_modem_interface_class_init (NetworkAbstractModemInterfaceClass * klass,
                                             gpointer klass_data)
{
	network_abstract_modem_interface_parent_class = g_type_class_peek_parent (klass);
	((NetworkWidgetNMInterfaceClass *) klass)->update_name = (void (*) (NetworkWidgetNMInterface*, gint)) network_abstract_modem_interface_real_update_name;
}

static void
network_abstract_modem_interface_instance_init (NetworkAbstractModemInterface * self,
                                                gpointer klass)
{
}

GType
network_abstract_modem_interface_get_type (void)
{
	return network_abstract_modem_interface_type_id;
}

GType
network_abstract_modem_interface_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (NetworkAbstractModemInterfaceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) network_abstract_modem_interface_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NetworkAbstractModemInterface), 0, (GInstanceInitFunc) network_abstract_modem_interface_instance_init, NULL };
	network_abstract_modem_interface_type_id = g_type_module_register_type (module, NETWORK_TYPE_WIDGET_NM_INTERFACE, "NetworkAbstractModemInterface", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return network_abstract_modem_interface_type_id;
}

