@@ -383,7 +383,7 @@ namespace WPEFramework
383383
384384 static void wifiConnectionUpdate (GObject *rmObject, GAsyncResult *res, gpointer user_data)
385385 {
386- NMRemoteConnection *remote_con = NM_REMOTE_CONNECTION (rmObject);
386+ NMRemoteConnection *remote_con = NM_REMOTE_CONNECTION (rmObject);
387387 wifiManager *_wifiManager = (static_cast <wifiManager*>(user_data));
388388 GVariant *ret = NULL ;
389389 GError *error = NULL ;
@@ -540,6 +540,74 @@ namespace WPEFramework
540540 return true ;
541541 }
542542
543+ bool wifiManager::activateKnownWifiConnection (std::string knownssid)
544+ {
545+ NMAccessPoint *AccessPoint = NULL ;
546+ const GPtrArray *wifiConnections = NULL ;
547+ NMConnection *m_connection = NULL ;
548+ const GPtrArray* ApList = NULL ;
549+ const char * specificObjPath = " /" ;
550+
551+ if (!createClientNewConnection ())
552+ return false ;
553+
554+ NMDevice *m_wifidevice = getWifiDevice ();
555+ if (m_wifidevice == NULL ) {
556+ NMLOG_WARNING (" wifi state is unmanaged !" );
557+ return false ;
558+ }
559+
560+ nm_device_set_autoconnect (m_wifidevice, true ); // set autoconnect true
561+
562+ if (knownssid.empty ())
563+ {
564+ NMLOG_WARNING (" ssid not specified !" );
565+ return false ;
566+ }
567+
568+ wifiConnections = nm_device_get_available_connections (m_wifidevice);
569+ if (wifiConnections == NULL )
570+ {
571+ NMLOG_WARNING (" No wifi connection found !" );
572+ return false ;
573+ }
574+
575+ for (guint i = 0 ; i < wifiConnections->len ; i++)
576+ {
577+ NMConnection *connection = static_cast <NMConnection*>(g_ptr_array_index (wifiConnections, i));
578+ if (connection == NULL )
579+ continue ;
580+
581+ const char *connId = nm_connection_get_id (NM_CONNECTION (connection));
582+ if (connId != NULL && strcmp (connId, knownssid.c_str ()) == 0 )
583+ {
584+ m_connection = g_object_ref (connection);
585+ NMLOG_DEBUG (" connection '%s' exists !" , knownssid.c_str ());
586+ if (m_connection == NULL )
587+ {
588+ NMLOG_ERROR (" m_connection == NULL smothing went worng" );
589+ return false ;
590+ }
591+ break ;
592+ }
593+ }
594+
595+ m_isSuccess = false ;
596+ if (m_connection != NULL && NM_IS_REMOTE_CONNECTION (m_connection))
597+ {
598+ NMLOG_INFO (" activating known wifi '%s' connection" , knownssid.c_str ());
599+ m_createNewConnection = false ; // no need to create new connection
600+ nm_client_activate_connection_async (m_client, NM_CONNECTION (m_connection), m_wifidevice, specificObjPath, NULL , wifiConnectCb, this );
601+ wait (m_loop);
602+ }
603+ else
604+ {
605+ NMLOG_ERROR (" '%s' connection not found !" , knownssid.c_str ());
606+ }
607+
608+ return m_isSuccess;
609+ }
610+
543611 bool wifiManager::wifiConnect (Exchange::INetworkManager::WiFiConnectTo ssidInfo)
544612 {
545613 NMAccessPoint *AccessPoint = NULL ;
@@ -856,7 +924,7 @@ namespace WPEFramework
856924 }
857925 if (!ssids.empty ())
858926 {
859- NMLOG_DEBUG (" known wifi connections are %s" , ssidPrint.c_str ());
927+ NMLOG_INFO (" known wifi connections are %s" , ssidPrint.c_str ());
860928 return true ;
861929 }
862930
0 commit comments