@@ -52,8 +52,10 @@ namespace WPEFramework
52
52
53
53
m_client = nm_client_new (NULL , &error);
54
54
if (!m_client || !m_loop) {
55
- NMLOG_ERROR (" Could not connect to NetworkManager: %s." , error->message );
56
- g_error_free (error);
55
+ if (error) {
56
+ NMLOG_ERROR (" Could not connect to NetworkManager: %s." , error->message );
57
+ g_error_free (error);
58
+ }
57
59
return false ;
58
60
}
59
61
return true ;
@@ -337,23 +339,28 @@ namespace WPEFramework
337
339
338
340
static void disconnectCb (GObject *object, GAsyncResult *result, gpointer user_data)
339
341
{
340
- NMDevice *device = NM_DEVICE (object);
341
- GError *error = NULL ;
342
- wifiManager *_wifiManager = ( static_cast <wifiManager*>(user_data) );
342
+ NMDevice *device = NM_DEVICE (object);
343
+ GError *error = NULL ;
344
+ wifiManager *_wifiManager = static_cast <wifiManager*>(user_data);
343
345
344
346
NMLOG_DEBUG (" Disconnecting... " );
345
347
_wifiManager->m_isSuccess = true ;
346
- if (!nm_device_disconnect_finish (device, result, &error)) {
347
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
348
- return ;
349
-
350
- NMLOG_ERROR (" Device '%s' (%s) disconnecting failed: %s" ,
351
- nm_device_get_iface (device),
352
- nm_object_get_path (NM_OBJECT (device)),
353
- error->message );
354
- g_error_free (error);
355
- _wifiManager->quit (device);
356
- _wifiManager->m_isSuccess = false ;
348
+ if (!nm_device_disconnect_finish (device, result, &error))
349
+ {
350
+ NMLOG_ERROR (" device '%s' disconnect failed !" , nm_device_get_iface (device));
351
+ if (error != NULL )
352
+ {
353
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
354
+ {
355
+ NMLOG_ERROR (" something went wrong no matching gerror found !" );
356
+ }
357
+ else
358
+ {
359
+ NMLOG_ERROR (" Device path '%s': %s" , nm_object_get_path (NM_OBJECT (device)), error->message );
360
+ }
361
+ g_error_free (error);
362
+ }
363
+ _wifiManager->m_isSuccess = false ;
357
364
}
358
365
_wifiManager->quit (device);
359
366
}
@@ -566,8 +573,12 @@ namespace WPEFramework
566
573
NULL ,
567
574
&error))
568
575
{
569
- NMLOG_ERROR (" ca certificate add failed: %s" , error->message );
570
- g_error_free (error);
576
+ NMLOG_ERROR (" ca certificate add failed" );
577
+ if (error != NULL )
578
+ {
579
+ NMLOG_ERROR (" Error message %s" , error->message );
580
+ g_error_free (error);
581
+ }
571
582
return false ;
572
583
}
573
584
@@ -577,8 +588,12 @@ namespace WPEFramework
577
588
NULL ,
578
589
&error))
579
590
{
580
- NMLOG_ERROR (" client certificate add failed: %s" , error->message );
581
- g_error_free (error);
591
+ NMLOG_ERROR (" client certificate add failed" );
592
+ if (error != NULL )
593
+ {
594
+ NMLOG_ERROR (" Error message %s" , error->message );
595
+ g_error_free (error);
596
+ }
582
597
return false ;
583
598
}
584
599
@@ -589,8 +604,12 @@ namespace WPEFramework
589
604
NULL ,
590
605
&error))
591
606
{
592
- NMLOG_ERROR (" client private key add failed: %s" , error->message );
593
- g_error_free (error);
607
+ NMLOG_ERROR (" client private key failed" );
608
+ if (error != NULL )
609
+ {
610
+ NMLOG_ERROR (" Error message %s" , error->message );
611
+ g_error_free (error);
612
+ }
594
613
return false ;
595
614
}
596
615
@@ -713,6 +732,9 @@ namespace WPEFramework
713
732
NMLOG_ERROR (" '%s' connection not found !" , knowConnectionID.c_str ());
714
733
}
715
734
735
+ if (knownConnection != NULL )
736
+ g_object_unref (knownConnection);
737
+
716
738
deleteClientConnection ();
717
739
return m_isSuccess;
718
740
}
@@ -878,8 +900,10 @@ namespace WPEFramework
878
900
ret = nm_remote_connection_update2_finish (remote_con, res, &error);
879
901
880
902
if (!ret) {
881
- NMLOG_ERROR (" Error: %s." , error->message );
882
- g_error_free (error);
903
+ if (error) {
904
+ NMLOG_ERROR (" Error: %s." , error->message );
905
+ g_error_free (error);
906
+ }
883
907
_wifiManager->m_isSuccess = false ;
884
908
NMLOG_ERROR (" AddToKnownSSIDs failed" );
885
909
}
@@ -995,6 +1019,7 @@ namespace WPEFramework
995
1019
{
996
1020
NMConnection *m_connection = NULL ;
997
1021
bool ssidSpecified = false ;
1022
+ bool connectionFound = false ;
998
1023
999
1024
if (!createClientNewConnection ())
1000
1025
return false ;
@@ -1039,13 +1064,27 @@ namespace WPEFramework
1039
1064
nm_remote_connection_delete (NM_REMOTE_CONNECTION (connection), NULL , &error);
1040
1065
if (error) {
1041
1066
NMLOG_ERROR (" deleting connection failed %s" , error->message );
1067
+ g_error_free (error);
1068
+ if (m_connection)
1069
+ {
1070
+ g_object_unref (m_connection);
1071
+ m_connection = NULL ;
1072
+ }
1073
+ break ; // error break the loop and return false
1042
1074
}
1043
1075
else
1044
1076
NMLOG_INFO (" delete '%s' connection ..." , connId);
1077
+ connectionFound = true ;
1078
+ }
1079
+
1080
+ if (m_connection)
1081
+ {
1082
+ g_object_unref (m_connection);
1083
+ m_connection = NULL ;
1045
1084
}
1046
1085
}
1047
1086
1048
- if (!m_connection )
1087
+ if (!connectionFound )
1049
1088
{
1050
1089
if (ssidSpecified)
1051
1090
NMLOG_WARNING (" '%s' no such connection profile" , ssid.c_str ());
@@ -1054,7 +1093,9 @@ namespace WPEFramework
1054
1093
}
1055
1094
1056
1095
deleteClientConnection ();
1057
- return true ;
1096
+ // ssid is specified and connection is not found return false
1097
+ // all other case return true, even if no wificonnection is found
1098
+ return ((ssidSpecified && !connectionFound)? false : true );
1058
1099
}
1059
1100
1060
1101
bool wifiManager::getKnownSSIDs (std::list<string>& ssids)
@@ -1201,8 +1242,10 @@ namespace WPEFramework
1201
1242
GMainLoop *loop = static_cast <GMainLoop *>(user_data);
1202
1243
nm_client_add_and_activate_connection_finish (NM_CLIENT (client), result, &error);
1203
1244
1204
- if (error)
1245
+ if (error) {
1205
1246
NMLOG_ERROR (" Failed to add/activate new connection: %s" , error->message );
1247
+ g_error_free (error);
1248
+ }
1206
1249
else
1207
1250
NMLOG_INFO (" WPS connection added/activated successfully" );
1208
1251
g_main_loop_quit (loop);
@@ -1236,6 +1279,7 @@ namespace WPEFramework
1236
1279
nm_remote_connection_delete (NM_REMOTE_CONNECTION (connection), NULL , &error);
1237
1280
if (error) {
1238
1281
NMLOG_ERROR (" deleting connection failed %s" , error->message );
1282
+ g_error_free (error);
1239
1283
return false ;
1240
1284
}
1241
1285
}
@@ -1526,16 +1570,25 @@ namespace WPEFramework
1526
1570
wifiManager *_wifiManager = static_cast <wifiManager *>(user_data);
1527
1571
GError *error = nullptr ;
1528
1572
1529
- if (!nm_client_dbus_set_property_finish (NM_CLIENT (object), result, &error)) {
1530
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
1573
+ if (!nm_client_dbus_set_property_finish (NM_CLIENT (object), result, &error))
1574
+ {
1575
+ NMLOG_ERROR (" Failed to set Managed property" );
1576
+ if (error != nullptr )
1577
+ {
1578
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1579
+ {
1580
+ NMLOG_ERROR (" something went wrong no matching gerror found !" );
1581
+ }
1582
+ else
1583
+ {
1584
+ NMLOG_ERROR (" Failed Error msg: %s" , error->message );
1585
+ }
1531
1586
g_error_free (error);
1532
- return ;
1587
+ _wifiManager-> m_isSuccess = false ;
1533
1588
}
1534
-
1535
- NMLOG_ERROR (" Failed to set Managed property: %s" , error->message );
1536
- g_error_free (error);
1537
- _wifiManager->m_isSuccess = false ;
1538
- } else {
1589
+ }
1590
+ else
1591
+ {
1539
1592
NMLOG_DEBUG (" Successfully set Managed property." );
1540
1593
_wifiManager->m_isSuccess = true ;
1541
1594
}
@@ -1664,8 +1717,12 @@ namespace WPEFramework
1664
1717
NMLOG_DEBUG (" activate connection completeing..." );
1665
1718
// Check if the operation was successful
1666
1719
if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) {
1667
- NMLOG_DEBUG (" Activating connection failed: %s" , error->message );
1668
- g_error_free (error);
1720
+ NMLOG_ERROR (" Activating connection failed" );
1721
+ if (error != NULL )
1722
+ {
1723
+ NMLOG_ERROR (" Activating connection failed: %s" , error->message );
1724
+ g_error_free (error);
1725
+ }
1669
1726
_wifiManager->m_isSuccess = false ;
1670
1727
} else {
1671
1728
NMLOG_DEBUG (" Activating connection successful" );
0 commit comments