示例#1
0
 public ViewDownSpeedGraph() {
   AzureusCoreFactory.addCoreRunningListener(
       new AzureusCoreRunningListener() {
         public void azureusCoreRunning(AzureusCore core) {
           manager = core.getGlobalManager();
           stats = manager.getStats();
         }
       });
 }
示例#2
0
  public static void registerWithFeatureManager() {
    if (!enabled) {
      return;
    }
    AzureusCoreFactory.addCoreRunningListener(
        new AzureusCoreRunningListener() {

          public void azureusCoreRunning(AzureusCore core) {
            PluginInterface pi = core.getPluginManager().getDefaultPluginInterface();
            featman = pi.getUtilities().getFeatureManager();

            fml = new FeatureManagerUIListener(featman);
            featman.addListener(fml);
            Licence[] licences = featman.getLicences();
            for (Licence licence : licences) {
              fml.licenceAdded(licence);
            }

            UIManager ui_manager = pi.getUIManager();

            ui_manager.addUIListener(
                new UIManagerListener() {
                  public void UIDetached(UIInstance instance) {}

                  public void UIAttached(UIInstance instance) {
                    if (!(instance instanceof UISWTInstance)) {
                      return;
                    }

                    if (!Utils.isAZ2UI()) {
                      addFreeBurnUI();
                    }
                  }
                });
          }
        });
  }
示例#3
0
  static final int openDocProc(int theAppleEvent, int reply, int handlerRefcon) {
    try {
      Object aeDesc = claAEDesc.newInstance();
      Object eventRecord = claEventRecord.newInstance();
      invoke(
          claOS,
          null,
          "ConvertEventRefToEventRecord",
          new Class[] {int.class, claEventRecord},
          new Object[] {theAppleEvent, eventRecord});
      try {
        int result =
            OSXAccess.AEGetParamDesc(theAppleEvent, kEventParamDirectObject, typeAEList, aeDesc);
        if (result != noErr) {
          Debug.out("OSX: Could call AEGetParamDesc. Error: " + result);
          return noErr;
        }
      } catch (java.lang.UnsatisfiedLinkError e) {
        Debug.out("OSX: AEGetParamDesc not available.  Can't open sent file");
        return noErr;
      }

      int[] count = new int[1];
      invoke(
          claOS,
          null,
          "AECountItems",
          new Class[] {claAEDesc, int[].class},
          new Object[] {aeDesc, count});
      // System.out.println("COUNT: " + count[0]);
      if (count[0] > 0) {
        final String[] fileNames = new String[count[0]];
        int maximumSize = 80; // size of FSRef
        int dataPtr =
            ((Number) invoke(claOS, null, "NewPtr", new Object[] {maximumSize})).intValue();
        int[] aeKeyword = new int[1];
        int[] typeCode = new int[1];
        int[] actualSize = new int[1];
        for (int i = 0; i < count[0]; i++) {
          try {
            // int AEGetNthPtr(AEDesc theAEDescList, int index, int desiredType,
            // int[] theAEKeyword, int[] typeCode, int dataPtr, int maximumSize, int[] actualSize);
            Class<?>[] sigAEGetNthPtr =
                new Class[] {
                  claAEDesc,
                  int.class,
                  int.class,
                  int[].class,
                  int[].class,
                  int.class,
                  int.class,
                  int[].class
                };
            int ret =
                ((Number)
                        invoke(
                            claOS,
                            null,
                            "AEGetNthPtr",
                            sigAEGetNthPtr,
                            new Object[] {
                              aeDesc,
                              i + 1,
                              typeFSRef,
                              aeKeyword,
                              typeCode,
                              dataPtr,
                              maximumSize,
                              actualSize
                            }))
                    .intValue();
            if (ret == noErr) {
              byte[] fsRef = new byte[actualSize[0]];
              memmove(fsRef, dataPtr, actualSize[0]);
              int dirUrl =
                  ((Number)
                          invoke(
                              claOS,
                              null,
                              "CFURLCreateFromFSRef",
                              new Object[] {kCFAllocatorDefault, fsRef}))
                      .intValue();
              int dirString =
                  ((Number)
                          invoke(
                              claOS,
                              null,
                              "CFURLCopyFileSystemPath",
                              new Object[] {dirUrl, kCFURLPOSIXPathStyle}))
                      .intValue();
              int length =
                  ((Number) invoke(claOS, null, "CFStringGetLength", new Object[] {dirString}))
                      .intValue();
              char[] buffer = new char[length];
              Object range = claCFRange.newInstance();
              claCFRange.getField("length").setInt(range, length);
              invoke(
                  claOS,
                  null,
                  "CFStringGetCharacters",
                  new Class[] {int.class, claCFRange, char[].class},
                  new Object[] {dirString, range, buffer});
              fileNames[i] = new String(buffer);
              invoke(claOS, null, "CFRelease", new Object[] {dirString});
              invoke(claOS, null, "CFRelease", new Object[] {dirUrl});
            } else {
              ret =
                  ((Number)
                          invoke(
                              claOS,
                              null,
                              "AEGetNthPtr",
                              sigAEGetNthPtr,
                              new Object[] {
                                aeDesc,
                                i + 1,
                                typeText,
                                aeKeyword,
                                typeCode,
                                dataPtr,
                                2048,
                                actualSize
                              }))
                      .intValue();

              if (ret == noErr) {
                byte[] urlRef = new byte[actualSize[0]];
                memmove(urlRef, dataPtr, actualSize[0]);
                fileNames[i] = new String(urlRef);
              }
            }
          } catch (Throwable t) {
            Debug.out(t);
          }
          // System.out.println(fileNames[i]);
        }

        AzureusCoreFactory.addCoreRunningListener(
            new AzureusCoreRunningListener() {
              public void azureusCoreRunning(AzureusCore core) {
                TorrentOpener.openTorrents(fileNames);
              }
            });
      }

      return noErr;
    } catch (Throwable e) {
      Debug.out(e);
    }
    return eventNotHandledErr;
  }