Passing arguments by reference (#21205)
old-commit-hash: ee46672d3c8c86b41fd8ae2fce9120e050b8e628
This commit is contained in:
@@ -41,7 +41,7 @@ Pigeon * Pigeon::connect(const char * tty){
|
||||
return pigeon;
|
||||
}
|
||||
|
||||
bool Pigeon::wait_for_ack(std::string ack, std::string nack){
|
||||
bool Pigeon::wait_for_ack(const std::string &ack, const std::string &nack){
|
||||
std::string s;
|
||||
while (!do_exit){
|
||||
s += receive();
|
||||
@@ -66,7 +66,7 @@ bool Pigeon::wait_for_ack(){
|
||||
return wait_for_ack(ack, nack);
|
||||
}
|
||||
|
||||
bool Pigeon::send_with_ack(std::string cmd){
|
||||
bool Pigeon::send_with_ack(const std::string &cmd){
|
||||
send(cmd);
|
||||
return wait_for_ack();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ class Pigeon {
|
||||
void init();
|
||||
void stop();
|
||||
bool wait_for_ack();
|
||||
bool wait_for_ack(std::string ack, std::string nack);
|
||||
bool send_with_ack(std::string cmd);
|
||||
bool wait_for_ack(const std::string &ack, const std::string &nack);
|
||||
bool send_with_ack(const std::string &cmd);
|
||||
virtual void set_baud(int baud) = 0;
|
||||
virtual void send(const std::string &s) = 0;
|
||||
virtual std::string receive() = 0;
|
||||
|
||||
@@ -76,7 +76,7 @@ std::string read_file(const std::string& fn) {
|
||||
return buffer.str();
|
||||
}
|
||||
|
||||
int read_files_in_dir(std::string path, std::map<std::string, std::string> *contents) {
|
||||
int read_files_in_dir(const std::string &path, std::map<std::string, std::string> *contents) {
|
||||
DIR *d = opendir(path.c_str());
|
||||
if (!d) return -1;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ std::string dir_name(std::string const& path);
|
||||
|
||||
// **** file fhelpers *****
|
||||
std::string read_file(const std::string& fn);
|
||||
int read_files_in_dir(std::string path, std::map<std::string, std::string>* contents);
|
||||
int read_files_in_dir(const std::string& path, std::map<std::string, std::string>* contents);
|
||||
int write_file(const char* path, const void* data, size_t size, int flags = O_WRONLY, mode_t mode = 0777);
|
||||
std::string readlink(const std::string& path);
|
||||
bool file_exists(const std::string& fn);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace ublox {
|
||||
uint32_t tAccNs;
|
||||
} __attribute__((packed));
|
||||
|
||||
inline std::string ubx_add_checksum(std::string msg){
|
||||
inline std::string ubx_add_checksum(const std::string &msg){
|
||||
assert(msg.size() > 2);
|
||||
|
||||
uint8_t ck_a = 0, ck_b = 0;
|
||||
|
||||
@@ -106,7 +106,7 @@ void Networking::refresh(){
|
||||
an->refresh();
|
||||
}
|
||||
|
||||
void Networking::connectToNetwork(Network n) {
|
||||
void Networking::connectToNetwork(const Network &n) {
|
||||
if (n.security_type == SecurityType::OPEN) {
|
||||
wifi->connect(n);
|
||||
} else if (n.security_type == SecurityType::WPA) {
|
||||
@@ -115,7 +115,7 @@ void Networking::connectToNetwork(Network n) {
|
||||
}
|
||||
}
|
||||
|
||||
void Networking::wrongPassword(QString ssid) {
|
||||
void Networking::wrongPassword(const QString &ssid) {
|
||||
for (Network n : wifi->seen_networks) {
|
||||
if (n.ssid == ssid) {
|
||||
QString pass = InputDialog::getText("Wrong password for \"" + n.ssid +"\"", 8);
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
bool tetheringEnabled;
|
||||
|
||||
signals:
|
||||
void connectToNetwork(Network n);
|
||||
void connectToNetwork(const Network &n);
|
||||
|
||||
public slots:
|
||||
void refresh();
|
||||
@@ -81,8 +81,8 @@ private:
|
||||
void attemptInitialization();
|
||||
|
||||
private slots:
|
||||
void connectToNetwork(Network n);
|
||||
void connectToNetwork(const Network &n);
|
||||
void refresh();
|
||||
void wrongPassword(QString ssid);
|
||||
void wrongPassword(const QString &ssid);
|
||||
};
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ QList<Network> WifiManager::get_networks() {
|
||||
return r;
|
||||
}
|
||||
|
||||
SecurityType WifiManager::getSecurityType(QString path) {
|
||||
SecurityType WifiManager::getSecurityType(const QString &path) {
|
||||
int sflag = get_property(path, "Flags").toInt();
|
||||
int wpaflag = get_property(path, "WpaFlags").toInt();
|
||||
int rsnflag = get_property(path, "RsnFlags").toInt();
|
||||
@@ -202,22 +202,22 @@ SecurityType WifiManager::getSecurityType(QString path) {
|
||||
}
|
||||
}
|
||||
|
||||
void WifiManager::connect(Network n) {
|
||||
void WifiManager::connect(const Network &n) {
|
||||
return connect(n, "", "");
|
||||
}
|
||||
|
||||
void WifiManager::connect(Network n, QString password) {
|
||||
void WifiManager::connect(const Network &n, const QString &password) {
|
||||
return connect(n, "", password);
|
||||
}
|
||||
|
||||
void WifiManager::connect(Network n, QString username, QString password) {
|
||||
void WifiManager::connect(const Network &n, const QString &username, const QString &password) {
|
||||
connecting_to_network = n.ssid;
|
||||
// disconnect();
|
||||
clear_connections(n.ssid); //Clear all connections that may already exist to the network we are connecting
|
||||
connect(n.ssid, username, password, n.security_type);
|
||||
}
|
||||
|
||||
void WifiManager::connect(QByteArray ssid, QString username, QString password, SecurityType security_type) {
|
||||
void WifiManager::connect(const QByteArray &ssid, const QString &username, const QString &password, SecurityType security_type) {
|
||||
Connection connection;
|
||||
connection["connection"]["type"] = "802-11-wireless";
|
||||
connection["connection"]["uuid"] = QUuid::createUuid().toString().remove('{').remove('}');
|
||||
@@ -243,7 +243,7 @@ void WifiManager::connect(QByteArray ssid, QString username, QString password, S
|
||||
activate_wifi_connection(QString(ssid));
|
||||
}
|
||||
|
||||
void WifiManager::deactivate_connections(QString ssid) {
|
||||
void WifiManager::deactivate_connections(const QString &ssid) {
|
||||
for (QDBusObjectPath active_connection_raw : get_active_connections()) {
|
||||
QString active_connection = active_connection_raw.path();
|
||||
QDBusInterface nm(nm_service, active_connection, props_iface, bus);
|
||||
@@ -279,7 +279,7 @@ QVector<QDBusObjectPath> WifiManager::get_active_connections() {
|
||||
return conns;
|
||||
}
|
||||
|
||||
void WifiManager::clear_connections(QString ssid) {
|
||||
void WifiManager::clear_connections(const QString &ssid) {
|
||||
for(QDBusObjectPath path : list_connections()){
|
||||
QDBusInterface nm2(nm_service, path.path(), nm_settings_conn_iface, bus);
|
||||
nm2.setTimeout(dbus_timeout);
|
||||
@@ -327,7 +327,7 @@ QString WifiManager::get_active_ap() {
|
||||
return r.path();
|
||||
}
|
||||
|
||||
QByteArray WifiManager::get_property(QString network_path ,QString property) {
|
||||
QByteArray WifiManager::get_property(const QString &network_path , const QString &property) {
|
||||
QDBusInterface device_props(nm_service, network_path, props_iface, bus);
|
||||
device_props.setTimeout(dbus_timeout);
|
||||
|
||||
@@ -335,7 +335,7 @@ QByteArray WifiManager::get_property(QString network_path ,QString property) {
|
||||
return get_response<QByteArray>(response);
|
||||
}
|
||||
|
||||
unsigned int WifiManager::get_ap_strength(QString network_path) {
|
||||
unsigned int WifiManager::get_ap_strength(const QString &network_path) {
|
||||
QDBusInterface device_props(nm_service, network_path, props_iface, bus);
|
||||
device_props.setTimeout(dbus_timeout);
|
||||
|
||||
@@ -409,7 +409,7 @@ QVector<QDBusObjectPath> WifiManager::list_connections(){
|
||||
return connections;
|
||||
}
|
||||
|
||||
bool WifiManager::activate_wifi_connection(QString ssid){
|
||||
bool WifiManager::activate_wifi_connection(const QString &ssid){
|
||||
QString devicePath = get_adapter();
|
||||
|
||||
for(QDBusObjectPath path : list_connections()){
|
||||
@@ -514,7 +514,7 @@ bool WifiManager::tetheringEnabled() {
|
||||
return get_property(active_ap, "Ssid") == tethering_ssid;
|
||||
}
|
||||
|
||||
void WifiManager::changeTetheringPassword(QString newPassword){
|
||||
void WifiManager::changeTetheringPassword(const QString &newPassword) {
|
||||
tetheringPassword = newPassword;
|
||||
clear_connections(tethering_ssid.toUtf8());
|
||||
addTetheringConnection();
|
||||
|
||||
@@ -35,9 +35,9 @@ public:
|
||||
QString ipv4_address;
|
||||
|
||||
void refreshNetworks();
|
||||
void connect(Network ssid);
|
||||
void connect(Network ssid, QString password);
|
||||
void connect(Network ssid, QString username, QString password);
|
||||
void connect(const Network &ssid);
|
||||
void connect(const Network &ssid, const QString &password);
|
||||
void connect(const Network &ssid, const QString &username, const QString &password);
|
||||
void disconnect();
|
||||
|
||||
// Tethering functions
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
|
||||
bool activate_tethering_connection();
|
||||
void addTetheringConnection();
|
||||
bool activate_wifi_connection(QString ssid);
|
||||
void changeTetheringPassword(QString newPassword);
|
||||
bool activate_wifi_connection(const QString &ssid);
|
||||
void changeTetheringPassword(const QString &newPassword);
|
||||
|
||||
private:
|
||||
QVector<QByteArray> seen_ssids;
|
||||
@@ -62,21 +62,21 @@ private:
|
||||
QString get_adapter();
|
||||
QString get_ipv4_address();
|
||||
QList<Network> get_networks();
|
||||
void connect(QByteArray ssid, QString username, QString password, SecurityType security_type);
|
||||
void connect(const QByteArray &ssid, const QString &username, const QString &password, SecurityType security_type);
|
||||
QString get_active_ap();
|
||||
void deactivate_connections(QString ssid);
|
||||
void clear_connections(QString ssid);
|
||||
void deactivate_connections(const QString &ssid);
|
||||
void clear_connections(const QString &ssid);
|
||||
QVector<QDBusObjectPath> get_active_connections();
|
||||
uint get_wifi_device_state();
|
||||
QByteArray get_property(QString network_path, QString property);
|
||||
unsigned int get_ap_strength(QString network_path);
|
||||
SecurityType getSecurityType(QString ssid);
|
||||
QByteArray get_property(const QString &network_path, const QString &property);
|
||||
unsigned int get_ap_strength(const QString &network_path);
|
||||
SecurityType getSecurityType(const QString &ssid);
|
||||
QVector<QDBusObjectPath> list_connections();
|
||||
|
||||
private slots:
|
||||
void change(unsigned int new_state, unsigned int previous_state, unsigned int change_reason);
|
||||
signals:
|
||||
void wrongPassword(QString ssid);
|
||||
void successfulConnection(QString ssid);
|
||||
void wrongPassword(const QString &ssid);
|
||||
void successfulConnection(const QString &ssid);
|
||||
void refresh();
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ void PairingQRWidget::refresh(){
|
||||
this->updateQrCode(qrString);
|
||||
}
|
||||
|
||||
void PairingQRWidget::updateQrCode(QString text) {
|
||||
void PairingQRWidget::updateQrCode(const QString &text) {
|
||||
QrCode qr = QrCode::encodeText(text.toUtf8().data(), QrCode::Ecc::LOW);
|
||||
qint32 sz = qr.getSize();
|
||||
// make the image larger so we can have a white border
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
|
||||
private:
|
||||
QLabel* qrCode;
|
||||
void updateQrCode(QString text);
|
||||
void updateQrCode(const QString &text);
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user