javaextensions/datagram/datagram/javasrc/com/nokia/mj/impl/datagram/UDPDatagramConnectionImpl.java
branchRCL_3
changeset 23 e5618cc85d74
parent 14 04becd199f91
child 25 ae942d28ec0e
equal deleted inserted replaced
21:4376525cdefb 23:e5618cc85d74
   295         int retVal;
   295         int retVal;
   296         if (!iConnectionOpen)
   296         if (!iConnectionOpen)
   297         {
   297         {
   298             throw new IOException("getLocalAddress failed: connection is already closed");
   298             throw new IOException("getLocalAddress failed: connection is already closed");
   299         }
   299         }
   300         retVal = _getLocalAddress(iNativePeerHandle, address);
   300         int apId = -1;
       
   301         int apType = -1;
       
   302         try
       
   303         {
       
   304 
       
   305             Uid appSuite = ApplicationInfo.getInstance().getSuiteUid();
       
   306             iCmInstance = ConnectionManager.getInstance();
       
   307             AccessPoint apn = iCmInstance.getApplicationDefault(appSuite);
       
   308             if (apn != null)
       
   309             {
       
   310                 apId = apn.getNapId();
       
   311                 apType = apn.getType();
       
   312 
       
   313                 if ((apType!=AccessPoint.NAP_SNAP) && (apType!=AccessPoint.NAP_IAP))
       
   314                 {
       
   315                     apType = -1;
       
   316                     apId = -1;
       
   317                 }
       
   318                 Logger.LOG(Logger.ESOCKET, Logger.EInfo,
       
   319                            "+SocketServerConnectionImpl:: getApplicationDefault returned,  \n"+apn.getNapId()+" type = "+apn.getType());
       
   320             }
       
   321         }
       
   322         catch (Exception e)
       
   323         {
       
   324 
       
   325         }
       
   326         retVal = _getLocalAddress(iNativePeerHandle, address, apId, apType);
   301         if (retVal < 0)
   327         if (retVal < 0)
   302         {
   328         {
   303             throw new IOException("getLocalAddress method failed.Posix error code: " + retVal);
   329             throw new IOException("getLocalAddress method failed.Posix error code: " + retVal);
   304         }
   330         }
   305         else
   331         else
   510      */
   536      */
   511 
   537 
   512     public Datagram newDatagram(byte[] aBuf, int aSize, String aAddr)
   538     public Datagram newDatagram(byte[] aBuf, int aSize, String aAddr)
   513     throws IOException
   539     throws IOException
   514     {
   540     {
   515 
   541         DatagramImpl tmp = null;
   516         if (!iConnectionOpen)
   542         if (!iConnectionOpen)
   517         {
   543         {
   518             throw new IOException("newDatagram failed: connection is already closed");
   544             throw new IOException("newDatagram failed: connection is already closed");
   519         }
   545         }
   520         if (aBuf == null)
   546         if (aBuf == null)
   522             throw new IllegalArgumentException("Invalid argument in newDatagram method");
   548             throw new IllegalArgumentException("Invalid argument in newDatagram method");
   523         }
   549         }
   524         if (aAddr != null)
   550         if (aAddr != null)
   525         {
   551         {
   526             UrlParser urlvalidation = new UrlParser(aAddr);
   552             UrlParser urlvalidation = new UrlParser(aAddr);
   527         }
   553             tmp = new DatagramImpl(aBuf, aSize, aAddr);
   528         DatagramImpl t = new DatagramImpl(aBuf, aSize, aAddr);
   554         }
   529         return t;
   555         else
       
   556         {
       
   557             String tmpAddr = null;
       
   558             if (iUri != null)   // server datagram if iUri = null
       
   559             {
       
   560                 if (iUri.host != null) // server datagram is host is null
       
   561                 {
       
   562                     tmpAddr = iUri.toString();
       
   563                 }
       
   564             }
       
   565             tmp = new DatagramImpl(aBuf, aSize, tmpAddr);
       
   566         }
       
   567         return tmp;
   530     }
   568     }
   531 
   569 
   532     Finalizer registerforFinalization()
   570     Finalizer registerforFinalization()
   533     {
   571     {
   534         Logger.LOG(Logger.ESOCKET, Logger.EInfo,
   572         Logger.LOG(Logger.ESOCKET, Logger.EInfo,
   569     private native int _openConnection(int iNativePeerHandle, int aType, int aApn, int[] retval);
   607     private native int _openConnection(int iNativePeerHandle, int aType, int aApn, int[] retval);
   570     private native int _send(int iNativePeerHandle, byte[] buf, int offset,
   608     private native int _send(int iNativePeerHandle, byte[] buf, int offset,
   571                              int length, String host, int port);
   609                              int length, String host, int port);
   572     private native int _receive(int iNativePeerHandle, byte[] buf, int offset,
   610     private native int _receive(int iNativePeerHandle, byte[] buf, int offset,
   573                                 int length, String[] senderAddr, int[] senderPort);
   611                                 int length, String[] senderAddr, int[] senderPort);
   574     private native int _getLocalAddress(int iNativePeerHandle, String[] address);
   612     private native int _getLocalAddress(int iNativePeerHandle, String[] address, int aIapId, int aType);
   575     private native int _getLocalPort(int iNativePeerHandle);
   613     private native int _getLocalPort(int iNativePeerHandle);
   576     private native int _close(int iNativePeerHandle);
   614     private native int _close(int iNativePeerHandle);
   577     private native void _dispose(int iNativePeerHandle);
   615     private native void _dispose(int iNativePeerHandle);
   578 
   616 
   579 }
   617 }