×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    4

    IAP Settings Please HELP!!!

    Hi to everyone !

    I've found many little code snipets, but I've not found a complete, well-operational example code about this problem :

    I'd like to create a setting list contains all of the IAPs, and i want to use the IAP selected by the user instead of the IAP settings popup dialog!!!

    So

    (Using SDK 1.2)
    1. How can I read the IAP records from CommDB?
    2. How can I set the user selected one to use?


    Pleeeeease HELP!!!! And please give me concrete solve, i know the CommDB classes...

    Thanks to everyone!

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi,

    there is what you want

    #ifndef __IAP_CONNECTION__
    #define __IAP_CONNECTION__

    // INCLUDES
    #include <e32base.h>
    #include <intconninit.h>
    #include <aknprogressdialog.h>

    // CONSTANTS
    const TUint32 KBearerSetUnknown = 1000;
    const TUint32 KUndefinedIAPid = 0x00;

    // FORWARD DECLARATION
    class CAknWaitDialog;

    // ***************************************************************************
    /// \brief Mixin class observing state of connection.
    ///
    class MIAPConnectionObserver
    {
    public:
    virtual void IAP_Error( TInt aError ) = 0;
    virtual void IAP_TimeOut() = 0;
    virtual void IAP_Connected() = 0;
    virtual void IAP_Canceled() = 0;
    };

    // ***************************************************************************
    /// \brief Engine class for network connection using IAP and displaying
    /// wait dialog.
    ///
    class CIAPConnection : public CActive, MProgressDialogCallback
    {
    public:

    /// state of connecting
    enum TState
    {
    ENotConnected,
    EConnected,
    EConnecting
    };

    ///
    /// \brief Createa a CIAPConnection object.
    ///
    static CIAPConnection* NewL(MIAPConnectionObserver& aObserver);

    ///
    /// \brief Creates a CIAPConnection object and puts the pointer the stack.
    ///
    static CIAPConnection* NewLC(MIAPConnectionObserver& aObserver);

    ///
    /// \brief Destructor.
    ///
    ~CIAPConnection();

    ///
    /// \brief Creates a connection to IAP.
    ///
    void ConnectL();

    ///
    /// \brief Terminates any active connection.
    ///
    void TerminateL();

    ///
    /// \brief Respond to events.
    ///
    void RunL();

    ///
    /// \brief Cancels any outstanding requests
    ///
    void DoCancel();

    void ShowDialogL();

    private:

    ///
    /// \brief Constructor
    ///
    CIAPConnection(MIAPConnectionObserver& aObserver);

    ///
    /// \briefSecond phase constructor
    ///
    void ConstructL();

    ///
    /// \brief Dialog methods: Create, destroy and mixing class implementation
    ///
    void DialogDismissedL( TInt aButtonId );

    private:

    /// state of the connection
    TState iState;

    /// parameters of connection
    CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref iPref;

    /// connection initiator
    CIntConnectionInitiator* iConnection;

    /// observer
    MIAPConnectionObserver& iObserver;

    /// wait dialog
    CAknWaitDialog* iWaitDialog;
    };


    #endif
    // INCLUDE FILES

    #include "IAPConnection.h"

    #include <AknWaitDialog.h>
    #include <Intconninit.h>
    #include <connectprog.h>
    #include <SpicyChat.rsg>
    #include <eikenv.h>

    // ---------------------------------------------------------------------------
    // EPOC constructor.
    // ---------------------------------------------------------------------------
    CIAPConnection* CIAPConnection::NewL(MIAPConnectionObserver& aObserver)
    {
    CIAPConnection* self = NewLC( aObserver );
    CleanupStack::Pop( self );
    return self;
    }

    // ---------------------------------------------------------------------------
    // EPOC constructor + push to stack.
    // ---------------------------------------------------------------------------
    CIAPConnection* CIAPConnection::NewLC(MIAPConnectionObserver& aObserver)
    {
    CIAPConnection* self = new( ELeave ) CIAPConnection( aObserver );
    CleanupStack::PushL( self );
    self->ConstructL();
    return self;
    }

    // ---------------------------------------------------------------------------
    // C++ constructor.
    // ---------------------------------------------------------------------------
    CIAPConnection::CIAPConnection(MIAPConnectionObserver& aObserver) :
    CActive( CActive::EPriorityStandard ),
    iObserver( aObserver )
    {
    iState = ENotConnected;
    }

    // ---------------------------------------------------------------------------
    // Destructor.
    // ---------------------------------------------------------------------------
    CIAPConnection::~CIAPConnection()
    {
    Cancel();
    delete iConnection;
    }

    // ---------------------------------------------------------------------------
    // 2nd stage constructor.
    // ---------------------------------------------------------------------------
    void CIAPConnection::ConstructL()
    {
    iConnection = CIntConnectionInitiator::NewL();
    CActiveScheduler::Add( this );
    }

    // ---------------------------------------------------------------------------
    // Connect to network via IAP.
    // ---------------------------------------------------------------------------
    void CIAPConnection::ConnectL()
    {
    if (!IsActive())
    {
    if ( ( iState != EConnected ) && ( iState != EConnecting ) )
    {
    // Set connection preferences. Preference can use specific IAP
    // id and if it is known. Withoust setting preference it falls
    // on device on emulator it works fine
    iPref.iRanking = 1;
    iPref.iDirection = ECommDbConnectionDirectionOutgoing;
    iPref.iDialogPref = ECommDbDialogPrefPrompt;

    // set bearer ( IAP or 'H'CSD )
    CCommsDbConnectionPrefTableView::TCommDbIapBearer bearer;
    bearer.iBearerSet = ECommDbBearerUnknown;
    bearer.iIapId = KUndefinedIAPid;
    iPref.iBearer = bearer;

    // connect ( displays IAP combo box dialog )
    iState = EConnecting;
    iStatus = KRequestPending;
    iConnection->ConnectL( iPref, iStatus );
    SetActive();
    }
    }
    }

    // ---------------------------------------------------------------------------
    // From CActive. Asynchronous event completed.
    // ---------------------------------------------------------------------------
    void CIAPConnection::RunL()
    {
    if (iState == EConnecting)
    {
    switch ( iStatus.Int() )
    {
    case KConnectionPref1Exists:
    case KConnectionPref2Exists:
    case KConnectionExists:
    case KConnectionPref1Created:
    case KConnectionPref2Created:
    case KConnectionCreated:
    {
    iState = EConnected;

    if ( iWaitDialog )
    {
    iWaitDialog->ProcessFinishedL();
    iWaitDialog = NULL;
    }

    iObserver.IAP_Connected();
    break;
    }

    default:
    {
    iState = ENotConnected;

    if ( iWaitDialog )
    {
    iWaitDialog->ProcessFinishedL();
    iWaitDialog = NULL;
    }
    iObserver.IAP_Error( iStatus.Int() );
    break;
    }
    }
    }
    }

    // ---------------------------------------------------------------------------
    // From CActive. Asynchronous event canceled.
    // ---------------------------------------------------------------------------
    void CIAPConnection::DoCancel()
    {
    iConnection->Cancel();
    iState = ENotConnected;
    iObserver.IAP_Canceled();
    }

    // ---------------------------------------------------------
    // Callback method. Get's called when a dialog is dismissed.
    // ---------------------------------------------------------
    void CIAPConnection::DialogDismissedL( TInt aButtonId )
    {
    if ( ( aButtonId == EAknSoftkeyCancel ) && ( iState == EConnecting ) )
    Cancel();
    }

    // ---------------------------------------------------------
    //
    // ---------------------------------------------------------
    void CIAPConnection::ShowDialogL()
    {
    if ( iState == EConnecting )
    {
    iWaitDialog = new( ELeave ) CAknWaitDialog( NULL, EFalse );
    iWaitDialog->SetCallback( this );

    TBuf<32> rss_connecting;
    CEikonEnv::Static()->ReadResource( rss_connecting, R_CONNECTING );
    iWaitDialog->SetTextL( rss_connecting );
    iWaitDialog->ExecuteLD( R_WAIT_DIALOG );
    }
    }

    Bye STEN

Posting Permissions

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