com.crashlytics.tools.eclipse.core_1.6.1.201405061826

16:34:25.066 INFO  jd.cli.Main - Decompiling com.crashlytics.tools.eclipse.core_1.6.1.201405061826.jar
package com.crashlytics.tools.eclipse.adt;

import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdklib.internal.project.ProjectProperties;
import com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;

public class AdtDerivedUtils
{
  public static final String POST_COMPILER_BUILDER_ID = "com.android.ide.eclipse.adt.ApkBuilder";
  public static final String SDKCONSTANTS_FN_PROJECT_PROPERTIES = "project.properties";
  public static final String ADTCONSTANTS_NATURE_DEFAULT = "com.android.ide.eclipse.adt.AndroidNature";
  public static final String ADT_EXPORT_WIZARD_ID = "com.android.ide.eclipse.adt.project.ExportWizard";
  public static final String LaunchConfigDelegate_ANDROID_LAUNCH_TYPE_ID = "com.android.ide.eclipse.adt.debug.LaunchConfigType";
  private static final String PROPERTY_SDK = "sdk.dir";
  private static final String HOME_PROPERTY = "user.home";
  private static final String HOME_PROPERTY_REF = "${user.home}";
  private static final String SDK_PROPERTY_REF = "${sdk.dir}";
  
  public static List<File> getProguardConfigFiles(IProject project)
  {
    ProjectState state = Sdk.getProjectState(project);
    String proguardConfig = state.getProperties().getProperty("proguard.config");
    
    List<File> proguardConfigFiles = new LinkedList();
    if ((proguardConfig != null) && (proguardConfig.length() > 0))
    {
      if ((File.separatorChar != '/') && (proguardConfig.indexOf('/') != -1)) {
        proguardConfig = proguardConfig.replace('/', File.separatorChar);
      }
      if (proguardConfig.indexOf(';') != -1) {
        proguardConfig = proguardConfig.replace(';', ':');
      }
      String[] paths = proguardConfig.split(":");
      String[] arrayOfString1;
      int j = (arrayOfString1 = paths).length;
      for (int i = 0; i < j; i++)
      {
        String path = arrayOfString1[i];
        if (path.startsWith("${sdk.dir}")) {
          path = AdtPrefs.getPrefs().getOsSdkFolder() + path.substring("${sdk.dir}".length());
        } else if (path.startsWith("${user.home}")) {
          path = System.getProperty("user.home") + path.substring("${user.home}".length());
        }
        File proguardConfigFile = new File(path);
        if (!proguardConfigFile.isAbsolute()) {
          proguardConfigFile = new File(project.getLocation().toFile(), path);
        }
        if (proguardConfigFile.isFile()) {
          proguardConfigFiles.add(proguardConfigFile);
        } else {
          CrashlyticsAdtPlugin.log(2, "Invalid proguard configuration file path " + 
            proguardConfigFile, null);
        }
      }
    }
    return proguardConfigFiles;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.adt.AdtDerivedUtils
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import com.crashlytics.api.User;
import com.crashlytics.api.WebApi;
import com.crashlytics.api.WebApi.ApiCallbackAdapter;
import com.crashlytics.java.Crashlytics;
import org.osgi.service.prefs.Preferences;

class CrashlyticsAdtPlugin$1
  extends WebApi.ApiCallbackAdapter
{
  CrashlyticsAdtPlugin$1(CrashlyticsAdtPlugin paramCrashlyticsAdtPlugin) {}
  
  public void onAuthenticateException(WebApi api, Exception exception)
  {
    CrashlyticsAdtPlugin.log(4, "Error authenticating user", exception);
    onAuthenticated(api, null);
  }
  
  public void onAuthenticated(WebApi api, User user)
  {
    if (user == null)
    {
      CrashlyticsAdtPlugin.log("User set to null");
      CrashlyticsAdtPlugin.access$0(this$0).remove("userEmail");
      CrashlyticsAdtPlugin.access$0(this$0).remove("userName");
      CrashlyticsAdtPlugin.access$0(this$0).remove("userToken");
    }
    else
    {
      CrashlyticsAdtPlugin.log("Authenticated user " + user.getEmail());
      CrashlyticsAdtPlugin.access$0(this$0).put("userEmail", user.getEmail());
      CrashlyticsAdtPlugin.access$0(this$0).put("userName", user.getName());
      CrashlyticsAdtPlugin.access$0(this$0).put("userToken", user.getToken());
    }
    Crashlytics.setString("UserEmail", user.getEmail());
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import com.crashlytics.tools.android.DeveloperTools;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;

class CrashlyticsAdtPlugin$2
  implements IResourceChangeListener
{
  CrashlyticsAdtPlugin$2(CrashlyticsAdtPlugin paramCrashlyticsAdtPlugin) {}
  
  public void resourceChanged(IResourceChangeEvent event)
  {
    IResource res = event.getResource();
    try
    {
      if ((event.getType() == 4) && (res.getType() == 4))
      {
        IProject proj = (IProject)res;
        if (EclipseIde.isWatchable(proj)) {
          CrashlyticsAdtPlugin.access$1(this$0).updateProjects();
        }
      }
      else if (event.getType() == 1)
      {
        IResourceDelta delta = event.getDelta();
        delta.accept(new CrashlyticsAdtPlugin.ProjectVisitor(this$0));
      }
      else if (event.getType() == 16)
      {
        IResourceDelta delta = event.getDelta();
        delta.accept(new CrashlyticsAdtPlugin.PostBuildProjectVisitor(this$0, null));
      }
      else if (event.getType() == 8)
      {
        IResourceDelta delta = event.getDelta();
        delta.accept(new CrashlyticsAdtPlugin.PreBuildProjectVisitor(this$0, null));
      }
    }
    catch (CoreException e)
    {
      DeveloperTools.logE("CoreException in resourceChanged", e);
    }
    catch (Exception e)
    {
      DeveloperTools.logE("Crashlytics could not react to resource change", e);
    }
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import com.crashlytics.tools.android.DeveloperTools.Logger;

class CrashlyticsAdtPlugin$3
  implements DeveloperTools.Logger
{
  CrashlyticsAdtPlugin$3(CrashlyticsAdtPlugin paramCrashlyticsAdtPlugin) {}
  
  public void logW(String msg, Throwable t)
  {
    CrashlyticsAdtPlugin.access$2(2, msg, t);
  }
  
  public void logI(String msg)
  {
    CrashlyticsAdtPlugin.access$2(1, msg, null);
  }
  
  public void logE(String msg, Throwable t)
  {
    CrashlyticsAdtPlugin.access$2(4, msg, t);
  }
  
  public void logD(String msg)
  {
    CrashlyticsAdtPlugin.access$2(0, msg, null);
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;

class CrashlyticsAdtPlugin$PostBuildProjectVisitor
  extends CrashlyticsAdtPlugin.ProjectAdaptor
{
  private CrashlyticsAdtPlugin$PostBuildProjectVisitor(CrashlyticsAdtPlugin paramCrashlyticsAdtPlugin)
  {
    super(paramCrashlyticsAdtPlugin);
  }
  
  public boolean visitProject(IProject project, IResourceDelta delta)
  {
    CrashlyticsAdtPlugin.access$3(this$0).postBuild(project);
    return true;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin.PostBuildProjectVisitor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;

class CrashlyticsAdtPlugin$PreBuildProjectVisitor
  extends CrashlyticsAdtPlugin.ProjectAdaptor
{
  private CrashlyticsAdtPlugin$PreBuildProjectVisitor(CrashlyticsAdtPlugin paramCrashlyticsAdtPlugin)
  {
    super(paramCrashlyticsAdtPlugin);
  }
  
  public boolean visitProject(IProject project, IResourceDelta delta)
  {
    CrashlyticsAdtPlugin.access$3(this$0).preBuild(project);
    return true;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin.PreBuildProjectVisitor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;

abstract class CrashlyticsAdtPlugin$ProjectAdaptor
  implements IResourceDeltaVisitor
{
  CrashlyticsAdtPlugin$ProjectAdaptor(CrashlyticsAdtPlugin paramCrashlyticsAdtPlugin) {}
  
  public boolean visit(IResourceDelta delta)
  {
    IResource res = delta.getResource();
    if (res.getType() == 8) {
      return true;
    }
    if (res.getType() == 4) {
      return visitProject((IProject)res, delta);
    }
    return false;
  }
  
  public abstract boolean visitProject(IProject paramIProject, IResourceDelta paramIResourceDelta);
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin.ProjectAdaptor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;

class CrashlyticsAdtPlugin$ProjectVisitor
  extends CrashlyticsAdtPlugin.ProjectAdaptor
{
  CrashlyticsAdtPlugin$ProjectVisitor(CrashlyticsAdtPlugin paramCrashlyticsAdtPlugin)
  {
    super(paramCrashlyticsAdtPlugin);
  }
  
  public boolean visitProject(IProject proj, IResourceDelta delta)
  {
    int flags = delta.getFlags();
    if ((proj.isOpen()) && (!EclipseIde.isWatchable(proj))) {
      return false;
    }
    if (flags > 0) {
      if ((flags & 0x1000) != 0) {
        CrashlyticsAdtPlugin.access$1(this$0).updateProjects();
      } else if ((flags & 0x4000) != 0) {
        CrashlyticsAdtPlugin.access$1(this$0).updateProjects();
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin.ProjectVisitor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import com.crashlytics.api.RestfulWebApi;
import com.crashlytics.api.User;
import com.crashlytics.api.WebApi;
import com.crashlytics.api.WebApi.ApiCallback;
import com.crashlytics.api.WebApi.ApiCallbackAdapter;
import com.crashlytics.java.Crashlytics;
import com.crashlytics.tools.android.DefaultSDKFactory;
import com.crashlytics.tools.android.DeveloperTools;
import com.crashlytics.tools.android.DeveloperTools.L4JWrappedLogger;
import com.crashlytics.tools.android.DeveloperTools.Logger;
import com.crashlytics.tools.android.DeveloperTools.MultiLogger;
import com.crashlytics.tools.android.OldSDKFactory;
import com.crashlytics.tools.android.ReleaseNotesManager;
import com.crashlytics.tools.android.SDKFactory;
import com.crashlytics.tools.eclipse.updater.UpdaterPlugin;
import com.crashlytics.tools.ide.android.AndroidPluginSupport;
import com.crashlytics.tools.utils.FileUtils;
import java.io.File;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;

public class CrashlyticsAdtPlugin
  extends Plugin
  implements EclipseReleaseNotesManager.ReleaseNotesPersistenceProvider
{
  private static final String USER_AGENT_PREFIX = "Crashlytics Eclipse Plugin for ";
  private static boolean debugMode = true;
  public static final String PLUGIN_ID = "com.crashlytics.tools.eclipse.core";
  private static final String PREF_USERNAME = "userName";
  private static final String PREF_EMAIL = "userEmail";
  private static final String PREF_USER_TOKEN = "userToken";
  private static final String BASE_API_URL_PROP = "com.crashlytics.tools.eclipse.BaseApiUrl";
  private static final String START_PLUGIN_AUTOUPDATER_PROP = "com.crashlytics.tools.eclipse.StartPluginAutoupdater";
  private static final String START_PLUGIN_AUTOUPDATER_DEFAULT = "true";
  private static final String START_SDK_AUTOUPDATER_PROP = "com.crashlytics.tools.eclipse.StartSdkAutoupdater";
  private static final String START_SDK_AUTOUPDATER_DEFAULT = "true";
  private static final String API_KEY_PROP = "com.crashlytics.tools.eclipse.ApiKey";
  private static final String API_KEY_DEFAULT = "6b10dbac8a804212dc8187434ef46720270928fe";
  private static final long PLUGIN_UPDATER_STARTUP_DELAY_MS = 45000L;
  private static CrashlyticsAdtPlugin plugin;
  private EclipseIde _ide;
  private Preferences _prefs;
  private AndroidPluginSupport _pluginSupport;
  private ProjectAssemblyListener _projectAssemblyListener;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
    
    DeveloperTools.setLogger(_devToolsLogger);
    
    IScopeContext scope = ConfigurationScope.INSTANCE;
    log("Starting CrashlyticsAdtPlugin (" + getBundle().getVersion().toString() + 
      ") with preferences from: " + scope.getLocation());
    
    _prefs = scope.getNode("com.crashlytics.tools.eclipse.core");
    
    String webApiUrl = System.getProperty("com.crashlytics.tools.eclipse.BaseApiUrl", "https://api.crashlytics.com");
    String apiKey = System.getProperty("com.crashlytics.tools.eclipse.ApiKey", "6b10dbac8a804212dc8187434ef46720270928fe");
    
    String osName = System.getProperty("os.name");
    String clientType = "Crashlytics Eclipse Plugin for " + osName;
    Version version = getBundle().getVersion();
    String clientVersion = version.getMajor() + "." + version.getMinor() + "." + version.getMicro();
    String eclipseVersion = System.getProperty("eclipse.buildId");
    
    WebApi api = new RestfulWebApi(webApiUrl);
    api.setUserAgent(clientType + "/" + clientVersion);
    api.setClientType(clientType);
    api.setClientVersion(clientVersion);
    api.setToolId("com.crashlytics.tools.eclipse.core");
    api.setToolVersion(clientVersion);
    api.setOperatingSystem(osName);
    
    IProduct product = Platform.getProduct();
    api.setEnvironmentId(product == null ? "org.eclipse(unknown)" : product.getId());
    api.setEnvironmentVersion(eclipseVersion);
    
    DeveloperTools.setWebApi(api);
    
    User user = api.getCurrentUser();
    if (user != null) {
      Crashlytics.setString("EMAIL", user.getEmail());
    }
    if (System.getProperty("crashlytics.ignore_crashes") != null)
    {
      log(2, "Crash reporting DISABLED", null);
      Crashlytics.startWithAPIKey(apiKey, webApiUrl, context.getDataFile(""), this, getBundle().getVersion()
        .toString(), 0.0F);
    }
    SDKFactory factory;
    SDKFactory factory;
    if (System.getProperty("crashlytics.force_old_sdk") != null)
    {
      log(1, "Forcing old SDK", null);
      factory = new OldSDKFactory();
    }
    else
    {
      factory = new DefaultSDKFactory();
    }
    String userToken = _prefs.get("userToken", null);
    if (userToken != null) {
      api.asyncAuthenticateWithToken(userToken, _apiCallback);
    }
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    File workspacePath = getRoot(workspace);
    if (workspacePath == null) {
      throw new RuntimeException("Crashlytics could not access workspace root directory. Aborting execution.");
    }
    String workspaceName = FileUtils.getIdentifier(workspacePath);
    
    File pluginDir = new File(DeveloperTools.CRASHLYTICS_DATA_ROOT, "com.crashlytics.tools.eclipse.core");
    File dataDir = new File(pluginDir, workspaceName);
    File logDir = new File(dataDir, "logs");
    logDir.mkdirs();
    
    DeveloperTools.Logger wrapperLogger = new DeveloperTools.L4JWrappedLogger(DeveloperTools.configureCrashlyticsLogger(logDir));
    DeveloperTools.Logger multiLogger = new DeveloperTools.MultiLogger(new DeveloperTools.Logger[] { wrapperLogger, _devToolsLogger });
    DeveloperTools.setLogger(multiLogger);
    DeveloperTools.logD("-------------Crashlytics now  appending to crashlytics.log-------------");
    DeveloperTools.logD("Tool Information: " + api.toString());
    
    ReleaseNotesManager releaseNotesManager = new EclipseReleaseNotesManager(pluginDir, this);
    _ide = new EclipseIde(dataDir, factory, releaseNotesManager);
    _pluginSupport = new AndroidPluginSupport();
    _projectAssemblyListener = new ThreadedAssemblyListener(
      new EclipseBuildListener(_ide, _ide, 
      new EclipseDeobsUploader(this)));
    
    workspace.addResourceChangeListener(resourceChangeListener, 29);
    
    boolean startSdkAutoupdater = Boolean.parseBoolean(System.getProperty("com.crashlytics.tools.eclipse.StartSdkAutoupdater", 
      "true"));
    if (startSdkAutoupdater) {
      _pluginSupport.startSDKUpdateWorker(_ide);
    } else {
      log("SDK autoupdating disabled.");
    }
    boolean startPluginAutoupdater = Boolean.parseBoolean(System.getProperty("com.crashlytics.tools.eclipse.StartPluginAutoupdater", 
      "true"));
    if (startPluginAutoupdater) {
      UpdaterPlugin.getDefault().startCheckingForUpdates(new EclipseUpdateFinder(_ide), 
        45000L);
    } else {
      log("Plugin autoupdating disabled.");
    }
    _pluginSupport.startUploadingDeobfuscationFiles(_ide, 60000L);
  }
  
  private File getRoot(IWorkspace workspace)
  {
    File returnPath = null;
    if (workspace != null)
    {
      IWorkspaceRoot root = workspace.getRoot();
      if (root != null)
      {
        IPath location = root.getLocation();
        if (location != null) {
          returnPath = location.toFile();
        }
      }
    }
    return returnPath;
  }
  
  public static boolean isDebugMode()
  {
    return debugMode;
  }
  
  /* Error */
  public synchronized void stop(BundleContext context)
    throws Exception
  {
    // Byte code:
    //   0: ldc_w 494
    //   3: invokestatic 153	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:log	(Ljava/lang/String;)V
    //   6: invokestatic 304	org/eclipse/core/resources/ResourcesPlugin:getWorkspace	()Lorg/eclipse/core/resources/IWorkspace;
    //   9: aload_0
    //   10: getfield 85	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:resourceChangeListener	Lorg/eclipse/core/resources/IResourceChangeListener;
    //   13: invokeinterface 496 2 0
    //   18: goto +4 -> 22
    //   21: pop
    //   22: aload_0
    //   23: getfield 381	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:_pluginSupport	Lcom/crashlytics/tools/ide/android/AndroidPluginSupport;
    //   26: invokevirtual 500	com/crashlytics/tools/ide/android/AndroidPluginSupport:stopPlugin	()V
    //   29: aload_0
    //   30: getfield 396	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:_projectAssemblyListener	Lcom/crashlytics/tools/eclipse/ProjectAssemblyListener;
    //   33: ifnull +12 -> 45
    //   36: aload_0
    //   37: getfield 396	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:_projectAssemblyListener	Lcom/crashlytics/tools/eclipse/ProjectAssemblyListener;
    //   40: invokeinterface 503 1 0
    //   45: aload_0
    //   46: getfield 376	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:_ide	Lcom/crashlytics/tools/eclipse/EclipseIde;
    //   49: ifnull +10 -> 59
    //   52: aload_0
    //   53: getfield 376	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:_ide	Lcom/crashlytics/tools/eclipse/EclipseIde;
    //   56: invokevirtual 508	com/crashlytics/tools/eclipse/EclipseIde:dispose	()V
    //   59: invokestatic 509	com/crashlytics/java/Crashlytics:stopCrashlytics	()V
    //   62: goto +27 -> 89
    //   65: astore_2
    //   66: iconst_4
    //   67: ldc_w 512
    //   70: aload_2
    //   71: invokestatic 270	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:log	(ILjava/lang/String;Ljava/lang/Throwable;)V
    //   74: goto +15 -> 89
    //   77: astore_3
    //   78: aconst_null
    //   79: putstatic 100	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:plugin	Lcom/crashlytics/tools/eclipse/CrashlyticsAdtPlugin;
    //   82: aload_0
    //   83: aload_1
    //   84: invokespecial 514	org/eclipse/core/runtime/Plugin:stop	(Lorg/osgi/framework/BundleContext;)V
    //   87: aload_3
    //   88: athrow
    //   89: aconst_null
    //   90: putstatic 100	com/crashlytics/tools/eclipse/CrashlyticsAdtPlugin:plugin	Lcom/crashlytics/tools/eclipse/CrashlyticsAdtPlugin;
    //   93: aload_0
    //   94: aload_1
    //   95: invokespecial 514	org/eclipse/core/runtime/Plugin:stop	(Lorg/osgi/framework/BundleContext;)V
    //   98: return
    // Line number table:
    //   Java source line #239	-> byte code offset #0
    //   Java source line #240	-> byte code offset #6
    //   Java source line #241	-> byte code offset #18
    //   Java source line #249	-> byte code offset #22
    //   Java source line #250	-> byte code offset #29
    //   Java source line #251	-> byte code offset #36
    //   Java source line #253	-> byte code offset #45
    //   Java source line #254	-> byte code offset #52
    //   Java source line #256	-> byte code offset #59
    //   Java source line #257	-> byte code offset #62
    //   Java source line #258	-> byte code offset #66
    //   Java source line #260	-> byte code offset #74
    //   Java source line #261	-> byte code offset #78
    //   Java source line #262	-> byte code offset #82
    //   Java source line #263	-> byte code offset #87
    //   Java source line #261	-> byte code offset #89
    //   Java source line #262	-> byte code offset #93
    //   Java source line #264	-> byte code offset #98
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	99	0	this	CrashlyticsAdtPlugin
    //   0	99	1	context	BundleContext
    //   65	6	2	e	Exception
    //   77	11	3	localObject	Object
    //   21	1	4	localIllegalStateException	IllegalStateException
    // Exception table:
    //   from	to	target	type
    //   0	18	21	java/lang/IllegalStateException
    //   22	62	65	java/lang/Exception
    //   0	77	77	finally
  }
  
  public EclipseIde getEclipseIde()
  {
    return _ide;
  }
  
  public ProjectAssemblyListener getAssemblyListener()
  {
    return _projectAssemblyListener;
  }
  
  private final WebApi.ApiCallback _apiCallback = new WebApi.ApiCallbackAdapter()
  {
    public void onAuthenticateException(WebApi api, Exception exception)
    {
      CrashlyticsAdtPlugin.log(4, "Error authenticating user", exception);
      onAuthenticated(api, null);
    }
    
    public void onAuthenticated(WebApi api, User user)
    {
      if (user == null)
      {
        CrashlyticsAdtPlugin.log("User set to null");
        _prefs.remove("userEmail");
        _prefs.remove("userName");
        _prefs.remove("userToken");
      }
      else
      {
        CrashlyticsAdtPlugin.log("Authenticated user " + user.getEmail());
        _prefs.put("userEmail", user.getEmail());
        _prefs.put("userName", user.getName());
        _prefs.put("userToken", user.getToken());
      }
      Crashlytics.setString("UserEmail", user.getEmail());
    }
  };
  
  public static CrashlyticsAdtPlugin getDefault()
  {
    return plugin;
  }
  
  public void startUploadingDeobfuscationFiles(long delay)
  {
    _pluginSupport.startUploadingDeobfuscationFiles(_ide, delay);
  }
  
  public boolean getAreNewReleaseNotesAvailable()
  {
    String result = _prefs.get("com.crashlytics.tools.ide.Ide.HAS_UPDATED_RELEASE_NOTES", 
      "false");
    return Boolean.parseBoolean(result);
  }
  
  public void setNewReleaseNotesAvailable(boolean newReleaseNotesAvailable)
  {
    String value = Boolean.toString(newReleaseNotesAvailable);
    _prefs.put("com.crashlytics.tools.ide.Ide.HAS_UPDATED_RELEASE_NOTES", value);
    try
    {
      _prefs.flush();
    }
    catch (BackingStoreException e)
    {
      log(4, "Couldn't flush preferences", e);
    }
  }
  
  private IResourceChangeListener resourceChangeListener = new IResourceChangeListener()
  {
    public void resourceChanged(IResourceChangeEvent event)
    {
      IResource res = event.getResource();
      try
      {
        if ((event.getType() == 4) && (res.getType() == 4))
        {
          IProject proj = (IProject)res;
          if (EclipseIde.isWatchable(proj)) {
            _ide.updateProjects();
          }
        }
        else if (event.getType() == 1)
        {
          IResourceDelta delta = event.getDelta();
          delta.accept(new CrashlyticsAdtPlugin.ProjectVisitor(CrashlyticsAdtPlugin.this));
        }
        else if (event.getType() == 16)
        {
          IResourceDelta delta = event.getDelta();
          delta.accept(new CrashlyticsAdtPlugin.PostBuildProjectVisitor(CrashlyticsAdtPlugin.this, null));
        }
        else if (event.getType() == 8)
        {
          IResourceDelta delta = event.getDelta();
          delta.accept(new CrashlyticsAdtPlugin.PreBuildProjectVisitor(CrashlyticsAdtPlugin.this, null));
        }
      }
      catch (CoreException e)
      {
        DeveloperTools.logE("CoreException in resourceChanged", e);
      }
      catch (Exception e)
      {
        DeveloperTools.logE("Crashlytics could not react to resource change", e);
      }
    }
  };
  
  private class PreBuildProjectVisitor
    extends CrashlyticsAdtPlugin.ProjectAdaptor
  {
    private PreBuildProjectVisitor()
    {
      super();
    }
    
    public boolean visitProject(IProject project, IResourceDelta delta)
    {
      _projectAssemblyListener.preBuild(project);
      return true;
    }
  }
  
  private class PostBuildProjectVisitor
    extends CrashlyticsAdtPlugin.ProjectAdaptor
  {
    private PostBuildProjectVisitor()
    {
      super();
    }
    
    public boolean visitProject(IProject project, IResourceDelta delta)
    {
      _projectAssemblyListener.postBuild(project);
      return true;
    }
  }
  
  class ProjectVisitor
    extends CrashlyticsAdtPlugin.ProjectAdaptor
  {
    ProjectVisitor()
    {
      super();
    }
    
    public boolean visitProject(IProject proj, IResourceDelta delta)
    {
      int flags = delta.getFlags();
      if ((proj.isOpen()) && (!EclipseIde.isWatchable(proj))) {
        return false;
      }
      if (flags > 0) {
        if ((flags & 0x1000) != 0) {
          _ide.updateProjects();
        } else if ((flags & 0x4000) != 0) {
          _ide.updateProjects();
        }
      }
      return true;
    }
  }
  
  abstract class ProjectAdaptor
    implements IResourceDeltaVisitor
  {
    ProjectAdaptor() {}
    
    public boolean visit(IResourceDelta delta)
    {
      IResource res = delta.getResource();
      if (res.getType() == 8) {
        return true;
      }
      if (res.getType() == 4) {
        return visitProject((IProject)res, delta);
      }
      return false;
    }
    
    public abstract boolean visitProject(IProject paramIProject, IResourceDelta paramIResourceDelta);
  }
  
  public static void log(String message)
  {
    log(0, message, null);
  }
  
  public static void log(int severity, String message, Throwable ex)
  {
    if (severity == 2) {
      DeveloperTools.logW(message, ex);
    } else if (severity == 1) {
      DeveloperTools.logI(message);
    } else if (severity == 4) {
      DeveloperTools.logE(message, ex);
    } else {
      DeveloperTools.logD(message);
    }
  }
  
  private static void logAdt(int severity, String message, Throwable ex)
  {
    if ((debugMode) && 
      (ex != null))
    {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      pw.append(ex.toString() + "\n");
      pw.append(ex.getMessage() + "\n");
      ex.printStackTrace(pw);
      message = message + "\nStack trace:\n" + sw.toString();
    }
    CrashlyticsAdtPlugin logPlugin = getDefault();
    ILog pluginLogger = null;
    try
    {
      pluginLogger = logPlugin == null ? null : logPlugin.getLog();
    }
    catch (NullPointerException localNullPointerException) {}
    if ((severity == 0) || (pluginLogger == null))
    {
      if (severity == 4) {
        System.err.println(message);
      } else {
        System.out.println(message);
      }
    }
    else {
      pluginLogger.log(new Status(severity, "com.crashlytics.tools.eclipse.core", message));
    }
  }
  
  private final DeveloperTools.Logger _devToolsLogger = new DeveloperTools.Logger()
  {
    public void logW(String msg, Throwable t)
    {
      CrashlyticsAdtPlugin.logAdt(2, msg, t);
    }
    
    public void logI(String msg)
    {
      CrashlyticsAdtPlugin.logAdt(1, msg, null);
    }
    
    public void logE(String msg, Throwable t)
    {
      CrashlyticsAdtPlugin.logAdt(4, msg, t);
    }
    
    public void logD(String msg)
    {
      CrashlyticsAdtPlugin.logAdt(0, msg, null);
    }
  };
  
  public static boolean isActive(CrashlyticsAdtPlugin plugin)
  {
    return plugin != null;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.CrashlyticsAdtPlugin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import com.crashlytics.api.WebApi;
import com.crashlytics.tools.android.project.AndroidProject;
import com.crashlytics.tools.android.project.DefaultAndroidBuildHandler;

public class EclipseAndroidBuildHandler
  extends DefaultAndroidBuildHandler
{
  private final long _numBuildsSinceLastSend;
  private final boolean _shouldSend;
  
  public EclipseAndroidBuildHandler(WebApi api, AndroidProject androidProject, boolean shouldSend, long numBuildsSinceLastSend)
  {
    super(api, androidProject);
    _shouldSend = shouldSend;
    _numBuildsSinceLastSend = numBuildsSinceLastSend;
  }
  
  public void notifyBuildEvent()
  {
    if (_shouldSend) {
      super.notifyBuildEvent();
    }
  }
  
  protected String getDetails()
  {
    return "NUM_BUILDS=" + _numBuildsSinceLastSend;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.EclipseAndroidBuildHandler
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

public class EclipseBuildHandlerFactory$BuildEventsRecord
{
  private final long _timeForNextSend;
  private final long _numBuildsSinceLastSend;
  
  public EclipseBuildHandlerFactory$BuildEventsRecord(long timeForNextSend, long numBuildsSinceLastSend)
  {
    _timeForNextSend = timeForNextSend;
    _numBuildsSinceLastSend = numBuildsSinceLastSend;
  }
  
  public long getTimeForNextSend()
  {
    return _timeForNextSend;
  }
  
  public long getNumBuildsSinceLastSend()
  {
    return _numBuildsSinceLastSend;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.EclipseBuildHandlerFactory.BuildEventsRecord
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import com.crashlytics.api.WebApi;
import com.crashlytics.tools.android.project.AndroidBuildHandler;
import com.crashlytics.tools.android.project.AndroidProject;
import com.crashlytics.tools.android.project.ManifestData;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public class EclipseBuildHandlerFactory
{
  private static final long THIRTY_MINUTES_IN_MILLIS = TimeUnit.MINUTES.toMillis(30L);
  
  public static class BuildEventsRecord
  {
    private final long _timeForNextSend;
    private final long _numBuildsSinceLastSend;
    
    public BuildEventsRecord(long timeForNextSend, long numBuildsSinceLastSend)
    {
      _timeForNextSend = timeForNextSend;
      _numBuildsSinceLastSend = numBuildsSinceLastSend;
    }
    
    public long getTimeForNextSend()
    {
      return _timeForNextSend;
    }
    
    public long getNumBuildsSinceLastSend()
    {
      return _numBuildsSinceLastSend;
    }
  }
  
  private Map<String, BuildEventsRecord> _buildRecords = new HashMap();
  private long _timeBetweenSends;
  private WebApi _api;
  
  public EclipseBuildHandlerFactory(WebApi api)
  {
    this(THIRTY_MINUTES_IN_MILLIS, api);
  }
  
  public EclipseBuildHandlerFactory(long timeBetweenSends, WebApi api)
  {
    _timeBetweenSends = timeBetweenSends;
    _api = api;
  }
  
  public synchronized AndroidBuildHandler create(AndroidProject project)
  {
    if (project == null) {
      return null;
    }
    String packageName = project.getManifestData().getPackageName();
    BuildEventsRecord record = (BuildEventsRecord)_buildRecords.get(packageName);
    long nextSend;
    long buildCount;
    long nextSend;
    if (record == null)
    {
      long buildCount = 1L;
      nextSend = 0L;
    }
    else
    {
      buildCount = record.getNumBuildsSinceLastSend() + 1L;
      nextSend = record.getTimeForNextSend();
    }
    long currentTime = System.currentTimeMillis();
    long buildCountToSend = buildCount;
    boolean shouldSend = false;
    if (currentTime >= nextSend)
    {
      shouldSend = true;
      nextSend = currentTime + _timeBetweenSends;
      buildCount = 0L;
    }
    _buildRecords.put(packageName, new BuildEventsRecord(nextSend, buildCount));
    return new EclipseAndroidBuildHandler(_api, project, shouldSend, buildCountToSend);
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.EclipseBuildHandlerFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import com.crashlytics.tools.android.DeveloperTools;
import com.crashlytics.tools.android.project.AndroidBuildHandler;
import com.crashlytics.tools.android.project.AndroidProject;
import com.crashlytics.tools.android.project.DeobfuscationManager;
import com.crashlytics.tools.android.project.ResourceUpdateData;
import com.crashlytics.tools.ide.IdeProject;
import com.crashlytics.tools.ide.android.AbstractAndroidIde;
import com.crashlytics.tools.ide.android.AndroidIde;
import java.io.IOException;
import java.util.UUID;
import org.eclipse.core.resources.IProject;

public class EclipseBuildListener
  implements ProjectAssemblyListener
{
  private final AndroidIde _ide;
  private IdeProjectProvider _provider;
  private boolean _exporting = false;
  private EclipseDeobsUploader _deobsUploader;
  
  public EclipseBuildListener(AndroidIde ide, IdeProjectProvider provider, EclipseDeobsUploader deobsUploader)
  {
    _ide = ide;
    _provider = provider;
    _deobsUploader = deobsUploader;
  }
  
  public void preBuild(IProject project)
  {
    if (!_exporting) {
      try
      {
        if (project != null) {
          DeveloperTools.logD("Executing pre-compilation Crashlytics task for " + project.getName() + ".");
        } else {
          DeveloperTools.logD("Executing pre-compilation Crashlytics task.");
        }
        IdeProject ideProject = getIdeProject(project);
        AndroidProject androidProj = createAndroidProject(ideProject);
        
        DeveloperTools.logD("Android project for pre-build is: " + androidProj);
        
        String apiKey = AbstractAndroidIde.getApiKey(androidProj);
        if (apiKey == null) {
          return;
        }
        AndroidBuildHandler buildHandler = _ide.getBuildHandler(androidProj);
        if (buildHandler == null) {
          return;
        }
        UUID buildId = buildHandler.updateBuildResources().getBuildId();
        buildHandler.notifyBuildEvent();
        
        DeveloperTools.logD("Updating Crashlytics-specific resources for " + project.getName() + 
          " (" + buildId + ")");
      }
      catch (IOException e)
      {
        DeveloperTools.logE("Failed to update resources for " + project.getName(), e);
      }
    } else {
      DeveloperTools.logD("Skipped pre-compilation Crashlytics task (during exporting.)");
    }
  }
  
  public void postBuild(IProject project) {}
  
  public void preExport(IProject project)
  {
    DeveloperTools.logD("Executing pre-export Crashlytics task.");
    try
    {
      IdeProject ideProject = getIdeProject(project);
      AndroidProject androidProj = createAndroidProject(ideProject);
      if (AbstractAndroidIde.getApiKey(androidProj) != null)
      {
        AndroidBuildHandler buildHandler = _ide.getBuildHandler(androidProj);
        _exporting = true;
        if (buildHandler != null)
        {
          buildHandler.updateBuildResources();
          
          buildHandler.notifyBuildEvent();
        }
      }
    }
    catch (IOException e)
    {
      DeveloperTools.logE("An error occurred while attempting to update the Crashlytics buildId.", e);
    }
  }
  
  public void postExport(IProject project)
  {
    DeveloperTools.logD("Executing post-export Crashlytics task.");
    try
    {
      IdeProject ideProject = getIdeProject(project);
      
      AndroidProject androidProj = createAndroidProject(ideProject);
      if (AbstractAndroidIde.getApiKey(androidProj) != null)
      {
        DeobfuscationManager buildHandler = _ide.getDeobsManager(androidProj);
        _exporting = false;
        
        _deobsUploader.uploadProguardFile(project, buildHandler);
      }
    }
    catch (IOException e)
    {
      DeveloperTools.logE("An error occurred while attempting to perform the post export task.", e);
    }
  }
  
  private IdeProject getIdeProject(IProject proj)
    throws IOException
  {
    if (proj == null) {
      return null;
    }
    IdeProject ideProj = _provider.findProject(proj);
    return ideProj;
  }
  
  private AndroidProject createAndroidProject(IdeProject project)
    throws IOException
  {
    if (project == null) {
      return null;
    }
    return _ide.createAndroidProject(project);
  }
  
  public void dispose() {}
}

/* Location:
 * Qualified Name:     com.crashlytics.tools.eclipse.EclipseBuildListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.tools.eclipse;

import com.crashlytics.tools.android.project.DeobfuscationManager;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;

public class EclipseDeobsUploader
{
  private CrashlyticsAdtPlugin _plugin;
  
  public EclipseDeobsUploader(CrashlyticsAdtPlugin crashlyticsAdtPlugin)
  {
    _plugin = crashlyticsAdtPlugin;
  }
  
  public void uploadProguardFile(IProject project, DeobfuscationManager deobsManager)
  {
    try
    {
      proguardConfig = new EclipseProguardConfig(project);
    }
    catch (IOException e)
    {
      EclipseProguardConfig proguardConfig;
      CrashlyticsAdtPlugin.log(4, "Crashlytics Build ID Updater could not determine ProGuard usage.", 
        e); return;
    }
    EclipseProguardConfig proguardConfig;
    if (proguardConfig.isObsfucationEnabled())
    {
      File deobsFile = proguardConfig.ge
1 2 3 4

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd