×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    19

    Unhappy How can i know whether an Access point is available or not?

    Hi Experts,
    I am using following code to establish a connect with internet via GPRS. Each time i use my application in new cellphone i have to define an access point in Settings>Connection>Access Points. My application crashes if i forget to defne an access point on phone( I use Nokia 6680 cellphone). I actually need to change my code so that it display a warning message that no Access Point is defined instead of crashing at once. Please help me!!!
    Application is crashing at this line in code...is there any way get out of this mess
    //User::LeaveIfError(iConnection.Start(prefs));

    The code is as following:
    // Open the RHTTPSession
    iSession.OpenL();
    //code for auto access point selection begin
    CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(commDB);
    // initialize a view
    CCommsDbConnectionPrefTableView* commDBView = commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);
    // go to the first record
    User::LeaveIfError(commDBView->GotoFirstRecord());
    // Declare a prefTableView Object.
    CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
    // read the connection preferences
    commDBView->ReadConnectionPreferenceL(pref);
    TUint32 iapID = pref.iBearer.iIapId;
    //Connect to Socket server
    User::LeaveIfError(iSockServ.Connect());
    //Define preferences for connection
    prefs.SetIapId(iapID);
    prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    prefs.SetDirection( ECommDbConnectionDirectionOutgoing );
    prefs.SetBearerSet( ECommDbBearerGPRS );
    //Start Connection
    User::LeaveIfError(iConnection.Open(iSockServ));
    User::LeaveIfError(iConnection.Start(prefs));//THIS IS WHERE APPLICATION CRASHES WHEN NO ACCESS POINT IS DEFINED
    //Set properties for session
    RStringPool strP = iSession.StringPool();
    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
    connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal (iSockServ.Handle()) );
    TInt connPtr = REINTERPRET_CAST(TInt, &iConnection);
    connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal (connPtr) );
    //code for auto access point selection end

  2. #2
    Super Contributor
    Join Date
    Oct 2005
    Posts
    739

    Re: How can i know whether an Access point is available or not?

    I Think by using the the return value of this function you can find out that

    //Connect to Socket server
    User::LeaveIfError(iSockServ.Connect());

    if this fails it means that the acces point specified is invalid.


    Reagrds,
    Peter

  3. #3
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How can i know whether an Access point is available or not?

    Below code will help you

    Code:
    CCommsDbTableView* SearchAPNL(CCommsDatabase& aCommDb)
        {
        CCommsDbTableView* commView = aCommDb.OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerGPRS,
                                                                                  ECommDbConnectionDirectionOutgoing);  // push commView
        if (commView->GotoFirstRecord() == KErrNone)
            {
            do
                {
                TUint32 id;
                TBuf<KCommsDbSvrMaxFieldLength> name;
                commView->ReadTextL(TPtrC(COMMDB_NAME), name);
                commView->ReadUintL(TPtrC(COMMDB_ID), id);
                name.UpperCase();
                if (name.Find(KAPNName) == 0) // KAPNName is you req. APN Name
                    {
                    CleanupStack::Pop(commView);  // pop commView
                    return commView;
                    }
                }
            while (commView->GotoNextRecord() == KErrNone);
            }
        CleanupStack::PopAndDestroy(commView);  // pop commView
        return NULL;
        }
        
    TBool IsAPNSetL()
        {
        TBool isInstalled = EFalse;
        CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
        CleanupStack::PushL(commDb);  // push commDb
        CCommsDbTableView* commView = SearchAPNL(*commDb);
        if (commView != NULL)
            {
            delete commView;
            commView = NULL;
            isInstalled = ETrue;
            }
        CleanupStack::PopAndDestroy(commDb);  // pop commDb
        return isInstalled;
        }

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    19

    Re: How can i know whether an Access point is available or not?

    Hii guys,

    Am very much thankful for the code provided by you guys. This has solved my problem completely..thanks again friends

  5. #5
    Regular Contributor
    Join Date
    Jun 2007
    Location
    INDIA
    Posts
    73

    Re: How can i know whether an Access point is available or not?

    Hi,

    I have created a Data Connection on an UIQ mobile, and able to browse the internet successfully.

    But when I executed the above piece of code, I am getting no records.

    // Open the commDB with IAP type
    TRAP(result, (commDB = CCommsDatabase::NewL (EDatabaseTypeIAP)));
    if (result != KErrNone)
    {
    debugBuf = KNullDesC;
    debugBuf.AppendFormat(KCommDbNewFail, result);
    OutText(debugBuf);
    return;
    }
    CleanupStack::PushL(commDB);

    commDB->ShowHiddenRecords();

    CCommsDbTableView* commView =
    commDB->OpenIAPTableViewMatchingBearerSetLC (ECommDbBearerGPRS, ECommDbConnectionDirectionOutgoing);

    Do I need search some other tables.

    Thanks and regards
    bytes

  6. #6
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: How can i know whether an Access point is available or not?

    I assume you mean you created an IAP and wanted to use it?
    In that case it would make better sense to search the IAP by name, wouldn't it?

    Also, regarding the above snippet, I wouldn't embrace the instantiation in a TRAP, as it's quite costly in terms of performance, and besides you're calling leaving methods later. You'd better just do:
    Code:
    commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(commDB);
    ...
    and then embrace that function call in a single trap, in case you need to avoid leaving..

    Also note that there are some small differences between S60 and UIQ table layout, so maybe you'd better ask this in the UIQ dev forum.

    Regards.

Similar Threads

  1. N70 Access Point becomes Unusable
    By ravey72 in forum Symbian
    Replies: 0
    Last Post: 2007-04-18, 10:58
  2. Gateway IP address in Nokia 6600 access point
    By yashodhan in forum General Development Questions
    Replies: 0
    Last Post: 2004-10-01, 12:22
  3. Midlet using a default Access Point
    By fboya in forum Mobile Java General
    Replies: 6
    Last Post: 2003-12-23, 09:58
  4. Why is client code to CSocketEngine hanging at Access Point dialogue?
    By nawkboy in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2003-03-11, 11:16
  5. Replies: 0
    Last Post: 2003-02-24, 04:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×