Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
- // Jad home page: http://www.kpdus.com/jad.html
- // Decompiler options: packimports(3)
- // Source File Name: TransportManager.java
- package arkalogic.net.service.rim;
- import java.io.IOException;
- import javax.microedition.io.Connection;
- import javax.microedition.io.Connector;
- import net.rim.device.api.servicebook.ServiceBook;
- import net.rim.device.api.servicebook.ServiceRecord;
- import net.rim.device.api.system.*;
- import net.rim.device.api.ui.component.Dialog;
- public class TransportManager
- implements GlobalEventListener, CoverageStatusListener
- {
- private TransportManager()
- {
- setCoverage();
- }
- public static TransportManager getInstance()
- {
- if(_manager == null)
- _manager = new TransportManager();
- return _manager;
- }
- private boolean isWifi()
- {
- boolean wifi;
- if(WLANInfo.getWLANState() == 4620)
- wifi = true;
- else
- wifi = false;
- return wifi;
- }
- public Connection getConnection(String name, int mode, boolean timeouts)
- throws IOException
- {
- if(DeviceInfo.isSimulator())
- name = name.concat(";deviceside=true;ConnectionTimeout=20000");
- else
- if(isWifi())
- name = name.concat(";deviceside=true;interface=wifi");
- else
- if(_mdsSupport)
- name = name.concat(";deviceside=false");
- else
- if(_bisSupport)
- name = name.concat(";deviceside=false;ConnectionType=mds-public;EndToEndRequired;ConnectionTimeout=45000");
- else
- if(!_wapSupport)
- name = name.concat(";deviceside=true");
- return Connector.open(name, mode, timeouts);
- }
- public String getConnectionType()
- {
- if(_mdsSupport)
- return "MDS";
- if(_bisSupport)
- return "BIS-B";
- if(_wapSupport)
- return "WAP";
- else
- return "Direct TCP";
- }
- private void setCoverage()
- {
- if(CoverageInfo.isCoverageSufficient(2))
- _mdsSupport = true;
- if(CoverageInfo.isCoverageSufficient(4))
- _bisSupport = true;
- }
- public void coverageStatusChanged(int newCoverage)
- {
- if((newCoverage & 2) == 2)
- _mdsSupport = true;
- if((newCoverage & 4) == 4)
- _bisSupport = true;
- }
- private void parseServiceBooks()
- {
- ServiceBook sb = ServiceBook.getSB();
- ServiceRecord records[] = sb.findRecordsByCid(IPPP);
- if(records == null)
- return;
- int numRecords = records.length;
- for(int i = 0; i < numRecords; i++)
- {
- ServiceRecord myRecord = records[i];
- String name = myRecord.getName();
- String uid = myRecord.getUid();
- if(!myRecord.isValid() || myRecord.isDisabled())
- continue;
- int encryptionMode = myRecord.getEncryptionMode();
- if(encryptionMode == 2)
- _mdsSupport = true;
- else
- _bisSupport = true;
- }
- }
- public void eventOccurred(long guid, int data0, int data1, Object object0, Object object1)
- {
- if(guid == 0xc56f572fa6bb41faL || guid == 0x73071ed24deea8fdL || guid == 0xb70eaf0364976928L || guid == 0x563b18cc6bc68309L || guid == 0x230322fc7183d35eL)
- {
- Dialog.inform("Service Book Global Event Received");
- parseServiceBooks();
- }
- }
- private static ServiceRecord getBIBSRecord()
- {
- ServiceRecord ippps[] = ServiceBook.getSB().getRecords();
- for(int i = 0; i < ippps.length; i++)
- if(ippps[i].getCid().equals("IPPP") && ippps[i].getName().indexOf("BIBS") >= 0)
- return ippps[i];
- return null;
- }
- private static final long ID = 0x1431cf6271d3b1edL;
- private static String IPPP = "IPPP";
- private static TransportManager _manager;
- private boolean _isSimulator;
- private boolean _mdsSupport;
- private boolean _bisSupport;
- private boolean _wapSupport;
- private boolean _wifiSupport;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement