package com.splunk.mint;

import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

class DataFlusher extends BaseExecutor
  implements InterfaceExecutor
{
  private static final int MAX_FILE_SIZE = 3000000;

  public ExecutorService getExecutor()
  {
    if (executor == null)
      executor = Executors.newFixedThreadPool(1);
    return executor;
  }

  public void send()
  {
    try
    {
      Thread localThread = new LowPriorityThreadFactory().newThread(new Runnable()
      {
        public void run()
        {
          if (!Utils.allowedToSendData())
            Logger.logInfo("You have enabled the FlushOnlyOverWiFi option and there is no WiFi connection, data will not be sent now.");
          while ((Properties.FILES_PATH == null) || (Properties.USER_OPTEDOUT))
            return;
          File[] arrayOfFile = new File(Properties.FILES_PATH).listFiles(SplunkFileFilter.getInstance());
          int i = arrayOfFile.length;
          int j = 0;
          label46: File localFile;
          NetSenderResponse localNetSenderResponse;
          if (j < i)
          {
            localFile = arrayOfFile[j];
            localNetSenderResponse = new NetSenderResponse(MintUrls.getURL(), null);
            if (localFile.exists())
              break label106;
            localNetSenderResponse.setException(new Exception("There is no data to be sent. This is not an error."));
            localNetSenderResponse.setSentSuccessfully(Boolean.valueOf(false));
          }
          while (true)
          {
            j++;
            break label46;
            break;
            label106: if (localFile.length() > 3000000L)
            {
              localFile.delete();
              localNetSenderResponse.setException(new Exception("File was too big, this shouldn't have happened since we split the data."));
              localNetSenderResponse.setSentSuccessfully(Boolean.valueOf(false));
            }
            else
            {
              String str1;
              try
              {
                String str2 = Utils.readFile(localFile.getAbsolutePath());
                str1 = str2;
                if ((str1 == null) || (str1.length() == 0))
                {
                  if (Mint.mintCallback == null)
                    continue;
                  Mint.mintCallback.netSenderResponse(localNetSenderResponse);
                }
              }
              catch (Exception localException)
              {
                while (true)
                {
                  localNetSenderResponse.setException(localException);
                  localNetSenderResponse.setSentSuccessfully(Boolean.valueOf(false));
                  localException.printStackTrace();
                  MintCallback localMintCallback = Mint.mintCallback;
                  str1 = null;
                  if (localMintCallback != null)
                  {
                    Mint.mintCallback.netSenderResponse(localNetSenderResponse);
                    str1 = null;
                  }
                }
              }
              if (new NetSender().sendBlocking(null, str1, false).getSentSuccessfully().booleanValue())
                localFile.delete();
            }
          }
        }
      });
      if (getExecutor() != null)
        getExecutor().execute(localThread);
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.splunk.mint.DataFlusher
 * JD-Core Version:    0.6.2
 */