summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/network/ftp/sym_iap_util.h60
1 files changed, 40 insertions, 20 deletions
diff --git a/examples/network/ftp/sym_iap_util.h b/examples/network/ftp/sym_iap_util.h
index 928b46e..046a7b5 100644
--- a/examples/network/ftp/sym_iap_util.h
+++ b/examples/network/ftp/sym_iap_util.h
@@ -46,6 +46,14 @@
#include <sys/socket.h>
#include <net/if.h>
+_LIT(KIapNameSetting, "IAP\\Name"); // text - mandatory
+_LIT(KIapDialogPref, "IAP\\DialogPref"); // TUnit32 - optional
+_LIT(KIapService, "IAP\\IAPService"); // TUnit32 - mandatory
+_LIT(KIapServiceType, "IAP\\IAPServiceType"); // text - mandatory
+_LIT(KIapBearer, "IAP\\IAPBearer"); // TUint32 - optional
+_LIT(KIapBearerType, "IAP\\IAPBearerType"); // text - optional
+_LIT(KIapNetwork, "IAP\\IAPNetwork"); // TUint32 - optional
+
QString qt_TDesC2QStringL(const TDesC& aDescriptor)
{
#ifdef QT_NO_UNICODE
@@ -58,6 +66,7 @@ QString qt_TDesC2QStringL(const TDesC& aDescriptor)
static void qt_SetDefaultIapL()
{
TUint count;
+ TBool activeLanConnectionFound = EFalse;
TRequestStatus status;
RSocketServ serv;
@@ -71,41 +80,52 @@ static void qt_SetDefaultIapL()
TConnectionInfoBuf connInfo;
- _LIT(KIapNameSetting, "IAP\\Name");
- TBuf8<256> iap8Name;
+ TBuf8<256> iapName;
+ TBuf8<256> iapServiceType;
if (conn.EnumerateConnections(count) == KErrNone) {
if(count > 0) {
for (TUint i = 1; i <= count; i++) {
- // Note: GetConnectionInfo expects 1-based index.
+ // we will loop all active connections
+ // if we find one of the LAN type - will use it silently
+ // if not prompt thet user as other types
+ /// are more likely to be charged :(
if (conn.GetConnectionInfo(i, connInfo) == KErrNone) {
if (conn.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) {
- conn.GetDesSetting(TPtrC(KIapNameSetting), iap8Name);
- break;
+ conn.GetDesSetting(TPtrC(KIapNameSetting), iapName);
+ conn.GetDesSetting(TPtrC(KIapServiceType), iapServiceType);
+ if(iapServiceType.Find(_L8("LANService")) != KErrNotFound) {
+ activeLanConnectionFound = ETrue;
+ break;
+ }
}
}
}
- } else {
- /*
- * no active connections yet
- * use IAP dialog to select one
- */
- User::LeaveIfError(conn.Start());
- User::LeaveIfError(conn.GetDesSetting(TPtrC(KIapNameSetting), iap8Name));
}
+ }
- iap8Name.ZeroTerminate();
+ if (!activeLanConnectionFound) {
+ /*
+ * no active connections yet
+ * offer IAP dialog to user
+ */
+ conn.Close();
+ User::LeaveIfError(conn.Open(serv));
+ User::LeaveIfError(conn.Start());
+ User::LeaveIfError(conn.GetDesSetting(TPtrC(KIapNameSetting), iapName));
+ }
- conn.Stop();
+ iapName.ZeroTerminate();
- struct ifreq ifReq;
- strcpy(ifReq.ifr_name, (char*)iap8Name.Ptr());
+ conn.Stop();
- User::LeaveIfError(setdefaultif(&ifReq));
+ struct ifreq ifReq;
+ strcpy(ifReq.ifr_name, (char*)iapName.Ptr());
- conn.Close();
- serv.Close();
- }
+ User::LeaveIfError(setdefaultif(&ifReq));
+
+ conn.Close();
+ serv.Close();
CleanupStack::PopAndDestroy(&conn);
CleanupStack::PopAndDestroy(&serv);