examples/network/qftp/sym_iap_util.h
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the examples of the Qt Toolkit.
     7 ** This file is part of the examples of the Qt Toolkit.
     8 **
     8 **
    58 #include <QSettings>
    58 #include <QSettings>
    59 #include <QStringList>
    59 #include <QStringList>
    60 //#include <QTextCodec>
    60 //#include <QTextCodec>
    61 
    61 
    62 _LIT(KIapNameSetting, "IAP\\Name");             // text - mandatory
    62 _LIT(KIapNameSetting, "IAP\\Name");             // text - mandatory
       
    63 _LIT(KIapTableIdField, "IAP\Id");
    63 _LIT(KIapDialogPref, "IAP\\DialogPref");        // TUnit32 - optional
    64 _LIT(KIapDialogPref, "IAP\\DialogPref");        // TUnit32 - optional
    64 _LIT(KIapService, "IAP\\IAPService");           // TUnit32 - mandatory
    65 _LIT(KIapService, "IAP\\IAPService");           // TUnit32 - mandatory
    65 _LIT(KIapServiceType, "IAP\\IAPServiceType");   // text - mandatory
    66 _LIT(KIapServiceType, "IAP\\IAPServiceType");   // text - mandatory
    66 _LIT(KIapBearer, "IAP\\IAPBearer");             // TUint32 - optional
    67 _LIT(KIapBearer, "IAP\\IAPBearer");             // TUint32 - optional
    67 _LIT(KIapBearerType, "IAP\\IAPBearerType");     // text - optional
    68 _LIT(KIapBearerType, "IAP\\IAPBearerType");     // text - optional
   296 QString qt_TDesC2QStringL(const TDesC& aDescriptor)
   297 QString qt_TDesC2QStringL(const TDesC& aDescriptor)
   297 {
   298 {
   298 #ifdef QT_NO_UNICODE
   299 #ifdef QT_NO_UNICODE
   299     return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length());
   300     return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length());
   300 #else
   301 #else
   301     return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length());
   302     return QString((const QChar *)aDescriptor.Ptr(), aDescriptor.Length());
   302 #endif
   303 #endif
   303 }
   304 }
   304 
   305 
   305 static bool qt_SetDefaultIapName(const QString &iapName, int &error) {
   306 static bool qt_SetDefaultIapName(const QString &iapName, int &error) {
   306     struct ifreq ifReq;
   307     struct ifreq ifReq;
   365 
   366 
   366     RConnection connection;
   367     RConnection connection;
   367     CleanupClosePushL(connection);
   368     CleanupClosePushL(connection);
   368 
   369 
   369     socketServ.Connect();
   370     socketServ.Connect();
       
   371 
       
   372     TCommDbConnPref prefs;
       
   373     prefs.SetDialogPreference(ECommDbDialogPrefPrompt);
       
   374 
   370     connection.Open(socketServ);
   375     connection.Open(socketServ);
   371     connection.Start();
   376     connection.Start(prefs);
   372 
   377 
   373     connection.GetDesSetting(TPtrC(KIapNameSetting), iapName);
   378     connection.GetDesSetting(TPtrC(KIapNameSetting), iapName);
   374 
       
   375     //connection.Stop();
   379     //connection.Stop();
   376 
   380 
   377     iapName.ZeroTerminate();
   381     iapName.ZeroTerminate();
   378     QString strIapName((char*)iapName.Ptr());
   382     QString strIapName((char*)iapName.Ptr());
   379 
   383 
   380     int error = 0;
   384     int error = 0;
   381     if(!qt_SetDefaultIapName(strIapName, error)) {
   385     if(!strIapName.isEmpty()) {
   382         //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error);
   386         if(!qt_SetDefaultIapName(strIapName, error)) {
   383         strIapName = QString("");
   387             //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error);
       
   388             strIapName = QString("");
       
   389         }
   384     }
   390     }
   385 
   391 
   386     CleanupStack::PopAndDestroy(&connection);
   392     CleanupStack::PopAndDestroy(&connection);
   387     CleanupStack::PopAndDestroy(&socketServ);
   393     CleanupStack::PopAndDestroy(&socketServ);
   388 
   394