Skip to content

Commit

Permalink
Fixed bug where ConnectWidget doesn't hold previous values like Wifi …
Browse files Browse the repository at this point in the history
…connection/AP mode/etc.
  • Loading branch information
erinharrington-12 committed Nov 23, 2022
1 parent cf6168f commit 55fdc58
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 121 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"C_Cpp.errorSquiggles": "Disabled",
"files.associations": {
"chrono": "cpp",
"variant": "cpp"
"variant": "cpp",
"*.tcc": "cpp",
"list": "cpp",
"array": "cpp",
"string_view": "cpp",
"string": "cpp"
}
}
1 change: 1 addition & 0 deletions dbus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(NETWORK_MANAGER_INTERFACES
org.freedesktop.NetworkManager.Settings
org.freedesktop.NetworkManager.AccessPoint
org.freedesktop.NetworkManager.IP4Config
org.freedesktop.NetworkManager.Connection.Active
org.freedesktop.NetworkManager
)

Expand Down
173 changes: 173 additions & 0 deletions dbus/org.freedesktop.NetworkManager.Connection.Active.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/">

<!--
org.freedesktop.NetworkManager.Connection.Active:
@short_description: Active Connection.
Objects that implement the Connection.Active interface represent an
attempt to connect to a network using the details provided by a Connection
object. The Connection.Active object tracks the life-cycle of the
connection attempt and if successful indicates whether the connected
network is the "default" or preferred network for access. NetworkManager
has the concept of connections, which can be thought of as settings, a
profile or a configuration that can be applied on a networking device.
Such settings-connections are exposed as D-Bus object and the
active-connection expresses this relationship between device and
settings-connection. At any time a settings-connection can only be
activated on one device and vice versa. However, during activation and
deactivation multiple active-connections can reference the same device or
settings-connection as they are waiting to be activated or to be
deactivated.
-->
<interface name="org.freedesktop.NetworkManager.Connection.Active">
<annotation name="org.gtk.GDBus.C.Name" value="ActiveConnection"/>

<!--
Connection:
The path of the connection.
-->
<property name="Connection" type="o" access="read"/>

<!--
SpecificObject:
A specific object associated with the active connection. This property
reflects the specific object used during connection activation, and will
not change over the lifetime of the ActiveConnection once set.
-->
<property name="SpecificObject" type="o" access="read"/>

<!--
Id:
The ID of the connection, provided as a convenience so that clients do not
have to retrieve all connection details.
-->
<property name="Id" type="s" access="read"/>

<!--
Uuid:
The UUID of the connection, provided as a convenience so that clients do
not have to retrieve all connection details.
-->
<property name="Uuid" type="s" access="read"/>

<!--
Type:
The type of the connection, provided as a convenience so that clients do
not have to retrieve all connection details.
-->
<property name="Type" type="s" access="read"/>

<!--
Devices:
Array of object paths representing devices which are part of this active
connection.
-->
<property name="Devices" type="ao" access="read"/>

<!--
State:
The state of this active connection.
Returns: <link linkend="NMActiveConnectionState">NMActiveConnectionState</link>
-->
<property name="State" type="u" access="read"/>

<!--
StateFlags:
The state flags of this active connection.
Returns: <link linkend="NMActivationStateFlags">NMActivationStateFlags</link>
-->
<property name="StateFlags" type="u" access="read"/>

<!--
StateChanged:
@state: (<link linkend="NMActiveConnectionState">NMActiveConnectionState</link>) The new state of the active connection.
@reason: (<link linkend="NMActiveConnectionStateReason">NMActiveConnectionStateReason</link>) Reason code describing the change to the new state.
@since: 1.8
Emitted when the state of the active connection has changed.
-->
<signal name="StateChanged">
<arg name="state" type="u"/>
<arg name="reason" type="u"/>
</signal>

<!--
Default:
Whether this active connection is the default IPv4 connection, i.e.
whether it currently owns the default IPv4 route.
-->
<property name="Default4" type="b" access="read"/>

<!--
Ip4Config:
Object path of the Ip4Config object describing the configuration of the
connection. Only valid when the connection is in the
NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
-->
<property name="Ip4Config" type="o" access="read"/>

<!--
Dhcp4Config:
Object path of the Dhcp4Config object describing the DHCP options returned
by the DHCP server (assuming the connection used DHCP). Only valid when
the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
-->
<property name="Dhcp4Config" type="o" access="read"/>

<!--
Default6:
Whether this active connection is the default IPv6 connection, i.e.
whether it currently owns the default IPv6 route.
-->
<property name="Default6" type="b" access="read"/>

<!--
Ip6Config:
Object path of the Ip6Config object describing the configuration of the
connection. Only valid when the connection is in the
NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
-->
<property name="Ip6Config" type="o" access="read"/>

<!--
Dhcp6Config:
Object path of the Dhcp6Config object describing the DHCP options returned
by the DHCP server (assuming the connection used DHCP). Only valid when
the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
-->
<property name="Dhcp6Config" type="o" access="read"/>

<!--
Vpn:
Whether this active connection is also a VPN connection.
-->
<property name="Vpn" type="b" access="read"/>

<!--
Master:
The path to the master device if the connection is a slave.
-->
<property name="Master" type="o" access="read"/>

</interface>
</node>
4 changes: 4 additions & 0 deletions include/botui/NetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ Q_OBJECT
QString ip4Address() const;

Connection createAPConfig() const ;

QString currentActiveConnectionName() const;

bool isActiveConnectionOn() const;

public slots:
bool turnOn();
Expand Down
6 changes: 1 addition & 5 deletions include/botui/NetworkSettingsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ public slots:
void connect();
void manage();
void updateInformation();
void enableAP();
void disableAP();
void enableAPControls();
void disableAPControls();
void disableAPControlsTemporarily();



private slots:
Expand Down
54 changes: 30 additions & 24 deletions include/botui/RootController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,65 @@
#include <QStack>
#include <QUrl>
#include <QMap>

#include "NetworkSettingsWidget.h"
#include "Singleton.h"

class RootController : public QObject, public Singleton<RootController>
{
Q_OBJECT
Q_PROPERTY(bool dismissable READ isDismissable WRITE setDismissable)
Q_PROPERTY(unsigned int depth READ depth)
Q_OBJECT
Q_PROPERTY(bool dismissable READ isDismissable WRITE setDismissable)
Q_PROPERTY(unsigned int depth READ depth)
public:
RootController();

const unsigned int depth() const;

void setDismissable(bool dismissable);
bool isDismissable() const;
void setFullscreen(const bool fullscreen);
bool isFullscreen() const;
template<typename T>

void setFullscreen(const bool fullscreen);
bool isFullscreen() const;

template <typename T>
void dismissUntil()
{
while(depth() > 1 && !dynamic_cast<T *>(m_stack.top())) m_stack.pop();
while (depth() > 1 && !dynamic_cast<T *>(m_stack.top()))
m_stack.pop();
}
template<typename T>

template <typename T>
bool containsWidget()
{
QStack<QWidget *>::ConstIterator it = m_stack.begin();
for(; it != m_stack.end(); ++it) {
if(dynamic_cast<T *>(*it)) return true;
for (; it != m_stack.end(); ++it)
{
if (dynamic_cast<T *>(*it))
return true;
}
return false;
}

public slots:
void presentQml(const QUrl& url);
void presentQml(const QUrl &url);
int presentDialog(QDialog *dialog);
void presentWidget(QWidget *widget, bool owns = true);

void dismissWidget();
void dismissAllWidgets();

void minimize();

void findNetworkSettingsWidget() const;
void addNetworkSettingsStack(NetworkSettingsWidget *networkWidget) ;
void minimize();
void printStack();
void getNetworkSettingsWidget();

private:
void constrain(QWidget *widget);
void present(QWidget *widget);

QMap<QWidget *, bool> m_ownership;
QStack<QWidget *> m_stack;
bool m_dismissable;
bool m_fullscreen;
bool m_fullscreen;
};

#endif
11 changes: 3 additions & 8 deletions src/AboutWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ AboutWidget::AboutWidget(Device *device, QWidget *parent)
ui(new Ui::AboutWidget)
{
ui->setupUi(this);

// Setup the UI
performStandardSetup(tr("About"));
// Version Number
ui->version->setText("Version 27.0 (Quark)");

Expand All @@ -22,11 +23,6 @@ AboutWidget::AboutWidget(Device *device, QWidget *parent)
const QString serial = device->serial();
ui->deviceName->setText("Wombat-" + serial);


//QDBusObjectPath ip4Config = m_device.ip4Config();
qDebug() << "IP Address: " << NetworkManager::ref().ip4Address();


// Check if eth0 is active (/sys/class/net/eth0/carrier will output 1 if eth0 is active and 0 if it is not)
QProcess proc;
proc.start("cat /sys/class/net/eth0/carrier");
Expand Down Expand Up @@ -62,8 +58,7 @@ AboutWidget::AboutWidget(Device *device, QWidget *parent)
ui->ssid->setText(ssid);
ui->password->setText(password);
}
// Setup the UI
performStandardSetup(tr("About"));

}

AboutWidget::~AboutWidget()
Expand Down
4 changes: 2 additions & 2 deletions src/AdvancedSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(Device *device, QWidget *parent)
#else
ui->network->setEnabled(true);
#endif

connect(ui->network, SIGNAL(clicked()), SLOT(network()));
connect(ui->factory, SIGNAL(clicked()), SLOT(factory()));
connect(ui->gui, SIGNAL(clicked()), SLOT(gui()));
Expand All @@ -45,7 +45,7 @@ AdvancedSettingsWidget::~AdvancedSettingsWidget()
void AdvancedSettingsWidget::network()
{
#ifdef NETWORK_ENABLED
RootController::ref().presentWidget(new NetworkSettingsWidget(device()));
RootController::ref().getNetworkSettingsWidget();

#endif
}
Expand Down
1 change: 1 addition & 0 deletions src/HomeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void HomeWidget::settings()
void HomeWidget::about()
{
RootController::ref().presentWidget(new AboutWidget(device()));
RootController::ref().printStack();
}

void HomeWidget::shutDown()
Expand Down
Loading

0 comments on commit 55fdc58

Please sign in to comment.