@ -213,7 +213,7 @@ void WifiManager::connect(const Network &n, const 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
   
			
		
	
		
			
				
					  forgetNetwork ( n . ssid ) ;  //Clear all connections that may already exist to the network we are connecting
   
			
		
	
		
			
				
					  connect ( n . ssid ,  username ,  password ,  n . security_type ) ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -240,10 +240,10 @@ void WifiManager::connect(const QByteArray &ssid, const QString &username, const 
			
		
	
		
			
				
					  nm_settings . setTimeout ( dbus_timeout ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  nm_settings . call ( " AddConnection " ,  QVariant : : fromValue ( connection ) ) ;   
			
		
	
		
			
				
					  activate_wifi_c onnection ( QString ( ssid ) ) ;   
			
		
	
		
			
				
					  activateWifiC onnection ( QString ( ssid ) ) ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					void  WifiManager : : deactivate_connections  ( const  QString  & ssid )  {  
			
		
	
		
			
				
					void  WifiManager : : deactivateConnection  ( 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 ) ;   
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -255,7 +255,7 @@ void WifiManager::deactivate_connections(const QString &ssid) { 
			
		
	
		
			
				
					      if  ( Ssid  = =  ssid )  {   
			
		
	
		
			
				
					        QDBusInterface  nm2 ( nm_service ,  nm_path ,  nm_iface ,  bus ) ;   
			
		
	
		
			
				
					        nm2 . setTimeout ( dbus_timeout ) ;   
			
		
	
		
			
				
					        nm2 . call ( " DeactivateConnection " ,  QVariant : : fromValue ( active_connection_raw ) ) ; // TODO change to disconnect
   
			
		
	
		
			
				
					        nm2 . call ( " DeactivateConnection " ,  QVariant : : fromValue ( active_connection_raw ) ) ;   
			
		
	
		
			
				
					      }   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					  }   
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -279,29 +279,17 @@ QVector<QDBusObjectPath> WifiManager::get_active_connections() { 
			
		
	
		
			
				
					  return  conns ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					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 ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    QDBusMessage  response  =  nm2 . call ( " GetSettings " ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    const  QDBusArgument  & dbusArg  =  response . arguments ( ) . at ( 0 ) . value < QDBusArgument > ( ) ;   
			
		
	
		
			
				
					bool  WifiManager : : isKnownNetwork ( const  QString  & ssid )  {  
			
		
	
		
			
				
					  return  ! pathFromSsid ( ssid ) . path ( ) . isEmpty ( ) ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    QMap < QString ,  QMap < QString , QVariant > >  map ;   
			
		
	
		
			
				
					    dbusArg  > >  map ;   
			
		
	
		
			
				
					    for  ( auto  & inner  :  map )  {   
			
		
	
		
			
				
					      for  ( auto  & val  :  inner )  {   
			
		
	
		
			
				
					        QString  key  =  inner . key ( val ) ;   
			
		
	
		
			
				
					        if  ( key  = =  " ssid " )  {   
			
		
	
		
			
				
					          if  ( val  = =  ssid )  {   
			
		
	
		
			
				
					void  WifiManager : : forgetNetwork ( const  QString  & ssid )  {  
			
		
	
		
			
				
					  QDBusObjectPath  path  =  pathFromSsid ( ssid ) ;   
			
		
	
		
			
				
					  if  ( ! path . path ( ) . isEmpty ( ) )  {   
			
		
	
		
			
				
					    QDBusInterface  nm2 ( nm_service ,  path . path ( ) ,  nm_settings_conn_iface ,  bus ) ;   
			
		
	
		
			
				
					    nm2 . call ( " Delete " ) ;   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					      }   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					void  WifiManager : : request_scan ( )  {  
			
		
	
		
			
				
					  QDBusInterface  nm ( nm_service ,  adapter ,  wireless_device_iface ,  bus ) ;   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -388,12 +376,22 @@ void WifiManager::change(unsigned int new_state, unsigned int previous_state, un 
			
		
	
		
			
				
					void  WifiManager : : disconnect ( )  {  
			
		
	
		
			
				
					  QString  active_ap  =  get_active_ap ( ) ;   
			
		
	
		
			
				
					  if  ( active_ap  ! =  " "  & &  active_ap  ! =  " / " )  {   
			
		
	
		
			
				
					    deactivate_connections  ( get_property ( active_ap ,  " Ssid " ) ) ;   
			
		
	
		
			
				
					    deactivateConnection  ( get_property ( active_ap ,  " Ssid " ) ) ;   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					QVector < QDBusObjectPath >  WifiManager : : list_connections ( )  {  
			
		
	
		
			
				
					  QVector < QDBusObjectPath >  connections ;   
			
		
	
		
			
				
					QDBusObjectPath  WifiManager : : pathFromSsid ( const  QString  & ssid )  {  
			
		
	
		
			
				
					  QDBusObjectPath  path ;   // returns uninitialized path if network is not known
   
			
		
	
		
			
				
					  for  ( auto  const &  [ conn_ssid ,  conn_path ]  :  listConnections ( ) )  {   
			
		
	
		
			
				
					    if  ( conn_ssid  = =  ssid )  {   
			
		
	
		
			
				
					      path  =  conn_path ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					  return  path ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					QVector < QPair < QString ,  QDBusObjectPath > >  WifiManager : : listConnections ( )  {  
			
		
	
		
			
				
					  QVector < QPair < QString ,  QDBusObjectPath > >  connections ;   
			
		
	
		
			
				
					  QDBusInterface  nm ( nm_service ,  nm_settings_path ,  nm_settings_iface ,  bus ) ;   
			
		
	
		
			
				
					  nm . setTimeout ( dbus_timeout ) ;   
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -404,68 +402,33 @@ QVector<QDBusObjectPath> WifiManager::list_connections() { 
			
		
	
		
			
				
					  while  ( ! args . atEnd ( ) )  {   
			
		
	
		
			
				
					    QDBusObjectPath  path ;   
			
		
	
		
			
				
					    args  > >  path ;   
			
		
	
		
			
				
					    connections . push_back ( path ) ;   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					  return  connections ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					bool  WifiManager : : activate_wifi_connection ( const  QString  & ssid )  {  
			
		
	
		
			
				
					  QString  devicePath  =  get_adapter ( ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  for ( QDBusObjectPath  path  :  list_connections ( ) )  {   
			
		
	
		
			
				
					    // Get ssid
   
			
		
	
		
			
				
					    QDBusInterface  nm2 ( nm_service ,  path . path ( ) ,  nm_settings_conn_iface ,  bus ) ;   
			
		
	
		
			
				
					    nm2 . setTimeout ( dbus_timeout ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    QDBusMessage  response  =  nm2 . call ( " GetSettings " ) ;   
			
		
	
		
			
				
					    const  QDBusArgument  & dbusArg  =  response . arguments ( ) . at ( 0 ) . value < QDBusArgument > ( ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    QMap < QString ,  QMap < QString ,  QVariant > >  map ;   
			
		
	
		
			
				
					    dbusArg  > >  map ;   
			
		
	
		
			
				
					    for  ( auto  & inner  :  map )  {   
			
		
	
		
			
				
					      for  ( auto  & val  :  inner )  {   
			
		
	
		
			
				
					        QString  key  =  inner . key ( val ) ;   
			
		
	
		
			
				
					        if  ( key  = =  " ssid " )  {   
			
		
	
		
			
				
					          if  ( val  = =  ssid )  {   
			
		
	
		
			
				
					            QDBusInterface  nm3 ( nm_service ,  nm_path ,  nm_iface ,  bus ) ;   
			
		
	
		
			
				
					            nm3 . setTimeout ( dbus_timeout ) ;   
			
		
	
		
			
				
					            nm3 . call ( " ActivateConnection " ,  QVariant : : fromValue ( path ) ,  QVariant : : fromValue ( QDBusObjectPath ( devicePath ) ) ,  QVariant : : fromValue ( QDBusObjectPath ( " / " ) ) ) ;   
			
		
	
		
			
				
					            return  true ;   
			
		
	
		
			
				
					          }   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					      }   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    const  QString  ssid  =  map . value ( " 802-11-wireless " ) . value ( " ssid " ) . toString ( ) ;   
			
		
	
		
			
				
					    connections . push_back ( qMakePair ( ssid ,  path ) ) ;   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					  return  false ;   
			
		
	
		
			
				
					  return  connections ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					//Functions for tethering
  
			
		
	
		
			
				
					bool  WifiManager : : activate_tethering_connection ( )  {  
			
		
	
		
			
				
					  QString  devicePath  =  get_adapter ( ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  for ( QDBusObjectPath  path  :  list_connections ( ) )  {   
			
		
	
		
			
				
					    QDBusInterface  nm2 ( nm_service ,  path . path ( ) ,  nm_settings_conn_iface ,  bus ) ;   
			
		
	
		
			
				
					    nm2 . setTimeout ( dbus_timeout ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    QDBusMessage  response  =  nm2 . call ( " GetSettings " ) ;   
			
		
	
		
			
				
					    const  QDBusArgument  & dbusArg  =  response . arguments ( ) . at ( 0 ) . value < QDBusArgument > ( ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    QMap < QString ,  QMap < QString , QVariant > >  map ;   
			
		
	
		
			
				
					    dbusArg  > >  map ;   
			
		
	
		
			
				
					    for  ( auto  & inner  :  map )  {   
			
		
	
		
			
				
					      for  ( auto  & val  :  inner )  {   
			
		
	
		
			
				
					        QString  key  =  inner . key ( val ) ;   
			
		
	
		
			
				
					        if  ( key  = =  " ssid " )  {   
			
		
	
		
			
				
					          if  ( val  = =  tethering_ssid . toUtf8 ( ) )  {   
			
		
	
		
			
				
					void  WifiManager : : activateWifiConnection ( const  QString  & ssid )  {  
			
		
	
		
			
				
					  QDBusObjectPath  path  =  pathFromSsid ( ssid ) ;   
			
		
	
		
			
				
					  if  ( ! path . path ( ) . isEmpty ( ) )  {   
			
		
	
		
			
				
					    QString  devicePath  =  get_adapter ( ) ;   
			
		
	
		
			
				
					    QDBusInterface  nm3 ( nm_service ,  nm_path ,  nm_iface ,  bus ) ;   
			
		
	
		
			
				
					    nm3 . setTimeout ( dbus_timeout ) ;   
			
		
	
		
			
				
					    nm3 . call ( " ActivateConnection " ,  QVariant : : fromValue ( path ) ,  QVariant : : fromValue ( QDBusObjectPath ( devicePath ) ) ,  QVariant : : fromValue ( QDBusObjectPath ( " / " ) ) ) ;   
			
		
	
		
			
				
					            return  true ;   
			
		
	
		
			
				
					          }   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					      }   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					  return  false ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					// Functions for tethering
  
			
		
	
		
			
				
					void  WifiManager : : addTetheringConnection ( )  {  
			
		
	
		
			
				
					  Connection  connection ;   
			
		
	
		
			
				
					  connection [ " connection " ] [ " id " ]  =  " Hotspot " ;   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -499,15 +462,14 @@ void WifiManager::addTetheringConnection() { 
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					void  WifiManager : : enableTethering ( )  {  
			
		
	
		
			
				
					  if ( activate_tethering_connection ( ) )  {   
			
		
	
		
			
				
					    return ;   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					  if  ( ! isKnownNetwork ( tethering_ssid . toUtf8 ( ) ) )  {   
			
		
	
		
			
				
					    addTetheringConnection ( ) ;   
			
		
	
		
			
				
					  activate_tethering_connection ( ) ;   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					  activateWifiConnection ( tethering_ssid . toUtf8 ( ) ) ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					void  WifiManager : : disableTethering ( )  {  
			
		
	
		
			
				
					  deactivate_connections  ( tethering_ssid . toUtf8 ( ) ) ;   
			
		
	
		
			
				
					  deactivateConnection  ( tethering_ssid . toUtf8 ( ) ) ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					bool  WifiManager : : tetheringEnabled ( )  {  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -517,6 +479,8 @@ bool WifiManager::tetheringEnabled() { 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					void  WifiManager : : changeTetheringPassword ( const  QString  & newPassword )  {  
			
		
	
		
			
				
					  tetheringPassword  =  newPassword ;   
			
		
	
		
			
				
					  clear_connections ( tethering_ssid . toUtf8 ( ) ) ;   
			
		
	
		
			
				
					  if  ( isKnownNetwork ( tethering_ssid . toUtf8 ( ) ) )  {   
			
		
	
		
			
				
					    forgetNetwork ( tethering_ssid . toUtf8 ( ) ) ;   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					  addTetheringConnection ( ) ;   
			
		
	
		
			
				
					}