plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTarget.java
changeset 483 109da596fa9d
parent 470 d4809db37847
child 484 f5df819c1852
equal deleted inserted replaced
482:2973198ae2a9 483:109da596fa9d
    51 import org.eclipse.core.runtime.SubProgressMonitor;
    51 import org.eclipse.core.runtime.SubProgressMonitor;
    52 import org.eclipse.ui.IMemento;
    52 import org.eclipse.ui.IMemento;
    53 import org.symbian.tools.tmw.core.TMWCore;
    53 import org.symbian.tools.tmw.core.TMWCore;
    54 import org.symbian.tools.tmw.core.projects.ITMWProject;
    54 import org.symbian.tools.tmw.core.projects.ITMWProject;
    55 import org.symbian.tools.tmw.core.runtimes.IPackager;
    55 import org.symbian.tools.tmw.core.runtimes.IPackager;
       
    56 import org.symbian.tools.tmw.ui.TMWCoreUI;
    56 import org.symbian.tools.tmw.ui.deployment.IDeploymentTarget;
    57 import org.symbian.tools.tmw.ui.deployment.IDeploymentTarget;
    57 
    58 
    58 public class BluetoothTarget extends PlatformObject implements IDeploymentTarget {
    59 public class BluetoothTarget extends PlatformObject implements IDeploymentTarget {
    59     private static final UUID OBEX_OBJECT_PUSH = new UUID(0x1105);
    60     private static final UUID OBEX_OBJECT_PUSH = new UUID(0x1105);
       
    61     public static final long BLUETOOTH_TIMEOUT = 5 * 60 * 1000; // 5 min
    60     private String serviceURL;
    62     private String serviceURL;
    61     private RemoteDevice device;
    63     private RemoteDevice device;
    62     protected String[] exceptionCodes = new String[] { "OBEX_HTTP_UNSUPPORTED_TYPE", "OBEX_HTTP_FORBIDDEN" };
    64     protected String[] exceptionCodes = new String[] { "OBEX_HTTP_UNSUPPORTED_TYPE", "OBEX_HTTP_FORBIDDEN" };
    63     private String message = "Deployment was successful. Please follow on-screen instructions to complete application deployment on your device.";
    65     private String message = "Deployment was successful. Please follow on-screen instructions to complete application deployment on your device.";
    64     private final String name;
    66     private final String name;
    82         }
    84         }
    83         final File application = packager.packageApplication(project, new SubProgressMonitor(monitor, 100));
    85         final File application = packager.packageApplication(project, new SubProgressMonitor(monitor, 100));
    84         try {
    86         try {
    85             deployWidget(application, packager.getFileType(project), new SubProgressMonitor(monitor, 10));
    87             deployWidget(application, packager.getFileType(project), new SubProgressMonitor(monitor, 10));
    86         } finally {
    88         } finally {
    87             application.delete();
    89             if (!application.delete()) {
       
    90                 TMWCoreUI.log("Can't delete %s", application);
       
    91             }
    88         }
    92         }
    89         monitor.done();
    93         monitor.done();
    90         MultiStatus multiStatus = new MultiStatus(TMWCore.PLUGIN_ID, 0, message, null);
    94         MultiStatus multiStatus = new MultiStatus(TMWCore.PLUGIN_ID, 0, message, null);
    91         for (IStatus status : statuses) {
    95         for (IStatus status : statuses) {
    92             multiStatus.add(status);
    96             multiStatus.add(status);
   149 
   153 
   150             hsOperation.setHeader(HeaderSet.NAME, inputWidget.getName());
   154             hsOperation.setHeader(HeaderSet.NAME, inputWidget.getName());
   151             hsOperation.setHeader(HeaderSet.TYPE, fileType);
   155             hsOperation.setHeader(HeaderSet.TYPE, fileType);
   152             int size = (int) inputWidget.length();
   156             int size = (int) inputWidget.length();
   153             byte file[] = new byte[size];
   157             byte file[] = new byte[size];
   154             hsOperation.setHeader(HeaderSet.LENGTH, new Long(file.length));
   158             hsOperation.setHeader(HeaderSet.LENGTH, Long.valueOf(file.length));
   155 
   159 
   156             // Create PUT Operation
   160             // Create PUT Operation
   157             putOperation = clientSession.put(hsOperation);
   161             putOperation = clientSession.put(hsOperation);
   158 
   162 
   159             os = putOperation.openOutputStream();
   163             os = putOperation.openOutputStream();
   289             int[] attrIDs = new int[] { 0x0100 }; // Service name
   293             int[] attrIDs = new int[] { 0x0100 }; // Service name
   290 
   294 
   291             synchronized (serviceSearchCompletedEvent) {
   295             synchronized (serviceSearchCompletedEvent) {
   292                 LocalDevice.getLocalDevice().getDiscoveryAgent()
   296                 LocalDevice.getLocalDevice().getDiscoveryAgent()
   293                         .searchServices(attrIDs, searchUuidSet, device, listener);
   297                         .searchServices(attrIDs, searchUuidSet, device, listener);
   294                 serviceSearchCompletedEvent.wait();
   298                 serviceSearchCompletedEvent.wait(BLUETOOTH_TIMEOUT);
   295             }
   299             }
   296 
   300 
   297         } catch (IOException e) {
   301         } catch (IOException e) {
   298             TMWCore.log("Error in Bluetooth service discovery", e);
   302             TMWCore.log("Error in Bluetooth service discovery", e);
   299         } catch (InterruptedException e) {
   303         } catch (InterruptedException e) {