javaextensions/iapinfo/javasrc.s60/com/nokia/mid/iapinfo/APNControl.java
author hgs
Fri, 15 Oct 2010 12:29:39 +0300
changeset 80 d6dafc5d983f
parent 21 2a9601315dfc
permissions -rw-r--r--
v2.2.19_1

/*
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implements Java APNControl related functions
 *
*/

package com.nokia.mid.iapinfo;

import com.nokia.mj.impl.connectionmanager.ConnectionManager;
import com.nokia.mj.impl.connectionmanager.AccessPoint;

/**
 * Implements Java APNControl related functions. Currently the only featue is
 * the retrieval of the last used IAP ID.
 *
 */
class APNControl
{

    /**
     * Retrieves the last used IAP ID. Typically this function is used when in
     * the socket connection URI the NETId parameter is used. (see Java
     * APNControl documentation)
     *
     * @return IAP ID used for the last network connection open
     */
    public int getLastIAP()
    {
        ConnectionManager cminstance = ConnectionManager.getInstance();
        if (cminstance != null)
        {
            AccessPoint  lastUsedApn = cminstance.iSessionNetworkAccessPoint;
            if (lastUsedApn != null)
            {
                if (lastUsedApn.getType() == AccessPoint.NAP_IAP) // IAP ID
                {
                    return  lastUsedApn.getNapId();
                }
                else
                {
                    return -1;
                }
            }
            else
            {
                return -1;
            }
        }
        else
        {
            return -1;
        }
        //return _getLastIAP();
    }

    /*----------------------------------------------------------------*/
    /* Native funcions */
    /*----------------------------------------------------------------*/
    /*
     * Retrieves the last used IAP ID.
     *
     * @return the IAP ID used for the last network connection open
     */
    private static native int _getLastIAP();
}